/* Expandable Drop Down Ticker * Author: Dynamic Drive at http://www.dynamicdrive.com/ * Visit http://www.dynamicdrive.com/ for full source code * Last Edited: Jan 25th, 2010 */ var expandticker={ buttonhtml: '', //HTML of "expand" button buttonoffset: [5, -10], //offset of button from lower left edge of ticker //No need to edit beyond here dsetting: {snippetlength:30, manual:false, timers: {rotatepause:6000, fxduration:600}}, effectfuncts: ['fadeIn', 'slideDown'], fetchajaxcontent:function($, s){ window.status+='x' clearTimeout(s.playtimer) //clear timers and remove $button, $menu if fetchajaxcontent() is being called more than once clearTimeout(s.pausetimer) clearTimeout(s.refreshtimer) if (s.$button){ s.$button.remove() s.$menu.remove() } s.$ticker.html("(Re)Fetching Ticker Contents...") $.ajax({ url: s.remotecontent[0], error:function(ajaxrequest){ s.$ticker.html('Error fetching content.
Server Response: '+ajaxrequest.responseText) }, success:function(content){ s.$ticker.html(content) expandticker.setup($, s) if (s.remotecontent[1]>5000) //5 secs minimum time allowed between updates s.refreshtimer=setTimeout(function(){expandticker.fetchajaxcontent($, s)}, s.remotecontent[1]) else if (s.remotecontent[1]>0) //if value is NOT 0 (0=never refetch) alert("Please Enter a value larger than 5 (sec) for the time between Ajax updates") } }) }, getmsgtitles:function(s){ var titlearray=[] for (var i=0; i') for (var i=0; i').html((i+1)+". "+titles[i]).wrapInner('')) } $menu.append($lis).hide().unbind('click').click(function(e){ //go to particular message when menu title is clicked on if (e.target.tagName=="A"){ clearTimeout(s.playtimer) s.curmsg=parseInt(e.target.getAttribute('data-pos')) expandticker.selectmsg($, s, s.curmsg) if (!s.manual) s.playtimer=setTimeout(function(){expandticker.rotatemsg($, s)}, s.timers.rotatepause) e.preventDefault() } }) $menu.appendTo(document.body) $menu.data('state', 'closed') //indicate menu is currently closed s.$menu=$menu //remember $menu s.$menulis=$lis //remember $menu LIs }, positionbutton:function($, s){ var toffset=s.$ticker.offset() var buttonpos=[toffset.left+this.buttonoffset[0], toffset.top+s.$ticker.outerHeight()+this.buttonoffset[1]] s.$button.css({left:buttonpos[0], top:buttonpos[1]}) }, addexpandbutton:function($, s){ s.$button=$(this.buttonhtml).css({position:'absolute'}).appendTo(document.body) //create expand button, add it to page, and remember it this.positionbutton($, s) this.adddropmenu($, s) s.$button.unbind('click').bind('click', function(e){ //show menu when expand button is clicked s.$menu.css({left:s.$button.css('left'), top:parseInt(s.$button.css('top'))-expandticker.buttonoffset[1]}).show() s.$menulis.removeClass('selected').eq(s.curmsg).addClass('selected') //highlight current message within menu s.$menu.data('state', 'open') //indicate menu is open e.stopPropagation() }) }, selectmsg:function($, s, selected){ s.$contents.stop(true,true).hide().eq(selected)[s.effectfunct](s.timers.fxduration, function(){ //animate message into view if (this.style && this.style.removeAttribute) this.style.removeAttribute('filter') //fix IE clearType problem when animation is fade-in }) s.curmsg=selected if (s.$menu.data('state')=="open") s.$menulis.removeClass('selected').eq(selected).addClass('selected') //highlight current message within menu }, rotatemsg:function($, s){ if (s.$ticker.data('state')=="over"){ //pause ticker onMouseover clearTimeout(s.pausetimer) s.pausetimer=setTimeout(function(){expandticker.rotatemsg($, s)}, 100) return } s.nextmsg=(s.curmsg0){ s.remotecontent[1]=s.remotecontent[1]*1000 //convert units into seconds expandticker.fetchajaxcontent($, s) } else expandticker.setup($, s) $(window).bind('load resize', function(e){ //reposition enlarge images when window has loaded or is resized if (s.$button) setTimeout(function(){expandticker.positionbutton($, s)}, (e.type=="load")? 200 : 0) }) $(document).click(function(){ if (s.$menu){ //hide menu when user clicks anywhere on page s.$menu.hide() s.$menu.data('state', 'closed') } }) }) } }