var JASplit2Menu = new Class({ initialize: function(el, options){ this.options = Object.extend({ minwidth: 0, maxwidth: 0, offwidth: 65, navwidth: 0, showactive: true }, options || {}); if (!el) return; this.element = $(el); items = this.element.getChildren(); if (items.length < 2) return; this._active = 0; var hw = 0; var sp = this.element.getElements('span')[0].getStyle('padding-left').toInt() + this.element.getElements('span')[0].getStyle('padding-right').toInt(); if(this.options.showactive){ if (!this.options.minwidth || !this.options.maxwidth) { if(!this.options.navwidth) this.options.navwidth = this.element.offsetWidth; this.options.minwidth = Math.round((this.options.navwidth - this.options.offwidth)/items.length); this.options.maxwidth = this.options.navwidth - this.options.minwidth*(items.length-1); } hw = this.options.minwidth } else { if (this.options.minwidth && this.options.maxwidth) { this.options.normalwidth = Math.floor(((items.length-1)*this.options.minwidth + this.options.maxwidth) / items.length); }else{ if(!this.options.navwidth) this.options.navwidth = this.element.offsetWidth; this.options.normalwidth = Math.floor(this.options.navwidth / items.length); this.options.navwidth = this.options.normalwidth * items.length this.options.minwidth = this.options.normalwidth - Math.round(this.options.offwidth/(items.length-1)); this.options.maxwidth = this.options.navwidth - this.options.minwidth*(items.length-1); } hw = this.options.normalwidth } var fx = new Fx.Elements(items, {wait: false, duration: 200, transition: Fx.Transitions.quadOut}); items.each(function(item, i){ //check if this is active one if(this.options.showactive){ if (item.className.test('active')) { this._active = i; item.setStyle('width', this.options.maxwidth); } else { item.setStyle('width', this.options.minwidth); } }else{ item.setStyle('width', this.options.normalwidth); } item.getElements('span').setStyle('width', hw-sp); if (item.getElements('img')) { item.getElements('a').setStyles({'position': 'relative','overflow':'hidden'}); item.getElements('img').setStyles({ 'position': 'absolute', 'left': (hw + 1) + 'px' }); }else{ item.getElements('a').setStyle('background-position', (hw + 1) + 'px 0'); } item.addEvent('mouseenter', function(e){ var obj = {}; obj[i] = { 'width': [item.getStyle('width').toInt(), this.options.maxwidth] }; items.each(function(other, j){ if (other != item){ var w = other.getStyle('width').toInt(); if (w != this.options.minwidth) obj[j] = {'width': [w, this.options.minwidth]}; } }.bind(this)); fx.start(obj); }.bind(this)); }.bind(this)); this.element.setStyles({'width': this.options.navwidth+5,'visibility':'visible'}); this.element.addEvent('mouseleave', function(e){ if (this.options.showactive) { this._doactive(); }else{ var obj = {}; items.each(function(other, j){ obj[j] = {'width': [other.getStyle('width').toInt(), this.options.normalwidth]}; }.bind(this)); fx.start(obj); } }.bind(this)); if (this.options.showactive) { this._doactive = function(){ var obj = {}; var item = items[this._active] obj[this._active] = { 'width': [item.getStyle('width').toInt(), this.options.maxwidth] }; items.each(function(other, j){ if (other != item){ var w = other.getStyle('width').toInt(); if (w != this.options.minwidth) obj[j] = {'width': [w, this.options.minwidth]}; } }.bind(this)); fx.start(obj); }.bind(this); } } }); //Ajax Pagination Script- Author: Dynamic Drive (http://www.dynamicdrive.com) //** Created Sept 14th, 07' //** Updated Oct 31st, 07'- Fixed bug when book only contains 1 page //** Updated Aug 9th 08'- Upgraded to v1.2: //1) Adds ability to limit the range of the visible pagination links shown for a book with many pages //2) Adds Session only persistence to persist the last page user viewed when navigating away then returning to the webpage containing the script. //3) Modified Ajax request function in IE7 to use ActiveXObject object, so script can be tested offline var ajaxpageclass=new Object() ajaxpageclass.loadstatustext="Requesting content, please wait..." // HTML to show while requested page is being fetched: ajaxpageclass.ajaxbustcache=true // Bust cache when fetching pages? ajaxpageclass.paginatepersist=true //enable persistence of last viewed pagination link (so reloading page doesn't reset page to 1)? ajaxpageclass.pagerange=4 // Limit page links displayed to a specific number (useful if you have many pages in your book)? ajaxpageclass.ellipse="..." // Ellipse text (no HTML allowed) /////////////// No need to edit beyond here ///////////////////////// ajaxpageclass.connect=function(pageurl, divId){ var page_request = false var bustcacheparameter="" var spoutses=new Date().getTime() var spoutsesa=Math.round(spoutses/1000000) if (window.XMLHttpRequest && !document.all) // if Mozilla, Safari etc (skip IE7, as object is buggy in that browser) page_request = new XMLHttpRequest() else if (window.ActiveXObject){ // if IE6 or below try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return false document.getElementById(divId).innerHTML=this.loadstatustext //Display "fetching page message" page_request.onreadystatechange=function(){ajaxpageclass.loadpage(page_request, divId)} if (this.ajaxbustcache) //if bust caching of external page bustcacheparameter=(pageurl.indexOf("?")!=-1)? "&"+ spoutsesa : "?"+ spoutsesa page_request.open('GET', pageurl+bustcacheparameter, true) page_request.send(null) } ajaxpageclass.loadpage=function(page_request, divId){ if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1)){ document.getElementById(divId).innerHTML=page_request.responseText } } ajaxpageclass.getCookie=function(Name){ var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair if (document.cookie.match(re)) //if cookie found return document.cookie.match(re)[0].split("=")[1] //return its value return null } ajaxpageclass.setCookie=function(name, value){ document.cookie = name+"="+value } ajaxpageclass.getInitialPage=function(divId, pageinfo){ var persistedpage=this.getCookie(divId) var selectedpage=(this.paginatepersist && this.getCookie(divId)!=null)? parseInt(this.getCookie(divId)) : pageinfo.selectedpage return (selectedpage>pageinfo.pages.length-1)? 0 : selectedpage //check that selectedpage isn't out of range } ajaxpageclass.createBook=function(pageinfo, divId, paginateIds){ //MAIN CONSTRUCTOR FUNCTION this.pageinfo=pageinfo //store object containing URLs of pages to fetch, selected page number etc this.divId=divId this.paginateIds=paginateIds //array of ids corresponding to the pagination DIVs defined for this pageinstance //NOTE: this.paginateInfo stores references to various components of each pagination DIV defined for this pageinstance //NOTE: Eg: divs[0] = 1st paginate div, pagelinks[0][0] = 1st page link within 1st paginate DIV, prevlink[0] = previous link within paginate DIV etc this.paginateInfo={divs:[], pagelinks:[[]], prevlink:[], nextlink:[], previouspage:null, previousrange:[null,null], leftellipse:[], rightellipse:[]} this.dopagerange=false this.pagerangestyle='' this.ellipse='' //construct HTML for ellipse var initialpage=ajaxpageclass.getInitialPage(divId, pageinfo) this.buildpagination(initialpage) this.selectpage(initialpage) } ajaxpageclass.createBook.prototype={ buildpagination:function(selectedpage){ //build pagination links based on length of this.pageinfo.pages[] this.dopagerange=(this.pageinfo.pages.length>ajaxpageclass.pagerange) //Bool: enable limitpagerange if pagerange value is less than total pages available this.pagerangestyle=this.dopagerange? 'style="display:none"' : '' //if limitpagerange enabled, hide pagination links when building them this.paginateInfo.previousrange=null //Set previousrange[start, finish] to null to start if (this.pageinfo.pages.length==0) return else if (this.pageinfo.pages.length==1) var paginateHTML="Page 1 of 1" //Pagination HTML to show when there's only 1 page (no pagination needed) else{ //construct paginate interface var paginateHTML='