From 41f62b5c8d9dc34df8b1cc0af7d1a321c53cbe18 Mon Sep 17 00:00:00 2001 From: Henrik Joreteg Date: Mon, 6 Feb 2012 11:12:19 -0800 Subject: [PATCH] now using the `on('click')` api instead --- build/ui.js | 29 ++++++++------------- lib/components/notification/notification.js | 29 ++++++++------------- 2 files changed, 22 insertions(+), 36 deletions(-) diff --git a/build/ui.js b/build/ui.js index 8161b8c..0b158e1 100644 --- a/build/ui.js +++ b/build/ui.js @@ -965,6 +965,7 @@ exports.error = type('error'); */ function Notification(options) { + ui.Emitter.call(this); options = options || {}; this.template = html; this.el = $(this.template); @@ -972,6 +973,11 @@ function Notification(options) { if (Notification.effect) this.effect(Notification.effect); }; +/** + * Inherit from `Emitter.prototype`. + */ + +Notification.prototype = new ui.Emitter; /** * Render with the given `options`. @@ -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(); @@ -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, "
  • \n
    \n

    Title

    \n ×\n

    Message

    \n
    \n
  • "); ;(function(exports, html){ diff --git a/lib/components/notification/notification.js b/lib/components/notification/notification.js index cd70d22..5f007c5 100644 --- a/lib/components/notification/notification.js +++ b/lib/components/notification/notification.js @@ -77,6 +77,7 @@ exports.error = type('error'); */ function Notification(options) { + ui.Emitter.call(this); options = options || {}; this.template = html; this.el = $(this.template); @@ -84,6 +85,11 @@ function Notification(options) { if (Notification.effect) this.effect(Notification.effect); }; +/** + * Inherit from `Emitter.prototype`. + */ + +Notification.prototype = new ui.Emitter; /** * Render with the given `options`. @@ -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(); @@ -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; }; \ No newline at end of file