js chrome und ie
This commit is contained in:
parent
6eadfb2c25
commit
505b15b5cd
|
@ -2,129 +2,143 @@
|
||||||
* To change this template, choose Tools | Templates
|
* To change this template, choose Tools | Templates
|
||||||
* and open the template in the editor.
|
* and open the template in the editor.
|
||||||
*/
|
*/
|
||||||
var global_load = null;
|
var global_load = null;
|
||||||
!function($) {
|
!function($) {
|
||||||
$(function() {
|
$(function() {
|
||||||
$body = $("body");
|
$body = $("body");
|
||||||
$(document).on({
|
$(document).on({
|
||||||
ajaxStart: function() { $body.addClass("loading"); },
|
ajaxStart: function() {
|
||||||
ajaxStop: function() { $body.removeClass("loading"); }
|
$body.addClass("loading");
|
||||||
});
|
},
|
||||||
$(window).bind('popstate',function(evt){
|
ajaxStop: function() {
|
||||||
console.log(evt.target.pageurl);
|
$body.removeClass("loading");
|
||||||
console.log(evt);
|
|
||||||
if(evt.originalEvent.state !== null) {
|
|
||||||
load(location.href,{'history':false},false);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
$("#popup").modal({'remote':false,'show':false});
|
$(window).bind('popstate', function(evt) {
|
||||||
$("#popup").on('show.bs.modal',function(e){
|
console.log(evt.target.pageurl);
|
||||||
$.ajax({url:$(e.relatedTarget).attr("href"),success:function(data){
|
console.log(evt);
|
||||||
$("#popup .modal-title").html($(e.relatedTarget).attr("title"));
|
if (evt.originalEvent.state !== null) {
|
||||||
$("#popup .modal-body").html($("#container div.box",data).html());
|
load(location.href, {'history': false}, false);
|
||||||
} ,error:function(data){}});
|
}
|
||||||
});
|
});
|
||||||
function stopLoad(e){
|
$("#popup").modal({'remote': false, 'show': false});
|
||||||
|
$("#popup").on('show.bs.modal', function(e) {
|
||||||
|
$.ajax({url: $(e.relatedTarget).attr("href"), success: function(data) {
|
||||||
|
$("#popup .modal-title").html($(e.relatedTarget).attr("title"));
|
||||||
|
$("#popup .modal-body").html($("#container div.box", data).html());
|
||||||
|
}, error: function(data) {
|
||||||
|
}});
|
||||||
|
});
|
||||||
|
function stopLoad(e) {
|
||||||
if (!e)
|
if (!e)
|
||||||
e = window.event;
|
e = window.event;
|
||||||
if (e.preventDefault)
|
if (e.preventDefault)
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
if (e.stopPropagation) {
|
if (e.stopPropagation) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
}else{
|
} else {
|
||||||
e.cancelBubble = true;
|
e.cancelBubble = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function event(where){
|
function event(where) {
|
||||||
/* Hotfix Ticket: 215*/
|
/* Hotfix Ticket: 215*/
|
||||||
$(where+' img').each(function(){ $(this).attr('src',$(this).attr('src')+ '?' + (new Date()).getTime()); });
|
$(where + ' img').each(function() {
|
||||||
|
$(this).attr('src', $(this).attr('src') + '?' + (new Date()).getTime());
|
||||||
|
});
|
||||||
|
|
||||||
$("#alert .alert").alert();
|
$("#alert .alert").alert();
|
||||||
$(where+' textarea').wysihtml5();
|
$(where + ' textarea').wysihtml5();
|
||||||
$(where+' select').each(function(){
|
$(where + ' select').each(function() {
|
||||||
$(this).select2({allowClear: true});
|
$(this).select2({allowClear: true});
|
||||||
});
|
});
|
||||||
$(where+' .dropdown-toggle').dropdown();
|
$(where + ' .dropdown-toggle').dropdown();
|
||||||
$(where+" a").tooltip();;
|
$(where + " a").tooltip();
|
||||||
$(where+" a").each(function(that){
|
;
|
||||||
if($(this).attr("rel")!=="external" && $(this).attr("ref")!=="eventOff" && !$(this).parents('ul').hasClass("wysihtml5-toolbar") && !$(this).hasClass(".select2-choice") && !$(this).parents('form').hasClass('tableForm'))
|
$(where + " a").each(function(that) {
|
||||||
$(this).click(function(e){
|
if ($(this).attr("rel") !== "external" && $(this).attr("ref") !== "eventOff" && !$(this).parents('ul').hasClass("wysihtml5-toolbar") && !$(this).hasClass(".select2-choice") && !$(this).parents('form').hasClass('tableForm'))
|
||||||
load($(this).attr('href'),{},($(this).attr('rel')=="tab"));
|
$(this).click(function(e) {
|
||||||
|
stopLoad(e);
|
||||||
|
load($(this).attr('href'), {}, ($(this).attr('rel') == "tab"));
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(where+" form").submit(function(e){
|
$(where + " form").submit(function(e) {
|
||||||
if(!$(this).hasClass("hide-form") && $(this).attr('enctype')!='multipart/form-data' ){
|
if (!$(this).hasClass("hide-form") && $(this).attr('enctype') != 'multipart/form-data') {
|
||||||
$(":input[ name *= '_wysihtml5_mod' ]",this).remove();
|
stopLoad(e);
|
||||||
|
$(":input[ name *= '_wysihtml5_mod' ]", this).remove();
|
||||||
//stopLoad(e);
|
//stopLoad(e);
|
||||||
if($(this).attr("back"))
|
if ($(this).attr("back"))
|
||||||
back=window.location.href;
|
back = window.location.href;
|
||||||
else
|
else
|
||||||
back=null;
|
back = null;
|
||||||
load($(this).attr("action"),{data:$(this).serialize(), type:$(this).attr("method"),back:back},($(this).attr('rel')=="tab"));
|
load($(this).attr("action"), {data: $(this).serialize(), type: $(this).attr("method"), back: back}, ($(this).attr('rel') == "tab"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(where+" form[ enctype *= 'multipart/form-data' ]").each(function(evt){
|
$(where + " form[ enctype *= 'multipart/form-data' ]").each(function(evt) {
|
||||||
|
stopLoad(evt);
|
||||||
if (!$('#fileUpload').length)
|
if (!$('#fileUpload').length)
|
||||||
$('body').append('<iframe id="fileUpload" name="fileUpload" style="display:none" />');
|
$('body').append('<iframe id="fileUpload" name="fileUpload" style="display:none" />');
|
||||||
$(this).attr('target','fileUpload');
|
$(this).attr('target', 'fileUpload');
|
||||||
$(":input[ name *= '_wysihtml5_mod' ]",this).remove();
|
$(":input[ name *= '_wysihtml5_mod' ]", this).remove();
|
||||||
$(this).submit(function(){
|
$(this).submit(function() {
|
||||||
frame = $('#fileUpload').load(function(){
|
frame = $('#fileUpload').load(function() {
|
||||||
setContent(frame.contents().find('body').html());
|
setContent(frame.contents().find('body').html());
|
||||||
frame.unbind('load');
|
frame.unbind('load');
|
||||||
setTimeout(function (){frame.html('');}, 1);
|
setTimeout(function() {
|
||||||
|
frame.html('');
|
||||||
|
}, 1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(where+" form.tableForm tbody").each(function(evt){
|
$(where + " form.tableForm tbody").each(function(evt) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var newRow = $(".new",this).html();
|
var newRow = $(".new", this).html();
|
||||||
$(that).change(function(){
|
$(that).change(function(e) {
|
||||||
|
stopLoad(e);
|
||||||
tosave = true;
|
tosave = true;
|
||||||
$("tr",that).each(function(evt){
|
$("tr", that).each(function(evt) {
|
||||||
see = true;
|
see = true;
|
||||||
$(":input:not([ type = 'hidden' ] )",this).each(function(){
|
$(":input:not([ type = 'hidden' ] )", this).each(function() {
|
||||||
if(see){
|
if (see) {
|
||||||
see = $(this).val()=='';
|
see = $(this).val() == '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(see && $(this).attr("data")=="set"){
|
if (see && $(this).attr("data") == "set") {
|
||||||
$(this).attr("data","");
|
$(this).attr("data", "");
|
||||||
$(this).remove();
|
$(this).remove();
|
||||||
}
|
}
|
||||||
if(!see && $(this).attr("data")!="set"){
|
if (!see && $(this).attr("data") != "set") {
|
||||||
$(this).attr("data","set");
|
$(this).attr("data", "set");
|
||||||
$("tr",that).removeClass("new");
|
$("tr", that).removeClass("new");
|
||||||
$(that).append("<tr class=\"new\">"+newRow+"</tr>");
|
$(that).append("<tr class=\"new\">" + newRow + "</tr>");
|
||||||
evet();
|
evet();
|
||||||
}
|
}
|
||||||
|
|
||||||
save = true;
|
save = true;
|
||||||
that2=this;
|
that2 = this;
|
||||||
$(":input:not([ type = 'hidden' ] )",this).each(function(){
|
$(":input:not([ type = 'hidden' ] )", this).each(function() {
|
||||||
if(save && !$(that2).hasClass("new")){
|
if (save && !$(that2).hasClass("new")) {
|
||||||
save = $(this).val()!='';
|
save = $(this).val() != '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(tosave && !$(that2).hasClass("new")){
|
if (tosave && !$(that2).hasClass("new")) {
|
||||||
tosave = save;
|
tosave = save;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if(tosave)
|
if (tosave)
|
||||||
//console.log("sendTosave");
|
//console.log("sendTosave");
|
||||||
saveForm(that);
|
saveForm(that);
|
||||||
});
|
});
|
||||||
//ZUOFT WIRD GESPEICHERT
|
//ZUOFT WIRD GESPEICHERT
|
||||||
|
|
||||||
function evet(){
|
function evet() {
|
||||||
$("tr:not(.new)",that).each(function(){
|
$("tr:not(.new)", that).each(function() {
|
||||||
var that2 = this;
|
var that2 = this;
|
||||||
$(".btn-del",this).unbind("click").click(function(evt){
|
$(".btn-del", this).unbind("click").click(function(evt) {
|
||||||
$(that2).remove();
|
$(that2).remove();
|
||||||
saveForm(that);
|
saveForm(that);
|
||||||
});
|
});
|
||||||
|
@ -133,41 +147,44 @@
|
||||||
evet();
|
evet();
|
||||||
});
|
});
|
||||||
|
|
||||||
function saveForm(here,back){
|
function saveForm(here, back) {
|
||||||
i = 0;
|
i = 0;
|
||||||
$(":input[ name *= '_wysihtml5_mod' ]",$(here).parents('form')).remove();
|
$(":input[ name *= '_wysihtml5_mod' ]", $(here).parents('form')).remove();
|
||||||
//$(":input[ class *= 'select2-focusser' ]",$(here).parents('form')).remove();
|
//$(":input[ class *= 'select2-focusser' ]",$(here).parents('form')).remove();
|
||||||
$("tbody tr.new",$(here).parents('form')).remove();
|
$("tbody tr.new", $(here).parents('form')).remove();
|
||||||
$("tbody tr",$(here).parents('form')).each(function(){
|
$("tbody tr", $(here).parents('form')).each(function() {
|
||||||
$(":input[name]",this).each(function(){
|
$(":input[name]", this).each(function() {
|
||||||
str = $(this).attr("name").replace(/data\[(.*?)\]\[.*?\]\[(.+)\]/g,'data[$1]['+i+'][$2]');
|
str = $(this).attr("name").replace(/data\[(.*?)\]\[.*?\]\[(.+)\]/g, 'data[$1][' + i + '][$2]');
|
||||||
$(this).attr("name",str);
|
$(this).attr("name", str);
|
||||||
});
|
});
|
||||||
i++;
|
i++;
|
||||||
});
|
});
|
||||||
load($(here).parents("form").attr("action"),{back:back,data:$(here).parents("form").serialize(), type:'POST'},false);
|
load($(here).parents("form").attr("action"), {back: back, data: $(here).parents("form").serialize(), type: 'POST'}, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$($(where+" form.tableForm .label.edit").parents('form.tableForm a')).click(function(){saveForm('form.tableForm tbody',$(this).attr('href'));return false;});
|
$($(where + " form.tableForm .label.edit").parents('form.tableForm a')).click(function() {
|
||||||
|
saveForm('form.tableForm tbody', $(this).attr('href'));
|
||||||
|
return false;
|
||||||
|
});
|
||||||
//$(where+" form label.has-error").parent(".form-group").addClass("has-error")
|
//$(where+" form label.has-error").parent(".form-group").addClass("has-error")
|
||||||
}
|
}
|
||||||
function setContent(data,back,tab,backignore){
|
function setContent(data, back, tab, backignore) {
|
||||||
alert = data.split('<!-- alert -->')[1].split('<!-- /alert -->')[0];
|
alert = data.split('<!-- alert -->')[1].split('<!-- /alert -->')[0];
|
||||||
$('#alert').removeClass('old');
|
$('#alert').removeClass('old');
|
||||||
if( alert.trim().length > 0){
|
if (alert.trim().length > 0) {
|
||||||
$('#alert').html(alert);
|
$('#alert').html(alert);
|
||||||
}else if(!backignore){
|
} else if (!backignore) {
|
||||||
$('#alert').addClass('old');
|
$('#alert').addClass('old');
|
||||||
}
|
}
|
||||||
|
|
||||||
if(back){
|
if (back) {
|
||||||
load(back,{'backignore':true},tab);
|
load(back, {'backignore': true}, tab);
|
||||||
}else if(tab){
|
} else if (tab) {
|
||||||
navbar = data.split('<!-- tab -->')[1].split('<!-- /tab -->')[0];
|
navbar = data.split('<!-- tab -->')[1].split('<!-- /tab -->')[0];
|
||||||
$('#tab').html(navbar);
|
$('#tab').html(navbar);
|
||||||
event("#tab");
|
event("#tab");
|
||||||
}else{
|
} else {
|
||||||
navbar = data.split('<!-- navbar -->')[1].split('<!-- /navbar -->')[0];
|
navbar = data.split('<!-- navbar -->')[1].split('<!-- /navbar -->')[0];
|
||||||
$('#navbar').html(navbar);
|
$('#navbar').html(navbar);
|
||||||
event("#navbar");
|
event("#navbar");
|
||||||
|
@ -184,13 +201,13 @@
|
||||||
$('#barleft').html(barleft);
|
$('#barleft').html(barleft);
|
||||||
event("#barleft");
|
event("#barleft");
|
||||||
}
|
}
|
||||||
if(!back){
|
if (!back) {
|
||||||
navbar = data.split('<!-- extraScript -->')[1].split('<!-- /extraScript -->')[0];
|
navbar = data.split('<!-- extraScript -->')[1].split('<!-- /extraScript -->')[0];
|
||||||
eval($(navbar).html());
|
eval($(navbar).html());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function setContentError(data,back,tab){
|
function setContentError(data, back, tab) {
|
||||||
alert = "<div class=\"alert alert-danger\">"+data.statusText+
|
alert = "<div class=\"alert alert-danger\">" + data.statusText +
|
||||||
"<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>"
|
"<button type=\"button\" class=\"close\" data-dismiss=\"alert\">×</button>"
|
||||||
+ "</div>";
|
+ "</div>";
|
||||||
$('#alert').removeClass('old');
|
$('#alert').removeClass('old');
|
||||||
|
@ -199,21 +216,21 @@
|
||||||
$('#container').html(data.responseText);
|
$('#container').html(data.responseText);
|
||||||
event("#container");
|
event("#container");
|
||||||
}
|
}
|
||||||
function load(pageurl,conf,tab){
|
function load(pageurl, conf, tab) {
|
||||||
data = {};
|
data = {};
|
||||||
typemethode = "GET";
|
typemethode = "GET";
|
||||||
back = false;
|
back = false;
|
||||||
backignore = false;
|
backignore = false;
|
||||||
history = true;
|
history = true;
|
||||||
if(conf['data'])
|
if (conf['data'])
|
||||||
data = conf['data'];
|
data = conf['data'];
|
||||||
if(conf['type'])
|
if (conf['type'])
|
||||||
typemethode = conf['type'];
|
typemethode = conf['type'];
|
||||||
if(conf['back'] && conf['back'].indexOf("logout")== -1 && conf['back'].indexOf("login")== -1 )
|
if (conf['back'] && conf['back'].indexOf("logout") == -1 && conf['back'].indexOf("login") == -1)
|
||||||
back = conf['back'];
|
back = conf['back'];
|
||||||
if(conf['backignore'])
|
if (conf['backignore'])
|
||||||
backignore = conf['backignore'];
|
backignore = conf['backignore'];
|
||||||
if(conf['history'])
|
if (conf['history'])
|
||||||
history = conf['history'];
|
history = conf['history'];
|
||||||
|
|
||||||
//e.preventDefault();
|
//e.preventDefault();
|
||||||
|
@ -221,11 +238,16 @@
|
||||||
if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content;
|
if uncomment the above line, html5 nonsupported browers won't change the url but will display the ajax content;
|
||||||
if commented, html5 nonsupported browers will reload the page to the specified link.
|
if commented, html5 nonsupported browers will reload the page to the specified link.
|
||||||
*/
|
*/
|
||||||
$.ajax({url:pageurl,data:data,type:typemethode,success:function(data){setContent(data,back,tab,backignore);} ,error:function(data){setContentError(data,back,tab);}});
|
$.ajax({url: pageurl, data: data, type: typemethode, success: function(data) {
|
||||||
if(history && pageurl!=window.location){
|
setContent(data, back, tab, backignore);
|
||||||
window.history.pushState({path:pageurl},'',pageurl);
|
}, error: function(data) {
|
||||||
|
setContentError(data, back, tab);
|
||||||
|
}});
|
||||||
|
if (history && pageurl != window.location) {
|
||||||
|
window.history.pushState({path: pageurl}, '', pageurl);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
;
|
||||||
event("");
|
event("");
|
||||||
global_load = load;
|
global_load = load;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue