text: "use strict";var Module=function(u){function a(){var e=location.search.substr(1),o={};return e.split("&").forEach(function(e){var t=e.split("=");o[t[0]]=encodeURI(unescape(unescape(t[1])))}),o}function n(e,t){var o=a();return o[e]=t,o}function i(t){var o=[];return Object.keys(t).map(function(e){"undefined"!==t[e]&&""!==t[e]&&o.push([e,t[e]].join("="))}),o.join("&")}function c(t){if(Object.keys(t).length){var o="";Object.keys(t).map(function(e){"page"!==e&&"undefined"!==t[e]&&""!==t[e]&&(""!==o&&(o+="&"),o+=[e,t[e]].join("="))}),location.search=o}}return{changeFileName:function(e,t){if(void 0!==e&&void 0!==t){var o=prompt("Введите новое имя",t);if(""!==o&&o!==t&&null!==o)return u.ajax({url:"/"+ADMIN_DIR+"/meta/filename",type:"POST",data:{id:e,name:o}}),o}return!1},ajaxFileDelete:function(e,t){return cp.dialog("Вы дейсвительно хотите удалить файл?")&&u.ajax({url:"/"+ADMIN_DIR+"/meta/filedelete",type:"post",data:{id:e},dataType:"JSON",success:function(e){!0===e.status&&u("#"+t).remove()}}),!1},sort:function(e){var t=a();if(void 0!==t.sort){var o=t.sort.split("-")[1];o="asc"===o?"desc":"asc",location.search=i(n("sort",e+"-"+o))}else location.search=i(n("sort",e+"-asc"))},search:function(e,t,o,a){o?13==a.keyCode&&c(n(e,t)):c(n(e,t))},reload:function(){var e=a();if(void 0!==e.page){var t=0<=e.page-1?e.page-1:"";t?location.search="page="+t:location.reload()}else location.reload()},setSort:function(e,t,o){var a=["module","sorted",t].join("_"),n=e.value,i=u.cookie(a);if(i){var c=[],r=unserialize(i);"undefined"==r[t]?(c[t]={},c[t][o]=n):(r[t][o],r[t][o]=n,c=r),u.removeCookie(a),u.cookie(a,serialize(c),{expires:30,path:"/"})}else{var l=[];l[t]={},l[t][o]=n,u.cookie(a,serialize(l),{expires:30,path:"/"})}setTimeout(function(){location.reload()},50)},setLimit:function(e,t){var o=["module","limit",t].join("_"),a=parseInt(e.value);u.removeCookie(o),u.cookie(o,a,{expires:30,path:"/"}),setTimeout(function(){location.reload()},50)},update:function(e,t,o){var a=Number(e.target.checked);u.ajax({url:["/",ADMIN_DIR,"/shopping/update"].join(""),type:"post",data:{id:o,name:t,value:a},dataType:"JSON",success:function(e){}})},checkAll:function(e){var t=u(e).prop("checked");u(".check-all-spy").prop("checked",t),t?u("#remove-button").addClass("enable"):u("#remove-button").removeClass("enable")},checkItem:function(e){u(".check-all-spy:checked").length?u("#remove-button").addClass("enable"):u("#remove-button").removeClass("enable")},deleteQuestion:function(e,t){if(e.preventDefault(),cp.dialog("Вы действительно хотите удалить позицию?")){var o=u(t).attr("href");u.post(o,function(){cp.notify("Позиция удалена","info"),u(t).closest("tr").remove()})}return!1},deleteItem:function(e,t,o){u.ajax({url:"/"+ADMIN_DIR+"/meta/module/del/"+t+"/"+e,type:"post",data:{id:e,module:t},dataType:"JSON",success:function(){u("#module-table").find('.module-table__row[data-id="'+e+'"]').remove(),o&&cp.notify("Позиция удалена","info")}})},deleteAll:function(e){e.preventDefault();var a=u(".check-all-spy:checked").length,n=u(".check-all-spy").length;if(a){var i=this;cp.dialog(["Вы действительно хотите удалить ",declOfNum(a,["позиция","позиций","позиции"]),"?"].join(""))&&u(".check-all-spy:checked").each(function(e,t){var o=u(t).val().split("_");i.deleteItem(parseInt(o[0]),parseInt(o[1]),!1),e+1==a&&(cp.notify(["Удалено ",declOfNum(a,["позиция","позиций","позиции"])].join(""),"info"),setTimeout(function(){a==n?i.reload():location.reload()},150))})}}}}(jQuery),structure=(jQuery,{});