First Commit
This commit is contained in:
commit
136bca1b88
7 changed files with 258 additions and 0 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
node_modules
|
||||
index.html
|
||||
32
Gruntfile.js
Normal file
32
Gruntfile.js
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
module.exports = function (grunt) {
|
||||
require('load-grunt-tasks')(grunt);
|
||||
|
||||
grunt.initConfig({
|
||||
babel: {
|
||||
options: {
|
||||
sourceMap: true,
|
||||
presets: ['env']
|
||||
},
|
||||
dist: {
|
||||
files: {
|
||||
'dist/a-alert.js': './index.js'
|
||||
}
|
||||
}
|
||||
},
|
||||
uglify: {
|
||||
dist: {
|
||||
options: {
|
||||
mangle: true,
|
||||
output: {
|
||||
comments: false
|
||||
}
|
||||
},
|
||||
files: {
|
||||
'dist/a-alert.min.js': ['dist/a-alert.js']
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', ['babel', 'uglify']);
|
||||
};
|
||||
98
dist/a-alert.js
vendored
Normal file
98
dist/a-alert.js
vendored
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
'use strict';
|
||||
|
||||
(function ($) {
|
||||
|
||||
$.fn.aalert = function (method) {
|
||||
if (methods[method]) {
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
} else {
|
||||
$.error('Method ' + method + ' does not exist');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var methods = {
|
||||
changeTo: function changeTo(valiant) {
|
||||
var $this = $(this);
|
||||
|
||||
$this.removeClass(function (index, css) {
|
||||
return (css.match(/(^|\s)alert-\S+/g) || []).join(' ');
|
||||
});
|
||||
|
||||
$this.addClass('alert-' + valiant);
|
||||
|
||||
return this;
|
||||
},
|
||||
changeContentTo: function changeContentTo(content) {
|
||||
var open = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
||||
|
||||
var $this = $(this);
|
||||
|
||||
$this.find('.alert-content').html(content);
|
||||
|
||||
if (open === true) {
|
||||
methods.open.apply(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
toggle: function toggle() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeToggle();
|
||||
} else if ($this.hasClass('slide')) {
|
||||
$this.slideToggle();
|
||||
} else {
|
||||
$this.toggle();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
close: function close() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeOut();
|
||||
} else if ($this.hasClass('slide')) {
|
||||
$this.slideUp();
|
||||
} else {
|
||||
$this.hide();
|
||||
}
|
||||
|
||||
if ($this.hasClass('remove')) {
|
||||
$this.remove();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
open: function open() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeIn();
|
||||
} else if ($this.hasClass('slide')) {
|
||||
$this.slideDown();
|
||||
} else {
|
||||
$this.show();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
closeAfter: function closeAfter(timeOut) {
|
||||
var that = this;
|
||||
setTimeout(function () {
|
||||
methods.close.apply(that);
|
||||
}, timeOut);
|
||||
|
||||
return this;
|
||||
}
|
||||
};
|
||||
|
||||
$('.alert [data-dismiss="aalert"]').click(function (e) {
|
||||
$element = $(e.target).closest('.alert');
|
||||
methods.close.apply($element);
|
||||
});
|
||||
|
||||
$('.alert[data-timeout]').each(function (index, element) {
|
||||
methods.closeAfter.apply(element, [$(element).data('timeout')]);
|
||||
});
|
||||
})(jQuery);
|
||||
//# sourceMappingURL=a-alert.js.map
|
||||
1
dist/a-alert.js.map
vendored
Normal file
1
dist/a-alert.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
1
dist/a-alert.min.js
vendored
Normal file
1
dist/a-alert.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
"use strict";!function(t){t.fn.aalert=function(s){return e[s]?e[s].apply(this,Array.prototype.slice.call(arguments,1)):(t.error("Method "+s+" does not exist"),!1)};var e={changeTo:function(e){var s=t(this);return s.removeClass(function(t,e){return(e.match(/(^|\s)alert-\S+/g)||[]).join(" ")}),s.addClass("alert-"+e),this},changeContentTo:function(s){var a=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return t(this).find(".alert-content").html(s),!0===a&&e.open.apply(this),this},toggle:function(){var e=t(this);return e.hasClass("fade")?e.fadeToggle():e.hasClass("slide")?e.slideToggle():e.toggle(),this},close:function(){var e=t(this);return e.hasClass("fade")?e.fadeOut():e.hasClass("slide")?e.slideUp():e.hide(),e.hasClass("remove")&&e.remove(),this},open:function(){var e=t(this);return e.hasClass("fade")?e.fadeIn():e.hasClass("slide")?e.slideDown():e.show(),this},closeAfter:function(t){var s=this;return setTimeout(function(){e.close.apply(s)},t),this}};t('.alert [data-dismiss="aalert"]').click(function(s){$element=t(s.target).closest(".alert"),e.close.apply($element)}),t(".alert[data-timeout]").each(function(s,a){e.closeAfter.apply(a,[t(a).data("timeout")])})}(jQuery);
|
||||
101
index.js
Normal file
101
index.js
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
(function ($) {
|
||||
|
||||
$.fn.aalert = function (method) {
|
||||
if (methods[method]) {
|
||||
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
||||
} else {
|
||||
$.error('Method ' + method + ' does not exist');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
var methods = {
|
||||
|
||||
changeTo(valiant) {
|
||||
var $this = $(this);
|
||||
|
||||
$this.removeClass((index, css) => {
|
||||
return (css.match (/(^|\s)alert-\S+/g) || []).join(' ');
|
||||
});
|
||||
|
||||
$this.addClass('alert-' + valiant);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
changeContentTo(content, open = true) {
|
||||
var $this = $(this);
|
||||
|
||||
$this.find('.alert-content').html(content);
|
||||
|
||||
if (open === true) {
|
||||
methods.open.apply(this);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
toggle() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeToggle();
|
||||
} else if ($this.hasClass('slide')) {
|
||||
$this.slideToggle();
|
||||
} else {
|
||||
$this.toggle();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
close() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeOut();
|
||||
} else if ($this.hasClass('slide')) {
|
||||
$this.slideUp();
|
||||
} else {
|
||||
$this.hide();
|
||||
}
|
||||
|
||||
if ( $this.hasClass('remove')) {
|
||||
$this.remove();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
open() {
|
||||
var $this = $(this);
|
||||
if ($this.hasClass('fade')) {
|
||||
$this.fadeIn();
|
||||
} else if ( $this.hasClass('slide')) {
|
||||
$this.slideDown();
|
||||
} else {
|
||||
$this.show();
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
closeAfter(timeOut) {
|
||||
var that = this;
|
||||
setTimeout(() => {
|
||||
methods.close.apply(that);
|
||||
}, timeOut);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
$('.alert [data-dismiss="aalert"]').click(e => {
|
||||
$element = $(e.target).closest('.alert');
|
||||
methods.close.apply($element);
|
||||
});
|
||||
|
||||
$('.alert[data-timeout]').each((index, element) => {
|
||||
methods.closeAfter.apply(element, [$(element).data('timeout')]);
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
23
package.json
Normal file
23
package.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"name": "bs-advanced-alert",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bootstrap": "^3.3.7",
|
||||
"jquery": "^3.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"babel-core": "^6.26.0",
|
||||
"babel-preset-env": "^1.6.0",
|
||||
"grunt": "^1.0.1",
|
||||
"grunt-babel": "^7.0.0",
|
||||
"grunt-contrib-uglify": "^3.1.0",
|
||||
"load-grunt-tasks": "^3.5.2"
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue