jQuery(function ($) { var menuEditorHeading = $('#ws_ame_editor_heading').first(); var pageWrapper = menuEditorHeading.closest('.wrap'); var tabList = pageWrapper.find('.nav-tab-wrapper').first(); //On AME pages, move settings tabs after the heading. This is necessary to make them appear on the right side, //and WordPress breaks that by moving notices like "Settings saved" after the first H1 (see common.js). var menuEditorTabs = tabList.add(tabList.next('.clear')); if ((menuEditorHeading.length > 0) && (menuEditorTabs.length > 0)) { menuEditorTabs.insertAfter(menuEditorHeading); } //Switch tab styles when there are too many tabs and they don't fit on one row. var $firstTab = null, $lastTab = null, knownTabWrapThreshold = -1; function updateTabStyles() { if (($firstTab === null) || ($lastTab === null)) { var $tabItems = tabList.children('.nav-tab'); $firstTab = $tabItems.first(); $lastTab = $tabItems.last(); } //To detect if any tabs are wrapped to the next row, check if the top of the last tab //is below the bottom of the first tab. var firstPosition = $firstTab.position(); var lastPosition = $lastTab.position(); var windowWidth = $(window).width(); //Sanity check. if ( !firstPosition || !lastPosition || !windowWidth || (typeof firstPosition['top'] === 'undefined') || (typeof lastPosition['top'] === 'undefined') ) { return; } var firstTabBottom = firstPosition.top + $firstTab.outerHeight(); var areTabsWrapped = (lastPosition.top >= firstTabBottom); //Tab positions may change when we apply different styles, which could lead to the tab bar //rapidly cycling between one and two two rows when the browser width is just right. //To prevent that, remember what the width was when we detected wrapping, and always apply //the alternative styles if the width is lower than that. var wouldWrapByDefault = (windowWidth <= knownTabWrapThreshold); var tooManyTabs = areTabsWrapped || wouldWrapByDefault; if (tooManyTabs && (windowWidth > knownTabWrapThreshold)) { knownTabWrapThreshold = windowWidth; } pageWrapper.toggleClass('ws-ame-too-many-tabs', tooManyTabs); } updateTabStyles(); $(window).on('resize', wsAmeLodash.debounce( function () { updateTabStyles(); }, 300 )); });
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
actor-manager.js | File | 32.62 KB | 0644 |
|
actor-manager.js.map | File | 24.64 KB | 0644 |
|
actor-manager.ts | File | 32.81 KB | 0644 |
|
admin-helpers.js | File | 2.78 KB | 0644 |
|
common.d.ts | File | 2.72 KB | 0644 |
|
jquery-json.d.ts | File | 109 B | 0644 |
|
jquery.biscuit.d.ts | File | 455 B | 0644 |
|
jquery.biscuit.js | File | 5.37 KB | 0644 |
|
jquery.color.d.ts | File | 5.06 KB | 0644 |
|
jquery.d.ts | File | 146.39 KB | 0644 |
|
jquery.form.d.ts | File | 804 B | 0644 |
|
jquery.form.js | File | 40.93 KB | 0644 |
|
jquery.json.js | File | 5.13 KB | 0644 |
|
jquery.qtip.js | File | 100.34 KB | 0644 |
|
jquery.qtip.min.js | File | 43.23 KB | 0644 |
|
jquery.sort.js | File | 1.92 KB | 0644 |
|
jqueryui.d.ts | File | 77.89 KB | 0644 |
|
knockout-sortable.js | File | 22.49 KB | 0644 |
|
knockout.d.ts | File | 42.65 KB | 0644 |
|
knockout.js | File | 66.65 KB | 0644 |
|
lazyload.d.ts | File | 10.2 KB | 0644 |
|
lazyload.min.js | File | 8.1 KB | 0644 |
|
lodash4.min.js | File | 71.54 KB | 0644 |
|
menu-editor.d.ts | File | 662 B | 0644 |
|
menu-editor.js | File | 185.29 KB | 0644 |
|
menu-highlight-fix.js | File | 11.12 KB | 0644 |
|
mini-func.js | File | 4.75 KB | 0644 |
|
mini-func.js.map | File | 4.1 KB | 0644 |
|
mini-func.ts | File | 5.02 KB | 0644 |
|
tab-utils.js | File | 2.25 KB | 0644 |
|