Last active
December 11, 2015 14:45
-
-
Save javierguerrero/dc05fd3ae21d3d1dec5e to your computer and use it in GitHub Desktop.
WP Tabify: Transform a SharePoint Web Part Zone into Tabs
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
.ui-tabs-nav { | |
margin: 0; | |
padding: 0; | |
} | |
.ui-tabs-nav li { | |
list-style: none; | |
margin: 0 1px 0 0; | |
padding: 0; | |
float: left; | |
} | |
.ui-tabs-nav a { | |
position: relative; | |
top: 1px; | |
display: block; | |
padding: 10px 8px; | |
border: solid #e1e0dc; | |
border-width: 1px 1px 0 1px; | |
background: #d6d6d6; | |
color: #999; | |
text-decoration: none; | |
-webkit-border-top-left-radius: 5px; | |
-webkit-border-top-right-radius: 5px; | |
-moz-border-radius-topleft: 5px; | |
-moz-border-radius-topright: 5px; | |
border-top-left-radius: 5px; | |
border-top-right-radius: 5px; | |
} | |
.ui-tabs-nav li.ui-tabs-selected a { | |
color: #c70d37; | |
background: #fff; | |
} | |
.ui-tabs-panel { | |
clear: both; | |
padding: 20px; | |
background: #fff; | |
border: 1px solid #e1e0dc; | |
} | |
.ui-tabs-hide { | |
display: none; | |
} |
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
<!--TABS--> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/jquery-ui.min.js"></script> |
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
(function($){ | |
$.fn.wpTabify = function(){ | |
if($('.ms-WPAddButton').size() == 0){ | |
return this.each(function(i){ | |
var tabList = $('<ul class="wpt-ui-tabs-nav"/>'); | |
var panels = $('<div class="wpt-ui-tabs-wrapper"/>'); | |
$(this).find('.s4-wpTopTable,td[id^="MSOZoneCell_"] > table').each(function(j){ | |
$(tabList).append('<li><a href="#ui-tab-panel' + i + j + '">' + $(this).find('h3.ms-WPTitle').text() + '</a></li>'); | |
var thisPanel = $('<div id="ui-tab-panel' + i + j + '" class="wpt-ui-tabs-panel"/>'); | |
var panelContents = $(this).detach(); | |
$(thisPanel).append($(panelContents).find('.ms-WPBody').html()); | |
$(panels).append(thisPanel); | |
}); | |
if($(tabList).find('li').size() > 0){ | |
$(this).prepend(panels); | |
$(this).prepend(tabList); | |
$(this).tabs(); | |
} | |
}); | |
} | |
else{ | |
return false; | |
} | |
}; | |
})(jQuery); | |
$(document).ready(function(){ | |
$('.my-web-part-tabs').wpTabify(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment