display asset helpers
This commit is contained in:
parent
7fca2c1947
commit
2e1589121a
2 changed files with 45 additions and 0 deletions
|
|
@ -260,6 +260,8 @@ if ($self->session->user->isRegistered || $self->session->setting->get("preventP
|
|||
title => $session->asset->getTitle,
|
||||
url => $session->asset->getUrl,
|
||||
icon => $session->asset->getIcon(1),
|
||||
type => $session->asset->assetName,
|
||||
helpers => $session->asset->getHelpers,
|
||||
};
|
||||
$var{'head.tags'} .= sprintf <<'ADMINJS', JSON->new->encode( $assetDef );
|
||||
if ( window.parent && window.parent.admin ) {
|
||||
|
|
|
|||
|
|
@ -187,6 +187,7 @@ WebGUI.Admin.prototype.navigate
|
|||
if ( !this.currentAssetDef || this.currentAssetDef.assetId != assetDef.assetId ) {
|
||||
this.currentAssetDef = assetDef;
|
||||
this.treeDirty = 1;
|
||||
this.updateAssetHelpers( assetDef );
|
||||
}
|
||||
|
||||
// Fire event
|
||||
|
|
@ -289,6 +290,48 @@ WebGUI.Admin.prototype.pasteAsset
|
|||
this.gotoAsset( url );
|
||||
};
|
||||
|
||||
/**
|
||||
* updateAssetHelpers( assetDef )
|
||||
* Update the asset helpers. assetDef must contain:
|
||||
* helper - An arrayref of hashrefs of helper definitions
|
||||
* icon - The icon of the current asset
|
||||
* type - The type of the current asset
|
||||
*/
|
||||
WebGUI.Admin.prototype.updateAssetHelpers
|
||||
= function ( assetDef ) {
|
||||
var typeEl = document.getElementById( 'helper_asset_name' );
|
||||
typeEl.style.backgroundImage = assetDef.icon;
|
||||
typeEl.innerHTML = assetDef.type;
|
||||
|
||||
// Clear old helpers
|
||||
var helperEl = document.getElementById( 'helper_list' );
|
||||
while ( helperEl.childNodes.length > 0 ) {
|
||||
helperEl.removeChild( helperEl.childNodes[0] );
|
||||
}
|
||||
|
||||
// Add new ones
|
||||
for ( var i = 0; i < assetDef.helpers.length; i++ ) {
|
||||
var helper = assetDef.helpers[i];
|
||||
var li = document.createElement('li');
|
||||
li.appendChild( document.createTextNode( helper.label ) );
|
||||
this.addHelperHandler( li, helper );
|
||||
helperEl.appendChild( li );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* addHelperHandler( elem, helper )
|
||||
* Add the click handler to activate the given helper
|
||||
*/
|
||||
WebGUI.Admin.prototype.addHelperHandler
|
||||
= function ( elem, helper ) {
|
||||
var self = this;
|
||||
if ( helper.url ) {
|
||||
YAHOO.util.Event.on( elem, "click", function(){ self.gotoAsset( helper.url ) }, self, true );
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* WebGUI.Admin.LocationBar
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue