diff --git a/apps/common/main/resources/less/common.less b/apps/common/main/resources/less/common.less index b4a0128b6..300130c01 100644 --- a/apps/common/main/resources/less/common.less +++ b/apps/common/main/resources/less/common.less @@ -127,6 +127,9 @@ label { .panel-menu { width: 260px; + max-height: 100%; + position: relative; + overflow: hidden; float: left; border-right: @scaled-one-px-value-ie solid @border-toolbar-ie; border-right: @scaled-one-px-value solid @border-toolbar; diff --git a/apps/documenteditor/main/app/view/FileMenu.js b/apps/documenteditor/main/app/view/FileMenu.js index ffdd1b0fa..245d57bd8 100644 --- a/apps/documenteditor/main/app/view/FileMenu.js +++ b/apps/documenteditor/main/app/view/FileMenu.js @@ -235,6 +235,17 @@ define([ this.rendered = true; this.$el.html($markup); this.$el.find('.content-box').hide(); + if (_.isUndefined(this.scroller)) { + var me = this; + this.scroller = new Common.UI.Scroller({ + el: this.$el.find('.panel-menu'), + suppressScrollX: true, + alwaysVisibleY: true + }); + Common.NotificationCenter.on('window:resize', function() { + me.scroller.update(); + }); + } this.applyMode(); if ( !!this.api ) { @@ -257,6 +268,7 @@ define([ if (!panel) panel = this.active || defPanel; this.$el.show(); + this.scroller.update(); this.selectMenu(panel, opts, defPanel); this.api.asc_enableKeyEvents(false); @@ -400,6 +412,17 @@ define([ this.$el.find('.content-box:visible').hide(); panel.show(opts); + if (this.scroller) { + var itemTop = item.$el.position().top, + itemHeight = item.$el.outerHeight(), + listHeight = this.$el.outerHeight(); + if (itemTop < 0 || itemTop + itemHeight > listHeight) { + var height = this.scroller.$el.scrollTop() + itemTop + (itemHeight - listHeight)/2; + height = (Math.floor(height/itemHeight) * itemHeight); + this.scroller.scrollTop(height); + } + } + this.active = menu; } } diff --git a/apps/presentationeditor/main/app/view/FileMenu.js b/apps/presentationeditor/main/app/view/FileMenu.js index ba9e00248..524b6a76a 100644 --- a/apps/presentationeditor/main/app/view/FileMenu.js +++ b/apps/presentationeditor/main/app/view/FileMenu.js @@ -231,6 +231,17 @@ define([ this.rendered = true; this.$el.html($markup); this.$el.find('.content-box').hide(); + if (_.isUndefined(this.scroller)) { + var me = this; + this.scroller = new Common.UI.Scroller({ + el: this.$el.find('.panel-menu'), + suppressScrollX: true, + alwaysVisibleY: true + }); + Common.NotificationCenter.on('window:resize', function() { + me.scroller.update(); + }); + } this.applyMode(); if ( !!this.api ) { @@ -253,6 +264,7 @@ define([ if (!panel) panel = this.active || defPanel; this.$el.show(); + this.scroller.update(); this.selectMenu(panel, defPanel); this.api && this.api.asc_enableKeyEvents(false); @@ -393,6 +405,17 @@ define([ this.$el.find('.content-box:visible').hide(); panel.show(); + if (this.scroller) { + var itemTop = item.$el.position().top, + itemHeight = item.$el.outerHeight(), + listHeight = this.$el.outerHeight(); + if (itemTop < 0 || itemTop + itemHeight > listHeight) { + var height = this.scroller.$el.scrollTop() + itemTop + (itemHeight - listHeight)/2; + height = (Math.floor(height/itemHeight) * itemHeight); + this.scroller.scrollTop(height); + } + } + this.active = menu; } } diff --git a/apps/spreadsheeteditor/main/app/view/FileMenu.js b/apps/spreadsheeteditor/main/app/view/FileMenu.js index 4f41c7ba0..bcd7073a3 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenu.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenu.js @@ -212,6 +212,17 @@ define([ this.rendered = true; this.$el.html($markup); this.$el.find('.content-box').hide(); + if (_.isUndefined(this.scroller)) { + var me = this; + this.scroller = new Common.UI.Scroller({ + el: this.$el.find('.panel-menu'), + suppressScrollX: true, + alwaysVisibleY: true + }); + Common.NotificationCenter.on('window:resize', function() { + me.scroller.update(); + }); + } this.applyMode(); if ( !!this.api ) { @@ -235,6 +246,7 @@ define([ if (!panel) panel = this.active || defPanel; this.$el.show(); + this.scroller.update(); this.selectMenu(panel, defPanel); this.api.asc_enableKeyEvents(false); @@ -377,6 +389,17 @@ define([ this.$el.find('.content-box:visible').hide(); panel.show(); + if (this.scroller) { + var itemTop = item.$el.position().top, + itemHeight = item.$el.outerHeight(), + listHeight = this.$el.outerHeight(); + if (itemTop < 0 || itemTop + itemHeight > listHeight) { + var height = this.scroller.$el.scrollTop() + itemTop + (itemHeight - listHeight)/2; + height = (Math.floor(height/itemHeight) * itemHeight); + this.scroller.scrollTop(height); + } + } + this.active = menu; } }