rainhead (owner)

Revisions

gist: 199325 Download_button fork
public
Public Clone URL: git://gist.github.com/199325.git
Embed All Files: show embed
JavaScript #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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();