From 8fe92b94ce5e1e2857d088752d94e19db7e3d8a8 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Sun, 17 Jun 2012 22:31:44 -0700 Subject: montage v11 merge into ninja Signed-off-by: Valerio Virgillito --- .../ui/skeleton/range-input.reel/range-input.js | 300 --------------------- 1 file changed, 300 deletions(-) delete mode 100644 node_modules/montage/ui/skeleton/range-input.reel/range-input.js (limited to 'node_modules/montage/ui/skeleton/range-input.reel/range-input.js') diff --git a/node_modules/montage/ui/skeleton/range-input.reel/range-input.js b/node_modules/montage/ui/skeleton/range-input.reel/range-input.js deleted file mode 100644 index 1dbd4272..00000000 --- a/node_modules/montage/ui/skeleton/range-input.reel/range-input.js +++ /dev/null @@ -1,300 +0,0 @@ -/* - 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. -
*/ -/*global require,exports */ -var Montage = require("montage").Montage, - Component = require("ui/component").Component; - -/** - * The input type="range" field - */ -var RangeInput = exports.RangeInput = Montage.create(Component, { - - DEFAULT_WIDTH: { - value: 300 - }, - - HANDLE_ADJUST: { - value: 5 - }, - - // public API - _min: { - value: null - }, - - min: { - get: function() { - return this._min; - }, - set: function(value) { - this._min = String.isString(value) ? parseFloat(value) : value; - this.needsDraw = true; - }, - serializable: true - }, - - _max: { - value: null - }, - - max: { - get: function() { - return this._max; - }, - set: function(value) { - this._max = String.isString(value) ? parseFloat(value) : value; - this.needsDraw = true; - }, - serializable: true - }, - - _step: { - value: null - }, - - step: { - get: function() { - return this._step; - }, - set: function(value) { - this._step = String.isString(value) ? parseFloat(value) : value; - this.needsDraw = true; - }, - serializable: true - }, - - /** Width of the slider in px. Default = 300 */ - _width: { - value: null - }, - - width: { - get: function() { - return this._width; - }, - set: function(value) { - this._width = String.isString(value) ? parseFloat(value) : value; - this.needsDraw = true; - }, - serializable: true - }, - - percent: { - value: null - }, - - _valueSyncedWithPosition: { - value: null - }, - - _value: { - value: null - }, - - value: { - get: function() { - return this._value; - }, - set: function(value, fromInput) { - this._value = String.isString(value) ? parseFloat(value) : value; - - if(fromInput) { - this._valueSyncedWithPosition = true; - } else { - this._valueSyncedWithPosition = false; - this._calculatePositionFromValue(); - this.needsDraw = true; - } - }, - serializable: true - }, - - // private - _handleEl: { - value: null, - serializable: true - }, - - _translateComposer: { - value: null, - serializable: true - }, - - _sliderLeft: { - value: null - }, - - _sliderWidth: { - value: null - }, - - __positionX: { - value: null - }, - - _positionX: { - get: function() { - return this.__positionX; - }, - set: function(value, fromValue) { - - if(value !== null && !isNaN(value)) { - this.__positionX = value; - if(!fromValue) { - this._calculateValueFromPosition(); - this._valueSyncedWithPosition = true; - } - this.needsDraw = true; - } - - } - }, - - _calculateValueFromPosition: { - value: function() { - if(this._sliderWidth > 0) { - var percent = this.percent = (this._positionX / this._sliderWidth) * 100; - var value = (this.min + ((percent/100) * (this.max - this.min))); - Object.getPropertyDescriptor(this, "value").set.call(this, value, true); - } - - } - }, - - _calculatePositionFromValue: { - value: function() { - // unless the element is ready, we cannot position the handle - if(this._sliderWidth) { - var percent, value = this.value; - var range = (this.max - this.min); - percent = ((this.value-this.min)/range) * 100; - var positionX = (percent/100)*this._sliderWidth; - Object.getPropertyDescriptor(this, "_positionX").set.call(this, positionX, true); - - this.percent = percent; - this._valueSyncedWithPosition = true; - } else { - this._valueSyncedWithPosition = false; - } - } - }, - - deserializedFromTemplate: { - value: function() { - // read initial values from the input type=range - this.min = this.min || this.element.getAttribute('min') || 0; - this.max = this.max || this.element.getAttribute('max') || 100; - this.step = this.step || this.element.getAttribute('step') || 1; - this.value = this.value || this.element.getAttribute('value') || 0; - } - }, - - prepareForDraw: { - value: function() { - this._sliderLeft = this.element.offsetLeft; - this._sliderWidth = (this.width || RangeInput.DEFAULT_WIDTH); //this.element.offsetWidth || 300; - this.element.style.width = (this._sliderWidth + RangeInput.HANDLE_ADJUST) + 'px'; - - if(!this._valueSyncedWithPosition) { - this._calculatePositionFromValue(); - } - } - }, - - // @todo: Without prepareForActivationEvents, the _translateComposer does not work - prepareForActivationEvents: { - value: function() { - this._translateComposer.addEventListener('translateStart', this, false); - this._translateComposer.addEventListener('translateEnd', this, false); - - this._addEventListeners(); - - } - }, - - _addEventListeners: { - value: function() { - if(window.Touch) { - this.element.addEventListener('touchstart', this, false); - } else { - this.element.addEventListener('mousedown', this, false); - } - } - }, - - _removeEventListeners: { - value: function() { - if(window.Touch) { - this.element.removeEventListener('touchstart', this, false); - } else { - this.element.removeEventListener('mousedown', this, false); - } - } - }, - - handleTranslateStart: { - value: function(e) { - this._removeEventListeners(); - this._valueSyncedWithPosition = false; - } - }, - - handleTranslateEnd: { - value: function(e) { - this._addEventListeners(); - } - }, - - // handle user clicking the slider scale directly instead of moving the knob - _handleClick: { - value: function(position) { - var positionX = (position - (this._sliderLeft + 2*RangeInput.HANDLE_ADJUST)); - if(positionX < 0) { - positionX = 0; - } - this._positionX = positionX; - } - }, - - handleMousedown: { - value: function(e) { - this._handleClick(e.clientX); - } - }, - - handleTouchstart: { - value: function(event) { - this._handleClick(event.changedTouches[0].clientX); - } - }, - - surrenderPointer: { - value: function(pointer, composer) { - // If the user is sliding us then we do not want anyone using - // the pointer - return false; - } - }, - - - draw: { - value: function() { - var el = this._handleEl; - - if(el.style.webkitTransform != null) { - // detection for webkitTransform to use Hardware acceleration where available - el.style.webkitTransform = 'translate(' + this._positionX + 'px)'; - } else if(el.style.MozTransform != null) { - el.style.MozTransform = 'translate(' + this._positionX + 'px)'; - } else if(el.style.transform != null) { - el.style.transform = 'translate(' + this._positionX + 'px)'; - } else { - // fallback - el.style['left'] = this._positionX + 'px'; - } - } - } -}); -- cgit v1.2.3