Skip to content

Commit ec91a0e

Browse files
committed
init method optimized
1 parent d0cfcc3 commit ec91a0e

File tree

9 files changed

+84
-78
lines changed

9 files changed

+84
-78
lines changed

README.md

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# jQuery Smart Tab 3
1+
# jQuery Smart Tab v3
22
#### The flexible jQuery tab control plugin.
33

44
[![Build Status](https://travis-ci.org/techlab/jquery-smarttab.svg?branch=master)](https://travis-ci.org/techlab/jquery-smarttab)
@@ -15,21 +15,21 @@ Smart Tab is a flexible and heavily customizable **jQuery Tab control plugin**.
1515
+ [StackOverflow Q&A](http://stackoverflow.com/questions/tagged/smart-tab)
1616
+ [GitHub Issues](https://github.com/techlab/jquery-smarttab/issues)
1717

18-
Screenshots
18+
Demos
1919
-----
20-
![Smart Tab Screenshot1](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-default.png)
20+
+ [Basic Example](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3)
21+
+ [Ajax Contents](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3/ajax)
22+
+ [Multiple Tabs](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3/multiple)
2123

22-
![Smart Tab Screenshot2](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-dark.png)
24+
Screenshots
25+
-----
26+
![jQuery Smart Tab default](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-default.png)
2327

24-
![Smart Tab Screenshot3](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-tabs.png)
28+
![jQuery Smart Tab dark](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-dark.png)
2529

26-
![Smart Tab Screenshot3](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-brick.png)
30+
![jQuery Smart Tab tabs](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-tabs.png)
2731

28-
Demos
29-
-----
30-
+ [Basic Example](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3)
31-
+ [Ajax Contents](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3/ajax)
32-
+ [Input Validation](http://techlaboratory.net/projects/demo/jquery-smart-tab/v3/multiple)
32+
![jQuery Smart Tab brick](http://techlaboratory.net/assets/media/jquery-smart-tab/smarttab-v3-brick.png)
3333

3434
Requirements
3535
-----
@@ -50,6 +50,26 @@ Installation
5050
### Download
5151
#### [Download from GitHub](https://github.com/techlab/jquery-smarttab/archive/master.zip)
5252

53+
Features
54+
-----
55+
56+
+ Responsive design
57+
+ Standalone CSS
58+
+ Bootstrap compatible
59+
+ Various themes included
60+
+ Customizable CSS
61+
+ Cool transition animations (fade/slide-horizontal/slide-vertical/slide-swing)
62+
+ URL navigation and tab selection
63+
+ Compatible with all jQuery versions (jQuery 1.11.1+, jQuery 2+, jQuery 3.5+)
64+
+ Auto content height adjustment
65+
+ Auto Progress (automatic navigation of tabs)
66+
+ Ajax content loading support
67+
+ Keyboard navigation
68+
+ External anchor support
69+
+ Custom events
70+
+ Supports all modern browsers
71+
+ Easy to implement and minimal HTML required
72+
5373
Usage
5474
-----
5575

@@ -123,25 +143,6 @@ Initialize the jQuery SmartTab
123143
That's it!
124144
Please see the [documentation](http://techlaboratory.net/jquery-smarttab#documentation) for more details on implementation and usage.
125145

126-
Features
127-
-----
128-
129-
+ Responsive design
130-
+ Standalone CSS
131-
+ Various themes included
132-
+ Customizable CSS
133-
+ URL navigation and tab selection
134-
+ Event support
135-
+ Ajax content loading support
136-
+ Keyboard navigation
137-
+ Auto content height adjustment
138-
+ Compatible with all jQuery versions (jQuery 1.11.1+, jQuery 2+, jQuery 3.5+)
139-
+ Easy to implement and minimal HTML required
140-
+ Supports all modern browsers
141-
+ Auto Progress (automatic navigation of tabs)
142-
+ Cool transition animations (fade/slide-horizontal/slide-vertical/slide-swing)
143-
+ External anchor support
144-
145146
License
146147
----
147148
[MIT License](https://github.com/techlab/jquery-smarttab/blob/master/LICENSE)
@@ -152,4 +153,4 @@ If you like the project please support with your contribution.
152153

153154
[Donate on Paypal](https://www.paypal.me/dipuraj)
154155

155-
Thank you :)
156+
Thank you and Happy Coding!

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"authors": [
2222
{
2323
"name": "Dipu Raj",
24-
"email": "hello@techlaboratory.net",
24+
"email": "hello.techlab@gmail.com",
2525
"homepage": "http://dipu.me"
2626
}
2727
],

dist/js/jquery.smartTab.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
99
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
1010

1111
/*!
12-
* jQuery SmartTab v3.0.0
12+
* jQuery SmartTab v3.0.1
1313
* The flexible jQuery tab control plugin
1414
* http://www.techlaboratory.net/jquery-smarttab
1515
*
@@ -52,7 +52,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
5252
enabled: false,
5353
// Enable/Disable Auto navigation
5454
interval: 3500,
55-
// Auto navigate Interval (used only if "autoProgress" is set to true)
55+
// Auto navigate Interval (used only if "autoProgress" is enabled)
5656
stopOnFocus: true // Stop auto navigation on focus and resume on outfocus
5757

5858
},
@@ -85,31 +85,37 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
8585

8686
this.current_index = null; // Autoprogress timer id
8787

88-
this.autoProgressId = null; // Clean the elements
88+
this.autoProgressId = null; // Assign options
8989

90-
this.pages.hide();
91-
this.tabs.removeClass('active'); // Call initial method
90+
this._initOptions(); // Initial load
9291

93-
this.init();
94-
} // Initial Method
9592

96-
97-
_createClass(SmartTab, [{
98-
key: "init",
99-
value: function init() {
100-
// Set the elements
101-
this._setElements(); // Assign plugin events
93+
this._initLoad();
94+
} // Initial Load Method
10295

10396

104-
this._setEvents(); // Get the initial tab index
105-
97+
_createClass(SmartTab, [{
98+
key: "_initLoad",
99+
value: function _initLoad() {
100+
// Clean the elements
101+
this.pages.hide();
102+
this.tabs.removeClass('active'); // Get the initial tab index
106103

107104
var idx = this._getTabIndex(); // Show the initial tab
108105

109106

110107
this._showTab(idx);
111-
} // PRIVATE FUNCTIONS
108+
} // Initialize options
112109

110+
}, {
111+
key: "_initOptions",
112+
value: function _initOptions() {
113+
// Set the elements
114+
this._setElements(); // Assign plugin events
115+
116+
117+
this._setEvents();
118+
}
113119
}, {
114120
key: "_getFirstDescendant",
115121
value: function _getFirstDescendant(selector) {
@@ -661,7 +667,8 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
661667
key: "setOptions",
662668
value: function setOptions(options) {
663669
this.options = $.extend(true, {}, this.options, options);
664-
this.init();
670+
671+
this._initOptions();
665672
}
666673
}, {
667674
key: "loader",

dist/js/jquery.smartTab.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/ajax.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ <h3>Tab 2 Content</h3>
209209
});
210210

211211
$("#animation").on("change", function() {
212-
// Change theme
212+
// Change animation
213213
var options = {
214214
transition: {
215215
animation: $(this).val()
@@ -228,9 +228,6 @@ <h3>Tab 2 Content</h3>
228228
return true;
229229
});
230230

231-
// Set selected theme on page refresh
232-
$("#theme_selector").change();
233-
234231
});
235232
</script>
236233
</body>

examples/index.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,6 @@ <h3>Tab 4 Content</h3>
167167
return true;
168168
});
169169

170-
// Set selected theme on page refresh
171-
$("#theme_selector").change();
172-
173170
});
174171
</script>
175172
</body>

examples/multiple.html

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ <h3>Tab 4 Content</h3>
205205

206206
// SmartTab initialize
207207
$('#smarttab').smartTab();
208-
$('#smarttab2').smartTab();
208+
$('#smarttab2').smartTab({
209+
theme: 'dark'
210+
});
209211

210212

211213
// Demo Button Events
@@ -305,9 +307,6 @@ <h3>Tab 4 Content</h3>
305307
return true;
306308
});
307309

308-
// Set selected theme on page refresh
309-
$("#theme_selector2").change();
310-
311310
});
312311
</script>
313312
</body>

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
{
22
"name": "jquery-smarttab",
33
"title": "jQuery Smart Tab",
4-
"version": "v3.0.0",
4+
"version": "v3.0.1",
55
"description": "The flexible jQuery tab control plugin",
66
"author": {
77
"name": "Dipu Raj",
8-
"email": "hello@techlaboratory.net",
8+
"email": "hello.techlab@gmail.com",
99
"url": "http://dipu.me"
1010
},
1111
"homepage": "http://techlaboratory.net/jquery-smarttab",
1212
"license": "MIT",
1313
"contributors": [
1414
{
1515
"name": "Dipu Raj",
16-
"email": "hello@techlaboratory.net"
16+
"email": "hello.techlab@gmail.com"
1717
}
1818
],
1919
"main": "./dist/js/jquery.smartTab.js",

src/js/jquery.smartTab.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* jQuery SmartTab v3.0.0
2+
* jQuery SmartTab v3.0.1
33
* The flexible jQuery tab control plugin
44
* http://www.techlaboratory.net/jquery-smarttab
55
*
@@ -29,7 +29,7 @@
2929
},
3030
autoProgress: { // Auto navigate tabs on interval
3131
enabled: false, // Enable/Disable Auto navigation
32-
interval: 3500, // Auto navigate Interval (used only if "autoProgress" is set to true)
32+
interval: 3500, // Auto navigate Interval (used only if "autoProgress" is enabled)
3333
stopOnFocus: true, // Stop auto navigation on focus and resume on outfocus
3434
},
3535
keyboardSettings: {
@@ -58,26 +58,31 @@
5858
this.current_index = null;
5959
// Autoprogress timer id
6060
this.autoProgressId = null;
61+
// Assign options
62+
this._initOptions();
63+
// Initial load
64+
this._initLoad();
65+
}
66+
67+
// Initial Load Method
68+
_initLoad() {
6169
// Clean the elements
6270
this.pages.hide();
6371
this.tabs.removeClass('active');
64-
// Call initial method
65-
this.init();
66-
}
6772

68-
// Initial Method
69-
init() {
70-
// Set the elements
71-
this._setElements();
72-
// Assign plugin events
73-
this._setEvents();
7473
// Get the initial tab index
7574
let idx = this._getTabIndex();
7675
// Show the initial tab
7776
this._showTab(idx);
7877
}
7978

80-
// PRIVATE FUNCTIONS
79+
// Initialize options
80+
_initOptions() {
81+
// Set the elements
82+
this._setElements();
83+
// Assign plugin events
84+
this._setEvents();
85+
}
8186

8287
_getFirstDescendant(selector) {
8388
// Check for first level element
@@ -565,7 +570,7 @@
565570

566571
setOptions(options) {
567572
this.options = $.extend(true, {}, this.options, options);
568-
this.init();
573+
this._initOptions();
569574
}
570575

571576
loader(state) {

0 commit comments

Comments
 (0)