From 7bee50379c1df86bb571e0e8d6c08e24d25231f5 Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Mon, 9 Jul 2012 16:38:08 -0700 Subject: BSD License --- js/components/editable.reel/editable.js | 61 +++++++++++++++++---------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'js/components/editable.reel') diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js index 026446ab..c008a18e 100644 --- a/js/components/editable.reel/editable.js +++ b/js/components/editable.reel/editable.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS @@ -39,7 +40,7 @@ EDITABLE - Methods - startEdit - stopEdit - value -- +- - _suggest - _suggestNext - _suggestPrev @@ -70,7 +71,7 @@ exports.Editable = Montage.create(Component, { if(this.startOnEvent) { this._element.addEventListener(this.startOnEvent, this, false); } - + } }, _readOnly : { @@ -80,9 +81,9 @@ exports.Editable = Montage.create(Component, { get : function() { return this._readOnly; }, set : function(makeReadOnly) { var action = makeReadOnly ? 'add' : 'remove'; - + this._element.classList[action](this.readOnlyClass); - + if(this.isEditable) { this.stop(); } @@ -160,7 +161,7 @@ exports.Editable = Montage.create(Component, { ///// Pre Edit Value ///// Value stored when editing starts ///// Useful for reverting to previous value - + _preEditValue : { value : null }, @@ -169,26 +170,26 @@ exports.Editable = Montage.create(Component, { if(!this._readOnly) { this._isEditable = this._element.contentEditable = true; this._element.classList.add(this.editingClass); - + ///// Save the preEditValue this._preEditValue = this.value; - + // Initialize enteredValue with current value this.enteredValue = this.value; - + if(this.selectOnStart) { this.selectAll(); } - + if(this.stopOnBlur) { //console.log('adding mousedown event listener'); ///// Simulate blur on editable node by listening to the doc document.addEventListener('mousedown', this, false); } - + this._sendEvent('start'); } - + } }, stop : { @@ -209,7 +210,7 @@ exports.Editable = Montage.create(Component, { value : function() { var range = document.createRange(), sel = window.getSelection(); - + sel.removeAllRanges(); range.selectNodeContents(this._element); sel.addRange(range); @@ -244,15 +245,15 @@ exports.Editable = Montage.create(Component, { this._sendEvent('blur'); } }, - + /* -------------------- User Event Handling -------------------- */ - + handleKeydown : { value : function(e) { var k = e.keyCode; } }, - + handleKeyup : { value : function(e) { // Record change in value @@ -267,7 +268,7 @@ exports.Editable = Montage.create(Component, { if(!this.isDirty) { this.isDirty = true; } - + this._sendEvent('input'); } }, @@ -310,7 +311,7 @@ exports.Editable = Montage.create(Component, { }, /* -------------------- CONFIG -------------------- */ - + editingClass : { value : 'editable' }, @@ -326,7 +327,7 @@ exports.Editable = Montage.create(Component, { stopOnBlur : { value : true }, - keyActions : { + keyActions : { value : { stop : [27,9,13], revert : [27], @@ -334,5 +335,5 @@ exports.Editable = Montage.create(Component, { }, distinct: true } - + }); -- cgit v1.2.3