Dial.js revision df71f95acec70ebddf0ab97cc1e0ff2b70048017
var supportsVML = false;
'v', // vml namespace
'urn:schemas-microsoft-com:vml',
'#default#VML' // required for IE8
);
supportsVML = true;
}
}
/* Dial class constructor */
}
/*
* Required NAME static field, to identify the Widget class and
* used as an event prefix, to generate class names etc. (set to the
* class name in camel case).
* Jeff says, "Camel doesn't seem to work for me. spinWheel didn't work."
*/
/*
* The attribute configuration for the Dial widget. Attributes can be
* as with any other class extending Base.
*/
// The minimum value for the dial.
min : {
value:0
},
// The maximum value for the dial.
max : {
value:100
},
// The diameter of the dial
diameter : {
value:100
},
// The current value of the dial.
value : {
value:0,
return this._validateValue(val);
}
},
minorStep : {
value:1
},
majorStep : {
value:10
},
// The value increments in 360 degrees of rotation
stepsPerRev : {
value:365
},
// The strings for the dial UI. This attribute is
// defined by the base Widget class but has an empty value. The
// dial is simply providing a default value for the attribute.
strings: {
resetStr: 'Reset',
tooltipHandle: 'Press the arrow up/down/left/right keys for minor increments, page up/down for major increments, home for reset.'
}
},
// The distance from the center of the dial to the resting place of the center of the handle and marker.
// The value is a percent of the radius of the dial
value:0.75
}
};
/* Static constant used to identify the classname applied to the spinwheels value field */
function makeClassName(str) {
}
Dial.CSS_CLASSES = {
};
/* Static constants used to define the markup templates used to create Dial DOM elements */
//var strs = this.get('strings');
Dial.LABEL_TEMPLATE = '<div id="' + labelId + '" class="' + Dial.CSS_CLASSES.label + '">' + Y.substitute('{label}', strs) + ':<span class="' + Dial.CSS_CLASSES.valueString + '"></span></div>';
if(supportsVML === false){
Dial.RING_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.ring + '"><div class="' + Dial.CSS_CLASSES.northMark + '"></div></div>';
Dial.MARKER_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.marker + ' marker-hidden"><div class="' + Dial.CSS_CLASSES.markerUser + '"></div></div>';
Dial.CENTER_BUTTON_TEMPLATE = '<div class="' + Dial.CSS_CLASSES.centerButton + '"><div class="' + Dial.CSS_CLASSES.resetString + '">' + Y.substitute('{resetStr}', Dial.ATTRS.strings.value) + '</div></div>';
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"></div></div>';// title="' + Y.substitute('{tooltipHandle}', strs) + '"
}else{ // VML case
'<v:oval strokecolor="#ceccc0" strokeweight="1px" class="' + Dial.CSS_CLASSES.ringVml + '"><v:fill type=gradient color="#8B8A7F" color2="#EDEDEB" angle="45"/></v:oval>'+
'<v:oval></v:oval>'+
'</div>'+
'';
'<v:fill opacity="20%" color="#000"/>'+
'</v:oval>'+
'<v:oval></v:oval>'+
'</div>'+
'';
'<v:oval strokecolor="#ceccc0" strokeweight="1px" class="' + Dial.CSS_CLASSES.centerButtonVml + '">'+
'<v:fill type=gradient color="#C7C5B9" color2="#fefcf6" colors="35% #d9d7cb, 65% #fefcf6" angle="45"/>'+
'<v:shadow on="True" color="#000" opacity="10%" offset="2px, 2px"/>'+
'</v:oval>'+
'<v:oval></v:oval>'+
'<div class="' + Dial.CSS_CLASSES.resetString + '">' + Y.substitute('{resetStr}', Dial.ATTRS.strings.value) + '</div>'+
'</div>'+
'';
' aria-labelledby="' + labelId + '" aria-valuetext="" aria-valuemax="" aria-valuemin="" aria-valuenow="" role="slider" tabindex="0" >'+ //title="' + Y.substitute('{tooltipHandle}', strs) + '"
'<v:fill opacity="20%" color="#6C3A3A"/>'+
'</v:oval>'+
'<v:oval></v:oval>'+
'</div>'+
'';
}
/*
* The HTML_PARSER static constant is used by the Widget base class to populate
* the configuration for the dial instance from markup already on the page.
*
* The Dial class attempts to set the value of the dial widget if it
* finds the appropriate input element on the page.
*/
Dial.HTML_PARSER = {
}
};
/* Dial extends the base Widget class */
/*
* renderUI is part of the lifecycle introduced by the
* Widget class. Widget's renderer method invokes:
*
* renderUI()
* bindUI()
* syncUI()
*
* renderUI is intended to be used by the Widget subclass
* to create or insert new elements into the DOM.
*
* For dial the method adds the input (if it's not already
*/
renderUI : function() {
this._renderLabel();
this._renderInput();
this._renderRing();
this._renderMarker();
this._renderCenterButton();
this._renderHandle();
// object handles
// constants
// variables
this._timesWrapped = 0;
this._angle = 0;
//this._prevX = this._centerXOnPage;
// init Aria
},
/*
* bindUI is intended to be used by the Widget subclass
* to bind any event listeners which will drive the Widget UI.
*
* It will generally bind event listeners for attribute change
* events, to update the state of the rendered UI in response
* to attribute value changes, and also attach any DOM events,
* to activate the UI.
*
* For dial, the method:
*
* - Sets up the attribute change listener for the "value" attribute
*
* - Binds a simple change listener on the input box.
*/
bindUI : function() {
// Looking for a key event which will fire continously across browsers while the key is held down.
keyEventSpec += "37, 39, 38, 40, 33, 34, 35, 36";
node: this._handleNode,
on : {
}
});
},
_dialCenterOver : function(e){
},
_dialCenterOut : function(e){
},
/*
* Reset all to zero and set dial and handle positions
*/
_resetDial : function(){
this._timesWrapped = -1;
//this._inputNode.focus();
},
_handleDrag : function(e){
var ang = Math.atan( (this._centerYOnPage - e.pageY) / (this._centerXOnPage - e.pageX) ) * (180 / Math.PI),
if(deltaX < 0){
}else{
}
// check for need to set timesWrapped
if((this._prevX <= this._centerXOnPage) && (e.pageX > this._centerXOnPage)){ // If wrapping, clockwise
}else if((this._prevX > this._centerXOnPage) && (e.pageX <= this._centerXOnPage)){ // if un-wrapping, counter-clockwise
}
}
}
// Y.log('this._centerYOnPage: ' + this._centerXOnPage + '.....e.pageX: '+ e.pageX + '.......wrap: ' + this._timesWrapped + '......ang: ' + ang);
// handle hitting max and min and going beyond, stops at max or min
//if((newValue > this.get('min')) && (newValue < this.get('max'))) {
}
},
_handleDragStart : function(e){
},
/*
* When handle is handleDragEnd, this animates the return to the fixed dial
*/
_handleDragEnd : function(){
var node = this._handleNode;
easing: 'ease-in',
}, Y.bind(function(){
}, this)
);
// this._inputNode.focus();
// this._inputNode.select();
},
/*
* Sets the XY of the node to the fixed dial within the control (resting position)
* Sets it according to the angle related to the current value
* In the case of handle drag:end, no obj is passed so
* this just returns [X,Y] for style transform
*/
_setNodeToFixedRadius : function(obj){
if(obj){
// obj.setXY([(this._centerXOnPage + newX), (this._centerYOnPage + newY)]);
obj.setXY([(this._ringNode.getX() + this._centerX + newX), (this._ringNode.getY() + this._centerY + newY)]);
}else{ // just need the style for css transform left and top to animate the handle drag:end
}
},
/*
* syncUI is intended to be used by the Widget subclass to
* update the UI to reflect the current state of the widget.
*
* For dial, the method sets the value of the input field,
* to match the current state of the value attribute.
*/
syncUI : function() {
},
/*
* Creates the input control for the dial and adds it to
* the widget's content box, if not already in the markup.
*/
_renderInput : function() {
if (!input) {
}
this._inputNode = input;
},
_renderLabel : function() {
if (!label) {
}
this._labelNode = label;
},
_renderRing : function() {
if (!ring) {
}
},
_renderMarker : function() {
if (!marker) {
}
this._markerNode = marker;
},
_renderCenterButton : function() {
if (!centerButton) {
}
this._centerButtonNode = centerButton;
// centering the reset string in the button
this._resetString.setStyle('top', (this._centerButtonNode.get('region').height / 2) - (this._resetString.get('region').height / 2) + 'px');
this._resetString.setStyle('left', (this._centerButtonNode.get('region').width / 2) - (this._resetString.get('region').width / 2) + 'px');
},
_renderHandle : function() {
if (!handle) {
}
this._handleNode = handle;
},
/*
* Override the default content box value, since we don't want the srcNode
* to be the content box for dial.
*/
_defaultCB : function() {
return null;
},
/*
*
* Increments/Decrement the dial value, based on the key pressed.
*/
_onDirectionKey : function(e) {
e.preventDefault();
switch (e.charCode) { //37 , 39 = arrow left/right, 38, 40 = arrow up/down, 33, 34 = page up/down, 35 , 36 = end/home
case 38: // up
break;
case 40: // down
break;
case 37: // left
break;
case 39: // right
break;
case 36: // home
newVal = 0;
break;
case 35: // end
break;
case 33: // page up
break;
case 34: // page down
break;
}
if(newVal === 0){
this._timesWrapped = -1;
}else{
}
}
// also IE seems to require 2 tab keystrokes to start responding to arrow keys etc. to modify value
// screen reader having trouble with IE6?
// alert("aria-valuenow: " + Y.one('.' + Dial.CSS_CLASSES.handleUser).get('aria-valuenow'));
// alert("aria-valuetext: " + Y.one('.' + Dial.CSS_CLASSES.handleUser).get('aria-valuetext'));
},
_getAngleFromValue : function(newVal){
return angleFromValue;
},
_getValueFromAngle : function(angle){
if(angle < 0){
}else if(angle === 0){
angle = 360;
}
},
_numberKey : function(e){
if(this._validateValue(val)){
}
},
/*
* value attribute change listener. Updates the
* value in the rendered input box, whenever the
* attribute value changes.
*/
_afterValueChange : function(e) {
this._uiSetValue(e.newVal);
},
/*
* Updates the value of the input box to reflect
* the value passed in.
* Makes all other needed UI display changes
*/
_uiSetValue : function(val) {
this._setNodeToFixedRadius(this._handleNode);
this._setNodeToFixedRadius(this._markerNode);
if(supportsVML === true){
}
}
}else{
if(supportsVML === true){
}
}
}
},
/*
* value attribute default validator. Verifies that
*/
_validateValue: function(val) {
}
});