danIT Posted March 12, 2009 Posted March 12, 2009 Im using this Javascript in a Moodle Theme, it currently uses images to create rounded corners by inserting some classes. Moodle is broken down into three sections, left - Middle - right, and this Javascript references them all. I want the javascript to only be applied to the Middle section, can anyone see how this might be accomplished by modifying the below script: <br /> /* <![CDATA[ */<br /> var CSSClass={};CSSClass.is=function(e,c){if(typeof e=="string")e=document.getElementById(e);var classes=e.className;if(!classes)return false;if(classes==c)return true;return e.className.search("\\b"+c+"\\b")!=-1;};CSSClass.add=function(e,c){if(typeof e=="string")e=document.getElementById(e);if(CSSClass.is(e,c))return;if(e.className)c=" "+c;e.className+=c;};CSSClass.remove=function(e,c){if(typeof e=="string")e=document.getElementById(e);e.className=e.className.replace(new RegExp("\\b"+c+"\\b\\s*","g"),"");};<br /> <br /> var script = {<br /> corrections: function () {<br /> if (top.user) {<br /> top.document.getElementsByTagName('frameset')[0].rows = "117,30%,0,200";<br /> }<br /> <br /> // check for layouttabel and add layouttable classes to body<br /> var tagname = 'nolayouttable';<br /> if (document.getElementById('middle-column')) {<br /> var lc = document.getElementById('left-column');<br /> var rc = document.getElementById('right-column');<br /> if ( lc && rc ) {<br /> tagname = 'haslayouttable rightandleftcolumn';<br /> } else if (lc) {<br /> tagname = 'haslayouttable onlyleftcolumn';<br /> } else if (rc) {<br /> tagname = 'haslayouttable onlyrightcolumn';<br /> } else {<br /> tagname = 'haslayouttable onlymiddlecolumn';<br /> }<br /> } else if(document.getElementsByTagName('body')[0].id.substring(0,9)=='calendar-') {<br /> tagname='haslayouttable onlyrightcolumn';<br /> }<br /> <br /> function setbodytag (tagname) {<br /> var bd = document.getElementsByTagName('body')[0];<br /> if (bd) {<br /> CSSClass.add(bd, tagname);<br /> } else {<br /> setTimeout(function() { setbodytag(tagname) }, 30);<br /> }<br /> }<br /> <br /> setTimeout(function() { setbodytag(tagname) }, 30);<br /> },<br /> <br /> init: function() {<br /> script.corrections();<br /> }<br /> };<br /> /* ]]> */<br /> Any ideas?
lightinthedark Posted March 12, 2009 Posted March 12, 2009 There's some deep stuff happening elsewhere I suspect, but my first attempt would be to replace: var lc = document.getElementById('left-column'); var rc = document.getElementById('right-column'); if ( lc && rc ) { tagname = 'haslayouttable rightandleftcolumn'; } else if (lc) { tagname = 'haslayouttable onlyleftcolumn'; } else if (rc) { tagname = 'haslayouttable onlyrightcolumn'; } else { tagname = 'haslayouttable onlymiddlecolumn'; } with tagname = 'haslayouttable onlymiddlecolumn'; From the look of it, that's what defines which columns get the special treatment. Hello :-Dave
danIT Posted March 13, 2009 Author Posted March 13, 2009 I;ve tried that without sucess, infact if i delete the contents of the file it still applies the style and i have no idea how?
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