From d46f77bf2eaae9fb04a6bbe68f864f11ce4bb7ed Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Mon, 19 Apr 2010 09:46:24 -0500 Subject: [PATCH] more work on admin console --- lib/WebGUI/Admin.pm | 2 ++ www/extras/admin/admin.css | 8 +++--- www/extras/admin/admin.js | 52 ++++++++++++++++++++++++++++++++------ 3 files changed, 50 insertions(+), 12 deletions(-) diff --git a/lib/WebGUI/Admin.pm b/lib/WebGUI/Admin.pm index 8aa439e5e..a100ecc40 100644 --- a/lib/WebGUI/Admin.pm +++ b/lib/WebGUI/Admin.pm @@ -177,6 +177,7 @@ sub www_view { } $var->{viewUrl} = $url->page; + $var->{homeUrl} = WebGUI::Asset->getDefault( $session )->getUrl; # All this needs to be template attachments $style->setLink( $url->extras('yui/build/button/assets/skins/sam/button.css'), {type=>"text/css",rel=>"stylesheet"}); @@ -265,6 +266,7 @@ __DATA__ diff --git a/www/extras/admin/admin.css b/www/extras/admin/admin.css index 029c1219d..c7f96b8b8 100644 --- a/www/extras/admin/admin.css +++ b/www/extras/admin/admin.css @@ -39,22 +39,22 @@ #locationBar #left { position: absolute; - width: 16%; + width: 12%; top: 5px; left: 0; } #locationBar #right { position: absolute; - width: 8%; + width: 10%; top: 5px; right: 0; } #locationBar #location { position: relative; - margin: auto 7% auto 16%; - width: 75%; + margin: auto 10% auto 12%; + width: 77%; height: 80%; border: 1px solid #333; border-radius: 3px; diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 71cf9d95c..696db56dd 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -99,9 +99,10 @@ WebGUI.Admin.prototype.navigate * WebGUI.Admin.LocationBar */ WebGUI.Admin.LocationBar -= function (id) { += function (id, cfg) { // Public properties this.id = id; // ID of the element containing the location bar + this.cfg = cfg; // Configuration this.currentAssetDef = null; // Object containing assetId, title, url, icon this.backAssetDefs = [ ]; // Asset defs to go back to this.forwardAssetDefs = [ ]; // Asset defs to go forward to @@ -129,12 +130,20 @@ WebGUI.Admin.LocationBar menu : [] } ); self.btnSearch = new YAHOO.widget.Button( "searchButton", { - label : '' + label : '', + onclick : { fn: self.clickSearchButton, scope: self } } ); self.btnHome = new YAHOO.widget.Button( "homeButton", { - label : '' + type : "button", + label : '', + onclick : { fn: self.goHome, scope: self } } ); // Take control of the location input + self.klInput = new YAHOO.util.KeyListener( "locationUrl", { keys: 13 }, { + fn: self.doInputSearch, + scope: self, + correctScope: true + } ); YAHOO.util.Event.addListener( "locationUrl", "focus", self.inputFocus, self, true ); YAHOO.util.Event.addListener( "locationUrl", "blur", self.inputBlur, self, true ); } @@ -186,6 +195,29 @@ WebGUI.Admin.LocationBar.prototype.clickForwardMenuItem this.swapForwardToBack( assetDef ); }; +/** + * doInputSearch() + * Perform the search as described in the location bar + */ +WebGUI.Admin.LocationBar.prototype.doInputSearch += function ( ) { + var input = document.getElementById("locationUrl").value; + // If input starts with a / and doesn't contain a ? go to the asset + if ( input.match(/^\//) ) { + if ( !input.match(/\?/) ) { + window.admin.gotoAsset( input ); + } + // If does contain a ?, go to url + else { + window.admin.go( input ); + } + } + // Otherwise ask WebGUI what do + else { + alert("TODO"); + } +}; + /** * getMenuItemLabel( assetDef ) * Build a menu item label for the given assetDef @@ -234,6 +266,7 @@ WebGUI.Admin.LocationBar.prototype.inputBlur if ( e.target.value.match(/^\s*$/) ) { e.target.value = this.currentAssetDef.url; } + this.klInput.disable(); }; /** @@ -245,6 +278,7 @@ WebGUI.Admin.LocationBar.prototype.inputFocus if ( e.target.value == this.currentAssetDef.url ) { e.target.value = ""; } + this.klInput.enable(); }; /** @@ -257,12 +291,14 @@ WebGUI.Admin.LocationBar.prototype.navigate this.setTitle( assetDef.title ); this.setUrl( assetDef.url ); - if ( this.currentAssetDef ) { - if ( this.currentAssetDef.assetId == assetDef.assetId ) { - // Don't do the same asset twice - return; - } + // Don't do the same asset twice + if ( this.currentAssetDef && this.currentAssetDef.assetId != assetDef.assetId ) { this.addBackAsset( this.currentAssetDef ); + // We navigated, so destroy the forward queue + //this.forwardAssetDefs = []; + //this.btnForward.getMenu().clearItems(); + //this.btnForward.getMenu().render(); + //this.btnForward.set( "disabled", true ); } // Current asset is now...