##// END OF EJS Templates
fix click unbind...
Matthias BUSSONNIER -
Show More
@@ -1,82 +1,82 b''
1 1 //----------------------------------------------------------------------------
2 2 // Copyright (C) 2008-2011 The IPython Development Team
3 3 //
4 4 // Distributed under the terms of the BSD License. The full license is in
5 5 // the file COPYING, distributed as part of this software.
6 6 //----------------------------------------------------------------------------
7 7
8 8 //============================================================================
9 9 // Notification widget
10 10 //============================================================================
11 11
12 12 var IPython = (function (IPython) {
13 13
14 14 var utils = IPython.utils;
15 15
16 16
17 17 var NotificationWidget = function (selector) {
18 18 this.selector = selector;
19 19 this.timeout = null;
20 20 this.busy = false;
21 21 if (this.selector !== undefined) {
22 22 this.element = $(selector);
23 23 this.style();
24 24 }
25 25 this.element.button();
26 26 this.element.hide();
27 27 var that = this;
28 28
29 29 };
30 30
31 31
32 32 NotificationWidget.prototype.style = function () {
33 33 this.element.addClass('notification_widget ui-widget ui-widget-content ui-corner-all');
34 34 this.element.addClass('border-box-sizing');
35 35 };
36 36
37 37 // msg : message to display
38 38 // timeout : time in ms before diseapearing
39 39 //
40 40 // if timeout <= 0
41 41 // click_callback : function called if user click on notification
42 42 // could return false to prevent the notification to be dismissed
43 43 NotificationWidget.prototype.set_message = function (msg, timeout, click_callback) {
44 44 var callback = click_callback || function(){return false};
45 45 var that = this;
46 46 this.element.html(msg);
47 47 this.element.fadeIn(100);
48 48 if (this.timeout !== null) {
49 49 clearTimeout(this.timeout);
50 50 this.timeout = null;
51 51 };
52 52 if (timeout !== undefined && timeout >=0) {
53 53 this.timeout = setTimeout(function () {
54 54 that.element.fadeOut(100, function () {that.element.html('');});
55 55 that.timeout = null;
56 56 }, timeout);
57 57 } else {
58 58 this.element.click(function(){
59 59 if( callback() != false){
60 60 that.element.fadeOut(100, function () {that.element.html('');});
61 that.element.unbind('click')
61 62 }
62 63 if (that.timeout !== undefined) {
63 64 that.timeout = undefined
64 65 clearTimeout(that.timeout);
65 66 }
66 that.element.unbind('click')
67 67 });
68 68 }
69 69 };
70 70
71 71
72 72 NotificationWidget.prototype.get_message = function () {
73 73 return this.element.html();
74 74 };
75 75
76 76
77 77 IPython.NotificationWidget = NotificationWidget;
78 78
79 79 return IPython;
80 80
81 81 }(IPython));
82 82
General Comments 0
You need to be logged in to leave comments. Login now