dial.js revision db4ce980273cc4e9e42eebf699de9b44b51768a4
736745cee753d967cf5fb1063c21578ecca61b4aJeff ConniffYUI.add('dial', function(Y) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff/**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Create a circular dial value range input visualized as a draggable handle on a
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * background element.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff * @module dial
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff */
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff var supportsVML = false;
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff if(Y.config.doc.namespaces && Y.config.doc.namespaces.add){
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff Y.config.doc.namespaces.add(
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff 'v', // vml namespace
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff 'urn:schemas-microsoft-com:vml',
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '#default#VML' // required for IE8
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff );
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if(Y.config.doc.createElement('v:oval').strokeColor){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff supportsVML = true;
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var Lang = Y.Lang,
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Widget = Y.Widget,
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Node = Y.Node;
736745cee753d967cf5fb1063c21578ecca61b4aJeff 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
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * position corresponds to a given value.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @class Dial
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @extends Widget
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @param config {Object} Configuration object
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @constructor
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff function Dial(config) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.superclass.constructor.apply(this, arguments);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff // Y.Dial static properties
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * The identity of the widget.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @property Dial.NAME
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @type String
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 'dial'
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @readOnly
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @static
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.NAME = "dial";
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * Static property used to define the default attribute configuration of
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * the Widget.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.ATTRS
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Object}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @static
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.ATTRS = {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff * minimum value allowed
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @attribute min
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default -220
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff min : {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff value:-220
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff * maximum value allowed
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @attribute max
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * @default 220
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff */
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff max : {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff value:220
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff * diameter of the circular background object
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * other objects scale accordingly
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @attribute diameter
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @type {Number} the number of px in diameter
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @default 100
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff diameter : {
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff value:100
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * initial value of the Dial
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @attribute value
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @default 0
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:0,
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff validator: function(val) {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff return this._validateValue(val);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff }
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * amount to increment/decrement the dial value
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * when the arrow up/down/left/right keys are pressed
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @attribute minorStep
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @default 1
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff minorStep : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:1
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * amount to increment/decrement the dial value
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * when the page up/down keys are pressed
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @attribute majorStep
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {Number}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @default 10
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff majorStep : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff value:10
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * number of value increments in one 360 degree revolution
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * of the handle around the dial
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute stepsPerRev
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 100
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff stepsPerRev : {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:100
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * number of decimal places of accuracy in the value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute decimalPlaces
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Number}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default 0
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff decimalPlaces : {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff value:0
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * visible strings for the dial UI. This attribute is
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff 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.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Gets localized strings in the current language
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute strings
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Object}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default {label: 'My label', resetStr: 'Reset', tooltipHandle: 'Drag to set value'}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff strings: {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff valueFn: function () {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff return Y.Intl.get('dial');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff 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.
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * The value is a percent of the radius of the dial.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @attribute handleDist
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {number}
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @default 0.75
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff handleDist:{
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff value:0.75
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff };
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * returns a properly formed yui class name
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @function
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @param {String} string to be appended at the end of class name
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @return
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @private
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff function makeClassName(str) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff return Y.ClassNameManager.getClassName(Dial.NAME, str);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * array of static constants used to identify the classname applied to the Dial DOM objects
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @property Dial.CSS_CLASSES
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {Array}
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @private
a90f7fefd9901a8da896d4bfe602441e0b7078d3Jeff Conniff * @static
a90f7fefd9901a8da896d4bfe602441e0b7078d3Jeff Conniff */
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff Dial.CSS_CLASSES = {
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff label : makeClassName("label"),
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff labelString : makeClassName("label-string"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff valueString : makeClassName("value-string"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff northMark : makeClassName("north-mark"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff ring : makeClassName('ring'),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff ringVml : makeClassName('ring-vml'),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff marker : makeClassName("marker"),
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff markerUser : makeClassName("marker-user"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff centerButton : makeClassName("center-button"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff centerButtonVml : makeClassName('center-button-vml'),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff resetString : makeClassName("reset-str"),
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff handle : makeClassName("handle"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff handleUser : makeClassName("handle-user"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff dragging : Y.ClassNameManager.getClassName("dd-dragging")
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff };
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /* Static constants used to define the markup templates used to create Dial DOM elements */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var labelId = Dial.CSS_CLASSES.label + Y.guid(); //get this unique id once then use
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's label.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @property Dial.LABEL_TEMPLATE
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {String}
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @default <div>...</div>
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff 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
736745cee753d967cf5fb1063c21578ecca61b4aJeff 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
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @type {String}
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @default &lt;div class="[...-ring]">&lt;div class="[...-northMark]">&lt;/div>&lt;/div>
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff */
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + '"><div class="' + Dial.CSS_CLASSES.northMark + '"></div></div>';
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * template that will contain the Dial's current angle marker.
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff *
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @property Dial.MARKER_TEMPLATE
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff * @type {String}
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @default &lt;div class="[...-marker] marker-hidden">&lt;div class="[...-markerUser]">&lt;/div>&lt;/div>
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @protected
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff Dial.MARKER_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.marker + ' marker-hidden"><div class="' + Dial.CSS_CLASSES.markerUser + '"></div></div>';
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * template that will contain the Dial's center button.
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @property Dial.CENTER_BUTTON_TEMPLATE
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @type {String}
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @default &lt;div class="[...-centerButton]">&lt;div class="[...-resetString]">' + Y.substitute('{resetStr}', Dial.ATTRS.strings.value) + '&lt;/div>&lt;/div>
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Dial.CENTER_BUTTON_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.centerButton + '"><div class="' + Dial.CSS_CLASSES.resetString + '">{resetStr}</div></div>';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * template that will contain the Dial's handle.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * @property Dial.HANDLE_TEMPLATE
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @type {String}
f47f024e093853ad3957be898687fc8317a835daJeff 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}"
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handle + '"><div class="' + Dial.CSS_CLASSES.handleUser + '" aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}"></div></div>';// title="{tooltipHandle}"
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }else{ // VML case
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + '">'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<div class="' + Dial.CSS_CLASSES.northMark + '"></div>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<v:oval strokecolor="#ceccc0" strokeweight="1px" class="' + Dial.CSS_CLASSES.ringVml + '"><v:fill type=gradient color="#8B8A7F" color2="#EDEDEB" angle="45"/></v:oval>'+
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff '<v:oval></v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</div>'+
f47f024e093853ad3957be898687fc8317a835daJeff Conniff '';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.MARKER_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.marker + ' marker-hidden">'+
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff '<v:oval stroked="false" class="' + Dial.CSS_CLASSES.markerUser + '">'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<v:fill opacity="20%" color="#000"/>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<v:oval></v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</div>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '';
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff Dial.CENTER_BUTTON_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.centerButton + '">'+
3e16868ea3bfcadfeeb8e23aca5bb2317a6a8ba9Jeff Conniff '<v:oval strokecolor="#ceccc0" strokeweight="1px" class="' + Dial.CSS_CLASSES.centerButtonVml + '">'+
f47f024e093853ad3957be898687fc8317a835daJeff Conniff '<v:fill type=gradient color="#C7C5B9" color2="#fefcf6" colors="35% #d9d7cb, 65% #fefcf6" angle="45"/>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<v:shadow on="True" color="#000" opacity="10%" offset="2px, 2px"/>'+
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff '</v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<v:oval></v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '<div class="' + Dial.CSS_CLASSES.resetString + '">{resetStr}</div>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</div>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff Dial.HANDLE_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.handle + '">'+
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff '<v:oval stroked="false" class="' + Dial.CSS_CLASSES.handleUser + '"'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff ' aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" title="{tooltipHandle}">'+ //title="{tooltipHandle}"
f47f024e093853ad3957be898687fc8317a835daJeff Conniff '<v:fill opacity="20%" color="#6C3A3A"/>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</v:oval>'+
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff '<v:oval></v:oval>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '</div>'+
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff '';
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /* Dial extends the base Widget class */
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff Y.extend(Dial, Widget, {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
f47f024e093853ad3957be898687fc8317a835daJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * creates the DOM structure for the Dial.
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method renderUI
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff renderUI : function() {
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff this._renderLabel();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderRing();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._renderMarker();
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._renderCenterButton();
04f7ef259d54aeab53258697e1e7f8856adcc8a6Jeff Conniff this._renderHandle();
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // object handles
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.contentBox = this.get("contentBox");
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff // constants
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._centerX = this.get('diameter') / 2;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._centerY = this.get('diameter') / 2;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._handleDist = this._centerX * this.get('handleDist');
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._originalValue = this.get('value');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // variables
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff this._timesWrapped = 0;
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._angle = this._getAngleFromValue(this.get('value'));
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._setTimesWrapedFromValue(this.get('value'));
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // init
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._handleUserNode.set('aria-valuemin', this.get('min'));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._handleUserNode.set('aria-valuemax', this.get('max'));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff 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
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
f47f024e093853ad3957be898687fc8317a835daJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff 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.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff keyEventSpec = (!Y.UA.opera) ? "down:" : "press:",
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff keyLeftRightSpec = (!Y.UA.opera) ? "down:" : "press:";
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff // 38, 40 = arrow up/down, 33, 34 = page up/down, 35 , 36 = end/home
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff keyEventSpec += "38, 40, 33, 34, 35, 36";
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff // 37 , 39 = arrow left/right
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff keyLeftRightSpec += "37, 39";
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff Y.on("key", Y.bind(this._onDirectionKey, this), boundingBox, keyEventSpec);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff Y.on("key", Y.bind(this._onLeftRightKey, this), boundingBox, keyLeftRightSpec);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff Y.on('mouseenter', Y.bind(this._dialCenterOver, this), this._centerButtonNode);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.on('mouseleave', Y.bind(this._dialCenterOut, this), this._centerButtonNode);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.on('click', Y.bind(this._resetDial, this), this._centerButtonNode);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff Y.on('mousedown', Y.bind(function(){this._handleUserNode.focus();}, this), this._handleNode);
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff var dd1 = new Y.DD.Drag({
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff node: this._handleNode,
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff on : {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff 'drag:drag' : Y.bind(this._handleDrag, this),
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff 'drag:start' : Y.bind(this._handleDragStart, this),
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff 'drag:end' : Y.bind(this._handleDragEnd, this)
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff });
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff },
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff /**
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * Sets _timesWrapped based on Dial value
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * to net integer revolutions the user dragged the handle around the Dial
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff *
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * @method _setTimesWrapedFromValue
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff * @param val {Number} current value of the Dial
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @private
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _setTimesWrapedFromValue : function(val){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff if(val % this.get('stepsPerRev') === 0){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._timesWrapped = (val / this.get('stepsPerRev')) -1;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff }else{
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this._timesWrapped = Math.floor(val / this.get('stepsPerRev'));
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff }
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * Sets the string in the object the user clicks to reset the Dial value
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _dialCenterOver
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @param e {DOMEvent} the mouseover event object
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff _dialCenterOver : function(e){
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff this._resetString.setContent(Y.substitute('{resetStr}', this.get('strings')));
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Sets the string in the object the user clicks to reset the Dial value
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * to ""
f47f024e093853ad3957be898687fc8317a835daJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _dialCenterOut
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @param e {DOMEvent} the mouseover event object
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _dialCenterOut : function(e){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._resetString.setContent('');
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * handles the user dragging the handle around the Dial, calculates the angle,
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * checks for wrapping around top center, handles exceeding min or max values
41af0d917f0352d732a7dbf9c9594f3ef30b82a0Jeff Conniff *
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @method _handleDrag
41af0d917f0352d732a7dbf9c9594f3ef30b82a0Jeff Conniff * @param e {DOMEvent} the drag event object
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff _handleDrag : function(e){
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff var ang = Math.atan( (this._centerYOnPage - e.pageY) / (this._centerXOnPage - e.pageX) ) * (180 / Math.PI),
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff deltaX = (this._centerXOnPage - e.pageX);
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff if(deltaX < 0){
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff ang = (ang + 90);
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff }else{
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff ang = (ang - 90);
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff }
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff // check for need to set timesWrapped
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff if(e.pageY < this._centerYOnPage){ //if handle is above the middle of the dial...
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if((this._prevX <= this._centerXOnPage) && (e.pageX > this._centerXOnPage)){ // If wrapping, clockwise
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._timesWrapped = (this._timesWrapped + 1);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }else if((this._prevX > this._centerXOnPage) && (e.pageX <= this._centerXOnPage)){ // if un-wrapping, counter-clockwise
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._timesWrapped = (this._timesWrapped - 1);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._prevX = e.pageX;
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff var 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
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff //if((newValue > this.get('min')) && (newValue < this.get('max'))) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff if((newValue > this.get('min')) && (newValue < this.get('max'))) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.set('value', newValue);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }else if(newValue > this.get('max')){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.set('value', this.get('max'));
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff }else if(newValue < this.get('min')){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.set('value', this.get('min'));
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff /**
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * handles the user starting to drag the handle around the Dial
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff *
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff * @method _handleDragStart
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff * @param e {DOMEvent} the drag event object
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _handleDragStart : function(e){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._markerNode.removeClass('marker-hidden');
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff if(!this._prevX){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._prevX = this._handleNode.getX();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
f47f024e093853ad3957be898687fc8317a835daJeff Conniff this._centerYOnPage = (this._ringNode.getY() + this._centerY);
f47f024e093853ad3957be898687fc8317a835daJeff Conniff this._centerXOnPage = (this._ringNode.getX() + this._centerX);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff /*
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff * When handle is handleDragEnd, this animates the return to the fixed dial
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff */
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff /**
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * handles the end of a user dragging the handle, animates the handle returning to
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * resting position.
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff *
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff * @method _handleDragEnd
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @protected
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff */
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff _handleDragEnd : function(){
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff var node = this._handleNode;
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff node.transition({
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff duration: 0.08, // seconds
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff easing: 'ease-in',
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff left: this._setNodeToFixedRadius()[0] + 'px',
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff top: this._setNodeToFixedRadius()[1] + 'px'
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff }, Y.bind(function(){
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff this._markerNode.addClass('marker-hidden');
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff this._prevX = this._handleNode.getX(); //makes us ready for next drag.
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff }, this)
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff );
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff this._setTimesWrapedFromValue(this.get('value'));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff /**
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff * returns the XY of the fixed position, handleDist, from the center of the Dial (resting position)
82cdeb4d776987d0e2501978b1e1c50143931bbcJeff Conniff * The XY also represents the angle related to the current value
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * If no param is passed, [X,Y] is returned.
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * If param is passed, the XY of the node passed is set.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @method _setNodeToFixedRadius
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @param obj {Node}
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @protected
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @return {Array} an array of [XY] is optionally returned
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff */
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff _setNodeToFixedRadius : function(obj){
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff var thisAngle = (this._angle - 90),
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff rad = (Math.PI / 180);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff var newY = Math.round(Math.sin(thisAngle * rad) * this._handleDist);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff var newX = Math.round(Math.cos(thisAngle * rad) * this._handleDist);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff if(obj){
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff obj.setXY([(this._ringNode.getX() + this._centerX + newX), (this._ringNode.getY() + this._centerY + newY)]);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff }else{ // just need the style for css transform left and top to animate the handle drag:end
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff return [this._centerX + newX, this._centerX + newY];
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * Synchronizes the DOM state with the attribute settings.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method syncUI
f47f024e093853ad3957be898687fc8317a835daJeff Conniff */
f47f024e093853ad3957be898687fc8317a835daJeff Conniff syncUI : function() {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._uiSetValue(this.get("value"));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * renders the DOM object for the Dial's label
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _renderLabel
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _renderLabel : function() {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var contentBox = this.get("contentBox"),
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff label = contentBox.one("." + Dial.CSS_CLASSES.label);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff if (!label) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff label = Node.create(Y.substitute(Dial.LABEL_TEMPLATE, this.get('strings')));
f47f024e093853ad3957be898687fc8317a835daJeff Conniff contentBox.append(label);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._labelNode = label;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._valueStringNode = this._labelNode.one("." + Dial.CSS_CLASSES.valueString);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * renders the DOM object for the Dial's background ring
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _renderRing
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @protected
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff */
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff _renderRing : function() {
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff var contentBox = this.get("contentBox"),
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff ring = contentBox.one("." + Dial.CSS_CLASSES.ring);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff if (!ring) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff ring = Node.create(Dial.RING_TEMPLATE);
24ef71067b8f34f90df1fc636a73424647c97f4bJeff Conniff contentBox.append(ring);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff ring.setStyles({width:this.get('diameter') + 'px', height:this.get('diameter') + 'px'});
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff }
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._ringNode = ring;
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff /**
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff 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
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * @protected
f47f024e093853ad3957be898687fc8317a835daJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _renderMarker : function() {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var contentBox = this.get("contentBox"),
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff marker = contentBox.one("." + Dial.CSS_CLASSES.marker);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff if (!marker) {
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff marker = Node.create(Dial.MARKER_TEMPLATE);
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff contentBox.one('.' + Dial.CSS_CLASSES.ring).append(marker);
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff }
7defd8450188bddcb9e79a7d1c2246aa027ed78fJeff Conniff this._markerNode = marker;
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._markerUserNode = this._markerNode.one('.' + Dial.CSS_CLASSES.markerUser);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff },
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * places the centerbutton's reset string in the center of the button
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * based on the size of the string object
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _setXYResetString
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _setXYResetString : function(){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._resetString.setStyle('top', (this._centerButtonNode.get('region').height / 2) - (this._resetString.get('region').height / 2) + 'px');
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._resetString.setStyle('left', (this._centerButtonNode.get('region').width / 2) - (this._resetString.get('region').width / 2) + 'px');
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * renders the DOM object for the Dial's center
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff *
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * @method _renderCenterButton
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff * @protected
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _renderCenterButton : function() {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff var contentBox = this.get("contentBox"),
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff centerButton = contentBox.one("." + Dial.CSS_CLASSES.centerButton);
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff if (!centerButton) {
4af2659c7f72aa2813a2eea32fcc568bbea27de7Jeff Conniff centerButton = Node.create(Y.substitute(Dial.CENTER_BUTTON_TEMPLATE, this.get('strings')));
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff contentBox.one('.' + Dial.CSS_CLASSES.ring).append(centerButton);
7e21402185b2bb1c42859a8dca7863be3759647dJeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._centerButtonNode = centerButton;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._resetString = this._centerButtonNode.one('.' + Dial.CSS_CLASSES.resetString);
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff this._setXYResetString(); // centering the reset string in the button
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._resetString.setContent('');
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff //var offset = (this._ringNode.get('region').width - this._centerButtonNode.get('region').width) / 2;
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff var offset = this._ringNode.get('region').width * 0.25; //better in IE
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._centerButtonNode.setXY([(this._ringNode.getX() + offset), (this._ringNode.getY() + offset)]);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff },
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff * renders the DOM object for the Dial's user draggable handle
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _renderHandle
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff * @protected
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff */
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff _renderHandle : function() {
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff var contentBox = this.get("contentBox"),
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff handle = contentBox.one("." + Dial.CSS_CLASSES.handle);
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff if (!handle) {
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff handle = Node.create(Y.substitute(Dial.HANDLE_TEMPLATE, this.get('strings')));
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff contentBox.one('.' + Dial.CSS_CLASSES.ring).append(handle);
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff }
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff this._handleNode = handle;
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff this._handleUserNode = this._handleNode.one('.' + Dial.CSS_CLASSES.handleUser);
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff /**
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * sets the visible UI label string
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _setLabelString
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @param str {String}
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @protected
7928e2ef0532df9064d9374ceda31d6ab080eb2dJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _setLabelString : function(str) {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this.get("contentBox").one("." + Dial.CSS_CLASSES.labelString).setContent(str);
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff },
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff /**
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * sets the visible UI label string
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff *
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * @method _setResetString
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * @param str {String}
11b81e1c54469a27a52271a2bcff20794d259d27Jeff Conniff * @protected
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff */
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff _setResetString : function(str) {
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff this.set('strings.resetStr', str);
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff this.get("contentBox").one("." + Dial.CSS_CLASSES.resetString).setContent(str);
624b3d25f12c6e63f607b2690315293ad7ef6481Jeff Conniff this._setXYResetString(); // recenters the string in the button
e81cc12bafc201061ba76fdfd173f1412371e0ecJeff Conniff this._resetString.setContent('');
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * sets the tooltip string in the Dial's handle
f47f024e093853ad3957be898687fc8317a835daJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _setTooltipString
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @param str {String}
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @protected
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _setTooltipString : function(str) {
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.get("contentBox").one("." + Dial.CSS_CLASSES.handleUser).set('title', str);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * sets the Dial's value in response to key events.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * Left and right keys are in a separate method
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * in case an implementation wants to increment values
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * but needs left and right arrow keys for other purposes.
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _onDirectionKey
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param e {Event} the key event
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _onDirectionKey : function(e) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff e.preventDefault();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff switch (e.charCode) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 38: // up
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff this._incrMinor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 40: // down
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._decrMinor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff case 36: // home
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._resetDial();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff break;
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff case 35: // end
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._setToMax();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff break;
f47f024e093853ad3957be898687fc8317a835daJeff Conniff case 33: // page up
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this._incrMajor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 34: // page down
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._decrMajor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
2aa0883432cf56a974eb9261afcf6ede4313384cJeff Conniff }
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * sets the Dial's value in response to left or right key events
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _onLeftRightKey
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @param e {Event} the key event
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
f47f024e093853ad3957be898687fc8317a835daJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _onLeftRightKey : function(e) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff e.preventDefault();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff switch (e.charCode) {
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 37: // left
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._decrMinor();
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff break;
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff case 39: // right
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._incrMinor();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff break;
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff }
dcb17c0ed0cc508b4c74234b7477b05e6a8723ebJeff Conniff },
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * increments Dial value by a minor increment
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _incrMinor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _incrMinor : function(){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff var newVal = (this.get('value') + this.get("minorStep"));
7defd8450188bddcb9e79a7d1c2246aa027ed78fJeff Conniff newVal = Math.min(newVal, this.get("max"));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff },
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * decrements Dial value by a minor increment
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _decrMinor
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _decrMinor : function(){
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff var newVal = (this.get('value') - this.get("minorStep"));
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff newVal = Math.max(newVal, this.get("min"));
f47f024e093853ad3957be898687fc8317a835daJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff },
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * increments Dial value by a major increment
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _incrMajor
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff _incrMajor : function(){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var newVal = (this.get('value') + this.get("majorStep"));
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff newVal = Math.min(newVal, this.get("max"));
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
f47f024e093853ad3957be898687fc8317a835daJeff Conniff },
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff /**
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * decrements Dial value by a major increment
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff *
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @method _decrMajor
691af6c84a00ad5f629ffcfa3b1e42c38da5da4fJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _decrMajor : function(){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var newVal = (this.get('value') - this.get("majorStep"));
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff newVal = Math.max(newVal, this.get("min"));
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.set('value', newVal.toFixed(this.get('decimalPlaces')) - 0);
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff },
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff
f47f024e093853ad3957be898687fc8317a835daJeff Conniff /**
aa1805d3af3a9ac854fadba9707e18ee5f006804Jeff Conniff * sets Dial value to dial's max attr
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
db4ce980273cc4e9e42eebf699de9b44b51768a4Jeff Conniff * @method _decrMajor
41a8874f3c14857a5a311a43eaf30a123f376771Jeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _setToMax : function(){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff this.set('value', this.get("max"));
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff },
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff /**
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * sets Dial value to dial's min attr
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff *
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff * @method _decrMajor
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * @protected
f47f024e093853ad3957be898687fc8317a835daJeff Conniff */
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff _setToMin : function(){
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this.set('value', this.get("min"));
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * resets Dial value to the orignal initial value.
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _resetDial
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @protected
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _resetDial : function(){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this.set('value', this._originalValue);
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff this._handleUserNode.focus();
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * returns the handle angle associated with the current value of the Dial
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @method _getAngleFromValue
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff * @param newVal {Number} the current value of the Dial
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @return {Number} the angle associated with the current Dial value
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @protected
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff */
df71f95acec70ebddf0ab97cc1e0ff2b70048017Jeff Conniff _getAngleFromValue : function(newVal){
736745cee753d967cf5fb1063c21578ecca61b4aJeff Conniff var nonWrapedPartOfValue = newVal % this.get('stepsPerRev');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var angleFromValue = nonWrapedPartOfValue / this.get('stepsPerRev') * 360;
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff return angleFromValue;
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff
f47f024e093853ad3957be898687fc8317a835daJeff Conniff /**
f47f024e093853ad3957be898687fc8317a835daJeff Conniff * returns the value of the Dial calculated from the current handle angle
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @method _getValueFromAngle
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @param angle {Number} the current angle of the Dial's handle
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @return {Number} the current Dial value corresponding to the handle position
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff * @protected
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff */
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff _getValueFromAngle : function(angle){
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff if(angle < 0){
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff angle = (360 + angle);
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff }else if(angle === 0){
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff angle = 360;
2353184083624510261e335c156a05e8cae2fc41Jeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff var value = (angle / 360) * this.get('stepsPerRev');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff value = (value + (this._timesWrapped * this.get('stepsPerRev')));
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff //return Math.round(value * 100) / 100;
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff return value.toFixed(this.get('decimalPlaces')) - 0;
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
f47f024e093853ad3957be898687fc8317a835daJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * calls the method to update the UI whenever the Dial value changes
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _afterValueChange
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff * @param e {Event}
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _afterValueChange : function(e) {
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._uiSetValue(e.newVal);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
f47f024e093853ad3957be898687fc8317a835daJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * Updates the UI display value of the Dial to reflect
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * the value passed in.
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * Makes all other needed UI display changes
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff * @method _uiSetValue
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @param val {Number} value of the Dial
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _uiSetValue : function(val) {
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._angle = this._getAngleFromValue(val);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if(this._handleNode.hasClass(Dial.CSS_CLASSES.dragging) === false){
f47f024e093853ad3957be898687fc8317a835daJeff Conniff this._setTimesWrapedFromValue(val);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._setNodeToFixedRadius(this._handleNode);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._prevX = this._handleNode.getX();
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._valueStringNode.setContent(val);
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this._handleUserNode.set('aria-valuenow', val);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._handleUserNode.set('aria-valuetext', val);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._setNodeToFixedRadius(this._markerNode);
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if((val === this.get('max')) || (val === this.get('min'))){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if(this._markerUserNode.hasClass('marker-max-min') === false){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._markerUserNode.addClass('marker-max-min');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if(supportsVML === true){
f47f024e093853ad3957be898687fc8317a835daJeff Conniff this._markerUserNode.one('fill').set('color', '#AB3232');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }else{
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if(supportsVML === true){
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff this._markerUserNode.one('fill').set('color', '#000');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff if(this._markerUserNode.hasClass('marker-max-min') === true){
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff this._markerUserNode.removeClass('marker-max-min');
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff },
f47f024e093853ad3957be898687fc8317a835daJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff /**
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * value attribute default validator. Verifies that
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff * the value being set lies between the min/max value
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff *
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @method _validateValue
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @param val {Number} value of the Dial
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff * @protected
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff */
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff _validateValue: function(val) {
f47f024e093853ad3957be898687fc8317a835daJeff Conniff var min = this.get("min"),
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff max = this.get("max");
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff return (Lang.isNumber(val) && val >= min && val <= max);
59927fc7ef43db5ef49fce3811b307e2f0a4267cJeff Conniff }
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff });
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff Y.Dial = Dial;
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff
44c68f247b9311ea767cb4656220793317e3383bJeff Conniff}, '@VERSION@' ,{requires:['widget', 'dd-drag', 'substitute', 'event-mouseenter', 'transition', 'intl'], skinnable:true, lang:['en','es' ]});
f47f024e093853ad3957be898687fc8317a835daJeff Conniff