jquery-modal
Advanced tools
Comparing version 0.7.0 to 0.7.1
@@ -0,1 +1,14 @@ | ||
<a name="0.7.1"></a> | ||
## 0.7.1 (2016-08-18) | ||
* add minified css ([4f43415](https://github.com/kylefox/jquery-modal/commit/4f43415)) | ||
* add snippet to be able to load jquery as a module ([a3f1508](https://github.com/kylefox/jquery-modal/commit/a3f1508)) | ||
* add the minified javascript source ([27c88ac](https://github.com/kylefox/jquery-modal/commit/27c88ac)) | ||
* Explain events. ([99034ae](https://github.com/kylefox/jquery-modal/commit/99034ae)) | ||
* Merge pull request #154 from YuriBrunetto/min-css ([8a45590](https://github.com/kylefox/jquery-modal/commit/8a45590)) | ||
* Merge pull request #166 from Cryde/master ([85267db](https://github.com/kylefox/jquery-modal/commit/85267db)) | ||
<a name="0.7.0"></a> | ||
@@ -2,0 +15,0 @@ # 0.7.0 (2016-03-17) |
var gulp = require('gulp'); | ||
var uglify = require("gulp-uglify"); | ||
var uglifycss = require("gulp-uglifycss"); | ||
var rename = require('gulp-rename'); | ||
@@ -13,2 +14,9 @@ var changelog = require('gulp-conventional-changelog'); | ||
gulp.task('css', function() { | ||
gulp.src('jquery.modal.css') | ||
.pipe(uglifycss()) | ||
.pipe(rename('jquery.modal.min.css')) | ||
.pipe(gulp.dest('.')); | ||
}); | ||
gulp.task('changelog', function() { | ||
@@ -15,0 +23,0 @@ gulp.src('CHANGELOG.md') |
/* | ||
A simple jQuery modal (http://github.com/kylefox/jquery-modal) | ||
Version 0.7.0 | ||
Version 0.7.1 | ||
*/ | ||
(function($) { | ||
(function (factory) { | ||
// Making your jQuery plugin work better with npm tools | ||
// http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm | ||
if(typeof module === "object" && typeof module.exports === "object") { | ||
factory(require("jquery"), window, document); | ||
} | ||
else { | ||
factory(jQuery, window, document); | ||
} | ||
}(function($, window, document, undefined) { | ||
var modals = [], | ||
@@ -228,2 +238,2 @@ getCurrent = function() { | ||
}); | ||
})(jQuery); | ||
})); |
/* | ||
A simple jQuery modal (http://github.com/kylefox/jquery-modal) | ||
Version 0.7.0 | ||
Version 0.7.1 | ||
*/ | ||
!function(o){var t=[],i=function(){return t.length?t[t.length-1]:null},e=function(){var o,i=!1;for(o=t.length-1;o>=0;o--)t[o].$blocker&&(t[o].$blocker.toggleClass("current",!i).toggleClass("behind",i),i=!0)};o.modal=function(e,s){var l,n;if(this.$body=o("body"),this.options=o.extend({},o.modal.defaults,s),this.options.doFade=!isNaN(parseInt(this.options.fadeDuration,10)),this.$blocker=null,this.options.closeExisting)for(;o.modal.isActive();)o.modal.close();if(t.push(this),e.is("a"))if(n=e.attr("href"),/^#/.test(n)){if(this.$elm=o(n),1!==this.$elm.length)return null;this.$body.append(this.$elm),this.open()}else this.$elm=o("<div>"),this.$body.append(this.$elm),l=function(o,t){t.elm.remove()},this.showSpinner(),e.trigger(o.modal.AJAX_SEND),o.get(n).done(function(t){if(o.modal.isActive()){e.trigger(o.modal.AJAX_SUCCESS);var s=i();s.$elm.empty().append(t).on(o.modal.CLOSE,l),s.hideSpinner(),s.open(),e.trigger(o.modal.AJAX_COMPLETE)}}).fail(function(){e.trigger(o.modal.AJAX_FAIL);var s=i();s.hideSpinner(),t.pop(),e.trigger(o.modal.AJAX_COMPLETE)});else this.$elm=e,this.$body.append(this.$elm),this.open()},o.modal.prototype={constructor:o.modal,open:function(){var t=this;this.block(),this.options.doFade?setTimeout(function(){t.show()},this.options.fadeDuration*this.options.fadeDelay):this.show(),o(document).off("keydown.modal").on("keydown.modal",function(o){var t=i();27==o.which&&t.options.escapeClose&&t.close()}),this.options.clickClose&&this.$blocker.click(function(t){t.target==this&&o.modal.close()})},close:function(){t.pop(),this.unblock(),this.hide(),o.modal.isActive()||o(document).off("keydown.modal")},block:function(){this.$elm.trigger(o.modal.BEFORE_BLOCK,[this._ctx()]),this.$body.css("overflow","hidden"),this.$blocker=o('<div class="jquery-modal blocker current"></div>').appendTo(this.$body),e(),this.options.doFade&&this.$blocker.css("opacity",0).animate({opacity:1},this.options.fadeDuration),this.$elm.trigger(o.modal.BLOCK,[this._ctx()])},unblock:function(t){!t&&this.options.doFade?this.$blocker.fadeOut(this.options.fadeDuration,this.unblock.bind(this,!0)):(this.$blocker.children().appendTo(this.$body),this.$blocker.remove(),this.$blocker=null,e(),o.modal.isActive()||this.$body.css("overflow",""))},show:function(){this.$elm.trigger(o.modal.BEFORE_OPEN,[this._ctx()]),this.options.showClose&&(this.closeButton=o('<a href="#close-modal" rel="modal:close" class="close-modal '+this.options.closeClass+'">'+this.options.closeText+"</a>"),this.$elm.append(this.closeButton)),this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker),this.options.doFade?this.$elm.css("opacity",0).show().animate({opacity:1},this.options.fadeDuration):this.$elm.show(),this.$elm.trigger(o.modal.OPEN,[this._ctx()])},hide:function(){this.$elm.trigger(o.modal.BEFORE_CLOSE,[this._ctx()]),this.closeButton&&this.closeButton.remove();var t=this;this.options.doFade?this.$elm.fadeOut(this.options.fadeDuration,function(){t.$elm.trigger(o.modal.AFTER_CLOSE,[t._ctx()])}):this.$elm.hide(0,function(){t.$elm.trigger(o.modal.AFTER_CLOSE,[t._ctx()])}),this.$elm.trigger(o.modal.CLOSE,[this._ctx()])},showSpinner:function(){this.options.showSpinner&&(this.spinner=this.spinner||o('<div class="'+this.options.modalClass+'-spinner"></div>').append(this.options.spinnerHtml),this.$body.append(this.spinner),this.spinner.show())},hideSpinner:function(){this.spinner&&this.spinner.remove()},_ctx:function(){return{elm:this.$elm,$blocker:this.$blocker,options:this.options}}},o.modal.close=function(t){if(o.modal.isActive()){t&&t.preventDefault();var e=i();return e.close(),e.$elm}},o.modal.isActive=function(){return t.length>0},o.modal.defaults={closeExisting:!0,escapeClose:!0,clickClose:!0,closeText:"Close",closeClass:"",modalClass:"modal",spinnerHtml:null,showSpinner:!0,showClose:!0,fadeDuration:null,fadeDelay:1},o.modal.BEFORE_BLOCK="modal:before-block",o.modal.BLOCK="modal:block",o.modal.BEFORE_OPEN="modal:before-open",o.modal.OPEN="modal:open",o.modal.BEFORE_CLOSE="modal:before-close",o.modal.CLOSE="modal:close",o.modal.AFTER_CLOSE="modal:after-close",o.modal.AJAX_SEND="modal:ajax:send",o.modal.AJAX_SUCCESS="modal:ajax:success",o.modal.AJAX_FAIL="modal:ajax:fail",o.modal.AJAX_COMPLETE="modal:ajax:complete",o.fn.modal=function(t){return 1===this.length&&new o.modal(this,t),this},o(document).on("click.modal",'a[rel="modal:close"]',o.modal.close),o(document).on("click.modal",'a[rel="modal:open"]',function(t){t.preventDefault(),o(this).modal()})}(jQuery); | ||
!function(o){"object"==typeof module&&"object"==typeof module.exports?o(require("jquery"),window,document):o(jQuery,window,document)}(function(o,t,e,i){var s=[],l=function(){return s.length?s[s.length-1]:null},n=function(){var o,t=!1;for(o=s.length-1;o>=0;o--)s[o].$blocker&&(s[o].$blocker.toggleClass("current",!t).toggleClass("behind",t),t=!0)};o.modal=function(t,e){var i,n;if(this.$body=o("body"),this.options=o.extend({},o.modal.defaults,e),this.options.doFade=!isNaN(parseInt(this.options.fadeDuration,10)),this.$blocker=null,this.options.closeExisting)for(;o.modal.isActive();)o.modal.close();if(s.push(this),t.is("a"))if(n=t.attr("href"),/^#/.test(n)){if(this.$elm=o(n),1!==this.$elm.length)return null;this.$body.append(this.$elm),this.open()}else this.$elm=o("<div>"),this.$body.append(this.$elm),i=function(o,t){t.elm.remove()},this.showSpinner(),t.trigger(o.modal.AJAX_SEND),o.get(n).done(function(e){if(o.modal.isActive()){t.trigger(o.modal.AJAX_SUCCESS);var s=l();s.$elm.empty().append(e).on(o.modal.CLOSE,i),s.hideSpinner(),s.open(),t.trigger(o.modal.AJAX_COMPLETE)}}).fail(function(){t.trigger(o.modal.AJAX_FAIL);var e=l();e.hideSpinner(),s.pop(),t.trigger(o.modal.AJAX_COMPLETE)});else this.$elm=t,this.$body.append(this.$elm),this.open()},o.modal.prototype={constructor:o.modal,open:function(){var t=this;this.block(),this.options.doFade?setTimeout(function(){t.show()},this.options.fadeDuration*this.options.fadeDelay):this.show(),o(e).off("keydown.modal").on("keydown.modal",function(o){var t=l();27==o.which&&t.options.escapeClose&&t.close()}),this.options.clickClose&&this.$blocker.click(function(t){t.target==this&&o.modal.close()})},close:function(){s.pop(),this.unblock(),this.hide(),o.modal.isActive()||o(e).off("keydown.modal")},block:function(){this.$elm.trigger(o.modal.BEFORE_BLOCK,[this._ctx()]),this.$body.css("overflow","hidden"),this.$blocker=o('<div class="jquery-modal blocker current"></div>').appendTo(this.$body),n(),this.options.doFade&&this.$blocker.css("opacity",0).animate({opacity:1},this.options.fadeDuration),this.$elm.trigger(o.modal.BLOCK,[this._ctx()])},unblock:function(t){!t&&this.options.doFade?this.$blocker.fadeOut(this.options.fadeDuration,this.unblock.bind(this,!0)):(this.$blocker.children().appendTo(this.$body),this.$blocker.remove(),this.$blocker=null,n(),o.modal.isActive()||this.$body.css("overflow",""))},show:function(){this.$elm.trigger(o.modal.BEFORE_OPEN,[this._ctx()]),this.options.showClose&&(this.closeButton=o('<a href="#close-modal" rel="modal:close" class="close-modal '+this.options.closeClass+'">'+this.options.closeText+"</a>"),this.$elm.append(this.closeButton)),this.$elm.addClass(this.options.modalClass).appendTo(this.$blocker),this.options.doFade?this.$elm.css("opacity",0).show().animate({opacity:1},this.options.fadeDuration):this.$elm.show(),this.$elm.trigger(o.modal.OPEN,[this._ctx()])},hide:function(){this.$elm.trigger(o.modal.BEFORE_CLOSE,[this._ctx()]),this.closeButton&&this.closeButton.remove();var t=this;this.options.doFade?this.$elm.fadeOut(this.options.fadeDuration,function(){t.$elm.trigger(o.modal.AFTER_CLOSE,[t._ctx()])}):this.$elm.hide(0,function(){t.$elm.trigger(o.modal.AFTER_CLOSE,[t._ctx()])}),this.$elm.trigger(o.modal.CLOSE,[this._ctx()])},showSpinner:function(){this.options.showSpinner&&(this.spinner=this.spinner||o('<div class="'+this.options.modalClass+'-spinner"></div>').append(this.options.spinnerHtml),this.$body.append(this.spinner),this.spinner.show())},hideSpinner:function(){this.spinner&&this.spinner.remove()},_ctx:function(){return{elm:this.$elm,$blocker:this.$blocker,options:this.options}}},o.modal.close=function(t){if(o.modal.isActive()){t&&t.preventDefault();var e=l();return e.close(),e.$elm}},o.modal.isActive=function(){return s.length>0},o.modal.defaults={closeExisting:!0,escapeClose:!0,clickClose:!0,closeText:"Close",closeClass:"",modalClass:"modal",spinnerHtml:null,showSpinner:!0,showClose:!0,fadeDuration:null,fadeDelay:1},o.modal.BEFORE_BLOCK="modal:before-block",o.modal.BLOCK="modal:block",o.modal.BEFORE_OPEN="modal:before-open",o.modal.OPEN="modal:open",o.modal.BEFORE_CLOSE="modal:before-close",o.modal.CLOSE="modal:close",o.modal.AFTER_CLOSE="modal:after-close",o.modal.AJAX_SEND="modal:ajax:send",o.modal.AJAX_SUCCESS="modal:ajax:success",o.modal.AJAX_FAIL="modal:ajax:fail",o.modal.AJAX_COMPLETE="modal:ajax:complete",o.fn.modal=function(t){return 1===this.length&&new o.modal(this,t),this},o(e).on("click.modal",'a[rel="modal:close"]',o.modal.close),o(e).on("click.modal",'a[rel="modal:open"]',function(t){t.preventDefault(),o(this).modal()})}); |
{ | ||
"name": "jquery-modal", | ||
"version": "0.7.0", | ||
"version": "0.7.1", | ||
"main": "jquery.modal.js", | ||
@@ -16,4 +16,5 @@ "style": "jquery.modal.css", | ||
"gulp-rename": "^1.2.2", | ||
"gulp-uglify": "^1.4.1" | ||
"gulp-uglify": "^1.4.1", | ||
"gulp-uglifycss": "^1.0.6" | ||
} | ||
} |
@@ -180,11 +180,13 @@ A simple & lightweight method of displaying modal windows with jQuery. | ||
The following events are triggered on the modal element at various points in the open/close cycle (see below for AJAX events). Hopefully the names are self-explanatory. | ||
The following events are triggered on the modal element at various points in the open/close cycle (see below for AJAX events). | ||
$.modal.BEFORE_BLOCK = 'modal:before-block'; | ||
$.modal.BLOCK = 'modal:block'; | ||
$.modal.BEFORE_OPEN = 'modal:before-open'; | ||
$.modal.OPEN = 'modal:open'; | ||
$.modal.BEFORE_CLOSE = 'modal:before-close'; | ||
$.modal.CLOSE = 'modal:close'; | ||
$.modal.AFTER_CLOSE = 'modal:after-close'; | ||
```javascript | ||
$.modal.BEFORE_BLOCK = 'modal:before-block'; // Fires just before the overlay (blocker) appears. | ||
$.modal.BLOCK = 'modal:block'; // Fires after the overlay (block) is visible. | ||
$.modal.BEFORE_OPEN = 'modal:before-open'; // Fires just before the modal opens. | ||
$.modal.OPEN = 'modal:open'; // Fires after the modal has finished opening. | ||
$.modal.BEFORE_CLOSE = 'modal:before-close'; // Fires when the modal has been requested to close. | ||
$.modal.CLOSE = 'modal:close'; // Fires when the modal begins closing (including animations). | ||
$.modal.AFTER_CLOSE = 'modal:after-close'; // Fires after the modal has fully closed (including animations). | ||
``` | ||
@@ -191,0 +193,0 @@ The first and only argument passed to these event handlers is the `modal` object, which has three properties: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
94109
16
467
308
5
2