Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ENHANCEMENT Using "concrete" jQuery plugin for SilverStripe tabset
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92485 467b73ca-7a2a-4603-9d3b-597d59a354a9
- Loading branch information
Showing
2 changed files
with
47 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
jQuery(document).ready(function () { | ||
(function($){ | ||
/** | ||
* 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. | ||
* 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. | ||
*/ | ||
jQuery('.ss-tabset > ul a').each(function() { | ||
var href = jQuery(this).attr('href').replace(/.*(#.*)/, '$1'); | ||
jQuery(this).attr('href', href); | ||
}) | ||
|
||
// Initialize tabset | ||
jQuery('.ss-tabset').tabs(); | ||
|
||
// if tab has no nested tabs, set overflow to auto | ||
jQuery('.ss-tabset .tab').not(':has(.tab)').css('overflow', 'auto'); | ||
$('.ss-tabset').concrete({ | ||
onmatch: function() { | ||
this.rewriteHashlinks(); | ||
|
||
// Initialize jQuery UI tabs | ||
this.tabs(); | ||
}, | ||
|
||
/** | ||
* 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); | ||
}) | ||
}, | ||
|
||
/** | ||
* If tab has no nested tabs, set overflow to auto | ||
*/ | ||
setOverflows: function() { | ||
$(this).find('.tab').not(':has(.tab)').css('overflow', 'auto'); | ||
} | ||
}); | ||
})(jQuery); | ||
|
||
jQuery(document).ready(function() { | ||
// @todo remove | ||
jQuery.concrete.triggerMatching(); | ||
}); |