|
1 | 1 | define([ |
2 | 2 | 'jquery', |
3 | 3 | 'underscore', |
4 | | - './Tabs' |
5 | | -], function ($, _, Tabs) { |
| 4 | + './Tabs', |
| 5 | + './WithDisablable' |
| 6 | +], function ($, _, Tabs, WithDisablable) { |
6 | 7 | "use strict"; |
7 | 8 |
|
8 | 9 | /** |
9 | 10 | * @class DisablableTabs |
| 11 | + * @mixes WithDisablable |
10 | 12 | * @extends Tabs |
11 | 13 | */ |
12 | | - var DisablableTabs = Tabs.extend(/**@lends DisablableTabs*/{ |
13 | | - |
14 | | - /** |
15 | | - * @see {@link Backbone.View._classes} |
16 | | - * @protected |
17 | | - * @returns {Object} |
18 | | - */ |
19 | | - _classes: function () { |
20 | | - return _.defaults({ |
21 | | - disabled: 'tabs__title_disabled_yes' |
22 | | - }, this._super()); |
23 | | - }, |
24 | | - |
25 | | - /** |
26 | | - * @protected |
27 | | - */ |
28 | | - _initActiveTab: function () { |
29 | | - var $enabledTitles = this._elem('titles').not(this._selector('disabled')); |
30 | | - if ($enabledTitles.length) { |
31 | | - this._activeTab = this._getTabNameFromEl($enabledTitles.eq(0).find(this._selector('control'))[0]); |
32 | | - } |
33 | | - }, |
34 | | - |
35 | | - /** |
36 | | - * @public |
37 | | - * @param {string} name |
38 | | - */ |
39 | | - enableTab: function (name) { |
40 | | - this._removeClass('disabled', this._getTabTitleByName(name)); |
41 | | - return this; |
42 | | - }, |
43 | | - |
44 | | - /** |
45 | | - * @public |
46 | | - * @param {string} name |
47 | | - */ |
48 | | - disableTab: function (name) { |
49 | | - this._addClass('disabled', this._getTabTitleByName(name)); |
50 | | - return this; |
51 | | - }, |
52 | | - |
53 | | - /** |
54 | | - * Disables all tabs in the collection |
55 | | - * @public |
56 | | - * @returns DisablableTabs this |
57 | | - */ |
58 | | - disable: function () { |
59 | | - this._addClass('disabled', 'title'); |
60 | | - return this; |
61 | | - }, |
62 | | - |
63 | | - /** |
64 | | - * Enables all tabs in the collection |
65 | | - * @public |
66 | | - * @returns DisablableTabs this |
67 | | - */ |
68 | | - enable: function () { |
69 | | - this._removeClass('disabled', 'title'); |
70 | | - return this; |
71 | | - }, |
72 | | - |
73 | | - /** |
74 | | - * @param {string} name |
75 | | - */ |
76 | | - show: function (name) { |
77 | | - if (this._hasClass('disabled', this._getTabTitleByName(name))) { |
78 | | - return this; |
79 | | - } |
80 | | - return this._super(name); |
81 | | - } |
82 | | - }); |
83 | | - |
84 | | - return DisablableTabs; |
| 14 | + return Tabs.mix(WithDisablable); |
85 | 15 | }); |
0 commit comments