Log in

View Full Version : Issue with JS drop down menus in threads


patracy
11-14-2011, 03:47 PM
Hello,

I'm having a time trying to clean up a mess. Viewing the forum homepage, the JS dropdown menus work fine. But when inside a thread, it seems that JS doesn't work at all. I've looked at the sources of the pages and found a difference related to the CSS settings.

From the main page that works:
<link rel="stylesheet" type="text/css" href="http://www.steelsoldiers.com/clientscript/vbulletin_important.css?v=386" />


<!-- / CSS Stylesheet -->

<script type="text/javascript" src="http://www.steelsoldiers.com/clientscript/yui/yahoo-dom-event/yahoo-dom-event.js?v=386"></script>

<script type="text/javascript" src="http://www.steelsoldiers.com/clientscript/yui/connection/connection-min.js?v=386"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "";
var SECURITYTOKEN = "1321285999-a572b3981598d4bb6bb14e22f54c0825e0095a80";
var IMGDIR_MISC = "http://test.steelsoldiers.com/images/misc";
var vb_disable_ajax = parseInt("0", 10);
// -->
</script>
<script type="text/javascript" src="http://www.steelsoldiers.com/clientscript/vbulletin_global.js?v=386"></script>
<script type="text/javascript" src="http://www.steelsoldiers.com/clientscript/vbulletin_menu.js?v=386"></script>



From source of a displayed thread that JS doesn't work in:
<link rel="stylesheet" type="text/css" href="clientscript/vbulletin_important.css?v=386" />


<!-- / CSS Stylesheet -->

<script type="text/javascript" src="clientscript/yui/yahoo-dom-event/yahoo-dom-event.js?v=386"></script>
<script type="text/javascript" src="clientscript/yui/connection/connection-min.js?v=386"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "";
var SECURITYTOKEN = "1321286040-71721bc72cd47589f19d40f0a1d95ea58f373c37";
var IMGDIR_MISC = "http://test.steelsoldiers.com/images/misc";
var vb_disable_ajax = parseInt("0", 10);
// -->
</script>
<script type="text/javascript" src="clientscript/vbulletin_global.js?v=386"></script>
<script type="text/javascript" src="clientscript/vbulletin_menu.js?v=386"></script>



I'm not certain where this is contained at looking through the templates. I'd like to update the second to match the first hopefully to resolve the JS issues.

Lynne
11-14-2011, 04:13 PM
Are they different styles? Try looking at the headinclude template.

patracy
11-14-2011, 04:34 PM
These are from the same style.

Looking at the headinclude it looks like it's using references:

<!-- CSS Stylesheet -->
$style[css]
<if condition="is_browser('opera') AND !is_browser('opera', '8.0.1')">
<style type="text/css" id="vbulletin_opera8fix_css">
ul, ol { padding-$stylevar[left]:20px; }
</style>
</if>
<if condition="$show['editor_css']">
$editor_css
</if>
<!-- / CSS Stylesheet -->

<script type="text/javascript" src="$stylevar[yuipath]/yahoo-dom-event/yahoo-dom-event.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript" src="$stylevar[yuipath]/connection/connection-min.js?v=$vboptions[simpleversion]"></script>
<script type="text/javascript">
<!--
var SESSIONURL = "$session[sessionurl_js]";
var SECURITYTOKEN = "$bbuserinfo[securitytoken]";
var IMGDIR_MISC = "$stylevar[imgdir_misc]";
var vb_disable_ajax = parseInt("$vboptions[disable_ajax]", 10);
// -->
</script>
<script type="text/javascript" src="clientscript/vbulletin_global.js?v=$vboptions[simpleversion]"></script>
<if condition="$show['popups']"><script type="text/javascript" src="clientscript/vbulletin_menu.js?v=$vboptions[simpleversion]"></script></if>


To make matters worse, it seems that sometimes threads allow JS to function properly. But most of the time not. The main navbar and thread tool JS menus are what's being affected.

From the home of the forum, the navbar menu works fine. But as soon as I go into a post, it seems that all the JS fails to function.

--------------- Added 1321292175 at 1321292175 ---------------

I've also created a new style to test and the problem persists in the same manner there as well.

--------------- Added 1321293603 at 1321293603 ---------------

Looking in FF, I see some errors when I navigate a post.

Error: YAHOO is not defined
Source File: http://www.steelsoldiers.com/clientscript/vbulletin_global.js?v=386
Line: 11

Error: vBulletin is undefined
Source File: http://www.steelsoldiers.com/clientscript/vbulletin_menu.js?v=386
Line: 11

Error: $ is not defined
Source File: http://www.steelsoldiers.com/steel-soldiers-rally/72989-2011-wa-state-mini-rally-5-a.html
Line: 346

Error: vBmenu is undefined
Source File: http://www.steelsoldiers.com/steel-soldiers-rally/72989-2011-wa-state-mini-rally-5-a.html
Line: 545

Error: PHP is undefined
Source File: http://www.steelsoldiers.com/clientscript/vbulletin_multi_quote.js?v=386
Line: 11

I would post the page source, but it exceeds the limit.

--------------- Added 1321298593 at 1321298593 ---------------

vBulletin is undefined error.
vBulletin.events.systemInit.subscribe(function(){i f(vBulletin.elements.vB_Lightbox_Container){for(va r B=0;B<vBulletin.elements.vB_Lightbox_Container.length;B+ +){var A=vBulletin.elements.vB_Lightbox_Container[B];init_postbit_lightbox(A[0],A[1])}vBulletin.elements.vB_Lightbox_Container=null}}) ;var Lightboxes=new Array();var Lightbox_overlay=null;var Lightbox_overlay_select_handler=null;var Lightbox_event_default=null;var Lightbox_current=null;var Lightbox_map={};function vB_Lightbox(B,C,D,A){this.minborder=100;this.mindi mension=50;this.event_click=1;this.event_hover=2;t his.click_triggered=false;this.events_enabled=fals e;this.element=B;this.timeout=null;this.imageloade r=null;this.status=0;this.active=false;this.ajax_r eq=null;this.cursor=null;this.link=null;this.date= null;this.time=null;this.name=null;this.html=null; this.loader_link=null;this.loader_height=null;this .loader_width=null;this.lightbox=null;this.closebt n=null;this.img=null;this.uniqueid=C;this.containe rid=D;if(A&this.event_hover){YAHOO.util.Event.on(this.element ,"mouseover",this.countdown,this,true);YAHOO.util.Event.on(thi s.element,"mouseout",this.halt,this,true)}if(A&this.event_click){YAHOO.util.Event.on(this.element ,"click",this.image_click,this,true)}}vB_Lightbox.prototyp e.set_status=function(A,B){console.log("vB_Lightbox :: Set status = %d (%s)",A,B);this.status=A};vB_Lightbox.prototype.check_s tatus=function(A){if(this.status>=A){return true}else{console.warn("Checked status for %d, found %d",A,this.status);return false}};vB_Lightbox.prototype.countdown=function(A ){if(!this.active){this.set_status(1,"countdown");this.cursor=YAHOO.util.Dom.getStyle(this.element ,"cursor");this.element.style.cursor="wait";this.click_triggered=false;this.timeout=setTimeou t("Lightboxes['"+this.uniqueid+"'].load_lightbox();",1500)}};vB_Lightbox.prototype.halt=function(A){if (this.status<2){this.set_status(0,"halt")}clearTimeout(this.timeout);this.element.style.cu rsor=this.cursor};vB_Lightbox.prototype.image_clic k=function(A){if(A.ctrlKey||A.shiftKey){return true}this.click_triggered=true;this.load_lightbox( A)};vB_Lightbox.prototype.load_lightbox=function(E ){if(this.check_status(0)&&!YAHOO.util.Connect.isCallInProgress(this.ajax_req )){this.set_status(2,"load_lightbox 1");if(Lightbox_current&&Lightbox_current.loader_link){Lightbox_current.img .src=Lightbox_current.loader_link;Lightbox_current .img.width=Lightbox_current.loader_width;Lightbox_ current.img.height=Lightbox_current.loader_height; center_element(Lightbox_current.lightbox)}if(E){YA HOO.util.Event.stopEvent(E)}if(this.timeout){clear Timeout(this.timeout);this.element.style.cursor=th is.cursor}if(this.html==null){var A=this.element.getAttribute("href");var B=A.substr(A.indexOf("?")+1)+"&securitytoken="+SECURITYTOKEN+"&ajax=1&uniqueid="+this.uniqueid;if(Lightbox_map[this.containerid][this.uniqueid+1]==null){B=B+"&last=1"}if(Lightbox_map[this.containerid][this.uniqueid-1]==null){B=B+"&first=1"}B=B+"&total="+Lightbox_map[this.containerid].size();B=B+"&current="+(Lightbox_map[this.containerid].find(this.uniqueid)+1);this.show_overlay();try{th is.ajax_req=YAHOO.util.Connect.asyncRequest("POST",A,{success:this.handle_ajax_response,failure:this .handle_ajax_error,scope:this,timeout:vB_Default_T imeout},B)}catch(E){var D=A.substr(0,A.indexOf("?"));var C;if(C=D.match(/\/([^/]*attachment\.php)$/)){this.ajax_req=YAHOO.util.Connect.asyncRequest("POST",C[1],{success:this.handle_ajax_response,failure:this.h andle_ajax_error,scope:this,timeout:vB_Default_Tim eout},B)}else{if(this.click_triggered){window.loca tion=A}}}}else{this.set_status(3,"load_lightbox 2");this.show_lightbox()}}};vB_Lightbox.prototype.ha ndle_ajax_error=function(A){vBulletin_AJAX_Error_H andler(A);if(this.click_triggered){window.location =this.element.getAttribute("href")}};vB_Lightbox.prototype.handle_ajax_response=fun ction(C){if(!this.check_status(2)){return }if(C.responseXML){var E=C.responseXML.getElementsByTagName("error");if(E.length){this.set_status(0,"handle_ajax_response - error");if(E[0].firstChild.nodeValue=="notimage"){console.warn("Attempted to load non-image (.%s) into lightbox. Aborted.",C.responseXML.getElementsByTagName("extension")[0].firstChild.nodeValue)}else{alert(E[0].firstChild.nodeValue.replace(/<(\/|[a-z]+)[^>]+>/g,""))}return false}var B=C.responseXML.getElementsByTagName("link");if(B.length){this.set_status(3,"handle_ajax_response - success");this.show_overlay();this.link=B[0].firstChild.nodeValue;this.imageloader=new Image();YAHOO.util.Event.on(this.imageloader,"load",this.show_lightbox,this,true);var D=new Array("date","time","name","html");for(var A=0;A<D.length;A++){this[D[A]]=C.responseXML.getElementsByTagName(D[A])[0].firstChild.nodeValue}this.lightbox=document.body. appendChild(string_to_node(this.html));this.closeb tn=YAHOO.util.Dom.get("lightboxbutton"+this.uniqueid);YAHOO.util.Event.on(this.closebtn,"click",this.hide_lightbox,this,true);YAHOO.util.Event.on (this.closebtn,"mouseover",this.highlight_btn,this.closebtn,true);YAHOO.util .Event.on(this.closebtn,"mouseout",this.highlight_btn,this.closebtn,true);this.prevb tn=YAHOO.util.Dom.get("lightboxprevbutton"+this.uniqueid);YAHOO.util.Event.on(this.prevbtn,"click",this.prev_lightbox,this,true);YAHOO.util.Event.on (this.prevbtn,"mouseover",this.highlight_btn,this.prevbtn,true);YAHOO.util. Event.on(this.prevbtn,"mouseout",this.highlight_btn,this.prevbtn,true);this.nextbt n=YAHOO.util.Dom.get("lightboxnextbutton"+this.uniqueid);YAHOO.util.Event.on(this.nextbtn,"click",this.next_lightbox,this,true);YAHOO.util.Event.on (this.nextbtn,"mouseover",this.highlight_btn,this.nextbtn,true);YAHOO.util. Event.on(this.nextbtn,"mouseout",this.highlight_btn,this.nextbtn,true);YAHOO.util. Event.on(YAHOO.util.Dom.get("lightboxlink"+this.uniqueid),"click",this.hide_lightbox,this,true);this.img=YAHOO.util .Dom.get("lightboximg"+this.uniqueid);this.loader_link=this.img.src;this .loader_width=this.img.width;this.loader_height=th is.img.height;this.imageloader.src=this.link;this. show_lightbox()}else{if(this.click_triggered){wind ow.location=imagelink}}}else{if(this.click_trigger ed){window.location=imagelink}}};vB_Lightbox.proto type.show_overlay=function(){if(this.check_status( 2)){var C=fetch_viewport_info();if(Lightbox_overlay==null) {Lightbox_overlay=document.createElement("div");Lightbox_overlay.id="Lightbox_overlay";var A={display:"none",position:"absolute",top:"0px",backgroundColor:"#000000",opacity:0.85,zIndex:10};if(document.dir=="rtl"){A.right="0px"}else{A.left="0px"}for(var B in A){if(YAHOO.lang.hasOwnProperty(A,B)){YAHOO.util.D om.setStyle(Lightbox_overlay,B,A[B])}}Lightbox_overlay=document.body.appendChild(Ligh tbox_overlay);Lightbox_overlay_select_handler=new vB_Select_Overlay_Handler(Lightbox_overlay)}YAHOO. util.Dom.setStyle(Lightbox_overlay,"display","");YAHOO.util.Dom.setStyle(Lightbox_overlay,"width",C.w+"px");YAHOO.util.Dom.setStyle(Lightbox_overlay,"height",C.h+"px");YAHOO.util.Dom.setXY(Lightbox_overlay,[C.x,C.y]);Lightbox_overlay_select_handler.hide()}};vB_Ligh tbox.prototype.show_lightbox=function(){if(this.ch eck_status(3)){if(Lightbox_current){Lightbox_curre nt.hide_lightbox(false,this,true)}this.show_overla y();if(!this.imageloader.complete&&this.imageloader.readyState!="complete"){YAHOO.util.Event.removeListener(this.imageloader ,"load",this.show_lightbox);YAHOO.util.Event.on(this.imag eloader,"load",this.show_lightbox,this,true)}else{this.img.src=t his.link;this.resize_image();YAHOO.util.Dom.setSty le(this.closebtn,"display","")}YAHOO.util.Dom.setStyle(this.lightbox,"display","");YAHOO.util.Dom.setStyle(this.lightbox,"zIndex",11);if(Lightbox_map[this.containerid].size()==1){YAHOO.util.Dom.setStyle(this.prevbtn,"display","none");YAHOO.util.Dom.setStyle(this.nextbtn,"display","none")}Lightbox_current=this;this.center_lightbox();thi s.active=true;this.enable_events()}};vB_Lightbox.p rototype.hide_lightbox=function(B,C,A){if(B&&B.type=="keydown"&&B.keyCode!=27){return }this.set_status(0,"hide_lightbox");this.disable_events();this.active=false;YAHOO.ut il.Dom.setStyle(this.lightbox,"display","none");if(!A){YAHOO.util.Dom.setStyle(Lightbox_overlay,"display","none")}Lightbox_overlay_select_handler.show();Lightbox_ current=null};vB_Lightbox.prototype.next_lightbox= function(B){var A=null;if(Lightbox_map[this.containerid][this.uniqueid+1]!=null){A=Lightboxes[this.uniqueid+1]}else{A=Lightboxes[Lightbox_map[this.containerid].first()]}A.load_lightbox()};vB_Lightbox.prototype.prev_lig htbox=function(B){var A=null;if(Lightbox_map[this.containerid][this.uniqueid-1]!=null){A=Lightboxes[this.uniqueid-1]}else{A=Lightboxes[Lightbox_map[this.containerid].last()]}A.load_lightbox()};vB_Lightbox.prototype.highligh t_btn=function(){var B=YAHOO.util.Dom.getStyle(this,"color");var A=YAHOO.util.Dom.getStyle(this,"background-color");var D,C;D=((B=="white"||B.toLowerCase()=="#ffffff")?"black":"white");C=((A=="black"||A.toLowerCase()=="#000000")?"white":"black");YAHOO.util.Dom.setStyle(this,"color",D);YAHOO.util.Dom.setStyle(this,"background-color",C)};vB_Lightbox.prototype.center_lightbox=functio n(){center_element(this.lightbox)};vB_Lightbox.pro totype.handle_viewport_change=function(){this.resi ze_image();this.center_lightbox();this.show_overla y()};vB_Lightbox.prototype.handle_viewport_change_ ie=function(){setTimeout("Lightboxes['"+this.uniqueid+"'].handle_viewport_change();",100)};vB_Lightbox.prototype.resize_image=function (){var C=fetch_viewport_info();var A=this.imageloader.width;var B=this.imageloader.height;if(A>C.w-this.minborder){A=C.w-this.minborder;A=(A<this.mindimension?this.mindimension:A);B=Math.ceil (this.imageloader.height*(A/this.imageloader.width))}if(B>C.h-this.minborder){B=C.h-this.minborder;B=(B<this.mindimension?this.mindimension:B);A=Math.ceil (this.imageloader.width*(B/this.imageloader.height))}this.img.setAttribute("width",A);this.img.setAttribute("height",B);this.img.setAttribute("title",this.name+"; \n"+this.imageloader.width+" x "+this.imageloader.height+" (@"+Math.ceil(A/this.imageloader.width*100)+"%)");if(A<this.imageloader.width||B<this.imageloader.height){console.info("vB_Lightbox :: Image original size: %dx%d, resizing to %dx%d",this.imageloader.width,this.imageloader.height,A, B)}};vB_Lightbox.prototype.enable_events=function( ){if(!this.events_enabled){YAHOO.util.Event.on(win dow,"resize",(is_ie?this.handle_viewport_change_ie:this.handle _viewport_change),this,true);YAHOO.util.Event.on(w indow,"scroll",this.hide_lightbox,this,true);YAHOO.util.Event.on (window,"keydown",this.hide_lightbox,this,true);YAHOO.util.Event.on (Lightbox_overlay,"click",this.hide_lightbox,this,true);this.events_enabled =true}};vB_Lightbox.prototype.disable_events=funct ion(){if(this.events_enabled){YAHOO.util.Event.rem oveListener(window,"resize",(is_ie?this.handle_viewport_change_ie:this.handle _viewport_change));YAHOO.util.Event.removeListener (window,"scroll",this.hide_lightbox);YAHOO.util.Event.removeListen er(window,"keydown",this.hide_lightbox);YAHOO.util.Event.removeListen er(Lightbox_overlay,"click",this.hide_lightbox);this.events_enabled=false}};v B_Lightbox_Container=function(){};vB_Lightbox_Cont ainer.prototype.size=function(){var B=0;for(var A in this){if(YAHOO.lang.hasOwnProperty(this,A)){B++}}r eturn B};vB_Lightbox_Container.prototype.first=function( ){for(var A in this){if(YAHOO.lang.hasOwnProperty(this,A)){return A}}};vB_Lightbox_Container.prototype.last=function (){var B;for(var A in this){if(YAHOO.lang.hasOwnProperty(this,A)){B=A}}r eturn B};vB_Lightbox_Container.prototype.find=function(C ){var B=0;for(var A in this){if(YAHOO.lang.hasOwnProperty(this,A)){if(A== C){return B}B++}}return -1};function is_lightbox_element(A){return(typeof (A.getAttribute("rel"))=="string"&&A.getAttribute("rel").match(/Lightbox[_]?(\d*)?/))}function init_postbit_lightbox(D,C,G){var A=userAgent.match(/applewebkit\/([0-9]+)/);if(A&&A[1]<522){return }if(Lightbox_event_default===null){Lightbox_event_ default=C}if(typeof (C)=="undefined"||C===false){C=(Lightbox_event_default?Lightbox_ev ent_default:1+2)}var E=YAHOO.util.Dom.getElementsBy(is_lightbox_element ,"a",D);for(var B=0;B<E.length;B++){var F=Lightboxes.length;var H=E[B].getAttribute("rel").match(/Lightbox[_]?(\d*)?/).pop();H=(H?H:0);Lightboxes[F]=new vB_Lightbox(E[B],F,H,C);if(!Lightbox_map[H]||G){Lightbox_map[H]=new vB_Lightbox_Container();G=false}Lightbox_map[H][F]=F}};

From page source
vBulletin.register_control("vB_Lightbox_Container", "posts", 1);

PHP in undefined
function mq_init(D){var C=fetch_cookie("vbulletin_multiquote");if(C!=null&&C!=""){C=C.split(",")}else{C=new Array()}var E;var A=fetch_tags(D,"img");for(var B=0;B<A.length;B++){if(A[B].id&&A[B].id.substr(0,3)=="mq_"){E=A[B].id.substr(3);A[B].onclick=function(F){return mq_click(this.id.substr(3))};change_mq_image(E,(PH P.in_array(E,C)>-1?true:false))}}}function mq_click(F){var D=fetch_cookie("vbulletin_multiquote");var B=new Array();var E=false;if(D!=null&&D!=""){D=D.split(",");for(C in D){if(!YAHOO.lang.hasOwnProperty(D,C)){continue}if (D[C]==F){E=true}else{if(D[C]){B.push(D[C])}}}}change_mq_image(F,(E?false:true));if(!E){B.pu sh(F);if(typeof mqlimit!="undefined"&&mqlimit>0){for(var C=0;C<(B.length-mqlimit);C++){var A=B.shift();change_mq_image(A,false)}}}set_cookie("vbulletin_multiquote",B.join(","));return false}function change_mq_image(C,B){var A=fetch_object("mq_"+C);if(A){if(B==true){A.src=A.src.replace(/\/multiquote_off\.([a-zA-Z0-9]+)$/,"/multiquote_on.$1")}else{A.src=A.src.replace(/\/multiquote_on\.([a-zA-Z0-9]+)$/,"/multiquote_off.$1")}}}mq_init(fetch_object("posts"));

Yahoo is not defined error:
var link_spans = YAHOO.util.Dom.getElementsByClassName("top_link", "span");
That's found in the file /clientscript/special_section.js

--------------- Added 1321300941 at 1321300941 ---------------

Pages JS will work from:

/search.php
/forum.php
/misc.php

It's random it seems when viewing threads under /forum.php

--------------- Added 1321301876 at 1321301876 ---------------

Ok, I see something else. The threads that allow JS to work on are the direct post links.

Example:
www.site.com/showthread.php?t=12345

The ones that don't work are:
www.site.com/forumname/threadname.html

--------------- Added 1321305669 at 1321305669 ---------------

I believe this might be due to vbseo which I've disabled because the install failed?

--------------- Added 1321307996 at 1321307996 ---------------

Looks like I'm making progress, reloaded vbseo and I *think* things are working correctly now.

Lynne
11-14-2011, 09:06 PM
I was going to suggest disabling all modifications, which includes vbseo, to see if you still had the same problem, but it looks like that is what you are trying now.

patracy
11-14-2011, 09:16 PM
I was going to suggest disabling all modifications, which includes vbseo, to see if you still had the same problem, but it looks like that is what you are trying now.

Yup, that's how I've spent the afternoon. Issue is now resolved with a reload of vbseo.