Mercurial > hg > OKFNAnnotator
annotate annotator_files/lib/notification.js @ 3:6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
author | casties |
---|---|
date | Thu, 05 Apr 2012 19:37:27 +0200 |
parents | |
children | 6979313586cf |
rev | line source |
---|---|
3
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
1 var Annotator, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
2 __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
3 __hasProp = Object.prototype.hasOwnProperty, |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
4 __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
5 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
6 Annotator = Annotator || {}; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
7 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
8 Annotator.Notification = (function(_super) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
9 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
10 __extends(Notification, _super); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
11 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
12 Notification.prototype.events = { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
13 "click": "hide" |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
14 }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
15 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
16 Notification.prototype.options = { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
17 html: "<div class='annotator-notice'></div>", |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
18 classes: { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
19 show: "annotator-notice-show", |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
20 info: "annotator-notice-info", |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
21 success: "annotator-notice-success", |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
22 error: "annotator-notice-error" |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
23 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
24 }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
25 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
26 function Notification(options) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
27 this.hide = __bind(this.hide, this); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
28 this.show = __bind(this.show, this); Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
29 } |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
30 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
31 Notification.prototype.show = function(message, status) { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
32 if (status == null) status = Annotator.Notification.INFO; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
33 $(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).escape(message || ""); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
34 setTimeout(this.hide, 5000); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
35 return this; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
36 }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
37 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
38 Notification.prototype.hide = function() { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
39 $(this.element).removeClass(this.options.classes.show); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
40 return this; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
41 }; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
42 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
43 return Notification; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
44 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
45 })(Delegator); |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
46 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
47 Annotator.Notification.INFO = 'show'; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
48 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
49 Annotator.Notification.SUCCESS = 'success'; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
50 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
51 Annotator.Notification.ERROR = 'error'; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
52 |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
53 $(function() { |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
54 var notification; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
55 notification = new Annotator.Notification; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
56 Annotator.showNotification = notification.show; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
57 return Annotator.hideNotification = notification.hide; |
6356e78ccf5c
new version contains Annotator JS files to be used with FilesystemSite.
casties
parents:
diff
changeset
|
58 }); |