summaryrefslogtreecommitdiff
path: root/js/core/alert.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/core/alert.js')
-rwxr-xr-xjs/core/alert.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/js/core/alert.js b/js/core/alert.js
new file mode 100755
index 0000000..e145d5f
--- /dev/null
+++ b/js/core/alert.js
@@ -0,0 +1,66 @@
1/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2(function(UI) {
3
4 "use strict";
5
6 UI.component('alert', {
7
8 defaults: {
9 "fade": true,
10 "duration": 200,
11 "trigger": ".uk-alert-close"
12 },
13
14 boot: function() {
15
16 // init code
17 UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) {
18
19 var ele = UI.$(this);
20
21 if (!ele.data("alert")) {
22
23 var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert")));
24
25 if (UI.$(e.target).is(alert.options.trigger)) {
26 e.preventDefault();
27 alert.close();
28 }
29 }
30 });
31 },
32
33 init: function() {
34
35 var $this = this;
36
37 this.on("click", this.options.trigger, function(e) {
38 e.preventDefault();
39 $this.close();
40 });
41 },
42
43 close: function() {
44
45 var element = this.trigger("close.uk.alert"),
46 removeElement = function () {
47 this.trigger("closed.uk.alert").remove();
48 }.bind(this);
49
50 if (this.options.fade) {
51 element.css("overflow", "hidden").css("max-height", element.height()).animate({
52 "height" : 0,
53 "opacity" : 0,
54 "padding-top" : 0,
55 "padding-bottom" : 0,
56 "margin-top" : 0,
57 "margin-bottom" : 0
58 }, this.options.duration, removeElement);
59 } else {
60 removeElement();
61 }
62 }
63
64 });
65
66})(UIkit);