Skip to content

Instantly share code, notes, and snippets.

@rainhead
Created October 1, 2009 23:38
Show Gist options
  • Save rainhead/199325 to your computer and use it in GitHub Desktop.
Save rainhead/199325 to your computer and use it in GitHub Desktop.
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