partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 7edcc801f599cdce8b5da91bcfed196184f47121
parent 28eba015eadacc5486722c231acc87749f31cfea
Author: Felicitus <felicitus@felicitus.org>
Date:   Wed, 14 Sep 2011 14:48:27 +0200

Refactored bugfixes into individual files

Diffstat:
Afrontend/js/ExtJS/Bugfixes/Ext.panel.Table-scrollDelta.js | 9+++++++++
Afrontend/js/ExtJS/Bugfixes/Ext.panelTable-scrollBug.js | 110+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afrontend/js/ExtJS/Bugfixes/Ext.selection.Model-lateBinding.js | 39+++++++++++++++++++++++++++++++++++++++
Afrontend/js/ExtJS/Enhancements/Ext.data.Connection-sessionInjection.js | 32++++++++++++++++++++++++++++++++
Afrontend/js/ExtJS/Enhancements/Ext.layout.component.field.Trigger-theme.js | 26++++++++++++++++++++++++++
Afrontend/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js | 31+++++++++++++++++++++++++++++++
Mfrontend/js/bugfixes.js | 252-------------------------------------------------------------------------------
7 files changed, 247 insertions(+), 252 deletions(-)

diff --git a/frontend/js/ExtJS/Bugfixes/Ext.panel.Table-scrollDelta.js b/frontend/js/ExtJS/Bugfixes/Ext.panel.Table-scrollDelta.js @@ -0,0 +1,8 @@ +/** + * Bugfix for Ext.panel.Table: + * + * Set the scrollDelta to 100 to ensure better scrolling experience + */ +Ext.override(Ext.panel.Table, { + scrollDelta: 100 +});+ \ No newline at end of file diff --git a/frontend/js/ExtJS/Bugfixes/Ext.panelTable-scrollBug.js b/frontend/js/ExtJS/Bugfixes/Ext.panelTable-scrollBug.js @@ -0,0 +1,109 @@ +/** + * Bugfix for Ext.panel.Table: + * + * Vertical scroller isn't activated until 4-5 records more than necessary are added to the grid + * + * Bugfix source: + * http://www.sencha.com/forum/showthread.php?137993-4.0.2-only-layout-fit-grid-scrollbar-when-used-does-not-scroll-content&p=640289&viewfull=1#post640289 + */ +Ext.override(Ext.panel.Table, { + determineScrollbars: function() { + var me = this, + box, + tableEl, + scrollWidth, + clientWidth, + scrollHeight, + clientHeight, + verticalScroller = me.verticalScroller, + horizontalScroller = me.horizontalScroller, + curScrollbars = (verticalScroller && verticalScroller.ownerCt === me ? 1 : 0) | + (horizontalScroller && horizontalScroller.ownerCt === me ? 2 : 0), + reqScrollbars = 0; // 1 = vertical, 2 = horizontal, 3 = both + + + // If we are not collapsed, and the view has been rendered AND filled, then we can determine scrollbars + if (!me.collapsed && me.view && me.view.el && me.view.el.dom.firstChild && !me.changingScrollBars) { + + + // Calculate maximum, *scrollbarless* space which the view has available. + // It will be the Fit Layout's calculated size, plus the widths of any currently shown scrollbars + //####### THIS IS ONLY CHANGE I HAVE MADE, USE VIEW SIZE RATHER THAN FULL PANEL SIZE ####### + box = me.view.getSize(); + + + clientWidth = box.width + ((curScrollbars & 1) ? verticalScroller.width : 0); + clientHeight = box.height + ((curScrollbars & 2) ? horizontalScroller.height : 0); + + + // Calculate the width of the scrolling block + // There will never be a horizontal scrollbar if all columns are flexed. + + + scrollWidth = (me.headerCt.query('[flex]').length && !me.headerCt.layout.tooNarrow) ? 0 : me.headerCt.getFullWidth(); + + + // Calculate the height of the scrolling block + if (verticalScroller && verticalScroller.el) { + scrollHeight = verticalScroller.getSizeCalculation().height; + } else { + tableEl = me.view.el.child('table', true); + scrollHeight = tableEl ? tableEl.offsetHeight : 0; + } + + + // View is too high. + // Definitely need a vertical scrollbar + if (scrollHeight > clientHeight) { + reqScrollbars = 1; + + + // But if scrollable block width goes into the zone required by the vertical scrollbar, we'll also need a horizontal + if (horizontalScroller && ((clientWidth - scrollWidth) < verticalScroller.width)) { + reqScrollbars = 3; + } + } + + + // View height fits. But we stil may need a horizontal scrollbar, and this might necessitate a vertical one. + else { + // View is too wide. + // Definitely need a horizontal scrollbar + if (scrollWidth > clientWidth) { + reqScrollbars = 2; + + + // But if scrollable block height goes into the zone required by the horizontal scrollbar, we'll also need a vertical + if (verticalScroller && ((clientHeight - scrollHeight) < horizontalScroller.height)) { + reqScrollbars = 3; + } + } + } + + + // If scrollbar requirements have changed, change 'em... + if (reqScrollbars !== curScrollbars) { + + + // Suspend component layout while we add/remove the docked scrollers + me.suspendLayout = true; + if (reqScrollbars & 1) { + me.showVerticalScroller(); + } else { + me.hideVerticalScroller(); + } + if (reqScrollbars & 2) { + me.showHorizontalScroller(); + } else { + me.hideHorizontalScroller(); + } + me.suspendLayout = false; + } + // Lay out the Component. + // Set a flag so that afterComponentLayout does not recurse back into here. + me.changingScrollBars = true; + me.doComponentLayout(); + me.changingScrollBars = false; + } + } +});+ \ No newline at end of file diff --git a/frontend/js/ExtJS/Bugfixes/Ext.selection.Model-lateBinding.js b/frontend/js/ExtJS/Bugfixes/Ext.selection.Model-lateBinding.js @@ -0,0 +1,39 @@ +/** + * Bugfix for Ext.selection.Model: + * + * If a store isn't bound yet, defer binding. + */ +Ext.override(Ext.selection.Model, { + /** + * @private + * Defines if the selection model is already bound to a store. + */ + _bound: false, + + constructor: function (cfg) { + /** + * @event _bind + * Fires as soon as a store is bound + */ + this.addEvents("_bind"); + + this.callOverridden(arguments); + }, + select: function(records, keepExisting, suppressEvent) { + // Check if we are bound to a store. If not, delay the select operation until the store is bound + if (this._bound) { + this.doSelect(records, keepExisting, suppressEvent); + } else { + this.on("_bind", function () { + this.doSelect(records, keepExisting, suppressEvent); + }, this, { single: true }); + } + + }, + bind: function(store, initial) { + this.callOverridden(arguments); + + this._bound = true; + this.fireEvent("_bind"); + } +}); diff --git a/frontend/js/ExtJS/Enhancements/Ext.data.Connection-sessionInjection.js b/frontend/js/ExtJS/Enhancements/Ext.data.Connection-sessionInjection.js @@ -0,0 +1,31 @@ +/** + * Enhancements for Ext.data.Connection: + * + * Inject the session automatically on each request if a + * session is available. + */ +Ext.override(Ext.data.Connection, { + /** + * Inject session header. I haven't found a better way to do + * it :( + */ + setupHeaders: function (xhr, options, data, params) { + var session; + + if (!options.headers) { + options.headers = {}; + } + + if (PartKeepr.getApplication() !== null) { + session = PartKeepr.getApplication().getSession(); + if (session !== null) { + options.headers.session = session; + } + } + + var headers = this.callOverridden(arguments); + + return headers; + } + +});+ \ No newline at end of file diff --git a/frontend/js/ExtJS/Enhancements/Ext.layout.component.field.Trigger-theme.js b/frontend/js/ExtJS/Enhancements/Ext.layout.component.field.Trigger-theme.js @@ -0,0 +1,26 @@ +/** + * Enhancements for Ext.layout.component.field.Trigger: + * + * Adjust the rendering so our custom theme works pretty. + */ +Ext.override(Ext.layout.component.field.Trigger, { + sizeBodyContents: function(width, height) { + var me = this, + owner = me.owner, + inputEl = owner.inputEl, + triggerWrap = owner.triggerWrap, + triggerWidth = owner.getTriggerWidth(); + + // If we or our ancestor is hidden, we can get a triggerWidth calculation + // of 0. We don't want to resize in this case. + if (owner.hideTrigger || owner.readOnly || triggerWidth > 0) { + // Decrease the field's width by the width of the triggers. Both the field and the triggerWrap + // are floated left in CSS so they'll stack up side by side. + me.setElementSize(inputEl, Ext.isNumber(width) ? width : width); + + inputEl.dom.style.paddingRight = (triggerWidth+2)+"px"; + // Explicitly set the triggerWrap's width, to prevent wrapping + triggerWrap.setWidth(triggerWidth); + } + } +}); diff --git a/frontend/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js b/frontend/js/ExtJS/Enhancements/Ext.tree.View-missingMethods.js @@ -0,0 +1,30 @@ +/** + * Enhancements for Ext.tree.View: + * + * Ported ensureVisible and scrollIntoView from ExtJS3 + */ +Ext.override(Ext.tree.View, { + /** + * Expands all parent nodes so the child is visible. + * @param {Ext.data.Model} record The record to make visible + */ + ensureVisible: function (record) { + if (!record) { return; } + + if (record.parentNode) { + record.parentNode.expand(); + this.ensureVisible(record.parentNode); + } + }, + /** + * Scrolls the specified record node into view + * @param {Ext.data.Model} record The record to scroll into view + */ + scrollIntoView: function (record) { + var node = this.getNode(record); + + if (node) { + node.scrollIntoView(this.getEl()); + } + } +});+ \ No newline at end of file diff --git a/frontend/js/bugfixes.js b/frontend/js/bugfixes.js @@ -15,137 +15,11 @@ Ext.override(Ext.data.reader.Reader, }); -Ext.override(Ext.panel.Table, { - scrollDelta: 100 -}); - -Ext.panel.Table.override({ - determineScrollbars: function() { - var me = this, - box, - tableEl, - scrollWidth, - clientWidth, - scrollHeight, - clientHeight, - verticalScroller = me.verticalScroller, - horizontalScroller = me.horizontalScroller, - curScrollbars = (verticalScroller && verticalScroller.ownerCt === me ? 1 : 0) | - (horizontalScroller && horizontalScroller.ownerCt === me ? 2 : 0), - reqScrollbars = 0; // 1 = vertical, 2 = horizontal, 3 = both - - - // If we are not collapsed, and the view has been rendered AND filled, then we can determine scrollbars - if (!me.collapsed && me.view && me.view.el && me.view.el.dom.firstChild && !me.changingScrollBars) { - - - // Calculate maximum, *scrollbarless* space which the view has available. - // It will be the Fit Layout's calculated size, plus the widths of any currently shown scrollbars - //####### THIS IS ONLY CHANGE I HAVE MADE, USE VIEW SIZE RATHER THAN FULL PANEL SIZE ####### - box = me.view.getSize(); - - - clientWidth = box.width + ((curScrollbars & 1) ? verticalScroller.width : 0); - clientHeight = box.height + ((curScrollbars & 2) ? horizontalScroller.height : 0); - - - // Calculate the width of the scrolling block - // There will never be a horizontal scrollbar if all columns are flexed. - - - scrollWidth = (me.headerCt.query('[flex]').length && !me.headerCt.layout.tooNarrow) ? 0 : me.headerCt.getFullWidth(); - - - // Calculate the height of the scrolling block - if (verticalScroller && verticalScroller.el) { - scrollHeight = verticalScroller.getSizeCalculation().height; - } else { - tableEl = me.view.el.child('table', true); - scrollHeight = tableEl ? tableEl.offsetHeight : 0; - } - - - // View is too high. - // Definitely need a vertical scrollbar - if (scrollHeight > clientHeight) { - reqScrollbars = 1; - // But if scrollable block width goes into the zone required by the vertical scrollbar, we'll also need a horizontal - if (horizontalScroller && ((clientWidth - scrollWidth) < verticalScroller.width)) { - reqScrollbars = 3; - } - } - - - // View height fits. But we stil may need a horizontal scrollbar, and this might necessitate a vertical one. - else { - // View is too wide. - // Definitely need a horizontal scrollbar - if (scrollWidth > clientWidth) { - reqScrollbars = 2; - - - // But if scrollable block height goes into the zone required by the horizontal scrollbar, we'll also need a vertical - if (verticalScroller && ((clientHeight - scrollHeight) < horizontalScroller.height)) { - reqScrollbars = 3; - } - } - } - - - // If scrollbar requirements have changed, change 'em... - if (reqScrollbars !== curScrollbars) { - // Suspend component layout while we add/remove the docked scrollers - me.suspendLayout = true; - if (reqScrollbars & 1) { - me.showVerticalScroller(); - } else { - me.hideVerticalScroller(); - } - if (reqScrollbars & 2) { - me.showHorizontalScroller(); - } else { - me.hideHorizontalScroller(); - } - me.suspendLayout = false; - } - // Lay out the Component. - // Set a flag so that afterComponentLayout does not recurse back into here. - me.changingScrollBars = true; - me.doComponentLayout(); - me.changingScrollBars = false; - } - } -}); -Ext.override(Ext.data.Connection, { - /** - * Inject session header. I haven't found a better way to do - * it :( - */ - setupHeaders: function (xhr, options, data, params) { - var session; - - if (!options.headers) { - options.headers = {}; - } - - if (PartKeepr.getApplication() !== null) { - session = PartKeepr.getApplication().getSession(); - if (session !== null) { - options.headers.session = session; - } - } - - var headers = this.callOverridden(arguments); - - return headers; - } - -}); Ext.view.AbstractView.override({ /** @@ -338,129 +212,3 @@ Ext.form.field.ComboBox.override({ }); -/** - * Bugfix for selection on views which aren't bound - */ -Ext.selection.Model.override({ - /** - * @private - * Defines if the selection model is already bound to a store. - */ - bound: false, - - constructor: function (cfg) { - /** - * @event _bind - * Fires as soon as a store is bound - */ - this.addEvents("_bind"); - - this.callOverridden(arguments); - }, - select: function(records, keepExisting, suppressEvent) { - // Check if we are bound to a store. If not, delay the select operation until the store is bound - if (this.bound) { - this.doSelect(records, keepExisting, suppressEvent); - } else { - this.on("_bind", function () { - this.doSelect(records, keepExisting, suppressEvent); - }, this, { single: true }); - } - - }, - bind: function(store, initial) { - this.callOverridden(arguments); - - this.bound = true; - this.fireEvent("_bind"); - } -}); - -/* -Ext.selection.RowModel.override({ - views: [], - - -});*/ - -Ext.tree.View.override({ - /** - * Expands all parent nodes so the child is visible. - * @param {Ext.data.Model} record The record to make visible - */ - ensureVisible: function (record) { - if (!record) { return; } - - if (record.parentNode) { - record.parentNode.expand(); - this.ensureVisible(record.parentNode); - } - }, - /** - * Scrolls the specified record node into view - * @param {Ext.data.Model} record The record to scroll into view - */ - scrollIntoView: function (record) { - var node = this.getNode(record); - - if (node) { - node.scrollIntoView(this.getEl()); - } - } -}); - -/* - -This file is part of Ext JS 4 - -Copyright (c) 2011 Sencha Inc - -Contact: http://www.sencha.com/contact - -GNU General Public License Usage -This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html. - -If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact. - -*/ -/** - * @private - * @class Ext.layout.component.field.Trigger - * @extends Ext.layout.component.field.Field - * Layout class for {@link Ext.form.field.Trigger} fields. Adjusts the input field size to accommodate - * the trigger button(s). - * @private - */ - -Ext.define('Ext.layout.component.field.Trigger', { - - /* Begin Definitions */ - - alias: ['layout.triggerfield'], - - extend: 'Ext.layout.component.field.Field', - - /* End Definitions */ - - type: 'triggerfield', - - sizeBodyContents: function(width, height) { - var me = this, - owner = me.owner, - inputEl = owner.inputEl, - triggerWrap = owner.triggerWrap, - triggerWidth = owner.getTriggerWidth(); - - // If we or our ancestor is hidden, we can get a triggerWidth calculation - // of 0. We don't want to resize in this case. - if (owner.hideTrigger || owner.readOnly || triggerWidth > 0) { - // Decrease the field's width by the width of the triggers. Both the field and the triggerWrap - // are floated left in CSS so they'll stack up side by side. - me.setElementSize(inputEl, Ext.isNumber(width) ? width : width); - - inputEl.dom.style.paddingRight = (triggerWidth+2)+"px"; - // Explicitly set the triggerWrap's width, to prevent wrapping - triggerWrap.setWidth(triggerWidth); - } - } -});