/** * @author me */ (function(){ jQuery.fn.linksCombo = function(config){ var myconfig = $.extend(/*deep*/true, {}, { id : '', onchange : function() {return false;}, attrListToCopy : ['id'], isDefault : function() {return false} }, config); return this.each(function(){ new jQuery.linksCombo(myconfig, this); }); } jQuery.linksCombo = function(config, list) { var options =[]; var defaultVal = null; //Collect all the a links inside the list(list items) $('li',list).each(function() { var opEl=$(document.createElement("option")); var li = $(this); opEl.text(li.text()); var data = li.metadata(); if(data) { data = data.value; } else { data = li.text(); } opEl.attr('value',data); if(config.isDefault(this, data)) { defaultVal = data; } if(config.attrListToCopy) { //copy over the attributes for(i in config.attrListToCopy) { opEl.attr(config.attrListToCopy[i],li.attr(config.attrListToCopy[i])); } } options.push(opEl[0]); }); //If we have any items in the list, whack the list and replace // it with the combo box if (options.length > 0) { var sel = $(document.createElement("select")); var ul = $(list); if(config.attrListToCopy) { //copy over the attributes for(i in config.attrListToCopy) { sel.attr(config.attrListToCopy[i],ul.attr(config.attrListToCopy[i])); } } sel.append(options); //Add the new "select" element as a sibling (after) the ul and remove the ul from the main DOM ul.after(sel).remove(); //Initialize the combo with the event handler and default value defaultVal && sel.val(defaultVal); sel.change(config.onchange); } } })(jQuery); ; /* * jQuery history plugin * * Copyright (c) 2006 Taku Sano (Mikage Sawatari) * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * Modified by Lincoln Cooper to add Safari support and only call the callback once during initialization * for msie when no initial hash supplied. */ jQuery.extend({ historyCurrentHash: undefined, historyCallback: undefined, historyInit: function(callback){ jQuery.historyCallback = callback; var current_hash = location.hash; jQuery.historyCurrentHash = current_hash; if(jQuery.browser.msie) { // To stop the callback firing twice during initilization if no hash present if (jQuery.historyCurrentHash == '') { jQuery.historyCurrentHash = '#'; } // add hidden iframe for IE $("body").prepend(''); var ihistory = $("#jQuery_history")[0]; var iframe = ihistory.contentWindow.document; iframe.open(); iframe.close(); iframe.location.hash = current_hash; } else if ($.browser.safari) { // etablish back/forward stacks jQuery.historyBackStack = []; jQuery.historyBackStack.length = history.length; jQuery.historyForwardStack = []; jQuery.isFirst = true; } jQuery.historyCallback(current_hash.replace(/^#/, '')); setInterval(jQuery.historyCheck, 100); }, historyAddHistory: function(hash) { // This makes the looping function do something jQuery.historyBackStack.push(hash); jQuery.historyForwardStack.length = 0; // clear forwardStack (true click occured) this.isFirst = true; }, historyCheck: function(){ if(jQuery.browser.msie) { // On IE, check for location.hash of iframe var ihistory = $("#jQuery_history")[0]; var iframe = ihistory.contentDocument || ihistory.contentWindow.document; var current_hash = iframe.location.hash; if(current_hash != jQuery.historyCurrentHash) { location.hash = current_hash; jQuery.historyCurrentHash = current_hash; jQuery.historyCallback(current_hash.replace(/^#/, '')); } } else if ($.browser.safari) { if (!jQuery.dontCheck) { var historyDelta = history.length - jQuery.historyBackStack.length; if (historyDelta) { // back or forward button has been pushed jQuery.isFirst = false; if (historyDelta < 0) { // back button has been pushed // move items to forward stack for (var i = 0; i < Math.abs(historyDelta); i++) jQuery.historyForwardStack.unshift(jQuery.historyBackStack.pop()); } else { // forward button has been pushed // move items to back stack for (var i = 0; i < historyDelta; i++) jQuery.historyBackStack.push(jQuery.historyForwardStack.shift()); } var cachedHash = jQuery.historyBackStack[jQuery.historyBackStack.length - 1]; if (cachedHash != undefined) { jQuery.historyCurrentHash = location.hash; jQuery.historyCallback(cachedHash); } } else if (jQuery.historyBackStack[jQuery.historyBackStack.length - 1] == undefined && !jQuery.isFirst) { // back button has been pushed to beginning and URL already pointed to hash (e.g. a bookmark) // document.URL doesn't change in Safari if (document.URL.indexOf('#') >= 0) { jQuery.historyCallback(document.URL.split('#')[1]); } else { var current_hash = location.hash; jQuery.historyCallback(''); } jQuery.isFirst = true; } } } else { // otherwise, check for location.hash var current_hash = location.hash; if(current_hash != jQuery.historyCurrentHash) { jQuery.historyCurrentHash = current_hash; jQuery.historyCallback(current_hash.replace(/^#/, '')); } } }, historyLoad: function(hash){ var newhash; if (jQuery.browser.safari) { newhash = hash; } else { newhash = '#' + hash; location.hash = newhash; } jQuery.historyCurrentHash = newhash; if(jQuery.browser.msie) { var ihistory = $("#jQuery_history")[0]; var iframe = ihistory.contentWindow.document; iframe.open(); iframe.close(); iframe.location.hash = newhash; jQuery.historyCallback(hash); } else if (jQuery.browser.safari) { jQuery.dontCheck = true; // Manually keep track of the history values for Safari this.historyAddHistory(hash); // Wait a while before allowing checking so that Safari has time to update the "history" object // correctly (otherwise the check loop would detect a false change in hash). var fn = function() {jQuery.dontCheck = false;}; window.setTimeout(fn, 200); jQuery.historyCallback(hash); // N.B. "location.hash=" must be the last line of code for Safari as execution stops afterwards. // By explicitly using the "location.hash" command (instead of using a variable set to "location.hash") the // URL in the browser and the "history" object are both updated correctly. location.hash = newhash; } else { jQuery.historyCallback(hash); } } }); ; /** * hoverIntent is similar to jQuery's built-in "hover" function except that * instead of firing the onMouseOver event immediately, hoverIntent checks * to see if the user's mouse has slowed down (beneath the sensitivity * threshold) before firing the onMouseOver event. * * hoverIntent r5 // 2007.03.27 // jQuery 1.1.2 * * * hoverIntent is currently available for use in all personal or commercial * projects under both MIT and GPL licenses. This means that you can choose * the license that best suits your project, and use it accordingly. * * // basic usage (just like .hover) receives onMouseOver and onMouseOut functions * $("ul li").hoverIntent( showNav , hideNav ); * * // advanced usage receives configuration object only * $("ul li").hoverIntent({ * sensitivity: 2, // number = sensitivity threshold (must be 1 or higher) * interval: 50, // number = milliseconds of polling interval * over: showNav, // function = onMouseOver callback (required) * timeout: 100, // number = milliseconds delay before onMouseOut function call * out: hideNav // function = onMouseOut callback (required) * }); * * @param f onMouseOver function || An object with configuration options * @param g onMouseOut function || Nothing (use configuration options object) * @return The object (aka "this") that called hoverIntent, and the event object * @author Brian Cherne */ (function($) { $.fn.hoverIntent = function(f,g) { // default configuration options var cfg = { sensitivity: 7, interval: 100, timeout: 0 }; // override configuration options with user supplied object cfg = $.extend(cfg, g ? { over: f, out: g } : f ); // instantiate variables // cX, cY = current X and Y position of mouse, updated by mousemove event // pX, pY = previous X and Y position of mouse, set by mouseover and polling interval var cX, cY, pX, pY; // A private function for getting mouse position var track = function(ev) { cX = ev.pageX; cY = ev.pageY; }; // A private function for comparing current and previous mouse position var compare = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); // compare mouse positions to see if they've crossed the threshold if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) { $(ob).unbind("mousemove",track); // set hoverIntent state to true (so mouseOut can be called) ob.hoverIntent_s = 1; return cfg.over.apply(ob,[ev]); } else { // set previous coordinates for next time pX = cX; pY = cY; // use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs) ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval ); } }; // A private function for delaying the mouseOut function var delay = function(ev,ob) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); ob.hoverIntent_s = 0; return cfg.out.apply(ob,[ev]); }; // A private function for handling mouse 'hovering' var handleHover = function(e) { // next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget; while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } } if ( p == this ) { return false; } // copy objects to be passed into t (required for event object to be passed in IE) var ev = jQuery.extend({},e); var ob = this; // cancel hoverIntent timer if it exists if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); } // else e.type == "onmouseover" if (e.type == "mouseover") { // set "previous" X and Y position based on initial entry point pX = ev.pageX; pY = ev.pageY; // update "current" X and Y position based on mousemove $(ob).bind("mousemove",track); // start polling interval (self-calling timeout) to compare mouse coordinates over time if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );} // else e.type == "onmouseout" } else { // unbind expensive mousemove event $(ob).unbind("mousemove",track); // if hoverIntent state is true, then call the mouseOut function after the specified delay if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );} } }; // bind the function to the two event listeners return this.mouseover(handleHover).mouseout(handleHover); }; })(jQuery); ; /** * Interface Elements for jQuery * utility function * * http://interface.eyecon.ro * * Copyright (c) 2006 Stefan Petre * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * */ jQuery.iUtil = { getPosition : function(e) { var x = 0; var y = 0; var es = e.style; var restoreStyles = false; if (jQuery(e).css('display') == 'none') { var oldVisibility = es.visibility; var oldPosition = es.position; restoreStyles = true; es.visibility = 'hidden'; es.display = 'block'; es.position = 'absolute'; } var el = e; while (el){ x += el.offsetLeft + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderLeftWidth)||0:0); y += el.offsetTop + (el.currentStyle && !jQuery.browser.opera ?parseInt(el.currentStyle.borderTopWidth)||0:0); el = el.offsetParent; } el = e; while (el && el.tagName && el.tagName.toLowerCase() != 'body') { x -= el.scrollLeft||0; y -= el.scrollTop||0; el = el.parentNode; } if (restoreStyles == true) { es.display = 'none'; es.position = oldPosition; es.visibility = oldVisibility; } return {x:x, y:y}; }, getPositionLite : function(el) { var x = 0, y = 0; while(el) { x += el.offsetLeft || 0; y += el.offsetTop || 0; el = el.offsetParent; } return {x:x, y:y}; }, getSize : function(e) { var w = jQuery.css(e,'width'); var h = jQuery.css(e,'height'); var wb = 0; var hb = 0; var es = e.style; if (jQuery(e).css('display') != 'none') { wb = e.offsetWidth; hb = e.offsetHeight; } else { var oldVisibility = es.visibility; var oldPosition = es.position; es.visibility = 'hidden'; es.display = 'block'; es.position = 'absolute'; wb = e.offsetWidth; hb = e.offsetHeight; es.display = 'none'; es.position = oldPosition; es.visibility = oldVisibility; } return {w:w, h:h, wb:wb, hb:hb}; }, getSizeLite : function(el) { return { wb:el.offsetWidth||0, hb:el.offsetHeight||0 }; }, getClient : function(e) { var h, w, de; if (e) { w = e.clientWidth; h = e.clientHeight; } else { de = document.documentElement; w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth; h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight; } return {w:w,h:h}; }, getScroll : function (e) { var t=0, l=0, w=0, h=0, iw=0, ih=0; if (e && e.nodeName.toLowerCase() != 'body') { t = e.scrollTop; l = e.scrollLeft; w = e.scrollWidth; h = e.scrollHeight; iw = 0; ih = 0; } else { if (document.documentElement) { t = document.documentElement.scrollTop; l = document.documentElement.scrollLeft; w = document.documentElement.scrollWidth; h = document.documentElement.scrollHeight; } else if (document.body) { t = document.body.scrollTop; l = document.body.scrollLeft; w = document.body.scrollWidth; h = document.body.scrollHeight; } iw = self.innerWidth||document.documentElement.clientWidth||document.body.clientWidth||0; ih = self.innerHeight||document.documentElement.clientHeight||document.body.clientHeight||0; } return { t: t, l: l, w: w, h: h, iw: iw, ih: ih }; }, getMargins : function(e, toInteger) { var el = jQuery(e); var t = el.css('marginTop') || ''; var r = el.css('marginRight') || ''; var b = el.css('marginBottom') || ''; var l = el.css('marginLeft') || ''; if (toInteger) return { t: parseInt(t)||0, r: parseInt(r)||0, b: parseInt(b)||0, l: parseInt(l) }; else return {t: t, r: r, b: b, l: l}; }, getPadding : function(e, toInteger) { var el = jQuery(e); var t = el.css('paddingTop') || ''; var r = el.css('paddingRight') || ''; var b = el.css('paddingBottom') || ''; var l = el.css('paddingLeft') || ''; if (toInteger) return { t: parseInt(t)||0, r: parseInt(r)||0, b: parseInt(b)||0, l: parseInt(l) }; else return {t: t, r: r, b: b, l: l}; }, getBorder : function(e, toInteger) { var el = jQuery(e); var t = el.css('borderTopWidth') || ''; var r = el.css('borderRightWidth') || ''; var b = el.css('borderBottomWidth') || ''; var l = el.css('borderLeftWidth') || ''; if (toInteger) return { t: parseInt(t)||0, r: parseInt(r)||0, b: parseInt(b)||0, l: parseInt(l)||0 }; else return {t: t, r: r, b: b, l: l}; }, getPointer : function(event) { var x = event.pageX || (event.clientX + (document.documentElement.scrollLeft || document.body.scrollLeft)) || 0; var y = event.pageY || (event.clientY + (document.documentElement.scrollTop || document.body.scrollTop)) || 0; return {x:x, y:y}; }, traverseDOM : function(nodeEl, func) { func(nodeEl); nodeEl = nodeEl.firstChild; while(nodeEl){ jQuery.iUtil.traverseDOM(nodeEl, func); nodeEl = nodeEl.nextSibling; } }, purgeEvents : function(nodeEl) { jQuery.iUtil.traverseDOM( nodeEl, function(el) { for(var attr in el){ if(typeof el[attr] === 'function') { el[attr] = null; } } } ); }, centerEl : function(el, axis) { var clientScroll = jQuery.iUtil.getScroll(); var windowSize = jQuery.iUtil.getSize(el); if (!axis || axis == 'vertically') jQuery(el).css( { top: clientScroll.t + ((Math.max(clientScroll.h,clientScroll.ih) - clientScroll.t - windowSize.hb)/2) + 'px' } ); if (!axis || axis == 'horizontally') jQuery(el).css( { left: clientScroll.l + ((Math.max(clientScroll.w,clientScroll.iw) - clientScroll.l - windowSize.wb)/2) + 'px' } ); }, fixPNG : function (el, emptyGIF) { var images = jQuery('img[@src*="png"]', el||document), png; images.each( function() { png = this.src; this.src = emptyGIF; this.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + png + "')"; }); } }; // Helper function to support older browsers! [].indexOf || (Array.prototype.indexOf = function(v, n){ n = (n == null) ? 0 : n; var m = this.length; for (var i=n; i