jquery.dirtyforms
Advanced tools
Comparing version 2.0.0-beta00004 to 2.0.0-beta00005
/*! | ||
Dirty Forms jQuery Plugin | v2.0.0-beta00004 | github.com/snikch/jquery.dirtyforms | ||
Dirty Forms jQuery Plugin | v2.0.0-beta00005 | github.com/snikch/jquery.dirtyforms | ||
(c) 2010-2015 Mal Curtis | ||
@@ -7,9 +7,10 @@ License MIT | ||
/*<iife_head>*/ | ||
// Support for UMD: https://github.com/umdjs/umd/blob/master/jqueryPluginCommonjs.js | ||
// This allows for tools such as Browserify to compose the components together into a single HTTP request. | ||
// See: http://blog.npmjs.org/post/112712169830/making-your-jquery-plugin-work-better-with-npm for details. | ||
(function (factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
// AMD. Register as an anonymous module. | ||
define(['jquery'], factory); | ||
} else if (typeof exports === 'object') { | ||
define(['jquery', 'window', 'document'], factory); | ||
} else if (typeof module === 'object' && module.exports) { | ||
// Node/CommonJS | ||
@@ -22,4 +23,9 @@ module.exports = factory(require('jquery'), window, document); | ||
}(function ($, window, document, undefined) { | ||
// Use ECMAScript 5's strict mode | ||
"use strict"; | ||
/*</iife_head>*/ | ||
// Can't use ECMAScript 5's strict mode because several apps | ||
// including ASP.NET trace the stack via arguments.caller.callee | ||
// and Firefox dies if you try to trace through "use strict" call chains. | ||
// See jQuery issue (#13335) | ||
// Support: Firefox 18+ | ||
//"use strict"; | ||
@@ -75,10 +81,29 @@ if (!$.fn.on) { | ||
isDirty: function (excludeHelpers) { | ||
var nonFormSelector = ':dirty:not(form)'; | ||
if (this.filter(nonFormSelector).length > 0 || this.find(nonFormSelector).length > 0) return true; | ||
var ignoreSelector = getIgnoreSelector(), | ||
dirtyClass = $.DirtyForms.dirtyClass, | ||
isDirty = false; | ||
var isDirty = false; | ||
if (!excludeHelpers) { | ||
this.not(':dirtyignored').each(function (index) { | ||
var $node = $(this); | ||
this.each(function (index) { | ||
var $node = $(this), | ||
ignored = isFieldIgnored($node, ignoreSelector); | ||
if ($node.hasClass(dirtyClass) && !ignored) { | ||
isDirty = true; | ||
// Exit out of the .each() function | ||
return false; | ||
} | ||
// Check any descendant nodes (if this is a container element) | ||
$node.find('.' + dirtyClass).each(function () { | ||
if (!isFieldIgnored($(this), ignoreSelector)) { | ||
isDirty = true; | ||
// Exit out of the .each() function | ||
return false; | ||
} | ||
}); | ||
// Exit out of the .each() function | ||
if (isDirty) return false; | ||
if (!ignored && !excludeHelpers) { | ||
// Test helpers for this node. | ||
$.each($.DirtyForms.helpers, function (i, helper) { | ||
@@ -94,5 +119,5 @@ if (helper.isDirty && helper.isDirty($node, index)) { | ||
if (isDirty) return false; | ||
}); | ||
} | ||
}); | ||
} | ||
return isDirty; | ||
@@ -122,3 +147,3 @@ }, | ||
if (excludeHelpers) return this; | ||
return fireHelperMethod(this, 'setClean', excludeIgnored); | ||
return fireHelperMethod(this, 'setClean', excludeIgnored, getIgnoreSelector()); | ||
}, | ||
@@ -149,3 +174,3 @@ // Scans the selected elements and descendants for any new fields and stores their original values. | ||
if (excludeHelpers) return this; | ||
return fireHelperMethod(this, 'rescan', excludeIgnored); | ||
return fireHelperMethod(this, 'rescan', excludeIgnored, getIgnoreSelector()); | ||
} | ||
@@ -156,23 +181,11 @@ }; | ||
$.extend($.expr[":"], { | ||
dirty: function (a) { | ||
return $(a).not(':dirtyignored').hasClass($.DirtyForms.dirtyClass); | ||
dirty: function (element) { | ||
var $element = $(element); | ||
return $element.hasClass($.DirtyForms.dirtyClass) && !$element.is(':dirtyignored'); | ||
}, | ||
dirtylistening: function (a) { | ||
return $(a).hasClass($.DirtyForms.listeningClass); | ||
dirtylistening: function (element) { | ||
return $(element).hasClass($.DirtyForms.listeningClass); | ||
}, | ||
dirtyignored: function (a) { | ||
var dirtyForms = $.DirtyForms; | ||
var getIgnoreSelector = function () { | ||
var result = dirtyForms.ignoreSelector; | ||
$.each(dirtyForms.helpers, function (key, obj) { | ||
if ('ignoreSelector' in obj) { | ||
if (result.length > 0) { result += ','; } | ||
result += obj.ignoreSelector; | ||
} | ||
}); | ||
return result; | ||
}; | ||
return $(a).closest('.' + dirtyForms.ignoreClass).length > 0 || $(a).is(getIgnoreSelector()); | ||
dirtyignored: function (element) { | ||
return isFieldIgnored($(element), false); | ||
} | ||
@@ -277,3 +290,3 @@ }); | ||
$(window).bind('beforeunload', data, events.onBeforeUnload); | ||
$(document).on('click', 'a[href]:not([target="_blank"])', data, events.onAnchorClick) | ||
$(document).on('click', 'a:not([target="_blank"])', data, events.onAnchorClick) | ||
.on('submit', 'form', data, events.onSubmit); | ||
@@ -344,5 +357,7 @@ }, | ||
onRefireAnchorClick: function (ev) { | ||
var href = $(ev.target).closest('[href]').attr('href'); | ||
dirtylog('Sending location to ' + href); | ||
window.location.href = href; | ||
var href = $(ev.target).closest('a[href]').attr('href'); | ||
if (href !== undefined) { | ||
dirtylog('Sending location to ' + href); | ||
window.location.href = href; | ||
} | ||
}, | ||
@@ -367,7 +382,7 @@ clearUnload: function () { | ||
var fireHelperMethod = function ($this, method, excludeIgnored) { | ||
var fireHelperMethod = function ($this, method, excludeIgnored, ignoreSelector) { | ||
return $this.each(function (index) { | ||
var $node = $(this); | ||
if (!excludeIgnored || !$node.is(':dirtyignored')) { | ||
if (!excludeIgnored || !isFieldIgnored($node, ignoreSelector)) { | ||
$.each($.DirtyForms.helpers, function (i, helper) { | ||
@@ -411,9 +426,28 @@ if (helper[method]) { helper[method]($node, index, excludeIgnored); } | ||
var isFieldDirty = function ($field) { | ||
if ($field.is(':dirtyignored') || !hasOriginalValue($field)) return false; | ||
var getIgnoreSelector = function () { | ||
var dirtyForms = $.DirtyForms, | ||
result = dirtyForms.ignoreSelector; | ||
$.each(dirtyForms.helpers, function (key, obj) { | ||
if ('ignoreSelector' in obj) { | ||
if (result.length > 0) { result += ','; } | ||
result += obj.ignoreSelector; | ||
} | ||
}); | ||
return result; | ||
}; | ||
var isFieldIgnored = function ($field, ignoreSelector) { | ||
if (!ignoreSelector) { | ||
ignoreSelector = getIgnoreSelector(); | ||
} | ||
return $field.is(ignoreSelector) || $field.closest('.' + $.DirtyForms.ignoreClass).length > 0; | ||
}; | ||
var isFieldDirty = function ($field, ignoreSelector) { | ||
if (!hasOriginalValue($field) || isFieldIgnored($field, ignoreSelector)) return false; | ||
return (getFieldValue($field) != $field.data('df-orig')); | ||
}; | ||
var setFieldStatus = function ($field) { | ||
if ($field.is(':dirtyignored')) return; | ||
var setFieldStatus = function ($field, ignoreSelector) { | ||
if (isFieldIgnored($field, ignoreSelector)) return; | ||
@@ -427,6 +461,6 @@ // Option groups are a special case because they change more than the current element. | ||
var $radio = $(this); | ||
setDirtyStatus($radio, isFieldDirty($radio)); | ||
setDirtyStatus($radio, isFieldDirty($radio, ignoreSelector)); | ||
}); | ||
} else { | ||
setDirtyStatus($field, isFieldDirty($field)); | ||
setDirtyStatus($field, isFieldDirty($field, ignoreSelector)); | ||
} | ||
@@ -589,2 +623,4 @@ }; | ||
/*<iife_foot>*/ | ||
})); | ||
/*</iife_foot>*/ |
/*! | ||
Dirty Forms jQuery Plugin | v2.0.0-beta00004 | github.com/snikch/jquery.dirtyforms | ||
Dirty Forms jQuery Plugin | v2.0.0-beta00005 | github.com/snikch/jquery.dirtyforms | ||
(c) 2010-2015 Mal Curtis | ||
License MIT | ||
*/ | ||
!function(e){"function"==typeof define&&define.amd?define(["jquery"],e):"object"==typeof exports?module.exports=e(require("jquery"),window,document):e(jQuery,window,document)}(function(e,t,i,r){"use strict";e.fn.on||(e.fn.on=function(e,t,i,r){return this.delegate(t,e,i,r)}),e.fn.dirtyForms=function(t){return n[t]?n[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.dirtyForms"):n.init.apply(this,arguments)};var n={init:function(r){var n={};return a.initialized||(e.extend(!0,e.DirtyForms,r),e(i).trigger("bind.dirtyforms",[u]),u.bind(t,i,n),a.initialized=!0),this.filter("form").not(":dirtylistening").each(function(){var t=e(this);t.find(e.DirtyForms.fieldSelector).each(function(){m(e(this))}),t.trigger("scan.dirtyforms"),u.bindForm(t,n)}),this},isDirty:function(t){var i=":dirty:not(form)";if(this.filter(i).length>0||this.find(i).length>0)return!0;var r=!1;return t||this.not(":dirtyignored").each(function(t){var i=e(this);return e.each(e.DirtyForms.helpers,function(e,n){return n.isDirty&&n.isDirty(i,t)?(r=!0,!1):void 0}),r?!1:void 0}),r},setClean:function(t,i){var r=function(){var t=e(this);m(t),F(t,!1)};return g(this,e.DirtyForms.fieldSelector,t).each(r).parents("form").trigger("setclean.dirtyforms",[t]),i?this:y(this,"setClean",t)},rescan:function(t,i){var r=function(){var t=e(this);p(t)||m(t),F(t,v(t))};return g(this,e.DirtyForms.fieldSelector,t).each(r).parents("form").trigger("rescan.dirtyforms",[t]),i?this:y(this,"rescan",t)}};e.extend(e.expr[":"],{dirty:function(t){return e(t).not(":dirtyignored").hasClass(e.DirtyForms.dirtyClass)},dirtylistening:function(t){return e(t).hasClass(e.DirtyForms.listeningClass)},dirtyignored:function(t){var i=e.DirtyForms,r=function(){var t=i.ignoreSelector;return e.each(i.helpers,function(e,i){"ignoreSelector"in i&&(t.length>0&&(t+=","),t+=i.ignoreSelector)}),t};return e(t).closest("."+i.ignoreClass).length>0||e(t).is(r())}}),e.DirtyForms={message:"You've made changes on this page which aren't saved. If you leave you will lose these changes.",dirtyClass:"dirty",listeningClass:"dirtylisten",ignoreClass:"dirtyignore",ignoreSelector:"",fieldSelector:"input:not([type='button'],[type='image'],[type='submit'],[type='reset'],[type='file'],[type='search']),select,textarea",helpers:[],dialog:!1};var o,a={initialized:!1,formStash:!1,dialogStash:!1,deciding:!1,decidingEvent:!1},s=function(e){return e.data.bindEscKey&&27==e.which||e.data.bindEnterKey&&13==e.which?f(e,!1):void 0},d=function(t){var r=t.staySelector,n=t.proceedSelector;""!==r&&e(r).unbind("click",f).click(f),""!==n&&e(n).unbind("click",l).click(l),(t.bindEscKey||t.bindEnterKey)&&e(i).unbind("keydown",s).keydown(t,s)},c=function(t,i){e.isFunction(e.DirtyForms.dialog.close)&&e.DirtyForms.dialog.close(t,i)},l=function(e){return f(e,!0)},f=function(t,r){if(a.deciding){if(t.preventDefault(),r===!0){var n=a.decidingEvent;e(i).trigger("proceed.dirtyforms",[n]),u.clearUnload(),c(r,!1),C(n)}else{e(i).trigger("stay.dirtyforms");var o=e.DirtyForms.dialog!==!1&&a.dialogStash!==!1&&e.isFunction(e.DirtyForms.dialog.unstash);c(r,o),o&&e.DirtyForms.dialog.unstash(a.dialogStash,t),e(i).trigger("afterstay.dirtyforms")}return a.deciding=a.decidingEvent=a.dialogStash=a.formStash=!1,!1}},u={bind:function(t,i,r){e(t).bind("beforeunload",r,u.onBeforeUnload),e(i).on("click",'a[href]:not([target="_blank"])',r,u.onAnchorClick).on("submit","form",r,u.onSubmit)},bindForm:function(t,r){var n=e.DirtyForms,o="onpropertychange"in i.createElement("input"),a="change input"+(o?" keyup selectionchange cut paste":"");t.addClass(n.listeningClass).on("focus keydown",n.fieldSelector,r,u.onFocus).on(a,n.fieldSelector,r,u.onFieldChange).bind("reset",r,u.onReset)},onFocus:function(t){var i=e(t.target);p(i)||m(i)},onFieldChange:function(t){var i=e(t.target);"change"!==t.type?S(function(){b(i)},100):b(i)},onReset:function(t){var i=e(t.target).closest("form");setTimeout(function(){i.dirtyForms("setClean")},100)},onAnchorClick:function(e){D(e)},onSubmit:function(e){D(e)},onBeforeUnload:function(e){var t=D(e);return t&&a.doubleunloadfix!==!0&&(a.deciding=!1),a.doubleunloadfix=!0,setTimeout(function(){a.doubleunloadfix=!1},200),"string"==typeof t?(e.returnValue=t,t):void 0},onRefireClick:function(t){var i=new e.Event("click");e(t.target).trigger(i),i.isDefaultPrevented()||u.onRefireAnchorClick(t)},onRefireAnchorClick:function(i){var r=e(i.target).closest("[href]").attr("href");t.location.href=r},clearUnload:function(){e(t).unbind("beforeunload",u.onBeforeUnload),t.onbeforeunload=null,e(i).trigger("beforeunload.dirtyforms")}},g=function(e,t,i){var r=e.filter(t).add(e.find(t));return i&&(r=r.not(":dirtyignored")),r},y=function(t,i,r){return t.each(function(t){var n=e(this);r&&n.is(":dirtyignored")||e.each(e.DirtyForms.helpers,function(e,o){o[i]&&o[i](n,t,r)})})},h=function(t){var i;return t.is("select")?(i="",t.find("option").each(function(){var t=e(this);t.is(":selected")&&(i.length>0&&(i+=","),i+=t.val())})):i=t.is(":checkbox,:radio")?t.is(":checked"):t.val(),i},m=function(e){e.data("df-orig",h(e));var t=e.data("df-orig")===r;e.data("df-empty",t)},p=function(e){return e.data("df-orig")!==r||e.data("df-empty")===!0},v=function(e){return e.is(":dirtyignored")||!p(e)?!1:h(e)!=e.data("df-orig")},b=function(t){if(!t.is(":dirtyignored"))if(t.is(":radio[name]")){var i=t.attr("name"),r=t.parents("form");r.find(":radio[name='"+i+"']").each(function(){var t=e(this);F(t,v(t))})}else F(t,v(t))},F=function(t,i){var r=e.DirtyForms.dirtyClass,n=t.parents("form");t.toggleClass(r,i);var o=i!==(n.hasClass(r)&&0===n.find(":dirty").length);o&&(n.toggleClass(r,i),i&&n.trigger("dirty.dirtyforms"),i||n.trigger("clean.dirtyforms"))},S=function(){var e=0;return function(t,i){clearTimeout(e),e=setTimeout(t,i)}}(),D=function(t){var r=e(t.target),n=t.type,s=e.DirtyForms;if(t.isDefaultPrevented())return!1;if("beforeunload"==n&&a.doubleunloadfix)return a.doubleunloadfix=!1,!1;if(r.is(":dirtyignored"))return u.clearUnload(),!1;if(a.deciding)return!1;if(!e("form:dirtylistening").dirtyForms("isDirty"))return u.clearUnload(),!1;if("submit"==n&&r.dirtyForms("isDirty"))return u.clearUnload(),!0;if(e(i).trigger("defer.dirtyforms"),"beforeunload"==n)return s.message;if(s.dialog){t.preventDefault(),t.stopImmediatePropagation(),a.deciding=!0,a.decidingEvent=t,e.isFunction(s.dialog.stash)&&(a.dialogStash=s.dialog.stash());var c=s.dialog.stashSelector;"string"==typeof c&&r.is("form")&&r.parents(c).length>0?a.formStash=r.clone(!0).hide():a.formStash=!1,o={proceed:!1,commit:function(e){return f(e,o.proceed)},bindEscKey:!0,bindEnterKey:!1,proceedSelector:"",staySelector:""},s.dialog.open(o,s.message,s.ignoreClass),d(o)}},C=function(t){if("click"===t.type)u.onRefireClick(t);else{var i;a.formStash?(i=a.formStash,e("body").append(i)):i=e(t.target).closest("form"),i.trigger(t.type)}}}); | ||
!function(e){"function"==typeof define&&define.amd?define(["jquery","window","document"],e):"object"==typeof module&&module.exports?module.exports=e(require("jquery"),window,document):e(jQuery,window,document)}(function(e,t,i,r){e.fn.on||(e.fn.on=function(e,t,i,r){return this.delegate(t,e,i,r)}),e.fn.dirtyForms=function(t){return n[t]?n[t].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof t&&t?void e.error("Method "+t+" does not exist on jQuery.dirtyForms"):n.init.apply(this,arguments)};var n={init:function(r){var n={};return a.initialized||(e.extend(!0,e.DirtyForms,r),e(i).trigger("bind.dirtyforms",[u]),u.bind(t,i,n),a.initialized=!0),this.filter("form").not(":dirtylistening").each(function(){var t=e(this);t.find(e.DirtyForms.fieldSelector).each(function(){m(e(this))}),t.trigger("scan.dirtyforms"),u.bindForm(t,n)}),this},isDirty:function(t){var i=v(),r=e.DirtyForms.dirtyClass,n=!1;return this.each(function(o){var a=e(this),s=b(a,i);return a.hasClass(r)&&!s?(n=!0,!1):(a.find("."+r).each(function(){return b(e(this),i)?void 0:(n=!0,!1)}),n?!1:s||t||(e.each(e.DirtyForms.helpers,function(e,t){return t.isDirty&&t.isDirty(a,o)?(n=!0,!1):void 0}),!n)?void 0:!1)}),n},setClean:function(t,i){var r=function(){var t=e(this);m(t),C(t,!1)};return g(this,e.DirtyForms.fieldSelector,t).each(r).parents("form").trigger("setclean.dirtyforms",[t]),i?this:y(this,"setClean",t,v())},rescan:function(t,i){var r=function(){var t=e(this);p(t)||m(t),C(t,F(t))};return g(this,e.DirtyForms.fieldSelector,t).each(r).parents("form").trigger("rescan.dirtyforms",[t]),i?this:y(this,"rescan",t,v())}};e.extend(e.expr[":"],{dirty:function(t){var i=e(t);return i.hasClass(e.DirtyForms.dirtyClass)&&!i.is(":dirtyignored")},dirtylistening:function(t){return e(t).hasClass(e.DirtyForms.listeningClass)},dirtyignored:function(t){return b(e(t),!1)}}),e.DirtyForms={message:"You've made changes on this page which aren't saved. If you leave you will lose these changes.",dirtyClass:"dirty",listeningClass:"dirtylisten",ignoreClass:"dirtyignore",ignoreSelector:"",fieldSelector:"input:not([type='button'],[type='image'],[type='submit'],[type='reset'],[type='file'],[type='search']),select,textarea",helpers:[],dialog:!1};var o,a={initialized:!1,formStash:!1,dialogStash:!1,deciding:!1,decidingEvent:!1},s=function(e){return e.data.bindEscKey&&27==e.which||e.data.bindEnterKey&&13==e.which?f(e,!1):void 0},d=function(t){var r=t.staySelector,n=t.proceedSelector;""!==r&&e(r).unbind("click",f).click(f),""!==n&&e(n).unbind("click",l).click(l),(t.bindEscKey||t.bindEnterKey)&&e(i).unbind("keydown",s).keydown(t,s)},c=function(t,i){e.isFunction(e.DirtyForms.dialog.close)&&e.DirtyForms.dialog.close(t,i)},l=function(e){return f(e,!0)},f=function(t,r){if(a.deciding){if(t.preventDefault(),r===!0){var n=a.decidingEvent;e(i).trigger("proceed.dirtyforms",[n]),u.clearUnload(),c(r,!1),w(n)}else{e(i).trigger("stay.dirtyforms");var o=e.DirtyForms.dialog!==!1&&a.dialogStash!==!1&&e.isFunction(e.DirtyForms.dialog.unstash);c(r,o),o&&e.DirtyForms.dialog.unstash(a.dialogStash,t),e(i).trigger("afterstay.dirtyforms")}return a.deciding=a.decidingEvent=a.dialogStash=a.formStash=!1,!1}},u={bind:function(t,i,r){e(t).bind("beforeunload",r,u.onBeforeUnload),e(i).on("click",'a:not([target="_blank"])',r,u.onAnchorClick).on("submit","form",r,u.onSubmit)},bindForm:function(t,r){var n=e.DirtyForms,o="onpropertychange"in i.createElement("input"),a="change input"+(o?" keyup selectionchange cut paste":"");t.addClass(n.listeningClass).on("focus keydown",n.fieldSelector,r,u.onFocus).on(a,n.fieldSelector,r,u.onFieldChange).bind("reset",r,u.onReset)},onFocus:function(t){var i=e(t.target);p(i)||m(i)},onFieldChange:function(t){var i=e(t.target);"change"!==t.type?S(function(){D(i)},100):D(i)},onReset:function(t){var i=e(t.target).closest("form");setTimeout(function(){i.dirtyForms("setClean")},100)},onAnchorClick:function(e){k(e)},onSubmit:function(e){k(e)},onBeforeUnload:function(e){var t=k(e);return t&&a.doubleunloadfix!==!0&&(a.deciding=!1),a.doubleunloadfix=!0,setTimeout(function(){a.doubleunloadfix=!1},200),"string"==typeof t?(e.returnValue=t,t):void 0},onRefireClick:function(t){var i=new e.Event("click");e(t.target).trigger(i),i.isDefaultPrevented()||u.onRefireAnchorClick(t)},onRefireAnchorClick:function(i){var n=e(i.target).closest("a[href]").attr("href");n!==r&&(t.location.href=n)},clearUnload:function(){e(t).unbind("beforeunload",u.onBeforeUnload),t.onbeforeunload=null,e(i).trigger("beforeunload.dirtyforms")}},g=function(e,t,i){var r=e.filter(t).add(e.find(t));return i&&(r=r.not(":dirtyignored")),r},y=function(t,i,r,n){return t.each(function(t){var o=e(this);r&&b(o,n)||e.each(e.DirtyForms.helpers,function(e,n){n[i]&&n[i](o,t,r)})})},h=function(t){var i;return t.is("select")?(i="",t.find("option").each(function(){var t=e(this);t.is(":selected")&&(i.length>0&&(i+=","),i+=t.val())})):i=t.is(":checkbox,:radio")?t.is(":checked"):t.val(),i},m=function(e){e.data("df-orig",h(e));var t=e.data("df-orig")===r;e.data("df-empty",t)},p=function(e){return e.data("df-orig")!==r||e.data("df-empty")===!0},v=function(){var t=e.DirtyForms,i=t.ignoreSelector;return e.each(t.helpers,function(e,t){"ignoreSelector"in t&&(i.length>0&&(i+=","),i+=t.ignoreSelector)}),i},b=function(t,i){return i||(i=v()),t.is(i)||t.closest("."+e.DirtyForms.ignoreClass).length>0},F=function(e,t){return!p(e)||b(e,t)?!1:h(e)!=e.data("df-orig")},D=function(t,i){if(!b(t,i))if(t.is(":radio[name]")){var r=t.attr("name"),n=t.parents("form");n.find(":radio[name='"+r+"']").each(function(){var t=e(this);C(t,F(t,i))})}else C(t,F(t,i))},C=function(t,i){var r=e.DirtyForms.dirtyClass,n=t.parents("form");t.toggleClass(r,i);var o=i!==(n.hasClass(r)&&0===n.find(":dirty").length);o&&(n.toggleClass(r,i),i&&n.trigger("dirty.dirtyforms"),i||n.trigger("clean.dirtyforms"))},S=function(){var e=0;return function(t,i){clearTimeout(e),e=setTimeout(t,i)}}(),k=function(t){var r=e(t.target),n=t.type,s=e.DirtyForms;if(t.isDefaultPrevented())return!1;if("beforeunload"==n&&a.doubleunloadfix)return a.doubleunloadfix=!1,!1;if(r.is(":dirtyignored"))return u.clearUnload(),!1;if(a.deciding)return!1;if(!e("form:dirtylistening").dirtyForms("isDirty"))return u.clearUnload(),!1;if("submit"==n&&r.dirtyForms("isDirty"))return u.clearUnload(),!0;if(e(i).trigger("defer.dirtyforms"),"beforeunload"==n)return s.message;if(s.dialog){t.preventDefault(),t.stopImmediatePropagation(),a.deciding=!0,a.decidingEvent=t,e.isFunction(s.dialog.stash)&&(a.dialogStash=s.dialog.stash());var c=s.dialog.stashSelector;"string"==typeof c&&r.is("form")&&r.parents(c).length>0?a.formStash=r.clone(!0).hide():a.formStash=!1,o={proceed:!1,commit:function(e){return f(e,o.proceed)},bindEscKey:!0,bindEnterKey:!1,proceedSelector:"",staySelector:""},s.dialog.open(o,s.message,s.ignoreClass),d(o)}},w=function(t){if("click"===t.type)u.onRefireClick(t);else{var i;a.formStash?(i=a.formStash,e("body").append(i)):i=e(t.target).closest("form"),i.trigger(t.type)}}}); | ||
//# sourceMappingURL=jquery.dirtyforms.min.js.map |
{ | ||
"name": "jquery.dirtyforms", | ||
"version": "2.0.0-beta00004", | ||
"version": "2.0.0-beta00005", | ||
"description": "Dirty Forms is a jQuery plugin to help prevent users from losing data when editing forms.", | ||
@@ -5,0 +5,0 @@ "main": "jquery.dirtyforms.min.js", |
@@ -53,3 +53,3 @@ [![jquery-dirtyforms MyGet Build Status](https://www.myget.org/BuildSource/Badge/jquery-dirtyforms?identifier=193d9dab-a526-484e-8062-9a960322f246)](https://www.myget.org/) | ||
```HTML | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.dirtyforms/2.0.0-beta00004/jquery.dirtyforms.min.js"></script> | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.dirtyforms/2.0.0-beta00005/jquery.dirtyforms.min.js"></script> | ||
``` | ||
@@ -59,3 +59,3 @@ | ||
```HTML | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/g/jquery@1.11.3,jquery.dirtyforms@2.0.0-beta00004"></script> | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/g/jquery@1.11.3,jquery.dirtyforms@2.0.0-beta00005"></script> | ||
``` | ||
@@ -97,3 +97,3 @@ | ||
```HTML | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.dirtyforms/2.0.0-beta00004/jquery.dirtyforms.min.js.map"></script> | ||
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery.dirtyforms/2.0.0-beta00005/jquery.dirtyforms.min.js.map"></script> | ||
``` | ||
@@ -100,0 +100,0 @@ |
Sorry, the diff of this file is not supported yet
89713
565