mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-18 12:52:42 +01:00
Quicksand - fix toggle behavior to work with quicksand
Summary: Fixes T7919. This is a pretty generic toggle behavior. Make it quicksand ready by making it install only once and swallow the regular "click" event so the quicksand "click" event doesn't get funky with it. Also fixes a bug in Quicksand that I discovered developing / testing this feature. We have to update the internal member variable to be better than 0 similarly to how id works. So do that. Test Plan: went to phriction, toggled menu open, clicked home, clicked phriction and toggled menu again. Went back in history and noted menu was left to toggle state I previously had it. (currently a feature, not a bug) Reviewers: epriestley Reviewed By: epriestley Subscribers: Korvin, epriestley Maniphest Tasks: T7919 Differential Revision: https://secure.phabricator.com/D12708
This commit is contained in:
parent
4ea9d76f66
commit
1db79044b5
3 changed files with 41 additions and 25 deletions
|
@ -8,7 +8,7 @@
|
|||
return array(
|
||||
'names' => array(
|
||||
'core.pkg.css' => 'ca3f6a60',
|
||||
'core.pkg.js' => '3331b919',
|
||||
'core.pkg.js' => 'e9484a4e',
|
||||
'darkconsole.pkg.js' => 'e7393ebb',
|
||||
'differential.pkg.css' => 'bb338e4b',
|
||||
'differential.pkg.js' => '3cfa26f9',
|
||||
|
@ -205,7 +205,7 @@ return array(
|
|||
'rsrc/externals/javelin/lib/JSON.js' => '69adf288',
|
||||
'rsrc/externals/javelin/lib/Leader.js' => '331b1611',
|
||||
'rsrc/externals/javelin/lib/Mask.js' => '8a41885b',
|
||||
'rsrc/externals/javelin/lib/Quicksand.js' => '7ba665f5',
|
||||
'rsrc/externals/javelin/lib/Quicksand.js' => '977e1f47',
|
||||
'rsrc/externals/javelin/lib/Request.js' => '94b750d2',
|
||||
'rsrc/externals/javelin/lib/Resource.js' => '44959b73',
|
||||
'rsrc/externals/javelin/lib/Routable.js' => 'b3e7d692',
|
||||
|
@ -488,7 +488,7 @@ return array(
|
|||
'rsrc/js/core/behavior-scrollbar.js' => '834a1173',
|
||||
'rsrc/js/core/behavior-search-typeahead.js' => '048330fa',
|
||||
'rsrc/js/core/behavior-select-on-click.js' => '4e3e79a6',
|
||||
'rsrc/js/core/behavior-toggle-class.js' => 'e566f52c',
|
||||
'rsrc/js/core/behavior-toggle-class.js' => '5d7c9f33',
|
||||
'rsrc/js/core/behavior-tokenizer.js' => 'b3a4b884',
|
||||
'rsrc/js/core/behavior-tooltip.js' => '3ee3408b',
|
||||
'rsrc/js/core/behavior-watch-anchor.js' => '9f36c42d',
|
||||
|
@ -659,7 +659,7 @@ return array(
|
|||
'javelin-behavior-slowvote-embed' => '887ad43f',
|
||||
'javelin-behavior-stripe-payment-form' => '3f5d6dbf',
|
||||
'javelin-behavior-test-payment-form' => 'fc91ab6c',
|
||||
'javelin-behavior-toggle-class' => 'e566f52c',
|
||||
'javelin-behavior-toggle-class' => '5d7c9f33',
|
||||
'javelin-behavior-typeahead-browse' => '635de1ec',
|
||||
'javelin-behavior-typeahead-search' => '93d0c9e3',
|
||||
'javelin-behavior-view-placeholder' => '47830651',
|
||||
|
@ -677,7 +677,7 @@ return array(
|
|||
'javelin-leader' => '331b1611',
|
||||
'javelin-magical-init' => '3010e992',
|
||||
'javelin-mask' => '8a41885b',
|
||||
'javelin-quicksand' => '7ba665f5',
|
||||
'javelin-quicksand' => '977e1f47',
|
||||
'javelin-reactor' => '2b8de964',
|
||||
'javelin-reactor-dom' => 'c90a04fc',
|
||||
'javelin-reactor-node-calmer' => '76f4ebed',
|
||||
|
@ -1234,6 +1234,11 @@ return array(
|
|||
'javelin-dom',
|
||||
'javelin-vector',
|
||||
),
|
||||
'5d7c9f33' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'5e9f347c' => array(
|
||||
'javelin-behavior',
|
||||
'multirow-row-manager',
|
||||
|
@ -1408,9 +1413,6 @@ return array(
|
|||
'javelin-stratcom',
|
||||
'javelin-util',
|
||||
),
|
||||
'7ba665f5' => array(
|
||||
'javelin-install',
|
||||
),
|
||||
'7cbe244b' => array(
|
||||
'javelin-install',
|
||||
'javelin-util',
|
||||
|
@ -1594,6 +1596,9 @@ return array(
|
|||
'javelin-resource',
|
||||
'javelin-routable',
|
||||
),
|
||||
'977e1f47' => array(
|
||||
'javelin-install',
|
||||
),
|
||||
'988040b4' => array(
|
||||
'javelin-install',
|
||||
'javelin-dom',
|
||||
|
@ -1895,11 +1900,6 @@ return array(
|
|||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
),
|
||||
'e566f52c' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-stratcom',
|
||||
'javelin-dom',
|
||||
),
|
||||
'e5822781' => array(
|
||||
'javelin-behavior',
|
||||
'javelin-dom',
|
||||
|
|
|
@ -53,6 +53,7 @@ JX.install('Quicksand', {
|
|||
var path = self._getRelativeURI(window.location);
|
||||
self._id = window.history.state || 0;
|
||||
var id = self._id;
|
||||
self._onpage = id;
|
||||
self._history.push({path: path, id: id});
|
||||
|
||||
self._responses[id] = first_response;
|
||||
|
|
|
@ -14,17 +14,32 @@
|
|||
* Optionally, you may provide a `state` key to set the default state of the
|
||||
* element.
|
||||
*/
|
||||
JX.behavior('toggle-class', function() {
|
||||
JX.Stratcom.listen(
|
||||
['touchstart', 'mousedown'],
|
||||
'jx-toggle-class',
|
||||
function(e) {
|
||||
e.kill();
|
||||
JX.behavior('toggle-class', function(config, statics) {
|
||||
statics.install = statics.install || install();
|
||||
|
||||
var t = e.getNodeData('jx-toggle-class');
|
||||
t.state = !t.state;
|
||||
for (var k in t.map) {
|
||||
JX.DOM.alterClass(JX.$(k), t.map[k], t.state);
|
||||
}
|
||||
});
|
||||
function install() {
|
||||
JX.Stratcom.listen(
|
||||
['touchstart', 'mousedown'],
|
||||
'jx-toggle-class',
|
||||
function(e) {
|
||||
e.kill();
|
||||
|
||||
var t = e.getNodeData('jx-toggle-class');
|
||||
t.state = !t.state;
|
||||
for (var k in t.map) {
|
||||
JX.DOM.alterClass(JX.$(k), t.map[k], t.state);
|
||||
}
|
||||
});
|
||||
|
||||
// Swallow the regular click handler event so e.g. Quicksand
|
||||
// click handler doesn't get a hold of it
|
||||
JX.Stratcom.listen(
|
||||
['click'],
|
||||
'jx-toggle-class',
|
||||
function(e) {
|
||||
e.kill();
|
||||
});
|
||||
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue