]> git.immae.eu Git - github/shaarli/Shaarli.git/commitdiff
Removed jQuery from almost all pages
authorSebastien SAUVAGE <sebsauvage@sebsauvage.net>
Wed, 25 Sep 2013 19:27:50 +0000 (21:27 +0200)
committerSebastien SAUVAGE <sebsauvage@sebsauvage.net>
Wed, 25 Sep 2013 19:27:50 +0000 (21:27 +0200)
jQuery has been removed from all pages, except those who really require
it (like autocomplete in link edition).
Immediate gain: All pages weight 286 kb LESS !   \o/
Highlighting in search results has also been temporarly removed (and
will be re-implemented).

inc/jquery.highlight.js [deleted file]
tpl/changetag.html
tpl/editlink.html
tpl/includes.html
tpl/linklist.html
tpl/page.footer.html
tpl/picwall.html

diff --git a/inc/jquery.highlight.js b/inc/jquery.highlight.js
deleted file mode 100644 (file)
index 9dcf3c7..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * jQuery Highlight plugin
- *
- * Based on highlight v3 by Johann Burkard
- * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
- *
- * Code a little bit refactored and cleaned (in my humble opinion).
- * Most important changes:
- *  - has an option to highlight only entire words (wordsOnly - false by default),
- *  - has an option to be case sensitive (caseSensitive - false by default)
- *  - highlight element tag and class names can be specified in options
- *
- * Usage:
- *   // wrap every occurrance of text 'lorem' in content
- *   // with <span class='highlight'> (default options)
- *   $('#content').highlight('lorem');
- *
- *   // search for and highlight more terms at once
- *   // so you can save some time on traversing DOM
- *   $('#content').highlight(['lorem', 'ipsum']);
- *   $('#content').highlight('lorem ipsum');
- *
- *   // search only for entire word 'lorem'
- *   $('#content').highlight('lorem', { wordsOnly: true });
- *
- *   // don't ignore case during search of term 'lorem'
- *   $('#content').highlight('lorem', { caseSensitive: true });
- *
- *   // wrap every occurrance of term 'ipsum' in content
- *   // with <em class='important'>
- *   $('#content').highlight('ipsum', { element: 'em', className: 'important' });
- *
- *   // remove default highlight
- *   $('#content').unhighlight();
- *
- *   // remove custom highlight
- *   $('#content').unhighlight({ element: 'em', className: 'important' });
- *
- *
- * Copyright (c) 2009 Bartek Szopka
- *
- * Licensed under MIT license.
- *
- */
-
-jQuery.extend({
-    highlight: function (node, re, nodeName, className) {
-        if (node.nodeType === 3) {
-            var match = node.data.match(re);
-            if (match) {
-                var highlight = document.createElement(nodeName || 'span');
-                highlight.className = className || 'highlight';
-                var wordNode = node.splitText(match.index);
-                wordNode.splitText(match[0].length);
-                var wordClone = wordNode.cloneNode(true);
-                highlight.appendChild(wordClone);
-                wordNode.parentNode.replaceChild(highlight, wordNode);
-                return 1; //skip added node in parent
-            }
-        } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
-                !/(script|style)/i.test(node.tagName) && // ignore script and style nodes
-                !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
-            for (var i = 0; i < node.childNodes.length; i++) {
-                i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
-            }
-        }
-        return 0;
-    }
-});
-
-jQuery.fn.unhighlight = function (options) {
-    var settings = { className: 'highlight', element: 'span' };
-    jQuery.extend(settings, options);
-
-    return this.find(settings.element + "." + settings.className).each(function () {
-        var parent = this.parentNode;
-        parent.replaceChild(this.firstChild, this);
-        parent.normalize();
-    }).end();
-};
-
-jQuery.fn.highlight = function (words, options) {
-    var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
-    jQuery.extend(settings, options);
-    
-    if (words.constructor === String) {
-        words = [words];
-    }
-    words = jQuery.grep(words, function(word, i){
-      return word != '';
-    });
-    words = jQuery.map(words, function(word, i) {
-      return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
-    });
-    if (words.length == 0) { return this; };
-
-    var flag = settings.caseSensitive ? "" : "i";
-    var pattern = "(" + words.join("|") + ")";
-    if (settings.wordsOnly) {
-        pattern = "\\b" + pattern + "\\b";
-    }
-    var re = new RegExp(pattern, flag);
-    
-    return this.each(function () {
-        jQuery.highlight(this, re, settings.element, settings.className);
-    });
-};
-
index b0bd0d064b9aa6282c1f99642322431269fc207b..b22bddea98f7c169e63c4c52804c8c2ee4425f54 100644 (file)
@@ -1,6 +1,8 @@
 <!DOCTYPE html>
 <html>
-<head>{include="includes"}</head>
+<head>{include="includes"}
+{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
+</head>
 <body onload="document.changetag.fromtag.focus();">
 <div id="pageheader">
        {include="page.header"}
 <script language="JavaScript">function confirmDeleteTag() { var agree=confirm("Are you sure you want to delete this tag from all links ?"); if (agree) return true ; else return false ; }</script>
 </div>
 {include="page.footer"}
+{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
+<script language="JavaScript">
+$(document).ready(function()
+{
+    $('#fromtag').autocomplete({source:'{$source}?ws=singletag',minLength:1});
+});
+</script>
+{/if}
 </body>
 </html>
\ No newline at end of file
index ad549137de3147849aed62632c3af3621fd091cb..4a2c30cc400e0ab6242d7e38fd0ca7c696f72618 100644 (file)
@@ -1,6 +1,8 @@
 <!DOCTYPE html>
 <html>
-<head>{include="includes"}</head>
+<head>{include="includes"}
+{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
+</head>
 <body
 {if condition="$link.title==''"}onload="document.linkform.lf_title.focus();"
 {elseif condition="$link.description==''"}onload="document.linkform.lf_description.focus();"
        </div>
 </div>
 {include="page.footer"}
+{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
+<script language="JavaScript">
+$(document).ready(function()
+{
+    $('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});
+});
+</script>
+{/if}
 </body>
 </html>
\ No newline at end of file
index e0ad00d551d7a226711817452b36b45b07fa0383..2b61f1e1479b49dff81641d728c3457c8d149b06 100644 (file)
@@ -7,4 +7,3 @@
 <link href="images/favicon.ico#" rel="shortcut icon" type="image/x-icon" />
 <link type="text/css" rel="stylesheet" href="inc/shaarli.css?version={$version|urlencode}#" />
 {if condition="is_file('inc/user.css')"}<link type="text/css" rel="stylesheet" href="inc/user.css?version={$version}#" />{/if}
-{if="empty($GLOBALS['disablejquery'])"}<script src="inc/jquery.min.js#"></script><script src="inc/jquery-ui.min.js#"></script>{/if}
index bce3fa9fcc551a4a34c78ae143a46041e921f641..ddc38cb0ae141ebb37b201d9ba096be4b4617e76 100644 (file)
@@ -68,7 +68,6 @@
     {include="page.footer"} 
 
 <script language="JavaScript">
-
 // Remove any displayed QR-Code
 function remove_qrcode()
 { 
index 3aa47ba651aa8241e2e72b5acf2d06215af3459d..8e5869c567711d12aec0b6c3aac17782aabe93bf 100644 (file)
@@ -7,24 +7,3 @@
 {if="isLoggedIn()"}
 <script language="JavaScript">function confirmDeleteLink() { var agree=confirm("Are you sure you want to delete this link ?"); if (agree) return true ; else return false ; }</script>
 {/if}
-
-{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
-<script language="JavaScript">
-$(document).ready(function()
-{
-    $('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});
-    $('#searchtags').autocomplete({source:'{$source}?ws=tags',minLength:1});
-    $('#fromtag').autocomplete({source:'{$source}?ws=singletag',minLength:1});
-});
-</script>
-{/if}
-
-{if="empty($GLOBALS['disablejquery']) && isset($_GET['searchterm'])"}
-<script src="inc/jquery.highlight.js#"></script>
-<script language="JavaScript">
-$(document).ready(function()
-{
-       $('#linklist li').highlight("{$search_crits}");
-});
-</script>
-{/if}
\ No newline at end of file
index 631e0866b4c4c5f03ae60d0adfb79efea891cccb..b78e260966bba1ee39f21ef46bd82053baa00252 100644 (file)
@@ -2,7 +2,9 @@
 <html>
 <head>{include="includes"}
 {if="empty($GLOBALS['disablejquery'])"}        
-       <script src="inc/jquery.lazyload.min.js#"></script>
+<script src="inc/jquery.min.js#"></script>
+<script src="inc/jquery-ui.min.js#"></script>
+<script src="inc/jquery.lazyload.min.js#"></script>
 {/if}
 </head>
 <body>