Sfoglia il codice sorgente

Update the website to not use jquery.easing

It will now also no longer be included in the full bundle.
JC Brand 8 anni fa
parent
commit
bd38f0d634
8 ha cambiato i file con 58 aggiunte e 49 eliminazioni
  1. 1 1
      .eslintrc.json
  2. 2 0
      CHANGES.md
  3. 1 1
      css/theme.css
  4. 2 32
      index.html
  5. 14 13
      package-lock.json
  6. 0 1
      package.json
  7. 0 1
      src/config.js
  8. 38 0
      src/website.js

+ 1 - 1
.eslintrc.json

@@ -18,7 +18,7 @@
         "lodash/prefer-lodash-method": [2, {
             "ignoreMethods": [
                 "find", "endsWith", "startsWith", "filter", "reduce",
-                "map", "replace", "toLower", "split", "trim"
+                "map", "replace", "toLower", "split", "trim", "forEach"
             ]
         }],
         "lodash/prefer-startswith": "off",

+ 2 - 0
CHANGES.md

@@ -3,6 +3,8 @@
 ## 3.2.0 (Unreleased)
 
 - Removed jQuery from `converse-core`, `converse-vcard` and `converse-roomslist`. [jcbrand]
+- Remove `jquery.easing` from the full build. Was only being used by the
+  [conversejs.org](https://conversejs.org) website, which has been updated to not rely on it. [jcbrand]
 - All promises are now native (or polyfilled) ES2015 Promises
   instead of jQuery's Deferred. [jcbrand]
 - #866 Add babel in order to support ES2015 syntax [jcbrand]

+ 1 - 1
css/theme.css

@@ -344,5 +344,5 @@ ul.features {
 .sponsors {
     clear: both;
     font-size: 1.1em;
-    padding: 6em 0 7em 0;
+    padding: 2em 0 7em 0;
 }

+ 2 - 32
index.html

@@ -15,7 +15,8 @@
     <link type="text/css" rel="stylesheet" media="screen" href="https://cdn.conversejs.org/3.1.0/css/converse.min.css" />
     <script type="text/javascript" src="analytics.js"></script>
     <noscript><p><img src="//stats.opkode.com/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
-    <![if gte IE 9]>
+	<script src="src/website.js"></script>
+    <![if gte IE 11]>
 	<script src="https://cdn.conversejs.org/3.1.0/dist/converse.min.js"></script>
     <![endif]>
 </head>
@@ -223,37 +224,6 @@
 </body>
 
 <script>
-    (function () {
-        /* XXX: This function initializes jquery.easing for the https://conversejs.org
-        * website. This code is only useful in the context of the converse.js
-        * website and converse.js itself is NOT dependent on it.
-        */
-        var $ = converse.env.jQuery;
-        $.extend( $.easing, {
-            easeInOutExpo: function (x, t, b, c, d) {
-                if (t==0) return b;
-                if (t==d) return b+c;
-                if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
-                return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
-            },
-        });
-
-        $(window).scroll(function() {
-            if ($(".navbar").offset().top > 50) {
-                $(".navbar-fixed-top").addClass("top-nav-collapse");
-            } else {
-                $(".navbar-fixed-top").removeClass("top-nav-collapse");
-            }
-        });
-        //jQuery for page scrolling feature - requires jQuery Easing plugin
-        $('.page-scroll a').bind('click', function(event) {
-            var $anchor = $(this);
-            $('html, body').stop().animate({
-                scrollTop: $($anchor.attr('href')).offset().top
-            }, 700, 'easeInOutExpo');
-            event.preventDefault();
-        });
-    })();
     converse.initialize({
         // Please use this connection manager only for testing purposes
         bosh_service_url: 'https://conversejs.org/http-bind/',

+ 14 - 13
package-lock.json

@@ -3033,12 +3033,6 @@
       "integrity": "sha1-ReB+QZAzTeNsnhpktDsfE3PZF1g=",
       "dev": true
     },
-    "jquery-easing": {
-      "version": "0.0.1",
-      "resolved": "https://registry.npmjs.org/jquery-easing/-/jquery-easing-0.0.1.tgz",
-      "integrity": "sha1-s8N1JbVXNNwe4a0JtsM3MYdodxU=",
-      "dev": true
-    },
     "jquery.browser": {
       "version": "0.1.0",
       "resolved": "https://registry.npmjs.org/jquery.browser/-/jquery.browser-0.1.0.tgz",
@@ -3607,7 +3601,8 @@
         },
         "dezalgo": {
           "version": "1.0.3",
-          "bundled": true,
+          "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.3.tgz",
+          "integrity": "sha1-f3Qt4Gb8dIvI24IFad3c5Jvw1FY=",
           "dev": true
         },
         "editor": {
@@ -4057,7 +4052,8 @@
         },
         "normalize-git-url": {
           "version": "3.0.2",
-          "bundled": true,
+          "resolved": "https://registry.npmjs.org/normalize-git-url/-/normalize-git-url-3.0.2.tgz",
+          "integrity": "sha1-jl8Uvgva7bc+ByADEKpBbCc1D8Q=",
           "dev": true
         },
         "normalize-package-data": {
@@ -4086,7 +4082,8 @@
         },
         "npm-install-checks": {
           "version": "3.0.0",
-          "bundled": true,
+          "resolved": "https://registry.npmjs.org/npm-install-checks/-/npm-install-checks-3.0.0.tgz",
+          "integrity": "sha1-1K7N/VGlPjcjt7L5Oy7ijjB7wNc=",
           "dev": true
         },
         "npm-package-arg": {
@@ -4290,7 +4287,8 @@
             },
             "core-util-is": {
               "version": "1.0.2",
-              "bundled": true,
+              "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz",
+              "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=",
               "dev": true
             },
             "isarray": {
@@ -4322,7 +4320,8 @@
         },
         "realize-package-specifier": {
           "version": "3.0.3",
-          "bundled": true,
+          "resolved": "https://registry.npmjs.org/realize-package-specifier/-/realize-package-specifier-3.0.3.tgz",
+          "integrity": "sha1-0N74gpUrjeP2frpekRmWYScfQfQ=",
           "dev": true
         },
         "request": {
@@ -4714,7 +4713,8 @@
           "dependencies": {
             "unique-slug": {
               "version": "2.0.0",
-              "bundled": true,
+              "resolved": "https://registry.npmjs.org/unique-slug/-/unique-slug-2.0.0.tgz",
+              "integrity": "sha1-22Z258fMBimHj/GWCXx4hVrp9Ks=",
               "dev": true
             }
           }
@@ -5145,7 +5145,8 @@
                 },
                 "spdx-license-ids": {
                   "version": "1.2.0",
-                  "bundled": true,
+                  "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-1.2.0.tgz",
+                  "integrity": "sha1-tUndD2Pct0Whfi6joHQC4OMy0eI=",
                   "dev": true
                 }
               }

+ 0 - 1
package.json

@@ -56,7 +56,6 @@
     "jasmine-core": "2.6.4",
     "jed": "0.5.4",
     "jquery": "2.2.3",
-    "jquery-easing": "0.0.1",
     "jquery.browser": ">=0.1.0",
     "jshint": "^2.9.4",
     "lodash": "4.17.4",

+ 0 - 1
src/config.js

@@ -27,7 +27,6 @@ require.config({
         "jquery":                   "node_modules/jquery/dist/jquery",
         "jquery.noconflict":        "src/jquery.noconflict",
         "jquery.browser":           "node_modules/jquery.browser/dist/jquery.browser",
-        "jquery.easing":            "node_modules/jquery-easing/jquery.easing.1.3.umd", // XXX: Only required for https://conversejs.org website
         "pluggable":                "node_modules/pluggable.js/dist/pluggable",
         "polyfill":                 "src/polyfill",
         "sizzle":                   "node_modules/jquery/sizzle/dist/sizzle",

+ 38 - 0
src/website.js

@@ -0,0 +1,38 @@
+(function () {
+    document.addEventListener("DOMContentLoaded", function(event) { 
+        function scrollTo(element, to, duration, hash) {
+            if (duration <= 0) return;
+            var difference = to - element.scrollTop;
+            var perTick = difference / duration * 10;
+
+            setTimeout(function() {
+                element.scrollTop = element.scrollTop + perTick;
+                if (element.scrollTop === to) {
+                    window.location.hash = hash;
+                    return;
+                }
+                scrollTo(element, to, duration - 10, hash);
+            }, 10);
+        }
+
+        window.addEventListener('scroll', function (ev) {
+            var navbar = document.querySelector(".navbar");
+            var fixed_top = document.querySelector(".navbar-fixed-top");
+            var rect = navbar.getBoundingClientRect();
+            if (rect.top + document.body.scrollTop > 50) {
+                fixed_top.classList.add("top-nav-collapse");
+            } else {
+                fixed_top.classList.remove("top-nav-collapse");
+            }
+        });
+
+        document.querySelectorAll('.page-scroll a').forEach(function (el) {
+            el.addEventListener('click', function (ev) {
+                ev.preventDefault();
+                var hash = this.getAttribute("href")
+                var goal = document.querySelector(hash);
+                scrollTo(document.body, goal.offsetTop, 600, hash);
+            });
+        });
+    });
+})();