fixed #12156: Asset Manager performance

This commit is contained in:
Paul Driver 2011-06-10 14:17:04 -05:00
parent 21bcd70980
commit 9dd8658ceb
2 changed files with 54 additions and 22 deletions

View file

@ -10,6 +10,7 @@
- fixed #12133: RenderThingData macro doesn't accept templateId - fixed #12133: RenderThingData macro doesn't accept templateId
- fixed #12152: PayPal Standard ignores shop-credit - fixed #12152: PayPal Standard ignores shop-credit
- fixed #12119: Locale setting for paypal - fixed #12119: Locale setting for paypal
- fixed #12156: Asset Manager performance
7.10.17 7.10.17
- fixed: Forced to use a PayDriver even with a balance of 0 in the cart. - fixed: Forced to use a PayDriver even with a balance of 0 in the cart.

View file

@ -7,6 +7,7 @@
if ( typeof WebGUI == "undefined" ) { if ( typeof WebGUI == "undefined" ) {
WebGUI = {}; WebGUI = {};
} }
if ( typeof WebGUI.AssetManager == "undefined" ) { if ( typeof WebGUI.AssetManager == "undefined" ) {
WebGUI.AssetManager = {}; WebGUI.AssetManager = {};
} }
@ -82,37 +83,52 @@ WebGUI.AssetManager.findRow = function ( child ) {
} }
}; };
WebGUI.AssetManager.assetActionCache = {};
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
WebGUI.AssetManager.formatActions ( ) WebGUI.AssetManager.formatActions ( )
Format the Edit and More links for the row Format the Edit and More links for the row
*/ */
WebGUI.AssetManager.formatActions = function ( elCell, oRecord, oColumn, orderNumber ) { WebGUI.AssetManager.formatActions = function ( elCell, oRecord, oColumn, orderNumber ) {
if ( oRecord.getData( 'actions' ) ) { var data = oRecord.getData(),
elCell.innerHTML id = data.assetId,
= '<a href="' + WebGUI.AssetManager.appendToUrl(oRecord.getData( 'url' ), 'func=edit;proceed=manageAssets') + '">' assets = WebGUI.AssetManager.assetActionCache,
+ WebGUI.AssetManager.i18n.get('Asset', 'edit') + '</a>' asset = assets[id],
+ ' | ' edit, more;
;
}
else {
elCell.innerHTML = "";
}
var more = document.createElement( 'a' );
elCell.appendChild( more );
more.appendChild( document.createTextNode( WebGUI.AssetManager.i18n.get('Asset','More' ) ) );
more.href = '#';
// Delete the old menu elCell.innerHTML = '';
if ( document.getElementById( 'moreMenu' + oRecord.getData( 'assetId' ) ) ) {
var oldMenu = document.getElementById( 'moreMenu' + oRecord.getData( 'assetId' ) ); if (!data.actions) {
oldMenu.parentNode.removeChild( oldMenu ); return;
} }
var options = WebGUI.AssetManager.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'actions' )); if (!asset) {
assets[id] = asset = {};
asset.data = data;
asset.bar = document.createTextNode(' | ');
var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options ); edit = asset.edit = document.createElement('a');
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } ); edit.href = WebGUI.AssetManager.appendToUrl(
YAHOO.util.Event.addListener( more, "click", function (e) { YAHOO.util.Event.stopEvent(e); menu.show(); menu.focus(); }, null, menu ); data.url, 'func=edit;proceed=manageAssets'
);
edit.appendChild(document.createTextNode(
WebGUI.AssetManager.i18n.get('Asset', 'edit')
));
more = asset.more = document.createElement('a');
more.href = '#';
more.appendChild(document.createTextNode(
WebGUI.AssetManager.i18n.get('Asset','More')
));
YAHOO.util.Event.addListener(
more, 'click', WebGUI.AssetManager.onMoreClick, asset
);
}
elCell.appendChild(asset.edit);
elCell.appendChild(asset.bar);
elCell.appendChild(asset.more);
}; };
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
@ -171,6 +187,21 @@ WebGUI.AssetManager.formatRank = function ( elCell, oRecord, oColumn, orderNumbe
+ 'onchange="WebGUI.AssetManager.selectRow( this )" />'; + 'onchange="WebGUI.AssetManager.selectRow( this )" />';
}; };
/*---------------------------------------------------------------------------
WebGUI.AssetManager.onMoreClick ( event, asset )
Event handler for the more menu's click event
*/
WebGUI.AssetManager.onMoreClick = function (e, a) {
var options, menu = a.menu, d = a.data;
YAHOO.util.Event.stopEvent(e);
if (!menu) {
options = WebGUI.AssetManager.buildMoreMenu(d.url, a.more, d.actions);
a.menu = menu = new YAHOO.widget.Menu('assetMenu'+d.assetId, options);
menu.render(document.getElementById('assetManager'));
}
menu.show();
menu.focus();
};
/*--------------------------------------------------------------------------- /*---------------------------------------------------------------------------
WebGUI.AssetManager.DefaultSortedBy ( ) WebGUI.AssetManager.DefaultSortedBy ( )