source: OKFNAnnotator (for Zope)/annotator_files/lib/notification.js @ 4:6979313586cf

Last change on this file since 4:6979313586cf was 4:6979313586cf, checked in by casties, 12 years ago

new version of annotator.

File size: 1.9 KB
Line 
1// Generated by CoffeeScript 1.3.3
2var Annotator,
3  __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
4  __hasProp = {}.hasOwnProperty,
5  __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; };
6
7Annotator = Annotator || {};
8
9Annotator.Notification = (function(_super) {
10
11  __extends(Notification, _super);
12
13  Notification.prototype.events = {
14    "click": "hide"
15  };
16
17  Notification.prototype.options = {
18    html: "<div class='annotator-notice'></div>",
19    classes: {
20      show: "annotator-notice-show",
21      info: "annotator-notice-info",
22      success: "annotator-notice-success",
23      error: "annotator-notice-error"
24    }
25  };
26
27  function Notification(options) {
28    this.hide = __bind(this.hide, this);
29
30    this.show = __bind(this.show, this);
31    Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
32  }
33
34  Notification.prototype.show = function(message, status) {
35    if (status == null) {
36      status = Annotator.Notification.INFO;
37    }
38    $(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).escape(message || "");
39    setTimeout(this.hide, 5000);
40    return this;
41  };
42
43  Notification.prototype.hide = function() {
44    $(this.element).removeClass(this.options.classes.show);
45    return this;
46  };
47
48  return Notification;
49
50})(Delegator);
51
52Annotator.Notification.INFO = 'show';
53
54Annotator.Notification.SUCCESS = 'success';
55
56Annotator.Notification.ERROR = 'error';
57
58$(function() {
59  var notification;
60  notification = new Annotator.Notification;
61  Annotator.showNotification = notification.show;
62  return Annotator.hideNotification = notification.hide;
63});
Note: See TracBrowser for help on using the repository browser.