Created
October 1, 2009 23:38
-
-
Save rainhead/199325 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
Caption.ATTRS = { | |
title_element: {}, | |
edit_input: {}, | |
edit_button: {}, | |
save_button: {} | |
}; | |
Caption.HTML_PARSER = { | |
title_element: '.view h3', | |
edit_input: '.edit input', | |
edit_button: '.view a[rel=edit]', | |
save_button: '.edit button' | |
}; | |
Y.extend(Caption, Y.Widget, { | |
bindUI: function () { | |
this.get('edit_button').on('click', this.edit, this); | |
this.get('save_button').on('click', this.save, this); | |
}, | |
edit: function () { | |
this.get('edit_input').set('value', this.get('title_element').get('text')); | |
this.get('contentBox').addClass('editing'); | |
}, | |
save: function () { | |
this.get('title_element').set('text', this.get('edit_input').get('value')); | |
this.get('contentBox').removeClass('editing'); | |
} | |
}); | |
/* instantiation */ | |
var caption = new Caption({contentBox: Y.one('#caption1')}); | |
caption.render(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment