From e00e83a5a5ba352532a49f251f0a3219a8fd94ac Mon Sep 17 00:00:00 2001 From: Doug Bell Date: Thu, 29 Jul 2010 13:37:50 -0500 Subject: [PATCH] add JS to update version tag after every page --- www/extras/admin/admin.js | 45 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 78316c3e6..40473b33a 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -42,6 +42,8 @@ WebGUI.Admin = function(cfg){ self.locationBar.navigate( self.currentAssetDef ); } + self.afterNavigate.subscribe( self.requestUpdateCurrentVersionTag, self ); + self.tree = new WebGUI.Admin.Tree(); self.tabBar = new YAHOO.widget.TabView( self.cfg.tabBarId ); // Keep track of View and Tree tabs @@ -329,6 +331,49 @@ WebGUI.Admin.prototype.addHelperHandler } }; +/** + * updateCurrentVersionTag( tag ) + * Update the current version tag. tag is an object of data about the tag: + * tagId : the ID of the tag + * name : The name of the tag + * editUrl : A URL to edit the tag + * commitUrl : A URL to commit the tag + * leaveUrl : A URL to leave the tag + */ +WebGUI.Admin.prototype.updateCurrentVersionTag += function ( tag ) { + var editEl = document.getElementById( 'editTag' ); + editEl.innerHTML = tag.name; + editEl.href = tag.editUrl; + + var publishEl = document.getElementById( 'publishTag' ); + publishEl.href = tag.commitUrl; + + var leaveEl = document.getElementById( 'leaveTag' ); + leaveEl.href = tag.leaveUrl; +}; + +/** + * requestUpdateCurrentVersionTag( ) + * Request an update for the current version tag + */ +WebGUI.Admin.prototype.requestUpdateCurrentVersionTag += function ( ) { + var callback = { + success : function (o) { + var tag = YAHOO.lang.JSON.parse( o.responseText ); + if ( tag ) { + this.updateCurrentVersionTag( tag ); + } + }, + failure : function (o) { + + }, + scope: this + }; + + var ajax = YAHOO.util.Connect.asyncRequest( 'GET', '?op=admin;method=getCurrentVersionTag', callback ); +}; /**************************************************************************** * WebGUI.Admin.LocationBar