mirror of
https://github.com/futurepress/epub.js.git
synced 2025-10-04 15:09:16 +02:00
Added several usage examples, fixed bugs, turned off restore by default
This commit is contained in:
parent
0e08b734ec
commit
416f7ab6a0
112 changed files with 23903 additions and 3348 deletions
65
libs/annotator/lib/notification.js
Normal file
65
libs/annotator/lib/notification.js
Normal file
|
@ -0,0 +1,65 @@
|
|||
// Generated by CoffeeScript 1.6.3
|
||||
var Annotator,
|
||||
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__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; };
|
||||
|
||||
Annotator = Annotator || {};
|
||||
|
||||
Annotator.Notification = (function(_super) {
|
||||
__extends(Notification, _super);
|
||||
|
||||
Notification.prototype.events = {
|
||||
"click": "hide"
|
||||
};
|
||||
|
||||
Notification.prototype.options = {
|
||||
html: "<div class='annotator-notice'></div>",
|
||||
classes: {
|
||||
show: "annotator-notice-show",
|
||||
info: "annotator-notice-info",
|
||||
success: "annotator-notice-success",
|
||||
error: "annotator-notice-error"
|
||||
}
|
||||
};
|
||||
|
||||
function Notification(options) {
|
||||
this.hide = __bind(this.hide, this);
|
||||
this.show = __bind(this.show, this);
|
||||
Notification.__super__.constructor.call(this, $(this.options.html).appendTo(document.body)[0], options);
|
||||
}
|
||||
|
||||
Notification.prototype.show = function(message, status) {
|
||||
if (status == null) {
|
||||
status = Annotator.Notification.INFO;
|
||||
}
|
||||
$(this.element).addClass(this.options.classes.show).addClass(this.options.classes[status]).html(Util.escape(message || ""));
|
||||
setTimeout(this.hide, 5000);
|
||||
return this;
|
||||
};
|
||||
|
||||
Notification.prototype.hide = function() {
|
||||
$(this.element).removeClass(this.options.classes.show);
|
||||
return this;
|
||||
};
|
||||
|
||||
return Notification;
|
||||
|
||||
})(Delegator);
|
||||
|
||||
Annotator.Notification.INFO = 'show';
|
||||
|
||||
Annotator.Notification.SUCCESS = 'success';
|
||||
|
||||
Annotator.Notification.ERROR = 'error';
|
||||
|
||||
$(function() {
|
||||
var notification;
|
||||
notification = new Annotator.Notification;
|
||||
Annotator.showNotification = notification.show;
|
||||
return Annotator.hideNotification = notification.hide;
|
||||
});
|
||||
|
||||
/*
|
||||
//@ sourceMappingURL=notification.map
|
||||
*/
|
Loading…
Add table
Add a link
Reference in a new issue