2009-11-21 03:22:52 +01:00
|
|
|
(function($){
|
2010-04-13 07:45:29 +02:00
|
|
|
$.entwine('ss', function($){
|
2009-11-21 03:33:06 +01:00
|
|
|
/**
|
|
|
|
* Lightweight wrapper around jQuery UI tabs.
|
|
|
|
* Ensures that anchor links are set properly,
|
|
|
|
* and any nested tabs are scrolled if they have
|
|
|
|
* their height explicitly set. This is important
|
|
|
|
* for forms inside the CMS layout.
|
|
|
|
*/
|
2010-04-13 07:45:29 +02:00
|
|
|
$('.ss-tabset').entwine({
|
2009-11-21 03:32:38 +01:00
|
|
|
onmatch: function() {
|
2011-07-21 18:39:26 +02:00
|
|
|
// Can't name redraw() as it clashes with other CMS entwine classes
|
|
|
|
this.redrawTabs();
|
2011-07-15 10:37:46 +02:00
|
|
|
this._super();
|
|
|
|
},
|
|
|
|
|
2011-07-21 18:39:26 +02:00
|
|
|
redrawTabs: function() {
|
2009-11-21 03:32:38 +01:00
|
|
|
this.rewriteHashlinks();
|
2009-11-21 03:22:52 +01:00
|
|
|
|
2009-11-21 03:32:38 +01:00
|
|
|
// Initialize jQuery UI tabs
|
2012-01-07 18:57:40 +01:00
|
|
|
var id = this.attr('id');
|
2009-11-21 03:32:38 +01:00
|
|
|
this.tabs({
|
2012-01-07 18:57:40 +01:00
|
|
|
cookie: ($.cookie && id) ? { expires: 30, path: '/', name: 'ui-tabs-' + id } : false
|
|
|
|
});
|
2009-11-21 03:32:38 +01:00
|
|
|
},
|
2009-11-21 03:33:06 +01:00
|
|
|
|
2009-11-21 03:32:38 +01:00
|
|
|
/**
|
|
|
|
* Replace prefixes for all hashlinks in tabs.
|
|
|
|
* SSViewer rewrites them from "#Root_MyTab" to
|
|
|
|
* e.g. "/admin/#Root_MyTab" which makes them
|
|
|
|
* unusable for jQuery UI.
|
|
|
|
*/
|
|
|
|
rewriteHashlinks: function() {
|
|
|
|
$(this).find('ul a').each(function() {
|
|
|
|
var href = $(this).attr('href').replace(/.*(#.*)/, '$1');
|
|
|
|
if(href) $(this).attr('href', href);
|
|
|
|
});
|
|
|
|
}
|
2009-11-21 03:33:06 +01:00
|
|
|
});
|
2009-11-21 03:22:52 +01:00
|
|
|
});
|
2009-11-21 03:22:54 +01:00
|
|
|
})(jQuery);
|