Component-Builder/admin/custom/uikit/js/core/alert.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-11-12 00:33:10 +00:00
/*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
2016-01-30 20:28:43 +00:00
(function(UI) {
"use strict";
UI.component('alert', {
defaults: {
2017-11-12 00:33:10 +00:00
fade: true,
duration: 200,
trigger: '.uk-alert-close'
2016-01-30 20:28:43 +00:00
},
boot: function() {
// init code
2017-11-12 00:33:10 +00:00
UI.$html.on('click.alert.uikit', '[data-uk-alert]', function(e) {
2016-01-30 20:28:43 +00:00
var ele = UI.$(this);
2017-11-12 00:33:10 +00:00
if (!ele.data('alert')) {
2016-01-30 20:28:43 +00:00
2017-11-12 00:33:10 +00:00
var alert = UI.alert(ele, UI.Utils.options(ele.attr('data-uk-alert')));
2016-01-30 20:28:43 +00:00
if (UI.$(e.target).is(alert.options.trigger)) {
e.preventDefault();
alert.close();
}
}
});
},
init: function() {
var $this = this;
2017-11-12 00:33:10 +00:00
this.on('click', this.options.trigger, function(e) {
2016-01-30 20:28:43 +00:00
e.preventDefault();
$this.close();
});
},
close: function() {
2017-11-12 00:33:10 +00:00
var element = this.trigger('close.uk.alert'),
2016-01-30 20:28:43 +00:00
removeElement = function () {
2017-11-12 00:33:10 +00:00
this.trigger('closed.uk.alert').remove();
2016-01-30 20:28:43 +00:00
}.bind(this);
if (this.options.fade) {
2017-11-12 00:33:10 +00:00
element.css('overflow', 'hidden').css("max-height", element.height()).animate({
height : 0,
opacity : 0,
paddingTop : 0,
paddingBottom : 0,
marginTop : 0,
marginBottom : 0
2016-01-30 20:28:43 +00:00
}, this.options.duration, removeElement);
} else {
removeElement();
}
}
});
2017-11-12 00:33:10 +00:00
})(UIkit2);