// Licensed Materials - Property of IBM // // IBM Cognos Products: cogadmin // // (C) Copyright IBM Corp. 2011 // // US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp. // // dojo.provide("com.ibm.cognos.admin.utils.Menu"); dojo.declare("com.ibm.cognos.admin.utils.Menu", null, { constructor: function (menuModel, fragId){ // menuModel { // id: xxx, // items: [ // id: xxx, // title: xxxx // ], // captionId: xxx, // fieldId: xxx, // inputValue: xxx, // defaultValue: xxx // } this.fragId = fragId; this.menuModel = menuModel; this.menu = new ui_menu({id: this.menuModel.id, items:this._getItems()}); this.menu.selectMenuItem(this.menuModel.inputValue || this.menuModel.defaultValue); }, _getItems: function(){ var items=[]; var self=this; dojo.forEach(this.menuModel.items, function(item){ items.push({ id: item.id, title: item.title, action: function(evt){ self.menu.selectMenuItem(item.id); self._setMenuItem(item.id, item.title); } }); }); return items; }, _setMenuItem: function(selectedValue, caption) { var captionId = this.menuModel.captionId || this.menuModel.id + "_caption"; var menuCaption = dojo.byId(this.fragId + captionId); if (menuCaption) { menuCaption.innerHTML = caption; dojo.byId(this.fragId + this.menuModel.fieldId).value = selectedValue; } }, getMenu: function(){ return this.menu; } });