| | |
| | | }, |
| | | |
| | | reportError: function(request) { |
| | | /* Error reporting is disabled by default as some browsers like safari |
| | | sometimes throw errors when a ajax request is delayed even if the |
| | | ajax request worked. */ |
| | | |
| | | /*alert(request);*/ |
| | | |
| | | }, |
| | | |
| | | registerHook: function(name, callback) { |
| | |
| | | 'fontAwesome': true, |
| | | 'autoclose': true |
| | | }); |
| | | $('[data-toggle="tooltip"]').tooltip({ |
| | | }); |
| | | |
| | | ISPConfig.callHook('onAfterContentLoad', {'url': url, 'data': data }); |
| | | }, |
| | | |
| | | /* THIS ONE SHOULD BE REMOVED AFTER CREATING THE STATIC LOGIN PAGE!!! */ |
| | | /*submitLoginForm: function(formname) { |
| | | //* Validate form. TODO: username and password with strip(); |
| | | var frm = document.getElementById(formname); |
| | | var userNameObj = frm.username; |
| | | if(userNameObj.value == ''){ |
| | | userNameObj.focus(); |
| | | return; |
| | | } |
| | | var passwordObj = frm.passwort; |
| | | if(passwordObj.value == ''){ |
| | | passwordObj.focus(); |
| | | return; |
| | | } |
| | | |
| | | $('#dummy_username').val(userNameObj.value); |
| | | $('#dummy_passwort').val(passwordObj.value); |
| | | $('#dummy_login_form').submit(); |
| | | |
| | | var submitFormObj = $.ajax({ |
| | | type: "POST", |
| | | url: "content.php", |
| | | data: $('#'+formname).serialize(), |
| | | dataType: "html", |
| | | beforeSend: function() { |
| | | ISPConfig.showLoadIndicator(); |
| | | }, |
| | | success: function(data, textStatus, jqXHR) { |
| | | if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
| | | var parts = jqXHR.responseText.split(':'); |
| | | ISPConfig.loadContent(parts[1]); |
| | | } else if (jqXHR.responseText.indexOf('LOGIN_REDIRECT:') > -1) { |
| | | // Go to the login page |
| | | document.location.href = 'index.php'; |
| | | } else { |
| | | $('#pageContent').html(jqXHR.responseText); |
| | | ISPConfig.onAfterContentLoad('content.php', $('#'+formname).serialize()); |
| | | ISPConfig.pageFormChanged = false; |
| | | } |
| | | ISPConfig.loadMenus(); |
| | | ISPConfig.hideLoadIndicator(); |
| | | }, |
| | | error: function() { |
| | | ISPConfig.hideLoadIndicator(); |
| | | ISPConfig.reportError('Ajax Request was not successful.110'); |
| | | } |
| | | }); |
| | | },*/ |
| | | |
| | | submitForm: function(formname, target, confirmation) { |
| | | var successMessage = arguments[3]; |
| | |
| | | } catch(e) { |
| | | response = responseStr; |
| | | } |
| | | var $response = $('<div></div>').html(response); |
| | | var msg = ''; |
| | | var okmsg = $('#OKMsg',response).html(); |
| | | var okmsg = $response.find('#OKMsg').html(); |
| | | if(okmsg){ |
| | | msg = '<div id="OKMsg">'+okmsg+'</div>'; |
| | | } |
| | | var errormsg = $('#errorMsg',response).html(); |
| | | var errormsg = $response.find('#errorMsg').html(); |
| | | if(errormsg){ |
| | | msg = msg+'<div id="errorMsg">'+errormsg+'</div>'; |
| | | } |
| | | |
| | | var csrf_key = $response.find('input[name="_csrf_key"]').val(); |
| | | var csrf_id = $response.find('input[name="_csrf_id"]').val(); |
| | | |
| | | msg = msg + '<input type="hidden" name="_csrf_id" value="' + csrf_id + '" /><input type="hidden" name="_csrf_key" value="' + csrf_key + '" />'; |
| | | |
| | | return msg; |
| | | |
| | | }; |
| | | |
| | | var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000); |
| | | $('body').after('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>'); |
| | | $('input[type="file"]').closest("form").attr({target: frame_id, action: target}).submit(); |
| | | $('body').append('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>'); |
| | | $('#'+frame_id).load(function() { |
| | | var msg = handleResponse(this); |
| | | $('#errorMsg').remove(); |
| | | $('#OKMsg').remove(); |
| | | $('input[name="_csrf_key"]').remove(); |
| | | $('input[name="_csrf_id"]').remove(); |
| | | $('input[name="id"]').before(msg); |
| | | $(this).remove(); |
| | | }); |
| | | $('input[type="file"]').closest("form").attr({target: frame_id, action: target}).submit(); |
| | | }, |
| | | |
| | | capp: function(module, redirect) { |
| | |
| | | var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length); |
| | | document.location.href = newUrl; |
| | | } else { |
| | | //document.getElementById('pageContent').innerHTML = jqXHR.responseText; |
| | | //var reponse = $(jqXHR.responseText); |
| | | //var reponseScript = reponse.filter("script"); |
| | | //$.each(reponseScript, function(idx, val) { eval(val.text); } ); |
| | | |
| | | $('#pageContent').html(jqXHR.responseText); |
| | | ISPConfig.onAfterContentLoad(pagename, (params ? params : null)); |
| | | ISPConfig.pageFormChanged = false; |
| | |
| | | }, |
| | | |
| | | loadInitContent: function() { |
| | | var startpage = $('#pageContent').attr('data-startpage'); |
| | | if(!startpage) startpage = 'dashboard/dashboard.php'; |
| | | var pageContentObject = $.ajax({ |
| | | type: "GET", |
| | | url: "dashboard/dashboard.php", |
| | | url: startpage, |
| | | data: "", |
| | | dataType: "html", |
| | | beforeSend: function() { |
| | |
| | | }, |
| | | |
| | | changeTab: function(tab, target, force) { |
| | | if(ISPConfig.requestsRunning > 0) return false; |
| | | if(ISPConfig.requestsRunning > 0) { |
| | | console.log('tab change interrupted, request still running.'); |
| | | return false; |
| | | } |
| | | |
| | | document.pageForm.next_tab.value = tab; |
| | | |
| | |
| | | } |
| | | }); |
| | | |
| | | var $page = $('html, body'); |
| | | |
| | | $(document).on('click', 'a[data-load-content],button[data-load-content]', function(e) { |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: $('#pageContent').offset().top}, 1000); |
| | | if(ISPConfig.requestsRunning > 0) { |
| | | console.log('preventing click because there is still a request running.'); |
| | | return; |
| | | } |
| | | |
| | | $page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
| | | $page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
| | | |
| | | var content_to_load = $(this).attr('data-load-content'); |
| | | if(!content_to_load) return this; |
| | |
| | | |
| | | $(document).on('click', 'a[data-capp],button[data-capp]', function(e) { |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: $('#pageContent').offset().top}, 1000); |
| | | if(ISPConfig.requestsRunning > 0) { |
| | | console.log('preventing click because there is still a request running.'); |
| | | return; |
| | | } |
| | | |
| | | $page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
| | | $page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
| | | |
| | | var content_to_load = $(this).attr('data-capp'); |
| | | if(!content_to_load) return this; |
| | |
| | | |
| | | $(document).on('click', 'a[data-submit-form],button[data-submit-form]', function(e) { |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: $('#pageContent').offset().top}, 1000); |
| | | if(ISPConfig.requestsRunning > 0) { |
| | | console.log('preventing click because there is still a request running.'); |
| | | return; |
| | | } |
| | | |
| | | $page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
| | | $page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
| | | |
| | | var $el = $(this); |
| | | var act = $el.attr('data-form-action'); |
| | |
| | | $("#pageForm .table #Filter").trigger('click'); |
| | | } |
| | | //Use $ submit with keypress Enter in forms |
| | | if (event.which == '13' && $(".pnl_formsarea button.positive").length > 0 && event.target.localName != 'textarea' && $(event.target).is(':input')) { |
| | | if (event.which == '13' && $(".tab-content button.formbutton-success").length > 0 && event.target.localName != 'textarea' && $(event.target).is(':input')) { |
| | | event.preventDefault(); |
| | | $(".pnl_formsarea button.positive:first").not("[disabled='disabled']").trigger('click'); |
| | | $(".tab-content button.formbutton-success").not("[disabled='disabled']").trigger('click'); |
| | | } |
| | | }); |
| | | |
| | |
| | | var template2 = $(this).siblings(':input'); |
| | | template2.insertAtCaret(placeholderContentText); |
| | | }); |
| | | |
| | | $(document).on("click", "[data-check-fields] > input[type='checkbox']", function() { |
| | | if($(this).is(':checked')) { |
| | | var flds = $(this).parent().attr('data-check-fields'); |
| | | var tmp = flds.split(/,/); |
| | | for(var i = 0; i < tmp.length; i++) { |
| | | var fname = tmp[i]; |
| | | $('input[type="checkbox"][name="' + fname + '"]').prop('checked', true); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | $(document).on("click", "[data-uncheck-fields] > input[type='checkbox']", function() { |
| | | if($(this).is(':checked') == false) { |
| | | var flds = $(this).parent().attr('data-uncheck-fields'); |
| | | var tmp = flds.split(/,/); |
| | | for(var i = 0; i < tmp.length; i++) { |
| | | var fname = tmp[i]; |
| | | $('input[type="checkbox"][name="' + fname + '"]').prop('checked', false); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | |
| | | $(document).on('ready', function () { |
| | | $.fn.extend({ |
| | |
| | | e.preventDefault(); |
| | | } |
| | | }); |
| | | |
| | | $.fn.setCursorPosition = function(pos) { |
| | | var self = $(this).get(0); |
| | | if(self.setSelectionRange) { |
| | | self.setSelectionRange(pos, pos); |
| | | } else if(self.createTextRange) { |
| | | var range = self.createTextRange(); |
| | | range.collapse(true); |
| | | if(pos < 0) { |
| | | pos = $(this).val().length + pos; |
| | | } |
| | | range.moveEnd('character', pos); |
| | | range.moveStart('character', pos); |
| | | range.select(); |
| | | } |
| | | }; |
| | | |
| | | $.fn.getCursorPosition = function() { |
| | | var iCaretPos = 0; |
| | | var self = $(this).get(0); |
| | | |
| | | if(typeof self.selectionStart === 'number') { |
| | | iCaretPos = self.selectionDirection == 'backward' ? self.selectionStart : self.selectionEnd; |
| | | } else if(document.selection) { |
| | | this.focus(); |
| | | var oSel = document.selection.createRange(); |
| | | oSel.moveStart('character', -self.value.length); |
| | | iCaretPos = oSel.text.length; |
| | | } |
| | | return iCaretPos; |
| | | }; |
| | | }); |