Dial.js revision 7928e2ef0532df9064d9374ceda31d6ab080eb2d
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff/**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Create a circular dial value range input visualized as a draggable handle on a
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * background element.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @module dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff var supportsVML = false,
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff testVMLNode;
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff if (Y.UA.ie && Y.UA.ie < 9){
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff supportsVML = true;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var Lang = Y.Lang,
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Widget = Y.Widget,
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Node = Y.Node;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Create a dial to represent an input control capable of representing a
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * series of intermediate states based on the position of the Dial's handle.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * These states are typically aligned to a value algorithm whereby the angle of the handle's
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * position corresponds to a given value.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @class Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @extends Widget
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param config {Object} Configuration object
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @constructor
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff function Dial(config) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.superclass.constructor.apply(this, arguments);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
f47f024e093853ad3957be898687fc8317a835daJeff Conniff // Y.Dial static properties
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * The identity of the widget.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.NAME
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type String
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 'dial'
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @readOnly
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @static
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.NAME = "dial";
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Static property used to define the default attribute configuration of
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * the Widget.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.ATTRS
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Object}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @static
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.ATTRS = {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * minimum value allowed
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute min
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default -220
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff min : {
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff value:-220
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * maximum value allowed
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute max
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 220
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff max : {
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff value:220
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * diameter of the circular background object.
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * Other objects scale accordingly
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * Set this only before rendering.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute diameter
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number} the number of px in diameter
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 100
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * @writeOnce
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff diameter : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:100
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * diameter of the handle object which users drag to change the value.
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * Dial sets the pixel dimension of the marker equal to markerDiameter * diameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * Set this only before rendering.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @attribute handleDiameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @default 0.2
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @writeOnce
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff handleDiameter : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:0.2
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * diameter of the marker object which follows the angle of the handle during value changes.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * Scaled relative to the diameter attribute
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * Dial sets the pixel dimension of the marker equal to markerDiameter * diameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * Set this only before rendering.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @attribute markerDiameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @default 0.1
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @writeOnce
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff markerDiameter : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:0.1
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * diameter of the center button object.
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * Dial sets the pixel dimension of the centerButton equal to centerButtonDiameter * diameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * Set this only before rendering.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @attribute centerButtonDiameter
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @default 0.1
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @writeOnce
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff centerButtonDiameter : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:0.5
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * initial value of the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 0
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:0,
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff validator: function(val) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff return this._validateValue(val);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * amount to increment/decrement the dial value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * when the arrow up/down/left/right keys are pressed
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute minorStep
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 1
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff minorStep : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:1
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * amount to increment/decrement the dial value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * when the page up/down keys are pressed
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute majorStep
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 10
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff majorStep : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:10
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * number of value increments in one 360 degree revolution
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * of the handle around the dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @attribute stepsPerRevolution
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 100
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff stepsPerRevolution : {
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff value:100
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * number of decimal places of accuracy in the value
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @attribute decimalPlaces
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @type {Number}
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @default 0
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff decimalPlaces : {
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff value:0
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * visible strings for the dial UI. This attribute is
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * defined by the base Widget class but has an empty value. The
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Dial is simply providing a default value for the attribute.
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * Gets localized strings in the current language
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute strings
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {Object} the values are HTML strings
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @default {label: 'My label', resetStr: 'Reset', tooltipHandle: 'Drag to set value'}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff strings: {
a90f7fefd9901a8da896d4bfe602441e0b7078d3Jeff Conniff valueFn: function () {
a90f7fefd9901a8da896d4bfe602441e0b7078d3Jeff Conniff return Y.Intl.get('dial');
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * distance from the center of the dial to the
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * resting place of the center of the handle and marker.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * The value is a percent of the radius of the dial.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @attribute handleDistance
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 0.75
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff handleDistance:{
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:0.75
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff };
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * returns a properly formed yui class name
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @function
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param {String} string to be appended at the end of class name
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @return
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @private
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff function makeClassName(str) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff return Y.ClassNameManager.getClassName(Dial.NAME, str);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * array of static constants used to identify the classname applied to the Dial DOM objects
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.CSS_CLASSES
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Array}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @private
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @static
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.CSS_CLASSES = {
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff label : makeClassName("label"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff labelString : makeClassName("label-string"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff valueString : makeClassName("value-string"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff northMark : makeClassName("north-mark"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff ring : makeClassName('ring'),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff ringVml : makeClassName('ring-vml'),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff marker : makeClassName("marker"),
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff markerVml : makeClassName("marker-vml"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff centerButton : makeClassName("center-button"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff centerButtonVml : makeClassName('center-button-vml'),
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff resetString : makeClassName("reset-string"),
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff handle : makeClassName("handle"),
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff handleVml : makeClassName("handle-vml"),
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff hidden : makeClassName("hidden"),
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff dragging : Y.ClassNameManager.getClassName("dd-dragging")
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff };
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /* Static constants used to define the markup templates used to create Dial DOM elements */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var labelId = Dial.CSS_CLASSES.label + Y.guid(); //get this unique id once then use
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's label.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.LABEL_TEMPLATE
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {HTML}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @default &lt;div id="' + labelId + '" class="[...-label]">&lt;span class="[...-label-string]">{label}&lt;/span>&lt;span class="[...-value-string]">&lt;/span>&lt;/div>
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.LABEL_TEMPLATE = '<div id="' + labelId + '" class="' + Dial.CSS_CLASSES.label + '"><span class="' + Dial.CSS_CLASSES.labelString + '">{label}</span><span class="' + Dial.CSS_CLASSES.valueString + '"></span></div>';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if(supportsVML === false){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's background ring.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.RING_TEMPLATE
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {HTML}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default &lt;div class="[...-ring]">&lt;div class="[...-northMark]">&lt;/div>&lt;/div>
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + '"><div class="' + Dial.CSS_CLASSES.northMark + '"></div></div>';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's current angle marker.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.MARKER_TEMPLATE
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {HTML}
3e16868ea3bfcadfeeb8e23aca5bb2317a6a8ba9Jeff Conniff * @default &lt;div class="[...-marker] [...-marker-hidden]">&lt;div class="[...-markerUser]">&lt;/div>&lt;/div>
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Dial.MARKER_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.marker + ' ' + Dial.CSS_CLASSES.hidden + '"></div>';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's center button.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.CENTER_BUTTON_TEMPLATE
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {HTML}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default &lt;div class="[...-centerButton]">&lt;div class="[...-resetString]">' + Y.substitute('{resetStr}', Dial.ATTRS.strings.value) + '&lt;/div>&lt;/div>
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Dial.CENTER_BUTTON_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.centerButton + '"><div class="' + Dial.CSS_CLASSES.resetString + ' ' + Dial.CSS_CLASSES.hidden + '">{resetStr}</div></div>';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's handle.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.HANDLE_TEMPLATE
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @type {HTML}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default &lt;div class="[...-handle]">&lt;div class="[...-handleUser]" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0">&lt;/div>&lt;/div>';// title="{tooltipHandle}"
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handle + '" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">';
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }else{ // VML case
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + ' ' + Dial.CSS_CLASSES.ringVml + '">'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '<div class="' + Dial.CSS_CLASSES.northMark + '"></div>'+
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff '<v:oval strokecolor="#ceccc0" strokeweight="1px"><v:fill type=gradient color="#8B8A7F" color2="#EDEDEB" angle="45"/></v:oval>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '</div>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '';
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Dial.MARKER_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.markerVml + ' ' + Dial.CSS_CLASSES.hidden + '">'+
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff '<v:oval stroked="false">'+
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff '<v:fill opacity="20%" color="#000"/>'+
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff '</v:oval>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '</div>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '';
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff Dial.CENTER_BUTTON_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.centerButton + ' ' + Dial.CSS_CLASSES.centerButtonVml + '">'+
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff '<v:oval strokecolor="#ceccc0" strokeweight="1px">'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '<v:fill type=gradient color="#C7C5B9" color2="#fefcf6" colors="35% #d9d7cb, 65% #fefcf6" angle="45"/>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '<v:shadow on="True" color="#000" opacity="10%" offset="2px, 2px"/>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '</v:oval>'+
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff '<div class="' + Dial.CSS_CLASSES.resetString + ' ' + Dial.CSS_CLASSES.hidden + '">{resetStr}</div>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '</div>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '';
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handleVml + '" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">'+
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff '<v:oval stroked="false">'+
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff '<v:fill opacity="20%" color="#6C3A3A"/>'+
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff '</v:oval>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '</div>'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '';
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /* Dial extends the base Widget class */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.extend(Dial, Widget, {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * creates the DOM structure for the Dial.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method renderUI
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff renderUI : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderLabel();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderRing();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderMarker();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderCenterButton();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderHandle();
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // object handles
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.contentBox = this.get("contentBox");
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // constants
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff this._originalValue = this.get('value');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // variables
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._timesWrapped = 0;
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff this._angle = this._getAngleFromValue(this.get('value'));
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._prevAng = this._angle;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff // init
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._setTimesWrappedFromValue(this._originalValue);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.set('aria-valuemin', this.get('min'));
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.set('aria-valuemax', this.get('max'));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff /**
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * Sets -webkit-border-radius to 50% of width/height of the ring, handle-user, marker-user, and center-button.
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * This is needed for iOS 3.x.
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * The objects render square if the radius is > 50% of the width/height
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * @method _setBorderRadius
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * @private
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff */
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff _setBorderRadius : function(){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._ringNode.setStyles({'WebkitBorderRadius':this._ringNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'MozBorderRadius':this._ringNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'borderRadius':this._ringNodeRadius + 'px'
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff });
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._handleNode.setStyles({'WebkitBorderRadius':this._handleNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'MozBorderRadius':this._handleNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'borderRadius':this._handleNodeRadius + 'px'
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff });
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._markerNode.setStyles({'WebkitBorderRadius':this._markerNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'MozBorderRadius':this._markerNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'borderRadius':this._markerNodeRadius + 'px'
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff });
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerButtonNode.setStyles({'WebkitBorderRadius':this._centerButtonNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'MozBorderRadius':this._centerButtonNodeRadius + 'px',
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'borderRadius':this._centerButtonNodeRadius + 'px'
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff });
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff },
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Creates the Y.DD.Drag instance used for the handle movement and
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * binds Dial interaction to the configured value model.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method bindUI
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff bindUI : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.after("valueChange", this._afterValueChange);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var boundingBox = this.get("boundingBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // Looking for a key event which will fire continously across browsers while the key is held down.
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff keyEventSpec = (!Y.UA.opera) ? "down:" : "press:",
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff keyLeftRightSpec = (!Y.UA.opera) ? "down:" : "press:";
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff // 38, 40 = arrow up/down, 33, 34 = page up/down, 35 , 36 = end/home
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff keyEventSpec += "38, 40, 33, 34, 35, 36";
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff // 37 , 39 = arrow left/right
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff keyLeftRightSpec += "37, 39";
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.on("key", Y.bind(this._onDirectionKey, this), boundingBox, keyEventSpec);
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff Y.on("key", Y.bind(this._onLeftRightKey, this), boundingBox, keyLeftRightSpec);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Y.on('mouseenter', function(){this.one('.' + Dial.CSS_CLASSES.resetString).removeClass(Dial.CSS_CLASSES.hidden);}, this._centerButtonNode);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Y.on('mouseleave', function(){this.one('.' + Dial.CSS_CLASSES.resetString).addClass(Dial.CSS_CLASSES.hidden);}, this._centerButtonNode);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.on('click', Y.bind(this._resetDial, this), this._centerButtonNode);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff Y.on('mousedown', Y.bind(function(){this._handleNode.focus();}, this), this._handleNode);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var dd1 = new Y.DD.Drag({
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff node: this._handleNode,
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff on : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff 'drag:drag' : Y.bind(this._handleDrag, this),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff 'drag:start' : Y.bind(this._handleDragStart, this),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff 'drag:end' : Y.bind(this._handleDragEnd, this)
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff });
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Sets _timesWrapped based on Dial value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * to net integer revolutions the user dragged the handle around the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _setTimesWrappedFromValue
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param val {Number} current value of the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @private
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _setTimesWrappedFromValue : function(val){
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff if(val % this.get('stepsPerRevolution') === 0){
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff this._timesWrapped = (val / this.get('stepsPerRevolution'));
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff }else{
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff this._timesWrapped = Math.floor(val / this.get('stepsPerRevolution'));
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff }
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * handles the user dragging the handle around the Dial, calculates the angle,
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * checks for wrapping around top center, handles exceeding min or max values
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _handleDrag
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @param e {DOMEvent} the drag event object
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _handleDrag : function(e){
7defd8450188bddcb9e79a7d1c2246aa027ed78fJeff Conniff var handleCenterX = (e.pageX + this._handleNodeRadius),
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff handleCenterY = (e.pageY + this._handleNodeRadius),
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff dMax = this.get('max'),
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff dMin = this.get('min'),
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff ang = Math.atan( (this._centerYOnPage - handleCenterY) / (this._centerXOnPage - handleCenterX) ) * (180 / Math.PI),
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff newValue;
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff ang = ((this._centerXOnPage - handleCenterX) < 0) ? ang + 90 : ang + 90 + 180;
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // check for need to set timesWrapped
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff if((this._prevAng > 270) && (ang < 90)){ // If wrapping, clockwise
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._timesWrapped = (this._timesWrapped + 1);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff }else if((this._prevAng < 90) && (ang > 270)){ // if un-wrapping, counter-clockwise
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._timesWrapped = (this._timesWrapped - 1);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._prevAng = ang;
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff newValue = this._getValueFromAngle(ang); // This function needs the current _timesWrapped value
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // handle hitting max and min and going beyond, stops at max or min
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff if((newValue > dMin) && (newValue < dMax)) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.set('value', newValue);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff }else if(newValue > dMax){
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this.set('value', dMax);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this._setTimesWrappedFromValue(dMax);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this._prevAng = this._getAngleFromValue(dMax);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff }else if(newValue < dMin){
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this.set('value', dMin);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this._setTimesWrappedFromValue(dMin);
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff this._prevAng = this._getAngleFromValue(dMin);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * handles the user starting to drag the handle around the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _handleDragStart
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @param e {DOMEvent} the drag event object
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _handleDragStart : function(e){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._markerNode.removeClass(Dial.CSS_CLASSES.hidden);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerYOnPage = (this._ringNode.getY() + this._ringNodeRadius);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerXOnPage = (this._ringNode.getX() + this._ringNodeRadius);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /*
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * When handle is handleDragEnd, this animates the return to the fixed dial
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * handles the end of a user dragging the handle, animates the handle returning to
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * resting position.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _handleDragEnd
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _handleDragEnd : function(){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var node = this._handleNode;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff node.transition({
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff duration: 0.08, // seconds
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff easing: 'ease-in',
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff left: this._setNodeToFixedRadius(this._handleNode, true)[0] + 'px',
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff top: this._setNodeToFixedRadius(this._handleNode, true)[1] + 'px'
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }, Y.bind(function(){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._markerNode.addClass(Dial.CSS_CLASSES.hidden);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }, this)
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff );
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * returns the XY of the fixed position, handleDistance, from the center of the Dial (resting position)
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * The XY also represents the angle related to the current value
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * If typeArray is true, [X,Y] is returned.
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * If typeArray is false, the XY of the node passed is set.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _setNodeToFixedRadius
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param obj {Node}
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * @param typeArray {Boolean} true returns an array [X,Y]
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @return {Array} an array of [XY] is optionally returned
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff _setNodeToFixedRadius : function(obj, typeArray){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var thisAngle = (this._angle - 90),
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff rad = (Math.PI / 180),
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff newY = Math.round(Math.sin(thisAngle * rad) * this._handleDistance),
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff newX = Math.round(Math.cos(thisAngle * rad) * this._handleDistance),
7defd8450188bddcb9e79a7d1c2246aa027ed78fJeff Conniff dia = obj.get('offsetWidth'); //Ticket #2529852
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff newY = newY - (dia * 0.5);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff newX = newX - (dia * 0.5);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff if(typeArray){ // just need the style for css transform left and top to animate the handle drag:end
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff return [(this._ringNodeRadius + newX), (this._ringNodeRadius + newY)];
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff }else{
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff obj.setStyle('left', (this._ringNodeRadius + newX) + 'px');
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff obj.setStyle('top', (this._ringNodeRadius + newY) + 'px');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Synchronizes the DOM state with the attribute settings.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method syncUI
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff syncUI : function() {
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff // Make the marker and the resetString display so their placement and borderRadius can be calculated, then hide them again.
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff // We would have used visibility:hidden in the css of this class,
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff // but IE8 VML never returns to visible after applying visibility:hidden then removing it.
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff this._markerNode.removeClass('yui3-dial-hidden');
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff this._resetString.removeClass('yui3-dial-hidden');
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._setSizes();
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._setBorderRadius();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._uiSetValue(this.get("value"));
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff this._markerNode.addClass('yui3-dial-hidden');
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff this._resetString.addClass('yui3-dial-hidden');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff /**
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * sets the sizes of ring, center-button, marker and handle VML ovals in pixels.
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * Needed only in some IE versions
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * that ignore percent style sizes/offsets.
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * so these must be set in pixels.
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * Normally these are set in % of the ring.
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _setSizes //FIXME: this name should have VML removed, doing for all.
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * @protected
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _setSizes : function(){
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff var dia = this.get('diameter');
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff var setSize = function(node, dia, percent){
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff var suffix = 'px';
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff node.getElementsByTagName('oval').setStyle('width', (dia * percent) + suffix);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff node.getElementsByTagName('oval').setStyle('height', (dia * percent) + suffix);
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff node.setStyle('width', (dia * percent) + suffix);
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff node.setStyle('height', (dia * percent) + suffix);
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff };
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff setSize(this._ringNode, dia, 1.0);
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff setSize(this._handleNode, dia, this.get('handleDiameter'));
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff setSize(this._markerNode, dia, this.get('markerDiameter'));
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff setSize(this._centerButtonNode, dia, this.get('centerButtonDiameter'));
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // Set these (used for trig) this way instead of relative to dia,
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // in case they have borders, have images etc.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._ringNodeRadius = this._ringNode.get('offsetWidth') * 0.5;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._handleNodeRadius = this._handleNode.get('offsetWidth') * 0.5;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._markerNodeRadius = this._markerNode.get('offsetWidth') * 0.5;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerButtonNodeRadius = this._centerButtonNode.get('offsetWidth') * 0.5;
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff this._handleDistance = this._ringNodeRadius * this.get('handleDistance');
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // place the centerButton
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff var offset = (this._ringNodeRadius - this._centerButtonNodeRadius);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerButtonNode.setStyle('left', offset + 'px');
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._centerButtonNode.setStyle('top', offset + 'px');
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff /*
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff Place the resetString
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff This seems like it should be able to be done with CSS,
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff But since there is also a VML oval in IE that is absolute positioned,
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff The resetString ends up behind the VML oval.
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff var offsetResetX = (this._centerButtonNodeRadius - (this._resetString.get('offsetWidth') * 0.5));
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff var offsetResetY = (this._centerButtonNodeRadius - (this._resetString.get('offsetHeight') * 0.5));
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._resetString.setStyles({'left':offsetResetX + 'px', 'top':offsetResetY + 'px'});
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff },
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * renders the DOM object for the Dial's label
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _renderLabel
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _renderLabel : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff label = contentBox.one("." + Dial.CSS_CLASSES.label);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!label) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff label = Node.create(Y.substitute(Dial.LABEL_TEMPLATE, this.get('strings')));
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff contentBox.append(label);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._labelNode = label;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._valueStringNode = this._labelNode.one("." + Dial.CSS_CLASSES.valueString);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * renders the DOM object for the Dial's background ring
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _renderRing
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _renderRing : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff ring = contentBox.one("." + Dial.CSS_CLASSES.ring);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!ring) {
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff ring = contentBox.appendChild(Dial.RING_TEMPLATE);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff ring.setStyles({width:this.get('diameter') + 'px', height:this.get('diameter') + 'px'});
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._ringNode = ring;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * renders the DOM object for the Dial's background marker which
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * tracks the angle of the user dragging the handle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _renderMarker
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _renderMarker : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff marker = contentBox.one("." + Dial.CSS_CLASSES.marker);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!marker) {
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff marker = contentBox.one('.' + Dial.CSS_CLASSES.ring).appendChild(Dial.MARKER_TEMPLATE);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._markerNode = marker;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * renders the DOM object for the Dial's center
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _renderCenterButton
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _renderCenterButton : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff centerButton = contentBox.one("." + Dial.CSS_CLASSES.centerButton);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!centerButton) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff centerButton = Node.create(Y.substitute(Dial.CENTER_BUTTON_TEMPLATE, this.get('strings')));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff contentBox.one('.' + Dial.CSS_CLASSES.ring).append(centerButton);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._centerButtonNode = centerButton;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._resetString = this._centerButtonNode.one('.' + Dial.CSS_CLASSES.resetString);
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * renders the DOM object for the Dial's user draggable handle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _renderHandle
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _renderHandle : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
7defd8450188bddcb9e79a7d1c2246aa027ed78fJeff Conniff handle = contentBox.one("." + Dial.CSS_CLASSES.handle);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!handle) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff handle = Node.create(Y.substitute(Dial.HANDLE_TEMPLATE, this.get('strings')));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff contentBox.one('.' + Dial.CSS_CLASSES.ring).append(handle);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._handleNode = handle;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * sets the visible UI label HTML string
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * @method _setLabelString
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @param str {HTML}
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @deprecated Use DialObjName.set('strings',{'label':'My new label'}); before DialObjName.render();
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff _setLabelString : function(str) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.get("contentBox").one("." + Dial.CSS_CLASSES.labelString).setContent(str);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * sets the visible UI label HTML string
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * @method _setResetString
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @param str {HTML}
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @deprecated Use DialObjName.set('strings',{'resetStr':'My new reset string'}); before DialObjName.render();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff _setResetString : function(str) {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this.get("contentBox").one("." + Dial.CSS_CLASSES.resetString).setContent(str);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // this._setXYResetString(); // This used to recenter the string in the button. Done with CSS now. Method has been removed.
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // this._resetString.setContent(''); //We no longer show/hide the reset string with setContent but by addClass and removeClass .yui3-dial-reset-string-hidden
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * sets the tooltip HTML string in the Dial's handle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * @method _setTooltipString
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @param str {HTML}
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @deprecated Use DialObjName.set('strings',{'tooltipHandle':'My new tooltip'}); before DialObjName.render();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff _setTooltipString : function(str) {
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.set('title', str);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * sets the Dial's value in response to key events.
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * Left and right keys are in a separate method
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * in case an implementation wants to increment values
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * but needs left and right arrow keys for other purposes.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _onDirectionKey
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @param e {Event} the key event
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _onDirectionKey : function(e) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff e.preventDefault();
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff switch (e.charCode) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 38: // up
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._incrMinor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 40: // down
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._decrMinor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 36: // home
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._resetDial();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 35: // end
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._setToMax();
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 33: // page up
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._incrMajor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 34: // page down
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._decrMajor();
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff break;
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * sets the Dial's value in response to left or right key events
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @method _onLeftRightKey
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @param e {Event} the key event
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff _onLeftRightKey : function(e) {
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff e.preventDefault();
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff switch (e.charCode) {
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff case 37: // left
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff this._decrMinor();
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff break;
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff case 39: // right
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff this._incrMinor();
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff break;
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff }
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * increments Dial value by a minor increment
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _incrMinor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _incrMinor : function(){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var newVal = (this.get('value') + this.get("minorStep"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff newVal = Math.min(newVal, this.get("max"));
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * decrements Dial value by a minor increment
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _decrMinor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _decrMinor : function(){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var newVal = (this.get('value') - this.get("minorStep"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff newVal = Math.max(newVal, this.get("min"));
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * increments Dial value by a major increment
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _incrMajor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _incrMajor : function(){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var newVal = (this.get('value') + this.get("majorStep"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff newVal = Math.min(newVal, this.get("max"));
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * decrements Dial value by a major increment
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _decrMajor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _decrMajor : function(){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var newVal = (this.get('value') - this.get("majorStep"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff newVal = Math.max(newVal, this.get("min"));
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * sets Dial value to dial's max attr
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _decrMajor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _setToMax : function(){
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', this.get("max"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * sets Dial value to dial's min attr
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _decrMajor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _setToMin : function(){
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', this.get("min"));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * resets Dial value to the orignal initial value.
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _resetDial
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _resetDial : function(){
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this.set('value', this._originalValue);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.focus();
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * returns the handle angle associated with the current value of the Dial. Returns a number between 0 and 360.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _getAngleFromValue
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param newVal {Number} the current value of the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @return {Number} the angle associated with the current Dial value
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _getAngleFromValue : function(newVal){
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff var nonWrappedPartOfValue = newVal % this.get('stepsPerRevolution');
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff var angleFromValue = nonWrappedPartOfValue / this.get('stepsPerRevolution') * 360;
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff return (angleFromValue < 0) ? (angleFromValue + 360) : angleFromValue;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * returns the value of the Dial calculated from the current handle angle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _getValueFromAngle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param angle {Number} the current angle of the Dial's handle
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @return {Number} the current Dial value corresponding to the handle position
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _getValueFromAngle : function(angle){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if(angle < 0){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff angle = (360 + angle);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }else if(angle === 0){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff angle = 360;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff var value = (angle / 360) * this.get('stepsPerRevolution');
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff value = (value + (this._timesWrapped * this.get('stepsPerRevolution')));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff //return Math.round(value * 100) / 100;
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff return value.toFixed(this.get('decimalPlaces')) - 0;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * calls the method to update the UI whenever the Dial value changes
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _afterValueChange
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param e {Event}
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _afterValueChange : function(e) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._uiSetValue(e.newVal);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * Updates the UI display value of the Dial to reflect
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * the value passed in.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * Makes all other needed UI display changes
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _uiSetValue
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param val {Number} value of the Dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _uiSetValue : function(val) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._angle = this._getAngleFromValue(val);
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff if(this._handleNode.hasClass(Dial.CSS_CLASSES.dragging) === false){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._setTimesWrappedFromValue(val);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._setNodeToFixedRadius(this._handleNode, false);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._prevAng = this._getAngleFromValue(this.get('value'));
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff }
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this._valueStringNode.setContent(val);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.set('aria-valuenow', val);
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._handleNode.set('aria-valuetext', val);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._setNodeToFixedRadius(this._markerNode, false);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if((val === this.get('max')) || (val === this.get('min'))){
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff if(this._markerNode.hasClass('marker-max-min') === false){
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._markerNode.addClass('marker-max-min');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if(supportsVML === true){
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._markerNode.getElementsByTagName('fill').set('color', '#AB3232');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }else{
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if(supportsVML === true){
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._markerNode.getElementsByTagName('fill').set('color', '#000');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff if(this._markerNode.hasClass('marker-max-min') === true){
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._markerNode.removeClass('marker-max-min');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * value attribute default validator. Verifies that
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * the value being set lies between the min/max value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _validateValue
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param val {Number} value of the Dial
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _validateValue: function(val) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var min = this.get("min"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff max = this.get("max");
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff return (Lang.isNumber(val) && val >= min && val <= max);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff });
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.Dial = Dial;