mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Making HTML5 History support optional, so we can disable HTML4 hash change fallback
This commit is contained in:
parent
1b7c33574a
commit
9c6cbf7012
@ -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();
|
||||
}
|
||||
|
@ -97,20 +97,25 @@
|
||||
// Expand this, and collapse all other items
|
||||
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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
// Internal Helper
|
||||
$.expr[':'].internal = function(obj){return obj.href.match(/^mailto\:/) || (obj.hostname == location.hostname);};
|
||||
$.expr[':'].external = function(obj){return !$(obj).is(':internal')};
|
||||
|
@ -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);
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user