Created
October 2, 2008 21:35
-
-
Save ttdonovan/14450 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ========================================================================== | |
// myApp.MainMenuController | |
// ========================================================================== | |
require('core'); | |
/** @class | |
(Document Your View Here) | |
@extends SC.Object | |
@author AuthorName | |
@version 0.1 | |
@static | |
*/ | |
myApp.mainMenuController = SC.ObjectController.create( | |
/** @scope myApp.mainMenuController */ { | |
isContentForUI: null, | |
isContentForUIObserver: function () { | |
if (this.isContentForUI) { | |
this._buildMenuUI(); | |
} | |
}.observes('isContentForUI'), | |
_buildMenuUI: function () { | |
var menuButtons = this.content.get('elements'), | |
mainMenuView = SC.page.desktopView.header.mainMenu, | |
params = null; | |
for (var i = 0; i < menuButtons.length; i += 1 ) { | |
// popup menu and menu items | |
var menulist = menuButtons[i].children || []; | |
var popupmenu = SC.PopupMenuView.create(); | |
popupmenu.setAttribute('id', 'popup_menu_' + i); | |
for (var j = 0; j < menulist.length; j += 1) { | |
params = { target: 'myApp.mainMenuController', action: 'execute' }; | |
var menuitem = SC.MenuItemView.create(params); | |
menuitem.set('title', menulist[j].label); // bug? - SC.ButtonView title is a computed property | |
popupmenu.appendChild(menuitem); // now where do i place popmenu ? | |
}; | |
// menu buttons | |
params = { menu: popupmenu.getAttribute('id') }; | |
var menuButton = SC.ButtonView.create(params); | |
menuButton.set('title', menuButtons[i].label); // bug? - SC.ButtonView title is a computed property | |
mainMenuView.appendChild(menuButton); | |
}; | |
}, | |
execute: function (menuItem) { | |
console.log('ive been executed, says', menuItem); | |
} | |
}) ; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment