// do not send '_dc' parameter
Ext.Ajax.disableCaching = false;
-// FIXME: HACK! Makes scrolling in number spinner work again. fixed in ExtJS >= 6.1
-if (Ext.isFirefox) {
- Ext.$eventNameMap.DOMMouseScroll = 'DOMMouseScroll';
-}
-
// custom Vtypes
Ext.apply(Ext.form.field.VTypes, {
IPAddress: function(v) {
passwordText: gettext('Passwords do not match'),
email: function(value) {
- let emailre = /^[\w+~-]+(\.[\w+~-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)$/;
+ let emailre = /^[\w+~-]+(\.[\w+~-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*$/;
return emailre.test(value);
},
});
-// Firefox 52+ Touchscreen bug
-// see https://www.sencha.com/forum/showthread.php?336762-Examples-don-t-work-in-Firefox-52-touchscreen/page2
-// and https://bugzilla.proxmox.com/show_bug.cgi?id=1223
-Ext.define('EXTJS_23846.Element', {
- override: 'Ext.dom.Element',
-}, function(Element) {
- let supports = Ext.supports,
- proto = Element.prototype,
- eventMap = proto.eventMap,
- additiveEvents = proto.additiveEvents;
-
- if (Ext.os.is.Desktop && supports.TouchEvents && !supports.PointerEvents) {
- eventMap.touchstart = 'mousedown';
- eventMap.touchmove = 'mousemove';
- eventMap.touchend = 'mouseup';
- eventMap.touchcancel = 'mouseup';
-
- additiveEvents.mousedown = 'mousedown';
- additiveEvents.mousemove = 'mousemove';
- additiveEvents.mouseup = 'mouseup';
- additiveEvents.touchstart = 'touchstart';
- additiveEvents.touchmove = 'touchmove';
- additiveEvents.touchend = 'touchend';
- additiveEvents.touchcancel = 'touchcancel';
-
- additiveEvents.pointerdown = 'mousedown';
- additiveEvents.pointermove = 'mousemove';
- additiveEvents.pointerup = 'mouseup';
- additiveEvents.pointercancel = 'mouseup';
- }
-});
-
-Ext.define('EXTJS_23846.Gesture', {
- override: 'Ext.event.publisher.Gesture',
-}, function(Gesture) {
- let gestures = Gesture.instance;
-
- if (Ext.supports.TouchEvents && !Ext.isWebKit && Ext.os.is.Desktop) {
- gestures.handledDomEvents.push('mousedown', 'mousemove', 'mouseup');
- gestures.registerEvents();
- }
-});
-
-Ext.define('EXTJS_18900.Pie', {
- override: 'Ext.chart.series.Pie',
-
- // from 6.0.2
- betweenAngle: function(x, a, b) {
- let pp = Math.PI * 2,
- offset = this.rotationOffset;
-
- if (a === b) {
- return false;
- }
-
- if (!this.getClockwise()) {
- x *= -1;
- a *= -1;
- b *= -1;
- a -= offset;
- b -= offset;
- } else {
- a += offset;
- b += offset;
- }
-
- x -= a;
- b -= a;
-
- // Normalize, so that both x and b are in the [0,360) interval.
- x %= pp;
- b %= pp;
- x += pp;
- b += pp;
- x %= pp;
- b %= pp;
-
- // Because 360 * n angles will be normalized to 0,
- // we need to treat b === 0 as a special case.
- return x < b || b === 0;
- },
-});
-
// we always want the number in x.y format and never in, e.g., x,y
Ext.define('PVE.form.field.Number', {
override: 'Ext.form.field.Number',
},
});
-// 'Enter' in Textareas and aria multiline fields should not activate the
-// defaultbutton, fixed in extjs 6.0.2
-Ext.define('PVE.panel.Panel', {
- override: 'Ext.panel.Panel',
-
- fireDefaultButton: function(e) {
- if (e.target.getAttribute('aria-multiline') === 'true' ||
- e.target.tagName === "TEXTAREA") {
- return true;
- }
- return this.callParent(arguments);
- },
-});
-
// if the order of the values are not the same in originalValue and value
// extjs will not overwrite value, but marks the field dirty and thus
// the reset button will be enabled (but clicking it changes nothing)
jumpToFocus: false,
saveFocusState: function() {
- let me = this,
+ var me = this,
store = me.dataSource,
actionableMode = me.actionableMode,
navModel = me.getNavigationModel(),
focusPosition = actionableMode ? me.actionPosition : navModel.getPosition(true),
- refocusRow, refocusCol;
-
- if (focusPosition) {
+ activeElement = Ext.fly(Ext.Element.getActiveElement()),
+ focusCell = focusPosition && focusPosition.view === me &&
+ Ext.fly(focusPosition.getCell(true)),
+ refocusRow, refocusCol, record;
+
+ // The navModel may return a position that is in a locked partner, so check that
+ // the focusPosition's cell contains the focus before going forward.
+ // The skipSaveFocusState is set by Actionables which actively control
+ // focus destination. See CellEditing#activateCell.
+ if (!me.skipSaveFocusState && focusCell && focusCell.contains(activeElement)) {
// Separate this from the instance that the nav model is using.
focusPosition = focusPosition.clone();
- // Exit actionable mode.
- // We must inform any Actionables that they must relinquish control.
- // Tabbability must be reset.
- if (actionableMode) {
- me.ownerGrid.setActionableMode(false);
+ // While we deactivate the focused element, suspend focus processing on it.
+ activeElement.suspendFocusEvents();
+
+ // Suspend actionable mode.
+ // Each Actionable must silently save its state ready to resume when focus
+ // can be restored but should only do that if the activeElement is not the cell itself,
+ // this happens when the grid is refreshed while one of the actionables is being
+ // deactivated (e.g. Calling view refresh inside CellEditor 'edit' event listener).
+ if (actionableMode && focusCell.dom !== activeElement.dom) {
+ me.suspendActionableMode();
+ } else {
+ // Clear position, otherwise the setPosition on the other side
+ // will be rejected as a no-op if the resumption position is logically
+ // equivalent.
+ actionableMode = false;
+ navModel.setPosition();
}
- // Blur the focused descendant, but do not trigger focusLeave.
- me.el.dom.focus();
+ // Do not leave the element in tht state in case refresh fails, and restoration
+ // closure not called.
+ activeElement.resumeFocusEvents();
- // Exiting actionable mode navigates to the owning cell, so in either focus mode we must
- // clear the navigation position
- navModel.setPosition();
+ // if the store is expanding or collapsing, we should never scroll the view.
+ if (store.isExpandingOrCollapsing) {
+ return Ext.emptyFn;
+ }
// The following function will attempt to refocus back in the same mode to the same cell
- // as it was at before based upon the previous record (if it's still inthe store), or the row index.
+ // as it was at before based upon the previous record (if it's still in the store),
+ // or the row index.
return function() {
+ var all;
+
+ // May have changed due to reconfigure
+ store = me.dataSource;
+
// If we still have data, attempt to refocus in the same mode.
if (store.getCount()) {
- // Adjust expectations of where we are able to refocus according to what kind of destruction
- // might have been wrought on this view's DOM during focus save.
- refocusRow = Math.min(focusPosition.rowIdx, me.all.getCount() - 1);
- refocusCol = Math.min(focusPosition.colIdx,
- me.getVisibleColumnManager().getColumns().length - 1);
- refocusRow = store.contains(focusPosition.record) ? focusPosition.record : refocusRow;
- focusPosition = new Ext.grid.CellContext(me).setPosition(refocusRow, refocusCol);
-
- if (actionableMode) {
- me.ownerGrid.setActionableMode(true, focusPosition);
- } else {
- me.cellFocused = true;
-
- // we sometimes want to scroll back to where we were
- let x = me.getScrollX();
- let y = me.getScrollY();
-
- // Pass "preventNavigation" as true so that that does not cause selection.
- navModel.setPosition(focusPosition, null, null, null, true);
-
- if (!me.jumpToFocus) {
- me.scrollTo(x, y);
+ all = me.all;
+
+ // Adjust expectations of where we are able to refocus according to
+ // what kind of destruction might have been wrought on this view's DOM
+ // during focus save.
+ refocusRow =
+ Math.min(Math.max(focusPosition.rowIdx, all.startIndex), all.endIndex);
+
+ refocusCol = Math.min(
+ focusPosition.colIdx,
+ me.getVisibleColumnManager().getColumns().length - 1,
+ );
+
+ record = focusPosition.record;
+
+ focusPosition = new Ext.grid.CellContext(me).setPosition(
+ record && store.contains(record) && !record.isCollapsedPlaceholder
+ ? record
+ : refocusRow,
+ refocusCol,
+ );
+
+ // Maybe there are no cells. eg: all groups collapsed.
+ if (focusPosition.getCell(true)) {
+ if (actionableMode) {
+ me.resumeActionableMode(focusPosition);
+ } else {
+ // we sometimes want to scroll back to where we are
+
+ let x = me.getScrollX();
+ let y = me.getScrollY();
+
+ // Pass "preventNavigation" as true
+ // so that that does not cause selection.
+ navModel.setPosition(focusPosition, null, null, null, true);
+
+ if (!navModel.getPosition()) {
+ focusPosition.column.focus();
+ }
+
+ if (!me.jumpToFocus) {
+ me.scrollTo(x, y);
+ }
}
}
} else { // No rows - focus associated column header
},
});
-// should be fixed with ExtJS 6.0.2, see:
-// https://www.sencha.com/forum/showthread.php?307244-Bug-with-datefield-in-window-with-scroll
-Ext.define('Proxmox.Datepicker', {
- override: 'Ext.picker.Date',
- hideMode: 'visibility',
-});
-
// ExtJS 6.0.1 has no setSubmitValue() (although you find it in the docs).
// Note: this.submitValue is a boolean flag, whereas getSubmitValue() returns
// data to be submitted.
},
});
-// this should be fixed with ExtJS 6.0.2
-// make mousescrolling work in firefox in the containers overflowhandler
+// make mousescrolling work in firefox in the containers overflowhandler,
+// by using only the 'wheel' event not 'mousewheel'(fixed in 7.3)
+// also reverse the scrolldirection (fixed in 7.3)
+// and reduce the default increment
Ext.define(null, {
override: 'Ext.layout.container.boxOverflow.Scroller',
- createWheelListener: function() {
- let me = this;
- if (Ext.isFirefox) {
- me.wheelListener = me.layout.innerCt.on('wheel', me.onMouseWheelFirefox, me, { destroyable: true });
+ wheelIncrement: 1,
+
+ getWheelDelta: function(e) {
+ return -e.getWheelDelta(e);
+ },
+
+ onOwnerRender: function(owner) {
+ var me = this,
+ scrollable = {
+ isBoxOverflowScroller: true,
+ x: false,
+ y: false,
+ listeners: {
+ scrollend: this.onScrollEnd,
+ scope: this,
+ },
+ };
+
+ // If no obstrusive scrollbars, allow natural scrolling on mobile touch devices
+ if (!Ext.scrollbar.width() && !Ext.platformTags.desktop) {
+ scrollable[owner.layout.horizontal ? 'x' : 'y'] = true;
} else {
- me.wheelListener = me.layout.innerCt.on('mousewheel', me.onMouseWheel, me, { destroyable: true });
+ me.wheelListener = me.layout.innerCt.on(
+ 'wheel', me.onMouseWheel, me, { destroyable: true },
+ );
}
- },
- // special wheel handler for firefox. differs from the default onMouseWheel
- // handler by using deltaY instead of wheelDeltaY and no normalizing,
- // because it is already
- onMouseWheelFirefox: function(e) {
- e.stopEvent();
- let delta = e.browserEvent.deltaY || 0;
- this.scrollBy(delta * this.wheelIncrement, false);
+ owner.setScrollable(scrollable);
},
+});
+
+// extj 6.7 reversed mousewheel direction... (fixed in 7.3)
+// https://forum.sencha.com/forum/showthread.php?472517-Mousewheel-scroll-direction-in-numberfield-with-spinners
+// alse use the 'wheel' event instead of 'mousewheel' (fixed in 7.3)
+Ext.define('Proxmox.form.field.Spinner', {
+ override: 'Ext.form.field.Spinner',
+
+ onRender: function() {
+ var me = this,
+ spinnerTrigger = me.getTrigger('spinner');
+
+ me.callParent();
+ // Init up/down arrow keys
+ if (me.keyNavEnabled) {
+ me.spinnerKeyNav = new Ext.util.KeyNav({
+ target: me.inputEl,
+ scope: me,
+ up: me.spinUp,
+ down: me.spinDown,
+ });
+
+ me.inputEl.on({
+ keyup: me.onInputElKeyUp,
+ scope: me,
+ });
+ }
+
+ // Init mouse wheel
+ if (me.mouseWheelEnabled) {
+ me.mon(me.bodyEl, 'wheel', me.onMouseWheel, me);
+ }
+
+ // in v4 spinUpEl/spinDownEl were childEls, now they are children of the trigger.
+ // create references for compatibility
+ me.spinUpEl = spinnerTrigger.upEl;
+ me.spinDownEl = spinnerTrigger.downEl;
+ },
+
+ onMouseWheel: function(e) {
+ var me = this,
+ delta;
+ if (me.hasFocus) {
+ delta = e.getWheelDelta();
+ if (delta > 0) {
+ me.spinDown();
+ } else if (delta < 0) {
+ me.spinUp();
+ }
+ e.stopEvent();
+ me.onSpinEnd();
+ }
+ },
});
// add '@' to the valid id
},
});
+// stop nulling of properties
+Ext.define('Proxmox.Component', {
+ override: 'Ext.Component',
+ clearPropertiesOnDestroy: false,
+});
+
// force alert boxes to be rendered with an Error Icon
// since Ext.Msg is an object and not a prototype, we need to override it
// after the framework has been initiated