MINOR Moved jsparty/tabstrip to sapphire/thirdparty/tabstrip

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@93560 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-11-26 03:18:05 +00:00 committed by Sam Minnee
parent c60c310cd3
commit 2f30ae7ba5
15 changed files with 478 additions and 0 deletions

BIN
thirdparty/tabstrip/images/add.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

BIN
thirdparty/tabstrip/images/norm_a_bg.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 831 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

View File

@ -0,0 +1,104 @@
/* Caution! Ensure accessibility in print and other media types... */
@media projection, screen { /* Use class for showing/hiding tab content, so that visibility can be better controlled in different media types... */
.ui-tabs-hide {
display: none;
}
}
/* Hide useless elements in print layouts... */
@media print {
.ui-tabs-nav {
display: none;
}
}
/* Skin */
.ui-tabs-nav {
list-style: none;
margin: 0;
padding: 0 0 0 3px;
border-bottom: 1px #AAA solid;
padding: 0;
margin: 0 !important;
clear: left;
float: left;
width: 100%;
/* Need this to stop tabs from disappearing sometimes */
position: relative;
}
.ui-tabs-nav:after { /* clearing without presentational markup, IE gets extra treatment */
display: block;
clear: both;
content: " ";
}
/* If I just say li I get into problems with ".ul-tabs-nav .ui-tabs-selected" below */
.ui-tabs-nav li {
float: left;
list-style: none;
background: url(images/norm_li_bg.gif) no-repeat left 3px;
margin: 0 2px 0 0;
padding: 0 0 0 9px;
cursor: pointer;
position: relative;
top: 1px;
}
.ui-tabs-nav a, .ui-tabs-nav a span {
}
.ui-tabs-nav a {
background: url(images/norm_a_bg.gif) no-repeat right 3px;
display: block;
float: left;
outline: none;
padding: 7px 9px 3px 0;
text-decoration: none;
color: #555;
font-size: 11px;
font-weight: bold;
}
.ui-tabs-nav li.ui-tabs-selected {
background: url(images/sel_li_bg.gif) no-repeat left top;
top: 1px;
}
.ui-tabs-nav li.ui-tabs-selected a {
background: url(images/sel_a_bg.gif) no-repeat right top;
padding: 6px 9px 5px 0;
color: #0074c6;
}
.ui-tabs-nav .ui-tabs-selected a:link, .ui-tabs-nav .ui-tabs-selected a:visited,
.ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited { /* @ Opera, use pseudo classes otherwise it confuses cursor... */
cursor: text;
}
.ui-tabs-nav a:hover, .ui-tabs-nav a:focus, .ui-tabs-nav a:active,
.ui-tabs-nav .ui-tabs-unselect a:hover, .ui-tabs-nav .ui-tabs-unselect a:focus, .ui-tabs-nav .ui-tabs-unselect a:active { /* @ Opera, we need to be explicit again here now... */
cursor: pointer;
}
.ui-tabs-disabled {
opacity: .4;
filter: alpha(opacity=40);
}
.ui-tabs-nav .ui-tabs-disabled a:link, .ui-tabs-nav .ui-tabs-disabled a:visited {
color: #000;
}
.ui-tabs-panel {
clear: left;
overflow: auto;
border: 1px solid #aaa;
border-top: none;
position: relative;
top: 0;
margin: 0;
padding: 10px;
}
/* Additional IE specific bug fixes... */
* html .ui-tabs-nav { /* auto clear @ IE 6 & IE 7 Quirks Mode */
display: inline-block;
}
*:first-child+html .ui-tabs-nav { /* auto clear @ IE 7 Standards Mode - do not group selectors, otherwise IE 6 will ignore complete rule (because of the unknown + combinator)... */
display: inline-block;
}

BIN
thirdparty/tabstrip/images/sel_a_bg.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

BIN
thirdparty/tabstrip/images/sel_li_bg.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 B

BIN
thirdparty/tabstrip/images/tab_bg.gif vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

70
thirdparty/tabstrip/tabstrip.css vendored Normal file
View File

@ -0,0 +1,70 @@
/*
* tabstrip-default.css
* Default styling for tabstrips
* Designed to look like windows-xp tabs
*
* Modified by Sean Harvey, SilverStripe Ltd 02/11/2007
*/
ul.tabstrip {
border-bottom: 1px #AAA solid;
padding: 0;
margin: 0 !important;
clear: left;
float: left;
width: 100%;
/* Need this to stop tabs from disappearing sometimes */
position: relative;
}
ul.tabstrip li {
float: left;
list-style: none;
background: url(images/norm_li_bg.gif) no-repeat left 3px;
margin: 0 2px 0 0;
padding: 0 0 0 9px;
cursor: pointer;
position: relative;
top: 1px;
}
ul.tabstrip li a {
background: url(images/norm_a_bg.gif) no-repeat right 3px;
display: block;
float: left;
outline: none;
padding: 7px 9px 3px 0;
text-decoration: none;
color: #555;
font-size: 11px;
font-weight: bold;
}
ul.tabstrip li a:hover {
text-decoration: none;
color: #000;
}
ul.tabstrip li.current,
ul.tabstrip li.ui-tabs-selected,
ul.tabstrip li.sel,
ul.tabstrip li.over {
background: url(images/sel_li_bg.gif) no-repeat left top;
top: 1px;
}
ul.tabstrip li.current a,
ul.tabstrip li.ui-tabs-selected a,
ul.tabstrip li.sel a,
ul.tabstrip li.over a {
background: url(images/sel_a_bg.gif) no-repeat right top;
padding: 6px 9px 5px 0;
color: #0074c6;
}
.tab {
clear: left;
overflow: auto;
border: 1px solid #aaa;
border-top: none;
position: relative;
top: 0;
margin: 0;
padding: 10px;
background-color: #FFFFFF;
}

304
thirdparty/tabstrip/tabstrip.js vendored Normal file
View File

@ -0,0 +1,304 @@
// jQuery loader
jQuery('ul.tabstrip').livequery(function() {
initTabstrip(this);
if(window.ontabschanged) window.ontabschanged();
});
var _CUR_TABS = [];
var _TABS_ON_PAGE = [];
var _TAB_DIVS_ON_PAGE = [];
function initTabstrip(tabstrip, namedAnchors) {
var i, anchor, container, anchorName, li;
var childAnchors = tabstrip.getElementsByTagName('a');
var base, curTab = null, curURL = window.location.href;
var previousTab = null;
var firstTab, foundATab = false;
// Strip query string from current URL
var curQuery = window.location.search;
// Detect a current tab from the # link
if(curURL.indexOf('#') == -1) {
base = curURL.length - curQuery.length;
} else {
base = curURL.indexOf('#') - curQuery.length;
curTab = curURL.substr(curURL.indexOf('#')+1);
}
// Get a stored current tab, used when Ajax-switching between pages
if(_CUR_TABS[tabstrip.parentNode.id] && $(_CUR_TABS[tabstrip.parentNode.id]) ) {
curTab = _CUR_TABS[tabstrip.parentNode.id];
} else {
// Default to showing the first tab
for(i=0;i<childAnchors.length;i++) {
var child = childAnchors[i];
var anchorPos = child.href.indexOf('#');
if(anchorPos != -1) {
anchorName = child.href.substr(anchorPos+1);
if(firstTab == null) firstTab = anchorName;
if(anchorName == curTab) foundATab = true;
}
}
if(!foundATab) curTab = firstTab;
}
_CUR_TABS[tabstrip.parentNode.id] = curTab;
for(i=0;i<childAnchors.length;i++) {
// Detect an anchor reference
var anchorBase = childAnchors[i].href.indexOf('#');
// if(childAnchors[i].href.substr(base,1) == '#') {
if( anchorBase != -1 ) {
anchorName = childAnchors[i].href.substr(anchorBase+1);
li = childAnchors[i].parentNode;
container = document.getElementById(anchorName);
if(container) tabstrip_initTab(childAnchors[i], anchorName, tabstrip, container);
// else throw("Cannot find ID: " + anchorName);
// Hook up previousTab / nextTab suppoort
if(previousTab) {
previousTab.nextTab = li;
li.previousTab = previousTab;
}
previousTab = li;
// Default to showing the first tab
// if(curTab == null && anchorName) curTab = anchorName;
// Show current tab
if(curTab && anchorName == curTab) {
tabstrip.currentlyShowing = li;
addClass(li, 'current');
if(container) {
container.style.display = '';
/*
// Show any parent tab that might be lurking about
var p = container.parentNode;
while(p.tagName.toLowerCase() != 'body') {
if(p.ownerTab) p.ownerTab.onclick('init');
p = p.parentNode;
}
*/
}
} else {
if(container) container.style.display = 'none';
}
}
}
// store the tabs in the window for window.ontabschanged
if($('Form_EditForm')) {
var divs = $('Form_EditForm').getElementsByTagName('div');
} else {
var divs = document.getElementsBySelector('form div');
}
for(i=0;i<divs.length;i++) {
if( ( Element.hasClassName(divs[i],'tab') || Element.hasClassName(divs[i],'tabset') ) ) {
_TAB_DIVS_ON_PAGE.push(divs[i]);
}
}
// Add nextTab() and previousTab() functions to the tabstrip
tabstrip.openNextTab = tabstrip_openNextTab;
tabstrip.openPreviousTab = tabstrip_openPreviousTab;
// Hook this into the destroyer, to prevent memory leaks
if(Class && Class.registerForDestruction) {
tabstrip.destroy = tabstrip_destroy;
Class.registerForDestruction(tabstrip);
}
}
function tabstrip_destroy() {
this.currentlyShowing = null;
_CUR_TABS = null;
var childAnchors = this.getElementsByTagName('a');
var i,a,li;
for(i=0;a=childAnchors[i];i++) {
a.onclick = null;
li = a.parentNode;
li.onclick = null;
li.onmouseover = null;
li.onmouseout = null;
li.tabstrip = null;
li.previousTab = null;
li.nextTab = null;
if(li.container) {
li.container.ownerTab = null;
li.container = null;
}
}
}
function tabstrip_initTab(a, anchorName, tabstrip, container) {
// Hook up information / events
a.onclick = tabstrip_showTab;
a.onclick = a.onclick.bindAsEventListener(a);
a.openTab = tabstrip_showTab;
li = a.parentNode;
li.container = container;
li.anchorName = anchorName;
li.tabstrip = tabstrip;
li.onclick = li.openTab = tabstrip_showTab;
li.onmouseover = tabstrip_mouseOver;
li.onmouseout = tabstrip_mouseOut;
_TABS_ON_PAGE[anchorName] = li;
container.ownerTab = li;
}
function openTab( anchorName ) {
if( typeof anchorName != 'string' )
return;
var tabNames = anchorName.split( 'set' );
if( tabNames.length > 1 )
anchorName = tabNames.shift() + 'set';
while( anchorName ) {
if( _TABS_ON_PAGE[anchorName] ) _TABS_ON_PAGE[anchorName].openTab( _TABS_ON_PAGE[anchorName].getElementsByTagName('a')[0] );
if( tabNames.length == 0 )
anchorName = null;
else {
anchorName = anchorName + tabNames.shift() + 'set';
}
}
}
/*
* Returns the form object that the given element is
* inside; or null if it's not inside a form
*/
function findParentForm(el) {
var ownerForm = el.parentNode, tn;
while((tn = ownerForm.tagName.toLowerCase()) != "body" && tn != "form") {
ownerForm = ownerForm.parentNode;
}
if(tn == "form") return ownerForm;
else return null;
}
function tabstrip_showTab(evt) {
if(this.tagName.toLowerCase() == "a") var el = this.parentNode;
else el = this;
_CUR_TABS[el.tabstrip.parentNode.id] = el.container.id;
if(el.tabstrip.currentlyShowing && el.tabstrip.currentlyShowing.container && el.tabstrip.currentlyShowing != el) {
el.tabstrip.currentlyShowing.container.style.display = 'none';
removeClass(el.tabstrip.currentlyShowing.container, 'current');
removeClass(el.tabstrip.currentlyShowing, 'current');
}
var container = document.getElementById( el.container.id );
if( container && container.style.display == 'none' ) {
container.style.display = 'block';
addClass( container, 'current' );
}
// el.container.style.display = '';
addClass(el, 'current');
el.tabstrip.currentlyShowing = el;
setHashLink(el.anchorName);
if(evt != 'init') {
if(window.ontabschanged) window.ontabschanged();
else if(window.onresize) window.onresize();
}
return false;
}
/*
* Redirect to the given hash link
* It won't actually reload the page, but it will update the current URL
*/
function setHashLink(hashLink) {
return; //temporarily disabled this
var preserveScroll = preserveScrollPosition(hashLink);
// Mac/IE5 cannot handle this
if(navigator.userAgent.indexOf("Mac") > -1 && navigator.userAgent.indexOf("MSIE") > -1)
return;
if(window.location.href.indexOf('#') == -1)
window.location.href += '#' + hashLink;
else
window.location.href = window.location.href.replace(/#.*$/, '#' + hashLink);
if(typeof preserveScroll != 'undefined')
restoreScrollPosition(preserveScroll);
}
/**
* Preserve the scroll position prior to visiting the given hashlink.
* Returns an object that you can pass to restoreScrollPosition
*/
function preserveScrollPosition(hashLink) {
var el = document.getElementById(hashLink);
var preserved = [];
while(el) {
preserved[preserved.length] = el;
el.oldScroll = el.scrollTop;
if(el.tagName && el.tagName.toLowerCase() == "body") break;
el = el.parentNode;
}
return preserved;
}
/*
* Restores the preserved scroll position
*/
function restoreScrollPosition(preserved) {
var i;
for(i=0;i<preserved.length;i++) {
preserved[i].scrollTop = preserved[i].oldScroll;
delete preserved[i].oldScroll;
}
}
function tabstrip_mouseOver() {
if(self.addClass) addClass(this, 'over');
}
function tabstrip_mouseOut() {
if(self.removeClass) removeClass(this, 'over');
}
function tabstrip_openNextTab() {
if(this.currentlyShowing && this.currentlyShowing.nextTab)
this.currentlyShowing.nextTab.onclick();
}
function tabstrip_openPreviousTab() {
if(this.currentlyShowing && this.currentlyShowing.previousTab)
this.currentlyShowing.previousTab.onclick();
}