This is an automated email from the ASF dual-hosted git repository.

humbedooh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-ponymail-foal.git

commit fce63e9458864482a72cd751c030874e1f1d5df8
Author: Daniel Gruno <[email protected]>
AuthorDate: Wed Nov 17 20:13:29 2021 +0100

    Replace jquery mobile which seems broken
---
 webui/js/jquery.mobile-1.4.5.min.js | 10 -------
 webui/js/source/primer.js           |  4 ++-
 webui/js/source/swipe.js            | 57 +++++++++++++++++++++++++++++++++++++
 webui/list.html                     |  9 ++----
 4 files changed, 63 insertions(+), 17 deletions(-)

diff --git a/webui/js/jquery.mobile-1.4.5.min.js 
b/webui/js/jquery.mobile-1.4.5.min.js
deleted file mode 100644
index 5b1a9a1..0000000
--- a/webui/js/jquery.mobile-1.4.5.min.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/*! jQuery Mobile 1.4.5 | Git HEADhash: 68e55e7 <> 2014-10-31T17:33:30Z | (c) 
2010, 2014 jQuery Foundation, Inc. | jquery.org/license */
-
-!function(a,b,c){"function"==typeof 
define&&define.amd?define(["jquery"],function(d){return 
c(d,a,b),d.mobile}):c(a.jQuery,a,b)}(this,document,function(a,b,c){!function(a){a.mobile={}}(a),function(a,b){function
 d(b,c){var 
d,f,g,h=b.nodeName.toLowerCase();return"area"===h?(d=b.parentNode,f=d.name,b.href&&f&&"map"===d.nodeName.toLowerCase()?(g=a("img[usemap=#"+f+"]")[0],!!g&&e(g)):!1):(/input|select|textarea|button|object/.test(h)?!b.disabled:"a"===h?b.href||c:c)&&e(b)}function
 e(b){return [...]
-i=d.squash(e),j=this.hash(e,i),g&&j!==d.stripHash(d.parseLocation().hash)&&(this.preventNextHashChange=g),this.preventHashAssignPopState=!0,b.location.hash=j,this.preventHashAssignPopState=!1,h=a.extend({url:i,hash:j,title:c.title},f),l&&(k=new
 
a.Event("popstate"),k.originalEvent={type:"popstate",state:null},this.squash(e,h),g||(this.ignorePopState=!0,a.mobile.window.trigger(k))),this.history.add(h.url,h)},popstate:function(b){var
 c,f;if(a.event.special.navigate.isPushStateEnabled())retu [...]
-}),a.mobile.window.bind("throttledresize",a.mobile.resetActivePageHeight)},a(function(){f.resolve()}),"complete"===c.readyState?h():a.mobile.window.load(h),a.when(f,a.mobile.navreadyDeferred).done(function(){a.mobile._registerInternalEvents()})}(a),function(a,b){a.mobile.Transition=function(){this.init.apply(this,arguments)},a.extend(a.mobile.Transition.prototype,{toPreClass:"
 
ui-page-pre-in",init:function(b,c,d,e){a.extend(this,{name:b,reverse:c,$to:d,$from:e,deferred:new
 a.Deferred})}, [...]
-},_wrap:function(){return a("<div class='"+(this.isSearch?"ui-input-search 
":"ui-input-text ")+this.classes.join(" ")+" 
ui-shadow-inset'></div>")},_autoCorrect:function(){"undefined"==typeof 
this.element[0].autocorrect||a.support.touchOverflow||(this.element[0].setAttribute("autocorrect","off"),this.element[0].setAttribute("autocomplete","off"))},_handleBlur:function(){this.widget().removeClass(a.mobile.focusClass),this.options.preventFocusZoom&&a.mobile.zoom.enable(!0)},_handleFocus:fun
 [...]
-if(this._resizeData){if(a.x===this._resizeData.windowCoordinates.x&&a.y===this._resizeData.windowCoordinates.y&&a.cx===this._resizeData.windowCoordinates.cx&&a.cy===this._resizeData.windowCoordinates.cy)return!1;clearTimeout(this._resizeData.timeoutId)}return
 
this._resizeData={timeoutId:this._delay("_resizeTimeout",200),windowCoordinates:a},!0},_resizeTimeout:function(){this._isOpen?this._expectResizeEvent()||(this._ui.container.hasClass("ui-popup-hidden")&&(this._ui.container.removeClas
 [...]
-}})}(a),function(a){a.widget("mobile.toolbar",a.mobile.toolbar,{_makeFixed:function(){this._super(),this._workarounds()},_workarounds:function(){var
 
a=navigator.userAgent,b=navigator.platform,c=a.match(/AppleWebKit\/([0-9]+)/),d=!!c&&c[1],e=null,f=this;if(b.indexOf("iPhone")>-1||b.indexOf("iPad")>-1||b.indexOf("iPod")>-1)e="ios";else{if(!(a.indexOf("Android")>-1))return;e="android"}if("ios"===e)f._bindScrollWorkaround();else{if(!("android"===e&&d&&534>d))return;f._bindScrollWorkaround(),
 [...]
-}),this.panels.each(function(){a(this).height(Math.max(0,c-a(this).innerHeight()+a(this).height()))}).css("overflow","auto")):"auto"===b&&(c=0,this.panels.each(function(){c=Math.max(c,a(this).height("").height())}).height(c))},_eventHandler:function(b){var
 
c=this.options,d=this.active,e=a(b.currentTarget),f=e.closest("li"),g=f[0]===d[0],h=g&&c.collapsible,i=h?a():this._getPanelForTab(f),j=d.length?this._getPanelForTab(d):a(),k={oldTab:d,oldPanel:j,newTab:h?a():f,newPanel:i};b.preventDefa
 [...]
-//# sourceMappingURL=jquery.mobile-1.4.5.min.map
\ No newline at end of file
diff --git a/webui/js/source/primer.js b/webui/js/source/primer.js
index e34fe1e..3e547b1 100644
--- a/webui/js/source/primer.js
+++ b/webui/js/source/primer.js
@@ -83,6 +83,8 @@ function post_prime(state) {
 
 // onload function for list.html
 function parseURL(state) {
+    console.log("Running ParseURL");
+    console.log(state);
     let bits = window.location.search.substr(1).split(":", 3);
     let list = bits[0];
     let month = bits[1];
@@ -215,4 +217,4 @@ function unshortenID(mid) {
         return id1+id2
     }
     return mid
-}
\ No newline at end of file
+}
diff --git a/webui/js/source/swipe.js b/webui/js/source/swipe.js
new file mode 100644
index 0000000..ca88d81
--- /dev/null
+++ b/webui/js/source/swipe.js
@@ -0,0 +1,57 @@
+const SWIPE_THRESHOLD = 50; // Need at least this long a swipe before we 
register it
+let xDown;
+let yDown;
+
+// touch/swipe begins                                                          
               
+function touchStart(evt) {
+    let firstTouch = (evt.touches || evt.originalEvent.touches)[0];
+    xDown = firstTouch.clientX;
+    yDown = firstTouch.clientY;
+}
+
+// Touch/swipe ends
+function touchEnd(evt) {
+    if (!xDown || !yDown) return
+    let xUp = evt.changedTouches[0].clientX;
+    let yUp = evt.changedTouches[0].clientY;
+
+    let xDiff = Math.abs(xDown - xUp);
+    let yDiff = Math.abs(yDown - yUp);
+    let coords = {
+        detail: {
+            swipestart: {
+                coords: [xDown, yDown]
+            },
+            swipestop: {
+                coords: [xUp, yUp]
+            }
+        }
+    };
+    // If the swipe was too short, abort
+    if (Math.sqrt(xDiff ** 2 + yDiff ** 2) < SWIPE_THRESHOLD) return
+
+    // Which direction??
+    if (xDiff > yDiff) {
+        if (xDiff > 0) {
+            document.dispatchEvent(new CustomEvent("swipeleft", coords));
+        } else {
+            document.dispatchEvent(new CustomEvent("swiperight", coords));
+        }
+    } else {
+        if (yDiff > 0) {
+            document.dispatchEvent(new CustomEvent("swipeup", coords));
+        } else {
+            document.dispatchEvent(new CustomEvent("swipedown", coords));
+        }
+    }
+
+    xDown = null;
+    yDown = null;
+};
+
+function attachSwipe(elm) {
+    console.log("Attaching swipe detector to element ", elm);
+    elm.addEventListener("touchstart", touchStart, false);
+    elm.addEventListener("touchend", touchEnd, false);
+}
+
diff --git a/webui/list.html b/webui/list.html
index cb9109f..a13dc5f 100644
--- a/webui/list.html
+++ b/webui/list.html
@@ -171,9 +171,6 @@ the License. -->
         $.mobile.keepNative = "input";
       });
     </script>
-    <script src="js/jquery.mobile-1.4.5.min.js"
-            
integrity="sha256-Lsk+CDPOzTapLoAzWW0G/WeQeViS3FMzywpzPZV8SXk="></script>
-
     <!-- Include all compiled plugins (below), or include individual files as 
needed -->
     <script src="js/bootstrap.min.js"></script>
     <script src="js/config.js"></script>
@@ -182,9 +179,9 @@ the License. -->
     <div id="splash" class="splash fade-in"> &nbsp; </div>
     <div style="clear: both;"></div>
     <script type="text/javascript">
-      $.event.special.swipe.scrollSupressionThreshold = 20;
-      $.event.special.swipe.verticalDistanceThreshold = 30;
-      $( "#emails" ).on( "swipe", ponymail_swipe );
+      attachSwipe(document.getElementById("emails"));
+      document.addEventListener("swipeleft", ponymail_swipe);
+      document.addEventListener("swiperight", ponymail_swipe);
     </script>
   </body>
 </html>

Reply via email to