From 35f6fac70bf464c56b16886be88bc15c7bbd3701 Mon Sep 17 00:00:00 2001 From: erickson Date: Thu, 30 Oct 2008 13:49:34 +0000 Subject: [PATCH] added add/remove css functions to util class (didn't see such a beast in dojo). apply some css to the selected menu option git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_4@10984 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/web/js/dojo/openils/Util.js | 45 +++++++++++++++++++++++++++++++++++ Open-ILS/web/vandelay/inc/toolbar.xml | 9 ++++--- Open-ILS/web/vandelay/vandelay.css | 1 + Open-ILS/web/vandelay/vandelay.js | 21 ++++++++++++++++ 4 files changed, 71 insertions(+), 5 deletions(-) diff --git a/Open-ILS/web/js/dojo/openils/Util.js b/Open-ILS/web/js/dojo/openils/Util.js index 904caa5f1a..83ec5af559 100644 --- a/Open-ILS/web/js/dojo/openils/Util.js +++ b/Open-ILS/web/js/dojo/openils/Util.js @@ -118,4 +118,49 @@ if(!dojo._hasResource["openils.Util"]) { return val; }; + + /** + * Given a DOM node, adds the provided class to the node + */ + openils.Util.addCSSClass = function(node, cls) { + if(!(node && cls)) return; + var className = node.className; + + if(!className) { + node.className = cls; + return; + } + + var classList = className.split(/\s+/); + var newName = ''; + + for (var i = 0; i < classList.length; i++) { + if(classList[i] == cls) return; + if(classList[i] != null) + newName += classList[i] + " "; + } + + newName += cls; + node.className = newName; + }, + + /** + * Given a DOM node, removes the provided class from the CSS class + * name list. + */ + openils.Util.removeCSSClass = function(node, cls) { + if(!(node && cls && node.className)) return; + var classList = node.className.split(/\s+/); + var className = ''; + for(var i = 0; i < classList.length; i++) { + if (classList[i] != cls) { + if(i == 0) + className = classList[i]; + else + className += ' ' + classList[i]; + } + } + node.className = className; + } + } diff --git a/Open-ILS/web/vandelay/inc/toolbar.xml b/Open-ILS/web/vandelay/inc/toolbar.xml index ad067d891c..6bf3b3993f 100644 --- a/Open-ILS/web/vandelay/inc/toolbar.xml +++ b/Open-ILS/web/vandelay/inc/toolbar.xml @@ -1,11 +1,10 @@
-
&vandelay.export.records;
-
&vandelay.import.records;
-
&vandelay.inspect.queue;
-
&vandelay.edit.attributes;
- diff --git a/Open-ILS/web/vandelay/vandelay.css b/Open-ILS/web/vandelay/vandelay.css index 27831fb46a..17c2491c85 100644 --- a/Open-ILS/web/vandelay/vandelay.css +++ b/Open-ILS/web/vandelay/vandelay.css @@ -33,3 +33,4 @@ table.dijitTooltipTable { border-collapse: separate; } .export_tr_border td { border-top: 1px solid #808080; } .nav_row_div {padding:1px; text-align:center; } +.toolbar_selected { border: 2px dashed #808080; text-decoration:underline; font-weight:bold;} diff --git a/Open-ILS/web/vandelay/vandelay.js b/Open-ILS/web/vandelay/vandelay.js index 14b0636468..8efa0497e4 100644 --- a/Open-ILS/web/vandelay/vandelay.js +++ b/Open-ILS/web/vandelay/vandelay.js @@ -87,6 +87,7 @@ function vlInit() { openils.Util.registerEnterHandler( vlQueueDisplayPage.domNode, function(){retrieveQueuedRecords();}); + openils.Util.addCSSClass(dojo.byId('vl-menu-marc-upload'), 'toolbar_selected'); function checkInitDone() { initCount++; @@ -207,6 +208,26 @@ function displayGlobalDiv(id) { } } dojo.style(dojo.byId(id),'display','block'); + + openils.Util.removeCSSClass(dojo.byId('vl-menu-marc-export'), 'toolbar_selected'); + openils.Util.removeCSSClass(dojo.byId('vl-menu-marc-upload'), 'toolbar_selected'); + openils.Util.removeCSSClass(dojo.byId('vl-menu-queue-select'), 'toolbar_selected'); + openils.Util.removeCSSClass(dojo.byId('vl-menu-attr-editor'), 'toolbar_selected'); + + switch(id) { + case 'vl-marc-export-div': + openils.Util.addCSSClass(dojo.byId('vl-menu-marc-export'), 'toolbar_selected'); + break; + case 'vl-marc-upload-div': + openils.Util.addCSSClass(dojo.byId('vl-menu-marc-upload'), 'toolbar_selected'); + break; + case 'vl-queue-select-div': + openils.Util.addCSSClass(dojo.byId('vl-menu-queue-select'), 'toolbar_selected'); + break; + case 'vl-attr-editor-div': + openils.Util.addCSSClass(dojo.byId('vl-menu-attr-editor'), 'toolbar_selected'); + break; + } } function runStartupCommands() { -- 2.11.0