View Full Version : Switch Content Script - how to put plus/minus image alignment issue

12-05-2012, 09:51 PM
The Switch Content script comes with an X or Check image to display the collapsed status. My issue is that I want the X and Check to show after my title text, not before it. Is there a way to easily do that? I've scanned through the .js with no avail.



12-06-2012, 06:25 AM
Untested (on iphone) but maybe a float:right style in the img tag?

<script type="text/javascript">
bobexample.setStatus('<img src="open.png" style="float:right" /> ', '<img src="close.png" style="float:right" /> ')

12-06-2012, 03:58 PM
switchcontent.prototype.togglestatus=function(header, status){
if (typeof this.statusOpen!="undefined")

var instanceOf=this
this.collectElementbyClass(this.className) //Get all headers and its corresponding content based on shared class name of contents
if (this.headers.length==0) //If no headers are present (no contents to switch), just exit
//If admin has changed number of days to persist from current cookie records, reset persistence by deleting cookie
if (this.persistType=="days" && (parseInt(switchcontent.getCookie(this.className+"_dtrack"))!=this.persistDays))
switchcontent.setCookie(this.className+"_d", "", -1) //delete cookie
// Get ids of open contents below. Four possible scenerios:
// 1) Session only persistence is enabled AND corresponding cookie contains a non blank ("") string
// 2) Regular (in days) persistence is enabled AND corresponding cookie contains a non blank ("") string
// 3) If there are contents that should be enabled by default (even if persistence is enabled and this IS the first page load)
// 4) Default to no contents should be expanded on page load ("" value)
var opencontents_ids=(this.persistType=="session" && switchcontent.getCookie(this.className)!="")? ','+switchcontent.getCookie(this.className)+',' : (this.persistType=="days" && switchcontent.getCookie(this.className+"_d")!="")? ','+switchcontent.getCookie(this.className+"_d")+',' : (this.expandedindices)? ','+this.expandedindices+',' : ""
for (var i=0; i<this.headers.length; i++){ //BEGIN FOR LOOP
if (typeof this.ajaxheaders["header"+i]!="undefined"){ //if this is an Ajax header
this.headers[i].ajaxstatus='waiting' //two possible statuses: "waiting" and "loaded"
if (typeof this.statusOpen!="undefined"){ //If open/ closing HTML indicator is enabled/ set
this.headers[i].innerHTML=this.headers[i].innerHTML+'<span class="status"></span>' //Add a span element to original HTML to store indicator
if (opencontents_ids.indexOf(','+i+',')!=-1){ //if index "i" exists within cookie string or default-enabled string (i=position of the content to expand)
this.expandcontent(this.headers[i]) //Expand each content per stored indices (if ""Collapse Previous" is set, only one content)
if (this.collapsePrev) //If "Collapse Previous" set
this.prevHeader=this.headers[i] //Indicate the expanded content's corresponding header as the last clicked on header (for logic purpose)
else //else if no indices found in stored string
this.contractcontent(this.headers[i]) //Contract each content by default
switchcontent.dotask(window, function(){instanceOf.rememberpluscleanup()}, "unload") //Call persistence method onunload

12-06-2012, 06:23 PM
That worked like a charm vwphillips. Thank you both for helping out on this one, it was a real time saver for me! Cheers to your health!