Skip to content

Commit

Permalink
doc
Browse files Browse the repository at this point in the history
  • Loading branch information
John Antoni Griffiths committed Sep 21, 2010
1 parent 4edf7e6 commit d1a3c43
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions jquery.tamper.min.js
@@ -1 +1,28 @@
/*
* jquery.tamper.js
* v 1.1
*
* Initial Author
* John Griffiths
*
* Description
* Simply watches an element for changes, if any encountered flips the tamper flag to true.
* If the exit button is clicked and the tamper flag is set to true a dialog will appear warning
* the user they will lose their changes if they click OK.
*
* Params:
* watchName : (required) element (textarea) to watch for changes
* exitName : (required) element (button) which classes as an exit when clicked
* messageText : (optional) text to show in the alert dialog
*
* PLEASE NOTE: if an onclick event is present on the exit element it will clone it, remove it
* and append it so when the user click's ok it fires.
*
* Requires: jQuery v1.3+
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.tamper=function(a,e,c){var d=$(a),b=$(e);c=c||"Are you sure? \nDoing so will lose any pending changes.";if(d.length>0){d.data("altered",false);b.data("tamper",{watch:a,message:c});if(b.attr("onclick").length>0){var h=b.attr("onclick");b.removeAttr("onclick")}d.keypress(function(){$(this).data("altered",true)});b.click(function(){var f=true,g=$(this).data("tamper").watch;if($(g).data("altered")){g=$(this).data("tamper").message;if(confirm(g)===false)f=false}f===true&&h&&b.attr("onclick",h); return f})}};jQuery.tamperAlert=function(a,e){var c=$(a);e=e||"Are you sure? \nDoing so will lose any pending changes.";if(c.length>0){c.data("tamper",{message:e});c.click(function(){var d=true,b=$(this).data("tamper").message;if($(this).data("altered"))if(confirm(b)===false)d=false;return d})}};jQuery.tamperFlag=function(a){a=$(a);a.length>0&&a.data("altered",true)};

0 comments on commit d1a3c43

Please sign in to comment.