Created
March 31, 2014 22:41
-
-
Save jconniff/9904049 to your computer and use it in GitHub Desktop.
Simple Example of YUI Dial with alternate actions to increment/decrement the value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://yui.yahooapis.com/3.14.1/build/yui/yui-min.js"></script> | |
</head> | |
<body class="yui3-skin-sam"> | |
<div id="demo"></div> | |
<br /> | |
<div id="buttons"> | |
<button class="xx min"> Min </button> | |
<button class="xx d_maj"> -- </button> | |
<button class="xx d_min"> - </button> | |
<button class="xx i_min"> + </button> | |
<button class="xx i_maj"> ++ </button> | |
<button class="xx max"> Max </button> | |
<button class="xx orig"> Reset </button> | |
</div> | |
<script> | |
YUI().use('dial', function(Y) { | |
var dial = new Y.Dial({ | |
strings: { | |
label: 'Volume', | |
}, | |
min:-34, | |
minorStep:3, // this is how you change the minimum increment step size | |
max:120, | |
stepsPerRevolution:100, | |
value: 0, | |
}).render("#demo"); | |
// event handler for all objects with class 'xx' | |
Y.all('.xx').on('click', function(e){ | |
if(e.target.hasClass('i_min')){ | |
// these are attributes built into dial | |
// You can set their values | |
// http://yuilibrary.com/yui/docs/dial/#attributes | |
dial._incrMinor(); | |
} | |
if(e.target.hasClass('d_min')){ | |
dial._decrMinor(); | |
} | |
if(e.target.hasClass('i_maj')){ | |
dial._incrMajor(); | |
} | |
if(e.target.hasClass('d_maj')){ | |
dial._decrMajor(); | |
} | |
if(e.target.hasClass('min')){ | |
dial._setToMin(); | |
} | |
if(e.target.hasClass('max')){ | |
dial._setToMax(); | |
} | |
if(e.target.hasClass('orig')){ | |
dial._resetDial(); | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment