Index: lams_common/src/flash/org/lamsfoundation/lams/common/ui/LFMenuBar.as =================================================================== diff -u -r4eaf8bcf5c9fe24055e7f087acb286d10a81d3de -r4a4f558890b5e65f7a63a8fd2e71e868c2c791dc --- lams_common/src/flash/org/lamsfoundation/lams/common/ui/LFMenuBar.as (.../LFMenuBar.as) (revision 4eaf8bcf5c9fe24055e7f087acb286d10a81d3de) +++ lams_common/src/flash/org/lamsfoundation/lams/common/ui/LFMenuBar.as (.../LFMenuBar.as) (revision 4a4f558890b5e65f7a63a8fd2e71e868c2c791dc) @@ -52,7 +52,9 @@ private var app:ApplicationParent; private var tm:ThemeManager; private var _dictionary:Dictionary; - + + private static var _instance:LFMenuBar = null; + //These are defined so that the compiler can 'see' the events that are added at runtime by EventDispatcher private var dispatchEvent:Function; public var addEventListener:Function; @@ -64,14 +66,24 @@ //Set up init for next frame and make invisible this frame this.onEnterFrame = init; this._visible = false; - + _instance = this; //Get a reference to the application, ThemeManager and Dictionary app = ApplicationParent.getInstance(); tm = ThemeManager.getInstance(); _dictionary = Dictionary.getInstance(); _dictionary.addEventListener('init',Delegate.create(this,setupMenuItems)); + } + + /** + * Retrieves an instance of the LFMenuBar singleton + */ + public static function getInstance():LFMenuBar{ + if(LFMenuBar._instance == null){ + LFMenuBar._instance = new LFMenuBar(); + } + return LFMenuBar._instance; } public function init() { @@ -106,12 +118,12 @@ file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_new'), instanceName:"newItem"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_open'), instanceName:"openItem"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_revert'), instanceName:"revertItem", enabled:false}); - file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_new'), instanceName:"closeItem"}); + //file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_close'), instanceName:"closeItem"}); file_menu.addMenuItem({type:"separator"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_save'), instanceName:"saveItem"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_saveas'), instanceName:"saveItemAs"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_import'), instanceName:"importItem"}); - file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_export'), instanceName:"exportItem"}); + file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_export'), instanceName:"exportItem", enabled:false}); file_menu.addMenuItem({type:"separator"}); file_menu.addMenuItem({label:Dictionary.getValue('mnu_file_exit'), instanceName:"exitItem"}); @@ -240,7 +252,7 @@ //Which item was clicked ? switch (eventObj.menuItem) { case eventObj.menu.newItem : - trace('new selected'); + org.lamsfoundation.lams.authoring.Application(app).getCanvas().clearCanvas(false); break; case eventObj.menu.openItem : app.getWorkspace().userSelectItem(); @@ -272,6 +284,7 @@ case eventObj.menu.scheduleItem: break; case eventObj.menu.exitItem: + getURL('javascript: window.close();'); break; } } @@ -374,7 +387,11 @@ Debugger.log('themeChanged event broadcast with an object.type not equal to "themeChanged"',Debugger.CRITICAL,'themeChanged','LFMenuBar'); } } - + + public function enableExport(enable:Boolean){ + file_menu.setMenuItemEnabled(file_menu.getMenuItemAt(7), enable); + } + /** * Set the styles for the menu called from init. and themeChanged event handler */