[open-ils-commits] [GIT] Evergreen ILS branch master updated. a7243f4497ddcb42c39188e6c82c879020e95eff

Evergreen Git git at git.evergreen-ils.org
Tue Mar 6 10:37:15 EST 2012


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Evergreen ILS".

The branch, master has been updated
       via  a7243f4497ddcb42c39188e6c82c879020e95eff (commit)
      from  4bbe4a9636490c587ca763fb0aedcbf29f33d8a8 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit a7243f4497ddcb42c39188e6c82c879020e95eff
Author: Thomas Berezansky <tsbere at mvlc.org>
Date:   Mon Mar 5 16:14:43 2012 -0500

    Add locale-aware menu sort, use it for admin menu
    
    Sort function can do recursive sorting and is menuseparator aware, sorting
    within blocks defined by menuseparators.
    
    Note: If a menu item has forceFirst set as an attribute it will be put in
    front of the current sort group. So far this is only used to keep the
    operator change menu item at the top of the admin menu.
    
    Signed-off-by: Thomas Berezansky <tsbere at mvlc.org>
    Signed-off-by: Jason Etheridge <jason at esilibrary.com>

diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu.js b/Open-ILS/xul/staff_client/chrome/content/main/menu.js
index e84ffac..bc1e834 100644
--- a/Open-ILS/xul/staff_client/chrome/content/main/menu.js
+++ b/Open-ILS/xul/staff_client/chrome/content/main/menu.js
@@ -1696,6 +1696,9 @@ main.menu.prototype = {
         obj.controller.view.tabs = window.document.getElementById('main_tabs');
         obj.controller.view.panels = window.document.getElementById('main_panels');
         obj.controller.view.tabscroller = window.document.getElementById('main_tabs_scrollbox');
+
+        obj.sort_menu(document.getElementById('main.menu.admin'), true);
+
         if(params['firstURL']) {
             obj.new_tab(params['firstURL'],{'focus':true},null);
         }
@@ -2465,6 +2468,45 @@ commands:
             return "user_false";
     },
 
+    'sort_menu' : function(menu, recurse) {
+        var curgroup = new Array();
+        var curstart = 1;
+        var curordinal = 0;
+        for (var itemid = 0; itemid < menu.firstChild.children.length; itemid++) {
+            var item = menu.firstChild.children[itemid];
+            curordinal++;
+            if (item.getAttribute('forceFirst')) {
+                item.setAttribute('ordinal', curstart);
+                curstart++;
+                continue;
+            }
+            if (item.nodeName == 'menuseparator') {
+                this.sort_menu_items(curgroup, curstart);
+                item.setAttribute('ordinal', curordinal);
+                curstart = curordinal + 1;
+                curgroup = new Array();
+                continue;
+            }
+            if (item.nodeName == 'menu' && recurse) {
+                this.sort_menu(item, recurse);
+            }
+            curgroup.push(item);
+        }
+        this.sort_menu_items(curgroup, curstart);
+    },
+
+    'sort_menu_items' : function(itemgroup, start) {
+        var curpos = start;
+        var sorted = itemgroup.sort(function(a,b) {
+            var labelA = a.getAttribute('label').toUpperCase();
+            var labelB = b.getAttribute('label').toUpperCase();
+            return labelA.localeCompare(labelB);
+        });
+        for(var item = 0; item < sorted.length; item++) {
+            sorted[item].setAttribute('ordinal', curpos++);
+        }
+    },
+
     'observe' : function(subject, topic, data) {
         if (topic != "nsPref:changed") {
             return;
diff --git a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
index c12c245..3b37a62 100644
--- a/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
+++ b/Open-ILS/xul/staff_client/chrome/content/main/menu_frame_menus.xul
@@ -424,7 +424,7 @@
 <menu id="main.menu.admin" label="&staff.main.menu.admin.label;" accesskey="&staff.main.menu.admin.accesskey;">
     <menupopup id="main.menu.admin.popup">
         <menuitem id="oc_menuitem" label="&staff.main.menu.admin.change_session.label;" label_orig="&staff.main.menu.admin.change_session.label;" 
-            accesskey="O" command="cmd_change_session"/>
+            accesskey="O" command="cmd_change_session" forceFirst="true"/>
         <menuitem label="&staff.main.menu.admin.offline_xacts.label;" accesskey="&staff.main.menu.admin.offline_xacts.accesskey;" command="cmd_manage_offline_xacts"/>
         <menuitem label="&staff.main.menu.admin.download_patrons.label;" accesskey="&staff.main.menu.admin.download_patrons.accesskey;" command="cmd_download_patrons"/>
         <menuseparator />

-----------------------------------------------------------------------

Summary of changes:
 .../xul/staff_client/chrome/content/main/menu.js   |   42 ++++++++++++++++++++
 .../chrome/content/main/menu_frame_menus.xul       |    2 +-
 2 files changed, 43 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
Evergreen ILS


More information about the open-ils-commits mailing list