diff --git a/local/ac.js b/local/ac.js index d1bf73f7..199fb592 100644 --- a/local/ac.js +++ b/local/ac.js @@ -50,7 +50,7 @@ function search(e, ui) { location.href = url_prefix + _qp + encodeURIComponent(ui.item.value).replace(/%2F/g,'/'); } -$().ready(function() { +function attachAutocomplete() { if (init_inputform('go','ac_goto')) $('#ac_goto').autocomplete({ source: titleindex, delay: 100, @@ -59,7 +59,10 @@ $().ready(function() { location.href = url_prefix + _qp + encodeURIComponent(ui.item.value).replace(/%2F/g,'/'); } }); -}); +} + +if (window.addEventListener) window.addEventListener("load",attachAutocomplete,false); +else if (window.attachEvent) window.attachEvent("onload",attachAutocomplete); })(); // vim:et:sts=4:sw=4: diff --git a/local/js/i18n.js b/local/js/i18n.js index 1f05c788..5f045c49 100644 --- a/local/js/i18n.js +++ b/local/js/i18n.js @@ -28,6 +28,7 @@ readLanguage = function(domain) { var js = document.createElement('script'); js.type = 'text/javascript'; js.src = _url_prefix + '/local/js/locale/' + lang.substr(0,2) + '/' + domain + '.js'; + js.defer = true; js.onreadystatechange = function () { if (this.readyState == 'complete') { loadLanguage(); diff --git a/local/mobile.js b/local/mobile.js index e8df380d..1b0ea02d 100644 --- a/local/mobile.js +++ b/local/mobile.js @@ -256,7 +256,7 @@ function init_images() { } // onload -if (jQuery) +if (typeof jQuery != 'undefined') $(document).ready(function() { init_images(); }); else if (window.addEventListener) diff --git a/plugin/Clip.php b/plugin/Clip.php index a532f8c4..f5f23430 100644 --- a/plugin/Clip.php +++ b/plugin/Clip.php @@ -156,10 +156,6 @@ function showImage(url) { }; } -if (url) { - showImage(url); -} - function postBase64(base64, name) { var postdata = 'action=clip&name=' + name + '&value=' + encodeURIComponent(base64); HTTPPost("$url_save", postdata, function(ret) { @@ -168,7 +164,12 @@ function postBase64(base64, name) { }); } -$(document).ready(function() { +$(function() { + +if (url) { + showImage(url); +} + $("#clipPlugin").on('paste', function(e) { var clipData = (e.clipboardData || e.originalEvent.clipboardData) if (!clipData) @@ -197,6 +198,7 @@ function postBase64(base64, name) { /*]]>*/ \n JS; + $formatter->jqReady = true; $png_url="$imgpath.png"; diff --git a/plugin/JME.php b/plugin/JME.php index 58d49249..ed9a783d 100644 --- a/plugin/JME.php +++ b/plugin/JME.php @@ -80,7 +80,7 @@ function macro_JME($formatter,$value) { $id = $cid + 0; return << + EOF; + $formatter->jqReady = true; + $submit_btn=''; $cancel_btn=''; diff --git a/plugin/Keywords.php b/plugin/Keywords.php index 3f447c47..cfe3ec5f 100644 --- a/plugin/Keywords.php +++ b/plugin/Keywords.php @@ -369,7 +369,8 @@ function macro_Keywords($formatter,$value,$options=array()) { $out = preg_replace('/&/',urlencode('&'),$out).""; $_prefix=qualifiedUrl("$DBInfo->url_prefix/applets/TagCloud"); - $formatter->register_javascripts(array("$_prefix/jquery.tagcanvas.js")); + $formatter->register_javascripts(""); + $formatter->jqReady = true; return << /*link_tag($formatter->page_urlname,"?$arg=...",'...', 'onClick="return daysago(this)"'); - $script=""; + $script=""; $btnlist=$msg[0].' '.$msg[1]; $btnlist=$script."
\n".$btnlist."
\n"; @@ -1263,7 +1263,7 @@ function update_bookmark(time) { $js = << /**/ JS; + $formatter->jqReady = true; $rc_id++; } else if ($use_js and $rctype == 'board') { $js.= <<*/ \n JS; - - $formatter->register_javascripts(''); + $formatter->jqReady = true; + $formatter->register_javascripts(''); return << diff --git a/wiki.php b/wiki.php index 839f6fa6..7c55fbf5 100644 --- a/wiki.php +++ b/wiki.php @@ -257,7 +257,7 @@ function kbd_handler($prefix = '') { FrontPage= "$Config[frontpage]"; /*]]>*/ -\n +\n EOS; } @@ -1911,6 +1911,34 @@ function __construct($page="",$options=array()) { # recursive footnote regex $this->footrule='\[\*[^\[\]]*((?:[^\[\]]++|\[(?13)\])*)\]'; + register_shutdown_function(array(&$this,'close_javascripts')); + } + + function close_javascripts() { + if (!empty($this->jqReady)) + echo << +/**/ +\n +EOJS; + $this->jqReady = false; } /** @@ -4832,6 +4860,10 @@ function send_header($header="",$options=array()) { JSHEAD; diff --git a/wikilib.php b/wikilib.php index 07bb9b00..54a8e265 100644 --- a/wikilib.php +++ b/wikilib.php @@ -4337,12 +4337,13 @@ function macro_RandomPage($formatter, $value = '', $params = array()) { $myid = sprintf("randomPage%02d", $id); $id++; $url = $formatter->link_url('', "?action=randompage/ajax&value=".$number); + $formatter->jqReady = true; return << EOF; @@ -5159,7 +5160,7 @@ function macro_PageCount($formatter, $value = '', $options = array()) { $js = << /**/ JS; + $formatter->jqReady = true; } $redirects = 0;