commit | author | age
|
9021d7
|
1 |
var ISPConfig = { |
MC |
2 |
pageFormChanged: false, |
|
3 |
tabChangeWarningTxt: '', |
|
4 |
tabChangeDiscardTxt: '', |
|
5 |
tabChangeWarning: false, |
|
6 |
tabChangeDiscard: false, |
|
7 |
requestsRunning: 0, |
|
8 |
indicatorCompleted: false, |
|
9 |
registeredHooks: new Array(), |
|
10 |
new_tpl_add_id: 0, |
|
11 |
|
|
12 |
options: { |
|
13 |
useLoadIndicator: false, |
b79c5b
|
14 |
useComboBox: false |
9021d7
|
15 |
}, |
MC |
16 |
|
|
17 |
setOption: function(key, value) { |
|
18 |
ISPConfig.options[key] = value; |
|
19 |
}, |
|
20 |
|
|
21 |
setOptions: function(opts) { |
|
22 |
$.extend(ISPConfig.options, opts); |
|
23 |
}, |
|
24 |
|
|
25 |
reportError: function(request) { |
844564
|
26 |
|
9021d7
|
27 |
}, |
MC |
28 |
|
|
29 |
registerHook: function(name, callback) { |
|
30 |
if(!ISPConfig.registeredHooks[name]) ISPConfig.registeredHooks[name] = new Array(); |
|
31 |
var newindex = ISPConfig.registeredHooks[name].length; |
|
32 |
ISPConfig.registeredHooks[name][newindex] = callback; |
|
33 |
}, |
|
34 |
|
|
35 |
callHook: function(name, params) { |
|
36 |
if(!ISPConfig.registeredHooks[name]) return; |
|
37 |
for(var i = 0; i < ISPConfig.registeredHooks[name].length; i++) { |
|
38 |
var callback = ISPConfig.registeredHooks[name][i]; |
|
39 |
callback(name, params); |
|
40 |
} |
|
41 |
}, |
|
42 |
|
|
43 |
resetFormChanged: function() { |
|
44 |
ISPConfig.pageFormChanged = false; |
|
45 |
}, |
|
46 |
|
|
47 |
showLoadIndicator: function() { |
|
48 |
document.body.style.cursor = 'wait'; |
|
49 |
|
|
50 |
if(ISPConfig.options.useLoadIndicator == true) { |
|
51 |
ISPConfig.requestsRunning += 1; |
|
52 |
|
|
53 |
if(ISPConfig.requestsRunning < 2) { |
|
54 |
var indicator = $('#ajaxloader'); |
|
55 |
if(indicator.length < 1) { |
|
56 |
indicator = $('<div id="ajaxloader" style="display: none;"></div>'); |
|
57 |
indicator.appendTo('body'); |
|
58 |
} |
|
59 |
var parent = $('#content'); |
|
60 |
if(parent.length < 1) return; |
|
61 |
ISPConfig.indicatorCompleted = false; |
|
62 |
|
|
63 |
var atx = parent.offset().left + 150; //((parent.outerWidth(true) - indicator.outerWidth(true)) / 2); |
|
64 |
var aty = parent.offset().top + 150; |
|
65 |
indicator.css( {'left': atx, 'top': aty } ).fadeIn('fast', function() { |
|
66 |
// check if loader should be hidden immediately |
|
67 |
ISPConfig.indicatorCompleted = true; |
|
68 |
if(ISPConfig.requestsRunning < 1) $(this).fadeOut('fast', function() { $(this).hide();}); |
|
69 |
}); |
|
70 |
} |
|
71 |
} |
|
72 |
}, |
|
73 |
|
|
74 |
hideLoadIndicator: function() { |
|
75 |
document.body.style.cursor = ''; |
|
76 |
|
|
77 |
ISPConfig.requestsRunning -= 1; |
|
78 |
if(ISPConfig.requestsRunning < 1) { |
|
79 |
ISPConfig.requestsRunning = 0; // just for the case... |
|
80 |
if(ISPConfig.indicatorCompleted == true) $('#ajaxloader').fadeOut('fast', function() { $('#ajaxloader').hide(); } ); |
|
81 |
} |
|
82 |
}, |
|
83 |
|
|
84 |
onAfterSideNavLoaded: function() { |
|
85 |
if(ISPConfig.options.useComboBox == true) { |
|
86 |
$('#sidebar').find("select:not(.chosen-select)").select2({ |
|
87 |
placeholder: '', |
|
88 |
width: 'element', |
|
89 |
selectOnBlur: true, |
b79c5b
|
90 |
allowClear: true |
9021d7
|
91 |
}); |
MC |
92 |
} |
|
93 |
}, |
|
94 |
|
|
95 |
onAfterContentLoad: function(url, data) { |
|
96 |
if(!data) data = ''; |
|
97 |
else data = '&' + data; |
|
98 |
|
|
99 |
if(ISPConfig.options.useComboBox == true) { |
|
100 |
$('#pageContent').find("select:not(.chosen-select)").select2({ |
|
101 |
placeholder: '', |
|
102 |
width: 'element', |
|
103 |
selectOnBlur: true, |
|
104 |
allowClear: true, |
|
105 |
formatResult: function(o) { |
|
106 |
if(o.id && $(o.element).parent().hasClass('flags')) return '<span class="flags flag-' + o.id.toLowerCase() + '">' + o.text + '</span>'; |
|
107 |
else return o.text; |
|
108 |
}, |
|
109 |
formatSelection: function(o) { |
|
110 |
if(o.id && $(o.element).parent().hasClass('flags')) return '<span class="flags flag-' + o.id.toLowerCase() + '">' + o.text + '</span>'; |
|
111 |
else return o.text; |
|
112 |
} |
|
113 |
}).on('change', function(e) { |
|
114 |
if ($("#pageForm .table #Filter").length > 0) { |
|
115 |
$("#pageForm .table #Filter").trigger('click'); |
|
116 |
} |
|
117 |
}); |
|
118 |
} |
|
119 |
|
43e5b6
|
120 |
$('input[data-input-element="date"]').datetimepicker({ |
MC |
121 |
'language': 'en', // TODO |
|
122 |
'todayHighlight': true, |
|
123 |
'todayBtn': 'linked', |
|
124 |
'bootcssVer': 3, |
|
125 |
'fontAwesome': true, |
|
126 |
'autoclose': true, |
|
127 |
'minView': 'month' |
|
128 |
}); |
|
129 |
$('input[data-input-element="datetime"]').datetimepicker({ |
|
130 |
'language': 'en', // TODO |
|
131 |
'todayHighlight': true, |
|
132 |
'todayBtn': 'linked', |
|
133 |
'bootcssVer': 3, |
|
134 |
'fontAwesome': true, |
|
135 |
'autoclose': true |
|
136 |
}); |
d75040
|
137 |
$('[data-toggle="tooltip"]').tooltip({ |
PD |
138 |
}); |
43e5b6
|
139 |
|
9021d7
|
140 |
ISPConfig.callHook('onAfterContentLoad', {'url': url, 'data': data }); |
MC |
141 |
}, |
|
142 |
|
|
143 |
submitForm: function(formname, target, confirmation) { |
|
144 |
var successMessage = arguments[3]; |
|
145 |
if(!confirmation) confirmation = false; |
|
146 |
|
|
147 |
if(!confirmation || window.confirm(confirmation)) { |
|
148 |
var submitFormObj = $.ajax({ |
|
149 |
type: "POST", |
|
150 |
url: target, |
|
151 |
data: $('#'+formname).serialize(), |
|
152 |
dataType: "html", |
|
153 |
beforeSend: function() { |
|
154 |
ISPConfig.showLoadIndicator(); |
|
155 |
}, |
|
156 |
success: function(data, textStatus, jqXHR) { |
|
157 |
if(successMessage) alert(successMessage); |
|
158 |
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
|
159 |
var parts = jqXHR.responseText.split(':'); |
|
160 |
ISPConfig.loadContent(parts[1]); |
b79c5b
|
161 |
} else if (jqXHR.responseText.indexOf('LOGIN_REDIRECT:') > -1) { |
TB |
162 |
// Go to the login page |
|
163 |
document.location.href = '/index.php'; |
9021d7
|
164 |
} else { |
MC |
165 |
$('#pageContent').html(jqXHR.responseText); |
|
166 |
ISPConfig.onAfterContentLoad(target, $('#'+formname).serialize()); |
|
167 |
ISPConfig.pageFormChanged = false; |
|
168 |
} |
|
169 |
ISPConfig.hideLoadIndicator(); |
|
170 |
}, |
|
171 |
error: function(jqXHR, textStatus, errorThrown) { |
|
172 |
ISPConfig.hideLoadIndicator(); |
|
173 |
var parts = jqXHR.responseText.split(':'); |
|
174 |
ISPConfig.reportError('Ajax Request was not successful. 111'); |
|
175 |
} |
|
176 |
}); |
|
177 |
} |
|
178 |
}, |
|
179 |
|
|
180 |
submitUploadForm: function(formname, target) { |
|
181 |
var handleResponse = function(loadedFrame) { |
|
182 |
var response, responseStr = loadedFrame.contentWindow.document.body.innerHTML; |
|
183 |
|
|
184 |
try { |
|
185 |
response = JSON.parse(responseStr); |
|
186 |
} catch(e) { |
|
187 |
response = responseStr; |
|
188 |
} |
d82de9
|
189 |
var $response = $('<div></div>').html(response); |
9021d7
|
190 |
var msg = ''; |
d82de9
|
191 |
var okmsg = $response.find('#OKMsg').html(); |
9021d7
|
192 |
if(okmsg){ |
MC |
193 |
msg = '<div id="OKMsg">'+okmsg+'</div>'; |
|
194 |
} |
d82de9
|
195 |
var errormsg = $response.find('#errorMsg').html(); |
9021d7
|
196 |
if(errormsg){ |
MC |
197 |
msg = msg+'<div id="errorMsg">'+errormsg+'</div>'; |
|
198 |
} |
d82de9
|
199 |
|
MB |
200 |
var csrf_key = $response.find('input[name="_csrf_key"]').val(); |
|
201 |
var csrf_id = $response.find('input[name="_csrf_id"]').val(); |
|
202 |
|
|
203 |
msg = msg + '<input type="hidden" name="_csrf_id" value="' + csrf_id + '" /><input type="hidden" name="_csrf_key" value="' + csrf_key + '" />'; |
|
204 |
|
9021d7
|
205 |
return msg; |
MC |
206 |
|
|
207 |
}; |
|
208 |
|
|
209 |
var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000); |
d82de9
|
210 |
$('body').append('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>'); |
9021d7
|
211 |
$('#'+frame_id).load(function() { |
MC |
212 |
var msg = handleResponse(this); |
|
213 |
$('#errorMsg').remove(); |
|
214 |
$('#OKMsg').remove(); |
d82de9
|
215 |
$('input[name="_csrf_key"]').remove(); |
MB |
216 |
$('input[name="_csrf_id"]').remove(); |
9021d7
|
217 |
$('input[name="id"]').before(msg); |
MC |
218 |
$(this).remove(); |
|
219 |
}); |
d82de9
|
220 |
$('input[type="file"]').closest("form").attr({target: frame_id, action: target}).submit(); |
9021d7
|
221 |
}, |
MC |
222 |
|
|
223 |
capp: function(module, redirect) { |
|
224 |
var submitFormObj = $.ajax({ |
|
225 |
type: "GET", |
|
226 |
url: "capp.php", |
|
227 |
data: "mod="+module+((redirect != undefined) ? '&redirect='+redirect : ''), |
|
228 |
dataType: "html", |
|
229 |
beforeSend: function() { |
|
230 |
ISPConfig.showLoadIndicator(); |
|
231 |
}, |
|
232 |
success: function(data, textStatus, jqXHR) { |
|
233 |
if(jqXHR.responseText != '') { |
|
234 |
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
|
235 |
var parts = jqXHR.responseText.split(':'); |
|
236 |
ISPConfig.loadContent(parts[1]); |
|
237 |
} else if (jqXHR.responseText.indexOf('URL_REDIRECT:') > -1) { |
|
238 |
var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length); |
|
239 |
document.location.href = newUrl; |
|
240 |
} else { |
|
241 |
//alert(jqXHR.responseText); |
|
242 |
} |
|
243 |
} |
|
244 |
ISPConfig.loadMenus(); |
|
245 |
ISPConfig.hideLoadIndicator(); |
|
246 |
}, |
|
247 |
error: function() { |
|
248 |
ISPConfig.hideLoadIndicator(); |
|
249 |
ISPConfig.reportError('Ajax Request was not successful.'+module); |
|
250 |
} |
|
251 |
}); |
|
252 |
}, |
|
253 |
|
|
254 |
loadContent: function(pagename) { |
|
255 |
var params = arguments[1]; |
|
256 |
var pageContentObject2 = $.ajax({ |
|
257 |
type: "GET", |
|
258 |
url: pagename, |
|
259 |
data: (params ? params : null), |
|
260 |
dataType: "html", |
|
261 |
beforeSend: function() { |
|
262 |
ISPConfig.showLoadIndicator(); |
|
263 |
}, |
|
264 |
success: function(data, textStatus, jqXHR) { |
|
265 |
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
|
266 |
var parts = jqXHR.responseText.split(':'); |
|
267 |
ISPConfig.loadContent(parts[1]); |
|
268 |
} else if (jqXHR.responseText.indexOf('URL_REDIRECT:') > -1) { |
|
269 |
var newUrl= jqXHR.responseText.substr(jqXHR.responseText.indexOf('URL_REDIRECT:') + "URL_REDIRECT:".length); |
|
270 |
document.location.href = newUrl; |
|
271 |
} else { |
|
272 |
$('#pageContent').html(jqXHR.responseText); |
|
273 |
ISPConfig.onAfterContentLoad(pagename, (params ? params : null)); |
|
274 |
ISPConfig.pageFormChanged = false; |
|
275 |
} |
|
276 |
ISPConfig.hideLoadIndicator(); |
|
277 |
}, |
|
278 |
error: function() { |
|
279 |
ISPConfig.hideLoadIndicator(); |
|
280 |
ISPConfig.reportError('Ajax Request was not successful. 113'); |
|
281 |
} |
|
282 |
}); |
|
283 |
}, |
|
284 |
|
|
285 |
loadContentRefresh: function(pagename) { |
|
286 |
if($('#refreshinterval').val() > 0) { |
|
287 |
var pageContentObject2 = $.ajax({ |
|
288 |
type: "GET", |
|
289 |
url: pagename, |
|
290 |
data: "refresh="+document.getElementById('refreshinterval').value, |
|
291 |
dataType: "html", |
|
292 |
beforeSend: function() { |
|
293 |
ISPConfig.showLoadIndicator(); |
|
294 |
}, |
|
295 |
success: function(data, textStatus, jqXHR) { |
|
296 |
ISPConfig.hideLoadIndicator(); |
|
297 |
$('#pageContent').html(jqXHR.responseText); |
|
298 |
ISPConfig.onAfterContentLoad(pagename, "refresh="+document.getElementById('refreshinterval').value); |
|
299 |
ISPConfig.pageFormChanged = false; |
|
300 |
}, |
|
301 |
error: function() { |
|
302 |
ISPConfig.hideLoadIndicator(); |
|
303 |
ISPConfig.reportError('Ajax Request was not successful.'+pagename); |
|
304 |
} |
|
305 |
}); |
|
306 |
setTimeout( "ISPConfig.loadContentRefresh('"+pagename+"&refresh="+document.getElementById('refreshinterval').value+"')", document.getElementById('refreshinterval').value*1000*60 ); |
|
307 |
} |
|
308 |
}, |
|
309 |
|
|
310 |
loadInitContent: function() { |
b2ba0d
|
311 |
var startpage = $('#pageContent').attr('data-startpage'); |
MB |
312 |
if(!startpage) startpage = 'dashboard/dashboard.php'; |
9021d7
|
313 |
var pageContentObject = $.ajax({ |
MC |
314 |
type: "GET", |
b2ba0d
|
315 |
url: startpage, |
b79c5b
|
316 |
data: "", |
9021d7
|
317 |
dataType: "html", |
MC |
318 |
beforeSend: function() { |
|
319 |
ISPConfig.showLoadIndicator(); |
|
320 |
}, |
|
321 |
success: function(data, textStatus, jqXHR) { |
|
322 |
if(jqXHR.responseText.indexOf('HEADER_REDIRECT:') > -1) { |
|
323 |
var parts = jqXHR.responseText.split(":"); |
|
324 |
ISPConfig.loadContent(parts[1]); |
|
325 |
} else { |
|
326 |
$('#pageContent').html(jqXHR.responseText); |
b79c5b
|
327 |
ISPConfig.onAfterContentLoad('dashboard/dashboard.php', ""); |
9021d7
|
328 |
ISPConfig.pageFormChanged = false; |
MC |
329 |
} |
|
330 |
ISPConfig.hideLoadIndicator(); |
|
331 |
}, |
|
332 |
error: function() { |
|
333 |
ISPConfig.hideLoadIndicator(); |
|
334 |
ISPConfig.reportError('Ajax Request was not successful. 114'); |
|
335 |
} |
|
336 |
}); |
|
337 |
|
|
338 |
ISPConfig.loadMenus(); |
|
339 |
ISPConfig.keepalive(); |
|
340 |
setTimeout(function() { |
|
341 |
try { |
|
342 |
$('form#pageForm').find('input[name="username"]').focus(); |
|
343 |
} catch (e) { |
|
344 |
|
|
345 |
} |
|
346 |
}, 1000); |
|
347 |
}, |
|
348 |
|
|
349 |
loadMenus: function() { |
|
350 |
var sideNavObject = $.ajax({ |
|
351 |
type: "GET", |
|
352 |
url: "nav.php", |
|
353 |
data: "nav=side", |
|
354 |
dataType: "html", |
|
355 |
beforeSend: function() { |
|
356 |
ISPConfig.showLoadIndicator(); |
|
357 |
}, |
|
358 |
success: function(data, textStatus, jqXHR) { |
|
359 |
ISPConfig.hideLoadIndicator(); |
|
360 |
$('#sidebar').html(jqXHR.responseText); |
|
361 |
ISPConfig.onAfterSideNavLoaded(); |
|
362 |
ISPConfig.loadPushyMenu(); |
|
363 |
}, |
|
364 |
error: function() { |
|
365 |
ISPConfig.hideLoadIndicator(); |
|
366 |
ISPConfig.reportError('Ajax Request was not successful. 115'); |
|
367 |
} |
|
368 |
}); |
|
369 |
|
|
370 |
var topNavObject = $.ajax({ |
|
371 |
type: "GET", |
|
372 |
url: "nav.php", |
|
373 |
data: "nav=top", |
|
374 |
dataType: "html", |
|
375 |
beforeSend: function() { |
|
376 |
ISPConfig.showLoadIndicator(); |
|
377 |
}, |
|
378 |
success: function(data, textStatus, jqXHR) { |
|
379 |
ISPConfig.hideLoadIndicator(); |
|
380 |
$('#topnav-container').html(jqXHR.responseText); |
|
381 |
ISPConfig.loadPushyMenu(); |
|
382 |
}, |
|
383 |
error: function(o) { |
|
384 |
ISPConfig.hideLoadIndicator(); |
|
385 |
ISPConfig.reportError('Ajax Request was not successful. 116'); |
|
386 |
} |
|
387 |
}); |
|
388 |
}, |
|
389 |
|
|
390 |
changeTab: function(tab, target, force) { |
844564
|
391 |
if(ISPConfig.requestsRunning > 0) { |
MB |
392 |
console.log('tab change interrupted, request still running.'); |
|
393 |
return false; |
|
394 |
} |
9021d7
|
395 |
|
MC |
396 |
document.pageForm.next_tab.value = tab; |
|
397 |
|
|
398 |
var idel = $('form#pageForm').find('[name="id"]'); |
|
399 |
var id = null; |
|
400 |
if(idel.length > 0) id = idel.val(); |
|
401 |
if(ISPConfig.tabChangeDiscard == 'y' && !force) { |
|
402 |
if((idel.length < 1 || id) && (ISPConfig.pageFormChanged == false || window.confirm(ISPConfig.tabChangeDiscardTxt))) { |
|
403 |
var next_tab = tab; |
|
404 |
if(id) ISPConfig.loadContent(target, {'next_tab': next_tab, 'id': id}); |
|
405 |
else ISPConfig.loadContent(target, {'next_tab': next_tab}); |
|
406 |
} else { |
|
407 |
return false; |
|
408 |
} |
|
409 |
} else { |
|
410 |
if(id && ISPConfig.tabChangeWarning == 'y' && ISPConfig.pageFormChanged == true) { |
|
411 |
if(window.confirm(ISPConfig.tabChangeWarningTxt)) { |
|
412 |
ISPConfig.submitForm('pageForm', target); |
|
413 |
} else { |
|
414 |
var next_tab = tab; |
|
415 |
if(id) ISPConfig.loadContent(target, {'next_tab': next_tab, 'id': id}); |
|
416 |
else ISPConfig.loadContent(target, {'next_tab': next_tab}); |
|
417 |
} |
|
418 |
} else { |
|
419 |
ISPConfig.submitForm('pageForm',target); |
|
420 |
} |
|
421 |
} |
|
422 |
}, |
|
423 |
|
|
424 |
confirm_action: function(link, confirmation) { |
|
425 |
if(window.confirm(confirmation)) { |
|
426 |
ISPConfig.loadContent(link); |
|
427 |
} |
|
428 |
}, |
|
429 |
|
|
430 |
loadContentInto: function(elementid,pagename) { |
|
431 |
var pageContentObject2 = $.ajax({ |
|
432 |
type: "GET", |
|
433 |
url: pagename, |
|
434 |
dataType: "html", |
|
435 |
beforeSend: function() { |
|
436 |
}, |
|
437 |
success: function(data, textStatus, jqXHR) { |
|
438 |
$('#'+elementid).html(jqXHR.responseText); |
|
439 |
}, |
|
440 |
error: function() { |
|
441 |
ISPConfig.reportError('Ajax Request was not successful. 118'); |
|
442 |
} |
|
443 |
}); |
|
444 |
}, |
|
445 |
|
d5f2d5
|
446 |
loadOptionInto: function(elementid,pagename,callback) { |
9021d7
|
447 |
var pageContentObject2 = $.ajax({ |
MC |
448 |
type: "GET", |
|
449 |
url: pagename, |
|
450 |
dataType: "html", |
|
451 |
beforeSend: function() { |
|
452 |
}, |
|
453 |
success: function(data, textStatus, jqXHR) { |
|
454 |
var teste = jqXHR.responseText; |
|
455 |
var elemente = teste.split('#'); |
|
456 |
el=document.getElementById(elementid); |
|
457 |
el.innerHTML=''; |
|
458 |
for (var i = 0; i < elemente.length; ++i){ |
|
459 |
var foo2 = document.createElement("option"); |
|
460 |
foo2.appendChild(document.createTextNode(elemente[i])); |
|
461 |
foo2.value=elemente[i]; |
|
462 |
el.appendChild(foo2); |
|
463 |
} |
d5f2d5
|
464 |
if (typeof(callback) != 'undefined') { |
MC |
465 |
callback(elementid,pagename); |
|
466 |
} |
9021d7
|
467 |
}, |
MC |
468 |
error: function() { |
|
469 |
ISPConfig.reportError('Ajax Request was not successful. 119'); |
|
470 |
} |
|
471 |
}); |
|
472 |
}, |
|
473 |
|
|
474 |
keepalive: function() { |
|
475 |
var pageContentObject3 = $.ajax({ |
|
476 |
type: "GET", |
|
477 |
url: "keepalive.php", |
|
478 |
dataType: "html", |
|
479 |
success: function(data, textStatus, jqXHR) { |
bbb85a
|
480 |
setTimeout( function() { ISPConfig.keepalive(); }, 1000000 ); |
9021d7
|
481 |
}, |
MC |
482 |
error: function() { |
|
483 |
ISPConfig.reportError('Session expired. Please login again.'); |
|
484 |
} |
|
485 |
}); |
|
486 |
}, |
|
487 |
|
|
488 |
addAdditionalTemplate: function(){ |
|
489 |
var tpl_add = $('#template_additional').val(); |
|
490 |
var addTemplate = $('#tpl_add_select').val().split('|',2); |
|
491 |
var addTplId = addTemplate[0]; |
|
492 |
var addTplText = addTemplate[1]; |
|
493 |
if(addTplId > 0) { |
|
494 |
var newVal = tpl_add.split('/'); |
|
495 |
ISPConfig.new_tpl_add_id += 1; |
|
496 |
var delbtn = $('<a href="#"></a>').attr('class', 'button icons16 icoDelete').click(function(e) { |
|
497 |
e.preventDefault(); |
|
498 |
ISPConfig.delAdditionalTemplate($(this).parent().attr('rel')); |
|
499 |
}); |
|
500 |
newVal[newVal.length] = 'n' + ISPConfig.new_tpl_add_id + ':' + addTplId; |
|
501 |
$('<li>' + addTplText + '</li>').attr('rel', 'n' + new_tpl_add_id).append(delbtn).appendTo('#template_additional_list ul'); |
|
502 |
$('#template_additional').val(newVal.join('/')); |
|
503 |
alert('additional template ' + addTplText + ' added to customer'); |
|
504 |
} else { |
|
505 |
alert('no additional template selcted'); |
|
506 |
} |
|
507 |
}, |
|
508 |
|
|
509 |
delAdditionalTemplate: function(tpl_id) { |
|
510 |
var tpl_add = $('#template_additional').val(); |
|
511 |
if(tpl_id) { |
|
512 |
// new style |
|
513 |
var $el = $('#template_additional_list ul').find('li[rel="' + tpl_id + '"]').eq(0); // only the first |
|
514 |
var addTplText = $el.text(); |
|
515 |
$el.remove(); |
|
516 |
|
|
517 |
var oldVal = tpl_add.split('/'); |
|
518 |
var newVal = new Array(); |
|
519 |
for(var i = 0; i < oldVal.length; i++) { |
|
520 |
var tmp = oldVal[i].split(':', 2); |
|
521 |
if(tmp.length == 2 && tmp[0] == tpl_id) continue; |
|
522 |
newVal[newVal.length] = oldVal[i]; |
|
523 |
} |
|
524 |
$('#template_additional').val(newVal.join('/')); |
|
525 |
alert('additional template ' + addTplText + ' deleted from customer'); |
|
526 |
} else if(tpl_add != '') { |
|
527 |
// old style |
|
528 |
var addTemplate = document.getElementById('tpl_add_select').value.split('|',2); |
|
529 |
var addTplId = addTemplate[0]; |
|
530 |
var addTplText = addTemplate[1]; |
|
531 |
|
|
532 |
$('#template_additional_list ul').find('li:not([rel])').each(function() { |
|
533 |
var text = $(this).text(); |
|
534 |
if(text == addTplText) { |
|
535 |
$(this).remove(); |
|
536 |
return false; |
|
537 |
} |
|
538 |
return this; |
|
539 |
}); |
|
540 |
|
|
541 |
var newVal = tpl_add; |
|
542 |
var repl = new RegExp('(^|\/)' + addTplId + '(\/|$)'); |
|
543 |
newVal = newVal.replace(repl, ''); |
|
544 |
newVal = newVal.replace('//', '/'); |
|
545 |
$('#template_additional').val(newVal); |
|
546 |
alert('additional template ' + addTplText + ' deleted from customer'); |
|
547 |
} else { |
|
548 |
alert('no additional template selcted'); |
|
549 |
} |
|
550 |
} |
|
551 |
}; |
|
552 |
|
|
553 |
|
|
554 |
$(document).on("change", function(event) { |
|
555 |
var elName = event.target.localName; |
|
556 |
if ($("#pageForm .table #Filter").length > 0 && elName == 'select') { |
|
557 |
event.preventDefault(); |
|
558 |
$("#pageForm .table #Filter").trigger('click'); |
|
559 |
} |
|
560 |
if(elName == 'select' || elName == 'input' || elName == 'textarea') { |
|
561 |
if($(event.target).hasClass('no-page-form-change') == false) { |
|
562 |
// set marker that something was changed |
|
563 |
ISPConfig.pageFormChanged = true; |
|
564 |
} |
|
565 |
} |
|
566 |
}); |
|
567 |
|
768b3f
|
568 |
var $page = $('html, body'); |
MB |
569 |
|
9021d7
|
570 |
$(document).on('click', 'a[data-load-content],button[data-load-content]', function(e) { |
37f2c2
|
571 |
e.preventDefault(); |
844564
|
572 |
if(ISPConfig.requestsRunning > 0) { |
MB |
573 |
console.log('preventing click because there is still a request running.'); |
|
574 |
return; |
|
575 |
} |
|
576 |
|
768b3f
|
577 |
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
MB |
578 |
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
37f2c2
|
579 |
|
9021d7
|
580 |
var content_to_load = $(this).attr('data-load-content'); |
MC |
581 |
if(!content_to_load) return this; |
|
582 |
|
|
583 |
ISPConfig.loadContent(content_to_load); |
|
584 |
}); |
|
585 |
|
|
586 |
$(document).on('click', 'a[data-capp],button[data-capp]', function(e) { |
37f2c2
|
587 |
e.preventDefault(); |
844564
|
588 |
if(ISPConfig.requestsRunning > 0) { |
MB |
589 |
console.log('preventing click because there is still a request running.'); |
|
590 |
return; |
|
591 |
} |
|
592 |
|
768b3f
|
593 |
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
MB |
594 |
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
37f2c2
|
595 |
|
9021d7
|
596 |
var content_to_load = $(this).attr('data-capp'); |
MC |
597 |
if(!content_to_load) return this; |
|
598 |
|
|
599 |
ISPConfig.capp(content_to_load); |
|
600 |
}); |
|
601 |
|
|
602 |
$(document).on('click', 'a[data-submit-form],button[data-submit-form]', function(e) { |
37f2c2
|
603 |
e.preventDefault(); |
844564
|
604 |
if(ISPConfig.requestsRunning > 0) { |
MB |
605 |
console.log('preventing click because there is still a request running.'); |
|
606 |
return; |
|
607 |
} |
|
608 |
|
768b3f
|
609 |
$page.on('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); |
MB |
610 |
$page.animate({scrollTop: 0}, 1000, function() { $page.off('scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove', function() { $page.stop(); }); }); |
9021d7
|
611 |
|
MC |
612 |
var $el = $(this); |
|
613 |
var act = $el.attr('data-form-action'); |
|
614 |
var form = $el.attr('data-submit-form'); |
|
615 |
|
|
616 |
if($el.attr('data-form-upload') == 'true') ISPConfig.submitUploadForm(form, act); |
|
617 |
else ISPConfig.submitForm(form, act); |
|
618 |
}); |
|
619 |
|
|
620 |
$(document).bind("keypress", function(event) { |
|
621 |
//Use $ submit with keypress Enter in panel filterbar |
|
622 |
if (event.which == '13' && $("#pageForm .table #Filter").length > 0 && $(event.target).hasClass('ui-autocomplete-input') == false ) { |
|
623 |
event.preventDefault(); |
|
624 |
$("#pageForm .table #Filter").trigger('click'); |
|
625 |
} |
|
626 |
//Use $ submit with keypress Enter in forms |
eb610b
|
627 |
if (event.which == '13' && $(".tab-content button.formbutton-success").length > 0 && event.target.localName != 'textarea' && $(event.target).is(':input')) { |
9021d7
|
628 |
event.preventDefault(); |
eb610b
|
629 |
$(".tab-content button.formbutton-success").not("[disabled='disabled']").trigger('click'); |
9021d7
|
630 |
} |
MC |
631 |
}); |
|
632 |
|
|
633 |
$(document).on('click', 'th[data-column]', function(e) { |
|
634 |
var $self = $(this); |
|
635 |
var column = $self.attr('data-column'); |
|
636 |
if(!column) return this; |
|
637 |
|
|
638 |
if($("#pageForm .table #Filter").length > 0 && $self.attr('data-sortable') != 'false') { |
|
639 |
var $el = $('#Filter'); |
|
640 |
var act = $el.attr('data-form-action'); |
|
641 |
var form = $el.attr('data-submit-form'); |
|
642 |
|
d76e2d
|
643 |
var dir = $self.attr('data-ordered'); |
MC |
644 |
|
024e13
|
645 |
var separator = '?'; |
MC |
646 |
if(act.indexOf("?") >= 0){ |
|
647 |
separator = '&'; |
|
648 |
} |
|
649 |
act = act + separator + 'orderby=' + column; |
9021d7
|
650 |
ISPConfig.submitForm(form, act); |
d76e2d
|
651 |
|
MC |
652 |
$(document).ajaxComplete(function() { |
|
653 |
var $self = $('#pageForm .table th[data-column="' + column + '"]'); |
|
654 |
$self.parent().children('th[data-column]').removeAttr('data-ordered'); |
|
655 |
if(dir && dir == 'asc') $self.attr('data-ordered', 'desc'); |
|
656 |
else $self.attr('data-ordered', 'asc'); |
|
657 |
}); |
|
658 |
|
9021d7
|
659 |
} |
MC |
660 |
}); |
|
661 |
|
|
662 |
$(document).on("click", ".addPlaceholder", function(){ |
|
663 |
var placeholderText = $(this).text(); |
|
664 |
var template = $(this).siblings(':input'); |
|
665 |
template.insertAtCaret(placeholderText); |
|
666 |
}); |
|
667 |
|
|
668 |
$(document).on("click", ".addPlaceholderContent", function(){ |
|
669 |
var placeholderContentText = $(this).find('.addPlaceholderContent').text(); |
|
670 |
var template2 = $(this).siblings(':input'); |
|
671 |
template2.insertAtCaret(placeholderContentText); |
|
672 |
}); |
|
673 |
|
af56b4
|
674 |
$(document).on("click", "[data-check-fields] > input[type='checkbox']", function() { |
MB |
675 |
if($(this).is(':checked')) { |
|
676 |
var flds = $(this).parent().attr('data-check-fields'); |
|
677 |
var tmp = flds.split(/,/); |
|
678 |
for(var i = 0; i < tmp.length; i++) { |
|
679 |
var fname = tmp[i]; |
|
680 |
$('input[type="checkbox"][name="' + fname + '"]').prop('checked', true); |
|
681 |
} |
|
682 |
} |
|
683 |
}); |
|
684 |
|
|
685 |
$(document).on("click", "[data-uncheck-fields] > input[type='checkbox']", function() { |
|
686 |
if($(this).is(':checked') == false) { |
|
687 |
var flds = $(this).parent().attr('data-uncheck-fields'); |
|
688 |
var tmp = flds.split(/,/); |
|
689 |
for(var i = 0; i < tmp.length; i++) { |
|
690 |
var fname = tmp[i]; |
|
691 |
$('input[type="checkbox"][name="' + fname + '"]').prop('checked', false); |
|
692 |
} |
|
693 |
} |
|
694 |
}); |
|
695 |
|
|
696 |
|
01cec5
|
697 |
$(document).on('ready', function () { |
9021d7
|
698 |
$.fn.extend({ |
MC |
699 |
insertAtCaret: function(myValue){ |
|
700 |
return this.each(function(i) { |
|
701 |
if (document.selection) { |
|
702 |
//For browsers like Internet Explorer |
|
703 |
this.focus(); |
|
704 |
sel = document.selection.createRange(); |
|
705 |
sel.text = myValue; |
|
706 |
this.focus(); |
|
707 |
} else if (this.selectionStart || this.selectionStart == '0') { |
|
708 |
//For browsers like Firefox and Webkit based |
|
709 |
var startPos = this.selectionStart; |
|
710 |
var endPos = this.selectionEnd; |
|
711 |
var scrollTop = this.scrollTop; |
|
712 |
this.value = this.value.substring(0, startPos)+myValue+this.value.substring(endPos,this.value.length); |
|
713 |
this.focus(); |
|
714 |
this.selectionStart = startPos + myValue.length; |
|
715 |
this.selectionEnd = startPos + myValue.length; |
|
716 |
this.scrollTop = scrollTop; |
|
717 |
} else { |
|
718 |
this.value += myValue; |
|
719 |
this.focus(); |
|
720 |
} |
|
721 |
}) |
|
722 |
} |
|
723 |
}); |
|
724 |
|
|
725 |
// Animierter Ladefortschritt |
|
726 |
$('.progress .progress-bar').css('width', function () { |
|
727 |
return $(this).attr('aria-valuenow') + '%'; |
|
728 |
}); |
|
729 |
|
|
730 |
ISPConfig.loadInitContent(); |
|
731 |
|
|
732 |
$('#searchform').submit(function(e) { |
|
733 |
e.preventDefault(); |
|
734 |
}); |
|
735 |
|
|
736 |
$("#pageForm").submit(function(e){ |
|
737 |
//Prevent form submit: e.preventDefault() in lists |
|
738 |
if ($("#pageForm .table #Filter").length > 0) { |
|
739 |
e.preventDefault(); |
|
740 |
} |
|
741 |
}); |
a6e530
|
742 |
|
MB |
743 |
$.fn.setCursorPosition = function(pos) { |
|
744 |
var self = $(this).get(0); |
|
745 |
if(self.setSelectionRange) { |
|
746 |
self.setSelectionRange(pos, pos); |
|
747 |
} else if(self.createTextRange) { |
|
748 |
var range = self.createTextRange(); |
|
749 |
range.collapse(true); |
|
750 |
if(pos < 0) { |
|
751 |
pos = $(this).val().length + pos; |
|
752 |
} |
|
753 |
range.moveEnd('character', pos); |
|
754 |
range.moveStart('character', pos); |
|
755 |
range.select(); |
|
756 |
} |
|
757 |
}; |
|
758 |
|
|
759 |
$.fn.getCursorPosition = function() { |
|
760 |
var iCaretPos = 0; |
|
761 |
var self = $(this).get(0); |
|
762 |
|
|
763 |
if(typeof self.selectionStart === 'number') { |
|
764 |
iCaretPos = self.selectionDirection == 'backward' ? self.selectionStart : self.selectionEnd; |
|
765 |
} else if(document.selection) { |
|
766 |
this.focus(); |
|
767 |
var oSel = document.selection.createRange(); |
|
768 |
oSel.moveStart('character', -self.value.length); |
|
769 |
iCaretPos = oSel.text.length; |
|
770 |
} |
|
771 |
return iCaretPos; |
|
772 |
}; |
01cec5
|
773 |
}); |