/*
This file contains proprietary software owned by Motorola Mobility, Inc.
No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
*/
var Montage = require("montage/core/core").Montage;
var Component = require("montage/ui/component").Component;
exports.MenuItem = Montage.create(Component, {
data: {
value: null
},
_enabled: {
value: null
},
enabled: {
get: function() {
return this._enabled;
},
set: function(value) {
if(value !== this._enabled) {
this._enabled = value;
this.needsDraw = true;
}
}
},
_checked: {
value: null
},
checked: {
get: function() {
return this._checked;
},
set: function(value) {
/*
if( Object.prototype.toString.call( value ) === '[object Array]' ) {
value = value.indexOf(this.data.displayText + "Panel") >= 0;
}
*/
if(this._checked !== value) {
this._checked = value;
this.needsDraw = true;
}
}
},
submenu: {
value: false
},
subentries: {
value: []
},
prepareForDraw: {
value: function() {
var boundObject = this.application.ninja, strArr = null, i=0;
if(!this.data) return;
if(this.data.separator) {
this.element.classList.add("itemSeparator");
this.itemBackground.classList.remove("menubg");
this.itemBackground.classList.add("separator");
return;
}
// Binding the checked to the assigned bound property
if(this.data.checked) {
Object.defineBinding(this, "checked", {
boundObject: this.application.ninja.appModel,
boundObjectPropertyPath: this.data.checked.boundProperty
});
}
if(this.data.enabled.boundProperty) {
strArr = this.data.enabled.boundObj.split(".");
for(i=0;i