From f7e4257745ccd44b8d24555f0ef787429d6e472c Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 00:11:03 -0700 Subject: adding the latest v0.10 montage Signed-off-by: Valerio Virgillito --- .../token-field/token-field.reel/token-field.html | 12 ++-- .../ui/token-field/token-field.reel/token-field.js | 24 ++++---- .../montage/ui/token-field/token.reel/token.html | 6 +- .../montage/ui/token-field/token.reel/token.js | 65 +++++++++++++++------- 4 files changed, 68 insertions(+), 39 deletions(-) (limited to 'node_modules/montage/ui/token-field') diff --git a/node_modules/montage/ui/token-field/token-field.reel/token-field.html b/node_modules/montage/ui/token-field/token-field.reel/token-field.html index 0335de13..2a2d98d4 100644 --- a/node_modules/montage/ui/token-field/token-field.reel/token-field.html +++ b/node_modules/montage/ui/token-field/token-field.reel/token-field.html @@ -9,7 +9,7 @@ { "owner": { - "prototype": "montage/ui/token-field/token-field.reel", + "prototype": "ui/token-field/token-field.reel", "properties": { "element": {"#": "token-field"}, "_autocomplete": {"@": "autocomplete"}, @@ -22,18 +22,18 @@ } }, "tokensController": { - "prototype": "montage/ui/controller/array-controller", + "prototype": "ui/controller/array-controller", "properties": { "selectObjectsOnAddition": true, "automaticallyOrganizeObjects": true }, "bindings": { - "content": {"<<->": "@owner.values"} + "content": {"<->": "@owner.values"} } }, "tokenList": { - "prototype": "montage/ui/repetition.reel", + "prototype": "ui/repetition.reel", "properties": { "element": { "#": "token-list" @@ -45,7 +45,7 @@ }, "token": { - "prototype": "montage/ui/token-field/token.reel", + "prototype": "ui/token-field/token.reel", "properties": { "element": {"#": "token"} }, @@ -57,7 +57,7 @@ } }, "autocomplete": { - "prototype": "montage/ui/autocomplete/autocomplete.reel", + "prototype": "ui/autocomplete/autocomplete.reel", "properties": { "element": {"#": "autocomplete"}, "identifier": "autocomplete", diff --git a/node_modules/montage/ui/token-field/token-field.reel/token-field.js b/node_modules/montage/ui/token-field/token-field.reel/token-field.js index 9f08e477..f8070993 100644 --- a/node_modules/montage/ui/token-field/token-field.reel/token-field.js +++ b/node_modules/montage/ui/token-field/token-field.reel/token-field.js @@ -15,21 +15,21 @@ KEY_DOWN = 40; exports.TokenField = Montage.create(Component, { - delegate: {value: null}, + delegate: {value: null, serializable: true}, - values: {value: null}, + values: {value: null, serializable: true}, /** * Path to a String within an Object that is representative of the Object */ - textPropertyPath: {value: null}, + textPropertyPath: {value: null, serializable: true}, /** * Allow ad-hoc strings (strings that do not have corresponding represented object) to be entered. */ - allowAdHocValues: {value: null}, + allowAdHocValues: {value: null, serializable: true}, - placeholder: {value: null}, + placeholder: {value: null, serializable: true}, // private @@ -47,11 +47,12 @@ exports.TokenField = Montage.create(Component, { } }, - _tokensController: {value: null}, - _tokenList: {value: null, enumerable: false}, - _autocomplete: {value: null, enumerable: false}, + _tokensController: {value: null, serializable: true}, + _tokenList: {value: null, serializable: true}, + _autocomplete: {value: null, serializable: true}, __autocompleteValue: {value: null}, _autocompleteValue: { + serializable: true, get: function() { return this.__autocompleteValue; }, @@ -62,6 +63,7 @@ exports.TokenField = Montage.create(Component, { __suggestedValue: {value: null}, _suggestedValue: { + serializable: true, get: function() { return this.__suggestedValue; }, @@ -84,6 +86,8 @@ exports.TokenField = Montage.create(Component, { this.values.push(this.__suggestedValue); this._autocomplete.value = ''; } + // nullify the value as autocomplete.value is empty + this.__suggestedValue = null; } } @@ -129,7 +133,6 @@ exports.TokenField = Montage.create(Component, { }, handleKeyup: { - enumerable: false, value: function(e) { var code = e.keyCode; //console.log('keyCode', code); @@ -150,7 +153,8 @@ exports.TokenField = Montage.create(Component, { // check if the selected token is the last one if(selectedIndexes && selectedIndexes.length > 0) { // removes the selected one - this._tokensController.remove(); + this._tokensController.removeObjectsAtSelectedIndexes(); + this._tokensController.selectedIndexes = []; } else { this._tokensController.selectedIndexes = [this.values.length-1]; } diff --git a/node_modules/montage/ui/token-field/token.reel/token.html b/node_modules/montage/ui/token-field/token.reel/token.html index 54ba266e..c478ef0c 100644 --- a/node_modules/montage/ui/token-field/token.reel/token.html +++ b/node_modules/montage/ui/token-field/token.reel/token.html @@ -9,7 +9,7 @@ { "tokenText": { - "prototype": "montage/ui/dynamic-text.reel", + "prototype": "ui/dynamic-text.reel", "properties": { "element": {"#": "token-text"} }, @@ -18,7 +18,7 @@ } }, "tokenDelete": { - "prototype": "montage/ui/dynamic-text.reel", + "prototype": "ui/dynamic-text.reel", "properties": { "element": {"#": "token-delete"}, "value": "✕" @@ -26,7 +26,7 @@ }, "owner": { - "prototype": "montage/ui/token-field/token.reel", + "prototype": "ui/token-field/token.reel", "properties": { "element": {"#": "token"}, "_deleteEl": {"#": "token-delete"} diff --git a/node_modules/montage/ui/token-field/token.reel/token.js b/node_modules/montage/ui/token-field/token.reel/token.js index 15216c3f..18112625 100644 --- a/node_modules/montage/ui/token-field/token.reel/token.js +++ b/node_modules/montage/ui/token-field/token.reel/token.js @@ -8,35 +8,58 @@ var Montage = require("montage").Montage, exports.Token = Montage.create(Component, { - text: {value: null}, + _text: { + value: null + }, + + text: { + dependencies: ["value", "textPropertyPath"], + get: function() { + var textPropertyPath, + value, + text; + + if (this._text == null) { + this._adHoc = false; + textPropertyPath = this.textPropertyPath; + value = this.value; + + if (textPropertyPath != null && value != null) { + if (typeof value[textPropertyPath] === 'undefined' && this.allowAdHocValues) { + this._adHoc = true; + this._text = value; + } else { + this._text = value[textPropertyPath]; + } + } else { + this._text = value; + } + } - allowAdHocValues: {value: null}, + return this._text; + } + }, + + allowAdHocValues: {value: null, serializable: true}, + + _value: { + value: null + }, value: { + serializable: true, get: function() { return this._value; }, set: function(aValue) { - this._adHoc = false; - if(aValue) { - this._value = aValue; - if(this.textPropertyPath) { - if(typeof aValue[this.textPropertyPath] == 'undefined' && this.allowAdHocValues) { - this.text = aValue; - this._adHoc = true; - } else { - this.text = this.value[this.textPropertyPath]; - } - } else { - this.text = this.value; - } - } + this._value = aValue; + this._text = null; } }, - textPropertyPath: {value: null}, + textPropertyPath: {value: null, serializable: true}, - tokensController: {value: null}, + tokensController: {value: null, serializable: true}, // private @@ -51,7 +74,7 @@ exports.Token = Montage.create(Component, { } }, - _deleteEl: {value: null}, + _deleteEl: {value: null, serializable: true}, prepareForDraw: { value: function() { @@ -73,7 +96,9 @@ exports.Token = Montage.create(Component, { removeSelf: { value: function() { - this.tokensController.removeObjects(this.value); + this.tokensController.selectedObjects = [this.value]; + this.tokensController.removeObjectsAtSelectedIndexes(); + this.tokensController.selectedIndexes = []; } }, -- cgit v1.2.3