-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
define([ | ||
'underscore', | ||
'backbone.factory/lib/SelectorsFactory', | ||
'./Tabs' | ||
], function (_, SelectorsFactory, Tabs) { | ||
'./Tabs', | ||
'./WithAnchor' | ||
], function (_, SelectorsFactory, Tabs, WithAnchor) { | ||
'use strict'; | ||
|
||
/** | ||
|
@@ -17,7 +18,8 @@ define([ | |
*/ | ||
_selectors: function () { | ||
return _.defaults({ | ||
tabs: '.tabs' | ||
tabs: '.tabs', | ||
anchorTabs: '.tabs_with_anchor' | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
apsavin
Contributor
|
||
}, this._super()); | ||
}, | ||
|
||
|
@@ -28,7 +30,8 @@ define([ | |
*/ | ||
_products: function () { | ||
return _.defaults({ | ||
'*': Tabs | ||
'*': Tabs, | ||
This comment has been minimized.
Sorry, something went wrong.
jifeon
Member
|
||
anchorTabs: Tabs.mix(WithAnchor) | ||
}, this._super()); | ||
}, | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
define([ | ||
'backbone.mix', | ||
'backbone.anchor/lib/anchor', | ||
'backbone-super' | ||
], function (Mixin, anchor) { | ||
'use strict'; | ||
|
||
/** | ||
* @mixin WithAnchors | ||
* @extends Tabs | ||
*/ | ||
var WithAnchors = new Mixin(/** @lends WithAnchors# */{ | ||
This comment has been minimized.
Sorry, something went wrong. |
||
/** | ||
* @constructs | ||
*/ | ||
initialize: function () { | ||
this._super(); | ||
|
||
this._linkWithAnchor(); | ||
}, | ||
|
||
/** | ||
* @private | ||
*/ | ||
_linkWithAnchor: function () { | ||
var name = this.getName(); | ||
anchor.on('change:' + name, this._onHashChange, this); | ||
if (anchor.has(name)) { | ||
this._processAnchorChange(anchor.get(name)); | ||
} | ||
}, | ||
|
||
/** | ||
* @param {string} tabName | ||
* @protected | ||
*/ | ||
_processAnchorChange: function (tabName) { | ||
this.show(tabName); | ||
}, | ||
|
||
/** | ||
* @param {Backbone.Model} model | ||
* @param {string} tabName | ||
* @private | ||
*/ | ||
_onHashChange: function (model, tabName) { | ||
this._processAnchorChange(tabName); | ||
}, | ||
|
||
/** | ||
* @public | ||
* @param {string} name | ||
* @returns {Tabs} this | ||
*/ | ||
show: function (name) { | ||
this._super(name); | ||
|
||
anchor.set(this.getName(), name); | ||
return this; | ||
} | ||
}); | ||
return WithAnchors; | ||
}); |
1 comment
on commit f9a6421
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apsavin Could look at this too, please.
I think modifier should be
with-anchor
, notwith
with valueanchor