Results 1 to 7 of 7

Thread: Ajax Tabs Content script - Hide external link

  1. #1
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Ajax Tabs Content script - Hide external link

    1) Script Title: Ajax Tabs Content script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...axtabscontent/

    3) Describe problem: Hide external link

    I would like to hide external link when they go with mouse over tabs.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    In the script replace the expandtab:function(tabref) with this one:

    Code:
    	expandtab:function(tabref){
    		var relattrvalue=tabref.getAttribute("rel").split('::')[0];
    		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
    		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
    		if (relattrvalue=="#default")
    			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
    		else if (relattrvalue=="#iframe")
    			this.iframedisplay(tabref.getAttribute("rel").split('::')[1], this.contentdivid)
    		else
    			ddajaxtabs.connect(tabref.getAttribute("rel").split('::')[1], this)
    		this.expandrevcontent(associatedrevids)
    		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
    			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("href")==tabref.getAttribute("href"))? "selected" : ""
    		}
    		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
    			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
    		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
    	},
    and replace the init:function(automodeperiod) with this one:

    Code:
    	init:function(automodeperiod){
    		var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
    		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
    		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
    		this.automodeperiod=automodeperiod || 0
    		this.defaultHTML=document.getElementById(this.contentdivid).innerHTML
    		for (var i=0; i<this.tabs.length; i++){
    			this.tabs[i].tabposition=i //remember position of tab relative to its peers
    			if (this.tabs[i].getAttribute("rel")){
    				var tabinstance=this
    				this.tabs[i].rel = this.tabs[i].rel + '::' + this.tabs[i].href;
    				this.tabs[i].href = 'javascript:ajaxTabs();';
    				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
    				this.tabs[i].onclick=function(){
    					tabinstance.expandtab(this)
    					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
    					return false
    				}
    				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
    					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
    				}
    				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
    					selectedtab=i //Selected tab index, if found
    				}
    			}
    		} //END for loop
    		if (selectedtab!=-1) //if a valid default selected tab index is found
    			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
    		else //if no valid default selected index found
    			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
    		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
    			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
    		}
    	} //END int() function
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Thanks for help, but I don't think it's working. With this modification external site doesn't show.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    You may have to unescape the rev value to which I had added the href to conceal it at various points. I tested the code with same site links both iframe and AJAX methods and it was fine locally, but live links and their surrounding text sometimes get escaped automatically by the browser. If that's the problem, let's try:

    Code:
    expandtab:function(tabref){
    		var relattrvalue=unescape(tabref.getAttribute("rel")).split('::')[0];
    		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
    		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
    		if (relattrvalue=="#default")
    			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
    		else if (relattrvalue=="#iframe")
    			this.iframedisplay(unescape(tabref.getAttribute("rel")).split('::')[1], this.contentdivid)
    		else
    			ddajaxtabs.connect(unescape(tabref.getAttribute("rel")).split('::')[1], this)
    		this.expandrevcontent(associatedrevids)
    		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
    			this.getselectedClassTarget(this.tabs[i]).className=(this.tabs[i].getAttribute("href")==tabref.getAttribute("href"))? "selected" : ""
    		}
    		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
    			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
    		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
    	},
    for the expandtab:function(tabref) function.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Lucifix (08-18-2008)

  6. #5
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Almost done

    But now the selected tab is not showing as selected.

    You can check it here:
    http://www.slo-foto.net/galerija.html

  7. #6
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    OK, this should be the final revisions. The href was used in some cases to determine the selected tab. I've changed that in the expandtab to use the unescaped rel, and in the init function to check before it changes the href. Use these functions in place of the ones of the same names:

    Code:
    expandtab:function(tabref){
    		var relattrvalue=unescape(tabref.getAttribute("rel")).split('::')[0];
    		//Get "rev" attr as a string of IDs in the format ",john,george,trey,etc," to easy searching through
    		var associatedrevids=(tabref.getAttribute("rev"))? ","+tabref.getAttribute("rev").replace(/\s+/, "")+"," : ""
    		if (relattrvalue=="#default")
    			document.getElementById(this.contentdivid).innerHTML=this.defaultHTML
    		else if (relattrvalue=="#iframe")
    			this.iframedisplay(unescape(tabref.getAttribute("rel")).split('::')[1], this.contentdivid)
    		else
    			ddajaxtabs.connect(unescape(tabref.getAttribute("rel")).split('::')[1], this)
    		this.expandrevcontent(associatedrevids)
    		for (var i=0; i<this.tabs.length; i++){ //Loop through all tabs, and assign only the selected tab the CSS class "selected"
    			this.getselectedClassTarget(this.tabs[i]).className=(unescape(this.tabs[i].getAttribute("rel"))==unescape(tabref.getAttribute("rel")))? "selected" : ""
    		}
    		if (this.enabletabpersistence) //if persistence enabled, save selected tab position(int) relative to its peers
    			ddajaxtabs.setCookie(this.tabinterfaceid, tabref.tabposition)
    		this.setcurrenttabindex(tabref.tabposition) //remember position of selected tab within hottabspositions[] array
    	},
    Code:
    	init:function(automodeperiod){
    		var persistedtab=ddajaxtabs.getCookie(this.tabinterfaceid) //get position of persisted tab (applicable if persistence is enabled)
    		var selectedtab=-1 //Currently selected tab index (-1 meaning none)
    		var selectedtabfromurl=this.urlparamselect(this.tabinterfaceid) //returns null or index from: tabcontent.htm?tabinterfaceid=index
    		this.automodeperiod=automodeperiod || 0
    		this.defaultHTML=document.getElementById(this.contentdivid).innerHTML
    		for (var i=0; i<this.tabs.length; i++){
    			this.tabs[i].tabposition=i //remember position of tab relative to its peers
    			if (this.tabs[i].getAttribute("rel")){
    				var tabinstance=this
    				if (selectedtabfromurl==i || this.enabletabpersistence && selectedtab==-1 && parseInt(persistedtab)==i || !this.enabletabpersistence && selectedtab==-1 && this.getselectedClassTarget(this.tabs[i]).className=="selected"){
    					selectedtab=i //Selected tab index, if found
    				}
    				this.tabs[i].rel = this.tabs[i].rel + '::' + this.tabs[i].href;
    				this.tabs[i].href = 'javascript:ajaxTabs();';
    				this.hottabspositions[this.hottabspositions.length]=i //store position of "hot" tab ("rel" attr defined) relative to its peers
    				this.tabs[i].onclick=function(){
    					tabinstance.expandtab(this)
    					tabinstance.cancelautorun() //stop auto cycling of tabs (if running)
    					return false
    				}
    				if (this.tabs[i].getAttribute("rev")){ //if "rev" attr defined, store each value within "rev" as an array element
    					this.revcontentids=this.revcontentids.concat(this.tabs[i].getAttribute("rev").split(/\s*,\s*/))
    				}
    			}
    		} //END for loop
    		if (selectedtab!=-1) //if a valid default selected tab index is found
    			this.expandtab(this.tabs[selectedtab]) //expand selected tab (either from URL parameter, persistent feature, or class="selected" class)
    		else //if no valid default selected index found
    			this.expandtab(this.tabs[this.hottabspositions[0]]) //Just select first tab that contains a "rel" attr
    		if (parseInt(this.automodeperiod)>500 && this.hottabspositions.length>1){
    			this.autoruntimer=setInterval(function(){tabinstance.autorun()}, this.automodeperiod)
    		}
    	} //END int() function
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  8. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Lucifix (08-18-2008)

  9. #7
    Join Date
    Feb 2008
    Posts
    14
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

    Hurey! You've done it

    Thanks alot!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •