Skip to content

Commit

Permalink
now using the on('click') api instead
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrikJoreteg committed Feb 6, 2012
1 parent 2c2f896 commit 41f62b5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 36 deletions.
29 changes: 11 additions & 18 deletions build/ui.js
Expand Up @@ -965,13 +965,19 @@ exports.error = type('error');
*/

function Notification(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (Notification.effect) this.effect(Notification.effect);
};

/**
* Inherit from `Emitter.prototype`.
*/

Notification.prototype = new ui.Emitter;

/**
* Render with the given `options`.
Expand All @@ -991,6 +997,11 @@ Notification.prototype.render = function(options){
return false;
});

el.click(function(e){
e.preventDefault();
self.emit('click', e);
});

el.find('h1').text(title);
if (!title) el.find('h1').remove();

Expand Down Expand Up @@ -1115,24 +1126,6 @@ Notification.prototype.remove = function(){
this.el.remove();
return this;
};

/**
* Enable a click callback.
*
* @return {Notification} for chaining
* @api public
*/

Notification.prototype.click = function(fn){
var self = this;
this.el.click(function(e){
e.preventDefault();
e.stopPropagation();
self.hide();
fn && fn();
});
return this;
};
})(ui, "<li class=\"notification hide\">\n <div class=\"content\">\n <h1>Title</h1>\n <a href=\"#\" class=\"close\">×</a>\n <p>Message</p>\n </div>\n</li>");
;(function(exports, html){

Expand Down
29 changes: 11 additions & 18 deletions lib/components/notification/notification.js
Expand Up @@ -77,13 +77,19 @@ exports.error = type('error');
*/

function Notification(options) {
ui.Emitter.call(this);
options = options || {};
this.template = html;
this.el = $(this.template);
this.render(options);
if (Notification.effect) this.effect(Notification.effect);
};

/**
* Inherit from `Emitter.prototype`.
*/

Notification.prototype = new ui.Emitter;

/**
* Render with the given `options`.
Expand All @@ -103,6 +109,11 @@ Notification.prototype.render = function(options){
return false;
});

el.click(function(e){
e.preventDefault();
self.emit('click', e);
});

el.find('h1').text(title);
if (!title) el.find('h1').remove();

Expand Down Expand Up @@ -226,22 +237,4 @@ Notification.prototype.hide = function(ms){
Notification.prototype.remove = function(){
this.el.remove();
return this;
};

/**
* Enable a click callback.
*
* @return {Notification} for chaining
* @api public
*/

Notification.prototype.click = function(fn){
var self = this;
this.el.click(function(e){
e.preventDefault();
e.stopPropagation();
self.hide();
fn && fn();
});
return this;
};

0 comments on commit 41f62b5

Please sign in to comment.