Guest User

Untitled

a guest
Apr 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. ImageToggler = $.klass(Toggler, {
  2. initialize: function() {
  3. this.img_src = this.element.attr('src');
  4. this.active_image = this.element.attr('src').replace(/.png|_rollover.png/, '_active.png');
  5. this.normal_image = this.element.attr('src').replace(/_active/, '');
  6. },
  7. onclick: function() {
  8. img = this.element.attr('src')
  9. if (this.element.attr('src').match(/_active/)) {
  10. this.element.attr('src', img.replace(/_active/, ''))
  11. }
  12. else {
  13. // trying to optionally return _active_rollover.png, or _active.png,
  14. this.element.attr('src', img.replace(/((_rollover)?.png)/, ('_active' + $1 )));
  15. }
  16. }
  17. });
Add Comment
Please, Sign In to add comment