BUGFIX Making HTML5 History support optional, so we can disable HTML4 hash change fallback

This commit is contained in:
Ingo Schommer 2011-12-14 16:13:13 +01:00
parent 1b7c33574a
commit 9c6cbf7012
4 changed files with 20 additions and 8 deletions

View File

@ -31,7 +31,12 @@
var url = $(node).find('a:first').attr('href');
if(url && url != '#') {
window.History.pushState({}, '', url);
if($(node).find('a:first').is(':internal')) url = $('base').attr('href') + url;
if(window.History.enabled) {
window.History.pushState({}, '', url);
} else {
window.location = url;
}
} else {
self.removeForm();
}

View File

@ -98,13 +98,18 @@
var item = this.getMenuItem();
item.select();
var url = this.attr('href');
if(this.is(':internal')) url = $('base').attr('href') + url;
var children = item.find('li');
if(children.length) {
children.first().find('a').click();
} else {
} else if(window.History.enabled) {
// Active menu item is set based on X-Controller ajax header,
// which matches one class on the menu
window.History.pushState({}, '', this.attr('href'));
window.History.pushState({}, '', url);
} else {
window.location = url;
}
}
});

View File

@ -99,9 +99,9 @@
var id = $(doc).find('meta[name=x-page-id]').attr('content'),
editLink = $(doc).find('meta[name=x-cms-edit-link]').attr('content'),
contentPanel = $('.cms-content');
// TODO Remove hardcoding
if(id && contentPanel.find(':input[name=ID]').val() != id) {
window.History.pushState({}, '', editLink);
// Ignore behaviour without history support (as we need ajax loading for the new form to load in the background)
if(window.History.enabled) window.History.pushState({}, '', editLink);
}
},

View File

@ -137,8 +137,10 @@
var firstLink = this.find('a[href]');
if(!firstLink) return;
window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href'));
return false;
if(window.History.enabled) {
window.History.pushState({selector: '.cms-content-fields form:first'}, '', firstLink.attr('href'));
return false;
}
}
});