]> git.proxmox.com Git - proxmox-widget-toolkit.git/blobdiff - src/Toolkit.js
Buttons: add AltText
[proxmox-widget-toolkit.git] / src / Toolkit.js
index b38e5041ddf5bd6c857755a674804b7f955c70f7..a1d291eeae921f6931e595e55b6fbff42086bd22 100644 (file)
@@ -126,6 +126,11 @@ Ext.apply(Ext.form.field.VTypes, {
     },
     DnsNameText: gettext('This is not a valid DNS name'),
 
+    DnsNameOrWildcard: function(v) {
+       return Proxmox.Utils.DnsName_or_Wildcard_match.test(v);
+    },
+    DnsNameOrWildcardText: gettext('This is not a valid DNS name'),
+
     // workaround for https://www.sencha.com/forum/showthread.php?302150
     proxmoxMail: function(v) {
         return (/^(\w+)([-+.][\w]+)*@(\w[-\w]*\.){1,5}([A-Za-z]){2,63}$/).test(v);
@@ -190,6 +195,16 @@ Ext.define('PVE.form.field.Number', {
     submitLocaleSeparator: false,
 });
 
+// avois spamming the console and if we ever use this avoid a CORS block error too
+Ext.define('PVE.draw.Container', {
+    override: 'Ext.draw.Container',
+    defaultDownloadServerUrl: document.location.origin, // avoid that pointing to http://svg.sencha.io
+    applyDownloadServerUrl: function(url) { // avoid noisy warning, we don't really use that anyway
+       url = url || this.defaultDownloadServerUrl;
+       return url;
+    },
+});
+
 // ExtJs 5-6 has an issue with caching
 // see https://www.sencha.com/forum/showthread.php?308989
 Ext.define('Proxmox.UnderlayPool', {
@@ -223,20 +238,6 @@ Ext.define('Proxmox.UnderlayPool', {
     },
 });
 
-// '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)
@@ -333,7 +334,7 @@ Ext.define(null, {
                navModel.setPosition();
            }
 
-           // Do not leave the element in tht state in case refresh fails, and restoration
+           // Do not leave the element in that state in case refresh fails, and restoration
            // closure not called.
            activeElement.resumeFocusEvents();
 
@@ -407,13 +408,6 @@ Ext.define(null, {
     },
 });
 
-// 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.
@@ -465,7 +459,7 @@ Ext.define(null, {
 
 // 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)
+// also use the 'wheel' event instead of 'mousewheel' (fixed in 7.3)
 Ext.define('Proxmox.form.field.Spinner', {
     override: 'Ext.form.field.Spinner',
 
@@ -685,15 +679,26 @@ Ext.define('Proxmox.selection.CheckboxModel', {
     },
 });
 
-// override the download server url globally, for privacy reasons
-Ext.draw.Container.prototype.defaultDownloadServerUrl = "-";
-
 // stop nulling of properties
 Ext.define('Proxmox.Component', {
     override: 'Ext.Component',
     clearPropertiesOnDestroy: false,
 });
 
+// Fix drag&drop for vms and desktops that detect 'pen' pointerType
+// NOTE: this part has been rewritten in ExtJS 7.4, so re-check once we can upgrade
+Ext.define('Proxmox.view.DragZone', {
+    override: 'Ext.view.DragZone',
+
+    onItemMouseDown: function(view, record, item, index, e) {
+        // Ignore touchstart.
+        // For touch events, we use longpress.
+        if (e.pointerType !== 'touch') {
+            this.onTriggerGesture(view, record, item, index, e);
+        }
+    },
+});
+
 // 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