r114184 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114183‎ | r114184 | r114185 >
Date:21:04, 19 March 2012
Author:jdlrobson
Status:ok
Tags:
Comment:
commit latest versions of minified

in preparation for deployment
Modified paths:
  • /trunk/extensions/MobileFrontend/javascripts/beta_opensearch.min.js (modified) (history)
  • /trunk/extensions/MobileFrontend/javascripts/references.min.js (added) (history)
  • /trunk/extensions/MobileFrontend/javascripts/toggle.min.js (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/javascripts/beta_opensearch.min.js
@@ -1 +1 @@
2 -MobileFrontend.opensearch=(function(){var c="/api.php",m=-1,d=500,z=15,q,l=document.getElementById("search"),t=document.getElementById("sq"),a=document.getElementById("searchbox"),r=document.getElementById("content"),o=document.getElementById("footer"),x=document.getElementById("clearsearch"),k=false,n=MobileFrontend.utils;c=MobileFrontend.setting("scriptPath")+c;function s(){results.style.display="none"}function h(){if(navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPad/i)){var u=n('meta[name="viewport"]');if(u){u=u[0];u.content="width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0";n(document.body).bind("gesturestart",function(){u.content="width=device-width, initial-scale=1.0"})}}}h();l.onfocus=function(){var u,A;a=document.getElementById("searchbox");t=document.getElementById("sq");r=document.getElementById("content");o=document.getElementById("footer");h();if(!k){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("a");u.setAttribute("href","#");u.setAttribute("id","remove-results");n(u).bind("click",y);A=document.createElement("div");A.setAttribute("id","left-arrow");u.appendChild(A);t.insertBefore(u,t.firstChild)}k=true}};function y(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(k){k=false}if(x){x.style.display="none"}}function b(A){var u;if(!A){A=window.event}if(A.target){u=A.target}else{if(A.srcElement){u=A.srcElement}}if(u.nodeType===3){u=u.parentNode}A.cancelBubble=true;A.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&results){results.innerHTML=""}}else{s()}}window.onload=function(){n(l).bind("keyup",function(){clearTimeout(m);q=this.value;if(q.length<1){results.innerHTML=""}else{q=encodeURIComponent(q);m=setTimeout(function(){j(q)},d)}})};function j(u){url=c+"?action=opensearch&limit="+z+"&namespace=0&format=xml&search="+u;n.ajax({url:url,success:function(A){p(g(A))}})}function g(D){var E=[],A,B,C,u=D.getElementsByTagName("Item");for(A=0;A<u.length;A++){B=u[A];C={label:B.getElementsByTagName("Text")[0].textContent,value:B.getElementsByTagName("Url")[0].textContent};E.push(C)}return E}function i(A){var u=document.getElementById("search");if(u){u.value=A+" ";u.focus();j(u.value)}}function e(B){var A=document.createTextNode(B),u=document.createElement("div");u.appendChild(A);return u.innerHTML}function w(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function p(J){var D=document.getElementById("results"),F,E,C=e(document.getElementById("search").value),B,I,A,u,G,H;D.style.display="block";if(l){l.focus()}if(!J||J.length<1){D.innerHTML='<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'}else{if(D.firstChild){D.removeChild(D.firstChild)}F=document.createElement("ul");F.className="suggestions-results";D.appendChild(F);B=function(){var K=this.parentNode.getAttribute("title");i(K)};for(E=0;E<J.length;E++){I=J[E];u=document.createElement("li");G=document.createElement("a");u.setAttribute("title",I.label);u.className="suggestions-result";H=document.createTextNode("+");G.appendChild(H);G.className="sq-val-update";n(G).bind("click",B);u.appendChild(G);G=document.createElement("a");G.setAttribute("href",I.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));G.className="search-result-item";H=document.createTextNode(I.label);G.appendChild(H);u.appendChild(G);F.appendChild(u);A=w(C);G.innerHTML=G.innerHTML.replace(new RegExp("("+A+")","ig"),"<strong>$1</strong>")}}}function f(){var D=document.getElementById("clearsearch"),u=document.getElementById("search");function B(){if(D){if(u.value.length>0){D.style.display="block"}else{D.style.display="none"}}}function A(E){u.value="";D.style.display="none";if(E){E.preventDefault()}}function C(){u.select()}n(D).bind("mousedown",A);n(u).bind("keyup",B);n(u).bind("click",C)}function v(){var u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b}v();f();return{init:v,initClearSearch:f,writeResults:p,createObjectArray:g,removeResults:y}}());
\ No newline at end of file
 2+MobileFrontend.opensearch=(function(){var c="/api.php",m=-1,d=500,A=15,q,k=document.getElementById("search"),a=document.getElementById("searchbox"),r=document.getElementById("content"),o=document.getElementById("footer"),y=document.getElementById("clearsearch"),j=false,x,w,n=MobileFrontend.utils;c=MobileFrontend.setting("scriptPath")+c;function s(){results.style.display="none"}x=n('meta[name="viewport"]');if(x){x=x[0];w=x.getAttribute("content")}function h(){if(x){x.setAttribute("content","minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0");n(document.body).bind("gesturestart",function(){x.setAttribute("content",w)})}}h();k.onfocus=function(){var u,B;a=document.getElementById("searchbox");header=document.getElementById("header");r=document.getElementById("content");o=document.getElementById("footer");h();if(!j){MobileFrontend.utils(document.body).addClass("full-screen-search");u=document.getElementById("remove-results");if(!u){u=document.createElement("a");u.setAttribute("href","#");u.setAttribute("id","remove-results");n(u).bind("click",z);B=document.createElement("div");B.setAttribute("id","left-arrow");u.appendChild(B);header.insertBefore(u,header.firstChild)}j=true}};function z(){MobileFrontend.utils(document.body).removeClass("full-screen-search");if(j){j=false}if(y){y.style.display="none"}}function b(B){var u;if(!B){B=window.event}if(B.target){u=B.target}else{if(B.srcElement){u=B.srcElement}}if(u.nodeType===3){u=u.parentNode}B.cancelBubble=true;B.stopPropagation();if(u.className==="suggestion-result"||u.className==="search-result-item"||u.className==="suggestions-result"||u.className==="sq-val-update"||u.id==="results"||u.id==="search"||u.id==="searchbox"||u.id==="sq"||u.id==="placeholder"||u.id==="clearsearch"||u.tagName==="BODY"){if(u.id==="clearsearch"&&results){results.innerHTML=""}}else{s()}}var l=function(u){u.preventDefault();clearTimeout(m);q=k.value;if(q.length<1){results.innerHTML=""}else{q=encodeURIComponent(q);m=setTimeout(function(){i(q)},d)}};n(k).bind("keyup",l);n(document.getElementById("searchForm")).bind("submit",l);n(k).bind("blur",l);function i(u){url=c+"?action=opensearch&limit="+A+"&namespace=0&format=xml&search="+u;n.ajax({url:url,success:function(B){if(n(document.body).hasClass("full-screen-search")){p(g(B))}}})}function g(E){var F=[],B,C,D,u=E.getElementsByTagName("Item");for(B=0;B<u.length;B++){C=u[B];D={label:C.getElementsByTagName("Text")[0].textContent,value:C.getElementsByTagName("Url")[0].textContent};F.push(D)}return F}function e(C){var B=document.createTextNode(C),u=document.createElement("div");u.appendChild(B);return u.innerHTML}function v(u){return u.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")}function p(J){var D=document.getElementById("results"),F,E,C=e(document.getElementById("search").value),I,B,u,G,H;D.style.display="block";if(k){k.focus()}if(!J||J.length<1){D.innerHTML='<ul class="suggestions-results" title="No Results"><li class="suggestions-result">No Results</li></div>'}else{if(D.firstChild){D.removeChild(D.firstChild)}F=document.createElement("ul");F.className="suggestions-results";D.appendChild(F);for(E=0;E<J.length;E++){I=J[E];u=document.createElement("li");u.setAttribute("title",I.label);u.className="suggestions-result";G=document.createElement("a");G.setAttribute("href",I.value.replace(/^(?:\/\/|[^\/]+)*\//,"/"));G.className="search-result-item";H=document.createTextNode(I.label);G.appendChild(H);u.appendChild(G);F.appendChild(u);B=v(C);G.innerHTML=G.innerHTML.replace(new RegExp("("+B+")","ig"),"<strong>$1</strong>")}}}function f(){var E=document.getElementById("clearsearch"),u=document.getElementById("search");function C(){if(E){if(u.value.length>0){E.style.display="block"}else{E.style.display="none"}}}function B(F){u.value="";E.style.display="none";F.preventDefault()}function D(){u.select()}n(E).bind("mousedown",B);n(u).bind("keyup",C);n(u).bind("click",D)}function t(){var u=document.getElementById("results");u.onmousedown=b;document.body.onmousedown=b;document.body.ontouchstart=b;u.ontouchstart=b}t();f();return{init:t,initClearSearch:f,writeResults:p,createObjectArray:g,removeResults:z}}());
\ No newline at end of file
Index: trunk/extensions/MobileFrontend/javascripts/references.min.js
@@ -0,0 +1 @@
 2+if(typeof jQuery!=="undefined"){MobileFrontend.references=(function(d){var b,f,a={};f=window.location.hash.substr(1).match(/refspeed:([0-9]*)/);a.animationSpeed=f?parseInt(f[1],10):500;f=window.location.hash.substr(1).match(/refanimation:([a-z]*)/);a.animation=f?f[1]:null;function c(){var g={};d("ol.references li").each(function(h,j){g[d(j).attr("id")]={html:d(j).html(),label:h+1}});return g}b=function(){var g=d("#mf-references").outerHeight();d("#mf-references").css({top:(window.innerHeight+window.pageYOffset)-g,bottom:"auto",position:"absolute"})};d(document).scroll(b);function e(){d('<div id="mf-references"><div></div></div>').hide().appendTo(document.body);var l=function(){var m;j=null;if(a.animation==="none"){d("#mf-references").hide()}else{if(a.animation==="slide"){m=window.innerHeight+window.pageYOffset;d("#mf-references").show().animate({top:m},a.animationSpeed)}else{d("#mf-references").fadeOut(a.animationSpeed)}}},j;d("<button>close</button>").click(l).appendTo("#mf-references");d(".mw-cite-backlink a").click(l);var k,i,g,h=c();d("sup a").unbind("click").click(function(m){var o,n;g=d(this).attr("href");k=g&&g.charAt(0)==="#"?h[g.substr(1,g.length)]:null;if(!d("#mf-references").is(":visible")||j!==g){j=g;if(k){i="<h3>["+k.label+"]</h3>"+k.html}else{i=d("<a />").text(d(this).text()).attr("href",g).appendTo("<div />").parent().html()}d("#mf-references div").html(i);b();if(a.animation==="none"){d("#mf-references").show()}else{if(a.animation==="slide"){o=window.innerHeight+window.pageYOffset;n=d("#mf-references").outerHeight();d("#mf-references").show().css({top:o}).animate({top:o-n},a.animationSpeed)}else{d("#mf-references").fadeIn(a.animationSpeed)}}}else{l()}m.preventDefault()})}e()})(jQuery)};
\ No newline at end of file
Index: trunk/extensions/MobileFrontend/javascripts/toggle.min.js
@@ -1 +1 @@
2 -MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var l,f,n,m,h=a(".section_heading");window.wm_toggle_section=b;m=a(".section_heading button");for(l=0;l<m.length;l++){a(m[l]).remove()}function k(){var i=this.id?this.id.split("_")[1]:-1;if(i>-1){b(i)}}function g(p){var o,i;o=document.createElement("button");i=document.createTextNode(MobileFrontend.message(p?"expand-section":"collapse-section"));o.className=p?"show":"hide";o.appendChild(i);return o}if(!h){h=[]}else{a(document.body).addClass("togglingEnabled")}for(l=0;l<h.length;l++){n=h[l];n.removeAttribute("onclick");n.insertBefore(g(true),n.firstChild);n.insertBefore(g(false),n.firstChild);a(n).bind("click",k)}function j(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}j();for(f=document.getElementsByTagName("a"),l=0;l<f.length;l++){a(f[l]).bind("click",j)}}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&h.style.display!=="block"){f=parseInt(h.id.split("_")[1],10);b(f)}}}function b(g){var f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;if(a(f).hasClass("openSection")){a(f).removeClass("openSection")}else{a(f).addClass("openSection")}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k){k.style.display=k.style.display==="block"?"none":"block"}}}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}})();
\ No newline at end of file
 2+MobileFrontend.toggle=(function(){var a=MobileFrontend.utils;function c(){var l,f,n,m,h=a(".section_heading");window.wm_toggle_section=b;m=a(".section_heading button");for(l=0;l<m.length;l++){a(m[l]).remove()}function k(){var i=this.id?this.id.split("_")[1]:-1;if(i!==-1){b(i)}}function g(p){var o,i;o=document.createElement("button");i=document.createTextNode(MobileFrontend.message(p?"expand-section":"collapse-section"));o.className=p?"show":"hide";o.appendChild(i);return o}if(!h){h=[]}else{a(document.body).addClass("togglingEnabled")}for(l=0;l<h.length;l++){n=h[l];n.removeAttribute("onclick");n.insertBefore(g(true),n.firstChild);n.insertBefore(g(false),n.firstChild);a(n).bind("click",k)}function j(){var i=this.hash||document.location.hash;if(i.indexOf("#")===0){e(i)}}j();for(f=document.getElementsByTagName("a"),l=0;l<f.length;l++){a(f[l]).bind("click",j)}}function e(i){var g=document.getElementById(i.substr(1)),h,f;if(g){h=g;while(h&&!a(h).hasClass("content_block")&&!a(h).hasClass("section_heading")){h=h.parentNode}if(h&&!a(h).hasClass("openSection")){f=parseInt(h.id.split("_")[1],10);b(f)}}}function b(g){var f=document.getElementById("section_"+g),l=f.getElementsByTagName("button"),h,j,k;if(a(f).hasClass("openSection")){a(f).removeClass("openSection")}else{a(f).addClass("openSection")}for(h=0,d=["content_","anchor_"];h<=1;h++){k=document.getElementById(d[h]+g);if(k&&a(k).hasClass("openSection")){a(k).removeClass("openSection")}else{a(k).addClass("openSection")}}}c();return{wm_reveal_for_hash:e,wm_toggle_section:b,init:c}})();
\ No newline at end of file

Follow-up revisions

RevisionCommit summaryAuthorDate
r114207MFT r114177, r114184, r114190, r114191, r114193awjrichards22:28, 19 March 2012

Status & tagging log