cp.scripts.js.go 9.5 KB

123
  1. package assets
  2. var CpScriptsJs = []byte(`!function(t,e){if("function"==typeof define&&define.amd)define(["module","exports"],e);else if("undefined"!=typeof exports)e(module,exports);else{var o={exports:{}};e(o,o.exports),t.autosize=o.exports}}(this,function(t,e){"use strict";var o,a,c="function"==typeof Map?new Map:(o=[],a=[],{has:function(t){return-1<o.indexOf(t)},get:function(t){return a[o.indexOf(t)]},set:function(t,e){-1===o.indexOf(t)&&(o.push(t),a.push(e))},delete:function(t){var e=o.indexOf(t);-1<e&&(o.splice(e,1),a.splice(e,1))}}),f=function(t){return new Event(t,{bubbles:!0})};try{new Event("test")}catch(t){f=function(t){var e=document.createEvent("Event");return e.initEvent(t,!0,!1),e}}function n(n){if(n&&n.nodeName&&"TEXTAREA"===n.nodeName&&!c.has(n)){var t,o=null,a=null,s=null,r=function(){n.clientWidth!==a&&u()},i=function(e){window.removeEventListener("resize",r,!1),n.removeEventListener("input",u,!1),n.removeEventListener("keyup",u,!1),n.removeEventListener("autosize:destroy",i,!1),n.removeEventListener("autosize:update",u,!1),Object.keys(e).forEach(function(t){n.style[t]=e[t]}),c.delete(n)}.bind(n,{height:n.style.height,resize:n.style.resize,overflowY:n.style.overflowY,overflowX:n.style.overflowX,wordWrap:n.style.wordWrap});n.addEventListener("autosize:destroy",i,!1),"onpropertychange"in n&&"oninput"in n&&n.addEventListener("keyup",u,!1),window.addEventListener("resize",r,!1),n.addEventListener("input",u,!1),n.addEventListener("autosize:update",u,!1),n.style.overflowX="hidden",n.style.wordWrap="break-word",c.set(n,{destroy:i,update:u}),"vertical"===(t=window.getComputedStyle(n,null)).resize?n.style.resize="none":"both"===t.resize&&(n.style.resize="horizontal"),o="content-box"===t.boxSizing?-(parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)):parseFloat(t.borderTopWidth)+parseFloat(t.borderBottomWidth),isNaN(o)&&(o=0),u()}function l(t){var e=n.style.width;n.style.width="0px",n.offsetWidth,n.style.width=e,n.style.overflowY=t}function d(){if(0!==n.scrollHeight){var t=function(t){for(var e=[];t&&t.parentNode&&t.parentNode instanceof Element;)t.parentNode.scrollTop&&e.push({node:t.parentNode,scrollTop:t.parentNode.scrollTop}),t=t.parentNode;return e}(n),e=document.documentElement&&document.documentElement.scrollTop;n.style.height="",n.style.height=n.scrollHeight+o+"px",a=n.clientWidth,t.forEach(function(t){t.node.scrollTop=t.scrollTop}),e&&(document.documentElement.scrollTop=e)}}function u(){d();var t=Math.round(parseFloat(n.style.height)),e=window.getComputedStyle(n,null),o="content-box"===e.boxSizing?Math.round(parseFloat(e.height)):n.offsetHeight;if(o<t?"hidden"===e.overflowY&&(l("scroll"),d(),o="content-box"===e.boxSizing?Math.round(parseFloat(window.getComputedStyle(n,null).height)):n.offsetHeight):"hidden"!==e.overflowY&&(l("hidden"),d(),o="content-box"===e.boxSizing?Math.round(parseFloat(window.getComputedStyle(n,null).height)):n.offsetHeight),s!==o){s=o;var a=f("autosize:resized");try{n.dispatchEvent(a)}catch(t){}}}}function s(t){var e=c.get(t);e&&e.destroy()}function r(t){var e=c.get(t);e&&e.update()}var i=null;"undefined"==typeof window||"function"!=typeof window.getComputedStyle?((i=function(t){return t}).destroy=function(t){return t},i.update=function(t){return t}):((i=function(t,e){return t&&Array.prototype.forEach.call(t.length?t:[t],function(t){return n(t)}),t}).destroy=function(t){return t&&Array.prototype.forEach.call(t.length?t:[t],s),t},i.update=function(t){return t&&Array.prototype.forEach.call(t.length?t:[t],r),t}),e.default=i,t.exports=e.default}),function(window,$){var fave=function(window,$){var FormDataWasChanged=!1;function GetModalAlertTmpl(t,e,o){return'<div class="alert alert-'+(o?"danger":"success")+' alert-dismissible fade show" role="alert"><strong>'+t+"</strong> "+e+'<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button></div>'}function ShowSystemMsg(t,e,o){var a=$(".modal.show .sys-messages");a.length||(a=$("form.alert-here .sys-messages")),a.length&&a.html(GetModalAlertTmpl(t,e,o))}function AjaxDone(data){try{eval(data)}catch(t){t instanceof SyntaxError&&(console.log(data),console.log("Error: JavaScript code eval error",t.message))}}function AjaxFail(t,e,o){console.log("Error: data sending error, page will be reloaded",t,e,o),setTimeout(function(){window.location.reload(!1)},1e3)}function FormToAjax(o){o.submit(function(t){if(o.hasClass("loading"))t.preventDefault();else{o.addClass("loading").addClass("alert-here");var e=o.find("button[type=submit]");e.addClass("progress-bar-striped").addClass("progress-bar-animated"),""!=e.attr("data-target")&&$("#"+e.attr("data-target")).addClass("progress-bar-striped").addClass("progress-bar-animated"),o.find(".sys-messages").html(""),$.ajax({type:"POST",url:o.attr("action"),data:o.serialize()}).done(function(t){FormDataWasChanged=!1,AjaxDone(t)}).fail(function(t,e,o){AjaxFail(t.responseText,e,o)}).always(function(){setTimeout(function(){o.removeClass("loading").removeClass("alert-here"),e.removeClass("progress-bar-striped").removeClass("progress-bar-animated"),""!=e.attr("data-target")&&$("#"+e.attr("data-target")).removeClass("progress-bar-striped").removeClass("progress-bar-animated")},100)}),t.preventDefault()}});var t=o.find("button[type=submit]");""!=t.attr("data-target")&&$("#"+t.attr("data-target")).click(function(){t.click()}),o.hasClass("prev-data-lost")&&o.find("input, textarea, select").on("input",function(){FormDataWasChanged||(FormDataWasChanged=!0)})}function AllFormsToAjax(){$("form").each(function(){FormToAjax($(this))})}function BindWindowBeforeUnload(){$(window).bind("beforeunload",function(){if(FormDataWasChanged)return"Some data was changed and not saved. Are you sure want to leave page?"})}function MakeTextAreasAutoSized(){autosize($("textarea.autosize"))}function Initialize(){"function"==typeof $?(AllFormsToAjax(),BindWindowBeforeUnload(),MakeTextAreasAutoSized()):console.log("Error: jQuery is not loaded!")}return window.addEventListener?window.addEventListener("load",Initialize,!1):window.attachEvent&&window.attachEvent("onload",Initialize),{ShowMsgSuccess:function(t,e){ShowSystemMsg(t,e,!1)},ShowMsgError:function(t,e){ShowSystemMsg(t,e,!0)},ModalUserProfile:function(){var t='<div class="modal fade" id="sys-modal-user-settings" tabindex="-1" role="dialog" aria-labelledby="sysModalUserSettingsLabel" aria-hidden="true"> \t\t\t\t\t<div class="modal-dialog modal-dialog-centered" role="document"> \t\t\t\t\t\t<div class="modal-content"> \t\t\t\t\t\t\t<form class="form-user-settings" action="/cp/" method="post" autocomplete="off"> \t\t\t\t\t\t\t\t<input type="hidden" name="action" value="index-user-update-profile"> \t\t\t\t\t\t\t\t<div class="modal-header"> \t\t\t\t\t\t\t\t\t<h5 class="modal-title" id="sysModalUserSettingsLabel">My profile</h5> \t\t\t\t\t\t\t\t\t<button type="button" class="close" data-dismiss="modal" aria-label="Close"> \t\t\t\t\t\t\t\t\t\t<span aria-hidden="true">&times;</span> \t\t\t\t\t\t\t\t\t</button> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t<div class="modal-body text-left"> \t\t\t\t\t\t\t\t\t<div class="form-group"> \t\t\t\t\t\t\t\t\t\t<label for="first_name">First name</label> \t\t\t\t\t\t\t\t\t\t<input type="text" class="form-control" id="first_name" name="first_name" value="'+window.CurrentUserProfileData.first_name+'" placeholder="User first name" autocomplete="off"> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div class="form-group"> \t\t\t\t\t\t\t\t\t\t<label for="last_name">Last name</label> \t\t\t\t\t\t\t\t\t\t<input type="text" class="form-control" id="last_name" name="last_name" value="'+window.CurrentUserProfileData.last_name+'" placeholder="User last name" autocomplete="off"> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div class="form-group"> \t\t\t\t\t\t\t\t\t\t<label for="email">Email</label> \t\t\t\t\t\t\t\t\t\t<input type="email" class="form-control" id="email" name="email" value="'+window.CurrentUserProfileData.email+'" placeholder="User email" autocomplete="off" required> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div class="form-group"> \t\t\t\t\t\t\t\t\t\t<label for="password">New password</label> \t\t\t\t\t\t\t\t\t\t<input type="password" class="form-control" id="password" aria-describedby="passwordHelp" name="password" value="" placeholder="User new password" autocomplete="off"> \t\t\t\t\t\t\t\t\t\t<small id="passwordHelp" class="form-text text-muted">Leave this field empty if you don\'t want change your password</small> \t\t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t\t<div class="sys-messages"></div> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t\t<div class="modal-footer"> \t\t\t\t\t\t\t\t\t<button type="submit" class="btn btn-primary">Save</button> \t\t\t\t\t\t\t\t\t<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button> \t\t\t\t\t\t\t\t</div> \t\t\t\t\t\t\t</form> \t\t\t\t\t\t</div> \t\t\t\t\t</div> \t\t\t\t</div>';$("#sys-modal-user-settings-placeholder").html(t),$("#sys-modal-user-settings").modal({backdrop:"static",keyboard:!1,show:!1}),$("#sys-modal-user-settings").on("hidden.bs.modal",function(t){$("#sys-modal-user-settings-placeholder").html("")}),FormToAjax($("#sys-modal-user-settings form")),$("#sys-modal-user-settings").modal("show")},ActionLogout:function(t){confirm(t)&&$.ajax({type:"POST",url:"/cp/",data:{action:"index-user-logout"}}).done(function(t){AjaxDone(t)}).fail(function(t,e,o){AjaxFail(t.responseText,e,o)})},ActionDataTableDelete:function(t,e,o,a){confirm(a)&&$.ajax({type:"POST",url:"/cp/",data:{action:e,id:o}}).done(function(t){AjaxDone(t)}).fail(function(t,e,o){AjaxFail(t.responseText,e,o)})}}}(window,$);window.fave=fave}(window,jQuery);`)