davej Posted August 20, 2012 Share Posted August 20, 2012 What happens when you mouse-hover over "More..." on the top bar here? http://www.bbc.co.uk/news/ Even if I apply the style "hidden" the div is still there taking up space, so how are divs added and removed? Thanks Link to comment Share on other sites More sharing options...
niche Posted August 20, 2012 Share Posted August 20, 2012 (edited) By toggling the display property. EDIT: It's super simple: function showDiv(value) { divTest = document.getElementById(value); if (divTest.style.display === "none") { divTest.style.display = ''; } else if (divTest.style.display === '') { divTest.style.display = "none"; } //alert(value); } html: echo '<button class="button2" onclick="showDiv(this.value)" value="companyInfo' . $counterz . '">Company Info</button>';echo '<div id="companyInfo' . $counterz . '" style="display:none;">' . $hours . '</div>'; Edited August 20, 2012 by niche Link to comment Share on other sites More sharing options...
davej Posted August 20, 2012 Author Share Posted August 20, 2012 Ah, thanks! Somehow I never noticed the "none" option there. Excellent! Then there is the matter of animating the height. Style.height isn't working for me. Is there another trick? Thanks! Link to comment Share on other sites More sharing options...
niche Posted August 20, 2012 Share Posted August 20, 2012 Please post your code. Link to comment Share on other sites More sharing options...
davej Posted August 20, 2012 Author Share Posted August 20, 2012 Oh, I had a typo. == rather than = So I wonder if the BBC div is actually an image? <html><head><title>hide abc</title><style type="text/css">div#hide{background-color: yellow;height: 200px;}div#def{background-color: green;height: 200px;}p{text-align:center;}</style><script type="text/javascript">window.onload = function(){$("btn_h").onclick = hide;$("btn_d").onclick = disp;$("btn_a").onclick = animate;}function hide(){if ($("hide").style.visibility=="hidden"){$("hide").style.visibility="visible";}else{$("hide").style.visibility="hidden";}}function disp(){if ($("hide").style.display!="none"){$("hide").style.display="none";}else{$("hide").style.display="";}}function animate(){if ($("hide").style.height!="0px"){//alert('['+$("hide").style.height+']');$("hide").style.height="0px";}else{$("hide").style.height="200px";}}function $(id){return document.getElementById(id);}</script></head><body><a href="#" id="btn_h">hide</a><a href="#" id="btn_d">display</a><a href="#" id="btn_a">animate</a><div id="hide"><p>abc</p></div><div id="def"><p>def</p></div></body></html> Link to comment Share on other sites More sharing options...
justsomeguy Posted August 20, 2012 Share Posted August 20, 2012 Why are you wondering when you could be using your browser's developer tools to inspect the elements and find out for yourself? Link to comment Share on other sites More sharing options...
niche Posted August 20, 2012 Share Posted August 20, 2012 I'm sure you mean "ABC". It's not an img, but could be. Link to comment Share on other sites More sharing options...
davej Posted August 20, 2012 Author Share Posted August 20, 2012 Ok, it's just a div containing a set of unordered lists. But obviously the display:none on the div is only part of the trick. Link to comment Share on other sites More sharing options...
davej Posted August 20, 2012 Author Share Posted August 20, 2012 Why are you wondering when you could be using your browser's developer tools to inspect the elements and find out for yourself? Good question. I'm using Chrome and actually I think Chrome sucks, but yes I can see it's not an image. Link to comment Share on other sites More sharing options...
niche Posted August 20, 2012 Share Posted August 20, 2012 OK, but are you using your developer tools to know that (firebug in firefox)? Coding is much easier with these tools. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 20, 2012 Share Posted August 20, 2012 With Chrome you can right-click anywhere on the page and select Inspect Element to have the developer tools open and highlight that element in the markup, which will also show all of the CSS rules that apply to it. Link to comment Share on other sites More sharing options...
davej Posted August 21, 2012 Author Share Posted August 21, 2012 (edited) With Chrome you can right-click anywhere on the page and select Inspect Element to have the developer tools open and highlight that element in the markup, which will also show all of the CSS rules that apply to it. Yes I eventually did that, but I don't feel very comfortable with Chrome. I'm used to FF but FF was unstable on my machine and there were too many updates coming out constantly. In Chrome how do I find the Javascript? Edited August 21, 2012 by davej Link to comment Share on other sites More sharing options...
niche Posted August 21, 2012 Share Posted August 21, 2012 (edited) See #6. Developer's tools are listed under tools. Edited August 21, 2012 by niche Link to comment Share on other sites More sharing options...
davej Posted August 21, 2012 Author Share Posted August 21, 2012 It's minified. I don't find it readable. */(function(){var f={glow:true},b=/([$^\\\/()|?+*\[\]{}.-])/g,a=navigator.userAgent.toLowerCase(),k="1.7.7",r=0,g=[],m=0,q=[],o=0,s=false,n={VERSION:k,UID:"glow"+Math.floor(Math.random()*(1<<30)),isDomReady:window.gloader&&gloader.isReady,isReady:window.gloader&&gloader.isReady,env:function(){var u=[0,NaN],d=(/opera[\s\/]([\w\.]+)/.exec(a)||u)[1],v=d?NaN:(/msie ([\w\.]+)/.exec(a)||u)[1],x=(/rv:([\w\.]+).*gecko\//.exec(a)||u)[1],e=(/applewebkit\/([\w\.]+)/.exec(a)||u)[1],t=(/khtml\/([\w\.]+)/.exec(a)||u)[1],w=parseFloat;return{gecko:w(x),ie:w(v),opera:w(d),webkit:w(e),khtml:w(t),version:v||x||e||d||t,standardsMode:document.compatMode!="BackCompat"&&(!v||v>=6)};}(),module:function(u){var t=2,w=u.depends[0]||[],d=w.length,e=u.name,v=window.glow;if(u.library[1]!=n.VERSION){throw new Error("Cannot register "+e+": Version mismatch");}if(w[2]){for(;t<d;t++){if(!f[w[t]]){throw new Error("Module "+w[t]+" required before "+e);}}}u.builder(n);f[e]=true;return n;},ready:function(d){if(this.isReady){d();}else{q[o++]=d;}return this;},_readyBlockers:{},_addReadyBlock:function(d){if(!n._readyBlockers[d]){n._readyBlockers[d]=true;n.isReady=false;r++;}return n;},_removeReadyBlock:function(d){if(n._readyBlockers[d]){n._readyBlockers[d]=false;r--;if(!r){n.isReady=true;p();}}return n;},onDomReady:function(d){if(this.isDomReady){d();}else{g[m++]=d;}},lang:{trim:function(d){return d.replace(/^\s*((?:[\S\s]*\S)?)\s*$/,"$1");},toArray:function(e){if(e.constructor==Array){return e;}var u=[],t=0,d=e.length;for(;t<d;t++){u[t]=e[t];}return u;},apply:function(d,t){for(var e in t){d[e]=t[e];}return d;},map:function(e,x,w){if(Array.prototype.map){return Array.prototype.map.call(e,x,w||e);}if(!x.call){throw new TypeError();}var d=e.length,v=[],u=w||e,t=0;for(;t<d;t++){if(t in e){v[t]=x.call(u,e[t],t,e);}}return v;},replace:(function(){var d="g".replace(/g/,function(){return"l";})!="l",e=String.prototype.replace;return function(y,w,t){var z,v,x,u;if(!d||typeof(t)!="function"){return e.call(y,w,t);}if(!(w instanceof RegExp)){z=y.indexOf(w);return z==-1?y:e.call(y,w,t.call(null,w,z,y));}u=[];x=w.lastIndex=0;while((v=w.exec(y))!=null){z=v.index;u[u.length]=y.slice(x,z);u[u.length]=t.apply(null,v);if(w.global){x=w.lastIndex;}else{x=z+v[0].length;break;}}u[u.length]=y.slice(x);return u.join("");};})(),interpolate:function(t,w,u){var d,v,e,x;u=u||{};if(u.escapeHtml){if(!n.dom){throw new Error("glow.lang.interpolate - glow.dom is needed for escapeHtml");}x=n.dom.create("<div></div>");}if(u.delimiter==undefined){d=/\{[^{}]+\}/g;}else{v=u.delimiter.substr(0,1).replace(b,"\\$1");e=u.delimiter.substr(1,1).replace(b,"\\$1")||v;d=new RegExp(v+"[^"+v+e+"]+"+e,"g");}return t.replace(d,function(D){var A=D.slice(1,-1),C=A.split("."),B,z=0,y=C.length;if(A in w){B=w[A];}else{B=w;for(;z<y;z++){if(C[z] in {B=B[C[z]];}else{return D;}}}if(u.escapeHtml){B=x.text(.html();}return B;});},hasOwnProperty:{}.hasOwnProperty?function(d,e){return d.hasOwnProperty(e);}:function(x,y){var u=x[y],w=x.__proto__,t=w?w[y]:{};if(u!==t){return true;}var e=n.lang.hasOwnProperty(w,y),d=w[y]={},v=(x[y]!==d);delete w[y];if(e){w[name]=d;}return v;},extend:function(e,u,d){var t=function(){},v;t.prototype=u.prototype;v=new t();e.prototype=v;v.constructor=e;e.base=u;if(d){n.lang.apply(e.prototype,d);}},clone:function(t){var d,u,e;t=t.valueOf();if(typeof t!=="object"){return t;}else{if(t[0]||t.concat){e=[];d=t.length;while(d--){e[d]=arguments.callee(t[d]);}}else{e={};for(d in t){e[d]=arguments.callee(t[d]);}}return e;}}}},h=n.env,l=document;function c(){n.isDomReady=true;for(var d=0;d<m;d++){g[d]();}}function p(){if(s){return;}s=true;for(var d=0;d<o;){q[d]();d++;if®{break;}}q=q.slice(d);o=o-d;s=false;}(function(){if(n.isDomReady){return;}n._addReadyBlock("glow_domReady");if(h.ie){if(typeof window.frameElement!="undefined"){l.attachEvent("onreadystatechange",function(){if(l.readyState=="complete"){l.detachEvent("onreadystatechange",arguments.callee);c();n._removeReadyBlock("glow_domReady");}});}else{(function(){try{l.documentElement.doScroll("left");}catch(u){setTimeout(arguments.callee,0);return;}c();n._removeReadyBlock("glow_domReady");})();}}else{if(n.env.webkit<525.13&&typeof l.readyState!="undefined"){var e=function(){if(/loaded|complete/.test(l.readyState)){c();n._removeReadyBlock("glow_domReady");}else{setTimeout(e,0);}};e();}else{var t=function(){if(t.fired){return;}t.fired=true;c();n._removeReadyBlock("glow_domReady");};if(l.addEventListener){l.addEventListener("DOMContentLoaded",t,false);}var d=window.onload;window.onload=function(){if(d){d();}t();};}}})();n.isSupported=!(h.ie<6||(h.gecko<1.9&&!/^1\.8\.1/.test(h.version))||h.opera<9||h.webkit<412);if(!n.isSupported){n._addReadyBlock("glow_browserSupport");}if(window.gloader){gloader.library({name:"glow",version:"1.7.7",builder:function(){return n;}});}else{if(window.glow){throw new Error("Glow global object already exists");}else{window.glow=n;}}if(n.ie){try{document.execCommand("BackgroundImageCache",false,true);}catch(j){}}})();/*@cc_on @*//*@if (@_jscript_version > 5.5)@*/(window.gloader||glow).module({name:"glow.i18n",library:["glow","1.7.7"],depends:[["glow","1.7.7"]],builder:function®{var A;var t={l:/^[a-z]$/,lv:/^[a-z]{2,3}$/,s:/^[A-Z][a-z]{3}$/,r:/^[A-Z]{2}|[0-9]{3}$/,v:/^[a-z0-9]{4,}$/};var s=1,k=2,l=4,j=8,p=s+k+l+j,f=s+l+j,x=s+k+j,c=s+j,y=s+k+l,e=s+l,d=s+k;var m={l:s,s:k,r:l,v:j},I=["l","s","r","v"],F={l:0,s:1,r:2,v:3};var C={};var b={};var o=w(document.documentElement.lang||"en")||w("en");function D(K){for(var J in t){if(t[J].test(K)){return J;}}return"";}function w(V){if(!V.split){V="";}var N=V.split("-"),Q=N.length,R=[],K={l:"",s:"",r:"",v:""},J=0,O=J,U=0,P,S;for(var M=0,T=I.length;M<T;M++){O=J;P=I[M];S=F[P];while((D(N[O]).indexOf(P)==-1)&&(O<Q)){O++;}if(O<Q){R[s]=N[O];U+=m[P];K[P]=N[O];N[O]="*";J=O;}}var L=R.join("-").replace(/-+/g,"-");if((L=="")||(L.substring(0,1)=="-")){return false;}else{return{canonical:L,mask:U,subtags:K};}}function g(K,M,J){var L;if((J&~K.mask)==0){L=K.subtags.l;if(k&J){L=L+"-"+K.subtags.s;}if(l&J){L=L+"-"+K.subtags.r;}if(j&J){L=L+"-"+K.subtags.v;}if(M(L)){return L;}}return false;}function a(K,N,J,L){var M;switch(K.mask){case f:if((M=g(K,N,f))){break;}case e:if((M=g(K,N,e))){break;}case p:if((M=g(K,N,p))){break;}case y:if((M=g(K,N,y))){break;}case x:if((M=g(K,N,x))){break;}case d:if((M=g(K,N,d))){break;}case c:if((M=g(K,N,c))){break;}case s:if((M=g(K,N,s))){break;}default:if(N("en")){M="en";}else{M=null;}}if(M==null){L();}else{J(M);}}function v(L){var J=o,K=w(L);if(K){o=K;o.next=J;}return A;}function H(){o=o.next||o;return A;}function B(){return o.canonical;}function h(M,L,Q){var J=w(L),P,O,K;if(J){P=C[J.canonical]=C[J.canonical]||{};O=P[M]=P[M]||{};K=b[M]=b[M]||{};for(var N in Q){O[N]=Q[N];K[N]=1;}}return A;}function E(K,J){var L={},S=J||{},N=b[K]||{},O=o,T,Q;function P(U){if(C[u]&&C[u][K]&&C[u][K][Q]){return true;}else{return false;}}function R(U){L[Q]=C[u][K][Q];}function M(){L[Q]="[Error! No "+K+"."+Q+" on "+O.canonical+"]";}if(S.locale!=undefined){T=w(S.locale);if(T){O=T;}}for(Q in N){a(O,P,R,M);}return L;}function G(K,L){for(var J in L){h(J,K,L[J]);}return A;}function u(L,M){var K=M||{},J=w(L);if(K.module){if(K.label){return q(J,K.module,K.label);}else{return n(J,K.module);}}else{return z(J);}return null;}function q(L,N,M){var J;function P(Q){if(C[Q]&&C[Q][N]&&C[Q][N][M]){return true;}else{return false;}}function O(Q){J=Q;}function K(){J="**error** - no negotiated value exists";}a(L,P,O,K);return J;}function n(L,O){var K=b[O]||{},N={},M;function Q®{if(C[R]&&C[R][O]&&C[R][O][M]){return true;}else{return false;}}function P®{N[M]=R;}function J(){N[M]="**error** - no negotiated value exists";}for(M in K){a(L,Q,P,J);}return N;}function z(K){var N={},M,L;function P(Q){if(C[Q]&&C[Q][M]&&C[Q][M][L]){return true;}else{return false;}}function O(Q){N[M][L]=Q;}function J(){N[M][L]="**error** - no negotiated value exists";}for(M in {N[M]={};for(L in b[M]){a(K,P,O,J);}}return N;}r.i18n=A={setLocale:v,revertLocale:H,getLocale:B,addLocaleModule:h,getLocaleModule:E,addLocalePack:G,checkLocale:u};G("en",{PROPERTIES:{LANGUAGE:"English",DIR:"ltr"}});}});(window.gloader||glow).module({name:"glow.dom",library:["glow","1.7.7"],depends:[],builder:function(u){var n=u.env,k=u.lang,s={tagName:/^(\w+|\*)/,combinator:/^\s*([>]?)\s*/,classNameOrId:(n.webkit<417)?new RegExp("^([\\.#])((??![\\.#\\[:\\s\\\\]).|\\\\.)+)"):/^([\.#])((?:[^\.#\[:\\\s]+|\\.)+)/},X=/([$^\\\/()|?+*\[\]{}.-])/g,B={},R={checked:"checked","class":"className",disabled:"disabled","for":"htmlFor",maxlength:"maxLength"},c={checked:true,disabled:true},ah={maxlength:function®{return r.toString()=="2147483647"?undefined:r;}},ad=1,x="_unique"+u.UID,ai="_uniqueData"+u.UID,ag=1,L=[],I={black:0,silver:12632256,gray:8421504,white:16777215,maroon:8388608,red:16711680,purple:8388736,fuchsia:16711935,green:32768,lime:65280,olive:8421376,yellow:16776960,navy:128,blue:255,teal:32896,aqua:65535,orange:16753920},D=/height|top/,t=/^rgb\(([\d\.]+)(%?),\s*([\d\.]+)(%?),\s*([\d\.]+)(%?)/i,A=/^(?:(width|height)|(border-(top|bottom|left|right)-width))$/,C=/width|height|top$|bottom$|left$|right$|spacing$|indent$|font-size/,T,d,K,H,aa=window,l=document,V,G,w,P=l.createElement("div"),y=[1,"<table>","</table>"],ab=[0,"",""],O=n.webkit<526?[0,"","</div>",true]:[1,"b<div>","</div>"],a=[3,"<table><tbody><tr>","</tr></tbody></table>"],E={caption:y,thead:y,th:a,colgroup:y,tbody:y,tr:[2,"<table><tbody>","</tbody></table>"],td:a,tfoot:y,option:[1,"<select>","</select>"],legend:[1,"<fieldset>","</fieldset>"],link:O,script:O,style:O};if(n.ie){window.attachEvent("onunload",function(){P=null;});}u.ready(function(){V=l.body;G=l.documentElement;}); [...etc...] Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2012 Share Posted August 21, 2012 Indeed. Even if you used a tool to reformat that it would still be obfuscated with the single-letter variables. Link to comment Share on other sites More sharing options...
davej Posted August 21, 2012 Author Share Posted August 21, 2012 So after looking around a bit I think it may be the JQuery function "slidedown" <!DOCTYPE html><html><head> <style>div { background:#de9a44; margin:3px; width:80px;height:40px; display:none; float:left; }</style> <script src="http://code.jquery.com/jquery-latest.js"></script></head><body> Click me!<div>aaa</div><div>bbb</div><div>ccc</div><script>$(document.body).click(function () {if ($("div:first").is(":hidden")) {$("div").slideDown("slow");} else {$("div").hide();}});</script></body></html> Can I go somewhere to look at the underlying Javascript inside JQuery? Thanks Link to comment Share on other sites More sharing options...
justsomeguy Posted August 21, 2012 Share Posted August 21, 2012 You can download the source for jQuery at their website and go through it there. The jQuery source file is also listed in the script tag. Link to comment Share on other sites More sharing options...
davej Posted August 22, 2012 Author Share Posted August 22, 2012 Oh yeah. I expected that code to be compressed and unreadable like the other was. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now