/*global wsAmeCurrentMenuItem*/ (function($) { var currentItem = (typeof wsAmeCurrentMenuItem !== 'undefined') ? wsAmeCurrentMenuItem : {}; //The page heading is typically hardcoded and/or not configurable, so we need to use JS to change it. var customPageHeading = currentItem.hasOwnProperty('customPageHeading') ? currentItem['customPageHeading'] : null; var pageHeadingSelector = currentItem.hasOwnProperty('pageHeadingSelector') ? currentItem['pageHeadingSelector'] : '.wrap > h2:first'; var ameHideHeading = null; if ( customPageHeading ) { //Temporarily hide the heading to prevent the original text from showing up briefly //before being replaced when the DOM is ready (see below). ameHideHeading = $('<style type="text/css">.wrap > h2:first-child,.wrap > h1:first-child { visibility: hidden; }</style>') .appendTo('head'); } jQuery(function($) { var adminMenu = $('#adminmenu'); //Menu separators shouldn't be clickable and should have a custom class. adminMenu .find('.ws-submenu-separator') .closest('a').on('click', function() { return false; }) .closest('li').addClass('ws-submenu-separator-wrap'); //Menus with the target "< None >" also shouldn't be clickable. adminMenu .find( 'a.menu-top.ame-unclickable-menu-item, ul.wp-submenu > li > a[href^="#ame-unclickable-menu-item"]' ) .on('click', function() { //Exception: At small viewport sizes, WordPress changes how top level menus work: clicking a menu //now expands its submenu. We must not ignore that click or it will be impossible to expand the menu. var viewportWidth = Math.max(document.documentElement.clientWidth, window.innerWidth || 0); if ((viewportWidth <= 782) && $(this).closest('li').hasClass('wp-has-submenu')) { return; } //Ignore the click. return false; }); //Open submenus that have the "always open" flag. adminMenu .find('li.ws-ame-has-always-open-submenu.wp-has-submenu') .addClass('wp-has-current-submenu') .removeClass('wp-not-current-submenu'); //Replace the original page heading with the custom heading. if ( customPageHeading ) { function replaceAdminPageHeading(newText) { var headingText = $(pageHeadingSelector) .contents() .filter(function() { //Find text nodes. if ((this.nodeType != 3) || (!this.nodeValue)) { return false; } //Skip whitespace. return /\S/.test(this.nodeValue); }).get(0); if (headingText && headingText.nodeValue) { headingText.nodeValue = newText; } } //Normal headings have at least one tab's worth of trailing whitespace. We need to replicate that //to keep the page layout roughly the same. replaceAdminPageHeading(customPageHeading + '\t'); ameHideHeading.remove(); //Make the heading visible. } }); })(jQuery);
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 |
|