mivita/resources/assets/vendor/libs/bootstrap-table/extensions/cookie/cookie.js
2018-10-29 09:39:31 +01:00

1 line
No EOL
7.9 KiB
JavaScript
Executable file

!function(o,e){var t=function(o){var e={};function t(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return o[i].call(r.exports,r,r.exports,t),r.l=!0,r.exports}return t.m=o,t.c=e,t.d=function(o,e,i){t.o(o,e)||Object.defineProperty(o,e,{configurable:!1,enumerable:!0,get:i})},t.r=function(o){Object.defineProperty(o,"__esModule",{value:!0})},t.n=function(o){var e=o&&o.__esModule?function(){return o.default}:function(){return o};return t.d(e,"a",e),e},t.o=function(o,e){return Object.prototype.hasOwnProperty.call(o,e)},t.p="",t(t.s=355)}({354:function(o,e){!function(o){"use strict";var e={sortOrder:"bs.table.sortOrder",sortName:"bs.table.sortName",pageNumber:"bs.table.pageNumber",pageList:"bs.table.pageList",columns:"bs.table.columns",searchText:"bs.table.searchText",filterControl:"bs.table.filterControl"},t=function(){return!!navigator.cookieEnabled},i=function(o,e){for(var t=-1,i=0;i<e.length;i++)if(o.toLowerCase()===e[i].toLowerCase()){t=i;break}return t},r=function(o,e,r){if(o.options.cookie&&t()&&""!==o.options.cookieIdTable&&-1!==i(e,o.options.cookiesEnabled)){switch(e=o.options.cookieIdTable+"."+e,o.options.cookieStorage){case"cookieStorage":document.cookie=[e,"=",r,"; expires="+n(o.options.cookieExpire),o.options.cookiePath?"; path="+o.options.cookiePath:"",o.options.cookieDomain?"; domain="+o.options.cookieDomain:"",o.options.cookieSecure?"; secure":""].join("");case"localStorage":localStorage.setItem(e,r);break;case"sessionStorage":sessionStorage.setItem(e,r);break;default:return!1}return!0}},s=function(o,e,t){if(!t)return null;if(-1===i(t,o.options.cookiesEnabled))return null;switch(t=e+"."+t,o.options.cookieStorage){case"cookieStorage":var r="; "+document.cookie,s=r.split("; "+t+"=");return 2===s.length?s.pop().split(";").shift():null;case"localStorage":return localStorage.getItem(t);case"sessionStorage":return sessionStorage.getItem(t);default:return null}},n=function(o){var e=o.replace(/[0-9]*/,"");switch(o=o.replace(/[A-Za-z]{1,2}/,""),e.toLowerCase()){case"s":o=+o;break;case"mi":o*=60;break;case"h":o=60*o*60;break;case"d":o=24*o*60*60;break;case"m":o=30*o*24*60*60;break;case"y":o=365*o*24*60*60;break;default:o=void 0}if(!o)return"";var t=new Date;return t.setTime(t.getTime()+1e3*o),t.toGMTString()},a=function(t){setTimeout(function(){var i=JSON.parse(s(t,t.options.cookieIdTable,e.filterControl));if(!t.options.filterControlValuesLoaded&&i){var r={},n=function(o){var e=o.$header;return o.options.height&&(e=o.$tableHeader),e}(t),a=function(o){var e="select, input";return o.options.height&&(e="table select, table input"),e}(t);n.find(a).each(function(){var e=o(this).closest("[data-field]").data("field"),t=o.grep(i,function(o){return o.field===e});!function(e,t){o(t).each(function(t,i){""!==i.text&&(o(e).val(i.text),r[i.field]=i.text)})}(this,t)}),t.initColumnSearch(r),t.options.filterControlValuesLoaded=!0,t.initServer()}},250)};o.extend(o.fn.bootstrapTable.defaults,{cookie:!1,cookieExpire:"2h",cookiePath:null,cookieDomain:null,cookieSecure:null,cookieIdTable:"",cookiesEnabled:["bs.table.sortOrder","bs.table.sortName","bs.table.pageNumber","bs.table.pageList","bs.table.columns","bs.table.searchText","bs.table.filterControl"],cookieStorage:"cookieStorage",filterControls:[],filterControlValuesLoaded:!1}),o.fn.bootstrapTable.methods.push("getCookies"),o.fn.bootstrapTable.methods.push("deleteCookie"),o.extend(o.fn.bootstrapTable.utils,{setCookie:r,getCookie:s});var p=o.fn.bootstrapTable.Constructor,l=p.prototype.init,c=p.prototype.initTable,u=p.prototype.initServer,h=p.prototype.onSort,f=p.prototype.onPageNumber,b=p.prototype.onPageListChange,d=p.prototype.onPagePre,y=p.prototype.onPageNext,g=p.prototype.toggleColumn,k=p.prototype.selectPage,m=p.prototype.onSearch;p.prototype.init=function(){if(this.options.filterControls=[],this.options.filterControlValuesLoaded=!1,this.options.cookiesEnabled="string"==typeof this.options.cookiesEnabled?this.options.cookiesEnabled.replace("[","").replace("]","").replace(/ /g,"").toLowerCase().split(","):this.options.cookiesEnabled,this.options.filterControl){var o=this;this.$el.on("column-search.bs.table",function(t,i,s){for(var n=!0,a=0;a<o.options.filterControls.length;a++)if(o.options.filterControls[a].field===i){o.options.filterControls[a].text=s,n=!1;break}n&&o.options.filterControls.push({field:i,text:s}),r(o,e.filterControl,JSON.stringify(o.options.filterControls))}).on("post-body.bs.table",a(o))}l.apply(this,Array.prototype.slice.apply(arguments))},p.prototype.initServer=function(){if(this.options.cookie&&this.options.filterControl&&!this.options.filterControlValuesLoaded){var o=JSON.parse(s(this,this.options.cookieIdTable,e.filterControl));if(o)return}u.apply(this,Array.prototype.slice.apply(arguments))},p.prototype.initTable=function(){c.apply(this,Array.prototype.slice.apply(arguments)),this.initCookie()},p.prototype.initCookie=function(){if(this.options.cookie){if(""===this.options.cookieIdTable||""===this.options.cookieExpire||!t())return console.error("Configuration error. Please review the cookieIdTable, cookieExpire properties, if those properties are ok, then this browser does not support the cookies"),void(this.options.cookie=!1);var i=s(this,this.options.cookieIdTable,e.sortOrder),r=s(this,this.options.cookieIdTable,e.sortName),n=s(this,this.options.cookieIdTable,e.pageNumber),a=s(this,this.options.cookieIdTable,e.pageList),p=JSON.parse(s(this,this.options.cookieIdTable,e.columns)),l=s(this,this.options.cookieIdTable,e.searchText);this.options.sortOrder=i||this.options.sortOrder,this.options.sortName=r||this.options.sortName,this.options.pageNumber=n?+n:this.options.pageNumber,this.options.pageSize=a?a===this.options.formatAllRows()?a:+a:this.options.pageSize,this.options.searchText=l||"",p&&o.each(this.columns,function(e,t){t.visible=-1!==o.inArray(t.field,p)})}},p.prototype.onSort=function(){h.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.sortOrder,this.options.sortOrder),r(this,e.sortName,this.options.sortName)},p.prototype.onPageNumber=function(){return f.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.pageNumber,this.options.pageNumber),!1},p.prototype.onPageListChange=function(){return b.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.pageList,this.options.pageSize),r(this,e.pageNumber,this.options.pageNumber),!1},p.prototype.onPagePre=function(){return d.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.pageNumber,this.options.pageNumber),!1},p.prototype.onPageNext=function(){return y.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.pageNumber,this.options.pageNumber),!1},p.prototype.toggleColumn=function(){g.apply(this,Array.prototype.slice.apply(arguments));var t=[];o.each(this.columns,function(o,e){e.visible&&t.push(e.field)}),r(this,e.columns,JSON.stringify(t))},p.prototype.selectPage=function(o){k.apply(this,Array.prototype.slice.apply(arguments)),r(this,e.pageNumber,o)},p.prototype.onSearch=function(){var t=Array.prototype.slice.apply(arguments);m.apply(this,t),o(t[0].currentTarget).parent().hasClass("search")&&r(this,e.searchText,this.searchText),r(this,e.pageNumber,this.options.pageNumber)},p.prototype.getCookies=function(){var t=this,i={};return o.each(e,function(o,e){i[o]=s(t,t.options.cookieIdTable,e),"columns"===o&&(i[o]=JSON.parse(i[o]))}),i},p.prototype.deleteCookie=function(o){""!==o&&t()&&function(o,e,t){switch(t=e+"."+t,o.options.cookieStorage){case"cookieStorage":document.cookie=[encodeURIComponent(t),"=","; expires=Thu, 01 Jan 1970 00:00:00 GMT",o.options.cookiePath?"; path="+o.options.cookiePath:"",o.options.cookieDomain?"; domain="+o.options.cookieDomain:""].join("");break;case"localStorage":localStorage.removeItem(t);break;case"sessionStorage":sessionStorage.removeItem(t)}}(this,this.options.cookieIdTable,e[o])}}(jQuery)},355:function(o,e,t){t(354)}});if("object"==typeof t){var i=["object"==typeof module&&"object"==typeof module.exports?module.exports:null,"undefined"!=typeof window?window:null,o&&o!==window?o:null];for(var r in t)i[0]&&(i[0][r]=t[r]),i[1]&&"__esModule"!==r&&(i[1][r]=t[r]),i[2]&&(i[2][r]=t[r])}}(this);