js chrome und ie

This commit is contained in:
Martin Müller 2014-05-14 00:06:53 +02:00
parent 6eadfb2c25
commit 505b15b5cd
1 changed files with 226 additions and 204 deletions

View File

@ -7,8 +7,12 @@
$(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");
},
ajaxStop: function() {
$body.removeClass("loading");
}
}); });
$(window).bind('popstate', function(evt) { $(window).bind('popstate', function(evt) {
console.log(evt.target.pageurl); console.log(evt.target.pageurl);
@ -22,7 +26,8 @@
$.ajax({url: $(e.relatedTarget).attr("href"), success: function(data) { $.ajax({url: $(e.relatedTarget).attr("href"), success: function(data) {
$("#popup .modal-title").html($(e.relatedTarget).attr("title")); $("#popup .modal-title").html($(e.relatedTarget).attr("title"));
$("#popup .modal-body").html($("#container div.box", data).html()); $("#popup .modal-body").html($("#container div.box", data).html());
} ,error:function(data){}}); }, error: function(data) {
}});
}); });
function stopLoad(e) { function stopLoad(e) {
if (!e) if (!e)
@ -37,7 +42,9 @@
} }
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();
@ -45,10 +52,12 @@
$(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) { $(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')) if ($(this).attr("rel") !== "external" && $(this).attr("ref") !== "eventOff" && !$(this).parents('ul').hasClass("wysihtml5-toolbar") && !$(this).hasClass(".select2-choice") && !$(this).parents('form').hasClass('tableForm'))
$(this).click(function(e) { $(this).click(function(e) {
stopLoad(e);
load($(this).attr('href'), {}, ($(this).attr('rel') == "tab")); load($(this).attr('href'), {}, ($(this).attr('rel') == "tab"));
return false; return false;
}); });
@ -56,6 +65,7 @@
$(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') {
stopLoad(e);
$(":input[ name *= '_wysihtml5_mod' ]", this).remove(); $(":input[ name *= '_wysihtml5_mod' ]", this).remove();
//stopLoad(e); //stopLoad(e);
if ($(this).attr("back")) if ($(this).attr("back"))
@ -68,6 +78,7 @@
}); });
$(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');
@ -76,7 +87,9 @@
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);
}); });
}); });
}); });
@ -84,7 +97,8 @@
$(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;
@ -149,7 +163,10 @@
} }
$($(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) {
@ -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) {
setContent(data, back, tab, backignore);
}, error: function(data) {
setContentError(data, back, tab);
}});
if (history && pageurl != window.location) { if (history && pageurl != window.location) {
window.history.pushState({path: pageurl}, '', pageurl); window.history.pushState({path: pageurl}, '', pageurl);
} }
}; }
;
event(""); event("");
global_load = load; global_load = load;
}); });