Skip to content
ispconfig.min.js 13.3 KiB
Newer Older
Till Brehm's avatar
Till Brehm committed
var ISPConfig={pageFormChanged:!1,tabChangeWarningTxt:"",tabChangeDiscardTxt:"",tabChangeWarning:!1,tabChangeDiscard:!1,requestsRunning:0,indicatorCompleted:!1,registeredHooks:[],new_tpl_add_id:0,options:{useLoadIndicator:!1,useComboBox:!1},setOption:function(a,b){ISPConfig.options[a]=b},setOptions:function(a){$.extend(ISPConfig.options,a)},reportError:function(a){},registerHook:function(a,b){ISPConfig.registeredHooks[a]||(ISPConfig.registeredHooks[a]=[]);ISPConfig.registeredHooks[a][ISPConfig.registeredHooks[a].length]=
b},callHook:function(a,b){if(ISPConfig.registeredHooks[a])for(var c=0;c<ISPConfig.registeredHooks[a].length;c++)(0,ISPConfig.registeredHooks[a][c])(a,b)},resetFormChanged:function(){ISPConfig.pageFormChanged=!1},showLoadIndicator:function(){document.body.style.cursor="wait";if(1==ISPConfig.options.useLoadIndicator&&(ISPConfig.requestsRunning+=1,2>ISPConfig.requestsRunning)){var a=$("#ajaxloader");1>a.length&&(a=$('<div id="ajaxloader" style="display: none;"></div>'),a.appendTo("body"));var b=$("#content");
if(!(1>b.length)){ISPConfig.indicatorCompleted=!1;var c=b.offset().left+150,b=b.offset().top+150;a.css({left:c,top:b}).fadeIn("fast",function(){ISPConfig.indicatorCompleted=!0;1>ISPConfig.requestsRunning&&$(this).fadeOut("fast",function(){$(this).hide()})})}}},hideLoadIndicator:function(){document.body.style.cursor="";--ISPConfig.requestsRunning;1>ISPConfig.requestsRunning&&(ISPConfig.requestsRunning=0,1==ISPConfig.indicatorCompleted&&$("#ajaxloader").fadeOut("fast",function(){$("#ajaxloader").hide()}))},
onAfterSideNavLoaded:function(){1==ISPConfig.options.useComboBox&&$("#sidebar").find("select:not(.chosen-select)").select2({placeholder:"",width:"element",selectOnBlur:!0,allowClear:!0})},onAfterContentLoad:function(a,b){b=b?"&"+b:"";if(1==ISPConfig.options.useComboBox)$("#pageContent").find("select:not(.chosen-select)").select2({placeholder:"",width:"element",selectOnBlur:!0,allowClear:!0,formatResult:function(a){return a.id&&$(a.element).parent().hasClass("flags")?'<span class="flags flag-'+a.id.toLowerCase()+
'">'+a.text+"</span>":a.text},formatSelection:function(a){return a.id&&$(a.element).parent().hasClass("flags")?'<span class="flags flag-'+a.id.toLowerCase()+'">'+a.text+"</span>":a.text}}).on("change",function(a){0<$("#pageForm .table #Filter").length&&$("#pageForm .table #Filter").trigger("click")});$('input[data-input-element="date"]').datetimepicker({language:"en",todayHighlight:!0,todayBtn:"linked",bootcssVer:3,fontAwesome:!0,autoclose:!0,minView:"month"});$('input[data-input-element="datetime"]').datetimepicker({language:"en",
todayHighlight:!0,todayBtn:"linked",bootcssVer:3,fontAwesome:!0,autoclose:!0});ISPConfig.callHook("onAfterContentLoad",{url:a,data:b})},submitForm:function(a,b,c,e){c||(c=!1);c&&!window.confirm(c)||$.ajax({type:"POST",url:b,data:$("#"+a).serialize(),dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},success:function(c,f,g){e&&alert(e);-1<g.responseText.indexOf("HEADER_REDIRECT:")?(c=g.responseText.split(":"),ISPConfig.loadContent(c[1])):-1<g.responseText.indexOf("LOGIN_REDIRECT:")?
document.location.href="/index.php":($("#pageContent").html(g.responseText),ISPConfig.onAfterContentLoad(b,$("#"+a).serialize()),ISPConfig.pageFormChanged=!1);ISPConfig.hideLoadIndicator()},error:function(a,b,c){ISPConfig.hideLoadIndicator();a.responseText.split(":");ISPConfig.reportError("Ajax Request was not successful. 111")}})},submitUploadForm:function(a,b){var c="ajaxUploader-iframe-"+Math.round((new Date).getTime()/1E3);$("body").after('<iframe width="0" height="0" style="display:none;" name="'+
c+'" id="'+c+'"/>');$('input[type="file"]').closest("form").attr({target:c,action:b}).submit();$("#"+c).load(function(){var a,b=this.contentWindow.document.body.innerHTML;try{a=JSON.parse(b)}catch(c){a=b}var b="",f=$("#OKMsg",a).html();f&&(b='<div id="OKMsg">'+f+"</div>");(a=$("#errorMsg",a).html())&&(b=b+'<div id="errorMsg">'+a+"</div>");a=b;$("#errorMsg").remove();$("#OKMsg").remove();$('input[name="id"]').before(a);$(this).remove()})},capp:function(a,b){$.ajax({type:"GET",url:"capp.php",data:"mod="+
a+(void 0!=b?"&redirect="+b:""),dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},success:function(a,b,d){""!=d.responseText&&(-1<d.responseText.indexOf("HEADER_REDIRECT:")?(a=d.responseText.split(":"),ISPConfig.loadContent(a[1])):-1<d.responseText.indexOf("URL_REDIRECT:")&&(a=d.responseText.substr(d.responseText.indexOf("URL_REDIRECT:")+13),document.location.href=a));ISPConfig.loadMenus();ISPConfig.hideLoadIndicator()},error:function(){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful."+
a)}})},loadContent:function(a,b){$.ajax({type:"GET",url:a,data:b?b:null,dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},success:function(c,e,d){-1<d.responseText.indexOf("HEADER_REDIRECT:")?(c=d.responseText.split(":"),ISPConfig.loadContent(c[1])):-1<d.responseText.indexOf("URL_REDIRECT:")?(c=d.responseText.substr(d.responseText.indexOf("URL_REDIRECT:")+13),document.location.href=c):($("#pageContent").html(d.responseText),ISPConfig.onAfterContentLoad(a,b?b:null),ISPConfig.pageFormChanged=
!1);ISPConfig.hideLoadIndicator()},error:function(){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful. 113")}})},loadContentRefresh:function(a){0<$("#refreshinterval").val()&&($.ajax({type:"GET",url:a,data:"refresh="+document.getElementById("refreshinterval").value,dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},success:function(b,c,e){ISPConfig.hideLoadIndicator();$("#pageContent").html(e.responseText);ISPConfig.onAfterContentLoad(a,"refresh="+
document.getElementById("refreshinterval").value);ISPConfig.pageFormChanged=!1},error:function(){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful."+a)}}),setTimeout("ISPConfig.loadContentRefresh('"+a+"&refresh="+document.getElementById("refreshinterval").value+"')",6E4*document.getElementById("refreshinterval").value))},loadInitContent:function(){$.ajax({type:"GET",url:"dashboard/dashboard.php",data:"",dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},
success:function(a,b,c){-1<c.responseText.indexOf("HEADER_REDIRECT:")?(a=c.responseText.split(":"),ISPConfig.loadContent(a[1])):($("#pageContent").html(c.responseText),ISPConfig.onAfterContentLoad("dashboard/dashboard.php",""),ISPConfig.pageFormChanged=!1);ISPConfig.hideLoadIndicator()},error:function(){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful. 114")}});ISPConfig.loadMenus();ISPConfig.keepalive();setTimeout(function(){try{$("form#pageForm").find('input[name="username"]').focus()}catch(a){}},
1E3)},loadMenus:function(){$.ajax({type:"GET",url:"nav.php",data:"nav=side",dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},success:function(a,b,c){ISPConfig.hideLoadIndicator();$("#sidebar").html(c.responseText);ISPConfig.onAfterSideNavLoaded();ISPConfig.loadPushyMenu()},error:function(){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful. 115")}});$.ajax({type:"GET",url:"nav.php",data:"nav=top",dataType:"html",beforeSend:function(){ISPConfig.showLoadIndicator()},
success:function(a,b,c){ISPConfig.hideLoadIndicator();$("#topnav-container").html(c.responseText);ISPConfig.loadPushyMenu()},error:function(a){ISPConfig.hideLoadIndicator();ISPConfig.reportError("Ajax Request was not successful. 116")}})},changeTab:function(a,b,c){if(0<ISPConfig.requestsRunning)return!1;document.pageForm.next_tab.value=a;var e=$("form#pageForm").find('[name="id"]'),d=null;0<e.length&&(d=e.val());if("y"!=ISPConfig.tabChangeDiscard||c)d&&"y"==ISPConfig.tabChangeWarning&&1==ISPConfig.pageFormChanged?
window.confirm(ISPConfig.tabChangeWarningTxt)?ISPConfig.submitForm("pageForm",b):d?ISPConfig.loadContent(b,{next_tab:a,id:d}):ISPConfig.loadContent(b,{next_tab:a}):ISPConfig.submitForm("pageForm",b);else if((1>e.length||d)&&(0==ISPConfig.pageFormChanged||window.confirm(ISPConfig.tabChangeDiscardTxt)))d?ISPConfig.loadContent(b,{next_tab:a,id:d}):ISPConfig.loadContent(b,{next_tab:a});else return!1},confirm_action:function(a,b){window.confirm(b)&&ISPConfig.loadContent(a)},loadContentInto:function(a,
b){$.ajax({type:"GET",url:b,dataType:"html",beforeSend:function(){},success:function(b,e,d){$("#"+a).html(d.responseText)},error:function(){ISPConfig.reportError("Ajax Request was not successful. 118")}})},loadOptionInto:function(a,b,c){$.ajax({type:"GET",url:b,dataType:"html",beforeSend:function(){},success:function(e,d,f){e=f.responseText.split("#");el=document.getElementById(a);el.innerHTML="";for(d=0;d<e.length;++d)f=document.createElement("option"),f.appendChild(document.createTextNode(e[d])),
f.value=e[d],el.appendChild(f);"undefined"!=typeof c&&c(a,b)},error:function(){ISPConfig.reportError("Ajax Request was not successful. 119")}})},keepalive:function(){$.ajax({type:"GET",url:"keepalive.php",dataType:"html",success:function(a,b,c){setTimeout(function(){ISPConfig.keepalive()},1E6)},error:function(){ISPConfig.reportError("Session expired. Please login again.")}})},addAdditionalTemplate:function(){var a=$("#template_additional").val(),b=$("#tpl_add_select").val().split("|",2),c=b[0],b=
b[1];if(0<c){a=a.split("/");ISPConfig.new_tpl_add_id+=1;var e=$('<a href="#"></a>').attr("class","button icons16 icoDelete").click(function(a){a.preventDefault();ISPConfig.delAdditionalTemplate($(this).parent().attr("rel"))});a[a.length]="n"+ISPConfig.new_tpl_add_id+":"+c;$("<li>"+b+"</li>").attr("rel","n"+new_tpl_add_id).append(e).appendTo("#template_additional_list ul");$("#template_additional").val(a.join("/"));alert("additional template "+b+" added to customer")}else alert("no additional template selcted")},
delAdditionalTemplate:function(a){var b=$("#template_additional").val();if(a){var c=$("#template_additional_list ul").find('li[rel="'+a+'"]').eq(0),e=c.text();c.remove();for(var b=b.split("/"),c=[],d=0;d<b.length;d++){var f=b[d].split(":",2);if(2!=f.length||f[0]!=a)c[c.length]=b[d]}$("#template_additional").val(c.join("/"));alert("additional template "+e+" deleted from customer")}else""!=b?(a=document.getElementById("tpl_add_select").value.split("|",2),c=a[0],e=a[1],$("#template_additional_list ul").find("li:not([rel])").each(function(){return $(this).text()==
e?($(this).remove(),!1):this}),c=b.replace(new RegExp("(^|/)"+c+"(/|$)"),""),c=c.replace("//","/"),$("#template_additional").val(c),alert("additional template "+e+" deleted from customer")):alert("no additional template selcted")}};
$(document).on("change",function(a){var b=a.target.localName;0<$("#pageForm .table #Filter").length&&"select"==b&&(a.preventDefault(),$("#pageForm .table #Filter").trigger("click"));"select"!=b&&"input"!=b&&"textarea"!=b||0!=$(a.target).hasClass("no-page-form-change")||(ISPConfig.pageFormChanged=!0)});$(document).on("click","a[data-load-content],button[data-load-content]",function(a){a=$(this).attr("data-load-content");if(!a)return this;ISPConfig.loadContent(a)});
$(document).on("click","a[data-capp],button[data-capp]",function(a){a=$(this).attr("data-capp");if(!a)return this;ISPConfig.capp(a)});$(document).on("click","a[data-submit-form],button[data-submit-form]",function(a){a=$(this);var b=a.attr("data-form-action"),c=a.attr("data-submit-form");"true"==a.attr("data-form-upload")?ISPConfig.submitUploadForm(c,b):ISPConfig.submitForm(c,b)});
$(document).bind("keypress",function(a){"13"==a.which&&0<$("#pageForm .table #Filter").length&&0==$(a.target).hasClass("ui-autocomplete-input")&&(a.preventDefault(),$("#pageForm .table #Filter").trigger("click"));"13"==a.which&&0<$(".pnl_formsarea button.positive").length&&"textarea"!=a.target.localName&&$(a.target).is(":input")&&(a.preventDefault(),$(".pnl_formsarea button.positive:first").not("[disabled='disabled']").trigger("click"))});
$(document).on("click","th[data-column]",function(a){var b=$(this),c=b.attr("data-column");if(!c)return this;if(0<$("#pageForm .table #Filter").length&&"false"!=b.attr("data-sortable")){var e=$("#Filter");a=e.attr("data-form-action");var e=e.attr("data-submit-form"),d=b.attr("data-ordered"),b="?";0<=a.indexOf("?")&&(b="&");ISPConfig.submitForm(e,a+b+"orderby="+c);$(document).ajaxComplete(function(){var a=$('#pageForm .table th[data-column="'+c+'"]');a.parent().children("th[data-column]").removeAttr("data-ordered");
d&&"asc"==d?a.attr("data-ordered","desc"):a.attr("data-ordered","asc")})}});$(document).on("click",".addPlaceholder",function(){var a=$(this).text();$(this).siblings(":input").insertAtCaret(a)});$(document).on("click",".addPlaceholderContent",function(){var a=$(this).find(".addPlaceholderContent").text();$(this).siblings(":input").insertAtCaret(a)});
$(document).on("ready",function(){$.fn.extend({insertAtCaret:function(a){return this.each(function(b){if(document.selection)this.focus(),sel=document.selection.createRange(),sel.text=a,this.focus();else if(this.selectionStart||"0"==this.selectionStart){b=this.selectionStart;var c=this.selectionEnd,e=this.scrollTop;this.value=this.value.substring(0,b)+a+this.value.substring(c,this.value.length);this.focus();this.selectionStart=b+a.length;this.selectionEnd=b+a.length;this.scrollTop=e}else this.value+=
a,this.focus()})}});$(".progress .progress-bar").css("width",function(){return $(this).attr("aria-valuenow")+"%"});ISPConfig.loadInitContent();$("#searchform").submit(function(a){a.preventDefault()});$("#pageForm").submit(function(a){0<$("#pageForm .table #Filter").length&&a.preventDefault()})});