aboutsummaryrefslogtreecommitdiffstats
path: root/uikit/static/js/core/alert.js
diff options
context:
space:
mode:
authorValentin Heinz <inktrap@users.noreply.github.com>2017-04-08 14:03:25 +0200
committerAlexis Metaireau <alexis@notmyidea.org>2017-04-08 14:03:25 +0200
commit5c231ceade17e7f5b1bba90e845dd2d17e54da1c (patch)
treef4f07dbbac2c51c8a0af1e1a24f11e030a2e4155 /uikit/static/js/core/alert.js
parent00986ab80df4b6be2d1306671907e2b2378e487f (diff)
downloadpelican-themes-5c231ceade17e7f5b1bba90e845dd2d17e54da1c.tar.gz
uikit demo theme ported to pelican (#385)
Diffstat (limited to 'uikit/static/js/core/alert.js')
-rw-r--r--uikit/static/js/core/alert.js66
1 files changed, 66 insertions, 0 deletions
diff --git a/uikit/static/js/core/alert.js b/uikit/static/js/core/alert.js
new file mode 100644
index 0000000..25ea2ad
--- /dev/null
+++ b/uikit/static/js/core/alert.js
@@ -0,0 +1,66 @@
+/*! UIkit 2.21.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
+(function(UI) {
+
+ "use strict";
+
+ UI.component('alert', {
+
+ defaults: {
+ "fade": true,
+ "duration": 200,
+ "trigger": ".uk-alert-close"
+ },
+
+ boot: function() {
+
+ // init code
+ UI.$html.on("click.alert.uikit", "[data-uk-alert]", function(e) {
+
+ var ele = UI.$(this);
+
+ if (!ele.data("alert")) {
+
+ var alert = UI.alert(ele, UI.Utils.options(ele.attr("data-uk-alert")));
+
+ if (UI.$(e.target).is(alert.options.trigger)) {
+ e.preventDefault();
+ alert.close();
+ }
+ }
+ });
+ },
+
+ init: function() {
+
+ var $this = this;
+
+ this.on("click", this.options.trigger, function(e) {
+ e.preventDefault();
+ $this.close();
+ });
+ },
+
+ close: function() {
+
+ var element = this.trigger("close.uk.alert"),
+ removeElement = function () {
+ this.trigger("closed.uk.alert").remove();
+ }.bind(this);
+
+ if (this.options.fade) {
+ element.css("overflow", "hidden").css("max-height", element.height()).animate({
+ "height" : 0,
+ "opacity" : 0,
+ "padding-top" : 0,
+ "padding-bottom" : 0,
+ "margin-top" : 0,
+ "margin-bottom" : 0
+ }, this.options.duration, removeElement);
+ } else {
+ removeElement();
+ }
+ }
+
+ });
+
+})(UIkit);