-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathasdfasdf.min.js
7 lines (7 loc) · 2.71 KB
/
asdfasdf.min.js
1
2
3
4
5
6
7
/**
* author: jupegarnica.com
* License: MIT
* Date: 2015-01-16
* Time: 12:12 PM
* Version 1.02
*/function asdfasdf(e,t){$(function(){asdfasdfInit(e,t)}),asdfasdfStarted||asdfasdfInit(e,t)}function asdfasdfInit(e,t){function i(){t.removeCookie("__asdfasdf",{expires:n.expires})}function s(e){var r;window.btoa&&e?r=window.btoa(JSON.stringify(e)):r=JSON.stringify(e),t.cookie("__asdfasdf",r,{expires:n.expires});if(n.showFeedback){var i='<span style="'+n.msgStyle+'">'+n.msgText+"</span>";t(i).appendTo("body").delay(n.msgHide).fadeOut(1e3)}}function o(){var e,n=t.cookie("__asdfasdf")||"";return window.atob?e=window.atob(n):e=n,e}t=t||jQuery,e=e||{};var n={showFeedback:!0,showLoaded:!0,msgLoadDataText:"Data Loaded",msgStyle:"position: fixed;top: 2em;color: white;background: tomato;right: 50%;transform: translateX(50%);width: auto;display: inline-block;padding: 0.5em;border-radius: 0.3em;text-transform: uppercase;",msgText:"auto saved",msgHide:500,elements:"input, textarea, select",expires:2};for(var r in n)n[r]=e[r]||n[r],e[r]&&console.log("Default setting changed:",r,e[r]);(function(){function r(){var e=o()||"{}";e=JSON.parse(e);var n=Object.keys(e),r=t(this),i,u,a;if(r.prop("type")==="checkbox")u=r.prop("checked"),i='[name="'+r.prop("name")+'"]'+'[value="'+r.prop("value")+'"]';else if(r.prop("type")=="radio"){u=r.prop("checked"),a='[name="'+r.prop("name")+'"]',i=a+'[value="'+r.prop("value")+'"]';var f;n.some(function(e){return f=e,e.contains(a)})&&(e[f]=undefined)}else if(r.is("select")){var l=r.find("option:selected");i='select[name="'+r.prop("name")+'"]'+' option:contains("'+l.val()+'")',u=l.prop("selected")}else u=r.val(),i='[name="'+r.prop("name")+'"]';console.log(i,u),e[i]=u,s(e)}t(n.elements).on("change",r)})(),function(){var r=!1;t(document).ready(function(){if(window.asdfasdfStarted)return;var e=o(),r;if(e){e=JSON.parse(e);var i=!1;Object.keys(e).forEach(function(s){r=t(s);if(r.length==0)return;r.prop("type")==="checkbox"?r.prop("checked",e[s]):r.prop("type")==="radio"?r.prop("checked",e[s]):r.is("option")?r.prop("selected",e[s]):r.val(e[s]);if(!i&&n.showFeedback){var o='<span style="'+n.msgStyle+'">'+n.msgLoadDataText+"</span>";t(o).appendTo("body").delay(n.msgHide).fadeOut(2e3),i=!0}})}window.asdfasdfStarted=!0})}(),window.deleteAutoSaveFormData=i}String.prototype.contains||(String.prototype.contains=function(){return String.prototype.indexOf.apply(this,arguments)!==-1}),Array.prototype.some||(Array.prototype.some=function(e){"use strict";if(this==null)throw new TypeError("Array.prototype.some called on null or undefined");if(typeof e!="function")throw new TypeError;var t=Object(this),n=t.length>>>0,r=arguments.length>=2?arguments[1]:void 0;for(var i=0;i<n;i++)if(i in t&&e.call(r,t[i],i,t))return!0;return!1});