diff --git a/admin_devel/admin_devel.js b/admin_devel/admin_devel.js index 833197a..c60e466 100644 --- a/admin_devel/admin_devel.js +++ b/admin_devel/admin_devel.js @@ -1,7 +1,11 @@ +/** + * @file + */ + (function($) { -/** - * jQuery debugging helper. + /** + * JQuery debugging helper. * * Invented for Dreditor. * @@ -9,32 +13,32 @@ * $.debug(var [, name]); * $variable.debug( [name] ); */ -jQuery.extend({ - debug: function () { - // Setup debug storage in global window. We want to look into it. - window.debug = window.debug || []; + jQuery.extend({ + debug: function () { + // Setup debug storage in global window. We want to look into it. + window.debug = window.debug || []; - args = jQuery.makeArray(arguments); - // Determine data source; this is an object for $variable.debug(). - // Also determine the identifier to store data with. - if (typeof this == 'object') { - var name = (args.length ? args[0] : window.debug.length); - var data = this; - } - else { - var name = (args.length > 1 ? args.pop() : window.debug.length); - var data = args[0]; - } - // Store data. - window.debug[name] = data; - // Dump data into Firebug console. - if (typeof console != 'undefined') { - console.log(name, data); + args = jQuery.makeArray(arguments); + // Determine data source; this is an object for $variable.debug(). + // Also determine the identifier to store data with. + if (typeof this == 'object') { + var name = (args.length ? args[0] : window.debug.length); + var data = this; + } + else { + var name = (args.length > 1 ? args.pop() : window.debug.length); + var data = args[0]; + } + // Store data. + window.debug[name] = data; + // Dump data into Firebug console. + if (typeof console != 'undefined') { + console.log(name, data); + } + return this; } - return this; - } -}); -// @todo Is this the right way? -jQuery.fn.debug = jQuery.debug; + }); + // @todo Is this the right way? + jQuery.fn.debug = jQuery.debug; })(jQuery); diff --git a/admin_menu-rtl.css b/admin_menu-rtl.css index 24116ff..88a81a9 100644 --- a/admin_menu-rtl.css +++ b/admin_menu-rtl.css @@ -1,4 +1,3 @@ - #admin-menu { text-align: right; } @@ -25,7 +24,7 @@ border-right: 0; } #admin-menu .dropdown .admin-menu-tab a { - border-left: 1px solid #52565E; + border-left: 1px solid #52565e; border-right: 0; } #admin-menu .dropdown li li a { @@ -36,8 +35,6 @@ #admin-menu .dropdown li { float: right; } -#admin-menu .dropdown li li { -} /* Second-level lists */ #admin-menu .dropdown li ul { diff --git a/admin_menu.admin.js b/admin_menu.admin.js index 9ee9f36..2fa565e 100644 --- a/admin_menu.admin.js +++ b/admin_menu.admin.js @@ -1,62 +1,66 @@ -(function($) { - /** - * Live preview of Administration menu components. + * @file */ -Drupal.behaviors.adminMenuLivePreview = { - attach: function (context, settings) { - $('input[name^="admin_menu_components"]', context).once('admin-menu-live-preview') - .change(function () { - var target = $(this).attr('rel'); - $(target).toggle(this.checked); - }) - .trigger('change'); - } -}; -/** - * Automatically enables required permissions on demand. - * - * Many users do not understand that two permissions are required for the - * administration menu to appear. Since Drupal core provides no facility for - * this, we implement a simple manual confirmation for automatically enabling - * the "other" permission. - */ -Drupal.behaviors.adminMenuPermissionsSetupHelp = { - attach: function (context, settings) { - $('#permissions', context).once('admin-menu-permissions-setup', function () { - // Retrieve matrix/mapping - these need to use the same indexes for the - // same permissions and roles. - var $roles = $(this).find('th:not(:first)'); - var $admin = $(this).find('input[name$="[access administration pages]"]'); - var $menu = $(this).find('input[name$="[access administration menu]"]'); +(function($) { + + /** + * Live preview of Administration menu components. + */ + Drupal.behaviors.adminMenuLivePreview = { + attach: function (context, settings) { + $('input[name^="admin_menu_components"]', context).once('admin-menu-live-preview') + .change(function () { + var target = $(this).attr('rel'); + $(target).toggle(this.checked); + }) + .trigger('change'); + } + }; + + /** + * Automatically enables required permissions on demand. + * + * Many users do not understand that two permissions are required for the + * administration menu to appear. Since Drupal core provides no facility for + * this, we implement a simple manual confirmation for automatically enabling + * the "other" permission. + */ + Drupal.behaviors.adminMenuPermissionsSetupHelp = { + attach: function (context, settings) { + $('#permissions', context).once('admin-menu-permissions-setup', function () { + // Retrieve matrix/mapping - these need to use the same indexes for the + // same permissions and roles. + var $roles = $(this).find('th:not(:first)'); + var $admin = $(this).find('input[name$="[access administration pages]"]'); + var $menu = $(this).find('input[name$="[access administration menu]"]'); - // Retrieve the permission label - without description. - var adminPermission = $.trim($admin.eq(0).parents('td').prev().children().get(0).firstChild.textContent); - var menuPermission = $.trim($menu.eq(0).parents('td').prev().children().get(0).firstChild.textContent); + // Retrieve the permission label - without description. + var adminPermission = $.trim($admin.eq(0).parents('td').prev().children().get(0).firstChild.textContent); + var menuPermission = $.trim($menu.eq(0).parents('td').prev().children().get(0).firstChild.textContent); - $admin.each(function (index) { - // Only proceed if both are not enabled already. - if (!(this.checked && $menu[index].checked)) { - // Stack both checkboxes and attach a click event handler to both. - $(this).add($menu[index]).click(function () { - // Do nothing when disabling a permission. - if (this.checked) { - // Figure out which is the other, check whether it still disabled, - // and if so, ask whether to auto-enable it. - var other = (this == $admin[index] ? $menu[index] : $admin[index]); - if (!other.checked && confirm(Drupal.t('Also allow !name role to !permission?', { - '!name': $roles[index].textContent, - '!permission': (this == $admin[index] ? menuPermission : adminPermission) - }))) { - other.checked = 'checked'; + $admin.each(function (index) { + // Only proceed if both are not enabled already. + if (!(this.checked && $menu[index].checked)) { + // Stack both checkboxes and attach a click event handler to both. + $(this).add($menu[index]).click(function () { + // Do nothing when disabling a permission. + if (this.checked) { + // Figure out which is the other, check whether it still disabled, + // and if so, ask whether to auto-enable it. + var other = (this == $admin[index] ? $menu[index] : $admin[index]); + if (!other.checked && confirm(Drupal.t('Also allow !name role to !permission?', { + '!name': $roles[index].textContent, + '!permission': (this == $admin[index] ? menuPermission : adminPermission) + }))) { + other.checked = 'checked'; + } } - } - }); - } + }); + } + }); }); - }); - } -}; + } + }; })(jQuery); diff --git a/admin_menu.api.php b/admin_menu.api.php index 2d212fb..e811ef8 100644 --- a/admin_menu.api.php +++ b/admin_menu.api.php @@ -52,10 +52,10 @@ function hook_admin_menu_map() { * - users: The user counter. * Additionally, these special properties: * - #components: The actual components contained in $content are configurable - * and depend on the 'admin_menu_components' configuration value. #components - * holds a copy of that for convenience. - * - #complete: A Boolean indicating whether the complete menu should be built, - * ignoring the current configuration in #components. + * and depend on the 'admin_menu_components' configuration value. + * #components holds a copy of that for convenience. + * - #complete: A Boolean indicating whether the complete menu should be + * built, ignoring the current configuration in #components. * Passed by reference. * * @see hook_admin_menu_output_alter() diff --git a/admin_menu.color.css b/admin_menu.color.css index ea3ef49..00cbf65 100644 --- a/admin_menu.color.css +++ b/admin_menu.color.css @@ -1,4 +1,3 @@ - /** * @file * Administration menu color override. @@ -17,7 +16,7 @@ border-right-color: #a91f1f; } #admin-menu ul li.admin-menu-tab a { - border-right-color: #52565E; + border-right-color: #52565e; } #admin-menu li li a { border-top-color: #801f1f; diff --git a/admin_menu.css b/admin_menu.css index 52ae3ff..42cdbf0 100644 --- a/admin_menu.css +++ b/admin_menu.css @@ -1,4 +1,3 @@ - /** * @file * Administration menu. @@ -62,7 +61,7 @@ body.admin-menu { #admin-menu li > span { background: transparent none; border: none; - color: #EEE; + color: #eee; font-weight: normal; text-align: left; /* LTR */ text-decoration: none; @@ -74,7 +73,7 @@ body.admin-menu { padding: 4px 8px; } #admin-menu .dropdown .admin-menu-tab a { - border-right: 1px solid #52565E; /* LTR */ + border-right: 1px solid #52565e; /* LTR */ } #admin-menu .dropdown li li a { border-right: none; /* LTR */ @@ -147,7 +146,7 @@ body.admin-menu { /* Second-and-more-level hovering */ #admin-menu .dropdown li li.expandable { - background: #45454A url(images/arrow.png) no-repeat 145px 6px; + background: #45454a url(images/arrow.png) no-repeat 145px 6px; } #admin-menu .dropdown li li:hover { background-color: #111; @@ -155,19 +154,19 @@ body.admin-menu { #admin-menu .dropdown li li:hover a, #admin-menu .dropdown li li:hover li:hover a, #admin-menu .dropdown li li:hover li:hover li:hover a { - color: #FFF; + color: #fff; } #admin-menu .dropdown li li.expandable:hover a, #admin-menu .dropdown li li.expandable:hover li.expandable:hover a { border-color: #444; - color: #EEE; + color: #eee; } #admin-menu .dropdown li li.expandable:hover li a, #admin-menu .dropdown li li.expandable:hover li.expandable:hover li a { border-color: #323232; } #admin-menu .dropdown li li:hover li a { - color: #EEE; + color: #eee; } /* Search form */ diff --git a/admin_menu.inc b/admin_menu.inc index 2eab789..91314bc 100644 --- a/admin_menu.inc +++ b/admin_menu.inc @@ -6,9 +6,11 @@ */ /** - * Build the full administration menu tree from static and expanded dynamic items. + * Build the full administration menu tree. * - * @param $menu_name + * The static and expanded dynamic items are used to build the menu tree. + * + * @param string $menu_name * The menu name to use as base for the tree. */ function admin_menu_tree($menu_name) { @@ -50,11 +52,11 @@ function admin_menu_tree($menu_name) { /** * Load menu link trees for router paths containing dynamic arguments. * - * @param $expand_map + * @param array $expand_map * An array containing menu router path placeholder expansion argument * mappings. * - * @return + * @return array * An associative array whose keys are the parent paths of the menu router * paths given in $expand_map as well as the parent paths of any child link * deeper down the tree. The parent paths are used in admin_menu_merge_tree() @@ -97,7 +99,7 @@ function admin_menu_tree_dynamic(array $expand_map) { $db_or = db_or(); foreach ($plids as $path_plids) { $db_and = db_and(); - // plids with value 0 may be ignored. + // Plids with value 0 may be ignored. foreach (array_filter($path_plids) as $column => $plid) { $db_and->condition($column, $plid); } @@ -134,11 +136,11 @@ function admin_menu_tree_dynamic(array $expand_map) { /** * Walk through the entire menu tree and merge in expanded dynamic menu links. * - * @param &$tree + * @param array &$tree * A menu tree structure as returned by menu_tree_all_data(). - * @param $tree_dynamic + * @param array $tree_dynamic * A dynamic menu tree structure as returned by admin_menu_tree_dynamic(). - * @param $expand_map + * @param array $expand_map * An array containing menu router path placeholder expansion argument * mappings. * @@ -249,9 +251,9 @@ function admin_menu_merge_tree(array &$tree, array $tree_dynamic, array $expand_ /** * Translate an expanded router item into a menu link suitable for rendering. * - * @param $router_item + * @param array $router_item * A menu router item. - * @param $map + * @param array $map * A path map with placeholders replaced. */ function admin_menu_translate($router_item, $map) { @@ -269,7 +271,7 @@ function admin_menu_translate($router_item, $map) { // replace any other. // @todo Doing this instead leads to plenty of duplicate links below // admin/structure/menu; likely a hidden recursion problem. - // $router_item['mlid'] = $router_item['href'] . $router_item['mlid']; + // $router_item['mlid'] = $router_item['href'] . $router_item['mlid'];. $router_item['mlid'] = $router_item['href']; // Turn menu callbacks into regular menu items to make them visible. if ($router_item['type'] == MENU_CALLBACK) { @@ -278,10 +280,12 @@ function admin_menu_translate($router_item, $map) { // @see _menu_tree_check_access() $key = (50000 + $router_item['weight']) . ' ' . $router_item['title'] . ' ' . $router_item['mlid']; - return array($key => array( - 'link' => $router_item, - 'below' => array(), - )); + return array( + $key => array( + 'link' => $router_item, + 'below' => array(), + ), + ); } return array(); @@ -290,7 +294,7 @@ function admin_menu_translate($router_item, $map) { /** * Create the cartesian product of multiple varying sized argument arrays. * - * @param $arguments + * @param array $arguments * A two dimensional array of arguments. * * @see hook_admin_menu_map() @@ -347,11 +351,11 @@ function admin_menu_expand_args($arguments) { /** * Build the administration menu as renderable menu links. * - * @param $tree + * @param array $tree * A data structure representing the administration menu tree as returned from * menu_tree_all_data(). * - * @return + * @return array * The complete administration menu, suitable for theme_admin_menu_links(). * * @see theme_admin_menu_links() @@ -690,7 +694,9 @@ function admin_menu_theme_settings() { } /** - * #process callback for component plugin form element in admin_menu_theme_settings(). + * Process callback for component plugin form element. + * + * This is called in admin_menu_theme_settings(). */ function admin_menu_settings_process_components($element) { // Assign 'rel' attributes to all options to achieve a live preview. @@ -716,7 +722,7 @@ function admin_menu_theme_settings_validate(&$form, &$form_state) { } /** - * Implementation of hook_form_FORM_ID_alter(). + * Implements hook_form_FORM_ID_alter(). * * Extends Devel module with Administration menu developer settings. */ @@ -732,7 +738,12 @@ function _admin_menu_form_devel_admin_settings_alter(&$form, $form_state) { '#collapsed' => TRUE, ); $display_options = array('mid', 'weight', 'pid'); - $display_options = array(0 => t('None'), 'mlid' => t('Menu link ID'), 'weight' => t('Weight'), 'plid' => t('Parent link ID')); + $display_options = array( + 0 => t('None'), + 'mlid' => t('Menu link ID'), + 'weight' => t('Weight'), + 'plid' => t('Parent link ID'), + ); $form['admin_menu']['admin_menu_display'] = array( '#type' => 'radios', '#title' => t('Display additional data for each menu item'), @@ -751,7 +762,7 @@ function _admin_menu_form_devel_admin_settings_alter(&$form, $form_state) { /** * Flush all caches or a specific one. * - * @param $name + * @param string $name * (optional) Name of cache to flush. */ function admin_menu_flush_cache($name = NULL) { @@ -827,7 +838,7 @@ function update_admin_menu_cache_info() { /** * Flush all caches or a specific one. * - * @param $name + * @param string $name * (optional) Name of cache to flush. * * @see system_admin_menu_cache_info() @@ -907,4 +918,3 @@ function template_preprocess_admin_menu_icon(&$variables) { function theme_admin_menu_icon($variables) { return ''; } - diff --git a/admin_menu.js b/admin_menu.js index 2e28b55..164a728 100644 --- a/admin_menu.js +++ b/admin_menu.js @@ -1,39 +1,43 @@ +/** + * @file + */ + (function($) { -Drupal.admin = Drupal.admin || {}; -Drupal.admin.behaviors = Drupal.admin.behaviors || {}; -Drupal.admin.hashes = Drupal.admin.hashes || {}; + Drupal.admin = Drupal.admin || {}; + Drupal.admin.behaviors = Drupal.admin.behaviors || {}; + Drupal.admin.hashes = Drupal.admin.hashes || {}; -/** - * Core behavior for Administration menu. - * - * Test whether there is an administration menu is in the output and execute all - * registered behaviors. - */ -Drupal.behaviors.adminMenu = { - attach: function (context, settings) { - // Initialize settings. - settings.admin_menu = $.extend({ - suppress: false, - margin_top: false, - position_fixed: false, - tweak_modules: false, - tweak_permissions: false, - tweak_tabs: false, - destination: '', - basePath: settings.basePath, - hash: 0, - replacements: {} - }, settings.admin_menu || {}); - // Check whether administration menu should be suppressed. - if (settings.admin_menu.suppress) { - return; - } - var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context); - // Client-side caching; if administration menu is not in the output, it is - // fetched from the server and cached in the browser. - if (!$adminMenu.length && settings.admin_menu.hash) { - Drupal.admin.getCache(settings.admin_menu.hash, function (response) { + /** + * Core behavior for Administration menu. + * + * Test whether there is an administration menu is in the output and execute all + * registered behaviors. + */ + Drupal.behaviors.adminMenu = { + attach: function (context, settings) { + // Initialize settings. + settings.admin_menu = $.extend({ + suppress: false, + margin_top: false, + position_fixed: false, + tweak_modules: false, + tweak_permissions: false, + tweak_tabs: false, + destination: '', + basePath: settings.basePath, + hash: 0, + replacements: {} + }, settings.admin_menu || {}); + // Check whether administration menu should be suppressed. + if (settings.admin_menu.suppress) { + return; + } + var $adminMenu = $('#admin-menu:not(.admin-menu-processed)', context); + // Client-side caching; if administration menu is not in the output, it is + // fetched from the server and cached in the browser. + if (!$adminMenu.length && settings.admin_menu.hash) { + Drupal.admin.getCache(settings.admin_menu.hash, function (response) { if (typeof response == 'string' && response.length > 0) { $('body', context).append(response); } @@ -42,74 +46,74 @@ Drupal.behaviors.adminMenu = { Drupal.admin.attachBehaviors(context, settings, $adminMenu); // Allow resize event handlers to recalculate sizes/positions. $(window).triggerHandler('resize'); - }); - } - // If the menu is in the output already, this means there is a new version. - else { - // Apply our behaviors. - Drupal.admin.attachBehaviors(context, settings, $adminMenu); + }); + } + // If the menu is in the output already, this means there is a new version. + else { + // Apply our behaviors. + Drupal.admin.attachBehaviors(context, settings, $adminMenu); + } } - } -}; + }; -/** - * Collapse fieldsets on Modules page. - */ -Drupal.behaviors.adminMenuCollapseModules = { - attach: function (context, settings) { - if (settings.admin_menu.tweak_modules) { - $('#system-modules fieldset:not(.collapsed)', context).addClass('collapsed'); + /** + * Collapse fieldsets on Modules page. + */ + Drupal.behaviors.adminMenuCollapseModules = { + attach: function (context, settings) { + if (settings.admin_menu.tweak_modules) { + $('#system-modules fieldset:not(.collapsed)', context).addClass('collapsed'); + } } - } -}; + }; -/** - * Collapse modules on Permissions page. - */ -Drupal.behaviors.adminMenuCollapsePermissions = { - attach: function (context, settings) { - if (settings.admin_menu.tweak_permissions) { - // Freeze width of first column to prevent jumping. - $('#permissions th:first', context).css({ width: $('#permissions th:first', context).width() }); - // Attach click handler. - $modules = $('#permissions tr:has(td.module)', context).once('admin-menu-tweak-permissions', function () { - var $module = $(this); - $module.bind('click.admin-menu', function () { - // @todo Replace with .nextUntil() in jQuery 1.4. - $module.nextAll().each(function () { - var $row = $(this); - if ($row.is(':has(td.module)')) { - return false; - } - $row.toggleClass('element-hidden'); + /** + * Collapse modules on Permissions page. + */ + Drupal.behaviors.adminMenuCollapsePermissions = { + attach: function (context, settings) { + if (settings.admin_menu.tweak_permissions) { + // Freeze width of first column to prevent jumping. + $('#permissions th:first', context).css({ width: $('#permissions th:first', context).width() }); + // Attach click handler. + $modules = $('#permissions tr:has(td.module)', context).once('admin-menu-tweak-permissions', function () { + var $module = $(this); + $module.bind('click.admin-menu', function () { + // @todo Replace with .nextUntil() in jQuery 1.4. + $module.nextAll().each(function () { + var $row = $(this); + if ($row.is(':has(td.module)')) { + return false; + } + $row.toggleClass('element-hidden'); + }); }); }); - }); - // Collapse all but the targeted permission rows set. - if (window.location.hash.length) { - $modules = $modules.not(':has(' + window.location.hash + ')'); + // Collapse all but the targeted permission rows set. + if (window.location.hash.length) { + $modules = $modules.not(':has(' + window.location.hash + ')'); + } + $modules.trigger('click.admin-menu'); } - $modules.trigger('click.admin-menu'); } - } -}; + }; -/** - * Apply margin to page. - * - * Note that directly applying marginTop does not work in IE. To prevent - * flickering/jumping page content with client-side caching, this is a regular - * Drupal behavior. - */ -Drupal.behaviors.adminMenuMarginTop = { - attach: function (context, settings) { - if (!settings.admin_menu.suppress && settings.admin_menu.margin_top) { - $('body:not(.admin-menu)', context).addClass('admin-menu'); + /** + * Apply margin to page. + * + * Note that directly applying marginTop does not work in IE. To prevent + * flickering/jumping page content with client-side caching, this is a regular + * Drupal behavior. + */ + Drupal.behaviors.adminMenuMarginTop = { + attach: function (context, settings) { + if (!settings.admin_menu.suppress && settings.admin_menu.margin_top) { + $('body:not(.admin-menu)', context).addClass('admin-menu'); + } } - } -}; + }; -/** + /** * Retrieve content from client-side cache. * * @param hash @@ -117,110 +121,112 @@ Drupal.behaviors.adminMenuMarginTop = { * @param onSuccess * A callback function invoked when the cache request was successful. */ -Drupal.admin.getCache = function (hash, onSuccess) { - if (Drupal.admin.hashes.hash !== undefined) { - return Drupal.admin.hashes.hash; - } - $.ajax({ - cache: true, - type: 'GET', - dataType: 'text', // Prevent auto-evaluation of response. - global: false, // Do not trigger global AJAX events. - url: Drupal.settings.admin_menu.basePath.replace(/admin_menu/, 'js/admin_menu/cache/' + hash), - success: onSuccess, - complete: function (XMLHttpRequest, status) { - Drupal.admin.hashes.hash = status; + Drupal.admin.getCache = function (hash, onSuccess) { + if (Drupal.admin.hashes.hash !== undefined) { + return Drupal.admin.hashes.hash; } - }); -}; + $.ajax({ + cache: true, + type: 'GET', + // Prevent auto-evaluation of response. + dataType: 'text', + // Do not trigger global AJAX events. + global: false, + url: Drupal.settings.admin_menu.basePath.replace(/admin_menu/, 'js/admin_menu/cache/' + hash), + success: onSuccess, + complete: function (XMLHttpRequest, status) { + Drupal.admin.hashes.hash = status; + } + }); + }; -/** + /** * TableHeader callback to determine top viewport offset. * * @see toolbar.js */ -Drupal.admin.height = function() { - var $adminMenu = $('#admin-menu'); - var height = $adminMenu.outerHeight(); - // In IE, Shadow filter adds some extra height, so we need to remove it from - // the returned height. - if ($adminMenu.css('filter') && $adminMenu.css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) { - height -= $adminMenu.get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength; - } - return height; -}; + Drupal.admin.height = function() { + var $adminMenu = $('#admin-menu'); + var height = $adminMenu.outerHeight(); + // In IE, Shadow filter adds some extra height, so we need to remove it from + // the returned height. + if ($adminMenu.css('filter') && $adminMenu.css('filter').match(/DXImageTransform\.Microsoft\.Shadow/)) { + height -= $adminMenu.get(0).filters.item("DXImageTransform.Microsoft.Shadow").strength; + } + return height; + }; -/** + /** * @defgroup admin_behaviors Administration behaviors. * @{ */ -/** + /** * Attach administrative behaviors. */ -Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) { - if ($adminMenu.length) { - $adminMenu.addClass('admin-menu-processed'); - $.each(Drupal.admin.behaviors, function() { - this(context, settings, $adminMenu); - }); - } -}; + Drupal.admin.attachBehaviors = function (context, settings, $adminMenu) { + if ($adminMenu.length) { + $adminMenu.addClass('admin-menu-processed'); + $.each(Drupal.admin.behaviors, function() { + this(context, settings, $adminMenu); + }); + } + }; -/** + /** * Apply 'position: fixed'. */ -Drupal.admin.behaviors.positionFixed = function (context, settings, $adminMenu) { - if (settings.admin_menu.position_fixed) { - $adminMenu.addClass('admin-menu-position-fixed'); - $adminMenu.css('position', 'fixed'); - } -}; + Drupal.admin.behaviors.positionFixed = function (context, settings, $adminMenu) { + if (settings.admin_menu.position_fixed) { + $adminMenu.addClass('admin-menu-position-fixed'); + $adminMenu.css('position', 'fixed'); + } + }; -/** + /** * Move page tabs into administration menu. */ -Drupal.admin.behaviors.pageTabs = function (context, settings, $adminMenu) { - if (settings.admin_menu.tweak_tabs) { - var $tabs = $(context).find('ul.tabs.primary'); - $adminMenu.find('#admin-menu-wrapper > ul').eq(1) - .append($tabs.find('li').addClass('admin-menu-tab')); - $(context).find('ul.tabs.secondary') - .appendTo('#admin-menu-wrapper > ul > li.admin-menu-tab.active') - .removeClass('secondary'); - $tabs.remove(); - } -}; + Drupal.admin.behaviors.pageTabs = function (context, settings, $adminMenu) { + if (settings.admin_menu.tweak_tabs) { + var $tabs = $(context).find('ul.tabs.primary'); + $adminMenu.find('#admin-menu-wrapper > ul').eq(1) + .append($tabs.find('li').addClass('admin-menu-tab')); + $(context).find('ul.tabs.secondary') + .appendTo('#admin-menu-wrapper > ul > li.admin-menu-tab.active') + .removeClass('secondary'); + $tabs.remove(); + } + }; -/** + /** * Perform dynamic replacements in cached menu. */ -Drupal.admin.behaviors.replacements = function (context, settings, $adminMenu) { - for (var item in settings.admin_menu.replacements) { - $(item, $adminMenu).html(settings.admin_menu.replacements[item]); - } -}; + Drupal.admin.behaviors.replacements = function (context, settings, $adminMenu) { + for (var item in settings.admin_menu.replacements) { + $(item, $adminMenu).html(settings.admin_menu.replacements[item]); + } + }; -/** + /** * Inject destination query strings for current page. */ -Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) { - if (settings.admin_menu.destination) { - $('a.admin-menu-destination', $adminMenu).each(function() { - this.search += (!this.search.length ? '?' : '&') + Drupal.settings.admin_menu.destination; - }); - } -}; + Drupal.admin.behaviors.destination = function (context, settings, $adminMenu) { + if (settings.admin_menu.destination) { + $('a.admin-menu-destination', $adminMenu).each(function() { + this.search += (!this.search.length ? '?' : '&') + Drupal.settings.admin_menu.destination; + }); + } + }; -/** + /** * Apply JavaScript-based hovering behaviors. * * @todo This has to run last. If another script registers additional behaviors * it will not run last. */ -Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) { - // Delayed mouseout. - $('li.expandable', $adminMenu).hover( + Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) { + // Delayed mouseout. + $('li.expandable', $adminMenu).hover( function () { // Stop the timer. clearTimeout(this.sfTimer); @@ -237,148 +243,148 @@ Drupal.admin.behaviors.hover = function (context, settings, $adminMenu) { uls.css({left: '-999em', display: 'none'}); }, 400); } - ); -}; + ); + }; -/** + /** * Apply the search bar functionality. */ -Drupal.admin.behaviors.search = function (context, settings, $adminMenu) { - // @todo Add a HTML ID. - var $input = $('input.admin-menu-search', $adminMenu); - // Initialize the current search needle. - var needle = $input.val(); - // Cache of all links that can be matched in the menu. - var links; - // Minimum search needle length. - var needleMinLength = 2; - // Append the results container. - var $results = $('
').insertAfter($input); + Drupal.admin.behaviors.search = function (context, settings, $adminMenu) { + // @todo Add a HTML ID. + var $input = $('input.admin-menu-search', $adminMenu); + // Initialize the current search needle. + var needle = $input.val(); + // Cache of all links that can be matched in the menu. + var links; + // Minimum search needle length. + var needleMinLength = 2; + // Append the results container. + var $results = $('').insertAfter($input); - /** - * Executes the search upon user input. - */ - function keyupHandler() { - var matches, $html, value = $(this).val(); - // Only proceed if the search needle has changed. - if (value !== needle) { - needle = value; - // Initialize the cache of menu links upon first search. - if (!links && needle.length >= needleMinLength) { - // @todo Limit to links in dropdown menus; i.e., skip menu additions. - links = buildSearchIndex($adminMenu.find('li:not(.admin-menu-action, .admin-menu-action li) > a')); - } - // Empty results container when deleting search text. - if (needle.length < needleMinLength) { - $results.empty(); - } - // Only search if the needle is long enough. - if (needle.length >= needleMinLength && links) { - matches = findMatches(needle, links); - // Build the list in a detached DOM node. - $html = buildResultsList(matches); - // Display results. - $results.empty().append($html); + /** + * Executes the search upon user input. + */ + function keyupHandler() { + var matches, $html, value = $(this).val(); + // Only proceed if the search needle has changed. + if (value !== needle) { + needle = value; + // Initialize the cache of menu links upon first search. + if (!links && needle.length >= needleMinLength) { + // @todo Limit to links in dropdown menus; i.e., skip menu additions. + links = buildSearchIndex($adminMenu.find('li:not(.admin-menu-action, .admin-menu-action li) > a')); + } + // Empty results container when deleting search text. + if (needle.length < needleMinLength) { + $results.empty(); + } + // Only search if the needle is long enough. + if (needle.length >= needleMinLength && links) { + matches = findMatches(needle, links); + // Build the list in a detached DOM node. + $html = buildResultsList(matches); + // Display results. + $results.empty().append($html); + } } } - } - /** - * Builds the search index. - */ - function buildSearchIndex($links) { - return $links - .map(function () { - var text = (this.textContent || this.innerText); - // Skip menu entries that do not contain any text (e.g., the icon). - if (typeof text === 'undefined') { - return; - } - return { - text: text, - textMatch: text.toLowerCase(), - element: this - }; - }); - } + /** + * Builds the search index. + */ + function buildSearchIndex($links) { + return $links + .map(function () { + var text = (this.textContent || this.innerText); + // Skip menu entries that do not contain any text (e.g., the icon). + if (typeof text === 'undefined') { + return; + } + return { + text: text, + textMatch: text.toLowerCase(), + element: this + }; + }); + } - /** - * Searches the index for a given needle and returns matching entries. - */ - function findMatches(needle, links) { - var needleMatch = needle.toLowerCase(); - // Select matching links from the cache. - return $.grep(links, function (link) { - return link.textMatch.indexOf(needleMatch) !== -1; - }); - } + /** + * Searches the index for a given needle and returns matching entries. + */ + function findMatches(needle, links) { + var needleMatch = needle.toLowerCase(); + // Select matching links from the cache. + return $.grep(links, function (link) { + return link.textMatch.indexOf(needleMatch) !== -1; + }); + } - /** - * Builds the search result list in a detached DOM node. - */ - function buildResultsList(matches) { - var $html = $(' '); - $.each(matches, function () { - var result = this.text; - var $element = $(this.element); + /** + * Builds the search result list in a detached DOM node. + */ + function buildResultsList(matches) { + var $html = $(' '); + $.each(matches, function () { + var result = this.text; + var $element = $(this.element); - // Check whether there is a top-level category that can be prepended. - var $category = $element.closest('#admin-menu-wrapper > ul > li'); - var categoryText = $category.find('> a').text() - if ($category.length && categoryText) { - result = categoryText + ': ' + result; - } + // Check whether there is a top-level category that can be prepended. + var $category = $element.closest('#admin-menu-wrapper > ul > li'); + var categoryText = $category.find('> a').text() + if ($category.length && categoryText) { + result = categoryText + ': ' + result; + } - var $result = $('