Skip to content

Commit

Permalink
Merge pull request #3 from jobara/FLUID-5534
Browse files Browse the repository at this point in the history
FLUID-5534: Changes based on PR comments
  • Loading branch information
Eloisa committed Sep 20, 2017
2 parents 9cb4fe2 + 12b94ba commit adeb402
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 35 deletions.
24 changes: 12 additions & 12 deletions src/framework/preferences/js/ArrowScrolling.js
Expand Up @@ -29,11 +29,11 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
},
model: {
// panelMaxIndex: null, // determined by the number of panels calculated after the onPrefsEditorMarkupReady event fired
// scrollToIndex: null, // the raw index set by translateToScroll, will be transformed to the panelIndex
// scrollToIndex: null, // the raw index set by eventToScrollIndex, will be transformed to the panelIndex
panelIndex: 0
},
events: {
// beforeReset: null // should be provided by the fluid.prefs.prefsEditor grade
beforeReset: null // should be fired by the fluid.prefs.prefsEditor grade
},
modelRelay: {
target: "panelIndex",
Expand All @@ -59,6 +59,11 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
method: "addEventListener",
args: ["resize", "{that}.events.onSignificantDOMChange.fire"]
},
"onDestroy.removeWindowResize": {
"this": window,
method: "removeEventListener",
args: ["resize", "{that}.events.onSignificantDOMChange.fire"]
},
// Need to set panelMaxIndex after onPrefsEditorMarkupReady to ensure that the template has been
// rendered before we try to get the number of panels.
"onPrefsEditorMarkupReady.setPanelMaxIndex": {
Expand All @@ -76,13 +81,8 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
}
},
invokers: {
scrollToPanel: {
changePath: "scrollToIndex",
value: "{arguments}.0",
source: "scrollToPanel"
},
translateToScroll: {
funcName: "fluid.prefs.arrowScrolling.translateToScroll",
eventToScrollIndex: {
funcName: "fluid.prefs.arrowScrolling.eventToScrollIndex",
args: ["{that}", "{arguments}.0"]
}
},
Expand All @@ -91,7 +91,7 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
"afterRender.bindScrollArrows": {
"this": "{that}.dom.header",
method: "click",
args: ["{prefsEditor}.translateToScroll"]
args: ["{prefsEditor}.eventToScrollIndex"]
}
},
target: "{that > fluid.prefs.panel}.options.listeners"
Expand All @@ -103,12 +103,12 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
return Math.max(0, panels.length - 1);
};

fluid.prefs.arrowScrolling.translateToScroll = function (that, event) {
fluid.prefs.arrowScrolling.eventToScrollIndex = function (that, event) {
event.preventDefault();
var target = $(event.target);
var midPoint = target.width() / 2;
var scrollToIndex = that.model.panelIndex + (event.offsetX < midPoint ? -1 : 1);
that.scrollToPanel(scrollToIndex);
that.applier.change("scrollToIndex", scrollToIndex, "ADD", "eventToScrollIndex");
};

fluid.prefs.arrowScrolling.scrollToPanel = function (that, panelIndex) {
Expand Down
10 changes: 0 additions & 10 deletions src/framework/preferences/js/SeparatedPanelPrefsEditor.js
Expand Up @@ -148,16 +148,6 @@ var fluid_3_0_0 = fluid_3_0_0 || {};
onSignificantDOMChange: null,
updateEnhancerModel: "{that}.events.modelChanged"
},
modelListeners: {
"panelIndex": {
listener: "fluid.prefs.arrowScrolling.scrollToPanel",
args: ["{that}", "{change}.value"],
// Only scrolling to panels on model changes triggered by "scrollToPanel",
// which comes from clicking on the arrows.
includeSource: ["scrollToPanel"],
namespace: "scrollToPanel"
}
},
listeners: {
"modelChanged.save": "{that}.save",
"onCreate.bindReset": {
Expand Down
Expand Up @@ -159,8 +159,8 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
func: "fluid.tests.assertPanelVisibility",
args: ["{separatedPanel}.prefsEditor", "Initial Rendering", 0]
}, {
func: "{separatedPanel}.prefsEditor.scrollToPanel",
args: [2]
func: "{separatedPanel}.applier.change",
args: ["scrollToIndex", 2]
}, {
func: "fluid.tests.assertPanelVisibility",
args: ["{separatedPanel}.prefsEditor", "ScrollToPanel 2", 2]
Expand All @@ -177,14 +177,14 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
func: "fluid.tests.assertPanelVisibility",
args: ["{separatedPanel}.prefsEditor", "Clicked to go to Panel to the Left", 2]
}, {
func: "{separatedPanel}.prefsEditor.scrollToPanel",
args: [-1]
func: "{separatedPanel}.applier.change",
args: ["scrollToIndex", -1]
}, {
func: "fluid.tests.assertPanelVisibility",
args: ["{separatedPanel}.prefsEditor", "Scrolled to panel below bounds", 0]
}, {
func: "{separatedPanel}.prefsEditor.scrollToPanel",
args: [20]
func: "{separatedPanel}.applier.change",
args: ["scrollToIndex", 20]
}, {
func: "fluid.tests.assertPanelVisibility",
args: ["{separatedPanel}.prefsEditor", "Scrolled to panel beyond bounds", 5]
Expand Down Expand Up @@ -220,18 +220,18 @@ https://github.com/fluid-project/infusion/raw/master/Infusion-LICENSE.txt
});

fluid.defaults("fluid.tests.separatedPanelInitialPanelIndexTester", {
gradeNames: ["fluid.test.testCaseHolder"],
modules: [{
name: "Separated panel initial panelIndex tester",
tests: [{
expect: 39,
gradeNames: ["fluid.test.testCaseHolder"],
modules: [{
name: "Separated panel initial panelIndex tester",
sequence: [{
tests: [{
expect: 39,
name: "Separated panel initial panelIndex tester",
sequence: [{
listener: "fluid.tests.assertSeparatedPanelInit",
event: "{separatedPanelInitialPanelIndex separatedPanel}.events.onReady",
args: ["{separatedPanel}", 2]
}, {
func: "{separatedPanel}.slidingPanel.showPanel"
func: "{separatedPanel}.slidingPanel.showPanel"
}, {
listener: "fluid.tests.assertSeparatedPanelState",
event: "{separatedPanel}.slidingPanel.events.afterPanelShow",
Expand Down

0 comments on commit adeb402

Please sign in to comment.