Skip to content

Instantly share code, notes, and snippets.

@jacobfogg
Forked from apipkin/gist:519370
Created August 11, 2010 22:55
Show Gist options
  • Save jacobfogg/519956 to your computer and use it in GitHub Desktop.
Save jacobfogg/519956 to your computer and use it in GitHub Desktop.
YUI.add('gallery-slider-captcha', function(Y){
var isString = Y.Lang.isString,
isBoolean = Y.Lang.isBoolean;
Y.SliderCaptcha = Y.Base.create('slider-captcha', Y.Widget, [], {
// P U B L I C //
initializer : function() {
// publish release-success event
// publish release-failure event
},
renderUI : function() {
// build message container
/* My thought for the structure :
<div> <!--constraining div-->
<div></div> <!--text-->
<div></div> <!--thumb-->
</div>
*/
// build handle
// append to content box
},
bindUI : function() {
// add dd to handle and constrain to content box
// add opacity change to text while dragging based on percentage to end. 100% - 10%?
// add animation to spring back on release if not at the edge of the container
// add release callback to fire success or failure event
},
// S U G A R //
isHuman : function() {
return this.get('isHuman');
},
// P R O T E C T E D //
_defSuccessReleaseFn : function(e) {
Y.one('').set('innerHTML',this.get('successText'));// update text
this.set('isHuman',true);// set isHuman to true
//logic to either submit the form or execute the callback function
//what happens at this point? the control renders as useless??
},
_defFailureReleaseFn : function(e) {
this.set('isHuman',false);// set isHuman to false
}
}, {
ATTRS : {
form : {
},
startText : {
value : 'Slide To Submit',
validator :isString
},
successText : {
value : 'Submitting!',
validator :isString
},
isHuman : {
value : false
validator :isBoolean
},
submitOnSuccess : {
value : true, // should it default to submit? - Yes, I think so
validator :isBoolean
},
callback : {//added to give the user the option of a callback method instad of a form submission
}
}
});
}, '0.1', {'widget','dd-constrain'});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment