From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- js/components/menu/menu-item.reel/menu-item.css | 72 ++++++++++ js/components/menu/menu-item.reel/menu-item.html | 83 ++++++++++++ js/components/menu/menu-item.reel/menu-item.js | 160 +++++++++++++++++++++++ 3 files changed, 315 insertions(+) create mode 100644 js/components/menu/menu-item.reel/menu-item.css create mode 100644 js/components/menu/menu-item.reel/menu-item.html create mode 100644 js/components/menu/menu-item.reel/menu-item.js (limited to 'js/components/menu/menu-item.reel') diff --git a/js/components/menu/menu-item.reel/menu-item.css b/js/components/menu/menu-item.reel/menu-item.css new file mode 100644 index 00000000..e5ceda5c --- /dev/null +++ b/js/components/menu/menu-item.reel/menu-item.css @@ -0,0 +1,72 @@ +/* + 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. +
*/ + +.menuItem .menuName { + font-family: 'Droid Sans', sans-serif; + font-size: 10pt; + padding: 3px 12px 3px 8px; + text-shadow : 1px 1px 1px #000000; +} + +.menuItem:hover { + background-color: #7f7f7f; +} + +.menubg .subEntries { + top: 0%; + left: 100%; + width: auto; + white-space:nowrap; +} + +.itemSeparator:hover { + background-color: #474747; +} + +.separator{ + width:100%; + height:2px; + position: relative; + border: 1px groove #474747 ; + border-radius: 2px; + background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#474747), to(#cccccc)); + opacity: 0.5; +} + +.disabled { + opacity: 0.5; +} + +.disabled:hover { + background-color: #474747; +} + +.menubg .check { + float:left; + background-image: url(../../../../images/menu/checkmark.png); + background-repeat: no-repeat; + background-position: center; + width: 10px; + height: 15px; + opacity: 0; +} + +.menubg.submenu .rightArrow { + float: right; + background-image:url('../../../../images/menu/arrow.png'); + background-repeat: no-repeat; + background-position: center; + width: 10px; + height: 15px; + position: absolute; + right:4px; + top: 5px; + margin-left: 8px; +} + +.subEntries.subMenu .rightArrow { + opacity: 0; +} \ No newline at end of file diff --git a/js/components/menu/menu-item.reel/menu-item.html b/js/components/menu/menu-item.reel/menu-item.html new file mode 100644 index 00000000..d199a440 --- /dev/null +++ b/js/components/menu/menu-item.reel/menu-item.html @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + diff --git a/js/components/menu/menu-item.reel/menu-item.js b/js/components/menu/menu-item.reel/menu-item.js new file mode 100644 index 00000000..64a89a6a --- /dev/null +++ b/js/components/menu/menu-item.reel/menu-item.js @@ -0,0 +1,160 @@ +/* +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() { + 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) { + Object.defineBinding(this, "enabled", { + boundObject: this.application.ninja[this.data.enabled.boundObj], + boundObjectPropertyPath: this.data.enabled.boundProperty + }); + + } else { + this.enabled = this.data.enabled; + } + + if(this.data.submenu) { + this.submenu = true; + + this.subentries = this.data.entries; + + this.subMenu.classList.add("subMenu"); + this.element.addEventListener("mouseover", this, false); + this.element.addEventListener("mouseout", this, false); + + } + + + this.itemText.innerHTML = this.data.displayText; + this.element.addEventListener("mousedown", this, true); + } + }, + + draw: { + value: function() { + + if(this.enabled) { + this.element.classList.remove("disabled"); + } else { + this.element.classList.add("disabled"); + } + + if(this.checked) { + this.itemBackground.classList.add("checked"); + } else { + this.itemBackground.classList.remove("checked"); + } + + if(this.submenu) { + this.itemBackground.classList.add("submenu"); + } + } + }, + + captureMousedown: { + value: function(event) { + + if(this.data.radio && this.checked) return; + + if(this.enabled || !this.submenu) { + if(this.data.action) { + NJevent ( this.data.action ); + } else if(this.checked !== null) { + this.checked = !this.checked; + } + } + + } + }, + + handleMouseover: { + value: function() { + if(this.enabled) this.subMenu.style.display = "block"; + } + }, + + handleMouseout: { + value: function() { + this.subMenu.style.display = "none"; + } + } + +}); \ No newline at end of file -- cgit v1.2.3