|
3 | 3 | * Author: Alex Chizhov
|
4 | 4 | * Author Website: http://alexchizhov.com/pwstabs
|
5 | 5 | * 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 |
8 | 8 | * Licensed under the MIT license
|
9 | 9 | */
|
10 | 10 | ;(function ($, window, document, undefined) {
|
11 | 11 |
|
12 |
| - |
13 | 12 | var pluginName = "pwstabs",
|
14 | 13 | 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 |
18 | 20 | };
|
19 | 21 |
|
20 |
| - |
21 |
| - |
22 | 22 | function Plugin(element, options) {
|
23 | 23 | this.element = $(element);
|
24 | 24 | this.$elem = $(this.element);
|
|
40 | 40 | // Adding class to our selector
|
41 | 41 | this.$elem.addClass('pws_tabs_list');
|
42 | 42 |
|
| 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 | + |
43 | 49 | // 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>'); |
45 | 51 |
|
46 | 52 |
|
47 | 53 | // Hiding selectors children (Tabs)
|
|
53 | 59 | } else if (this.settings.effect == 'slideright') {
|
54 | 60 | $(pwsTabs).addClass('pws_tabs_slide_right_hide');
|
55 | 61 | } else if (this.settings.effect == 'slidetop') {
|
56 |
| - $(pwsTabs).addClass('pws_tabs_slide_top_hide'); |
| 62 | + $(pwsTabs).addClass('pws_tabs_slide_top_hide'); |
57 | 63 | } else if (this.settings.effect == 'slidedown') {
|
58 | 64 | $(pwsTabs).addClass('pws_tabs_slide_down_hide');
|
59 | 65 | } else { // In case something else is in the settings field that is not correct
|
|
62 | 68 |
|
63 | 69 |
|
64 | 70 | // 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 | + } |
67 | 78 |
|
68 | 79 | var pwsTabsDataCounter = '1';
|
69 | 80 | this.$elem.children('[data-pws-tab]').each(function(){
|
70 |
| - |
71 | 81 | // Set Data attributes with tab id number 1+
|
72 | 82 | $(this).attr('data-pws-tab-id', pwsTabsDataCounter);
|
73 |
| - |
74 | 83 | // Add LIs and A controls
|
75 | 84 | $(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 |
| - |
77 | 85 | // Adding class to our selector children (Tabs)
|
78 | 86 | $(this).addClass('pws_tab_single');
|
79 |
| - |
80 | 87 | pwsTabsDataCounter++;
|
81 |
| - |
82 | 88 | });
|
83 |
| - |
84 | 89 |
|
85 |
| - |
86 | 90 | // Now lets show default Tab
|
87 | 91 | if (this.settings.effect == 'slideleft') {
|
88 | 92 | this.$elem.find('[data-pws-tab-id="' + this.settings.defaultTab + '"]').addClass('pws_tabs_slide_left_show');
|
|
103 | 107 | // Now lets add active class to default tabs controller
|
104 | 108 | 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');
|
105 | 109 |
|
106 |
| - |
107 |
| - |
108 | 110 | // First lets find A link and add click function
|
109 | 111 | this.$elem.parent().find('ul li a').on('click', {pwsOptions : this.settings}, function (e) {
|
110 | 112 |
|
|
124 | 126 |
|
125 | 127 | var getTabsContainer = $(this).parent().parent().parent().find('.pws_tabs_list');
|
126 | 128 |
|
127 |
| - |
128 | 129 | // Now lets make it cooler, and add some effects to tabs container
|
129 | 130 | if (effect == 'slideleft') {
|
130 | 131 | allTabs.removeClass('pws_tabs_slide_left_show').addClass('pws_tabs_slide_left_hide');
|
|
0 commit comments