Skip to content
This repository has been archived by the owner on May 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #809 from ezsystems/Fix-EZP-26044_NavigationHub_hi…
Browse files Browse the repository at this point in the history
…de_upper_screen

EZP-26044: Handle height change and scroll on navigation
  • Loading branch information
StephaneDiot authored Feb 27, 2017
2 parents ed9f59b + beb539c commit 3e47095
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 2 deletions.
10 changes: 10 additions & 0 deletions Resources/public/js/apps/ez-platformuiapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,16 @@ YUI.add('ez-platformuiapp', function (Y) {
update: true,
render: true
});

if (app.get('scrollToTop')) {
// Scroll to the top of the page. The timeout ensures that the
// scroll happens after navigation begins, so that the current
// scroll position will be restored if the user clicks the back
// button.
setTimeout(function () {
window.scroll(0, 0);
}, 1);
}
};

if ( this.get('activeView') ) {
Expand Down
1 change: 1 addition & 0 deletions Resources/public/js/views/ez-navigationhubview.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ YUI.add('ez-navigationhubview', function (Y) {
var oldHeight;

if ( this.get('active') ) {
this.set('navigationFixed', false);
oldHeight = this._getContainerHeight();
this._uiSetActiveNavigation(e.prevVal);
this._navigateToZone(e.newVal);
Expand Down
31 changes: 30 additions & 1 deletion Tests/js/apps/assets/ez-platformuiapp-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ YUI.add('ez-platformuiapp-tests', function (Y) {
showSideViewTest, hideSideViewTest, enablingRoutingTest, hashChangeTest,
handleMainViewTest, titleTest, configRouteTest,
dispatchConfigTest, getLanguageNameTest, refreshViewTest,
navigateToTest,
navigateToTest, scrollTest,
Assert = Y.Assert, Mock = Y.Mock;

appTest = new Y.Test.Case({
Expand Down Expand Up @@ -199,6 +199,34 @@ YUI.add('ez-platformuiapp-tests', function (Y) {
},
});

scrollTest = new Y.Test.Case({
name: "Scroll tests",

setUp: function () {
this.app = new Y.eZ.PlatformUIApp({
container: '.app',
viewContainer: '.view-container'
});
},

tearDown: function () {
this.app.destroy();
delete this.app;
},

"Should scroll to top and left of the window when showing main view": function () {
window.scroll(800, 800);

this.app.showView('view', {}, Y.bind(function () {
this.resume(function () {
Assert.areSame(window.pageXOffset, 0 ,"window should be scrolled to left");
Assert.areSame(window.pageYOffset, 0 ,"window should be scrolled to top");
});
}, this));
this.wait();
},
});

handleMainViewTest = new Y.Test.Case({
name: "handleMainView app tests",

Expand Down Expand Up @@ -2443,4 +2471,5 @@ YUI.add('ez-platformuiapp-tests', function (Y) {
Y.Test.Runner.add(enablingRoutingTest);
Y.Test.Runner.add(hashChangeTest);
Y.Test.Runner.add(navigateToTest);
Y.Test.Runner.add(scrollTest);
}, '', {requires: ['test', 'ez-platformuiapp', 'ez-viewservice', 'ez-viewservicebaseplugin', 'history-hash']});
1 change: 0 additions & 1 deletion Tests/js/views/assets/ez-locationviewview-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,6 @@ YUI.add('ez-locationviewview-tests', function (Y) {
},
});


Y.Test.Runner.setName("eZ Location View view tests");
Y.Test.Runner.add(test);
Y.Test.Runner.add(tabsTest);
Expand Down
10 changes: 10 additions & 0 deletions Tests/js/views/assets/ez-navigationhubview-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,16 @@ YUI.add('ez-navigationhubview-tests', function (Y) {
Y.Assert.areEqual(2, eventFired, "The 'navigationModeChange' event should be been fire twice");
},

"Should set navigationFixed to false on navigationChange": function () {
this.view.set('active', true);
this.view.set('activeNavigation', 'platform');

Y.Assert.isFalse(
this.view.get('navigationFixed'),
"navigationFixed attribute should be false"
);
},

"Should fire the heightChange event when getting fixed": function () {
var heightChange = false;

Expand Down

0 comments on commit 3e47095

Please # to comment.