diff --git a/www/extras/admin/admin.css b/www/extras/admin/admin.css index 7b3c37947..f5b5d9556 100644 --- a/www/extras/admin/admin.css +++ b/www/extras/admin/admin.css @@ -217,7 +217,7 @@ input.disabled { margin: 0; padding: 0; } -#viewTab iframe { +#tab_content_wrapper iframe { border: none; width: 100%; height: 100%; diff --git a/www/extras/admin/admin.js b/www/extras/admin/admin.js index 12751871e..29b4d81da 100644 --- a/www/extras/admin/admin.js +++ b/www/extras/admin/admin.js @@ -549,6 +549,7 @@ WebGUI.Admin.prototype.requestHelper * message : A message to the user * error : An error message * openDialog : Open a dialog with the given URL + * openTab : Open a tab with the given URL * redirect : Redirect the View pane to the given URL * scriptFile : Load a JS file * scriptFunc : Run a JS function. Used with scriptFile @@ -735,6 +736,41 @@ WebGUI.Admin.prototype.addHistoryHandler YAHOO.util.Event.on( elem, "click", function(){ self.gotoAsset( url ) }, self, true ); }; +/** + * openTab ( url ) + * Open a new tab with an iframe and the given URL + */ +WebGUI.Admin.prototype.openTab += function ( url ) { + // Prepare the iframe first + var iframe = document.createElement( 'iframe' ); + iframe.src = url; + YAHOO.util.Event.on( iframe, 'load', function(){ this.updateTabLabel(newTab); }, this, true ); + + // Prepare the tab + var newTab = new YAHOO.widget.Tab({ + label : "Loading...", + content : '' + }); + newTab.get('contentEl').appendChild( iframe ); + + // Fire when ready, Gridley + this.tabBar.addTab( newTab ); + +}; + +/** + * updateTabLabel( tab ) + * Update the tab's label with the title from the iframe inside + */ +WebGUI.Admin.prototype.updateTabLabel += function ( tab ) { + // Find the iframe + var iframe = tab.get('contentEl').getElementsByTagName( 'iframe' )[0]; + var title = iframe.contentDocument.title; + tab.set( 'label', title ); +}; + /**************************************************************************** * WebGUI.Admin.LocationBar */