| | |
| | | } 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) { |
| | |
| | | }, |
| | | |
| | | 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() { |
| | |
| | | }); |
| | | |
| | | $(document).on('click', 'a[data-load-content],button[data-load-content]', function(e) { |
| | | //e.preventDefault(); |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: 0}, 1000); |
| | | |
| | | 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(); |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: 0}, 1000); |
| | | |
| | | 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(); |
| | | e.preventDefault(); |
| | | $('html, body').animate({scrollTop: 0}, 1000); |
| | | |
| | | 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; |
| | | }; |
| | | }); |