silverstripe-framework/javascript/TabSet.js
Ingo Schommer a7efc76c36 Removed usage of deprecated jQuery UI 1.9 features
See http://jqueryui.com/upgrade-guide/1.9 for details.
Fixes fade effect on changing toplevel tabs
(semantics for "show" option in $.tabs() changed).
2012-11-06 22:53:34 +01:00

35 lines
871 B
JavaScript

(function($){
$.entwine('ss', function($){
/**
* Lightweight wrapper around jQuery UI tabs.
*/
$('.ss-tabset').entwine({
onadd: function() {
// Can't name redraw() as it clashes with other CMS entwine classes
this.redrawTabs();
this._super();
},
onremove: function() {
if(this.data('uiTabs')) this.tabs('destroy');
this._super();
},
redrawTabs: function() {
this.rewriteHashlinks();
this.tabs();
},
/**
* Ensure hash links are prefixed with the current page URL,
* otherwise jQuery interprets them as being external.
*/
rewriteHashlinks: function() {
$(this).find('ul a').each(function() {
var matches = $(this).attr('href').match(/#.*/);
if(!matches) return;
$(this).attr('href', document.location.href.replace(/#.*/, '') + matches[0]);
});
}
});
});
})(jQuery);