##// END OF EJS Templates
fix missing semicolons
Matthias BUSSONNIER -
Show More
@@ -1,104 +1,104
1 1 // Copyright (c) IPython Development Team.
2 2 // Distributed under the terms of the Modified BSD License.
3 3
4 4 define([
5 5 'base/js/namespace',
6 6 'jquery',
7 7 ], function(IPython, $) {
8 8 "use strict";
9 9
10 10 var NotificationWidget = function (selector) {
11 11 this.selector = selector;
12 12 this.timeout = null;
13 13 this.busy = false;
14 14 if (this.selector !== undefined) {
15 15 this.element = $(selector);
16 16 this.style();
17 17 }
18 18 this.element.hide();
19 19 var that = this;
20 20
21 21 this.inner = $('<span/>');
22 22 this.element.append(this.inner);
23 23
24 24 };
25 25
26 26 NotificationWidget.prototype.style = function () {
27 27 this.element.addClass('notification_widget');
28 28 };
29 29
30 30 // msg : message to display
31 31 // timeout : time in ms before diseapearing
32 32 //
33 33 // if timeout <= 0
34 34 // click_callback : function called if user click on notification
35 35 // could return false to prevent the notification to be dismissed
36 36 NotificationWidget.prototype.set_message = function (msg, timeout, click_callback, options) {
37 37 var options = options || {};
38 38 var callback = click_callback || function() {return true;};
39 39 var that = this;
40 40 // unbind potential previous callback
41 41 this.element.unbind('click');
42 42 this.inner.attr('class', options.icon);
43 43 this.inner.attr('title', options.title);
44 44 this.inner.text(msg);
45 45 this.element.fadeIn(100);
46 46
47 47 // reset previous set style
48 this.element.removeClass(),
48 this.element.removeClass();
49 49 this.style();
50 50 if (options.class){
51 51
52 52 this.element.addClass(options.class)
53 53 }
54 54 if (this.timeout !== null) {
55 55 clearTimeout(this.timeout);
56 56 this.timeout = null;
57 57 }
58 58 if (timeout !== undefined && timeout >=0) {
59 59 this.timeout = setTimeout(function () {
60 60 that.element.fadeOut(100, function () {that.inner.text('');});
61 61 that.timeout = null;
62 62 }, timeout);
63 63 } else {
64 64 this.element.click(function() {
65 65 if( callback() !== false ) {
66 66 that.element.fadeOut(100, function () {that.inner.text('');});
67 67 that.element.unbind('click');
68 68 }
69 69 if (that.timeout !== undefined) {
70 70 that.timeout = undefined;
71 71 clearTimeout(that.timeout);
72 72 }
73 73 });
74 74 }
75 75 };
76 76
77 77
78 78 NotificationWidget.prototype.info = function (msg, timeout, click_callback, options) {
79 79 var options = options || {};
80 80 options.class = options.class +' info';
81 81 var timeout = timeout || 3500;
82 82 this.set_message(msg, timeout, click_callback, options);
83 83 }
84 84 NotificationWidget.prototype.warning = function (msg, timeout, click_callback, options) {
85 85 var options = options || {};
86 86 options.class = options.class +' warning';
87 87 this.set_message(msg, timeout, click_callback, options);
88 88 }
89 89 NotificationWidget.prototype.danger = function (msg, timeout, click_callback, options) {
90 90 var options = options || {};
91 91 options.class = options.class +' danger';
92 92 this.set_message(msg, timeout, click_callback, options);
93 93 }
94 94
95 95
96 96 NotificationWidget.prototype.get_message = function () {
97 97 return this.inner.html();
98 98 };
99 99
100 100 // For backwards compatibility.
101 101 IPython.NotificationWidget = NotificationWidget;
102 102
103 103 return {'NotificationWidget': NotificationWidget};
104 104 });
@@ -1,31 +1,31
1 1 .notification_widget {
2 2 color: @navbar-default-link-color;
3 3 padding: 1px 12px;
4 4 margin: 2px 4px;
5 5 z-index: 10;
6 6 border-radius: @border-radius-base;
7 7 background: @notification_widget_bg;
8 8 .pull-right();
9 9 .border-box-sizing();
10 10 .btn();
11 11 .btn-default();
12 12 .btn-xs();
13 13
14 14 &.span {
15 15 padding-right:2px;
16 16 }
17 17 }
18 18
19 19 .notification_widget.warning {
20 .btn-warning()
20 .btn-warning();
21 21 }
22 22 .notification_widget.success {
23 .btn-success()
23 .btn-success();
24 24 }
25 25 .notification_widget.info {
26 .btn-info()
26 .btn-info();
27 27 }
28 28 .notification_widget.danger {
29 .btn-danger()
29 .btn-danger();
30 30 }
31 31
General Comments 0
You need to be logged in to leave comments. Login now