Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ImageToggler = $.klass(Toggler, {
- initialize: function() {
- this.img_src = this.element.attr('src');
- this.active_image = this.element.attr('src').replace(/.png|_rollover.png/, '_active.png');
- this.normal_image = this.element.attr('src').replace(/_active/, '');
- },
- onclick: function() {
- img = this.element.attr('src')
- if (this.element.attr('src').match(/_active/)) {
- this.element.attr('src', img.replace(/_active/, ''))
- }
- else {
- // trying to optionally return _active_rollover.png, or _active.png,
- this.element.attr('src', img.replace(/((_rollover)?.png)/, ('_active' + $1 )));
- }
- }
- });
Add Comment
Please, Sign In to add comment