Skip to content

Commit aa9a66d

Browse files
Version 1.1.2 Update
RTL support horizontalPosition settings New examples
1 parent 23903d2 commit aa9a66d

8 files changed

+167
-44
lines changed

assets/jquery.pwstabs-1.1.1.min.js

-10
This file was deleted.

assets/jquery.pwstabs-1.1.1.js renamed to assets/jquery.pwstabs-1.1.2.js

+23-22
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
* Author: Alex Chizhov
44
* Author Website: http://alexchizhov.com/pwstabs
55
* GitHub: https://github.com/alexchizhovcom/pwstabs
6-
* Version: 1.1.1
7-
* Version from: 16.01.2015
6+
* Version: 1.1.2
7+
* Version from: 17.01.2015
88
* Licensed under the MIT license
99
*/
1010
;(function ($, window, document, undefined) {
1111

12-
1312
var pluginName = "pwstabs",
1413
defaults = {
15-
effect: 'scale', // You can change effects of your tabs container: scale, slideleft, slideright, slidetop, slidedown
16-
defaultTab: 1, // The tab we want to be opened by default
17-
containerWidth: '100%' // Set custom container width if not set then 100% is used
14+
effect: 'scale', // You can change effects of your tabs container: scale, slideleft, slideright, slidetop, slidedown
15+
defaultTab: 1, // The tab we want to be opened by default
16+
containerWidth: '100%', // Set custom container width if not set then 100% is used
17+
//tabsPosition: 'horizontal', // Tabs position: horizontal / vertical
18+
horizontalPosition: 'top', // Tabs horizontal position: top / bottom
19+
rtl: false // Right to left support: true/ false
1820
};
1921

20-
21-
2222
function Plugin(element, options) {
2323
this.element = $(element);
2424
this.$elem = $(this.element);
@@ -40,8 +40,14 @@
4040
// Adding class to our selector
4141
this.$elem.addClass('pws_tabs_list');
4242

43+
// Check if RTL support is true or false
44+
var pwsRtlClass = '';
45+
if( this.settings.rtl == true ){
46+
pwsRtlClass = ' pws_tabs_rtl';
47+
}
48+
4349
// Put tabs container into another block
44-
this.$elem.wrap('<div class="pws_tabs_container" style="width:' + this.settings.containerWidth + '"></div>');
50+
this.$elem.wrap('<div class="pws_tabs_container'+pwsRtlClass+'" style="width:' + this.settings.containerWidth + '"></div>');
4551

4652

4753
// Hiding selectors children (Tabs)
@@ -53,7 +59,7 @@
5359
} else if (this.settings.effect == 'slideright') {
5460
$(pwsTabs).addClass('pws_tabs_slide_right_hide');
5561
} else if (this.settings.effect == 'slidetop') {
56-
$(pwsTabs).addClass('pws_tabs_slide_top_hide');
62+
$(pwsTabs).addClass('pws_tabs_slide_top_hide');
5763
} else if (this.settings.effect == 'slidedown') {
5864
$(pwsTabs).addClass('pws_tabs_slide_down_hide');
5965
} else { // In case something else is in the settings field that is not correct
@@ -62,27 +68,25 @@
6268

6369

6470
// Add UL / LI and A control elements to Tabs Container
65-
this.$elem.parent().prepend('<ul class="pws_tabs_controll"></ul>');
66-
71+
72+
// Check if Horizontal and what position
73+
if ( this.settings.horizontalPosition == 'top' ){
74+
this.$elem.parent().prepend('<ul class="pws_tabs_controll pws_tabs_horizontal_top"></ul>');
75+
} else {
76+
this.$elem.parent().append('<ul class="pws_tabs_controll pws_tabs_horizontal_bottom"></ul>');
77+
}
6778

6879
var pwsTabsDataCounter = '1';
6980
this.$elem.children('[data-pws-tab]').each(function(){
70-
7181
// Set Data attributes with tab id number 1+
7282
$(this).attr('data-pws-tab-id', pwsTabsDataCounter);
73-
7483
// Add LIs and A controls
7584
$(this).parent().parent().find('ul.pws_tabs_controll').append('<li><a href="#" data-tab-id="' + $(this).data('pws-tab') + '">' + $(this).data('pws-tab-name') + '</a></li>');
76-
7785
// Adding class to our selector children (Tabs)
7886
$(this).addClass('pws_tab_single');
79-
8087
pwsTabsDataCounter++;
81-
8288
});
83-
8489

85-
8690
// Now lets show default Tab
8791
if (this.settings.effect == 'slideleft') {
8892
this.$elem.find('[data-pws-tab-id="' + this.settings.defaultTab + '"]').addClass('pws_tabs_slide_left_show');
@@ -103,8 +107,6 @@
103107
// Now lets add active class to default tabs controller
104108
this.$elem.parent().find('ul li a[data-tab-id="' + this.$elem.find('[data-pws-tab-id="' + this.settings.defaultTab + '"]').data('pws-tab') + '"]').addClass('pws_tab_active');
105109

106-
107-
108110
// First lets find A link and add click function
109111
this.$elem.parent().find('ul li a').on('click', {pwsOptions : this.settings}, function (e) {
110112

@@ -124,7 +126,6 @@
124126

125127
var getTabsContainer = $(this).parent().parent().parent().find('.pws_tabs_list');
126128

127-
128129
// Now lets make it cooler, and add some effects to tabs container
129130
if (effect == 'slideleft') {
130131
allTabs.removeClass('pws_tabs_slide_left_show').addClass('pws_tabs_slide_left_hide');

assets/jquery.pwstabs-1.1.2.min.js

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/jquery.pwstabs.css

+14-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33
* Author: Alex Chizhov
44
* Author Website: http://alexchizhov.com/pwstabs
55
* GitHub: https://github.com/alexchizhovcom/pwstabs
6-
* Version: 1.1.1
7-
* Version from: 16.01.2015
6+
* Version: 1.1.2
7+
* Version from: 17.01.2015
88
* Licensed under the MIT license
99
*/
10+
.pws_tabs_container.pws_tabs_rtl{
11+
text-align: right;
12+
direction: rtl;
13+
}
1014
.pws_tabs_container ul.pws_tabs_controll{
1115
list-style: none;
1216
}
@@ -21,6 +25,10 @@
2125
color: #fff;
2226
margin-right: 3px;
2327
}
28+
.pws_tabs_container.pws_tabs_rtl ul.pws_tabs_controll li a{
29+
margin-right: 0;
30+
margin-left: 3px;
31+
}
2432
.pws_tabs_container ul.pws_tabs_controll li a.pws_tab_active{
2533
background-color: #fff;
2634
color: #505050;
@@ -56,6 +64,10 @@
5664
-o-transition: all .3s ease-in-out;
5765
-ms-transition: all .3s ease-in-out;
5866
}
67+
.pws_tabs_container.pws_tabs_rtl .pws_tab_single{
68+
padding-right: 0;
69+
padding-left: 20px;
70+
}
5971

6072
/**
6173
* ######################################################

0 commit comments

Comments
 (0)