code
stringlengths
1
2.08M
language
stringclasses
1 value
/* Demo Note: This demo uses a FileProgress class that handles the UI for displaying the file name and percent complete. The FileProgress class is not part of SWFUpload. */ /* ********************** Event Handlers These are my custom event handlers to make my web application behave the way I went when SWFUpload completes different tasks. These aren't part of the SWFUpload package. They are part of my application. Without these none of the actions SWFUpload makes will show up in my application. ********************** */ function fileQueued(file) { try { var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setStatus("Pending..."); progress.toggleCancel(true, this); } catch (ex) { this.debug(ex); } } function fileQueueError(file, errorCode, message) { try { if (errorCode === SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED) { alert("You have attempted to queue too many files.\n" + (message === 0 ? "You have reached the upload limit." : "You may select " + (message > 1 ? "up to " + message + " files." : "one file."))); return; } var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setError(); progress.toggleCancel(false); switch (errorCode) { case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: progress.setStatus("File is too big."); this.debug("Error Code: File too big, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: progress.setStatus("Cannot upload Zero Byte files."); this.debug("Error Code: Zero byte file, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: progress.setStatus("Invalid File Type."); this.debug("Error Code: Invalid File Type, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; default: if (file !== null) { progress.setStatus("Unhandled Error"); } this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; } } catch (ex) { this.debug(ex); } } function fileDialogComplete(numFilesSelected, numFilesQueued) { try { if (numFilesSelected > 0) { document.getElementById(this.customSettings.cancelButtonId).disabled = false; } /* I want auto start the upload and I can do that here */ this.startUpload(); } catch (ex) { this.debug(ex); } } function uploadStart(file) { try { /* I don't want to do any file validation or anything, I'll just update the UI and return true to indicate that the upload should start. It's important to update the UI here because in Linux no uploadProgress events are called. The best we can do is say we are uploading. */ var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setStatus("Uploading..."); progress.toggleCancel(true, this); } catch (ex) {} return true; } function uploadProgress(file, bytesLoaded, bytesTotal) { try { var percent = Math.ceil((bytesLoaded / bytesTotal) * 100); var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setProgress(percent); progress.setStatus("Uploading..."); } catch (ex) { this.debug(ex); } } function uploadSuccess(file, serverData) { try { var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setComplete(); progress.setStatus("Complete."); progress.toggleCancel(false); } catch (ex) { this.debug(ex); } } function uploadError(file, errorCode, message) { try { var progress = new FileProgress(file, this.customSettings.progressTarget); progress.setError(); progress.toggleCancel(false); switch (errorCode) { case SWFUpload.UPLOAD_ERROR.HTTP_ERROR: progress.setStatus("Upload Error: " + message); this.debug("Error Code: HTTP Error, File name: " + file.name + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.UPLOAD_FAILED: progress.setStatus("Upload Failed."); this.debug("Error Code: Upload Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.IO_ERROR: progress.setStatus("Server (IO) Error"); this.debug("Error Code: IO Error, File name: " + file.name + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.SECURITY_ERROR: progress.setStatus("Security Error"); this.debug("Error Code: Security Error, File name: " + file.name + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.UPLOAD_LIMIT_EXCEEDED: progress.setStatus("Upload limit exceeded."); this.debug("Error Code: Upload Limit Exceeded, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.FILE_VALIDATION_FAILED: progress.setStatus("Failed Validation. Upload skipped."); this.debug("Error Code: File Validation Failed, File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; case SWFUpload.UPLOAD_ERROR.FILE_CANCELLED: // If there aren't any files left (they were all cancelled) disable the cancel button if (this.getStats().files_queued === 0) { document.getElementById(this.customSettings.cancelButtonId).disabled = true; } progress.setStatus("Cancelled"); progress.setCancelled(); break; case SWFUpload.UPLOAD_ERROR.UPLOAD_STOPPED: progress.setStatus("Stopped"); break; default: progress.setStatus("Unhandled Error: " + errorCode); this.debug("Error Code: " + errorCode + ", File name: " + file.name + ", File size: " + file.size + ", Message: " + message); break; } } catch (ex) { this.debug(ex); } } function uploadComplete(file) { if (this.getStats().files_queued === 0) { document.getElementById(this.customSettings.cancelButtonId).disabled = true; } } // This event comes from the Queue Plugin function queueComplete(numFilesUploaded) { //var status = document.getElementById("divStatus"); //status.innerHTML = numFilesUploaded + " file" + (numFilesUploaded === 1 ? "" : "s") + " uploaded."; }
JavaScript
/* Queue Plug-in Features: *Adds a cancelQueue() method for cancelling the entire queue. *All queued files are uploaded when startUpload() is called. *If false is returned from uploadComplete then the queue upload is stopped. If false is not returned (strict comparison) then the queue upload is continued. *Adds a QueueComplete event that is fired when all the queued files have finished uploading. Set the event handler with the queue_complete_handler setting. */ var SWFUpload; if (typeof(SWFUpload) === "function") { SWFUpload.queue = {}; SWFUpload.prototype.initSettings = (function (oldInitSettings) { return function () { if (typeof(oldInitSettings) === "function") { oldInitSettings.call(this); } this.queueSettings = {}; this.queueSettings.queue_cancelled_flag = false; this.queueSettings.queue_upload_count = 0; this.queueSettings.user_upload_complete_handler = this.settings.upload_complete_handler; this.queueSettings.user_upload_start_handler = this.settings.upload_start_handler; this.settings.upload_complete_handler = SWFUpload.queue.uploadCompleteHandler; this.settings.upload_start_handler = SWFUpload.queue.uploadStartHandler; this.settings.queue_complete_handler = this.settings.queue_complete_handler || null; }; })(SWFUpload.prototype.initSettings); SWFUpload.prototype.startUpload = function (fileID) { this.queueSettings.queue_cancelled_flag = false; this.callFlash("StartUpload", [fileID]); }; SWFUpload.prototype.cancelQueue = function () { this.queueSettings.queue_cancelled_flag = true; this.stopUpload(); var stats = this.getStats(); while (stats.files_queued > 0) { this.cancelUpload(); stats = this.getStats(); } }; SWFUpload.queue.uploadStartHandler = function (file) { var returnValue; if (typeof(this.queueSettings.user_upload_start_handler) === "function") { returnValue = this.queueSettings.user_upload_start_handler.call(this, file); } // To prevent upload a real "FALSE" value must be returned, otherwise default to a real "TRUE" value. returnValue = (returnValue === false) ? false : true; this.queueSettings.queue_cancelled_flag = !returnValue; return returnValue; }; SWFUpload.queue.uploadCompleteHandler = function (file) { var user_upload_complete_handler = this.queueSettings.user_upload_complete_handler; var continueUpload; if (file.filestatus === SWFUpload.FILE_STATUS.COMPLETE) { this.queueSettings.queue_upload_count++; } if (typeof(user_upload_complete_handler) === "function") { continueUpload = (user_upload_complete_handler.call(this, file) === false) ? false : true; } else if (file.filestatus === SWFUpload.FILE_STATUS.QUEUED) { // If the file was stopped and re-queued don't restart the upload continueUpload = false; } else { continueUpload = true; } if (continueUpload) { var stats = this.getStats(); if (stats.files_queued > 0 && this.queueSettings.queue_cancelled_flag === false) { this.startUpload(); } else if (this.queueSettings.queue_cancelled_flag === false) { this.queueEvent("queue_complete_handler", [this.queueSettings.queue_upload_count]); this.queueSettings.queue_upload_count = 0; } else { this.queueSettings.queue_cancelled_flag = false; this.queueSettings.queue_upload_count = 0; } } }; }
JavaScript
/** * add to body onLoad="autoindex('autoindex')" where "autoindex" is the id of the object where index will be created */ indexList = new Array(); function autoindex( elementId ) { //var element = document.getElementById(elementId); var bodyTag = document.getElementsByTagName("body"); var list = searchHeadlines( bodyTag[0] ); element = document.getElementById(elementId); newContents = ""; newContents = "<ol class=\"autoIndex\">"; var lines = 0; for( var i=0; i<indexList.length; i++ ) { if( indexList[i].tagName == "H1" ) { if( lines != 0 ) newContents += "</ol>"; newContents += "<li><a href=\"#link_"+i+"\">"+indexList[i].innerHTML+" </a></li><ol>"; } else { newContents += "<li><a href=\"#link_"+i+"\">"+indexList[i].innerHTML+" </a></li>"; } indexList[i].innerHTML = "<a name=\"link_"+i+"\">"+indexList[i].innerHTML+"</a> <a href=\"#link_2\"></a>"; lines++; } element.innerHTML = newContents+"</ol>"; } function searchHeadlines( element ) { for( var i=0; i<element.childNodes.length; i++) { //if( i<2) alert(element.childNodes[i].tagName); if( element.childNodes[i].tagName == "H1") { indexList.push( element.childNodes[i]); } else if( element.childNodes[i].tagName == "H2") { indexList.push( element.childNodes[i]); } else { searchHeadlines( element.childNodes[i] ); } } }
JavaScript
/** * add to body onLoad="lineNumbersToCode()" */ function lineNumbersToCode() { var items = document.getElementsByTagName("pre"); for( var i=0; i<items.length; i++) { if( items[i].className == "code") { addLineNumbers( items[i] ); } } } function addLineNumbers( element ) { var contents = element.innerHTML.split("\n"); var newContents = ""; for( var i=0; i<contents.length; i++) { newContents += "<span class=\"lineNumber\">"+(i+1)+"</span>"+contents[i]+"\n"; } //alert(newContents); element.innerHTML = newContents; } /** * add to body onLoad="autoindex('autoindex')" where "autoindex" is the id of the object where index will be created */ indexList = new Array(); function autoindex( elementId ) { //var element = document.getElementById(elementId); var bodyTag = document.getElementsByTagName("body"); var list = searchHeadlines( bodyTag[0] ); element = document.getElementById(elementId); newContents = ""; newContents = "<ol>"; for( var i=2; i<indexList.length; i++ ) { if( indexList[i].tagName == "H1" ) { if( newContents != "<ol>") newContents += "</ol>"; newContents += "<li><a href=\"#link_"+i+"\">"+indexList[i].innerHTML+" > </a></li><ol>"; } else { newContents += "<li><a href=\"#link_"+i+"\">"+indexList[i].innerHTML+" > </a></li>"; } indexList[i].innerHTML = "<a name=\"link_"+i+"\">"+indexList[i].innerHTML+"</a> <a href=\"#link_2\">></a>"; } element.innerHTML = newContents+"</ol>"; } function searchHeadlines( element ) { for( var i=0; i<element.childNodes.length; i++) { //if( i<2) alert(element.childNodes[i].tagName); if( element.childNodes[i].tagName == "H1") { indexList.push( element.childNodes[i]); } else if( element.childNodes[i].tagName == "H2") { indexList.push( element.childNodes[i]); } else { searchHeadlines( element.childNodes[i] ); } } } /** * parses all code elements to PHP code. * Usage: Add to body onLoad="codeParser();" */ function codeParser() { var items = document.getElementsByTagName("pre"); for( var i=0; i<items.length; i++) { if( items[i].className == "code") { items[i].innerHTML = parseCode( items[i].innerHTML ); } } } areaTags = new Array(); areaTags.push({name:"php", start:"&lt;?php", end:"?&gt;", class:"php", selfClass:"php_tag", notIn:new Array("string","string2","comment")}); areaTags.push({name:"comment", start:"/*", end:"*/", class:"comment", selfClass:false, notIn:new Array("string","string2")}); areaTags.push({name:"string", start:"\"", end:"\"", class:"php_string", escapeChar:'\\', selfClass:false, notIn:new Array("string2")}); areaTags.push({name:"string2", start:"'", end:"'", class:"php_string", escapeChar:'\\', selfClass:false, notIn:new Array("string")}); keys = new Array(); keys.push({tag:"class", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"abstract", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"final", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"implements", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"static", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"interface", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"protected", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"private", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"public", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"new ", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"extends", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"true", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"false", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"function", class:"php_meth", mustBeIn:new Array("php") }); keys.push({tag:"if", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"else", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"elseif", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:"array", class:"php_meth", mustBeIn:new Array("php") }); keys.push({tag:"define", class:"php_meth", mustBeIn:new Array("php") }); keys.push({tag:"NULL", class:"php_meth", mustBeIn:new Array("php") }); keys.push({tag:"foreach", class:"php_func", mustBeIn:new Array("php") }); keys.push({tag:" as ", class:"php_func", mustBeIn:new Array("php") }); lineTags = new Array(); lineTags.push({tag:"@orm", class:"orm", mustBeIn:new Array("comment"), endsWith:new Array("\n") }); lineTags.push({tag:"@param", class:"annotation", mustBeIn:new Array("comment"), endsWith:new Array("\n") }); lineTags.push({tag:"@return", class:"annotation", mustBeIn:new Array("comment"), endsWith:new Array("\n") }); lineTags.push({tag:"//", class:"comment", mustBeIn:new Array(), endsWith:new Array("\n") }); lineTags.push({tag:"$", class:"php_var", mustBeIn:new Array("php"), endsWith:new Array(" ",";","-","]","[","{",",","(",")",";") }); function parseCode( code ) { var codeLength = code.length; var areaTagsLength = areaTags.length; var keysLength = keys.length; var lineTagsLength = lineTags.length; var inTags = new Array(); var inLineTag = -1; for( var i=0; i<areaTagsLength; i++) { areaTags[i].startChar = areaTags[i].start.charAt(0); areaTags[i].endChar = areaTags[i].end.charAt(0); inTags[areaTags[i].name] = 0; } for( var i=0; i<keysLength; i++) { keys[i].char = keys[i].tag.charAt(0); } for( var i=0; i<lineTagsLength; i++) { lineTags[i].char = lineTags[i].tag.charAt(0); } //var debug = ""; var newCode = ""; for( var charNr=0; charNr<codeLength; charNr++ ) { char = code.charAt(charNr); found = false; // PARSING LINE TAGS if( inLineTag == -1 ) { for( var i=0; i<lineTagsLength; i++) { // checking for not in tags var skip = false; for( var s=0; s<lineTags[i].mustBeIn.length; s++) { if( inTags[lineTags[i].mustBeIn[s]] == 0 ) skip = true; } // skipping if needed if( skip == true) continue; if( char == lineTags[i].char && code.substr(charNr,lineTags[i].tag.length) == lineTags[i].tag ) { //debug += "in tag "+keys[i].tag+"<br />"; inLineTag = i; newCode += "<span class=\""+lineTags[i].class+"\">"+lineTags[i].tag; charNr += lineTags[i].tag.length-1; found = true; break; } } } else { found = true; for( var i=0; i<lineTags[inLineTag].endsWith.length; i++) { if( char == lineTags[inLineTag].endsWith[i] ) { inLineTag = -1; newCode += "</span>"; break; } } newCode += char; } if( found == true ) continue; // END PARSING LINE TAGS // PARSING AREA TAGS for( var i=0; i<areaTagsLength; i++) { // checking for not in tags var skip = false; for( var s=0; s<areaTags[i].notIn.length; s++) { if( inTags[areaTags[i].notIn[s]] > 0 ) skip = true; } // skipping if needed if( skip == true) continue; if( inTags[areaTags[i].name] == 0 && char == areaTags[i].startChar && code.substr(charNr,areaTags[i].start.length) == areaTags[i].start ) { inTags[areaTags[i].name]++; //debug += "in tag "+areaTags[i].name+"<br />"; newCode += "<span class=\""+areaTags[i].class+"\">"; if( areaTags[i].selfClass == false ) { newCode += areaTags[i].start; } else { newCode += "<span class=\""+areaTags[i].selfClass+"\">"+areaTags[i].start+"</span>"; } charNr += areaTags[i].start.length-1; found = true; } else if( inTags[areaTags[i].name] > 0 && char == areaTags[i].endChar && code.substr(charNr,areaTags[i].end.length) == areaTags[i].end && code.charAt(charNr-1) != areaTags[i].escapeChar) { inTags[areaTags[i].name]--; //debug += "ended tag "+areaTags[i].name+"<br />"; if( areaTags[i].selfClass == false ) { newCode += areaTags[i].end; } else { newCode += "<span class=\""+areaTags[i].selfClass+"\">"+areaTags[i].end+"</span>"; } newCode += "</span>"; charNr += areaTags[i].start.length-1; found = true; } } if( found == true ) continue; // END PARSING AREA TAGS // PARSING KEY TAGS for( var i=0; i<keysLength; i++) { if( char == keys[i].char && code.substr(charNr,keys[i].tag.length) == keys[i].tag ) { //debug += "in tag "+keys[i].tag+"<br />"; newCode += "<span class=\""+keys[i].class+"\">"+keys[i].tag+"</span>"; charNr += keys[i].tag.length-1; found = true; break; } } if( found == true ) continue; // END PARSING KEY TAGS newCode += char; } //newCode += "<br />DEBUG:<br />"+debug+"<br />"; return newCode; }
JavaScript
var $lang={ errAlertMsg: "Invalid date or the date out of range,redo or not?", aWeekStr: ["wk", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], aLongWeekStr:["wk","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"], aMonStr: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], aLongMonStr: ["January","February","March","April","May","June","July","August","September","October","November","December"], clearStr: "Clear", todayStr: "Today", okStr: "OK", updateStr: "OK", timeStr: "Time", quickStr: "Quick Selection", err_1: 'MinDate Cannot be bigger than MaxDate!' }
JavaScript
var langList = [ {name:'en', charset:'UTF-8'}, {name:'zh-cn', charset:'gb2312'}, {name:'zh-tw', charset:'GBK'} ]; var skinList = [ {name:'default', charset:'gb2312'}, {name:'whyGreen', charset:'gb2312'} ];
JavaScript
/* * jQuery Easing v1.1.1 - http://gsgd.co.uk/sandbox/jquery.easing.php * * Uses the built in easing capabilities added in jQuery 1.1 * to offer multiple easing options * * Copyright (c) 2007 George Smith * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php */ jQuery.extend(jQuery.easing, { easein: function(x, t, b, c, d) { return c*(t/=d)*t + b; // in }, easeinout: function(x, t, b, c, d) { if (t < d/2) return 2*c*t*t/(d*d) + b; var ts = t - d/2; return -2*c*ts*ts/(d*d) + 2*c*ts/d + c/2 + b; }, easeout: function(x, t, b, c, d) { return -c*t*t/(d*d) + 2*c*t/d + b; }, expoin: function(x, t, b, c, d) { var flip = 1; if (c < 0) { flip *= -1; c *= -1; } return flip * (Math.exp(Math.log(c)/d * t)) + b; }, expoout: function(x, t, b, c, d) { var flip = 1; if (c < 0) { flip *= -1; c *= -1; } return flip * (-Math.exp(-Math.log(c)/d * (t-d)) + c + 1) + b; }, expoinout: function(x, t, b, c, d) { var flip = 1; if (c < 0) { flip *= -1; c *= -1; } if (t < d/2) return flip * (Math.exp(Math.log(c/2)/(d/2) * t)) + b; return flip * (-Math.exp(-2*Math.log(c/2)/d * (t-d)) + c + 1) + b; }, bouncein: function(x, t, b, c, d) { return c - jQuery.easing['bounceout'](x, d-t, 0, c, d) + b; }, bounceout: function(x, t, b, c, d) { if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } }, bounceinout: function(x, t, b, c, d) { if (t < d/2) return jQuery.easing['bouncein'] (x, t*2, 0, c, d) * .5 + b; return jQuery.easing['bounceout'] (x, t*2-d,0, c, d) * .5 + c*.5 + b; }, elasin: function(x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; }, elasout: function(x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; }, elasinout: function(x, t, b, c, d) { var s=1.70158;var p=0;var a=c; if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); if (a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; }, backin: function(x, t, b, c, d) { var s=1.70158; return c*(t/=d)*t*((s+1)*t - s) + b; }, backout: function(x, t, b, c, d) { var s=1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; }, backinout: function(x, t, b, c, d) { var s=1.70158; if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; } });
JavaScript
function getGwid(){ var spid = document.getElementById("spid").value; $.ajax({ type : "post", url : "<%=request.getContextPath() %>/cgateway.do", data : "action=findGatewayBySp&spid="+spid, datatype : "text", success : function(data) { $("#gwid").html(data); }, error: function(){ alert("something error,try again!"); } }); }
JavaScript
//mobile String.prototype.IsMobile = function(){ var regexp = /^\d{11}$/; return regexp.test(this); } //number check String.prototype.IsNumberCheck = function(){ var regexp = /^\d{1,10}$/; return regexp.test(this); }
JavaScript
/* Copyright (c) 2007 Paul Bakaus (paul.bakaus@googlemail.com) and Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * $LastChangedDate: 2007-10-06 20:11:15 +0200 (Sa, 06 Okt 2007) $ * $Rev: 3581 $ * * Version: @VERSION * * Requires: jQuery 1.2+ */ (function($){ $.dimensions = { version: '@VERSION' }; // Create innerHeight, innerWidth, outerHeight and outerWidth methods $.each( [ 'Height', 'Width' ], function(i, name){ // innerHeight and innerWidth $.fn[ 'inner' + name ] = function() { if (!this[0]) return; var torl = name == 'Height' ? 'Top' : 'Left', // top or left borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right return num( this, name.toLowerCase() ) + num(this, 'padding' + torl) + num(this, 'padding' + borr); }; // outerHeight and outerWidth $.fn[ 'outer' + name ] = function(options) { if (!this[0]) return; var torl = name == 'Height' ? 'Top' : 'Left', // top or left borr = name == 'Height' ? 'Bottom' : 'Right'; // bottom or right options = $.extend({ margin: false }, options || {}); return num( this, name.toLowerCase() ) + num(this, 'border' + torl + 'Width') + num(this, 'border' + borr + 'Width') + num(this, 'padding' + torl) + num(this, 'padding' + borr) + (options.margin ? (num(this, 'margin' + torl) + num(this, 'margin' + borr)) : 0); }; }); // Create scrollLeft and scrollTop methods $.each( ['Left', 'Top'], function(i, name) { $.fn[ 'scroll' + name ] = function(val) { if (!this[0]) return; return val != undefined ? // Set the scroll offset this.each(function() { this == window || this == document ? window.scrollTo( name == 'Left' ? val : $(window)[ 'scrollLeft' ](), name == 'Top' ? val : $(window)[ 'scrollTop' ]() ) : this[ 'scroll' + name ] = val; }) : // Return the scroll offset this[0] == window || this[0] == document ? self[ (name == 'Left' ? 'pageXOffset' : 'pageYOffset') ] || $.boxModel && document.documentElement[ 'scroll' + name ] || document.body[ 'scroll' + name ] : this[0][ 'scroll' + name ]; }; }); $.fn.extend({ position: function() { var left = 0, top = 0, elem = this[0], offset, parentOffset, offsetParent, results; if (elem) { // Get *real* offsetParent offsetParent = this.offsetParent(); // Get correct offsets offset = this.offset(); parentOffset = offsetParent.offset(); // Subtract element margins offset.top -= num(elem, 'marginTop'); offset.left -= num(elem, 'marginLeft'); // Add offsetParent borders parentOffset.top += num(offsetParent, 'borderTopWidth'); parentOffset.left += num(offsetParent, 'borderLeftWidth'); // Subtract the two offsets results = { top: offset.top - parentOffset.top, left: offset.left - parentOffset.left }; } return results; }, offsetParent: function() { var offsetParent = this[0].offsetParent; while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && $.css(offsetParent, 'position') == 'static') ) offsetParent = offsetParent.offsetParent; return $(offsetParent); } }); function num(el, prop) { return parseInt($.css(el.jquery?el[0]:el,prop))||0; }; })(jQuery);
JavaScript
/* * Async Treeview 0.1 - Lazy-loading extension for Treeview * * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ * * Copyright (c) 2007 Jörn Zaefferer * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Revision: $Id$ * */ ;(function($) { function load(settings, root, child, container) { $.getJSON(settings.url, {root: root}, function(response) { function createNode(parent) { var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent); if (this.classes) { current.children("span").addClass(this.classes); } if (this.expanded) { current.addClass("open"); } if (this.hasChildren || this.children && this.children.length) { var branch = $("<ul/>").appendTo(current); if (this.hasChildren) { current.addClass("hasChildren"); createNode.call({ text:"placeholder", id:"placeholder", children:[] }, branch); } if (this.children && this.children.length) { $.each(this.children, createNode, [branch]) } } } $.each(response, createNode, [child]); $(container).treeview({add: child}); }); } var proxied = $.fn.treeview; $.fn.treeview = function(settings) { if (!settings.url) { return proxied.apply(this, arguments); } var container = this; load(settings, "source", this, container); var userToggle = settings.toggle; return proxied.call(this, $.extend({}, settings, { collapsed: true, toggle: function() { var $this = $(this); if ($this.hasClass("hasChildren")) { var childList = $this.removeClass("hasChildren").find("ul"); childList.empty(); load(settings, this.id, childList, container); } if (userToggle) { userToggle.apply(this, arguments); } } })); }; })(jQuery);
JavaScript
/* * Treeview 1.4 - jQuery plugin to hide and show branches of a tree * * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ * http://docs.jquery.com/Plugins/Treeview * * Copyright (c) 2007 Jörn Zaefferer * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Revision: $Id: jquery.treeview.js 4684 2008-02-07 19:08:06Z joern.zaefferer $ * */ ;(function($) { $.extend($.fn, { swapClass: function(c1, c2) { var c1Elements = this.filter('.' + c1); this.filter('.' + c2).removeClass(c2).addClass(c1); c1Elements.removeClass(c1).addClass(c2); return this; }, replaceClass: function(c1, c2) { return this.filter('.' + c1).removeClass(c1).addClass(c2).end(); }, hoverClass: function(className) { className = className || "hover"; return this.hover(function() { $(this).addClass(className); }, function() { $(this).removeClass(className); }); }, heightToggle: function(animated, callback) { animated ? this.animate({ height: "toggle" }, animated, callback) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); if(callback) callback.apply(this, arguments); }); }, heightHide: function(animated, callback) { if (animated) { this.animate({ height: "hide" }, animated, callback); } else { this.hide(); if (callback) this.each(callback); } }, prepareBranches: function(settings) { if (!settings.prerendered) { // mark last tree items this.filter(":last-child:not(ul)").addClass(CLASSES.last); // collapse whole tree, or only those marked as closed, anyway except those marked as open this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide(); } // return all items with sublists return this.filter(":has(>ul)"); }, applyClasses: function(settings, toggler) { this.filter(":has(>ul):not(:has(>a))").find(">span").click(function(event) { toggler.apply($(this).next()); }).add( $("a", this) ).hoverClass(); if (!settings.prerendered) { // handle closed ones first this.filter(":has(>ul:hidden)") .addClass(CLASSES.expandable) .replaceClass(CLASSES.last, CLASSES.lastExpandable); // handle open ones this.not(":has(>ul:hidden)") .addClass(CLASSES.collapsable) .replaceClass(CLASSES.last, CLASSES.lastCollapsable); // create hitarea this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea).each(function() { var classes = ""; $.each($(this).parent().attr("class").split(" "), function() { classes += this + "-hitarea "; }); $(this).addClass( classes ); }); } // apply event to hitarea this.find("div." + CLASSES.hitarea).click( toggler ); }, treeview: function(settings) { settings = $.extend({ cookieId: "treeview" }, settings); if (settings.add) { return this.trigger("add", [settings.add]); } if ( settings.toggle ) { var callback = settings.toggle; settings.toggle = function() { return callback.apply($(this).parent()[0], arguments); }; } // factory for treecontroller function treeController(tree, control) { // factory for click handlers function handler(filter) { return function() { // reuse toggle event handler, applying the elements to toggle // start searching for all hitareas toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() { // for plain toggle, no filter is provided, otherwise we need to check the parent element return filter ? $(this).parent("." + filter).length : true; }) ); return false; }; } // click on first element to collapse tree $("a:eq(0)", control).click( handler(CLASSES.collapsable) ); // click on second to expand tree $("a:eq(1)", control).click( handler(CLASSES.expandable) ); // click on third to toggle tree $("a:eq(2)", control).click( handler() ); } // handle toggle event function toggler() { $(this) .parent() // swap classes for hitarea .find(">.hitarea") .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) .end() // swap classes for parent li .swapClass( CLASSES.collapsable, CLASSES.expandable ) .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) // find child lists .find( ">ul" ) // toggle them .heightToggle( settings.animated, settings.toggle ); if ( settings.unique ) { $(this).parent() .siblings() // swap classes for hitarea .find(">.hitarea") .replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) .replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) .end() .replaceClass( CLASSES.collapsable, CLASSES.expandable ) .replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) .find( ">ul" ) .heightHide( settings.animated, settings.toggle ); } } function serialize() { function binary(arg) { return arg ? 1 : 0; } var data = []; branches.each(function(i, e) { data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0; }); $.cookie(settings.cookieId, data.join("") ); } function deserialize() { var stored = $.cookie(settings.cookieId); if ( stored ) { var data = stored.split(""); branches.each(function(i, e) { $(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ](); }); } } // add treeview class to activate styles this.addClass("treeview"); // prepare branches and find all tree items with child lists var branches = this.find("li").prepareBranches(settings); switch(settings.persist) { case "cookie": var toggleCallback = settings.toggle; settings.toggle = function() { serialize(); if (toggleCallback) { toggleCallback.apply(this, arguments); } }; deserialize(); break; case "location": var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); }); if ( current.length ) { current.addClass("selected").parents("ul, li").add( current.next() ).show(); } break; } branches.applyClasses(settings, toggler); // if control option is set, create the treecontroller and show it if ( settings.control ) { treeController(this, settings.control); $(settings.control).show(); } return this.bind("add", function(event, branches) { $(branches).prev() .removeClass(CLASSES.last) .removeClass(CLASSES.lastCollapsable) .removeClass(CLASSES.lastExpandable) .find(">.hitarea") .removeClass(CLASSES.lastCollapsableHitarea) .removeClass(CLASSES.lastExpandableHitarea); $(branches).find("li").andSelf().prepareBranches(settings).applyClasses(settings, toggler); }); } }); // classes used by the plugin // need to be styled via external stylesheet, see first example var CLASSES = $.fn.treeview.classes = { open: "open", closed: "closed", expandable: "expandable", expandableHitarea: "expandable-hitarea", lastExpandableHitarea: "lastExpandable-hitarea", collapsable: "collapsable", collapsableHitarea: "collapsable-hitarea", lastCollapsableHitarea: "lastCollapsable-hitarea", lastCollapsable: "lastCollapsable", lastExpandable: "lastExpandable", last: "last", hitarea: "hitarea" }; // provide backwards compability $.fn.Treeview = $.fn.treeview; })(jQuery);
JavaScript
function form_submit(){ document.getElementById("login").submit(); } function form_reset(){ document.getElementById("login").reset(); } function reloadcode(){ var verify=document.getElementById('safecode'); verify.setAttribute('src','code.php?'+Math.random()); }
JavaScript
/* * jQuery UI Accordion 1.6 * * Copyright (c) 2007 Jörn Zaefferer * * http://docs.jquery.com/UI/Accordion * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Revision: $Id: jquery.accordion.js 4876 2008-03-08 11:49:04Z joern.zaefferer $ * */ ;(function($) { // If the UI scope is not available, add it $.ui = $.ui || {}; $.fn.extend({ accordion: function(options, data) { var args = Array.prototype.slice.call(arguments, 1); return this.each(function() { if (typeof options == "string") { var accordion = $.data(this, "ui-accordion"); accordion[options].apply(accordion, args); // INIT with optional options } else if (!$(this).is(".ui-accordion")) $.data(this, "ui-accordion", new $.ui.accordion(this, options)); }); }, // deprecated, use accordion("activate", index) instead activate: function(index) { return this.accordion("activate", index); } }); $.ui.accordion = function(container, options) { // setup configuration this.options = options = $.extend({}, $.ui.accordion.defaults, options); this.element = container; $(container).addClass("ui-accordion"); if ( options.navigation ) { var current = $(container).find("a").filter(options.navigationFilter); if ( current.length ) { if ( current.filter(options.header).length ) { options.active = current; } else { options.active = current.parent().parent().prev(); current.addClass("current"); } } } // calculate active if not specified, using the first header options.headers = $(container).find(options.header); options.active = findActive(options.headers, options.active); if ( options.fillSpace ) { var maxHeight = $(container).parent().height(); options.headers.each(function() { maxHeight -= $(this).outerHeight(); }); var maxPadding = 0; options.headers.next().each(function() { maxPadding = Math.max(maxPadding, $(this).innerHeight() - $(this).height()); }).height(maxHeight - maxPadding); } else if ( options.autoheight ) { var maxHeight = 0; options.headers.next().each(function() { maxHeight = Math.max(maxHeight, $(this).outerHeight()); }).height(maxHeight); } options.headers .not(options.active || "") .next() .hide(); options.active.parent().andSelf().addClass(options.selectedClass); if (options.event) $(container).bind((options.event) + ".ui-accordion", clickHandler); }; $.ui.accordion.prototype = { activate: function(index) { // call clickHandler with custom event clickHandler.call(this.element, { target: findActive( this.options.headers, index )[0] }); }, enable: function() { this.options.disabled = false; }, disable: function() { this.options.disabled = true; }, destroy: function() { this.options.headers.next().css("display", ""); if ( this.options.fillSpace || this.options.autoheight ) { this.options.headers.next().css("height", ""); } $.removeData(this.element, "ui-accordion"); $(this.element).removeClass("ui-accordion").unbind(".ui-accordion"); } } function scopeCallback(callback, scope) { return function() { return callback.apply(scope, arguments); }; } function completed(cancel) { // if removed while animated data can be empty if (!$.data(this, "ui-accordion")) return; var instance = $.data(this, "ui-accordion"); var options = instance.options; options.running = cancel ? 0 : --options.running; if ( options.running ) return; if ( options.clearStyle ) { options.toShow.add(options.toHide).css({ height: "", overflow: "" }); } $(this).triggerHandler("change.ui-accordion", [options.data], options.change); } function toggle(toShow, toHide, data, clickedActive, down) { var options = $.data(this, "ui-accordion").options; options.toShow = toShow; options.toHide = toHide; options.data = data; var complete = scopeCallback(completed, this); // count elements to animate options.running = toHide.size() == 0 ? toShow.size() : toHide.size(); if ( options.animated ) { if ( !options.alwaysOpen && clickedActive ) { $.ui.accordion.animations[options.animated]({ toShow: jQuery([]), toHide: toHide, complete: complete, down: down, autoheight: options.autoheight }); } else { $.ui.accordion.animations[options.animated]({ toShow: toShow, toHide: toHide, complete: complete, down: down, autoheight: options.autoheight }); } } else { if ( !options.alwaysOpen && clickedActive ) { toShow.toggle(); } else { toHide.hide(); toShow.show(); } complete(true); } } function clickHandler(event) { var options = $.data(this, "ui-accordion").options; if (options.disabled) return false; // called only when using activate(false) to close all parts programmatically if ( !event.target && !options.alwaysOpen ) { options.active.parent().andSelf().toggleClass(options.selectedClass); var toHide = options.active.next(), data = { instance: this, options: options, newHeader: jQuery([]), oldHeader: options.active, newContent: jQuery([]), oldContent: toHide }, toShow = options.active = $([]); toggle.call(this, toShow, toHide, data ); return false; } // get the click target var clicked = $(event.target); // due to the event delegation model, we have to check if one // of the parent elements is our actual header, and find that if ( clicked.parents(options.header).length ) while ( !clicked.is(options.header) ) clicked = clicked.parent(); var clickedActive = clicked[0] == options.active[0]; // if animations are still active, or the active header is the target, ignore click if (options.running || (options.alwaysOpen && clickedActive)) return false; if (!clicked.is(options.header)) return; // switch classes options.active.parent().andSelf().toggleClass(options.selectedClass); if ( !clickedActive ) { clicked.parent().andSelf().addClass(options.selectedClass); } // find elements to show and hide var toShow = clicked.next(), toHide = options.active.next(), //data = [clicked, options.active, toShow, toHide], data = { instance: this, options: options, newHeader: clicked, oldHeader: options.active, newContent: toShow, oldContent: toHide }, down = options.headers.index( options.active[0] ) > options.headers.index( clicked[0] ); options.active = clickedActive ? $([]) : clicked; toggle.call(this, toShow, toHide, data, clickedActive, down ); return false; }; function findActive(headers, selector) { return selector != undefined ? typeof selector == "number" ? headers.filter(":eq(" + selector + ")") : headers.not(headers.not(selector)) : selector === false ? $([]) : headers.filter(":eq(0)"); } $.extend($.ui.accordion, { defaults: { selectedClass: "selected", alwaysOpen: true, animated: 'slide', event: "click", header: "a", autoheight: true, running: 0, navigationFilter: function() { return this.href.toLowerCase() == location.href.toLowerCase(); } }, animations: { slide: function(options, additions) { options = $.extend({ easing: "swing", duration: 300 }, options, additions); if ( !options.toHide.size() ) { options.toShow.animate({height: "show"}, options); return; } var hideHeight = options.toHide.height(), showHeight = options.toShow.height(), difference = showHeight / hideHeight; options.toShow.css({ height: 0, overflow: 'hidden' }).show(); options.toHide.filter(":hidden").each(options.complete).end().filter(":visible").animate({height:"hide"},{ step: function(now) { var current = (hideHeight - now) * difference; if ($.browser.msie || $.browser.opera) { current = Math.ceil(current); } options.toShow.height( current ); }, duration: options.duration, easing: options.easing, complete: function() { if ( !options.autoheight ) { options.toShow.css("height", "auto"); } options.complete(); } }); }, bounceslide: function(options) { this.slide(options, { easing: options.down ? "bounceout" : "swing", duration: options.down ? 1000 : 200 }); }, easeslide: function(options) { this.slide(options, { easing: "easeinout", duration: 700 }) } } }); })(jQuery);
JavaScript
/** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ /** * Create a cookie with the given name and value and other optional parameters. * * @example $.cookie('the_cookie', 'the_value'); * @desc Set the value of a cookie. * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true}); * @desc Create a cookie with all available options. * @example $.cookie('the_cookie', 'the_value'); * @desc Create a session cookie. * @example $.cookie('the_cookie', null); * @desc Delete a cookie by passing null as value. * * @param String name The name of the cookie. * @param String value The value of the cookie. * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. * If set to null or omitted, the cookie will be a session cookie and will not be retained * when the the browser exits. * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will * require a secure protocol (like HTTPS). * @type undefined * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ /** * Get the value of a cookie with the given name. * * @example $.cookie('the_cookie'); * @desc Get the value of a cookie. * * @param String name The name of the cookie. * @return The value of the cookie. * @type String * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } };
JavaScript
<script language="JavaScript" type="text/javascript"> <!-- // validateSignInInput function validateSignIn( form ) { var re = /^[\w-]+(\.[\w-]+)*@([\w-]+\.)+[a-zA-Z]{2,7}$/; var alertmsg = ""; var result = false; if ( form.usr.value == "" ) { alertmsg = "Username can't be blank."; } else if (form.pwd.value == "") { alertmsg += "Password can't be blank"; } else result = true; if (!result) alert(alertmsg); return result; } --> </script>
JavaScript
// ----------------------------------------------------------------------------------- // // Lightbox v2.04 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 2/9/08 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.rel == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { // if caption is not null if (this.imageArray[this.activeImage][1] != ""){ this.caption.update(this.imageArray[this.activeImage][1]).show(); } // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); });
JavaScript
// ----------------------------------------------------------------------------------- // // Lightbox v2.05 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 3/18/11 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.getAttribute("rel") == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; /*Bug Fixed by Andy Scott*/ this.lightboxImage.width = imgPreloader.width; this.lightboxImage.height = imgPreloader.height; /*End of Bug Fix*/ this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { this.caption.update(this.imageArray[this.activeImage][1]).show(); // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); });
JavaScript
// script.aculo.us scriptaculous.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010 // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // For details, see the script.aculo.us web site: http://script.aculo.us/ var Scriptaculous = { Version: '1.9.0', require: function(libraryName) { try{ // inserting via DOM fails in Safari 2.0, so brute force approach document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); } catch(e) { // for xhtml+xml served content, fall back to DOM methods var script = document.createElement('script'); script.type = 'text/javascript'; script.src = libraryName; document.getElementsByTagName('head')[0].appendChild(script); } }, REQUIRED_PROTOTYPE: '1.6.0.3', load: function() { function convertVersionString(versionString) { var v = versionString.replace(/_.*|\./g, ''); v = parseInt(v + '0'.times(4-v.length)); return versionString.indexOf('_') > -1 ? v-1 : v; } if((typeof Prototype=='undefined') || (typeof Element == 'undefined') || (typeof Element.Methods=='undefined') || (convertVersionString(Prototype.Version) < convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE))) throw("script.aculo.us requires the Prototype JavaScript framework >= " + Scriptaculous.REQUIRED_PROTOTYPE); var js = /scriptaculous\.js(\?.*)?$/; $$('script[src]').findAll(function(s) { return s.src.match(js); }).each(function(s) { var path = s.src.replace(js, ''), includes = s.src.match(/\?.*load=([a-z,]*)/); (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each( function(include) { Scriptaculous.require(path+include+'.js') }); }); } }; Scriptaculous.load();
JavaScript
// script.aculo.us builder.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010 // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // script.aculo.us is freely distributable under the terms of an MIT-style license. // For details, see the script.aculo.us web site: http://script.aculo.us/ var Builder = { NODEMAP: { AREA: 'map', CAPTION: 'table', COL: 'table', COLGROUP: 'table', LEGEND: 'fieldset', OPTGROUP: 'select', OPTION: 'select', PARAM: 'object', TBODY: 'table', TD: 'table', TFOOT: 'table', TH: 'table', THEAD: 'table', TR: 'table' }, // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, // due to a Firefox bug node: function(elementName) { elementName = elementName.toUpperCase(); // try innerHTML approach var parentTag = this.NODEMAP[elementName] || 'div'; var parentElement = document.createElement(parentTag); try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; } catch(e) {} var element = parentElement.firstChild || null; // see if browser added wrapping tags if(element && (element.tagName.toUpperCase() != elementName)) element = element.getElementsByTagName(elementName)[0]; // fallback to createElement approach if(!element) element = document.createElement(elementName); // abort if nothing could be created if(!element) return; // attributes (or text) if(arguments[1]) if(this._isStringOrNumber(arguments[1]) || (arguments[1] instanceof Array) || arguments[1].tagName) { this._children(element, arguments[1]); } else { var attrs = this._attributes(arguments[1]); if(attrs.length) { try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 parentElement.innerHTML = "<" +elementName + " " + attrs + "></" + elementName + ">"; } catch(e) {} element = parentElement.firstChild || null; // workaround firefox 1.0.X bug if(!element) { element = document.createElement(elementName); for(attr in arguments[1]) element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; } if(element.tagName.toUpperCase() != elementName) element = parentElement.getElementsByTagName(elementName)[0]; } } // text, or array of children if(arguments[2]) this._children(element, arguments[2]); return $(element); }, _text: function(text) { return document.createTextNode(text); }, ATTR_MAP: { 'className': 'class', 'htmlFor': 'for' }, _attributes: function(attributes) { var attrs = []; for(attribute in attributes) attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"'); return attrs.join(" "); }, _children: function(element, children) { if(children.tagName) { element.appendChild(children); return; } if(typeof children=='object') { // array can hold nodes and text children.flatten().each( function(e) { if(typeof e=='object') element.appendChild(e); else if(Builder._isStringOrNumber(e)) element.appendChild(Builder._text(e)); }); } else if(Builder._isStringOrNumber(children)) element.appendChild(Builder._text(children)); }, _isStringOrNumber: function(param) { return(typeof param=='string' || typeof param=='number'); }, build: function(html) { var element = this.node('div'); $(element).update(html.strip()); return element.down(); }, dump: function(scope) { if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); tags.each( function(tag){ scope[tag] = function() { return Builder.node.apply(Builder, [tag].concat($A(arguments))); }; }); } };
JavaScript
// ----------------------------------------------------------------------------------- // // Lightbox v2.04 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 2/9/08 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.rel == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { // if caption is not null if (this.imageArray[this.activeImage][1] != ""){ this.caption.update(this.imageArray[this.activeImage][1]).show(); } // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); });
JavaScript
// ----------------------------------------------------------------------------------- // // Lightbox v2.05 // by Lokesh Dhakar - http://www.lokeshdhakar.com // Last Modification: 3/18/11 // // For more information, visit: // http://lokeshdhakar.com/projects/lightbox2/ // // Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/ // - Free for use in both personal and commercial projects // - Attribution requires leaving author name, author link, and the license info intact. // // Thanks: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), and Thomas Fuchs(mir.aculo.us) for ideas, libs, and snippets. // Artemy Tregubenko (arty.name) for cleanup and help in updating to latest ver of proto-aculous. // // ----------------------------------------------------------------------------------- /* Table of Contents ----------------- Configuration Lightbox Class Declaration - initialize() - updateImageList() - start() - changeImage() - resizeImageContainer() - showImage() - updateDetails() - updateNav() - enableKeyboardNav() - disableKeyboardNav() - keyboardAction() - preloadNeighborImages() - end() Function Calls - document.observe() */ // ----------------------------------------------------------------------------------- // // Configurationl // LightboxOptions = Object.extend({ fileLoadingImage: 'images/loading.gif', fileBottomNavCloseImage: 'images/closelabel.gif', overlayOpacity: 0.8, // controls transparency of shadow overlay animate: true, // toggles resizing animations resizeSpeed: 7, // controls the speed of the image resizing animations (1=slowest and 10=fastest) borderSize: 10, //if you adjust the padding in the CSS, you will need to update this variable // When grouping images this is used to write: Image # of #. // Change it for non-english localization labelImage: "Image", labelOf: "of" }, window.LightboxOptions || {}); // ----------------------------------------------------------------------------------- var Lightbox = Class.create(); Lightbox.prototype = { imageArray: [], activeImage: undefined, // initialize() // Constructor runs on completion of the DOM loading. Calls updateImageList and then // the function inserts html at the bottom of the page which is used to display the shadow // overlay and the image container. // initialize: function() { this.updateImageList(); this.keyboardAction = this.keyboardAction.bindAsEventListener(this); if (LightboxOptions.resizeSpeed > 10) LightboxOptions.resizeSpeed = 10; if (LightboxOptions.resizeSpeed < 1) LightboxOptions.resizeSpeed = 1; this.resizeDuration = LightboxOptions.animate ? ((11 - LightboxOptions.resizeSpeed) * 0.15) : 0; this.overlayDuration = LightboxOptions.animate ? 0.2 : 0; // shadow fade in/out duration // When Lightbox starts it will resize itself from 250 by 250 to the current image dimension. // If animations are turned off, it will be hidden as to prevent a flicker of a // white 250 by 250 box. var size = (LightboxOptions.animate ? 250 : 1) + 'px'; // Code inserts html at the bottom of the page that looks similar to this: // // <div id="overlay"></div> // <div id="lightbox"> // <div id="outerImageContainer"> // <div id="imageContainer"> // <img id="lightboxImage"> // <div style="" id="hoverNav"> // <a href="#" id="prevLink"></a> // <a href="#" id="nextLink"></a> // </div> // <div id="loading"> // <a href="#" id="loadingLink"> // <img src="images/loading.gif"> // </a> // </div> // </div> // </div> // <div id="imageDataContainer"> // <div id="imageData"> // <div id="imageDetails"> // <span id="caption"></span> // <span id="numberDisplay"></span> // </div> // <div id="bottomNav"> // <a href="#" id="bottomNavClose"> // <img src="images/close.gif"> // </a> // </div> // </div> // </div> // </div> var objBody = $$('body')[0]; objBody.appendChild(Builder.node('div',{id:'overlay'})); objBody.appendChild(Builder.node('div',{id:'lightbox'}, [ Builder.node('div',{id:'outerImageContainer'}, Builder.node('div',{id:'imageContainer'}, [ Builder.node('img',{id:'lightboxImage'}), Builder.node('div',{id:'hoverNav'}, [ Builder.node('a',{id:'prevLink', href: '#' }), Builder.node('a',{id:'nextLink', href: '#' }) ]), Builder.node('div',{id:'loading'}, Builder.node('a',{id:'loadingLink', href: '#' }, Builder.node('img', {src: LightboxOptions.fileLoadingImage}) ) ) ]) ), Builder.node('div', {id:'imageDataContainer'}, Builder.node('div',{id:'imageData'}, [ Builder.node('div',{id:'imageDetails'}, [ Builder.node('span',{id:'caption'}), Builder.node('span',{id:'numberDisplay'}) ]), Builder.node('div',{id:'bottomNav'}, Builder.node('a',{id:'bottomNavClose', href: '#' }, Builder.node('img', { src: LightboxOptions.fileBottomNavCloseImage }) ) ) ]) ) ])); $('overlay').hide().observe('click', (function() { this.end(); }).bind(this)); $('lightbox').hide().observe('click', (function(event) { if (event.element().id == 'lightbox') this.end(); }).bind(this)); $('outerImageContainer').setStyle({ width: size, height: size }); $('prevLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage - 1); }).bindAsEventListener(this)); $('nextLink').observe('click', (function(event) { event.stop(); this.changeImage(this.activeImage + 1); }).bindAsEventListener(this)); $('loadingLink').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); $('bottomNavClose').observe('click', (function(event) { event.stop(); this.end(); }).bind(this)); var th = this; (function(){ var ids = 'overlay lightbox outerImageContainer imageContainer lightboxImage hoverNav prevLink nextLink loading loadingLink ' + 'imageDataContainer imageData imageDetails caption numberDisplay bottomNav bottomNavClose'; $w(ids).each(function(id){ th[id] = $(id); }); }).defer(); }, // // updateImageList() // Loops through anchor tags looking for 'lightbox' references and applies onclick // events to appropriate links. You can rerun after dynamically adding images w/ajax. // updateImageList: function() { this.updateImageList = Prototype.emptyFunction; document.observe('click', (function(event){ var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]'); if (target) { event.stop(); this.start(target); } }).bind(this)); }, // // start() // Display overlay and lightbox. If image is part of a set, add siblings to imageArray. // start: function(imageLink) { $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'hidden' }); // stretch overlay to fill page and fade in var arrayPageSize = this.getPageSize(); $('overlay').setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); new Effect.Appear(this.overlay, { duration: this.overlayDuration, from: 0.0, to: LightboxOptions.overlayOpacity }); this.imageArray = []; var imageNum = 0; if ((imageLink.getAttribute("rel") == 'lightbox')){ // if image is NOT part of a set, add single image to imageArray this.imageArray.push([imageLink.href, imageLink.title]); } else { // if image is part of a set.. this.imageArray = $$(imageLink.tagName + '[href][rel="' + imageLink.rel + '"]'). collect(function(anchor){ return [anchor.href, anchor.title]; }). uniq(); while (this.imageArray[imageNum][0] != imageLink.href) { imageNum++; } } // calculate top and left offset for the lightbox var arrayPageScroll = document.viewport.getScrollOffsets(); var lightboxTop = arrayPageScroll[1] + (document.viewport.getHeight() / 10); var lightboxLeft = arrayPageScroll[0]; this.lightbox.setStyle({ top: lightboxTop + 'px', left: lightboxLeft + 'px' }).show(); this.changeImage(imageNum); }, // // changeImage() // Hide most elements and preload image in preparation for resizing image container. // changeImage: function(imageNum) { this.activeImage = imageNum; // update global var // hide elements during transition if (LightboxOptions.animate) this.loading.show(); this.lightboxImage.hide(); this.hoverNav.hide(); this.prevLink.hide(); this.nextLink.hide(); // HACK: Opera9 does not currently support scriptaculous opacity and appear fx this.imageDataContainer.setStyle({opacity: .0001}); this.numberDisplay.hide(); var imgPreloader = new Image(); // once image is preloaded, resize image container imgPreloader.onload = (function(){ this.lightboxImage.src = this.imageArray[this.activeImage][0]; /*Bug Fixed by Andy Scott*/ this.lightboxImage.width = imgPreloader.width; this.lightboxImage.height = imgPreloader.height; /*End of Bug Fix*/ this.resizeImageContainer(imgPreloader.width, imgPreloader.height); }).bind(this); imgPreloader.src = this.imageArray[this.activeImage][0]; }, // // resizeImageContainer() // resizeImageContainer: function(imgWidth, imgHeight) { // get current width and height var widthCurrent = this.outerImageContainer.getWidth(); var heightCurrent = this.outerImageContainer.getHeight(); // get new width and height var widthNew = (imgWidth + LightboxOptions.borderSize * 2); var heightNew = (imgHeight + LightboxOptions.borderSize * 2); // scalars based on change from old to new var xScale = (widthNew / widthCurrent) * 100; var yScale = (heightNew / heightCurrent) * 100; // calculate size difference between new and old image, and resize if necessary var wDiff = widthCurrent - widthNew; var hDiff = heightCurrent - heightNew; if (hDiff != 0) new Effect.Scale(this.outerImageContainer, yScale, {scaleX: false, duration: this.resizeDuration, queue: 'front'}); if (wDiff != 0) new Effect.Scale(this.outerImageContainer, xScale, {scaleY: false, duration: this.resizeDuration, delay: this.resizeDuration}); // if new and old image are same size and no scaling transition is necessary, // do a quick pause to prevent image flicker. var timeout = 0; if ((hDiff == 0) && (wDiff == 0)){ timeout = 100; if (Prototype.Browser.IE) timeout = 250; } (function(){ this.prevLink.setStyle({ height: imgHeight + 'px' }); this.nextLink.setStyle({ height: imgHeight + 'px' }); this.imageDataContainer.setStyle({ width: widthNew + 'px' }); this.showImage(); }).bind(this).delay(timeout / 1000); }, // // showImage() // Display image and begin preloading neighbors. // showImage: function(){ this.loading.hide(); new Effect.Appear(this.lightboxImage, { duration: this.resizeDuration, queue: 'end', afterFinish: (function(){ this.updateDetails(); }).bind(this) }); this.preloadNeighborImages(); }, // // updateDetails() // Display caption, image number, and bottom nav. // updateDetails: function() { this.caption.update(this.imageArray[this.activeImage][1]).show(); // if image is part of set display 'Image x of x' if (this.imageArray.length > 1){ this.numberDisplay.update( LightboxOptions.labelImage + ' ' + (this.activeImage + 1) + ' ' + LightboxOptions.labelOf + ' ' + this.imageArray.length).show(); } new Effect.Parallel( [ new Effect.SlideDown(this.imageDataContainer, { sync: true, duration: this.resizeDuration, from: 0.0, to: 1.0 }), new Effect.Appear(this.imageDataContainer, { sync: true, duration: this.resizeDuration }) ], { duration: this.resizeDuration, afterFinish: (function() { // update overlay size and update nav var arrayPageSize = this.getPageSize(); this.overlay.setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' }); this.updateNav(); }).bind(this) } ); }, // // updateNav() // Display appropriate previous and next hover navigation. // updateNav: function() { this.hoverNav.show(); // if not first image in set, display prev image button if (this.activeImage > 0) this.prevLink.show(); // if not last image in set, display next image button if (this.activeImage < (this.imageArray.length - 1)) this.nextLink.show(); this.enableKeyboardNav(); }, // // enableKeyboardNav() // enableKeyboardNav: function() { document.observe('keydown', this.keyboardAction); }, // // disableKeyboardNav() // disableKeyboardNav: function() { document.stopObserving('keydown', this.keyboardAction); }, // // keyboardAction() // keyboardAction: function(event) { var keycode = event.keyCode; var escapeKey; if (event.DOM_VK_ESCAPE) { // mozilla escapeKey = event.DOM_VK_ESCAPE; } else { // ie escapeKey = 27; } var key = String.fromCharCode(keycode).toLowerCase(); if (key.match(/x|o|c/) || (keycode == escapeKey)){ // close lightbox this.end(); } else if ((key == 'p') || (keycode == 37)){ // display previous image if (this.activeImage != 0){ this.disableKeyboardNav(); this.changeImage(this.activeImage - 1); } } else if ((key == 'n') || (keycode == 39)){ // display next image if (this.activeImage != (this.imageArray.length - 1)){ this.disableKeyboardNav(); this.changeImage(this.activeImage + 1); } } }, // // preloadNeighborImages() // Preload previous and next images. // preloadNeighborImages: function(){ var preloadNextImage, preloadPrevImage; if (this.imageArray.length > this.activeImage + 1){ preloadNextImage = new Image(); preloadNextImage.src = this.imageArray[this.activeImage + 1][0]; } if (this.activeImage > 0){ preloadPrevImage = new Image(); preloadPrevImage.src = this.imageArray[this.activeImage - 1][0]; } }, // // end() // end: function() { this.disableKeyboardNav(); this.lightbox.hide(); new Effect.Fade(this.overlay, { duration: this.overlayDuration }); $$('select', 'object', 'embed').each(function(node){ node.style.visibility = 'visible' }); }, // // getPageSize() // getPageSize: function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // all except Explorer if(document.documentElement.clientWidth){ windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // for small pages with total height less then height of the viewport if(yScroll < windowHeight){ pageHeight = windowHeight; } else { pageHeight = yScroll; } // for small pages with total width less then width of the viewport if(xScroll < windowWidth){ pageWidth = xScroll; } else { pageWidth = windowWidth; } return [pageWidth,pageHeight]; } } document.observe('dom:loaded', function () { new Lightbox(); });
JavaScript
// script.aculo.us scriptaculous.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010 // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the // "Software"), to deal in the Software without restriction, including // without limitation the rights to use, copy, modify, merge, publish, // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: // // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // // For details, see the script.aculo.us web site: http://script.aculo.us/ var Scriptaculous = { Version: '1.9.0', require: function(libraryName) { try{ // inserting via DOM fails in Safari 2.0, so brute force approach document.write('<script type="text/javascript" src="'+libraryName+'"><\/script>'); } catch(e) { // for xhtml+xml served content, fall back to DOM methods var script = document.createElement('script'); script.type = 'text/javascript'; script.src = libraryName; document.getElementsByTagName('head')[0].appendChild(script); } }, REQUIRED_PROTOTYPE: '1.6.0.3', load: function() { function convertVersionString(versionString) { var v = versionString.replace(/_.*|\./g, ''); v = parseInt(v + '0'.times(4-v.length)); return versionString.indexOf('_') > -1 ? v-1 : v; } if((typeof Prototype=='undefined') || (typeof Element == 'undefined') || (typeof Element.Methods=='undefined') || (convertVersionString(Prototype.Version) < convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE))) throw("script.aculo.us requires the Prototype JavaScript framework >= " + Scriptaculous.REQUIRED_PROTOTYPE); var js = /scriptaculous\.js(\?.*)?$/; $$('script[src]').findAll(function(s) { return s.src.match(js); }).each(function(s) { var path = s.src.replace(js, ''), includes = s.src.match(/\?.*load=([a-z,]*)/); (includes ? includes[1] : 'builder,effects,dragdrop,controls,slider,sound').split(',').each( function(include) { Scriptaculous.require(path+include+'.js') }); }); } }; Scriptaculous.load();
JavaScript
// script.aculo.us builder.js v1.9.0, Thu Dec 23 16:54:48 -0500 2010 // Copyright (c) 2005-2010 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) // // script.aculo.us is freely distributable under the terms of an MIT-style license. // For details, see the script.aculo.us web site: http://script.aculo.us/ var Builder = { NODEMAP: { AREA: 'map', CAPTION: 'table', COL: 'table', COLGROUP: 'table', LEGEND: 'fieldset', OPTGROUP: 'select', OPTION: 'select', PARAM: 'object', TBODY: 'table', TD: 'table', TFOOT: 'table', TH: 'table', THEAD: 'table', TR: 'table' }, // note: For Firefox < 1.5, OPTION and OPTGROUP tags are currently broken, // due to a Firefox bug node: function(elementName) { elementName = elementName.toUpperCase(); // try innerHTML approach var parentTag = this.NODEMAP[elementName] || 'div'; var parentElement = document.createElement(parentTag); try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 parentElement.innerHTML = "<" + elementName + "></" + elementName + ">"; } catch(e) {} var element = parentElement.firstChild || null; // see if browser added wrapping tags if(element && (element.tagName.toUpperCase() != elementName)) element = element.getElementsByTagName(elementName)[0]; // fallback to createElement approach if(!element) element = document.createElement(elementName); // abort if nothing could be created if(!element) return; // attributes (or text) if(arguments[1]) if(this._isStringOrNumber(arguments[1]) || (arguments[1] instanceof Array) || arguments[1].tagName) { this._children(element, arguments[1]); } else { var attrs = this._attributes(arguments[1]); if(attrs.length) { try { // prevent IE "feature": http://dev.rubyonrails.org/ticket/2707 parentElement.innerHTML = "<" +elementName + " " + attrs + "></" + elementName + ">"; } catch(e) {} element = parentElement.firstChild || null; // workaround firefox 1.0.X bug if(!element) { element = document.createElement(elementName); for(attr in arguments[1]) element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; } if(element.tagName.toUpperCase() != elementName) element = parentElement.getElementsByTagName(elementName)[0]; } } // text, or array of children if(arguments[2]) this._children(element, arguments[2]); return $(element); }, _text: function(text) { return document.createTextNode(text); }, ATTR_MAP: { 'className': 'class', 'htmlFor': 'for' }, _attributes: function(attributes) { var attrs = []; for(attribute in attributes) attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + '="' + attributes[attribute].toString().escapeHTML().gsub(/"/,'&quot;') + '"'); return attrs.join(" "); }, _children: function(element, children) { if(children.tagName) { element.appendChild(children); return; } if(typeof children=='object') { // array can hold nodes and text children.flatten().each( function(e) { if(typeof e=='object') element.appendChild(e); else if(Builder._isStringOrNumber(e)) element.appendChild(Builder._text(e)); }); } else if(Builder._isStringOrNumber(children)) element.appendChild(Builder._text(children)); }, _isStringOrNumber: function(param) { return(typeof param=='string' || typeof param=='number'); }, build: function(html) { var element = this.node('div'); $(element).update(html.strip()); return element.down(); }, dump: function(scope) { if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); tags.each( function(tag){ scope[tag] = function() { return Builder.node.apply(Builder, [tag].concat($A(arguments))); }; }); } };
JavaScript
/* begin Page */ /* Created by Artisteer v3.0.0.39952 jQuery(function(){jQuery('#art-page-background-glare').css('zoom',1)});*/ // css hacks (function($) { // fix ie blinking var m = document.uniqueID && document.compatMode && !window.XMLHttpRequest && document.execCommand; try { if (!!m) { m('BackgroundImageCache', false, true); } } catch (oh) { }; // css helper var data = [ {str:navigator.userAgent,sub:'Chrome',ver:'Chrome',name:'chrome'}, {str:navigator.vendor,sub:'Apple',ver:'Version',name:'safari'}, {prop:window.opera,ver:'Opera',name:'opera'}, {str:navigator.userAgent,sub:'Firefox',ver:'Firefox',name:'firefox'}, {str:navigator.userAgent,sub:'MSIE',ver:'MSIE',name:'ie'}]; for (var n=0;n<data.length;n++) { if ((data[n].str && (data[n].str.indexOf(data[n].sub) != -1)) || data[n].prop) { var v = function(s){var i=s.indexOf(data[n].ver);return (i!=-1)?parseInt(s.substring(i+data[n].ver.length+1)):'';}; $('html').addClass(data[n].name+' '+data[n].name+v(navigator.userAgent) || v(navigator.appVersion)); break; } } })(jQuery); var _artStyleUrlCached = null; function artGetStyleUrl() { if (null == _artStyleUrlCached) { var ns; _artStyleUrlCached = ''; ns = jQuery('link'); for (var i = 0; i < ns.length; i++) { var l = ns[i].href; if (l && /style\.ie6\.css(\?.*)?$/.test(l)) return _artStyleUrlCached = l.replace(/style\.ie6\.css(\?.*)?$/, ''); } ns = jQuery('style'); for (var i = 0; i < ns.length; i++) { var matches = new RegExp('import\\s+"([^"]+\\/)style\\.ie6\\.css"').exec(ns[i].html()); if (null != matches && matches.length > 0) return _artStyleUrlCached = matches[1]; } } return _artStyleUrlCached; } function artFixPNG(element) { if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 7) { var src; if (element.tagName == 'IMG') { if (/\.png$/.test(element.src)) { src = element.src; element.src = artGetStyleUrl() + 'images/spacer.gif'; } } else { src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i); if (src) { src = src[1]; element.runtimeStyle.backgroundImage = 'none'; } } if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "')"; } } jQuery(function() { jQuery.each(jQuery('ul.art-hmenu>li:not(.art-hmenu-li-separator),ul.art-vmenu>li:not(.art-vmenu-separator)'), function (i, val) { var l = jQuery(val); var s = l.children('span'); if (s.length == 0) return; var t = l.find('span.t').last(); l.children('a').append(t.html(t.text())); s.remove(); }); });/* end Page */ /* begin Box, Sheet */ function artFluidSheetComputedWidth(percent, minval, maxval) { percent = parseInt(percent); var val = document.body.clientWidth / 100 * percent; return val < minval ? minval + 'px' : val > maxval ? maxval + 'px' : percent + '%'; }/* end Box, Sheet */ /* begin Menu */ jQuery(function() { jQuery.each(jQuery('ul.art-hmenu>li:not(:last-child)'), function(i, val) { jQuery('<li class="art-hmenu-li-separator"><span class="art-hmenu-separator"> </span></li>').insertAfter(val); }); if (!jQuery.browser.msie || parseInt(jQuery.browser.version) > 6) return; jQuery.each(jQuery('ul.art-hmenu li'), function(i, val) { val.j = jQuery(val); val.UL = val.j.children('ul:first'); if (val.UL.length == 0) return; val.A = val.j.children('a:first'); this.onmouseenter = function() { this.j.addClass('art-hmenuhover'); this.UL.addClass('art-hmenuhoverUL'); this.A.addClass('art-hmenuhoverA'); }; this.onmouseleave = function() { this.j.removeClass('art-hmenuhover'); this.UL.removeClass('art-hmenuhoverUL'); this.A.removeClass('art-hmenuhoverA'); }; }); }); /* end Menu */ /* begin Layout */ jQuery(function () { var c = jQuery('div.art-content'); if (c.length !== 1) return; var s = c.parent().children('.art-layout-cell:not(.art-content)'); if (jQuery.browser.msie && parseInt(jQuery.browser.version) < 8) { jQuery(window).bind('resize', function () { var w = 0; c.hide(); s.each(function () { w += this.clientWidth; }); c.w = c.parent().width(); c.css('width', c.w - w + 'px'); c.show(); }) var r = jQuery('div.art-content-layout-row').each(function () { this.c = jQuery(this).children('.art-layout-cell:not(.art-content)'); }); jQuery(window).bind('resize', function () { r.each(function () { if (this.h == this.clientHeight) return; this.c.css('height', 'auto'); this.h = this.clientHeight; this.c.css('height', this.h + 'px'); }); }); } var g = jQuery('.art-layout-glare-image'); jQuery(window).bind('resize', function () { g.each(function () { var i = jQuery(this); i.css('height', i.parents('.art-layout-cell').height() + 'px'); }); }); jQuery(window).trigger('resize'); });/* end Layout */ /* begin VMenu */ jQuery(function() { jQuery('ul.art-vmenu li').not(':first').before('<li class="art-vsubmenu-separator"><span class="art-vsubmenu-separator-span"> </span></li>'); jQuery('ul.art-vmenu > li.art-vsubmenu-separator').removeClass('art-vsubmenu-separator').addClass('art-vmenu-separator').children('span').removeClass('art-vsubmenu-separator-span').addClass('art-vmenu-separator-span'); jQuery('ul.art-vmenu > li > ul > li.art-vsubmenu-separator:first-child').removeClass('art-vsubmenu-separator').addClass('art-vmenu-separator').addClass('art-vmenu-separator-first').children('span').removeClass('art-vsubmenu-separator-span').addClass('art-vmenu-separator-span'); }); /* end VMenu */ /* begin VMenuItem */ jQuery(function() { jQuery('ul.art-vmenu a').click(function () { var a = jQuery(this); a.parents('ul.art-vmenu').find("ul, a").removeClass('active'); a.parent().children('ul').addClass('active'); a.parents('ul.art-vmenu ul').addClass('active'); a.parents('ul.art-vmenu li').children('a').addClass('active'); }); }); /* end VMenuItem */ /* begin Button */ function artButtonSetup(className) { jQuery.each(jQuery("a." + className + ", button." + className + ", input." + className), function (i, val) { var b = jQuery(val); if (!b.parent().hasClass('art-button-wrapper')) { if (b.is('input')) b.val(b.val().replace(/^\s*/, '')).css('zoom', '1'); if (!b.hasClass('art-button')) b.addClass('art-button'); jQuery("<span class='art-button-wrapper'><span class='art-button-l'> </span><span class='art-button-r'> </span></span>").insertBefore(b).append(b); if (b.hasClass('active')) b.parent().addClass('active'); } b.mouseover(function () { jQuery(this).parent().addClass("hover"); }); b.mouseout(function () { var b = jQuery(this); b.parent().removeClass("hover"); if (!b.hasClass('active')) b.parent().removeClass('active'); }); b.mousedown(function () { var b = jQuery(this); b.parent().removeClass("hover"); if (!b.hasClass('active')) b.parent().addClass('active'); }); b.mouseup(function () { var b = jQuery(this); if (!b.hasClass('active')) b.parent().removeClass('active'); }); }); } jQuery(function() { artButtonSetup("art-button"); }); /* end Button */
JavaScript
var timer = { minutes :0, seconds : 0, elm :null, samay : null, sep : ':', init : function(m,s,elm) { m = parseInt(m,10); s = parseInt(s,10); if(m < 0 || s <0 || isNaN(m) || isNaN(s)) { alert('Invalid Values'); return; } this.minutes = m; this.seconds = s; this.elm = document.getElementById(elm); timer.start(); }, start : function() { this.samay = setInterval((this.doCountDown),1000); }, doCountDown : function() { if(timer.seconds == 0) { if(timer.minutes == 0) { clearInterval(timer.samay); timerComplete(); return; } else { timer.seconds=60; timer.minutes--; } } timer.seconds--; timer.updateTimer(timer.minutes,timer.seconds); }, updateTimer : function(min,secs) { min = (min < 10 ? '0'+min : min); secs = (secs < 10 ? '0'+secs : secs); (this.elm).innerHTML = min+(this.sep)+secs; } } function timerComplete() { alert('time out buddy!!!'); } /* Example window.onload = init; function init() { timer.init(0,55,'container'); }*/ // Add Event function function addEvent(elm, evType, fn, useCapture) { // cross browser event handling for IE 5+, NS6+ and Gecko if (elm.addEventListener) { elm.addEventListener(evType, fn, useCapture); return true; } else if (elm.attachEvent) { var r = elm.attachEvent('on' + evType, fn); return r; } else { elm['on' + evType] = fn; } } // Add Listeners function addListeners(e) { // window unload listener addEvent(window, 'unload', exitAlert, false); } // Confirm exit needed function exitAlert() { if(confirm('Are you sure you want to leave the current page?')) { __doPostBack('<%=btnStart.UniqueID %>',''); } else { if(window.event) { window.event.returnValue = false; } else { e.preventDefault(); } return false; } } // Init addEvent(window, 'load', addListeners, false);
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ ~function(F){ //LRC歌词类 F.lyric = F.Class({ init : function (container, getpos, getlen){ this.container = F(container); //歌词外框对象 var st = this.container.node.style; this.container.css("fontSize",st.fontSize||"12px").css("backgroundColor",st.backgroundColor||"#000000").css("color",st.color||"#9a9a9a").css("overflow","hidden").html(""); this.box = this.container.append("div").css("position","relative"); //创建一个歌词内框 this.hlcolor = this.container.attr("hlcolor") || "#00ff00"; //高亮色 this.w = this.container.node.offsetWidth; //歌词外框的宽度 this.h = Number(this.container.attr("rowheight")||16); //行高 this.midPos = Math.round(this.container.node.offsetHeight/2-this.h/2);//歌词外框中心点高度 this.getpos = getpos; //获取当前时间 this.getlen = getlen; //获取播放结束时间; this.hl = []; //高亮对象 this.timer = null; //计时器 this.data = []; //歌词数组 this.row = 0; //当前行 this.rows = 0; //总行数 }, //重新定位 setPos : function (){ this.box.anime({top:this.midPos-Math.round(this.row*this.h)}); }, //从歌词地址显示 showFromUrl : function (url){ F.get(url).callback(F.proxy(this,"showFromString")); }, //从歌词内容显示 showFromString : function (lyrics){ if (!/\[\d+:\d+/.test(lyrics)){ this.box.html("很遗憾,此歌曲暂无匹配的歌词!"); return; } this.data = this.parseLrc(lyrics, this.container.css("fontSize")); this.rows = this.data.length; this.box.html(""); this.hl = []; var tmp = null; var html=[]; for (var s,i=0;i<this.rows;i++){ html[i] = '<div style="position:relative;left:'+(this.w-this.data[i].len)/2+'px;width:'+this.data[i].len+'px;height:'+this.h+'px;">'+ '<div style="position:absolute;">'+this.data[i].w+'</div>'+ '<div style="position:absolute;width:0px;white-space:nowrap;overflow:hidden;color:'+this.hlcolor+';">'+this.data[i].w+'</div>'+ '</div>'; } this.box.html(html.join("")); for(var a=this.box.child(),i=0;i<this.rows;i++){ this.hl[i] = a.item(i).child(1); } this.row = 0; this.setPos(); this.startShow(); }, //启动歌词显示定时器 startShow : function(){ window.clearInterval(this.timer); if (this.getlen()>0){ //得到总时间之后 this.data[this.rows-1].t2 = this.getlen(); this.timer = window.setInterval(this.show.proxy(this), 100); return; } this.timer = window.setInterval(this.startShow.proxy(this), 100); }, //动态显示歌词 show : function (){ var t = this.getpos(); if (t<this.data[0].t1) { return; //未开唱退出 } var o = this.data[this.row]; //当前歌词行 if (t>=o.t1 && t<o.t2){ //如果位于当前行 this.hl[this.row].width(Math.round((t-o.t1)/(o.t2-o.t1)*o.len)); }else{ //当行改变并且在最后一行前面时 this.hl[this.row].width(0); if (this.row<this.rows-1 && t>=this.data[this.row+1].t1 && t<this.data[this.row+1].t2){ //如果位于下一行 this.row++; }else{ this.row = this.seekRow(t); document.title = this.row; this.setPos(); } //o = this.data[this.row]; //新的当前行歌词 this.box.anime({top:this.midPos-Math.round(this.row*this.h), duration:this.h*100}); } }, //二分法检索歌词 seekRow : function (t){ var idx; var min = 0; var max = this.rows-1; while (min<=max){ idx = Math.floor((min+max)/2); if (t<this.data[idx].t1){ max = idx - 1; }else if(t==this.data[idx].t2){ return idx + 1; }else if(t>this.data[idx].t2){ min = idx + 1; }else{ return idx; } } }, //分析LRC歌词文本, 存取到数组中, 以供调用 parseLrc : function (lyrics,fontSize){ var a = []; lyrics = lyrics.replace(/((?:\[\d+:\d+(?:\.\d+)?\])+)([^\[\r\n]*)/g,function(row,labels,word){ labels.replace(/[^\[\]]+/g,function(label){ var t = label.split(":"); a.push({t1:t[0]*60000+t[1]*1000,t2:0,w:word,len:0}); }); }); a.sort(function (row1,row2){return row1.t1-row2.t1}); var len = a.length; var offset= /\[offset:(\-?\d+)\]/i.test(lyrics) ? Math.floor(RegExp.$1) : 0; //加上时间偏差 if (offset!=0){ for (var i=0;i<len;i++){ a[i].t1 += offset; } } for (var j=0;j<len-1;j++){ a[j].t2 = a[j+1].t1; } var obj = document.createElement("span"); document.body.appendChild(obj); obj.style.fontSize = fontSize; for (var k=0; k<len; k++){ obj.innerHTML = a[k].w; a[k].len = obj.offsetWidth; } document.body.removeChild(obj); obj = null; var unknown = [0,"未知"]; a.ar = ( lyrics.match(/\[ar[::](.+?)\]/i) || unknown ) [1]; a.al = ( lyrics.match(/\[al[::](.+?)\]/i) || unknown ) [1]; a.ti = ( lyrics.match(/\[ti[::](.+?)\]/i) || unknown ) [1]; a.by = ( lyrics.match(/\[by[::](.+?)\]/i) || unknown ) [1]; a.offset = offset; return a; } }); }($1stjs);
JavaScript
/**//**//**//**//**//**//* ** ================================================================================================== ** 类名:F.highlight ** 功能:语法高亮 ** 示例: --------------------------------------------------------------------------------------------------- 用法1:var html = F.highlight(strCode); 用法2:F("box").highlight(strCode); --------------------------------------------------------------------------------------------------- ** 作者:Li ** 邮件:61114579@qq.com ** 日期:2011-8-26 ** ================================================================================================== **/ ~function(F){ //语法高亮类 F.highlight = F.Fun({ init : function(codetxt, lang, skinName){ if(!codetxt) return ""; lang = lang || "html"; skinName = skinName || "dreamweaver"; this.skin = this.skins[skinName]; var dom = F("$1stjs_highlight"); if(!dom){ var a = [], o, langs={js:1,css:1,html:1}; for(var lan in langs){ o = this.skin[lan]; for(p in o){ a.push(F.mix(".$0$ .$1$ .$2$ { $3$ }", [skinName,lan,p,o[p]])); } } F.css(a).attr("id", "$1stjs_highlight"); } return '<span class="'+skinName+'">'+this.parsecode(codetxt, lang)+'</span>'; }, //获取代码片段 getSplinter : function(codetxt, dword){ var a = []; var oldword = false; codetxt.replace(/[\s\S]/g, function(s){ var isword = dword.indexOf(s)==-1; isword && oldword ? a[a.length-1]+=s : a.push(s); oldword = isword; }); return a; }, //代码片段解析 parsecode : function(codetxt, lang){ switch(lang){ case "js" : return this.js_parser(codetxt); case "css" : return this.css_parser(codetxt); case "html" : return this.html_parser(codetxt); } }, //JS解析 js_parser : function(codetxt){ if(!codetxt) return ""; var a = this.getSplinter(codetxt, "  ,?!:;\\/<>(){}[]\"'\r\n\t=+-|*%^&"); //alert(a); var keys = this.keys.js; var skin = this.skin.js; var len = a.length; var lastIdx = len - 1; var quote_opened = false; //引用标记 var quote_tag = ""; //引用标记类型 var comment_opened = false; //单行注释标记 var comment_type = ""; //注释类型 SL=单行, ML=多行 var re_opened = false; //正则标记 var rebra_opened = false; //正则里的中括号 //var line_num = 1; //行号 var html = [], i=0, s, pre=[], ispre; while(i<len){ ispre = true; s = a[i]; //处理空格 if(s==" "){ s = "&nbsp;"; } //处理换行 else if(s=="\n"){ if(comment_opened && comment_type=="SL"){ ispre = false; comment_opened = false; s = "</span><br/>"; }else{ s = "<br/>"; } //line_num++; } //处理TAB缩进 else if(s=="\t"){ s = "&nbsp;&nbsp;&nbsp;&nbsp;"; } //处理标签 else if(s=="<"||s==">"){ s = s.replace("<","&lt;").replace(">","&gt;"); } //处理转义 else if(s=="\\"){ if(!comment_opened){ //if(a[i+1]>=32&&a[i+1]<=127){ if(i<lastIdx){ s = "\\" + a[++i]; } //} } } //处理引号(引号前不能为转义字符) else if(s=="'" || s=='"'){ if(!comment_opened && !re_opened){ //打开 if(!quote_opened){ quote_opened = true; quote_tag = s; s = '<span class="string">' + s; //关闭 }else if(quote_tag==s) { s = s + '</span>'; quote_opened = false; quote_tag = ""; } } } //处理注释和正则 else if(s=="/"){ //处理多行注释结尾 if(comment_opened && comment_type=="ML" && i>0 && a[i-1]=="*"){ s = '/</span>'; ispre = false; comment_opened = false; }else if(!comment_opened && !quote_opened){ //处理单行注释开头 if(i<lastIdx && a[i+1]=="/"){ comment_opened = true; comment_type = "SL"; s = '<span class="comment">//'; ++i; //处理多行注释开头 }else if(i<lastIdx && a[i+1]=="*"){ comment_opened = true; comment_type = "ML"; s = '<span class="comment">/*'; ++i; //处理正则 }else{ //chkre start //判断前半部分是否有运算符和括号,以区分跟除号的区别 var isre = pre.length==0 || /[*/%<=>&|!~^?:;,([{}]|^(?:typeof|in|case|void|throw|return)$/.test(pre[0]) || /^(?:\+|\+\+\+|\-|\-\-\-)$/.test(pre.join("")); //判断后半部分是否有另一个斜杠 if(isre){ isre = false; var isbra = false; var k = i; var t = ["/"]; while(k<=lastIdx && a[k]!="\n"){ t.push(a[++k]); //处理正则表达式中的转义 if(a[k]=="\\"){ k<lastIdx && t.push(a[++k]); } //处理正则表达式中的中括号 else if(a[k]=="[" || a[k]=="]"){ isbra = a[k]=="["; } //处理正则结尾 else if(a[k]=="/" && isbra==false){ while(k<lastIdx && /[img]/.test(a[k+1])){ t.push(a[++k]); }; s = '<span class="regexp">'+t.join("").replace("<","&lt;").replace(">","&gt;")+'</span>'; i = k; isre = true; break; } } } if(!isre) s='<span class="operator">'+s+'</span>'; //chkre end } } } //处理关键字颜色代码 else if(!comment_opened && !quote_opened){ for(var k in keys){ if(keys[k].test(s)){ s = '<span class="'+k+'">'+s+'</span>' break; } } } if(!comment_opened && !quote_opened && ispre && /\S/.test(a[i])){ pre.unshift(a[i]); pre.length>3 && pre.pop(); } html.push(s); ++i; }; return '<span class="js">'+html.join("")+'</span>'; }, //CSS解析 css_parser : function(codetxt){ var a = this.getSplinter(codetxt, "  {:;}<>\r\n\t/*"); //alert(a); var skin = this.skin.css; var len = a.length; var lastIdx = len - 1; var comment_opened = false; //注释 var block_opened = false; //语句块 var colon_opened = false; //冒号 var html = [], i=0, s; while(i<len){ s = a[i]; //处理空格 if(s==" "){ s = "&nbsp;"; } //处理换行 else if(s=="\n"){ s = "<br/>"; } //处理TAB缩进 else if(s=="\t"){ s = "&nbsp;&nbsp;&nbsp;&nbsp;"; } //处理import else if(s=="!" && i<lastIdx && a[i+1]=="import"){ s = '<span class="_import">'+s+'</span>'; } //处理important else if(s=="@" && i<lastIdx && a[i+1]=="important"){ s = '<span class="important">'+s+'</span>'; } //处理media else if(s=="@" && i<lastIdx && a[i+1]=="media"){ s = '<span class="media">'+s+'</span>'; } //处理标签 else if(s=="<"||s==">"){ s = s.replace("<","&lt;").replace(">","&gt;"); }else if(!comment_opened){ //处理花括号 if(s=="{"||s=="}"){ block_opened = s=="{"; //处理冒号 }else if(s==":"){ if(block_opened){ colon_opened = true; }else{ s = '<span class="selector">'+s+'</span>'; } //处理分号 }else if(s==";"){ colon_opened = false; //处理注释开头 }else if(s=="/" && i<lastIdx && a[i+1]=="*"){ comment_opened = true; s = '<span class="comment">/*'; ++i; //高亮色 }else{ if(!block_opened){ s = '<span class="selector">'+s+'</span>'; }else{ if(!colon_opened){ s = '<span class="property">'+s+'</span>'; }else{ s = '<span class="value">'+s+'</span>'; } } } //处理注释结尾 }else if(comment_opened && s=="/" && i>0 && a[i-1]=="*"){ s = '/</span>'; comment_opened = false; } html.push(s); ++i; }; return '<span class="css">'+html.join("")+'</span>'; }, //HTML解析 html_parser : function(codetxt){ var html = []; var re = /(<(?:script|style)[\s\S]*?>)([\s\S]*?)(<\/(script|style)>)/i; while(re.test(codetxt)){ var s1=RegExp.$1, s2=RegExp.$2, s3=RegExp.$3, s4=RegExp.$4.toLowerCase(), s=RegExp.leftContext+s1; codetxt = s3 + RegExp.rightContext; var t = s4=="script" ? this.js_parser(s2) : this.css_parser(s2); html.push( this.htmlcode_parser(s)+t ); } html.push( this.htmlcode_parser(codetxt) ); return html.join(""); }, //HTML代码解析 htmlcode_parser : function(codetxt){ var a = this.getSplinter(codetxt, "  <>\r\n\t/\"'"); //alert(a); var keys = this.keys.html; var skin = this.skin.html; var len = a.length; var lastIdx = len - 1; var comment_opened = false; //注释 var quote_opened = false; //字符串 var block_opened = false; //语句块 var colon_opened = false; //冒号 var color = ""; var html = [], i=0, s; while(i<len){ s = a[i]; //处理空格 if(s==" "){ s = "&nbsp;"; } //处理换行 else if(s=="\n"){ s = "<br/>"; } //处理TAB缩进 else if(s=="\t"){ s = "&nbsp;&nbsp;&nbsp;&nbsp;"; } //处理左尖括号 else if(s=="<"){ s = "&lt;"; if(!comment_opened && !quote_opened && i<lastIdx){ var t = a[i+1]; //处理注释开始 if(t=="!--"){ comment_opened = true; s = '<span class="comment">' + s + a[++i]; } //处理关键字颜色代码 else if(t=="/" && i<lastIdx-2 && a[i+3]==">"){ t = a[i+2]; for(var k in keys){ if(keys[k].test(t)){ s = '<span class="'+k+'">&lt;/'+t+'&gt;</span>'; i += 3; break; } } } else{ for(var k in keys){ if(keys[k].test(t)){ s = '<span class="'+k+'">&lt;'+a[++i];//+'&gt;</span>'; break; } } } } } //处理右尖括号 else if(s==">"){ s = "&gt;"; if(comment_opened && i>0 && a[i-1]=="--"){ comment_opened = false; s = '&gt;</span>'; }else if(!comment_opened){ s = '&gt;</span>'; } } //处理引号 else if(s=="'" || s=='"'){ if(!comment_opened){ //打开 if(!quote_opened){ quote_opened = true; quote_tag = s; s = '<span class="attribute_value">' + s; //关闭 }else if(quote_tag==s) { s = s + '</span>'; quote_opened = false; quote_tag = ""; } } } html.push(s); ++i; } return '<span class="html">'+html.join("")+'</span>'; }, //关键字正则 keys : { //JS关键字 js : { bracket : /[{}[\]()]/, //括号 client_keywords : /^(?:window|document|body|alert|open|setTimeout|setInterval|location|execScript)$/, //客户端关键字 function_keyword : /^function$/, //函数关键字 native_keywords : /^(?:String|Number|Array|Boolean|RegExp|Math|Date|Function|Object|arguments|Error|eval|parseInt|parseFloat|escape|unescape|decodeURI|decodeURIComponent|encodeURI|encodeURIComponent|isNaN|isFinite|typeof)$/, //内建对象及global函数 number : /^(?:(0x[0-9a-fA-F]+|(?:\d+\.\d*|\d*\.\d+|\d+)(?:[eE][+\-]?\d+)?))$/, //数字 //还有Infinity operator : /[+\-*/%<=>&\|!~^?:]/, //运算符 reserved_keywords : /^(?:return|if|else|switch|case|break|default|for|in|do|while|continue|try|catch|finally|throw|void|with|new|delete|var|this|true|false|null|class)$/ //保留关键字 }, //CSS关键字 css : { important : /!important/, media : /@media/, _import : /@import/ }, //HTML关键字 html : { anchor_tags : /^(a)$/i, form_tags : /^(form|input|textarea|button|select|option)$/i, images_tags : /^(img)$/i, object_tags : /^(object|embed)$/i, //other_tags : //, script_tags : /^(script)$/i, //special_characters : //, style_tags : /^(link|style)$/i, table_tags : /^(table|tr|td|caption)$/i, tags : /^(!doctype|\?import|html|head|meta|title|body|div|span|p|ul|ol|li|dl|dt|dd|br|em|u|i|b|s|font|iframe|frame|frameset|h1|h2|h3|h4|h5|h6)$/i } }, //皮肤配置 skins : { //adobe dreamweaver dreamweaver : { js : { bracket : "color:#009; font-weight:bold;", //括号 client_keywords : "color:#909;", //客户端关键字 comment : "color:#999;", //注释 default_text : "color:#000;", //默认字符 function_keyword : "color:#000; font-weight:bold;", //函数关键字 identifier : "color:#000;", //标记符 native_keywords : "color:#099;", //内建对象 number : "color:#f00;", //数字 operator : "color:#00f;", //运算符 regexp : "color:#060;", //正则表达式 reserved_keywords : "color:#009; font-weight:bold;",//保留关键字 string : "color:#00f;" //字符串 }, css : { _import : "color:#099; font-weight:bold;", //import media : "color:#900; font-weight:bold;", //@media comment : "color:#999;", //注释 important : "color:#f00; font-weight:bold;", //!important property : "color:#009;", //属性 selector : "color:#f0f;", //选择器 string : "color:#060;", //字符串 value : "color:#00f;" //属性值 }, html : { anchor_tags : "color:#060;", //瞄标签 attribute_value : "color:#00f;", //属性值 comment : "color:#999;", //注释 form_tags : "color:#f90;", //表单标签 image_tags : "color:#909;", //图片标签 number : "color:#00f;", //数字 object_tags : "color:#900;", //多媒体标签 other_tags : "color:#009;", //其他标签 script_tags : "color:#900;", //脚本标签 special_characters : "color:#000;font-weight:bold;",//特殊字符 style_tags : "color:#909;", //样式标签 table_tags : "color:#099;", //表格标签 tags : "color:#009;", //标签 text : "color:#000;" //文本 }, bgcolor : "#fff" }, other : { js : { }, css : { }, html : { } } } }); }($1stjs);
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ //检测碰撞 //例如:F.iscross({x1:480,y1:0,x2:520,y2:40},{x1:480,y1:10,x2:40,y2:50}); F.iscross = function(o1,o2){ if(o1.x1==o2.x1&&o1.x2==o2.x2&&(o1.y1>o2.y1&&o1.y1<o2.y2||o1.y2>o2.y1&&o1.y2<o2.y2))return true; if(o1.y1==o2.y1&&o1.y2==o2.y2&&(o1.x1>o2.x1&&o1.x1<o2.x2||o1.x2>o2.x1&&o1.x2<o2.x2))return true; if(o1.x1==o2.x1&&o1.x2==o2.x2&&o1.y1==o2.y1&&o1.y2==o2.y2)return true; var a = [ [o2.y1,o2.x1], [o2.y1,o2.x2], [o2.y2,o2.x1], [o2.y2,o2.x2] ]; var y,x; for(var i=0; i<4; i++){ y=a[i][0], x=a[i][1]; if(y>o1.y1&&y<o1.y2&&x>o1.x1&&x<o1.x2) return true; } return false; }; //冒泡算法 F.bubble = function(a){ for(var i=a.length-1; i>0; i--){ for(var j=0; j<i; j++){ a[j]>a[i] && a.swap(i,j); } } return a; }
JavaScript
/* @title: 图片缩放插件 @author: likaituan @date: 2011.8.1 */ function zoomImg(obj){ var img = F(obj).css("width:100%; height:100%;"), sbox = img.parent().hover(function(e){ mirror.show() && bigimg.src(img.attr('bigimg')) && ibox.show(); },function(e){ mirror.hide() && ibox.hide(); }).bind("mousemove", function(e){ var x = F.limit(e.clientX-p.x-sw/2,0,sw); var y = F.limit(e.clientY-p.y-sh/2,0,sh); mirror.pos(x,y); ibox.scrollLeft(x/sw*iw).scrollTop(y/sh*ih); }), p = sbox.abspos(1), sw = sbox.width()/2, sh = sbox.height()/2, mirror = sbox.append("div").bg("#fede4f").border("#aaa").cursor("move").opacity(0.5).rect(0,sh,sw,sh,1).hide(); ibox = sbox.parent().append("div").cls("big_box").hide(); iw = ibox.width(), ih = ibox.height(), bigimg = ibox.append("img").css("width:200%; height:200%;"); }
JavaScript
// Simple Set Clipboard System // Author: Joseph Huckaby var ZeroClipboard = { version: "1.0.6", clients: {}, // registered upload clients on page, indexed by id moviePath: '/fw4/data/swf/copy.swf', // URL to movie nextId: 1, // ID of next movie $: function(thingy) { // simple DOM lookup utility function if (typeof(thingy) == 'string') thingy = document.getElementById(thingy); if (!thingy.addClass) { // extend element with a few useful methods thingy.hide = function() { this.style.display = 'none'; }; thingy.show = function() { this.style.display = ''; }; thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; }; thingy.removeClass = function(name) { var classes = this.className.split(/\s+/); var idx = -1; for (var k = 0; k < classes.length; k++) { if (classes[k] == name) { idx = k; k = classes.length; } } if (idx > -1) { classes.splice( idx, 1 ); this.className = classes.join(' '); } return this; }; thingy.hasClass = function(name) { return !!this.className.match( new RegExp("\\s*" + name + "\\s*") ); }; } return thingy; }, setMoviePath: function(path) { // set path to ZeroClipboard.swf this.moviePath = path; }, dispatch: function(id, eventName, args) { // receive event from flash movie, send to client var client = this.clients[id]; if (client) { client.receiveEvent(eventName, args); } }, register: function(id, client) { // register new client to receive events this.clients[id] = client; }, getDOMObjectPosition: function(obj, stopObj) { // get absolute coordinates for dom element var info = { left: 0, top: 0, width: obj.width ? obj.width : obj.offsetWidth, height: obj.height ? obj.height : obj.offsetHeight }; while (obj && (obj != stopObj)) { info.left += obj.offsetLeft; info.top += obj.offsetTop; obj = obj.offsetParent; } return info; }, Client: function(elem) { // constructor for new simple upload client this.handlers = {}; // unique ID this.id = ZeroClipboard.nextId++; this.movieId = 'ZeroClipboardMovie_' + this.id; // register client with singleton to receive flash events ZeroClipboard.register(this.id, this); // create movie if (elem) this.glue(elem); } }; ZeroClipboard.Client.prototype = { id: 0, // unique ID for us ready: false, // whether movie is ready to receive events or not movie: null, // reference to movie object clipText: '', // text to copy to clipboard handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor cssEffects: true, // enable CSS mouse effects on dom container handlers: null, // user event handlers glue: function(elem, appendElem, stylesToAdd) { // glue to DOM element // elem can be ID or actual DOM element object this.domElement = ZeroClipboard.$(elem); // float just above object, or zIndex 99 if dom element isn't set var zIndex = 99; if (this.domElement.style.zIndex) { zIndex = parseInt(this.domElement.style.zIndex, 10) + 1; } if (typeof(appendElem) == 'string') { appendElem = ZeroClipboard.$(appendElem); } else if (typeof(appendElem) == 'undefined') { appendElem = document.getElementsByTagName('body')[0]; } // find X/Y position of domElement var box = ZeroClipboard.getDOMObjectPosition(this.domElement, appendElem); // create floating DIV above element this.div = document.createElement('div'); var style = this.div.style; style.position = 'absolute'; style.left = '' + box.left + 'px'; style.top = '' + box.top + 'px'; style.width = '' + box.width + 'px'; style.height = '' + box.height + 'px'; style.zIndex = zIndex; if (typeof(stylesToAdd) == 'object') { for (addedStyle in stylesToAdd) { style[addedStyle] = stylesToAdd[addedStyle]; } } // style.backgroundColor = '#f00'; // debug appendElem.appendChild(this.div); this.div.innerHTML = this.getHTML( box.width, box.height ); }, getHTML: function(width, height) { // return HTML for movie var html = ''; var flashvars = 'id=' + this.id + '&width=' + width + '&height=' + height; if (navigator.userAgent.match(/MSIE/)) { // IE gets an OBJECT tag var protocol = location.href.match(/^https/i) ? 'https://' : 'http://'; html += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+protocol+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+width+'" height="'+height+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+flashvars+'"/><param name="wmode" value="transparent"/></object>'; } else { // all other browsers get an EMBED tag html += '<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+flashvars+'" wmode="transparent" />'; } return html; }, hide: function() { // temporarily hide floater offscreen if (this.div) { this.div.style.left = '-2000px'; } }, show: function() { // show ourselves after a call to hide() this.reposition(); }, destroy: function() { // destroy control and floater if (this.domElement && this.div) { this.hide(); this.div.innerHTML = ''; var body = document.getElementsByTagName('body')[0]; try { body.removeChild( this.div ); } catch(e) {;} this.domElement = null; this.div = null; } }, reposition: function(elem) { // reposition our floating div, optionally to new container // warning: container CANNOT change size, only position if (elem) { this.domElement = ZeroClipboard.$(elem); if (!this.domElement) this.hide(); } if (this.domElement && this.div) { var box = ZeroClipboard.getDOMObjectPosition(this.domElement); var style = this.div.style; style.left = '' + box.left + 'px'; style.top = '' + box.top + 'px'; } }, setText: function(newText) { // set text to be copied to clipboard this.clipText = newText; if (this.ready) this.movie.setText(newText); }, addEventListener: function(eventName, func) { // add user event listener for event // event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel eventName = eventName.toString().toLowerCase().replace(/^on/, ''); if (!this.handlers[eventName]) this.handlers[eventName] = []; this.handlers[eventName].push(func); }, setHandCursor: function(enabled) { // enable hand cursor (true), or default arrow cursor (false) this.handCursorEnabled = enabled; if (this.ready) this.movie.setHandCursor(enabled); }, setCSSEffects: function(enabled) { // enable or disable CSS effects on DOM container this.cssEffects = !!enabled; }, receiveEvent: function(eventName, args) { // receive event from flash eventName = eventName.toString().toLowerCase().replace(/^on/, ''); // special behavior for certain events switch (eventName) { case 'load': // movie claims it is ready, but in IE this isn't always the case... // bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function this.movie = document.getElementById(this.movieId); if (!this.movie) { var self = this; setTimeout( function() { self.receiveEvent('load', null); }, 1 ); return; } // firefox on pc needs a "kick" in order to set these in certain cases if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) { var self = this; setTimeout( function() { self.receiveEvent('load', null); }, 100 ); this.ready = true; return; } this.ready = true; this.movie.setText( this.clipText ); this.movie.setHandCursor( this.handCursorEnabled ); break; case 'mouseover': if (this.domElement && this.cssEffects) { this.domElement.addClass('hover'); if (this.recoverActive) this.domElement.addClass('active'); } break; case 'mouseout': if (this.domElement && this.cssEffects) { this.recoverActive = false; if (this.domElement.hasClass('active')) { this.domElement.removeClass('active'); this.recoverActive = true; } this.domElement.removeClass('hover'); } break; case 'mousedown': if (this.domElement && this.cssEffects) { this.domElement.addClass('active'); } break; case 'mouseup': if (this.domElement && this.cssEffects) { this.domElement.removeClass('active'); this.recoverActive = false; } break; } // switch eventName if (this.handlers[eventName]) { for (var idx = 0, len = this.handlers[eventName].length; idx < len; idx++) { var func = this.handlers[eventName][idx]; if (typeof(func) == 'function') { // actual function reference func(this, args); } else if ((typeof(func) == 'object') && (func.length == 2)) { // PHP style object + method, i.e. [myObject, 'myMethod'] func[0][ func[1] ](this, args); } else if (typeof(func) == 'string') { // name of function window[func](this, args); } } // foreach event handler defined } // user defined handler for event } };
JavaScript
//弹出层函数 var fw_dialog = Fw.cc({ init : function(box, isstep){ this.isstep = isstep; this.x = "center"; this.y = "middle"; this.pos = 0; this.timer = null; this.time = 0; this.box = $(box); if(!this.box){ this.box = $(document.body).append("div"); } return this; }, //增加遮照功能 setmask : function(mk){ if(!mk){ mk = document.createElement("div"); var css = "position:absolute; left:0px; top:0px; background-color:#cccccc; display:none;"; css += "opacity:0.5; filter:alpha(opacity=50); width:100%; height:100%;"; mk.style.cssText = css; //document.body.appendChild(mk); document.body.insertBefore(mk, this.box.obj); } this.mk = Fw.obj(mk); return this; }, //设置拖动功能 setdrag : function(hander){ Fw.drag(this.box.obj, hander); return this; }, //设置延时关闭的时间 settime : function(t){ this.time = t; return this; }, //设置延时关闭的时间 setpos : function(y,x,pos){ this.y = y; this.x = x; if(pos) this.pos=pos; return this; }, //设置打开按钮 setopen : function(trigger){ Fw.obj(trigger).onclick = this.open.bind(this); return this; }, //设置关闭按钮 setclose : function(trigger){ Fw.obj(trigger).onclick = this.close.bind(this); return this; }, //打开文件 openFromFile : function(url){ this.box.html('<iframe src="'+url+'" />'); this.open(); }, //打开弹出框 open : function(obj,e){ var This = this; var d = document.documentElement; if(this.mk){ var h = Math.max(document.body.offsetHeight,d.offsetHeight,d.clientHeight); this.mk.style.height = h + "px"; this.mk.style.display = "block"; } this.box.show(); var w = this.box.obj.offsetWidth; var h = this.box.obj.offsetHeight; if(this.pos==0){ var bw = Math.max(d.clientWidth, document.body.clientWidth); var bh = Math.max(d.clientHeight, document.body.clientHeight); var y = this.y=="top" ? 0 : this.y=="bottom" ? bh-h : this.y=="middle" ? Math.floor(bh/2-h/2) : this.y; var x = this.x=="left" ? 0 : this.x=="right" ? bw-w : this.x=="center" ? Math.floor(bw/2-w/2) : this.x; }else if(this.pos==1){ e = window.event || e; var my = e.clientY; var mx = e.clientX; var y = this.y=="top" ? my-h : this.y=="bottom" ? my : this.y=="middle" ? Math.floor(my-h/2) : my+this.y; var x = this.x=="left" ? mx-w : this.x=="right" ? mx : this.x=="center" ? Math.floor(mx-w/2) : mx+this.x; } this.box.css({x:x,y:y+d.scrollTop}); if(this.time>0){ this.timer = window.setTimeout(function(){This.close()},this.time); } this.onopen && this.onopen(obj); return this; }, //关闭弹出框 close : function(obj){ var This = this; this.time>0 && window.clearTimeout(this.timer); if(this.isstep){ var layer = this.box; var mk = this.mk; var t; var n = 1; var f = function(){ n -= 0.1; if(n<0){ clearTimeout(t); Fw.setOpacity(layer, 1); layer.hide(); if(mk){ Fw.setOpacity(mk, 0.5); mk.style.display = "none"; } This.onclose && This.onclose(obj); return; } Fw.setOpacity(layer, n); mk && Fw.setOpacity(mk, n*0.5); t = setTimeout(f, 24); }; f(); }else{ if(this.mk) this.mk.style.display = "none"; this.box.hide(); this.onclose && this.onclose(obj); } return this; } });
JavaScript
~function(){ function gv_cnzz(of){ var es = document.cookie.indexOf(";",of); if(es==-1) es=document.cookie.length; return unescape(document.cookie.substring(of,es)); } function gc_cnzz(n){ var arg=n+"="; var alen=arg.length; var clen=document.cookie.length; var i=0; while(i<clen){ var j=i+alen; if(document.cookie.substring(i,j)==arg) return gv_cnzz(j); i=document.cookie.indexOf(" ",i)+1; if(i==0) break; } return -1; } var cnzz_ed=new Date(); var cnzz_now=parseInt(cnzz_ed.getTime()); var cnzz_ref=document.referrer; var cnzz_data='&r='+escape(cnzz_ref.substr(0,512))+'&lg='+escape(navigator.systemLanguage)+'&ntime=0.47778400 1314341254'; var cnzz_a=gc_cnzz("cnzz_a3385509"); if(cnzz_a!=-1) cnzz_a=parseInt(cnzz_a)+1; else cnzz_a=0; var cnzz_rt=parseInt(gc_cnzz("rtime")); var cnzz_lt=parseInt(gc_cnzz("ltime")); var cnzz_st = parseInt((cnzz_now-cnzz_lt)/1000); var cnzz_sin = gc_cnzz("sin3385509"); if(cnzz_sin==-1) cnzz_sin='none'; if( cnzz_ref.split('/')[2]!=document.domain ) cnzz_sin=cnzz_ref; var cnzz_eid=gc_cnzz("cnzz_eid"); if(cnzz_eid==-1) cnzz_eid=Math.floor(Math.random()*100000000)+"-"+1314341254+"-"+cnzz_ref.substr(0,64); if(cnzz_lt<1000000){cnzz_rt=0;cnzz_lt=0;} if(cnzz_rt<1) cnzz_rt=0; if(((cnzz_now-cnzz_lt)>500*86400)&&(cnzz_lt>0)) cnzz_rt++; cnzz_data=cnzz_data+'&repeatip='+cnzz_a+'&rtime='+cnzz_rt+'&cnzz_eid='+escape(cnzz_eid)+'&showp='+escape(screen.width+'x'+screen.height)+'&st='+cnzz_st+'&sin='+escape(cnzz_sin.substr(0,512))+'&res=0'; //document.write('<a href="http://www.cnzz.com/stat/website.php?web_id=3385509" target=_blank title="&#31449;&#38271;&#32479;&#35745;">&#31449;&#38271;&#32479;&#35745;</a>'); F().append('<img src="http://zs14.cnzz.com/stat.htm?id=3385509'+cnzz_data+'" border=0 width=0 height=0 />'); var cnzz_et=(86400-cnzz_ed.getHours()*3600-cnzz_ed.getMinutes()*60-cnzz_ed.getSeconds()); cnzz_ed.setTime(cnzz_now+1000*(cnzz_et-cnzz_ed.getTimezoneOffset()*60)); document.cookie="cnzz_a3385509="+cnzz_a+";expires="+cnzz_ed.toGMTString()+ "; path=/"; document.cookie="sin3385509="+escape(cnzz_sin)+ ";expires="+cnzz_ed.toGMTString()+";path=/"; cnzz_ed.setTime(cnzz_now+1000*86400*182); document.cookie="rtime="+cnzz_rt+";expires="+cnzz_ed.toGMTString()+ ";path=/"; document.cookie="ltime="+cnzz_now+";expires=" + cnzz_ed.toGMTString()+ ";path=/"; document.cookie="cnzz_eid="+escape(cnzz_eid)+ ";expires="+cnzz_ed.toGMTString()+";path=/"; }(3385509);
JavaScript
//绘图类 var fw_draw2 = function(canvas, param){ var vml = Fw.getparam(param, "fillcolor", "strokecolor", "strokeweight"); var wh = Fw.getparam(param,"width", "height"); if(Fw.iscanvas){ if(canvas.obj.tagName.toLowerCase()!="canvas"){ canvas = canvas.append("canvas").attr(wh); } var ctx = canvas.obj.getContext("2d"); ctx.clearRect(0,0,canvas.obj.width,canvas.obj.height); canvas.attr(wh); ctx.fillStyle = vml.fillcolor; ctx.storkeStyle = vml.storkecolor; ctx.lineWidth = vml.strokeweight; ctx.beginPath(); switch(param.tp){ case "rectangle": ctx.fillRect(0, 0, param.width, param.height); break; case "circle": var radius = Math.round(param.width/2); ctx.arc(radius, radius, radius, 0, Math.PI*2, false); ctx.fill(); break; case "trapezoid": ctx.moveTo(param.x1, param.y1); ctx.lineTo(param.x2, param.y2); ctx.lineTo(param.x3, param.y3); ctx.lineTo(param.x4, param.y4); ctx.fill(); ctx.closePath(); break; case "line": ctx.moveTo(param.x1, param.y1); if(param.lineType==1){ ctx.lineTo(param.x1, param.y2); }else if(param.lineType==2){ ctx.lineTo(param.x2, param.y1); } ctx.lineTo(param.x2, param.y2); break; } ctx.stroke(); //ctx.scale(1,1); }else{ if(param.vml.indexOf(canvas.obj.tagName.toLowerCase())==-1){ canvas = canvas.append(param.vml).css(wh); //vml没有width和height属性 } switch(param.tp){ case "trapezoid": canvas.attr("path","m"+param.x1+","+param.y1+"l"+[param.x2,+param.y2,param.x3,param.y3,param.x4,param.y4].join(",")+"xe"); canvas.attr("coordsize",wh.width+","+wh.height); break; case "line": wh = {width:Math.abs(param.x2-param.x1),height:Math.abs(param.y2-param.y1)}; canvas.css(wh); //canvas.attr("from",param.x1+","+param.y1).attr("to",param.x2+","+param.y2); var pos; if(param.lineType==0){ pos = [param.x2-param.x1,param.y2-param.y1]; }else if(param.lineType==1){ pos = [0,param.y2-param.y1,param.x2-param.x1,param.y2-param.y1]; }else if(param.lineType==2){ pos = [param.x2-param.x1,0,param.x2-param.x1,param.y2-param.y1]; } canvas.attr({path:"m0,0l"+pos.join(",")+"e",filled:"f"}).css({position:"absolute",x:param.x1,y:param.y1}); canvas.attr("coordsize",wh.width+","+wh.height); break; } canvas.attr(vml); } return canvas; };
JavaScript
//最小值 min : function(arr){ return Math.min.apply(null,arr); }, //最大值 max : function(arr){ return Math.max.apply(null,arr); }, //求和 sum : function(arr){ return new Function("return "+arr.join("+"))(); }, //字符串复制 repeat : function (str, times){ return(new Array(times + 1)).join(str); }, //arguments转化为Array fw.a2a = function(as){ //return Array.prototype.slice.call(as); IE下报错 var a = []; for(var i=0,l=as.length; i<l; i++){ a[i] = as[i]; } return a; };
JavaScript
[ { name:"手机", ename:"Mobile", open:true, nodes: [ { name:"诺基亚", ename:"Nokia", nocheck:true, nodes: [ { name:"C6(音乐版)", ename:"C6(Music)"}, { name:"X6(导航版)", ename:"X6(GPS)"}, { name:"5230(世博版)", ename:"5230(SB)"}, { name:"N97mini", ename:"N97mini"} ]}, { name:"三星", ename:"Samsung", nocheck:true, nodes: [ { name:"I9000(联通版)", ename:"I9000(Unicom)"}, { name:"I9000(移动版)", ename:"I9000(China Mobile)"}, { name:"Galaxy Naos", ename:"Galaxy Naos"}, { name:"Fascinate", ename:"Fascinate"} ]}, { name:"索爱", ename:"Sony Ericsson", nocheck:true, nodes: [ { name:"U1i(Satio)", ename:"U1i(Satio)"}, { name:"U5i(Vivaz)", ename:"U5i(Vivaz)"}, { name:"X10i", ename:"X10i"}, { name:"Aino mini", ename:"Aino mini"} ]}, { name:"多普达", ename:"Dopod"} ]}, { name:"电脑", ename:"Computer", open:true, nodes: [ { name:"硬件", ename:"Hardware", nodes: [ { name:"主板", ename:"Motherboard"}, { name:"显卡", ename:"Graphics"}, { name:"CPU", ename:"CPU"}, { name:"内存", ename:"Memory"}, { name:"硬盘", ename:"Hard disk"}, { name:"音箱", ename:"Speaker"}, { name:"机箱", ename:"Chassis"}, { name:"电源", ename:"Power supply"} ]}, { name:"整机", ename:"Software", nodes: [ { name:"联想", ename:"Lenovo"}, { name:"戴尔", ename:"Dell"}, { name:"方正", ename:"Founder"}, { name:"宏基", ename:"Acer"}, { name:"惠普", ename:"Hewlett-Packard"} ]}, { name:"网络设备", ename:"Network", nodes: [ { name:"网卡", ename:"NIC"}, { name:"交换机", ename:"Switch"}, { name:"路由器", ename:"Router"} ]} ]}, { name:"家电", ename:"Home Appliances", open:true, nodes: [ { name:"冰箱", ename:"Refrigerator", isParent:true}, { name:"电视", ename:"TV", nodes: [ { name:"液晶", ename:"Liquid crystal"}, { name:"等离子", ename:"Plasma"}, { name:"3D", ename:"Three-dimensional"} ]}, { name:"空调", ename:"Air conditioning"} ]} ]
JavaScript
[ {key:"北京", items:[ {key:"北京市"}, {key:"东城"}, {key:"西城"}, {key:"崇文"}, {key:"宣武"}, {key:"朝阳"}, {key:"丰台"}, {key:"石景山"}, {key:"海淀"}, {key:"门头沟"}, {key:"房山"}, {key:"通州"}, {key:"顺义"}, {key:"昌平"}, {key:"大兴"}, {key:"平谷"}, {key:"怀柔"}, {key:"密云"}, {key:"延庆"} ]}, {key:"上海", items:[ {key:"上海市"}, {key:"黄浦"}, {key:"卢湾"}, {key:"徐汇"}, {key:"长宁"}, {key:"静安"}, {key:"普陀"}, {key:"闸北"}, {key:"虹口"}, {key:"杨浦"}, {key:"闵行"}, {key:"宝山"}, {key:"嘉定"}, {key:"浦东"}, {key:"金山"}, {key:"松江"}, {key:"青浦"}, {key:"南汇"}, {key:"奉贤"}, {key:"崇明"} ]}, {key:"天津", items:[ {key:"天津市"}, {key:"和平"}, {key:"东丽"}, {key:"河东"}, {key:"西青"}, {key:"河西"}, {key:"津南"}, {key:"南开"}, {key:"北辰"}, {key:"河北"}, {key:"武清"}, {key:"红挢"}, {key:"塘沽"}, {key:"汉沽"}, {key:"大港"}, {key:"宁河"}, {key:"静海"}, {key:"宝坻"}, {key:"蓟县"} ]}, {key:"重庆", items:[ {key:"城口县"}, {key:"大足县"}, {key:"垫江县"}, {key:"丰都县"}, {key:"奉节县"}, {key:"合川市"}, {key:"江津市"}, {key:"开县"}, {key:"梁平县"}, {key:" 南川市"}, {key:"彭水苗族土家族自治县"}, {key:"荣昌县"}, {key:"石柱土家族自治县"}, {key:"铜梁县"}, {key:"巫山县"}, {key:"巫溪县"}, {key:"武隆县"}, {key:"秀山土家族苗族自治县"}, {key:"永川市"}, {key:"酉阳土家族苗族自治县"}, {key:"云阳县"}, {key:"忠县"}, {key:"重庆市"}, {key:"潼南县"}, {key:"璧山县"}, {key:"綦江县"} ]}, {key:"安徽", items:[ {key:"安庆", items:[ {key:"安庆市"}, {key:"怀宁县"}, {key:"潜山县"}, {key:"宿松县"}, {key:"太湖县"}, {key:"桐城市"}, {key:"望江县"}, {key:"岳西县"}, {key:"枞阳县"} ]}, {key:"蚌埠", items:[ {key:"蚌埠市"}, {key:"固镇县"}, {key:"怀远县"}, {key:"五河县"} ]}, {key:"巢湖", items:[ {key:"巢湖市"}, {key:"含山县"}, {key:"和县"}, {key:"庐江县"}, {key:"无为县"} ]}, {key:"池州", items:[ {key:"池州市"}, {key:"东至县"}, {key:"青阳县"}, {key:"石台县"} ]}, {key:"滁州", items:[ {key:"滁州市"}, {key:"定远县"}, {key:"凤阳县"}, {key:"来安县"}, {key:"明光市"}, {key:"全椒县"}, {key:"天长市"} ]}, {key:"阜阳", items:[ {key:"阜南县"}, {key:"阜阳市"}, {key:"界首市"}, {key:"临泉县"}, {key:"太和县"}, {key:"颖上县"} ]}, {key:"合肥", items:[ {key:"长丰县"}, {key:"肥东县"}, {key:"肥西县"} ]}, {key:"淮北", items:[ {key:"淮北市"}, {key:"濉溪县"} ]}, {key:"淮南", items:[ {key:"凤台县"}, {key:"淮南市"} ]}, {key:"黄山", items:[ {key:"黄山市"}, {key:"祁门县"}, {key:"休宁县"}, {key:"歙县"}, {key:"黟县"} ]}, {key:"六安", items:[ {key:"霍邱县"}, {key:"霍山县"}, {key:"金寨县"}, {key:"六安市"}, {key:"寿县"}, {key:"舒城县"} ]}, {key:"马鞍山", items:[ {key:"当涂县"}, {key:"马鞍山市"} ]}, {key:"宿州", items:[ {key:"灵璧县"}, {key:"宿州市"}, {key:"萧县"}, {key:"泗县"}, {key:"砀山县"} ]}, {key:"铜陵", items:[ {key:"铜陵市"}, {key:"铜陵县"} ]}, {key:"芜湖", items:[ {key:"繁昌县"}, {key:"南陵县"}, {key:"芜湖市"}, {key:"芜湖县"} ]}, {key:"宣城", items:[ {key:"广德县"}, {key:"绩溪县"}, {key:"郎溪县"}, {key:"宁国市"}, {key:"宣城市"}, {key:"泾县"}, {key:"旌德县"} ]}, {key:"亳州", items:[ {key:"利辛县"}, {key:"蒙城县"}, {key:"涡阳县"}, {key:"亳州市"} ]} ]}, {key:"福建", items:[ {key:"福州", items:[ {key:"长乐市"}, {key:"福清市"}, {key:"福州市"}, {key:"连江县"}, {key:"罗源县"}, {key:"闽侯县"}, {key:"闽清县"}, {key:"平潭县"}, {key:"永泰县"} ]}, {key:"龙岩", items:[ {key:"长汀县"}, {key:"连城县"}, {key:"龙岩市"}, {key:"上杭县"}, {key:"武平县"}, {key:"永定县"}, {key:"漳平市"} ]}, {key:"南平", items:[ {key:"光泽县"}, {key:"建阳市"}, {key:"建瓯市"}, {key:"南平市"}, {key:"浦城县"}, {key:"邵武市"}, {key:"顺昌县"}, {key:"松溪县"}, {key:"武夷山市"}, {key:"政和县"} ]}, {key:"宁德", items:[ {key:"福安市"}, {key:"福鼎市"}, {key:"古田县"}, {key:"宁德市"}, {key:"屏南县"}, {key:"寿宁县"}, {key:"霞浦县"}, {key:"周宁县"}, {key:"柘荣县"} ]}, {key:"莆田", items:[ {key:"莆田市"}, {key:"仙游县"} ]}, {key:"泉州", items:[ {key:"安溪县"}, {key:"德化县"}, {key:"惠安县"}, {key:"金门县"}, {key:"晋江市"}, {key:"南安市"}, {key:"泉州市"}, {key:"石狮市"}, {key:"永春县"} ]}, {key:"三明", items:[ {key:"大田县"}, {key:"建宁县"}, {key:"将乐县"}, {key:"明溪县"}, {key:"宁化县"}, {key:"清流县"}, {key:"三明市"}, {key:"沙县"}, {key:"泰宁县"}, {key:"永安市"}, {key:"尤溪县"} ]}, {key:"厦门", items:[ {key:"厦门市"} ]}, {key:"漳州", items:[ {key:"长泰县"}, {key:"东山县"}, {key:"华安县"}, {key:"龙海市"}, {key:"南靖县"}, {key:"平和县"}, {key:"云霄县"}, {key:"漳浦县"}, {key:"漳州市"}, {key:"诏安县"} ]} ]}, {key:"甘肃", items:[ {key:"白银", items:[ {key:"白银市"}, {key:"会宁县"}, {key:"景泰县"}, {key:"靖远县"} ]}, {key:"定西", items:[ {key:"定西县"}, {key:"临洮县"}, {key:"陇西县"}, {key:"通渭县"}, {key:"渭源县"}, {key:"漳县"}, {key:"岷县"} ]}, {key:"甘南藏族自治州", items:[ {key:"迭部县"}, {key:"合作市"}, {key:"临潭县"}, {key:"碌曲县"}, {key:"玛曲县"}, {key:"夏河县"}, {key:"舟曲县"}, {key:"卓尼县"} ]}, {key:"嘉峪关", items:[ {key:"嘉峪关市"} ]}, {key:"金昌", items:[ {key:"金昌市"}, {key:"永昌县"} ]}, {key:"酒泉", items:[ {key:"阿克塞哈萨克族自治县"}, {key:"安西县"}, {key:"敦煌市"}, {key:"金塔县"}, {key:"酒泉市"}, {key:"肃北蒙古族自治县"}, {key:"玉门市"} ]}, {key:"兰州", items:[ {key:"皋兰县"}, {key:"兰州市"}, {key:"永登县"}, {key:"榆中县"} ]}, {key:"临夏回族自治州", items:[ {key:"东乡族自治县"}, {key:"广河县"}, {key:"和政县"}, {key:"积石山保安族东乡族撒拉族自治县"}, {key:"康乐县"}, {key:"临夏市"}, {key:"临夏县"}, {key:"永靖县"} ]}, {key:"陇南", items:[ {key:"成县"}, {key:"徽县"}, {key:"康县"}, {key:"礼县"}, {key:"两当县"}, {key:"文县"}, {key:"武都县"}, {key:"西和县"}, {key:"宕昌县"} ]}, {key:"平凉", items:[ {key:"崇信县"}, {key:"华亭县"}, {key:"静宁县"}, {key:"灵台县"}, {key:"平凉市"}, {key:"庄浪县"}, {key:"泾川县"} ]}, {key:"庆阳", items:[ {key:"合水县"}, {key:"华池县"}, {key:"环县"}, {key:"宁县"}, {key:"庆城县"}, {key:"庆阳市"}, {key:"镇原县"}, {key:"正宁县"} ]}, {key:"天水", items:[ {key:"甘谷县"}, {key:"秦安县"}, {key:"清水县"}, {key:"天水市"}, {key:"武山县"}, {key:"张家川回族自治县"} ]}, {key:"武威", items:[ {key:"古浪县"}, {key:"民勤县"}, {key:"天祝藏族自治县"}, {key:"武威市"} ]}, {key:"张掖", items:[ {key:"高台县"}, {key:"临泽县"}, {key:"民乐县"}, {key:"山丹县"}, {key:"肃南裕固族自治县"}, {key:"张掖市"} ]} ]}, {key:"广东", items:[ {key:"潮州", items:[ {key:"潮安县"}, {key:"潮州市"}, {key:"饶平县"} ]}, {key:"东莞", items:[ {key:"东莞市"} ]}, {key:"佛山", items:[ {key:"佛山市"} ]}, {key:"广州", items:[ {key:"从化市"}, {key:"广州市"}, {key:"增城市"} ]}, {key:"河源", items:[ {key:"东源县"}, {key:"和平县"}, {key:"河源市"}, {key:"连平县"}, {key:"龙川县"}, {key:"紫金县"} ]}, {key:"惠州", items:[ {key:"博罗县"}, {key:"惠东县"}, {key:"惠阳市"}, {key:"惠州市"}, {key:"龙门县"} ]}, {key:"江门", items:[ {key:"恩平市"}, {key:"鹤山市"}, {key:"江门市"}, {key:"开平市"}, {key:"台山市"} ]}, {key:"揭阳", items:[ {key:"惠来县"}, {key:"揭东县"}, {key:"揭西县"}, {key:"揭阳市"}, {key:"普宁市"} ]}, {key:"茂名", items:[ {key:"电白县"}, {key:"高州市"}, {key:"化州市"}, {key:"茂名市"}, {key:"信宜市"} ]}, {key:"梅州", items:[ {key:"大埔县"}, {key:"丰顺县"}, {key:"蕉岭县"}, {key:"梅县"}, {key:"梅州市"}, {key:"平远县"}, {key:"五华县"}, {key:"兴宁市"} ]}, {key:"清远", items:[ {key:"佛冈县"}, {key:"连南瑶族自治县"}, {key:"连山壮族瑶族自治县"}, {key:"连州市"}, {key:"清新县"}, {key:"清远市"}, {key:"阳山县"}, {key:"英德市"} ]}, {key:"汕头", items:[ {key:"潮阳市"}, {key:"澄海市"}, {key:"南澳县"}, {key:"汕头市"} ]}, {key:"汕尾", items:[ {key:"海丰县"}, {key:"陆丰市"}, {key:"陆河县"}, {key:"汕尾市"} ]}, {key:"韶关", items:[ {key:"乐昌市"}, {key:"南雄市"}, {key:"曲江县"}, {key:"仁化县"}, {key:"乳源瑶族自治县"}, {key:"韶关市"}, {key:"始兴县"}, {key:"翁源县"}, {key:"新丰县"} ]}, {key:"深圳", items:[ {key:"深圳市"} ]}, {key:"阳江", items:[ {key:"阳春市"}, {key:"阳东县"}, {key:"阳江市"}, {key:"阳西县"} ]}, {key:"云浮", items:[ {key:"罗定市"}, {key:"新兴县"}, {key:"郁南县"}, {key:"云安县"}, {key:"云浮市"} ]}, {key:"湛江", items:[ {key:"雷州市"}, {key:"廉江市"}, {key:"遂溪县"}, {key:"吴川市"}, {key:"徐闻县"}, {key:"湛江市"} ]}, {key:"肇庆", items:[ {key:"德庆县"}, {key:"封开县"}, {key:"高要市"}, {key:"广宁县"}, {key:"怀集县"}, {key:"四会市"}, {key:"肇庆市"} ]}, {key:"中山", items:[ {key:"中山市"} ]}, {key:"珠海", items:[ {key:"珠海市"} ]} ]}, {key:"广西", items:[ {key:"百色", items:[ {key:"百色市"}, {key:"德保县"}, {key:"靖西县"}, {key:"乐业县"}, {key:"凌云县"}, {key:"隆林各族自治县"}, {key:"那坡县"}, {key:"平果县"}, {key:"田东县"}, {key:"田林县"}, {key:"田阳县"}, {key:"西林县"} ]}, {key:"北海", items:[ {key:"北海市"}, {key:"合浦县"} ]}, {key:"崇左", items:[ {key:"崇左市"}, {key:"大新县"}, {key:"扶绥县"}, {key:"龙州县"}, {key:"宁明县"}, {key:"凭祥市"}, {key:"天等县"} ]}, {key:"防城港", items:[ {key:"东兴市"}, {key:"防城港市"}, {key:"上思县"} ]}, {key:"桂林", items:[ {key:"恭城瑶族自治县"}, {key:"灌阳县"}, {key:"桂林市"}, {key:"荔浦县"}, {key:"临桂县"}, {key:"灵川县"}, {key:"龙胜各族自治县"}, {key:"平乐县"}, {key:"全州县"}, {key:"兴安县"}, {key:"阳朔县"}, {key:"永福县"}, {key:"资源县"} ]}, {key:"贵港", items:[ {key:"桂平市"}, {key:"贵港市"}, {key:"平南县"} ]}, {key:"河池", items:[ {key:"巴马瑶族自治县"}, {key:"大化瑶族自治县"}, {key:"东兰县"}, {key:"都安瑶族自治县"}, {key:"凤山县"}, {key:"河池市"}, {key:"环江毛南族自治县"}, {key:"罗城仡佬族自治县"}, {key:"南丹县"}, {key:"天峨县"}, {key:"宜州市"} ]}, {key:"贺州", items:[ {key:"富川瑶族自治县"}, {key:"贺州市"}, {key:"昭平县"}, {key:"钟山县"} ]}, {key:"来宾", items:[ {key:"合山市"}, {key:"金秀瑶族自治县"}, {key:"来宾市"}, {key:"武宣县"}, {key:"象州县"}, {key:"忻城县"} ]}, {key:"柳州", items:[ {key:"柳城县"}, {key:"柳江县"}, {key:"柳州市"}, {key:"鹿寨县"}, {key:"融安县"}, {key:"融水苗族自治县"}, {key:"三江侗族自治县"} ]}, {key:"南宁", items:[ {key:"宾阳县"}, {key:"横县"}, {key:"隆安县"}, {key:"马山县"}, {key:"南宁市"}, {key:"上林县"}, {key:"武鸣县"}, {key:"邕宁县"} ]}, {key:"钦州", items:[ {key:"灵山县"}, {key:"浦北县"}, {key:"钦州市"} ]}, {key:"梧州", items:[ {key:"苍梧县"}, {key:"蒙山县"}, {key:"藤县"}, {key:"梧州市"}, {key:"岑溪市"} ]}, {key:"玉林", items:[ {key:"北流市"}, {key:"博白县"}, {key:"陆川县"}, {key:"容县"}, {key:"兴业县"}, {key:"玉林市"} ]} ]}, {key:"贵州", items:[ {key:"安顺", items:[ {key:"安顺市"}, {key:"关岭布依族苗族自治县"}, {key:"平坝县"}, {key:"普定县"}, {key:"镇宁布依族苗族自治县"}, {key:"紫云苗族布依族自治县"} ]}, {key:"毕节", items:[ {key:"毕节市"}, {key:"大方县"}, {key:"赫章县"}, {key:"金沙县"}, {key:"纳雍县"}, {key:"黔西县"}, {key:"威宁彝族回族苗族自治县"}, {key:"织金县"} ]}, {key:"贵阳", items:[ {key:"贵阳市"}, {key:"开阳县"}, {key:"清镇市"}, {key:"息烽县"}, {key:"修文县"} ]}, {key:"六盘水", items:[ {key:"六盘水市"}, {key:"六枝特区"}, {key:"盘县"}, {key:"水城县"} ]}, {key:"黔东南苗族侗族自治州", items:[ {key:"从江县"}, {key:"丹寨县"}, {key:"黄平县"}, {key:"剑河县"}, {key:"锦屏县"}, {key:"凯里市"}, {key:"雷山县"}, {key:"黎平县"}, {key:"麻江县"}, {key:"三穗县"}, {key:"施秉县"}, {key:"台江县"}, {key:"天柱县"}, {key:"镇远县"}, {key:"岑巩县"}, {key:"榕江县"} ]}, {key:"黔南布依族苗族自治州", items:[ {key:"长顺县"}, {key:"都匀市"}, {key:"独山县"}, {key:"福泉市"}, {key:"贵定县"}, {key:"惠水县"}, {key:"荔波县"}, {key:"龙里县"}, {key:"罗甸县"}, {key:"平塘县"}, {key:"三都水族自治县"}, {key:"瓮安县"} ]}, {key:"黔西南布依族苗族自治州", items:[ {key:"安龙县"}, {key:"册亨县"}, {key:"普安县"}, {key:"晴隆县"}, {key:"望谟县"}, {key:"兴仁县"}, {key:"兴义市"}, {key:"贞丰县"} ]}, {key:"铜仁", items:[ {key:"德江县"}, {key:"江口县"}, {key:"石阡县"}, {key:"思南县"}, {key:"松桃苗族自治县"}, {key:"铜仁市"}, {key:"万山特区"}, {key:"沿河土家族自治县"}, {key:"印江土家族苗族自治县"}, {key:"玉屏侗族自治县"} ]}, {key:"遵义", items:[ {key:"赤水市"}, {key:"道真仡佬族苗族自治县"}, {key:"凤冈县"}, {key:"仁怀市"}, {key:"绥阳县"}, {key:"桐梓县"}, {key:"务川仡佬族苗族自治县"}, {key:"习水县"}, {key:"余庆县"}, {key:"正安县"}, {key:"遵义市"}, {key:"遵义县"}, {key:"湄潭县"} ]} ]}, {key:"海南", items:[ {key:"白沙黎族自治县", items:[ {key:"白沙黎族自治县"} ]}, {key:"保亭黎族苗族自治县", items:[ {key:"保亭黎族苗族自治县"} ]}, {key:"昌江黎族自治县", items:[ {key:"昌江黎族自治县"} ]}, {key:"澄迈县", items:[ {key:"澄迈县"} ]}, {key:"定安县", items:[ {key:"定安县"} ]}, {key:"东方", items:[ {key:"东方市"} ]}, {key:"海口", items:[ {key:"海口市"} ]}, {key:"乐东黎族自治县", items:[ {key:"乐东黎族自治县"} ]}, {key:"临高县", items:[ {key:"临高县"} ]}, {key:"陵水黎族自治县", items:[ {key:"陵水黎族自治县"} ]}, {key:"琼海", items:[ {key:"琼海市"} ]}, {key:"琼中黎族苗族自治县", items:[ {key:"琼中黎族苗族自治县"} ]}, {key:"三亚", items:[ {key:"三亚市"} ]}, {key:"屯昌县", items:[ {key:"屯昌县"} ]}, {key:"万宁", items:[ {key:"万宁市"} ]}, {key:"文昌", items:[ {key:"文昌市"} ]}, {key:"五指山", items:[ {key:"五指山市"} ]}, {key:"儋州", items:[ {key:"儋州市"} ]} ]}, {key:"河北", items:[ {key:"保定", items:[ {key:"安国市"}, {key:"安新县"}, {key:"保定市"}, {key:"博野县"}, {key:"定兴县"}, {key:"定州市"}, {key:"阜平县"}, {key:"高碑店市"}, {key:"高阳县"}, {key:"满城县"}, {key:"清苑县"}, {key:"曲阳县"}, {key:"容城县"}, {key:"顺平县"}, {key:"唐县"}, {key:"望都县"}, {key:"雄县"}, {key:"徐水县"}, {key:"易县"}, {key:"涞水县"}, {key:"涞源县"}, {key:"涿州市"}, {key:"蠡县"} ]}, {key:"沧州", items:[ {key:"泊头市"}, {key:"沧县"}, {key:"沧州市"}, {key:"东光县"}, {key:"海兴县"}, {key:"河间市"}, {key:"黄骅市"}, {key:"孟村回族自治县"}, {key:"南皮县"}, {key:"青县"}, {key:"任丘市"}, {key:"肃宁县"}, {key:"吴桥县"}, {key:"献县"}, {key:"盐山县"} ]}, {key:"承德", items:[ {key:"承德市"}, {key:"承德县"}, {key:"丰宁满族自治县"}, {key:"宽城满族自治县"}, {key:"隆化县"}, {key:"滦平县"}, {key:"平泉县"}, {key:"围场满族蒙古族自治县"}, {key:"兴隆县"} ]}, {key:"邯郸", items:[ {key:"成安县"}, {key:"磁县"}, {key:"大名县"}, {key:"肥乡县"}, {key:"馆陶县"}, {key:"广平县"}, {key:"邯郸市"}, {key:"邯郸县"}, {key:"鸡泽县"}, {key:"临漳县"}, {key:"邱县"}, {key:"曲周县"}, {key:"涉县"}, {key:"魏县"}, {key:"武安市"}, {key:"永年县"} ]}, {key:"衡水", items:[ {key:"安平县"}, {key:"阜城县"}, {key:"故城县"}, {key:"衡水市"}, {key:"冀州市"}, {key:"景县"}, {key:"饶阳县"}, {key:"深州市"}, {key:"武强县"}, {key:"武邑县"}, {key:"枣强县"} ]}, {key:"廊坊", items:[ {key:"霸州市"}, {key:"大厂回族自治县"}, {key:"大城县"}, {key:"固安县"}, {key:"廊坊市"}, {key:"三河市"}, {key:"文安县"}, {key:"香河县"}, {key:"永清县"} ]}, {key:"秦皇岛", items:[ {key:"昌黎县"}, {key:"抚宁县"}, {key:"卢龙县"}, {key:"秦皇岛市"}, {key:"青龙满族自治县"} ]}, {key:"石家庄", items:[ {key:"高邑县"}, {key:"晋州市"}, {key:"井陉县"}, {key:"灵寿县"}, {key:"鹿泉市"}, {key:"平山县"}, {key:"深泽县"}, {key:"石家庄市"}, {key:"无极县"}, {key:"辛集市"}, {key:"新乐市"}, {key:"行唐县"}, {key:"元氏县"}, {key:"赞皇县"}, {key:"赵县"}, {key:"正定县"}, {key:"藁城市"}, {key:"栾城县"} ]}, {key:"唐山", items:[ {key:"乐亭县"}, {key:"滦南县"}, {key:"滦县"}, {key:"迁安市"}, {key:"迁西县"}, {key:"唐海县"}, {key:"唐山市"}, {key:"玉田县"}, {key:"遵化市"} ]}, {key:"邢台", items:[ {key:"柏乡县"}, {key:"广宗县"}, {key:"巨鹿县"}, {key:"临城县"}, {key:"临西县"}, {key:"隆尧县"}, {key:"南宫市"}, {key:"南和县"}, {key:"内丘县"}, {key:"宁晋县"}, {key:"平乡县"}, {key:"清河县"}, {key:"任县"}, {key:"沙河市"}, {key:"威县"}, {key:"新河县"}, {key:"邢台市"}, {key:"邢台县"} ]}, {key:"张家口", items:[ {key:"赤城县"}, {key:"崇礼县"}, {key:"沽源县"}, {key:"怀安县"}, {key:"怀来县"}, {key:"康保县"}, {key:"尚义县"}, {key:"万全县"}, {key:"蔚县"}, {key:"宣化县"}, {key:"阳原县"}, {key:"张北县"}, {key:"张家口市"}, {key:"涿鹿县"} ]} ]}, {key:"河南", items:[ {key:"安阳", items:[ {key:"安阳市"}, {key:"安阳县"}, {key:"滑县"}, {key:"林州市"}, {key:"内黄县"}, {key:"汤阴县"} ]}, {key:"鹤壁", items:[ {key:""}, {key:"鹤壁市"}, {key:"浚县"}, {key:"淇县"} ]}, {key:"济源", items:[ {key:"济源市"} ]}, {key:"焦作", items:[ {key:"博爱县"}, {key:"焦作市"}, {key:"孟州市"}, {key:"沁阳市"}, {key:"温县"}, {key:"武陟县"}, {key:"修武县"} ]}, {key:"开封", items:[ {key:"开封市"}, {key:"开封县"}, {key:"兰考县"}, {key:"通许县"}, {key:"尉氏县"}, {key:"杞县"} ]}, {key:"洛阳", items:[ {key:"洛宁县"}, {key:"洛阳市"}, {key:"孟津县"}, {key:"汝阳县"}, {key:"新安县"}, {key:"伊川县"}, {key:"宜阳县"}, {key:"偃师市"}, {key:"嵩县"}, {key:"栾川县"} ]}, {key:"南阳", items:[ {key:"邓州市"}, {key:"方城县"}, {key:"南阳市"}, {key:"南召县"}, {key:"内乡县"}, {key:"社旗县"}, {key:"唐河县"}, {key:"桐柏县"}, {key:"西峡县"}, {key:"新野县"}, {key:"镇平县"}, {key:"淅川县"} ]}, {key:"平顶山", items:[ {key:"宝丰县"}, {key:"鲁山县"}, {key:"平顶山市"}, {key:"汝州市"}, {key:"舞钢市"}, {key:"叶县"}, {key:"郏县"} ]}, {key:"三门峡", items:[ {key:"灵宝市"}, {key:"卢氏县"}, {key:"三门峡市"}, {key:"陕县"}, {key:"义马市"}, {key:"渑池县"} ]}, {key:"商丘", items:[ {key:"民权县"}, {key:"宁陵县"}, {key:"商丘市"}, {key:"夏邑县"}, {key:"永城市"}, {key:"虞城县"}, {key:"柘城县"}, {key:"睢县"} ]}, {key:"新乡", items:[ {key:"长垣县"}, {key:"封丘县"}, {key:"辉县市"}, {key:"获嘉县"}, {key:"卫辉市"}, {key:"新乡市"}, {key:"新乡县"}, {key:"延津县"}, {key:"原阳县"} ]}, {key:"信阳", items:[ {key:"固始县"}, {key:"光山县"}, {key:"淮滨县"}, {key:"罗山县"}, {key:"商城县"}, {key:"息县"}, {key:"新县"}, {key:"信阳市"}, {key:"潢川县"} ]}, {key:"许昌", items:[ {key:"长葛市"}, {key:"襄城县"}, {key:"许昌市"}, {key:"许昌县"}, {key:"禹州市"}, {key:"鄢陵县"} ]}, {key:"郑州", items:[ {key:"登封市"}, {key:"巩义市"}, {key:"新密市"}, {key:"新郑市"}, {key:"郑州市"}, {key:"中牟县"}, {key:"荥阳市"} ]}, {key:"周口", items:[ {key:"郸城县"}, {key:"扶沟县"}, {key:"淮阳县"}, {key:"鹿邑县"}, {key:"商水县"}, {key:"沈丘县"}, {key:"太康县"}, {key:"西华县"}, {key:"项城市"}, {key:"周口市"} ]}, {key:"驻马店", items:[ {key:"泌阳县"}, {key:"平舆县"}, {key:"确山县"}, {key:"汝南县"}, {key:"上蔡县"}, {key:"遂平县"}, {key:"西平县"}, {key:"新蔡县"}, {key:"正阳县"}, {key:"驻马店市"} ]}, {key:"漯河", items:[ {key:"临颍县"}, {key:"舞阳县"}, {key:"郾城县"}, {key:"漯河市"} ]}, {key:"濮阳", items:[ {key:"范县"}, {key:"南乐县"}, {key:"清丰县"}, {key:"台前县"}, {key:"濮阳市"}, {key:"濮阳县"} ]} ]}, {key:"黑龙江", items:[ {key:"大庆", items:[ {key:"大庆市"}, {key:"杜尔伯特蒙古族自治县"}, {key:"林甸县"}, {key:"肇源县"}, {key:"肇州县"} ]}, {key:"大兴安岭", items:[ {key:"呼玛县"}, {key:"漠河县"}, {key:"塔河县"} ]}, {key:"哈尔滨", items:[ {key:"阿城市"}, {key:"巴彦县"}, {key:"宾县"}, {key:"方正县"}, {key:"哈尔滨市"}, {key:"呼兰县"}, {key:"木兰县"}, {key:"尚志市"}, {key:"双城市"}, {key:"通河县"}, {key:"五常市"}, {key:"延寿县"}, {key:"依兰县"} ]}, {key:"鹤岗", items:[ {key:"鹤岗市"}, {key:"萝北县"}, {key:"绥滨县"} ]}, {key:"黑河", items:[ {key:"北安市"}, {key:"黑河市"}, {key:"嫩江县"}, {key:"孙吴县"}, {key:"五大连池市"}, {key:"逊克县"} ]}, {key:"鸡西", items:[ {key:"虎林市"}, {key:"鸡东县"}, {key:"鸡西市"}, {key:"密山市"} ]}, {key:"佳木斯", items:[ {key:"抚远县"}, {key:"富锦市"}, {key:"佳木斯市"}, {key:"汤原县"}, {key:"同江市"}, {key:"桦川县"}, {key:"桦南县"} ]}, {key:"牡丹江", items:[ {key:"东宁县"}, {key:"海林市"}, {key:"林口县"}, {key:"牡丹江市"}, {key:"穆棱市"}, {key:"宁安市"}, {key:"绥芬河市"} ]}, {key:"七台河", items:[ {key:"勃利县"}, {key:"七台河市"} ]}, {key:"齐齐哈尔", items:[ {key:"拜泉县"}, {key:"富裕县"}, {key:"甘南县"}, {key:"克东县"}, {key:"克山县"}, {key:"龙江县"}, {key:"齐齐哈尔市"}, {key:"泰来县"}, {key:"依安县"}, {key:"讷河市"} ]}, {key:"双鸭山", items:[ {key:"宝清县"}, {key:"集贤县"}, {key:"饶河县"}, {key:"双鸭山市"}, {key:"友谊县"} ]}, {key:"绥化", items:[ {key:"安达市"}, {key:"海伦市"}, {key:"兰西县"}, {key:"明水县"}, {key:"青冈县"}, {key:"庆安县"}, {key:"绥化市"}, {key:"绥棱县"}, {key:"望奎县"}, {key:"肇东市"} ]}, {key:"伊春", items:[ {key:"嘉荫县"}, {key:"铁力市"}, {key:"伊春市"} ]} ]}, {key:"湖北", items:[ {key:"鄂州", items:[ {key:"鄂州市"} ]}, {key:"恩施土家族苗族自治州", items:[ {key:"巴东县"}, {key:"恩施市"}, {key:"鹤峰县"}, {key:"建始县"}, {key:"来凤县"}, {key:"利川市"}, {key:"咸丰县"}, {key:"宣恩县"} ]}, {key:"黄冈", items:[ {key:"红安县"}, {key:"黄冈市"}, {key:"黄梅县"}, {key:"罗田县"}, {key:"麻城市"}, {key:"团风县"}, {key:"武穴市"}, {key:"英山县"}, {key:"蕲春县"}, {key:"浠水县"} ]}, {key:"黄石", items:[ {key:"大冶市"}, {key:"黄石市"}, {key:"阳新县"} ]}, {key:"荆门", items:[ {key:"荆门市"}, {key:"京山县"}, {key:"沙洋县"}, {key:"钟祥市"} ]}, {key:"荆州", items:[ {key:"公安县"}, {key:"洪湖市"}, {key:"监利县"}, {key:"江陵县"}, {key:"荆州市"}, {key:"石首市"}, {key:"松滋市"} ]}, {key:"潜江", items:[ {key:"潜江市"} ]}, {key:"神农架林区", items:[ {key:"神农架林区"} ]}, {key:"十堰", items:[ {key:"丹江口市"}, {key:"房县"}, {key:"十堰市"}, {key:"郧西县"}, {key:"郧县"}, {key:"竹山县"}, {key:"竹溪县"} ]}, {key:"随州", items:[ {key:"广水市"}, {key:"随州市"} ]}, {key:"天门", items:[ {key:"天门市"} ]}, {key:"武汉", items:[ {key:"武汉市"} ]}, {key:"仙桃", items:[ {key:"仙桃市"} ]}, {key:"咸宁", items:[ {key:"赤壁市"}, {key:"崇阳县"}, {key:"嘉鱼县"}, {key:"通城县"}, {key:"通山县"}, {key:"咸宁市"} ]}, {key:"襄樊", items:[ {key:"保康县"}, {key:"谷城县"}, {key:"老河口市"}, {key:"南漳县"}, {key:"襄樊市"}, {key:"宜城市"}, {key:"枣阳市"} ]}, {key:"孝感", items:[ {key:"安陆市"}, {key:"大悟县"}, {key:"汉川市"}, {key:"孝昌县"}, {key:"孝感市"}, {key:"应城市"}, {key:"云梦县"} ]}, {key:"宜昌", items:[ {key:"长阳土家族自治县"}, {key:"当阳市"}, {key:"五峰土家族自治县"}, {key:"兴山县"}, {key:"宜昌市"}, {key:"宜都市"}, {key:"远安县"}, {key:"枝江市"}, {key:"秭归县"} ]} ]}, {key:"湖南", items:[ {key:"常德", items:[ {key:"安乡县"}, {key:"常德市"}, {key:"汉寿县"}, {key:"津市市"}, {key:"临澧县"}, {key:"石门县"}, {key:"桃源县"}, {key:"澧县"} ]}, {key:"长沙", items:[ {key:"长沙市"}, {key:"长沙县"}, {key:"宁乡县"}, {key:"望城县"}, {key:"浏阳市"} ]}, {key:"郴州", items:[ {key:"安仁县"}, {key:"郴州市"}, {key:"桂东县"}, {key:"桂阳县"}, {key:"嘉禾县"}, {key:"临武县"}, {key:"汝城县"}, {key:"宜章县"}, {key:"永兴县"}, {key:"资兴市"} ]}, {key:"衡阳", items:[ {key:"常宁市"}, {key:"衡东县"}, {key:"衡南县"}, {key:"衡山县"}, {key:"衡阳市"}, {key:"衡阳县"}, {key:"祁东县"}, {key:"耒阳市"} ]}, {key:"怀化", items:[ {key:"辰溪县"}, {key:"洪江市"}, {key:"怀化市"}, {key:"会同县"}, {key:"靖州苗族侗族自治县"}, {key:"麻阳苗族自治县"}, {key:"通道侗族自治县"}, {key:"新晃侗族自治县"}, {key:"中方县"}, {key:"芷江侗族自治县"}, {key:"沅陵县"}, {key:"溆浦县"} ]}, {key:"娄底", items:[ {key:"冷水江市"}, {key:"涟源市"}, {key:"娄底市"}, {key:"双峰县"}, {key:"新化县"} ]}, {key:"邵阳", items:[ {key:"城步苗族自治县"}, {key:"洞口县"}, {key:"隆回县"}, {key:"邵东县"}, {key:"邵阳市"}, {key:"邵阳县"}, {key:"绥宁县"}, {key:"武冈市"}, {key:"新宁县"}, {key:"新邵县"} ]}, {key:"湘潭", items:[ {key:"韶山市"}, {key:"湘潭市"}, {key:"湘潭县"}, {key:"湘乡市"} ]}, {key:"湘西土家族苗族自治州", items:[ {key:"保靖县"}, {key:"凤凰县"}, {key:"古丈县"}, {key:"花垣县"}, {key:"吉首市"}, {key:"龙山县"}, {key:"永顺县"}, {key:"泸溪县"} ]}, {key:"益阳", items:[ {key:"安化县"}, {key:"南县"}, {key:"桃江县"}, {key:"益阳市"}, {key:"沅江市"} ]}, {key:"永州", items:[ {key:"道县"}, {key:"东安县"}, {key:"江华瑶族自治县"}, {key:"江永县"}, {key:"蓝山县"}, {key:"宁远县"}, {key:"祁阳县"}, {key:"双牌县"}, {key:"新田县"}, {key:"永州市"} ]}, {key:"岳阳", items:[ {key:"华容县"}, {key:"临湘市"}, {key:"平江县"}, {key:"湘阴县"}, {key:"岳阳市"}, {key:"岳阳县"}, {key:"汨罗市"} ]}, {key:"张家界", items:[ {key:"慈利县"}, {key:"桑植县"}, {key:"张家界市"} ]}, {key:"株洲", items:[ {key:"茶陵县"}, {key:"炎陵县"}, {key:"株洲市"}, {key:"株洲县"}, {key:"攸县"}, {key:"醴陵市"} ]} ]}, {key:"吉林", items:[ {key:"白城", items:[ {key:"白城市"}, {key:"大安市"}, {key:"通榆县"}, {key:"镇赉县"}, {key:"洮南市"} ]}, {key:"白山", items:[ {key:"白山市"}, {key:"长白朝鲜族自治县"}, {key:"抚松县"}, {key:"江源县"}, {key:"靖宇县"}, {key:"临江市"} ]}, {key:"长春", items:[ {key:"长春市"}, {key:"德惠市"}, {key:"九台市"}, {key:"农安县"}, {key:"榆树市"} ]}, {key:"吉林", items:[ {key:"吉林市"}, {key:"磐石市"}, {key:"舒兰市"}, {key:"永吉县"}, {key:"桦甸市"}, {key:"蛟河市"} ]}, {key:"辽源", items:[ {key:"东丰县"}, {key:"东辽县"}, {key:"辽源市"} ]}, {key:"四平", items:[ {key:"公主岭市"}, {key:"梨树县"}, {key:"双辽市"}, {key:"四平市"}, {key:"伊通满族自治县"} ]}, {key:"松原", items:[ {key:"长岭县"}, {key:"扶余县"}, {key:"乾安县"}, {key:"前郭尔罗斯蒙古族自治县"}, {key:"松原市"} ]}, {key:"通化", items:[ {key:"辉南县"}, {key:"集安市"}, {key:"柳河县"}, {key:"梅河口市"}, {key:"通化市"}, {key:"通化县"} ]}, {key:"延边朝鲜族自治州", items:[ {key:"安图县"}, {key:"敦化市"}, {key:"和龙市"}, {key:"龙井市"}, {key:"图们市"}, {key:"汪清县"}, {key:"延吉市"}, {key:"珲春市"} ]} ]}, {key:"江苏", items:[ {key:"常州", items:[ {key:"常州市"}, {key:"金坛市"}, {key:"溧阳市"} ]}, {key:"淮安", items:[ {key:"洪泽县"}, {key:"淮安市"}, {key:"金湖县"}, {key:"涟水县"}, {key:"盱眙县"} ]}, {key:"连云港", items:[ {key:"东海县"}, {key:"赣榆县"}, {key:"灌南县"}, {key:"灌云县"}, {key:"连云港市"} ]}, {key:"南京", items:[ {key:"高淳县"}, {key:"南京市"}, {key:"溧水县"} ]}, {key:"南通", items:[ {key:"海安县"}, {key:"海门市"}, {key:"南通市"}, {key:"启东市"}, {key:"如东县"}, {key:"如皋市"}, {key:"通州市"} ]}, {key:"苏州", items:[ {key:"常熟市"}, {key:"昆山市"}, {key:"苏州市"}, {key:"太仓市"}, {key:"吴江市"}, {key:"张家港市"} ]}, {key:"宿迁", items:[ {key:"宿迁市"}, {key:"宿豫县"}, {key:"沭阳县"}, {key:"泗洪县"}, {key:"泗阳县"} ]}, {key:"泰州", items:[ {key:"姜堰市"}, {key:"靖江市"}, {key:"泰兴市"}, {key:"泰州市"}, {key:"兴化市"} ]}, {key:"无锡", items:[ {key:"江阴市"}, {key:"无锡市"}, {key:"宜兴市"} ]}, {key:"徐州", items:[ {key:"丰县"}, {key:"沛县"}, {key:"铜山县"}, {key:"新沂市"}, {key:"徐州市"}, {key:"邳州市"}, {key:"睢宁县"} ]}, {key:"盐城", items:[ {key:"滨海县"}, {key:"大丰市"}, {key:"东台市"}, {key:"阜宁县"}, {key:"建湖县"}, {key:"射阳县"}, {key:"响水县"}, {key:"盐城市"}, {key:"盐都县"} ]}, {key:"扬州", items:[ {key:"宝应县"}, {key:"高邮市"}, {key:"江都市"}, {key:"扬州市"}, {key:"仪征市"} ]}, {key:"镇江", items:[ {key:"丹阳市"}, {key:"句容市"}, {key:"扬中市"}, {key:"镇江市"} ]} ]}, {key:"江西", items:[ {key:"抚州", items:[ {key:"崇仁县"}, {key:"东乡县"}, {key:"抚州市"}, {key:"广昌县"}, {key:"金溪县"}, {key:"乐安县"}, {key:"黎川县"}, {key:"南城县"}, {key:"南丰县"}, {key:"宜黄县"}, {key:"资溪县"} ]}, {key:"赣州", items:[ {key:"安远县"}, {key:"崇义县"}, {key:"大余县"}, {key:"定南县"}, {key:"赣县"}, {key:"赣州市"}, {key:"会昌县"}, {key:"龙南县"}, {key:"南康市"}, {key:"宁都县"}, {key:"全南县"}, {key:"瑞金市"}, {key:"上犹县"}, {key:"石城县"}, {key:"信丰县"}, {key:"兴国县"}, {key:"寻乌县"}, {key:"于都县"} ]}, {key:"吉安", items:[ {key:"安福县"}, {key:"吉安市"}, {key:"吉安县"}, {key:"吉水县"}, {key:"井冈山市"}, {key:"遂川县"}, {key:"泰和县"}, {key:"万安县"}, {key:"峡江县"}, {key:"新干县"}, {key:"永丰县"}, {key:"永新县"} ]}, {key:"景德镇", items:[ {key:"浮梁县"}, {key:"景德镇市"}, {key:"乐平市"} ]}, {key:"九江", items:[ {key:"德安县"}, {key:"都昌县"}, {key:"湖口县"}, {key:"九江市"}, {key:"九江县"}, {key:"彭泽县"}, {key:"瑞昌市"}, {key:"武宁县"}, {key:"星子县"}, {key:"修水县"}, {key:"永修县"} ]}, {key:"南昌", items:[ {key:"安义县"}, {key:"进贤县"}, {key:"南昌市"}, {key:"南昌县"}, {key:"新建县"} ]}, {key:"萍乡", items:[ {key:"莲花县"}, {key:"芦溪县"}, {key:"萍乡市"}, {key:"上栗县"} ]}, {key:"上饶", items:[ {key:"波阳县"}, {key:"德兴市"}, {key:"广丰县"}, {key:"横峰县"}, {key:"铅山县"}, {key:"上饶市"}, {key:"上饶县"}, {key:"万年县"}, {key:"余干县"}, {key:"玉山县"}, {key:"弋阳县"}, {key:"婺源县"} ]}, {key:"新余", items:[ {key:"分宜县"}, {key:"新余市"} ]}, {key:"宜春", items:[ {key:"丰城市"}, {key:"奉新县"}, {key:"高安市"}, {key:"靖安县"}, {key:"上高县"}, {key:"铜鼓县"}, {key:"万载县"}, {key:"宜春市"}, {key:"宜丰县"}, {key:"樟树市"} ]}, {key:"鹰潭", items:[ {key:"贵溪市"}, {key:"鹰潭市"}, {key:"余江县"} ]} ]}, {key:"辽宁", items:[ {key:"鞍山", items:[ {key:"鞍山市"}, {key:"海城市"}, {key:"台安县"}, {key:"岫岩满族自治县"} ]}, {key:"本溪", items:[ {key:"本溪满族自治县"}, {key:"本溪市"}, {key:"桓仁满族自治县"} ]}, {key:"朝阳", items:[ {key:"北票市"}, {key:"朝阳市"}, {key:"朝阳县"}, {key:"建平县"}, {key:"喀喇沁左翼蒙古族自治县"}, {key:"凌源市"} ]}, {key:"大连", items:[ {key:"长海县"}, {key:"大连市"}, {key:"普兰店市"}, {key:"瓦房店市"}, {key:"庄河市"} ]}, {key:"丹东", items:[ {key:"丹东市"}, {key:"东港市"}, {key:"凤城市"}, {key:"宽甸满族自治县"} ]}, {key:"抚顺", items:[ {key:"抚顺市"}, {key:"抚顺县"}, {key:"清原满族自治县"}, {key:"新宾满族自治县"} ]}, {key:"阜新", items:[ {key:"阜新蒙古族自治县"}, {key:"阜新市"}, {key:"彰武县"} ]}, {key:"葫芦岛", items:[ {key:"葫芦岛市"}, {key:"建昌县"}, {key:"绥中县"}, {key:"兴城市"} ]}, {key:"锦州", items:[ {key:"北宁市"}, {key:"黑山县"}, {key:"锦州市"}, {key:"凌海市"}, {key:"义县"} ]}, {key:"辽阳", items:[ {key:"灯塔市"}, {key:"辽阳市"}, {key:"辽阳县"} ]}, {key:"盘锦", items:[ {key:"大洼县"}, {key:"盘锦市"}, {key:"盘山县"} ]}, {key:"沈阳", items:[ {key:"法库县"}, {key:"康平县"}, {key:"辽中县"}, {key:"沈阳市"}, {key:"新民市"} ]}, {key:"铁岭", items:[ {key:"昌图县"}, {key:"调兵山市"}, {key:"开原市"}, {key:"铁岭市"}, {key:"铁岭县"}, {key:"西丰县"} ]}, {key:"营口", items:[ {key:"大石桥市"}, {key:"盖州市"}, {key:"营口市"} ]} ]}, {key:"内蒙古", items:[ {key:"阿拉善盟", items:[ {key:"阿拉善右旗"}, {key:"阿拉善左旗"}, {key:"额济纳旗"} ]}, {key:"巴彦淖尔盟", items:[ {key:"杭锦后旗"}, {key:"临河市"}, {key:"乌拉特后旗"}, {key:"乌拉特前旗"}, {key:"乌拉特中旗"}, {key:"五原县"}, {key:"磴口县"} ]}, {key:"包头", items:[ {key:"包头市"}, {key:"达尔罕茂明安联合旗"}, {key:"固阳县"}, {key:"土默特右旗"} ]}, {key:"赤峰", items:[ {key:"阿鲁科尔沁旗"}, {key:"敖汉旗"}, {key:"巴林右旗"}, {key:"巴林左旗"}, {key:"赤峰市"}, {key:"喀喇沁旗"}, {key:"克什克腾旗"}, {key:"林西县"}, {key:"宁城县"}, {key:"翁牛特旗"} ]}, {key:"鄂尔多斯", items:[ {key:"达拉特旗"}, {key:"鄂尔多斯市"}, {key:"鄂托克旗"}, {key:"鄂托克前旗"}, {key:"杭锦旗"}, {key:"乌审旗"}, {key:"伊金霍洛旗"}, {key:"准格尔旗"} ]}, {key:"呼和浩特", items:[ {key:"和林格尔县"}, {key:"呼和浩特市"}, {key:"清水河县"}, {key:"土默特左旗"}, {key:"托克托县"}, {key:"武川县"} ]}, {key:"呼伦贝尔", items:[ {key:"阿荣旗"}, {key:"陈巴尔虎旗"}, {key:"额尔古纳市"}, {key:"鄂伦春自治旗"}, {key:"鄂温克族自治旗"}, {key:"根河市"}, {key:"呼伦贝尔市"}, {key:"满洲里市"}, {key:"莫力达瓦达斡尔族自治旗"}, {key:"新巴尔虎右旗"}, {key:"新巴尔虎左旗"}, {key:"牙克石市"}, {key:"扎兰屯市"} ]}, {key:"通辽", items:[ {key:"霍林郭勒市"}, {key:"开鲁县"}, {key:"科尔沁左翼后旗"}, {key:"科尔沁左翼中旗"}, {key:"库伦旗"}, {key:"奈曼旗"}, {key:"通辽市"}, {key:"扎鲁特旗"} ]}, {key:"乌海", items:[ {key:"乌海市"} ]}, {key:"乌兰察布盟", items:[ {key:"察哈尔右翼后旗"}, {key:"察哈尔右翼前旗"}, {key:"察哈尔右翼中旗"}, {key:"丰镇市"}, {key:"化德县"}, {key:"集宁市"}, {key:"凉城县"}, {key:"商都县"}, {key:"四子王旗"}, {key:"兴和县"}, {key:"卓资县"} ]}, {key:"锡林郭勒盟", items:[ {key:"阿巴嘎旗"}, {key:"东乌珠穆沁旗"}, {key:"多伦县"}, {key:"二连浩特市"}, {key:"苏尼特右旗"}, {key:"苏尼特左旗"}, {key:"太仆寺旗"}, {key:"西乌珠穆沁旗"}, {key:"锡林浩特市"}, {key:"镶黄旗"}, {key:"正蓝旗"}, {key:"正镶白旗"} ]}, {key:"兴安盟", items:[ {key:"阿尔山市"}, {key:"科尔沁右翼前旗"}, {key:"科尔沁右翼中旗"}, {key:"突泉县"}, {key:"乌兰浩特市"}, {key:"扎赉特旗"} ]} ]}, {key:"宁夏", items:[ {key:"固原", items:[ {key:"固原市"}, {key:"海原县"}, {key:"隆德县"}, {key:"彭阳县"}, {key:"西吉县"}, {key:"泾源县"} ]}, {key:"石嘴山", items:[ {key:"惠农县"}, {key:"平罗县"}, {key:"石嘴山市"}, {key:"陶乐县"} ]}, {key:"吴忠", items:[ {key:"青铜峡市"}, {key:"同心县"}, {key:"吴忠市"}, {key:"盐池县"}, {key:"中宁县"}, {key:"中卫县"} ]}, {key:"银川", items:[ {key:"贺兰县"}, {key:"灵武市"}, {key:"银川市"}, {key:"永宁县"} ]} ]}, {key:"青海", items:[ {key:"果洛藏族自治州", items:[ {key:"班玛县"}, {key:"达日县"}, {key:"甘德县"}, {key:"久治县"}, {key:"玛多县"}, {key:"玛沁县"} ]}, {key:"海北藏族自治州", items:[ {key:"刚察县"}, {key:"海晏县"}, {key:"门源回族自治县"}, {key:"祁连县"} ]}, {key:"海东", items:[ {key:"互助土族自治县"}, {key:"化隆回族自治县"}, {key:"乐都县"}, {key:"民和回族土族自治县"}, {key:"平安县"}, {key:"循化撒拉族自治县"} ]}, {key:"海南藏族自治州", items:[ {key:"共和县"}, {key:"贵德县"}, {key:"贵南县"}, {key:"同德县"}, {key:"兴海县"} ]}, {key:"海西蒙古族藏族自治州", items:[ {key:"德令哈市"}, {key:"都兰县"}, {key:"格尔木市"}, {key:"天峻县"}, {key:"乌兰县"} ]}, {key:"黄南藏族自治州", items:[ {key:"河南蒙古族自治县"}, {key:"尖扎县"}, {key:"同仁县"}, {key:"泽库县"} ]}, {key:"西宁", items:[ {key:"大通回族土族自治县"}, {key:"西宁市"}, {key:"湟源县"}, {key:"湟中县"} ]}, {key:"玉树藏族自治州", items:[ {key:"称多县"}, {key:"囊谦县"}, {key:"曲麻莱县"}, {key:"玉树县"}, {key:"杂多县"}, {key:"治多县"} ]} ]}, {key:"山东", items:[ {key:"滨州", items:[ {key:"滨州市"}, {key:"博兴县"}, {key:"惠民县"}, {key:"无棣县"}, {key:"阳信县"}, {key:"沾化县"}, {key:"邹平县"} ]}, {key:"德州", items:[ {key:"德州市"}, {key:"乐陵市"}, {key:"临邑县"}, {key:"陵县"}, {key:"宁津县"}, {key:"平原县"}, {key:"齐河县"}, {key:"庆云县"}, {key:"武城县"}, {key:"夏津县"}, {key:"禹城市"} ]}, {key:"东营", items:[ {key:"东营市"}, {key:"广饶县"}, {key:"垦利县"}, {key:"利津县"} ]}, {key:"菏泽", items:[ {key:"曹县"}, {key:"成武县"}, {key:"单县"}, {key:"定陶县"}, {key:"东明县"}, {key:"菏泽市"}, {key:"巨野县"}, {key:"郓城县"}, {key:"鄄城县"} ]}, {key:"济南", items:[ {key:"济南市"}, {key:"济阳县"}, {key:"平阴县"}, {key:"商河县"}, {key:"章丘市"} ]}, {key:"济宁", items:[ {key:"济宁市"}, {key:"嘉祥县"}, {key:"金乡县"}, {key:"梁山县"}, {key:"曲阜市"}, {key:"微山县"}, {key:"鱼台县"}, {key:"邹城市"}, {key:"兖州市"}, {key:"汶上县"}, {key:"泗水县"} ]}, {key:"莱芜", items:[ {key:"莱芜市"} ]}, {key:"聊城", items:[ {key:"东阿县"}, {key:"高唐县"}, {key:"冠县"}, {key:"聊城市"}, {key:"临清市"}, {key:"阳谷县"}, {key:"茌平县"}, {key:"莘县"} ]}, {key:"临沂", items:[ {key:"苍山县"}, {key:"费县"}, {key:"临沂市"}, {key:"临沭县"}, {key:"蒙阴县"}, {key:"平邑县"}, {key:"沂南县"}, {key:"沂水县"}, {key:"郯城县"}, {key:"莒南县"} ]}, {key:"青岛", items:[ {key:"即墨市"}, {key:"胶南市"}, {key:"胶州市"}, {key:"莱西市"}, {key:"平度市"}, {key:"青岛市"} ]}, {key:"日照", items:[ {key:"日照市"}, {key:"五莲县"}, {key:"莒县"} ]}, {key:"泰安", items:[ {key:"东平县"}, {key:"肥城市"}, {key:"宁阳县"}, {key:"泰安市"}, {key:"新泰市"} ]}, {key:"威海", items:[ {key:"荣成市"}, {key:"乳山市"}, {key:"威海市"}, {key:"文登市"} ]}, {key:"潍坊", items:[ {key:"安丘市"}, {key:"昌乐县"}, {key:"昌邑市"}, {key:"高密市"}, {key:"临朐县"}, {key:"青州市"}, {key:"寿光市"}, {key:"潍坊市"}, {key:"诸城市"} ]}, {key:"烟台", items:[ {key:"长岛县"}, {key:"海阳市"}, {key:"莱阳市"}, {key:"莱州市"}, {key:"龙口市"}, {key:"蓬莱市"}, {key:"栖霞市"}, {key:"烟台市"}, {key:"招远市"} ]}, {key:"枣庄", items:[ {key:"枣庄市"}, {key:"滕州市"} ]}, {key:"淄博", items:[ {key:"高青县"}, {key:"桓台县"}, {key:"沂源县"}, {key:"淄博市"} ]} ]}, {key:"山西", items:[ {key:"长治", items:[ {key:"长治市"}, {key:"长治县"}, {key:"长子县"}, {key:"壶关县"}, {key:"黎城县"}, {key:"潞城市"}, {key:"平顺县"}, {key:"沁县"}, {key:"沁源县"}, {key:"屯留县"}, {key:"武乡县"}, {key:"襄垣县"} ]}, {key:"大同", items:[ {key:"大同市"}, {key:"大同县"}, {key:"广灵县"}, {key:"浑源县"}, {key:"灵丘县"}, {key:"天镇县"}, {key:"阳高县"}, {key:"左云县"} ]}, {key:"晋城", items:[ {key:"高平市"}, {key:"晋城市"}, {key:"陵川县"}, {key:"沁水县"}, {key:"阳城县"}, {key:"泽州县"} ]}, {key:"晋中", items:[ {key:"和顺县"}, {key:"介休市"}, {key:"晋中市"}, {key:"灵石县"}, {key:"平遥县"}, {key:"祁县"}, {key:"寿阳县"}, {key:"太谷县"}, {key:"昔阳县"}, {key:"榆社县"}, {key:"左权县"} ]}, {key:"临汾", items:[ {key:"安泽县"}, {key:"大宁县"}, {key:"汾西县"}, {key:"浮山县"}, {key:"古县"}, {key:"洪洞县"}, {key:"侯马市"}, {key:"霍州市"}, {key:"吉县"}, {key:"临汾市"}, {key:"蒲县"}, {key:"曲沃县"}, {key:"襄汾县"}, {key:"乡宁县"}, {key:"翼城县"}, {key:"永和县"}, {key:"隰县"} ]}, {key:"吕梁", items:[ {key:"方山县"}, {key:"汾阳市"}, {key:"交城县"}, {key:"交口县"}, {key:"离石市"}, {key:"临县"}, {key:"柳林县"}, {key:"石楼县"}, {key:"文水县"}, {key:"孝义市"}, {key:"兴县"}, {key:"中阳县"}, {key:"岚县"} ]}, {key:"朔州", items:[ {key:"怀仁县"}, {key:"山阴县"}, {key:"朔州市"}, {key:"应县"}, {key:"右玉县"} ]}, {key:"太原", items:[ {key:"古交市"}, {key:"娄烦县"}, {key:"清徐县"}, {key:"太原市"}, {key:"阳曲县"} ]}, {key:"忻州", items:[ {key:"保德县"}, {key:"代县"}, {key:"定襄县"}, {key:"繁峙县"}, {key:"河曲县"}, {key:"静乐县"}, {key:"宁武县"}, {key:"偏关县"}, {key:"神池县"}, {key:"五台县"}, {key:"五寨县"}, {key:"忻州市"}, {key:"原平市"}, {key:"岢岚县"} ]}, {key:"阳泉", items:[ {key:"平定县"}, {key:"阳泉市"}, {key:"盂县"} ]}, {key:"运城", items:[ {key:"河津市"}, {key:"临猗县"}, {key:"平陆县"}, {key:"万荣县"}, {key:"闻喜县"}, {key:"夏县"}, {key:"新绛县"}, {key:"永济市"}, {key:"垣曲县"}, {key:"运城市"}, {key:"芮城县"}, {key:"绛县"}, {key:"稷山县"} ]} ]}, {key:"陕西", items:[ {key:"安康", items:[ {key:"安康市"}, {key:"白河县"}, {key:"汉阴县"}, {key:"宁陕县"}, {key:"平利县"}, {key:"石泉县"}, {key:"旬阳县"}, {key:"镇坪县"}, {key:"紫阳县"}, {key:"岚皋县"} ]}, {key:"宝鸡", items:[ {key:"宝鸡市"}, {key:"宝鸡县"}, {key:"凤县"}, {key:"凤翔县"}, {key:"扶风县"}, {key:"陇县"}, {key:"眉县"}, {key:"千阳县"}, {key:"太白县"}, {key:"岐山县"}, {key:"麟游县"} ]}, {key:"汉中", items:[ {key:"城固县"}, {key:"佛坪县"}, {key:"汉中市"}, {key:"留坝县"}, {key:"略阳县"}, {key:"勉县"}, {key:"南郑县"}, {key:"宁强县"}, {key:"西乡县"}, {key:"洋县"}, {key:"镇巴县"} ]}, {key:"商洛", items:[ {key:"丹凤县"}, {key:"洛南县"}, {key:"山阳县"}, {key:"商洛市"}, {key:"商南县"}, {key:"镇安县"}, {key:"柞水县"} ]}, {key:"铜川", items:[ {key:"铜川市"}, {key:"宜君县"} ]}, {key:"渭南", items:[ {key:"白水县"}, {key:"澄城县"}, {key:"大荔县"}, {key:"富平县"}, {key:"韩城市"}, {key:"合阳县"}, {key:"华县"}, {key:"华阴市"}, {key:"蒲城县"}, {key:"渭南市"}, {key:"潼关县"} ]}, {key:"西安", items:[ {key:"高陵县"}, {key:"户县"}, {key:"蓝田县"}, {key:"西安市"}, {key:"周至县"} ]}, {key:"咸阳", items:[ {key:"彬县"}, {key:"长武县"}, {key:"淳化县"}, {key:"礼泉县"}, {key:"乾县"}, {key:"三原县"}, {key:"武功县"}, {key:"咸阳市"}, {key:"兴平市"}, {key:"旬邑县"}, {key:"永寿县"}, {key:"泾阳县"} ]}, {key:"延安", items:[ {key:"安塞县"}, {key:"富县"}, {key:"甘泉县"}, {key:"黄陵县"}, {key:"黄龙县"}, {key:"洛川县"}, {key:"吴旗县"}, {key:"延安市"}, {key:"延长县"}, {key:"延川县"}, {key:"宜川县"}, {key:"志丹县"}, {key:"子长县"} ]}, {key:"榆林", items:[ {key:"定边县"}, {key:"府谷县"}, {key:"横山县"}, {key:"佳县"}, {key:"靖边县"}, {key:"米脂县"}, {key:"清涧县"}, {key:"神木县"}, {key:"绥德县"}, {key:"吴堡县"}, {key:"榆林市"}, {key:"子洲县"} ]} ]}, {key:"四川", items:[ {key:"阿坝藏族羌族自治州", items:[ {key:"阿坝县"}, {key:"黑水县"}, {key:"红原县"}, {key:"金川县"}, {key:"九寨沟县"}, {key:"理县"}, {key:"马尔康县"}, {key:"茂县"}, {key:"壤塘县"}, {key:"若尔盖县"}, {key:"松潘县"}, {key:"小金县"}, {key:"汶川县"} ]}, {key:"巴中", items:[ {key:"巴中市"}, {key:"南江县"}, {key:"平昌县"}, {key:"通江县"} ]}, {key:"成都", items:[ {key:"成都市"}, {key:"崇州市"}, {key:"大邑县"}, {key:"都江堰市"}, {key:"金堂县"}, {key:"彭州市"}, {key:"蒲江县"}, {key:"双流县"}, {key:"新津县"}, {key:"邛崃市"}, {key:"郫县"} ]}, {key:"达州", items:[ {key:"达县"}, {key:"达州市"}, {key:"大竹县"}, {key:"开江县"}, {key:"渠县"}, {key:"万源市"}, {key:"宣汉县"} ]}, {key:"德阳", items:[ {key:"德阳市"}, {key:"广汉市"}, {key:"罗江县"}, {key:"绵竹市"}, {key:"什邡市"}, {key:"中江县"} ]}, {key:"甘孜藏族自治州", items:[ {key:"巴塘县"}, {key:"白玉县"}, {key:"丹巴县"}, {key:"稻城县"}, {key:"道孚县"}, {key:"德格县"}, {key:"得荣县"}, {key:"甘孜县"}, {key:"九龙县"}, {key:"康定县"}, {key:"理塘县"}, {key:"炉霍县"}, {key:"色达县"}, {key:"石渠县"}, {key:"乡城县"}, {key:"新龙县"}, {key:"雅江县"}, {key:"泸定县"} ]}, {key:"广安", items:[ {key:"广安市"}, {key:"华蓥市"}, {key:"邻水县"}, {key:"武胜县"}, {key:"岳池县"} ]}, {key:"广元", items:[ {key:"苍溪县"}, {key:"广元市"}, {key:"剑阁县"}, {key:"青川县"}, {key:"旺苍县"} ]}, {key:"乐山", items:[ {key:"峨边彝族自治县"}, {key:"峨眉山市"}, {key:"夹江县"}, {key:"井研县"}, {key:"乐山市"}, {key:"马边彝族自治县"}, {key:"沐川县"}, {key:"犍为县"} ]}, {key:"凉山彝族自治州", items:[ {key:"布拖县"}, {key:"德昌县"}, {key:"甘洛县"}, {key:"会东县"}, {key:"会理县"}, {key:"金阳县"}, {key:"雷波县"}, {key:"美姑县"}, {key:"冕宁县"}, {key:"木里藏族自治县"}, {key:"宁南县"}, {key:"普格县"}, {key:"西昌市"}, {key:"喜德县"}, {key:"盐源县"}, {key:"越西县"}, {key:"昭觉县"} ]}, {key:"眉山", items:[ {key:"丹棱县"}, {key:"洪雅县"}, {key:"眉山市"}, {key:"彭山县"}, {key:"青神县"}, {key:"仁寿县"} ]}, {key:"绵阳", items:[ {key:"安县"}, {key:"北川县"}, {key:"江油市"}, {key:"绵阳市"}, {key:"平武县"}, {key:"三台县"}, {key:"盐亭县"}, {key:"梓潼县"} ]}, {key:"南充", items:[ {key:"南部县"}, {key:"南充市"}, {key:"蓬安县"}, {key:"西充县"}, {key:"仪陇县"}, {key:"营山县"}, {key:"阆中市"} ]}, {key:"内江", items:[ {key:"隆昌县"}, {key:"内江市"}, {key:"威远县"}, {key:"资中县"} ]}, {key:"攀枝花", items:[ {key:"米易县"}, {key:"攀枝花市"}, {key:"盐边县"} ]}, {key:"遂宁", items:[ {key:"大英县"}, {key:"蓬溪县"}, {key:"射洪县"}, {key:"遂宁市"} ]}, {key:"雅安", items:[ {key:"宝兴县"}, {key:"汉源县"}, {key:"芦山县"}, {key:"名山县"}, {key:"石棉县"}, {key:"天全县"}, {key:"雅安市"}, {key:"荥经县"} ]}, {key:"宜宾", items:[ {key:"长宁县"}, {key:"高县"}, {key:"江安县"}, {key:"南溪县"}, {key:"屏山县"}, {key:"兴文县"}, {key:"宜宾市"}, {key:"宜宾县"}, {key:"珙县"}, {key:"筠连县"} ]}, {key:"资阳", items:[ {key:"安岳县"}, {key:"简阳市"}, {key:"乐至县"}, {key:"资阳市"} ]}, {key:"自贡", items:[ {key:"富顺县"}, {key:"荣县"}, {key:"自贡市"} ]}, {key:"泸州", items:[ {key:"古蔺县"}, {key:"合江县"}, {key:"叙永县"}, {key:"泸县"}, {key:"泸州市"} ]} ]}, {key:"西藏", items:[ {key:"阿里", items:[ {key:"措勤县"}, {key:"噶尔县"}, {key:"改则县"}, {key:"革吉县"}, {key:"普兰县"}, {key:"日土县"}, {key:"札达县"} ]}, {key:"昌都", items:[ {key:"八宿县"}, {key:"边坝县"}, {key:"察雅县"}, {key:"昌都县"}, {key:"丁青县"}, {key:"贡觉县"}, {key:"江达县"}, {key:"类乌齐县"}, {key:"洛隆县"}, {key:"芒康县"}, {key:"左贡县"} ]}, {key:"拉萨", items:[ {key:"达孜县"}, {key:"当雄县"}, {key:"堆龙德庆县"}, {key:"拉萨市"}, {key:"林周县"}, {key:"墨竹工卡县"}, {key:"尼木县"}, {key:"曲水县"} ]}, {key:"林芝", items:[ {key:"波密县"}, {key:"察隅县"}, {key:"工布江达县"}, {key:"朗县"}, {key:"林芝县"}, {key:"米林县"}, {key:"墨脱县"} ]}, {key:"那曲", items:[ {key:"安多县"}, {key:"巴青县"}, {key:"班戈县"}, {key:"比如县"}, {key:"嘉黎县"}, {key:"那曲县"}, {key:"尼玛县"}, {key:"聂荣县"}, {key:"申扎县"}, {key:"索县"} ]}, {key:"日喀则", items:[ {key:"昂仁县"}, {key:"白朗县"}, {key:"定结县"}, {key:"定日县"}, {key:"岗巴县"}, {key:"吉隆县"}, {key:"江孜县"}, {key:"康马县"}, {key:"拉孜县"}, {key:"南木林县"}, {key:"聂拉木县"}, {key:"仁布县"}, {key:"日喀则市"}, {key:"萨嘎县"}, {key:"萨迦县"}, {key:"谢通门县"}, {key:"亚东县"}, {key:"仲巴县"} ]}, {key:"山南", items:[ {key:"措美县"}, {key:"错那县"}, {key:"贡嘎县"}, {key:"加查县"}, {key:"浪卡子县"}, {key:"隆子县"}, {key:"洛扎县"}, {key:"乃东县"}, {key:"琼结县"}, {key:"曲松县"}, {key:"桑日县"}, {key:"扎囊县"} ]} ]}, {key:"新疆", items:[ {key:"阿克苏", items:[ {key:"阿克苏市"}, {key:"阿瓦提县"}, {key:"拜城县"}, {key:"柯坪县"}, {key:"库车县"}, {key:"沙雅县"}, {key:"温宿县"}, {key:"乌什县"}, {key:"新和县"} ]}, {key:"阿拉尔", items:[ {key:"阿拉尔市"} ]}, {key:"巴音郭楞蒙古自治州", items:[ {key:"博湖县"}, {key:"和静县"}, {key:"和硕县"}, {key:"库尔勒市"}, {key:"轮台县"}, {key:"且末县"}, {key:"若羌县"}, {key:"尉犁县"}, {key:"焉耆回族自治县"} ]}, {key:"博尔塔拉蒙古自治州", items:[ {key:"博乐市"}, {key:"精河县"}, {key:"温泉县"} ]}, {key:"昌吉回族自治州", items:[ {key:"昌吉市"}, {key:"阜康市"}, {key:"呼图壁县"}, {key:"吉木萨尔县"}, {key:"玛纳斯县"}, {key:"米泉市"}, {key:"木垒哈萨克自治县"}, {key:"奇台县"} ]}, {key:"哈密", items:[ {key:"巴里坤哈萨克自治县"}, {key:"哈密市"}, {key:"伊吾县"} ]}, {key:"和田", items:[ {key:"策勒县"}, {key:"和田市"}, {key:"和田县"}, {key:"洛浦县"}, {key:"民丰县"}, {key:"墨玉县"}, {key:"皮山县"}, {key:"于田县"} ]}, {key:"喀什", items:[ {key:"巴楚县"}, {key:"喀什市"}, {key:"麦盖提县"}, {key:"莎车县"}, {key:"疏附县"}, {key:"疏勒县"}, {key:"塔什库尔干塔吉克自治县"}, {key:"叶城县"}, {key:"英吉沙县"}, {key:"岳普湖县"}, {key:"泽普县"}, {key:"伽师县"} ]}, {key:"克拉玛依", items:[ {key:"克拉玛依市"} ]}, {key:"克孜勒苏柯尔克孜自治州", items:[ {key:"阿合奇县"}, {key:"阿克陶县"}, {key:"阿图什市"}, {key:"乌恰县"} ]}, {key:"石河子", items:[ {key:"石河子市"} ]}, {key:"图木舒克", items:[ {key:"图木舒克市"} ]}, {key:"吐鲁番", items:[ {key:"吐鲁番市"}, {key:"托克逊县"}, {key:"鄯善县"} ]}, {key:"乌鲁木齐", items:[ {key:"乌鲁木齐市"}, {key:"乌鲁木齐县"} ]}, {key:"五家渠", items:[ {key:"五家渠市"} ]}, {key:"伊犁哈萨克自治州", items:[ {key:"阿勒泰市"}, {key:"布尔津县"}, {key:"察布查尔锡伯自治县"}, {key:"额敏县"}, {key:"福海县"}, {key:"富蕴县"}, {key:"巩留县"}, {key:"哈巴河县"}, {key:"和布克赛尔蒙古自治县"}, {key:"霍城县"}, {key:"吉木乃县"}, {key:"奎屯市"}, {key:"尼勒克县"}, {key:"青河县"}, {key:"沙湾县"}, {key:"塔城市"}, {key:"特克斯县"}, {key:"托里县"}, {key:"乌苏市"}, {key:"新源县"}, {key:"伊宁市"}, {key:"伊宁县"}, {key:"裕民县"}, {key:"昭苏县"} ]} ]}, {key:"云南", items:[ {key:"保山", items:[ {key:"保山市"}, {key:"昌宁县"}, {key:"龙陵县"}, {key:"施甸县"}, {key:"腾冲县"} ]}, {key:"楚雄彝族自治州", items:[ {key:"楚雄市"}, {key:"大姚县"}, {key:"禄丰县"}, {key:"牟定县"}, {key:"南华县"}, {key:"双柏县"}, {key:"武定县"}, {key:"姚安县"}, {key:"永仁县"}, {key:"元谋县"} ]}, {key:"大理白族自治州", items:[ {key:"宾川县"}, {key:"大理市"}, {key:"洱源县"}, {key:"鹤庆县"}, {key:"剑川县"}, {key:"弥渡县"}, {key:"南涧彝族自治县"}, {key:"巍山彝族回族自治县"}, {key:"祥云县"}, {key:"漾濞彝族自治县"}, {key:"永平县"}, {key:"云龙县"} ]}, {key:"德宏傣族景颇族自治州", items:[ {key:"梁河县"}, {key:"陇川县"}, {key:"潞西市"}, {key:"瑞丽市"}, {key:"盈江县"} ]}, {key:"迪庆藏族自治州", items:[ {key:"德钦县"}, {key:"维西傈僳族自治县"}, {key:"香格里拉县"} ]}, {key:"红河哈尼族彝族自治州", items:[ {key:"个旧市"}, {key:"河口瑶族自治县"}, {key:"红河县"}, {key:"建水县"}, {key:"金平苗族瑶族傣族自治县"}, {key:"开远市"}, {key:"绿春县"}, {key:"蒙自县"}, {key:"弥勒县"}, {key:"屏边苗族自治县"}, {key:"石屏县"}, {key:"元阳县"}, {key:"泸西县"} ]}, {key:"昆明", items:[ {key:"安宁市"}, {key:"呈贡县"}, {key:"富民县"}, {key:"晋宁县"}, {key:"昆明市"}, {key:"禄劝彝族苗族自治县"}, {key:"石林彝族自治县"}, {key:"寻甸回族自治县"}, {key:"宜良县"}, {key:"嵩明县"} ]}, {key:"丽江", items:[ {key:"华坪县"}, {key:"丽江市"}, {key:"宁蒗彝族自治县"}, {key:"永胜县"}, {key:"玉龙纳西族自治县"} ]}, {key:"临沧", items:[ {key:"沧源佤族自治县"}, {key:"凤庆县"}, {key:"耿马傣族佤族治县"}, {key:"临沧县"}, {key:"双江拉祜族佤族布朗族傣族自治县"}, {key:"永德县"}, {key:"云县"}, {key:"镇康县"} ]}, {key:"怒江傈傈族自治州", items:[ {key:"福贡县"}, {key:"贡山独龙族怒族自治县"}, {key:"兰坪白族普米族自治县"}, {key:"泸水县"} ]}, {key:"曲靖", items:[ {key:"富源县"}, {key:"会泽县"}, {key:"陆良县"}, {key:"罗平县"}, {key:"马龙县"}, {key:"曲靖市"}, {key:"师宗县"}, {key:"宣威市"}, {key:"沾益县"} ]}, {key:"思茅", items:[ {key:"江城哈尼族彝族自治县"}, {key:"景东彝族自治县"}, {key:"景谷彝族傣族自治县"}, {key:"澜沧拉祜族自治县"}, {key:"孟连傣族拉祜族佤族自治县"}, {key:"墨江哈尼族自治县"}, {key:"普洱哈尼族彝族自治县"}, {key:"思茅市"}, {key:"西盟佤族自治县"}, {key:"镇沅彝族哈尼族拉祜族自治县"} ]}, {key:"文山壮族苗族自治州", items:[ {key:"富宁县"}, {key:"广南县"}, {key:"麻栗坡县"}, {key:"马关县"}, {key:"丘北县"}, {key:"文山县"}, {key:"西畴县"}, {key:"砚山县"} ]}, {key:"西双版纳傣族自治州", items:[ {key:"景洪市"}, {key:"勐海县"}, {key:"勐腊县"} ]}, {key:"玉溪", items:[ {key:"澄江县"}, {key:"峨山彝族自治县"}, {key:"华宁县"}, {key:"江川县"}, {key:"通海县"}, {key:"新平彝族傣族自治县"}, {key:"易门县"}, {key:"玉溪市"}, {key:"元江哈尼族彝族傣族自治县"} ]}, {key:"昭通", items:[ {key:"大关县"}, {key:"鲁甸县"}, {key:"巧家县"}, {key:"水富县"}, {key:"绥江县"}, {key:"威信县"}, {key:"盐津县"}, {key:"彝良县"}, {key:"永善县"}, {key:"昭通市"}, {key:"镇雄县"} ]} ]}, {key:"浙江", items:[ {key:"杭州", items:[ {key:"淳安县"}, {key:"富阳市"}, {key:"杭州市"}, {key:"建德市"}, {key:"临安市"}, {key:"桐庐县"} ]}, {key:"湖州", items:[ {key:"安吉县"}, {key:"长兴县"}, {key:"德清县"}, {key:"湖州市"} ]}, {key:"嘉兴", items:[ {key:"海宁市"}, {key:"海盐县"}, {key:"嘉善县"}, {key:"嘉兴市"}, {key:"平湖市"}, {key:"桐乡市"} ]}, {key:"金华", items:[ {key:"东阳市"}, {key:"金华市"}, {key:"兰溪市"}, {key:"磐安县"}, {key:"浦江县"}, {key:"武义县"}, {key:"义乌市"}, {key:"永康市"} ]}, {key:"丽水", items:[ {key:"景宁畲族自治县"}, {key:"丽水市"}, {key:"龙泉市"}, {key:"青田县"}, {key:"庆元县"}, {key:"松阳县"}, {key:"遂昌县"}, {key:"云和县"}, {key:"缙云县"} ]}, {key:"宁波", items:[ {key:"慈溪市"}, {key:"奉化市"}, {key:"宁波市"}, {key:"宁海县"}, {key:"象山县"}, {key:"余姚市"} ]}, {key:"绍兴", items:[ {key:"上虞市"}, {key:"绍兴市"}, {key:"绍兴县"}, {key:"新昌县"}, {key:"诸暨市"}, {key:"嵊州市"} ]}, {key:"台州", items:[ {key:"临海市"}, {key:"三门县"}, {key:"台州市"}, {key:"天台县"}, {key:"温岭市"}, {key:"仙居县"}, {key:"玉环县"} ]}, {key:"温州", items:[ {key:"苍南县"}, {key:"洞头县"}, {key:"乐清市"}, {key:"平阳县"}, {key:"瑞安市"}, {key:"泰顺县"}, {key:"温州市"}, {key:"文成县"}, {key:"永嘉县"} ]}, {key:"舟山", items:[ {key:"舟山市"}, {key:"岱山县"}, {key:"嵊泗县"} ]}, {key:"衢州", items:[ {key:"常山县"}, {key:"江山市"}, {key:"开化县"}, {key:"龙游县"}, {key:"衢州市"} ]} ]} ]
JavaScript
[ { text : "曹操", items : [ { text:"夏侯敦", wuli:96, zhili:70 }, { text:"夏侯渊", wuli:93, zhili:60 }, { text:"曹仁", wuli:90, zhili:82 }, { text:"曹操", wuli:87, zhili:96 }, { text:"乐进", wuli:83, zhili:56 }, { text:"曹洪", wuli:82, zhili:51 }, { text:"李典", wuli:78, zhili:81 }, { text:"曹纯", wuli:74, zhili:70 } ] }, { text : "刘备", items : [ { text:"关羽", wuli:99, zhili:85 }, { text:"张飞", wuli:99, zhili:51 }, { text:"刘备", wuli:84, zhili:80 }, { text:"简雍", wuli:45, zhili:80 } ] }, { text : "孙坚", items : [ { text:"孙策", wuli:95, zhili:83 }, { text:"孙坚", wuli:94, zhili:85 }, { text:"黄盖", wuli:88, zhili:67 }, { text:"程普", wuli:84, zhili:80 }, { text:"韩当", wuli:82, zhili:66 }, { text:"祖茂", wuli:74, zhili:65 }, { text:"朱治", wuli:62, zhili:53 }, { text:"孙静", wuli:55, zhili:77 }, { text:"澉泽", wuli:54, zhili:78 } ] }, { text : "董卓", items : [ { text:"吕布", wuli:100, zhili:42 }, { text:"张辽", wuli:95, zhili:88 }, { text:"董卓", wuli:92, zhili:60 }, { text:"华雄", wuli:90, zhili:45 }, { text:"樊稠", wuli:82, zhili:38 }, { text:"徐荣", wuli:80, zhili:43 }, { text:"董文", wuli:78, zhili:51 }, { text:"董承", wuli:74, zhili:63 }, { text:"李催", wuli:74, zhili:38 }, { text:"郭汜", wuli:73, zhili:42 }, { text:"卢植", wuli:71, zhili:50 }, { text:"张济", wuli:70, zhili:63 }, { text:"皇浦嵩", wuli:69, zhili:73 }, { text:"贾翊", wuli:50, zhili:97 }, { text:"华韵", wuli:45, zhili:80 }, { text:"李儒", wuli:42, zhili:91 }, { text:"王允", wuli:42, zhili:72 }, { text:"蔡邕", wuli:41, zhili:80 } ] }, { text : "袁绍", items : [ { text:"颜良", wuli:96, zhili:45 }, { text:"文丑", wuli:96, zhili:40 }, { text:"张合", wuli:93, zhili:67 }, { text:"袁绍", wuli:81, zhili:77 }, { text:"高览", wuli:75, zhili:55 }, { text:"袁尚", wuli:71, zhili:50 }, { text:"袁谭", wuli:65, zhili:52 }, { text:"袁熙", wuli:64, zhili:70 }, { text:"逢纪", wuli:63, zhili:85 }, { text:"田丰", wuli:52, zhili:95 }, { text:"郭图", wuli:49, zhili:80 }, { text:"陈林", wuli:38, zhili:84 } ] }, { text : "袁术", items : [ { text:"纪灵", wuli:85, zhili:36 }, { text:"袁术", wuli:75, zhili:70 }, { text:"张动", wuli:69, zhili:63 }, { text:"雷薄", wuli:65, zhili:45 } ] }, { text : "公孙瓒", items : [ { text:"公孙瓒", wuli:86, zhili:70 }, { text:"严纲", wuli:70, zhili:49 }, { text:"公孙越", wuli:65, zhili:46 } ] }, { text : "刘焉", items : [ { text:"张任", wuli:89, zhili:75 }, { text:"严颜", wuli:89, zhili:72 }, { text:"雷铜", wuli:82, zhili:51 }, { text:"吴懿", wuli:79, zhili:77 }, { text:"杨怀", wuli:76, zhili:48 }, { text:"皺靖", wuli:69, zhili:67 }, { text:"高沛", wuli:64, zhili:43 }, { text:"刘鄢", wuli:42, zhili:78 }, { text:"刘璋", wuli:42, zhili:64 } ] }, { text : "刘表", items : [ { text:"蔡瑁", wuli:80, zhili:72 }, { text:"霍俊", wuli:77, zhili:65 }, { text:"黄祖", wuli:74, zhili:38 }, { text:"刘表", wuli:63, zhili:77 }, { text:"荆越", wuli:44, zhili:87 }, { text:"荆良", wuli:42, zhili:86 }, { text:"韩嵩", wuli:42, zhili:70 } ] }, { text : "陶谦", items : [ { text:"张岂", wuli:69, zhili:75 }, { text:"糜芳", wuli:65, zhili:80 }, { text:"陈登", wuli:52, zhili:71 }, { text:"陶谦", wuli:51, zhili:70 }, { text:"孙乾", wuli:41, zhili:80 }, { text:"糜竺", wuli:40, zhili:82 } ] }, { text : "韩复", items : [ { text:"潘凤", wuli:75, zhili:39 }, { text:"韩复", wuli:69, zhili:48 }, { text:"泪授", wuli:66, zhili:90 }, { text:"辛评", wuli:65, zhili:76 } ] }, { text : "刘繇", items : [ { text:"陈武", wuli:78, zhili:62 }, { text:"张英", wuli:73, zhili:40 }, { text:"陈横", wuli:66, zhili:52 }, { text:"刘繇", wuli:42, zhili:60 } ] }, { text : "马腾", items : [ { text:"马腾", wuli:91, zhili:61 }, { text:"梁兴", wuli:71, zhili:38 }, { text:"马玩", wuli:70, zhili:42 } ] }, { text : "孔融", items : [ { text:"管亥", wuli:93, zhili:45 }, { text:"武安国", wuli:70, zhili:40 }, { text:"孔融", wuli:45, zhili:89 } ] }, { text : "严白虎", items : [ { text:"严白虎", wuli:80, zhili:52 }, { text:"严兴", wuli:76, zhili:45 } ] }, { text : "乔瑁", items : [ { text:"乔瑁", wuli:68, zhili:60 }, { text:"乔玄", wuli:46, zhili:55 } ] }, { text : "王朗", items : [ { text:"王朗", wuli:60, zhili:86 }, { text:"虞翻", wuli:47, zhili:78 } ] }, { text : "孔岫", items : [ { text:"孔岫", wuli:42, zhili:81 } ] }, { text : "搜索", items : [ { text:"赵云", wuli:98, zhili:88 }, { text:"马超", wuli:98, zhili:48 }, { text:"典韦", wuli:98, zhili:45 }, { text:"许诸", wuli:98, zhili:40 }, { text:"太史慈", wuli:97, zhili:70 }, { text:"甘宁", wuli:96, zhili:63 }, { text:"黄忠", wuli:95, zhili:66 }, { text:"周泰", wuli:94, zhili:67 }, { text:"魏延", wuli:94, zhili:52 }, { text:"徐晃", wuli:93, zhili:70 }, { text:"王双", wuli:89, zhili:78 }, { text:"关平", wuli:88, zhili:70 }, { text:"马岱", wuli:85, zhili:52 }, { text:"周仓", wuli:85, zhili:42 }, { text:"吕蒙", wuli:85, zhili:80 }, { text:"郝昭", wuli:84, zhili:89 }, { text:"徐盛", wuli:84, zhili:84 }, { text:"高顺", wuli:84, zhili:59 }, { text:"凌操", wuli:82, zhili:48 }, { text:"吴兰", wuli:82, zhili:44 }, { text:"蒋钦", wuli:81, zhili:74 }, { text:"于禁", wuli:81, zhili:71 }, { text:"牛金", wuli:81, zhili:46 }, { text:"谭雄", wuli:81, zhili:44 }, { text:"潘璋", wuli:79, zhili:48 }, { text:"臧霸", wuli:79, zhili:47 }, { text:"李粪", wuli:79, zhili:36 }, { text:"周瑜", wuli:78, zhili:95 }, { text:"廖化", wuli:76, zhili:68 }, { text:"淳一琼", wuli:75, zhili:60 }, { text:"胡车儿", wuli:74, zhili:56 }, { text:"孟达", wuli:73, zhili:72 }, { text:"卞喜", wuli:73, zhili:42 }, { text:"车胃", wuli:72, zhili:61 }, { text:"夏侯恩", wuli:72, zhili:58 }, { text:"公孙康", wuli:72, zhili:54 }, { text:"董袭", wuli:72, zhili:42 }, { text:"龚都", wuli:72, zhili:40 }, { text:"何仪", wuli:70, zhili:42 }, { text:"宋宪", wuli:68, zhili:48 }, { text:"诸葛亮", wuli:66, zhili:100 }, { text:"陈宫", wuli:66, zhili:90 }, { text:"张鲁", wuli:65, zhili:83 }, { text:"金旋", wuli:65, zhili:52 }, { text:"程昱", wuli:58, zhili:93 }, { text:"满宠", wuli:57, zhili:82 }, { text:"蒋琬", wuli:56, zhili:91 }, { text:"李恢", wuli:54, zhili:87 }, { text:"荀攸", wuli:52, zhili:95 }, { text:"诸葛瑾", wuli:52, zhili:91 }, { text:"郭嘉", wuli:50, zhili:90 }, { text:"吕范", wuli:48, zhili:76 }, { text:"荀彧", wuli:46, zhili:98 }, { text:"杨修", wuli:45, zhili:92 }, { text:"伊籍", wuli:44, zhili:81 }, { text:"陷圃", wuli:42, zhili:80 }, { text:"刘哗", wuli:40, zhili:84 }, { text:"步惊", wuli:40, zhili:83 }, { text:"董允", wuli:38, zhili:84 }, { text:"张松", wuli:37, zhili:92 }, { text:"张昭", wuli:36, zhili:94 }, { text:"张厷", wuli:35, zhili:89 }, { text:"向朗", wuli:34, zhili:83 }, { text:"左慈", wuli:33, zhili:98 }, { text:"于吉", wuli:30, zhili:97 } ] }, { text : "指定", items : [ { text:"孙翊", wuli:81, zhili:53 }, { text:"夏侯尚", wuli:73, zhili:68 }, { text:"刘琦", wuli:46, zhili:85 }, { text:"刘宗", wuli:43, zhili:63 } ] } ]
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ ~function(F){ //日历类 F.calendar = F.Class({ init : function (box){ F.css(F.data("img/calendar/calendar.css")); this.box = F(box).cls("F_calendar"); this.itemclick = new Function(); this.w = 36; this.initUI(); F.get(F.data("data.php?act=getdate")).callback(F.proxy(this,this.chkday)); return this; }, //设置显示的时间 chkday : function(sd){ sd = sd.split("-"); var d = new Date(); var y = [d.getFullYear(), +sd[0]]; var m = [d.getMonth()+1, +sd[1]]; var i = +(!(y[0]==y[1]&&m[0]==m[1])&&window.confirm("您的本机时间与北京时间不同,是否设定为北京时间?")); this.y = y[i]; this.m = m[i]; this.up(0, 0); }, //设置显示的时间 setday : function(d){ this.y = d.getFullYear(); this.m = d.getMonth() + 1; return this.up(0,0); }, //初始化界面 initUI : function(){ this.ym(-1,0,"<<").ym(0,-1,"<").ti().ym(0,1,">").ym(1,0,">>"); this.wk("日").wk("一").wk("二").wk("三").wk("四").wk("五").wk("六"); this.space = this.box.append("div").cls("space"); this.days = []; var fun = function(d){ var t = [this.y,this.m,d].join('-'); if(this.hms){ var selects = this.hms.tags("select"); var a = []; for(var i=0; i<selects.length; i++){ a[i] = selects[i].value; } t += " " + a.join(":"); } this.itemclick(t); }; for(var i=0; i<31; i++){ this.days[i] = this.box.append("a").attr("href","javascript:void(0);").html(i+1).click(F.proxy(this,fun,i+1)); } return this; }, //标题HTML ti : function(){ var fo = this.box.append("b").cls("dateCap").html('<span></span>年<span></span>月'); this.year = fo.child(0); this.moon = fo.child(1); return this; }, //年月跳转HTML ym : function(y, m, bn){ this.box.append("b").cls("btn").click(F.proxy(this,this.up,y,m)).html(bn); return this; }, //星期HTML wk : function(s){ this.box.append("b").html(s); return this; }, //绑定到控件中 input : function (id){ var obj = F(id).node; obj.onfocus = F.proxy(this,this.show,obj); return this; }, //增加事件 on : function(handler, fun){ this[handler] = fun; return this; }, //更新HTML up : function(y,m){ y += this.y; m += this.m; m==13 && (m=1,y++) || m==0 && (m=12,y--); this.year.html(y); this.moon.html(m); this.space.css("w", new Date(y,m-1,1).getDay()*this.w); var totaldays = new Date(y, m, 0).getDate(); for(var i=28; i<31; i++){ this.days[i].node.style.display = i<totaldays ? "block" : "none"; } this.y = y; this.m = m; return this; }, //动态添加层 getbox : function (){ if(F.isie6){ this.ifr = F().append("iframe").css("cssText","position:absolute; display:none; width:0px; height:0px"); } return F().append("div").cls("cal2").attr("title","点击面板空白处关闭").click(F.proxy(function(e){ (document.all||e.target==this.obj) && this.hide(); },this)).hide(); }, //选中 select : function (d){ this.input.value = d; this.hide(); }, //显示 show : function (obj){ this.input = obj; var o = F(obj).abspos(1); this.box.pos(o.x, o.y+obj.offsetHeight).show(); this.ifr && this.ifr.show().sync(this.box,1); }, //隐藏 hide : function (){ this.ifr && this.ifr.hide(); this.box.hide(); }, //格式化时分秒 format : function (str){ var o = {}; str.replace(/./g,function(s){o[s]=1}); var hops = [], mops = [], sops = []; for(var i=0; i<60; i++){ o.h && i<24 && hops.push('<option>'+i+'</option>'); o.m && mops.push('<option>'+i.zero()+'</option>'); o.s && sops.push('<option>'+i.zero()+'</option>'); } hops = o.h ? '<span><select>'+hops.join("")+'</select>时</span>' : ''; mops = o.m ? '<span><select>'+mops.join("")+'</select>分</span>' : ''; sops = o.s ? '<span><select>'+sops.join("")+'</select>秒</span>' : ''; this.hms = this.box.append("span").cls("time").html(hops+mops+sops); } }); }($1stjs);
JavaScript
(function(ns, pt, Fw_map){ var _win = window; var _doc = document; //命名空间、唯一全局对象、构造器 var F = _win.$1stjs = function(v){ if(F.isfdom(v)){ return v; } var node = F.node(arguments.length>0?v:_doc.body); if(node){ var Class = function(){ this.isfdom = true; this.node = node; this.tag = this.node==_win ? "win" : this.node==_doc ? "doc" : this.node.tagName.toLowerCase(); }; Class.prototype = _Fwdom; var instance = new Class(); instance.toString = function(){return "Fdom"}; return instance; } return false; }; /*====================================一、Fw核心*=================================================*/ /*--------------1.框架特性----------------*/ //版权信息 F.about = { author : "likaituan", email : "61114579@qq.com", version : "4.0", date : "2010-09-05", lastime : "2011-8-18" }; //单例对象转化为类实例 F.Class = function(o) { var Class = function(){}; Class.prototype = o; return function(){ var instance = new Class(); instance.init && instance.init.apply(instance,arguments); return instance; }; }; //单例对象转化为函数 F.Fun = function(o){ var Class = function(){}; Class.prototype = o; return function(){ var instance = new Class(); return instance.init.apply(instance,arguments); }; }; //显示JSON字符串 F.alert = function(){ var msg = []; for(var i=0,a=arguments,l=a.length; i<l; i++){ msg[i] = F.json_stringify(a[i]); } msg = msg.join(","); alert(msg); return msg; }; //本地数据 F.data = function(url){ return F.path + "data/" + (url||""); } //加载完成回调 F.ready = function(o){ if(F.isfun(o)){ return _ready(o); } o.init && _ready(F.proxy(o,o.init)); return o; } //加载完成回调 var _ready = function(){ var isReady=false, readyList= [], timer, ready=function(fn) { if (isReady){ fn(); }else{ readyList.push(fn); } }, onDOMReady=function(){ for(var i=0,lg=readyList.length;i<lg;i++){ readyList[i](); } readyList = null; }, bindReady = function(evt){ if(isReady)return; isReady=true; onDOMReady(); if(_doc.removeEventListener){ _doc.removeEventListener("DOMContentLoaded",bindReady,false); }else if(_doc.attachEvent){ _doc.detachEvent("onreadystatechange", bindReady); if(_win == _win.top){ clearInterval(timer); timer = null; } } }; if(_doc.addEventListener){ _doc.addEventListener("DOMContentLoaded", bindReady, false); }else if(_doc.attachEvent){ _doc.attachEvent("onreadystatechange", function(){ if((/loaded|complete/).test(_doc.readyState))bindReady(); }); if(_win == _win.top){ timer = setInterval(function(){ try{ isReady||_doc.docElement.doScroll('left'); }catch(e){ return; } bindReady(); },5); } } return ready; }(); /*--------------2.浏览器相关----------------*/ //获取操作系统信息 F.os = (/window|linux/i.exec(navigator.userAgent)||["unknown"])[0].toLowerCase(); //获取浏览器信息 F.browser = (/(msie|firefox|chrome|safari|opera)\D*(\d+(?:\.\d+)*)/.exec(navigator.userAgent.toLowerCase())||[0,"unknown",0]).slice(1); F.isie = F.browser[0]=="msie"; F.isie6 = F.isie && F.browser[1].charAt(0)==6; F.iscanvas = !!_doc.createElement("canvas").getContext; //获取浏览器显示区域大小 F.dw = _doc.documentElement.clientWidth; F.dh = _doc.documentElement.clientHeight; //cook操作 F.cookie = function(key, val, t){ if(arguments.length==1){ var arr = _doc.cookie.match(new RegExp("(^| )"+ key +"=([^;]*)(;|$)")); if(arr != null) return unescape(arr[2]); return null; } var exp = new Date(); exp.setTime(exp.getTime() + (t||24)*60*60*1000); _doc.cookie = key + "="+ escape(val) + ";expires=" + exp.toGMTString()+';path=/'; return this; }; //复制 F.copy = function(copytext){ var obj; if(F.isobj(copytext)){ obj = copytext; copytext = obj.value; } if(_win.clipboardData){ _win.clipboardData.clearData(); _win.clipboardData.setData("Text",copytext); }else if(F.browser[0]=="opera"){ _win.location = copytext; }else if(_win.netscape){ try{ netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }catch(e){ alert("您的firefox安全限制限制您进行剪贴板操作,请打开’about:config’将signed.applets.codebase_principal_support’设置为true’之后重试,相对路径为firefox根目录/greprefs/all.js\n\n如果不设置,你也可以手动复制,谢谢!"); obj && obj.select(); return false; } var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard); var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable); if(!clip||!trans){ return false; } var clipid = Components.interfaces.nsIClipboard; var o = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString); o.data = copytext; trans.addDataFlavor('text/unicode'); trans.setTransferData("text/unicode", o, copytext.length*2); clip.setData(trans,null,clipid.kGlobalClipboard); }else{ alert("您的浏览器不支持复制功能,请手动复制,谢谢!"); obj && obj.select(); return false; } alert("生成的代码已经复制到粘贴板,你可以使用Ctrl+V 贴到需要的地方去了哦! "); return F; } //读取本地文件 F.read = function(fileObj, funName){ var iframe = F("iframe1st").size(800,600); var form = fileObj.form; //form.enctype = "mutlipart/form-data"; //form.method = "POST"; form.action = "../data/data.php?act=readFile&fileName="+fileObj.name+"&funName="+funName; alert(form.action); form.target = "iframe1st"; form.submit(); return this; } //保存文件 F.save = function(codeText, fileName){ if(F.isnode(codeText)){ codeText = codeText.value; } var win = window.open("", "_blank", "top=-2000"); var doc = win.document; doc.open("text/html", "replace"); doc.writeln(codeText); doc.execCommand("saveas", "", fileName||"test.html"); win.close(); return true; } /*--------------3.常用正则表达式----------------*/ //正则匹配 F.re = { en:/^[a-z]+$/i, //匹配英文 cn:/^[\u4e00-\u9fa5]+$/, //匹配中文 num:/^\-?\d+(?:\.\d+)?$/, //匹配数字(包括小数点) int:/^\-?\d+$/, //匹配整数 sint:/^(0|[1-9]\d*)$/, //匹配正整数 pint:/^\d+$/, //匹配纯数字 uid:/^[a-z][a-z0-9_]*$/i, //匹配登陆账号(字母开头,接数字、字母、下划线) zipcode:/^[1-9]\d{5}$/, //匹配邮编(6位,首位不为零) qq:/^[1-9][0-9]{4,9}$/, //匹配QQ号(5到10位,首位不为零) email:/^[\w\-]+(\.[\w\-]+)?@[\w\-]+(\.[\w\-]+){1,3}$/, //匹配电子邮箱,比如:61114579@qq.com或li.kaituan@vip.qq.com等 url:/^http:\/\/[\w-]+(\.[\w-]+)+\/?.*$/i, //匹配网址 mobile:/^(13|15|18)\d\-?\d{8}$/, //匹配手机号码13/15/18开头的前3位+后8位,之间可加杠 tel:/^\d{3,4}\-?\d{7,8}(\-\d{1,5})?$/, //匹配固定电话号码,限国内,前3到4位+后7到8位,之间可加杠,分机号前必须加杠,最多5位 phone:/^(13|15|18)\d\-?\d{8}$|^\d{3,4}\-?\d{7,8}(\-\d{1,5})?$/, //电话,手机和固定电话之一 ip:/^(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))(\.(([01]?[\d]{1,2})|(2[0-4][\d])|(25[0-5]))){3}$/, //IP地址 //idcard:/^\d{15}$|^\d{17}(?:\d|X)$/, //匹配身份证(15或18位) car:/^[\u4e00-\u9fa5][A-Z][A-Z0-9]{5}$/, //匹配车牌 bir:/^(19|20)\d\d(0[1-9]|1[0-2])([012][1-9]|3[01])$/ //匹配8位数的生日,1900-2099年间 }; /*--------------4.类型判断----------------*/ //判断数据是否为对象,不包括null F.isobj = function(v, flag){ var isobj = typeof(v)=="object" && v!=null; //判断是否空对象 if(isobj && F.isset(flag)){ for(var name in obj){ return !!flag; } } return isobj; } //判断数据是否为数组|函数 F.isarr = function(v){ return F.isobj(v) && (v instanceof Array); }; //判断数据是否为数组|函数 F.isfun = function(v){ return typeof(v)=="function" && (v instanceof Function); }; //判断数据是否为字符串|数字 F.isstr = function(v){ return typeof(v)=="string"; }; //判断数据是否为字符串|数字 F.isnum = function(v){ return typeof(v)=="number"; }; //是否存在 F.isset = function(v){ return v!==undefined; } //是否不存在 F.unset = function(v){ return v===undefined; } //判断数据是否为节点对象 F.isnode = function(v){ return F.isobj(v) && v.nodeType===1 && !!v.nodeName; }; //判断变量是否为DOM对象 F.isdom = function(v){ return F.isnode(v)||v==_win||v==_doc; }; //判断数据是否为Fdom对象 F.isfdom = function(v){ return F.isobj(v) && v.isfdom===true; }; //判断数据是否为Fdoms对象 F.isfdoms = function(v){ return F.isobj(v) && v.isfdoms===true; }; //判断数据是否为非空集合 F.iscollect = function(v){ return F.isobj(v) && F.isset(v.length); }; //判断数据是否为非空集合 F.isdoms = function(v){ return F.isobj(v) && F.isset(v.length) && v.length>0 && F.isnode(v[0]); }; /*--------------5.类型强制转换----------------*/ //强制转换为日期 F.date = function(d){ return F.isstr(d) ? new Date(d.replace(/\-/g,"/")) : d; }; //lambda表达式函数 F.lambda = function(fn){ return F.isstr(fn) ? new Function("a","b","c","return "+fn) : fn; }; /*--------------6.数据格式转换----------------*/ //秒转换为毫秒 F.s2ms = function (str){ var t = str.split(":"); return t[0] * 60000 + t[1] * 1000; }; //毫秒转换为秒 F.ms2s = function (ms){ return (ms/60000+":"+ms/1000%60).replace(/\.\d+/g,"").replace(/(^|:)(\d)(?!\d)/g,"$10$2"); }; //数字转化为中文 F.num2gb = function (n){ return "零一二三四五六七八九".split("")[n]; }; //中文转化为数字 F.gb2num = function (gb){ return "零一二三四五六七八九".indexOf(gb); }; //RGB颜色转化为16进制的颜色值 F.rgb2hex = function (r,g,b){ return "#" + F.zero(r.toString(16)) + F.zero(g.toString(16)) + F.zero(b.toString(16)); }; //GB转化为字节 F.gb2byte = function (gb){ return gb*1024*1024*1024; }; //字节转化为GB F.byte2gb = function (byte){ //return num<1<<10 ? num+" B" : (num<1<<20 ? (num/(1<<10)).toFixed(2)+" KB" : (num/(1<<20)).toFixed(2)+" MB") return byte/1024/1024/1024; }; /*====================================二、DOM操作=================================================*/ var _Fwdom = { /*--------------2.查找----------------*/ //获取父节点 parent : function (level){ level = level || 1; var obj = this.node; for(var i=0; i<level; i++){ obj = obj.parentNode; } return F(obj); }, //获取兄弟节点 sibling : function (idx){ //相对与本节点的 if(F.isset(idx) && F.re.num.test(idx)){ var dir = idx>0 ? "nextSibling" : "previousSibling"; idx = Math.abs(idx); var obj = this.node; while(obj=obj[dir]){ if(obj.nodeType==1&&(--idx==0)){ return F(obj); } } return false; } //获取兄弟节点列表 var a = []; (F.unset(idx)?"<>":idx).replace(/./g,F.proxy(this,function(dir){ var obj = this.node; if(dir=="<"){ while(obj=obj.previousSibling){ obj.nodeType==1 && a.unshift(obj); } }else if(dir==">"){ while(obj=obj.nextSibling){ obj.nodeType==1 && a.push(obj); } } })); return F.doms(a); }, //上一个节点 prev : function(){ return this.sibling(-1); }, //下一个节点 next : function(){ return this.sibling(1); }, //获取子节点 child : function (idx){ //获取子节点集合 if(arguments.length==0){ var ol = []; for (var nodes=this.node.childNodes,l=nodes.length,i=0; i<l; i++){ nodes[i].nodeType==1 && ol.push(nodes[i]); } return F.doms(ol); } //获取子节点 var getChild = function(obj, a){ var nodes = obj.childNodes; var l = nodes.length; var idx = +a.shift(); var i; if(idx<0){ for(i=l-1; i>=0; i--){ if(nodes[i].nodeType==1&&++idx==0) break; } }else{ for(i=0; i<l; i++){ if(nodes[i].nodeType==1&&--idx<0) break; } } if(i<0||i>=l){ return false; //throw "child("+i+") is out range"; } return a.length>0 ? getChild(nodes[i],a) : F(nodes[i]); } return F(getChild(this.node, F.map(arguments))); }, //第一个节点 first : function(){ return this.child(0); }, //最后一个节点 last : function(){ return this.child(-1); }, //标签选择器 tags : function (exp){ var a=[], doms, k, v, fun; if(/^\w+$/.test(exp)){ a = this.node.getElementsByTagName(exp); }else if(/^(\w+)\.(\w+)$/.test(exp)){ doms = this.node.getElementsByTagName(RegExp.$1); for(var i=0,l=doms.length; i<l; i++){ doms[i].className==RegExp.$2 && a.push(doms[i]); } }else if(/^(\w+)\[(\w+)((!)?=(.+))?\]$/.test(exp)){ doms = this.node.getElementsByTagName(RegExp.$1); k = RegExp.$2; if(RegExp.$3){ v = RegExp.$5; fun = RegExp.$4=="!" ? F.lambda("a!=b") : F.lambda("a==b"); for(var i=0,l=doms.length; i<l; i++){ fun(doms[i][k]||doms[i].getAttribute(k),v) && a.push(doms[i]); } }else{ for(var i=0,l=doms.length; i<l; i++){ doms[i].node.hasAttribute(k) && a.push(doms[i]); } } } return F.doms(a); }, //获取索引值 index : function(idx){ var i = 0; var obj = this.node; while(obj=obj.previousSibling){ obj.nodeType==1 && ++i; } return idx===undefined ? i : idx==i; }, /*--------------3.操作----------------*/ //增加节点 append : function (tag, idx){ var obj; if(/^(\w+)(\.(\w+))?$/.test(tag)){ obj = _doc.createElement(RegExp.$1); RegExp.$2 && (obj.className=RegExp.$3); }else{ var div = _doc.createElement("div"); div.innerHTML = tag; obj = div.firstChild; } if(F.unset(idx)){ this.node.appendChild(obj); }else{ this.node.insertBefore(obj, F.isstr(idx) ? this.node.childNodes[idx] : this.child(idx).node); } return F(obj); }, //追加节点并铺满父元素 full : function(tag){ return this.append(tag||"div").css("left:0;top:0;width:100%;height:100%"); }, //删除当前节点 remove : function (){ this.parent().node.removeChild(this.node); return this; }, //清空子节点,$type==2时,删除非元素节点,只保留元素节点 empty : function (typeid){ if(F.unset(typeid)){ while(this.node.firstChild){ this.node.removeChild(this.node.firstChild); } }else{ for (var nodes=this.node.childNodes,i=nodes.length-1; i>=0; i--){ nodes[i].nodeType!=typeid && this.node.removeChild(nodes[i]); } } return this; }, /*--------------4.样式-----------------*/ //1.基本样式 //CSS样式 css : function(p, v){ //name/value格式 if(F.isobj(p)){ for(var i in p){ this.css(i,p[i]); } return this; } //CSS多样式格式 if(p.indexOf(":")>-1){ F.each(p.replace(/;$/,"").split(";"), F.proxy(function(s){ var a = s.split(":"); this.css(F.trim(a.shift()), F.trim(a.join(":"))); },this)); return this; } //横杠小写字母替换为大写 if(/\-\w/.test(p)){ p = p.replace(/\-(\w)/, function(s,s1){return s1.toUpperCase();}); } //获取单项属性 if(arguments.length==1){ return this.node.style[p] || ( _doc.defaultView ? _doc.defaultView.getComputedStyle(this.node, null)[p] : this.node.currentStyle ? this.node.currentStyle[p] : ""); } //设置单项属性 var aa=2; this.node.style[p] = v; return this; }, //获取节点px值 px : function(name, val){ if(arguments.length==2){ this.node.style[name] = val + "px"; return this; } return parseInt(this.css(name),10) || 0; }, //className cls : function(v){ //v可能为空 if(F.isset(v)){ if(v.indexOf(".")==-1){ this.node.className = v; return this; } v = this.node.getElementsByClassName(v.slice(1)); return F(v[0]) || false; } return this.node.className; }, //设置浮动 float : function(dir){ return this.css(this.node.style.styleFloat?"styleFloat":"cssFloat", dir||"left"); }, //设置绝对定位 ps : function(){ return this.css("position","absolute"); }, //设置透明度 opacity : function(n){ if(arguments.length==1){ if(this.node.style.opacity!=undefined){ return this.css("opacity", n); } return this.css("filter", "alpha(opacity="+n*100+")"); } if(this.node.style.opacity!=undefined){ return F.re.num.test(this.css("opacity")) ? +RegExp.lastMatch : 1; } return /alpha\(opacity=(\d+)\)/.test(this.css("filter")) ? RegExp.$1/100 : 1; }, //设置对齐方式 align : function(align_method){ return this.css("text-align", align_method); }, //设置边框样式 border : function(){ var o = {px:1, st:"solid", color:"#00f"}; F.map(arguments).join(" ").replace(/\S+/g, function(s){ s.replace(/^(\d+)(?:px)?$|^(solid|dashed)$|.+/,function(s,a,b){o[a?"px":b?"st":"color"]=s}); }); return this.css("border", F.mix("$px$px $st $color",o)); }, //设置鼠标样式 cursor : function(v){ return this.css("cursor", v||"pointer"); }, //2.位置大小 //设置或获取左上角X坐标的值 left : function(x){ if(arguments.length==1){ return this.px("left",x); } return this.px("left") || this.node.offsetLeft-this.px("marginLeft"); }, //设置或获取左上角Y坐标的值 top : function(y){ if(arguments.length==1){ return this.px("top",y); } return this.px("top") || this.node.offsetTop-this.px("marginTop"); }, //设置或获取宽度值 width : function(w){ if(arguments.length==1){ return this.px("width",w); } return this.px("width") || this.node.offsetWidth-this.px("paddingLeft")-this.px("paddingRight")-this.px("borderLeftWidth")-this.px("borderRightWidth"); }, //设置或获取高度值 height : function(h){ if(arguments.length==1){ return this.px("height", h); } return this.px("height") || this.node.offsetHeight-this.px("paddingTop")-this.px("paddingBottom")-this.px("borderTopWidth")-this.px("borderBottomWidth"); }, //设置或获取元素的位置 pos : function(x,y){ var n = arguments.length; if(n==2){ return this.left(x).top(y); }else if(n==0){ return [this.left(), this.top()]; }else if(n==1){ return {x:this.left(), y:this.top()}; } }, //设置或获取元素的尺寸大小 size : function(w,h){ var n = arguments.length; if(n==2){ return this.width(w).height(h); }else if(n==0){ return [this.width(), this.height()]; }else if(n==1){ return {w:this.width(), h:this.height()}; } }, //设置或获取元素的位置和大小 rect : function(x,y,w,h){ var n = arguments.length; if(n==4){ return this.pos(x,y).size(w,h); }else if(n==0){ return [this.left(), this.top(), this.width(), this.height()]; }else if(n==1){ return {x:this.left(), y:this.top(), w:this.width(), h:this.height()}; } }, //偏移(对齐、重叠) offset : function(targetObj, mode, offsetX, offsetY, offsetW, offsetH){ var fo = F(targetObj); mode = mode || "rect"; offsetX = offsetX || 0; offsetY = offsetY || 0; offsetW = offsetW || 0; offsetH = offsetH || 0; if(mode=="rect"){ return this.rect(fo.left()+offsetX, fo.top()+offsetY, fo.width()+offsetW, fo.height()+offsetH); }else if(mode=="pos"){ return this.pos(fo.left()+offsetX, fo.top()+offsetY); }else if(mode=="size"){ return this.size(fo.width()+offsetW, fo.height()+offsetH); } }, //移到正中央 center : function(){ var o1 = this.parent().size(1); var o2 = this.size(1); return this.pos(Math.floor(o1.w/2-o2.w/2), Math.floor(o1.h/2-o2.h/2)); }, //移出页面之外 out : function(){ return this.top(-999); }, //获取中心点 midpoint : function(flag){ var o = { x : Math.floor(this.left()+this.width()/2), y : Math.floor(this.top()+this.height()/2) }; return flag ? o : [o.x,o.y]; }, //获取元素在页面中的绝对位置 abspos : function (flag){ var o = {x:0,y:0}; for(var obj=this.node; obj; obj=obj.offsetParent){ o.x += obj.offsetLeft; o.y += obj.offsetTop; } return flag==1 ? o : [o.x,o.y]; }, //按比例缩放到 scaleTo : function (width, height){ return this; }, //scrollLeft scrollLeft : function (px){ if(F.isset(px)){ this.node.scrollLeft = px; return this; } return this.node.scrollLeft; }, //scrollTop scrollTop : function (px){ if(F.isset(px)){ this.node.scrollTop = px; return this; } return this.node.scrollTop; }, //3.显示隐藏 //显示 show : function(){ return this.css("display", /^(span|img|a|input|b|u|i|label|strong|em)$/.test(this.tag)===false?"block":"inline"); }, //隐藏 hide : function(){ return this.css("display", "none"); }, //切换元素的可见状态 toggle : function(){ this.css("display")=="none" ? this.show.apply(this,arguments) : this.hide(); return this.css("display"); }, //4.背景 //背景颜色 bg : function(color){ if(arguments.length==0){ return this.css("backgroundColor"); } return this.css("backgroundColor", color); }, //背景图片 bgimg : function(img){ if(arguments.length==0){ return this.css("backgroundImage").replace(/url\([\"\']?(.+?)[\"\']?\)/i, "$1"); } if(img!="none"){ img = "url("+img+")"; } return this.css("backgroundImage", img); }, //背景位置 bgpos : function(x, y){ if(arguments.length<1){ return this.css("backgroundPosition"); } y = y || 0; return this.css("backgroundPosition", x+"px "+y+"px"); }, /*--------------5.属性-----------------*/ //innerHTML html : function(v){ if(F.unset(v)){ return this.node.innerHTML; }else if(v===true){ var div = _doc.createElement("div"); div.appendChild(this.node.cloneNode(true)); return div.innerHTML; }else if(F.isarr(v)){ v = v.join(""); }else if(F.isfdom(v)||F.isnode(v)){ v = F(v).html(); }else if(F.isfun(v)){ v = v(this); } switch(this.tag){ case "select": if(F.isie){ this.empty(); var obj = _doc.createElement("div"); obj.innerHTML = '<select>' + v + '</select>'; var nodes = obj.firstChild.childNodes; while(nodes.length>0){ this.node.appendChild(nodes[0]); } }else{ this.node.innerHTML = v; } if(arguments.length==2){ this.node.value = arguments[1]; } break; case "table": this.tags("tbody").item(0).html(v); break; case "thead": case "tfoot": case "tbody": this.empty(); var div = _doc.createElement("div"); div.innerHTML = "<table><tbody>"+v+"</tbody></table>"; var ol = div.firstChild.tBodies[0].rows; while(ol.length>0){ this.node.appendChild(ol[0]); } break; default: this.node.innerHTML = v; break; } return this; }, //attribute属性 attr : function(p, v){ var n = arguments.length; if(n==2){ //设置单个属性 if(p=="style"){ this.node.style.cssText = v; }else if(this.node[p]!=undefined){ this.node[p] = v; }else{ this.node.setAttribute(p,v); } return this; } if(n==1){ //设置{key:value}对象多属性格式 if(typeof p=="object"){ for(var i in p){ this.attr(i,p[i]); } return this; } //设置key=value字符串表达式多属性格式 if(p.indexOf("=")>-1){ F.each(F.trim(p).split(/\s+/), F.proxy(function(s){ var a = s.split("="); this.attr(F.trim(a[0]), /["'](.+?)["']/.test(a[1]) ? RegExp.$1 : F.trim(a[1])); },this)); return this; } //获取单个属性 if(p=="style"){ return this.node.style.cssText; }else if(p=="href"&&this.tag=="a"){ return this.node.getAttribute(p,2); }else if(this.node[p]!=undefined){ return this.node[p]; } return this.node.getAttribute(p); } if(n==0){ //获取所有属性 var o = {}; for(var a=this.node.attributes,l=a.length,i=0; i<l; i++){ o[a[i].name] = a[i].value; } return o; } }, //value值 val : function(v){ if(F.isset(v)){ this.node.value = v; return this; } return this.node.value; }, //图片地址 src : function(url){ if(F.isset(url)){ this.node.src = url; return this; } return this.node.src; }, /*--------------6.事件-----------------*/ //绑定事件 bind : function(etype, fun, scope){ etype = etype.replace(/^_/,""); var fdom = this; var scope = scope || this; var fun2 = function(e){fun.call(scope,F.event(e),fdom)}; if (_win.addEventListener){ this.node.addEventListener(etype, fun2, false); }else if(_win.attachEvent){ this.node.attachEvent("on"+etype, fun2); } return RegExp.lastMatch=="_" ? fun2 : this; }, //解除绑定 unbind : function(etype, fun){ if (_win.removeEventListener){ this.node.removeEventListener(etype, fun, false); }else if(_win.attachEvent){ this.node.detachEvent("on"+etype, fun); } return this; }, //单击事件 click : function(fun, scope){ return this.bind("click", fun, scope); }, //鼠标停留和移出事件 hover : function(over_callback, out_callback){ this.bind("mouseover", over_callback); this.bind("mouseout", out_callback); return this; }, //主动触发事件 fire : function(etype){ if(F.isie){ this.node.click(); }else{ evt = _doc.createEvent("MouseEvents"); evt.initEvent("click", true, true); this.node.dispatchEvent(evt); } return this; } }; //事件封装 F.event = function (e){ e = _win.event || e; var o = {}; for(var i in e){ o[i] = F.isfun(e[i]) ? F.proxy(e,e[i]) : e[i]; } if(e.target){ o.x = e.pageX; o.y = e.pageY; o.fromTarget = e.type=="mouseover" ? e.relatedTarget : null; o.toTarget = e.type=="mouseout" ? e.relatedTarget : null; }else if(e.srcElement){ o.target = e.scrElement; o.button = {1:0,4:2,2:1}[e.button]; o.stopPropagation = function(){e.cancelBubble = true;} o.preventDefault = function(){e.returnValue = false;} } o.toString = F.lambda('"object Fevent"'); return o; } "anime,drag,slides,tree,load,limitbox".replace(/\w+/g,function(method){ _Fwdom[method] = function(){ return F[method].apply(F,[this].concat(F.map(arguments))); }; }); "flash,audio,video,highlight".replace(/\w+/g,function(method){ _Fwdom[method] = function(){ this.html(F[method].apply(F,arguments)); return this; } }); /*--------------7.对象集合操作----------------*/ //Fw对象集合 F.doms = function(v){ var a; if(arguments.length>1){ a = arguments; }else if(F.isfdoms(v)){ return v; }else if(F.isarr(v)||F.isdoms(v)){ a = v; }else if(F.isstr(v)){ a = /^n:(\w+)$/.test(v) ? _doc.getElementsByName(RegExp.$1) : _doc.getElementsByTagName(v); } if(a && a.length>0){ var data = []; for(var l=a.length,i=0; i<l; i++){ data[i] = F(a[i]); if(!data[i]) return false; } var methodList = []; for(var ii in data[0]){ /^(?:node|init|parent|sibling|child|tags)$/.test(ii)||methodList.push(ii); } //alert(methodList); var f = function(data){ this.data = data; this.len = data.length; this.isfdoms = true; return this; } var oo = { //返回对象集合链的第几个 item : function(idx){ if(idx<0){ idx += this.len; } return this.data[idx]; }, //遍历 each : function(fun, scope){ var fdom; for(var idx=0; idx<this.len; idx++){ fdom = this.data[idx]; fun.call(scope||fdom,idx,fdom); } return this; } }; for(var l=methodList.length,i=0; i<l; i++){ (function(m){ oo[m] = function(){ var a = [], fdom; for(var j=0; j<this.len; j++){ fdom = this.data[j]; a[j] = fdom[m].apply(fdom, arguments); } return (a.length==0||F.isstr(a[0])||F.isnum(a[0])) ? a : this; } })(methodList[i]); } f.prototype = oo; var instance = new f(data); instance.toString = function(){return "Fdoms";}; return instance; } return false; } /*--------------8.dom其他----------------*/ //Fdom方法扩展 F.extend = function(method, fn){ if(!_Fwdom[method]){ _Fwdom[method] = fn; } return F; } //原生节点 F.node = function(v){ return F.isdom(v) ? v : F.isstr(v) ? (_doc.getElementById(v)||_doc.getElementsByName(v)[0]) : null; }; /*====================================三、原型扩展=================================================*/ //前加_ : 不作为原型 //后加_ : 覆盖JS高版本的原型方法 //不加_ : 不覆盖 var _prototype = { /*--------------1.字符串扩展----------------*/ "String" : { //拼接字符串,变量和常量混合渗入 mix : function(str, owner, more){ if(F.unset(owner)){ owner = _win; }else if(F.isset(more)||!F.isobj(owner)){ owner = F.map(arguments).slice(1); } return str.replace(/\$(\w+(?:\.\w+)*)\$?/g,function(s,a){ a = a.split("."); var v = owner; while(a.length>0){ v = v[a.shift()]; } return v===undefined ? s : v; }); }, //删除两边的空白 trim : function(str){ return str.replace(/^\s+|\s+$/g,""); }, //获取真实字节数 bytelen : function(str){ return str.replace(/[^\x00-\xff]/g,"aa").length; }, //字符串复制 repeat : function (str, times){ return(new Array(times + 1)).join(str); }, //首字母大写 capitalize : function(str){ return str.charAt(0).toUpperCase() + str.substring(1); }, //获取真实字节数 link_ : function(str, url, target){ return '<a href="'+url+'"'+(target?' target="'+target+'"':'')+'>'+str+'</a>'; } }, /*--------------2.数字扩展----------------*/ "Number" : { //数字补零 zero : function(num, len){ len = len || 2; return Array(len).join("0").concat(num).slice(-len); }, //人民币格式化 rmb : function(num, prefix){ prefix = arguments.length<2 ? "¥" : ""; return prefix + num.toFixed(2).replace(/(\d)(?=(?:\d{3})+(?!\d))/g,"$1,"); }, //获取两个数之间的随机数 limit : function(num, min, max){ return Math.min(max, Math.max(min,num)); }, //获取指定指定范围的随机数 _rand : function (min, max){ return Math.floor(Math.random()*(max-min+1)) + min; } }, /*--------------3.数组扩展----------------*/ "Array" : { //将一组元素转换成其他数组(不论是否是元素数组) map_ : function(collect, callback){ var a = [], len=collect.length; if(callback){ callback = F.lambda(callback); for(var i=0; i<len; i++){ a[i] = callback(collect[i],i); } }else{ for(var i=0; i<len; i++){ a[i] = collect[i]; } } return a; }, //过滤 filter : function(arr, fun){ var a = []; for(var i=0,l=arr.length; i<l; i++){ fun(arr[i]) && a.push(arr[i]); } return a; }, //选择项,方便倒序 eq : function(arr,idx){ if(idx<0){ idx += arr.length; } return arr[idx]; }, //获取索引值 index : function(arr, p, v){ var l = arr.length; if(F.unset(v)){ for(var i=0; i<l; i++){ if(arr[i]==p){ return i; } } }else{ for(var i=0; i<l; i++){ if(arr[i][p]==v){ return i; } } } return -1; }, //二分法(binary_search) search : function(a, num){ var min = 0; var max = a.length-1; var i = -1; var fun = F.lambda("a"); if(/v\.\w+/.test(num)){ fun = F.lambda(RegExp.lastMatch); if(/^v\.\w+=(\d+)$/.test(num)){ num = RegExp.$1; } } var minF, maxF; if(F.re.sint.test(num)){ minF = new Function("n", "return n<"+num); maxF = new Function("n", "return n>"+num); } if(/^(\d+)<(=)?v(?:\.\w+)?<(=)?(\d+)$/.test(num)){ minF = new Function("n", "return n<"+(RegExp.$2?"=":"")+RegExp.$1); maxF = new Function("n", "return n>"+(RegExp.$3?"=":"")+RegExp.$4); } while(min<=max){ i = Math.floor((min+max)/2); var n = fun(a[i]); if(minF(n)){ min = i+1; }else if(maxF(n)){ max = i-1; }else{ return i; } } return -1; }, //数组重排(乱序) shuffle : function(arr){ return arr.slice(0).sort(function(){return Math.random()-0.5;}); }, //移除重复值 unique : function(arr){ var o = {}, v; for(var i=0; i<arr.length; i++){ v = arr[i]; if(o[v]){ a.splice(i,1); i--; }else{ o[v] = 1; } } return a; }, //数组元素互换 swap : function(arr,i,j){ var temp = arr[i]; arr[i] = arr[j]; arr[j] = temp; return arr; }, //二维数组排序 sortby : function(arr, key, order){ return arr.sort(new Function("a","b",order?F.mix("return b.$0-a.$0",key):F.mix("return a.$0-b.$0",key))); }, //用给定的值填充数组 _range : function (v1, v2, count){ var a = []; //数字 if(F.re.int.test(v1)&&F.re.int.test(v2)){ var dir = v2-v1>0 ? 1 : -1; for(var i=0,l=Math.abs(v2-v1)+1; i<l; i++){ a.push(v1+i*dir); } //字母其他 }else{ var n1=v1.charCodeAt(), n2=v2.charCodeAt(); var dir = n2-n1>0 ? 1 : -1; for(var i=0,l=Math.abs(n2-n1)+1; i<l; i++){ a.push(String.fromCharCode(n1+i*dir)); } } return count ? F.shuffle(a).slice(0,count) : a; }, //做为数组升序排序的简化函数 _up : function(a,b){ return a-b; } }, /*--------------4.日期扩展----------------*/ "Date" : { //日期格式化 format : function(dat, str){ dat = F.date(dat); var y=dat.getFullYear(), m=dat.getMonth()+1, d=dat.getDate(); return str.replace(/y+/i,y) .replace(/m+/i,function(s){return s.length>1?F.zero(m):m}) .replace(/d+/i,function(s){return s.length>1?F.zero(d):d}); }, //时间差 diff : function(d1, d2, flag){ var n1 = d1.getTime(); var n2 = F.date(d2).getTime(); var n = Math.abs(n1-n2); if(flag==1){ return n; } var a = []; a[0] = Math.floor(n/86400000); n -= a[0]*86400000; a[1] = Math.floor(n/3600000); n -= a[1]*3600000; a[2] = Math.floor(n/60000); n -= a[2]*60000; a[3] = Math.floor(n/1000); n -= a[3]*1000; a[4] = n; return a; } }, /*--------------5.函数扩展----------------*/ "Function" : { //作用域绑定代理 proxy : function(v1, v2){ var args = [].slice.call(arguments,2); var scope = v2; var fun = v1; if(F.isfun(v2)){ scope = v1; fun = v2; }else if(F.isstr(v2)){ scope = v1; fun = scope[v2]; } return function(){ //return fun.apply(scope, [].concat.apply(args, arguments)); return fun.apply(scope, args.concat([].slice.call(arguments))); }; }, //继承 inherit : function(fun, superClass){ fun.prototype = new superClass(); return fun; } } }; /*--------------6.对象扩展----------------*/ //选择键值 F.clone = function(o){ var o2 = {}; for(var i=1,a=arguments,l=a.length; i<l; i++){ o2[a[i]] = o[a[i]]; } return o2; }; //删除键值 F.cut = function(o){ for(var i=1,a=arguments,l=a.length; i<l; i++){ delete o[a[i]]; } return o; }; //合并到源对象,循环目标对象 F.merge = function (source, target, $type) { if(F.isstr(target)){ source[target] = $type; return source; } var f = new Function("o","k",["return true","return o.hasOwnProperty(k)","return !o.hasOwnProperty(k)"][$type||0]); for (var key in target) { f(source,key) && (source[key]=target[key]); } return source; }; //键值翻转 F.flip = function(hashObj){ var o = {}; for(var key in hashObj){ o[hashObj[key]] = key; } return o; } //遍历对象 F.each = function(json, callback){ //如果是集合 if(F.iscollect(json)){ for(var idx=0,l=json.length; idx<l; idx++){ callback(json[idx], idx); } }else{ for(var key in json){ callback(json[key], key); } } return F; }; for(var tp in _prototype){ F.each(_prototype[tp], function(fun, method){ F[method.replace(/^_|_$/,"")] = fun; }); } /*====================================四、AJAX|请求相关=================================================*/ //xmlhttp对象(格式化的AJAX对象) var _XHR = (function(){ if (_win.XMLHttpRequest){ return XMLHttpRequest; } var a = ["Msxml2.XMLHTTP.3.0","Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0","Msxml2.XMLHTTP.5.0"]; for (var i=0,l=a.length;i<l;i++){ try{ var X = new ActiveXObject(a[i]); return function(){return X;}; }catch(e){} } return false; })(); //ajax类 F.ajax = F.Class({ init : function(ops){ this.url = ops.url; this.data = ""; if(ops.data){ if(F.isnode(ops.data)){ ops.data = F.getForm(ops.data); } this.data = F.serialize(ops.data, ops.isEncode||0); } this.method = ops.method || "get"; this.charset = ops.charset || "utf-8"; ops.obj && this.callback(F.proxy(ops.obj,"html")); return this; }, //回调返回JSON数据 call2json : function(fun){ this.callback(fun,"json"); }, //回调,默认返回字符串 callback : function(fun, $type){ if(this.method=="get"&&this.data!=""){ this.url += (this.url.indexOf("?")>-1?"&":"?") + this.data; this.data = ""; } var x = new _XHR(); x.open(this.method, this.url, true); //第3个参数固定为true,异步提交 this.method=="post" && x.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset="+this.charset); if(fun){ //解析字符串格式的函数 if(F.isstr(fun)){ var a = fun.split("."); var scope = _win; while(a.length>1){ scope = scope[a.shift()]; } fun = F.proxy(scope, a[0]); } x.onreadystatechange = function(){ x.readyState==4&&(x.status==0||x.status==200) && fun($type=="json"?F.json_parse(x.responseText):x.responseText); }; } x.send(this.data); } }); //ajax的get请求 F.get = function(url,data){ return F.ajax({url:url,data:data,method:"get"}); }; //ajax的post请求 F.post = function(url,data){ return F.ajax({url:url,data:data,method:"post"}); }; //ajax异步加载HTML代码 F.load = function(fo,url,data){ var o = {url:url, obj:fo}; if(data){ o.method = "post"; o.data = data; } return F.ajax(o); }; //动态加载JS var _jsfiles = {}; F.js = function(url, callback){ if(_jsfiles[url]){ return callback && callback(); } _jsfiles[url] = true; if(Fw_map[url]){ url = /^http:\/\//.test(Fw_map[url]) ? Fw_map[url] : F.data("fw/"+Fw_map[url]); } var fo = _head.append("script").attr("type","text/javascript").src(url); callback && _loadFileCallback(fo, callback); return fo; } //加载文件回调 var _loadFileCallback = function(fo, callback){ var obj = fo.node; if(obj.readyState){ obj.onreadystatechange = function(){ (obj.readyState=='loaded'||obj.readyState=='complete') && fo.remove() && callback && callback(); }; }else{ var intervalID = setInterval(function() { try{ obj.sheet.cssRules; _win.clearInterval(intervalID); callback(); }catch(e){} },100); obj.onload = function(){ fo.remove() && callback && callback(); }; } return this; }; //动态加载CSS文件 var _cssfiles = {}; F.css = function(v, callback){ if(F.isarr(v)){ v = v.join("\n"); } if(/{[\w\W]+?}/.test(v)){ var dom = _head.append("style").attr("type","text/css"); dom.node.styleSheet && (dom.node.styleSheet.cssText=v) || dom.node.appendChild(_doc.createTextNode(v)); return dom; } if(_cssfiles[v]){ return callback && callback(); } var fo = _cssfiles[v] = _head.append("link").attr({rel:"stylesheet",type:"text/css",href:v}); callback && _loadFileCallback(fo, callback); return _cssfiles[v]; }; //加载图片 F.img = F.loadImg = function(imgs, itemLoaded, allLoaded){ var me = this; imgs = imgs.split(","); //图片数组 var count = imgs.length; //图片总数 var idx = 0; //已经被加载的图片个数 var fun = function(){ idx++; itemLoaded && itemLoaded(idx, count, this); if (idx<count) return down(); allLoaded && allLoaded(); }; var down = function () { var img = new Image(); img.onload = fun; img.src = imgs[idx]; }; down(); return this; }; //生成flash F.flash = function (url, width, height, param){ var tagName = "", o1 = {width:width||1, height:height||1}, o2 = {}; if (F.browser[0]=="msie"){ tagName = "object "; o1.classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"; o1.codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"; o2.movie = url; o2.quality = "high"; param && F.merge(o2, param); }else{ tagName = "embed "; o1.type = "application/x-shockwave-flash"; o1.pluginspage = "http://www.macromedia.com/go/getflashplayer"; o1.src = url; o1.quality = "high"; param && F.merge(o1, param); } if(o1.width<2&&o1.height<2) tagName+='style="position:absolute; top:-100px;" '; var a1=[], a2=[], i; for(i in o1) a1.push(i+'="'+o1[i]+'"'); for(i in o2) a2.push('<param name="'+i+'" value="'+o2[i]+'" />'); return '<'+tagName+a1.join(' ')+'>'+a2.join('')+'</'+tagName+'>'; }; //播放器生成代码 F.audio = function (url, width, height, param){ var wmp = ["6bf52a52-394a-11d3-b153-00c04f79faa6","application/x-mplayer2"]; var rmp = ["CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA","audio/x-pn-realaudio-plugin"]; var mp = /\.rm$/.test(url) ? rmp : wmp; var tagName = "", o1 = {width:width||1, height:height||1}, o2 = {}; if (F.isie){ tagName = "object "; o1.classid = "clsid:"+mp[0]; o2.url = url; param && F.merge(o2, param); }else{ tagName = "embed "; o1.type = mp[1]; o1.src = url; param && F.merge(o1, param); } if(o1.width<2&&o1.height<2) tagName+='style="position:absolute; top:-100px;" '; var a1=[], a2=[], i; for(i in o1) a1.push(i+'="'+o1[i]+'"'); for(i in o2) a2.push('<param name="'+i+'" value="'+o2[i]+'" />'); return '<'+tagName+a1.join(' ')+'>'+a2.join('')+'</'+tagName+'>'; }; //视频生成代码 F.video = function (url, width, height, param){ return F.audio(url, width, height, param); }; /*====================================五、表单相关=================================================*/ //自定义表单 //参考自jquery.HooRay F.diyForm = function(obj){ var btns = []; var rds = {}; var box = F(obj); var chkRadio = function(input){ var idx = input.attr("btnIdx"); var oldIdx = rds[input.node.name]; if(oldIdx&&oldIdx==idx) return; if(F.isset(oldIdx)){ btns[oldIdx].bgpos(0,0); } rds[input.node.name] = idx; btns[idx].bgpos(0,-36); }; var chkCheckbox = function(input){ btns[input.attr("btnIdx")].bgpos(0, input.node.checked?-36:0); }; box.tags("input").each(function(idx, fo){ var $type = fo.attr("type"); if($type=="radio"||$type=="checkbox"){ var skinId = fo.attr("skin"); if(skinId){ var input = fo.size(20,15).opacity(0).attr("btnIdx",idx); var o = input.abspos(1); var u = F.data("img/diyForm/skin/"+$type+skinId+".png"); btns[idx] = F().append("div").css("zIndex",-1).bgimg(u).bgpos(0,0).ps().rect(o.x,o.y,18,18); if($type=="radio"){ input.node.checked && chkRadio(input); input.click(F.proxy(null,chkRadio,input)); }else if($type=="checkbox"){ chkCheckbox(input); input.click(F.proxy(null,chkCheckbox,input)); } } }else if($type=="file" && fo.attr("skin")){ var input = fo.size(70,25).opacity(0).attr("btnIdx",idx); var o = input.abspos(1); if(fo.attr("skin")=="button"){ btns[idx] = F().append("button").html(fo.attr("val")).css("zIndex",-1).ps().rect(o.x,o.y,70,25); } } }); return box; }; //获取表单所有的值 F.getForm = function(form){ form = F(form).node; var o = {}; F.each(form.elements, function(obj){ if(obj.name && obj.disabled==false){ if(obj.type=="radio"||obj.type=="checkbox"){ if(obj.checked){ o[obj.name] = (F.isset(o[obj.name])?o[obj.name]+",":"") + obj.value; } }else{ o[obj.name] = obj.value; } } }); return o; }; //表单赋值 F.setForm = function(form, o){ form = F(form).node; for (var name in o){ if(!form[name]){ throw name +" is not a name in the form: " + form.name; } var obj = form[name]; if(obj.length){ if(obj[0].type=="radio"){ F.each(form[name], function(obj){ obj.checked = obj.value==o[name]; }); }else if(obj[0].type=="checkbox"){ var aa = F.isarr ? o[name] : o[name].split(","); F.each(form[name], function(obj,i){ obj.checked = F.index(aa, obj.value)>-1; }); } }else{ obj.value = o[name]; } } return this; }; //case "select": if(!this.select(td2.tags("select").item(0), ti))return false; //case "radio" : if(!this.radio(td2.tags("input"), ti))return false; break; //case "checkbox" : if(!this.checkbox(td2.tags("input"), ti))return false; break; //表单验证组件 F.validator = function(objForm){ objForm = F(objForm); var form = objForm.node; //验证 var chks = function(obj){ var v = obj.bg("#fff").val(); var doms = obj.sibling(">"), fo; if(!doms) return true; doms.hide(); for(var i=0; i<doms.len; i++){ fo = doms.item(i); switch(fo.tag){ case "i": if(!chk(fo,v)){ obj.bg("#ffe7e7") && fo.show("inline") && obj.node.focus(); return false; } break; case "u": if(obj.attr("passkey")!=v){ fo.show("inline"); F.get(fo.attr("url"), {chk:obj.attr("name"),val:v}).callback(F.proxy(this,function(fo,obj,n){ fo.hide().sibling(n).show("inline"); n>1 ? obj.bg("#ffe7e7") && obj.node.focus() : obj.attr("passkey",v) && chkForm(2); },fo,obj)); return false; } break; case "b": v!="" && fo.show("inline"); return true; } } return true; } //验证单个 var chk = function(obj,v){ var o = obj.attr(); if(F.isset(o.required)){ return v!=""; } if(F.isset(o.empty) && v==""){ return true; } return ( F.unset(o.re) || F.re[o.re].test(v) ) && ( F.unset(o.pattern) || new RegExp(o.pattern).test(v) ) && ( F.unset(o.minlen) || v.length>=o.minlen ) && ( F.unset(o.maxlen) || v.length<=o.maxlen ) && ( F.unset(o.min) || v>=o.min ) && ( F.unset(o.max) || v<=o.max ) && ( F.unset(o.pwd) || v==form[o.pwd].value); } //验证绑定 var obj; for(var eles=form.elements,l=eles.length,i=0; i<l; i++){ obj = F(eles[i]); obj.bind("blur",F.proxy(null,chks,obj)); } //提交验证 var chkForm = function(flag){ for(var eles=form.elements,l=eles.length,i=0; i<l; i++){ if(!chks(F(eles[i]))) return false; } var o = objForm.attr(); if(o.ajax){ F.ajax({url:o.action,method:o.method||"get",data:form}).callback(o.callback); return false; } flag==2 && form.submit(); return true; } form.onsubmit = chkForm; }; //获取或设置单选框的值 F.radio = function (obj, val){ var ol = F.doms(F.isstr(obj)?"n:"+obj:obj); //获取 if(F.unset(val)){ for(var i=0; i<ol.len; i++){ if(ol.item(i).node.checked){ return ol.item(i).val(); } } return false; } //设置 for(var i=0; i<ol.len; i++){ if(ol.item(i).val()==val){ ol.item(i).node.checked = true; break; } } return this; }; //获取或设置复选框的值 F.checkbox = function (obj, v){ var ol = F.doms(F.isstr(obj)?"n:"+obj:obj); //获取 if(F.unset(v)){ var a = []; ol.each(function(){ this.node.checked && a.push(this.val()); }); return a; } //设置 ol.each(function(idx){ this.node.checked = v[idx]==1; }); return this; }; //全选/反选/清除功能 F.selectall = function(v){ return this; }; //只能输入数字 F.limitbox = function(obj, re){ var re = re || /[^\d\.]/g; re = F.isstr(re) ? F.re[re] : re; F(obj).bind("keyup", function(){ this.val(this.val().replace(re,'')); }); return this; }; //输入框提示 F.tipbox = function(obj){ obj = F(obj).node; var msg = obj.value; obj.onfocus = function(){ if(obj.value==msg) obj.value=""; }; obj.onblur = function(){ if(obj.value=="") obj.value=msg; }; return msg; }; //代码框 F.codebox = function(v){ return this; }; /*===========================================六、编码解码========================================*/ //Object对象转换为JSON字符串 F.json_stringify = function(jsonObj){ var obj2str = function(v){ if(v==undefined) return v; switch(v.constructor){ case Number: case Boolean: return v; case String: return '"' + v + '"'; case Array: var a = []; for(var i=0,l=v.length; i<l; i++){ a.push(obj2str(v[i])); } return "[" + a.join(",") + "]"; case Object: var a = []; for(var i in v){ a.push('"'+i+'":'+obj2str(v[i])); } return "{" + a.join(",") + "}"; default: return undefined; } }; return obj2str(jsonObj); }; //JSON字符串转换为Object对象 F.json_parse = function(jsonStr){ if(F.isstr(jsonStr)){ try{ return eval('(' + jsonStr + ')'); }catch(e){return false;} }else{ return jsonStr; } } //URL编码 F.url_encode = function(str){ //return s.replace(/&/g,"%26").replace(/\+/g,"%2b").replace(/\'/g,"''"); return str .replace(/%/g,'%25') .replace(/ /g,'%20') .replace(/#/g,'%23') .replace(/&/g,'%26') .replace(/=/g,'%3D') .replace(/\//g,'%2F') .replace(/\?/g,'%3F') .replace(/\+/g,'%2B'); }; //URL解码 F.url_decode = function(s){ //return s.replace(/%26/g,"&").replace(/%2b/g,"+").replace(/\'\'/g,"'"); }; //HTML特殊字符编码 F.html_encode = function(str, flag){ str = str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"); flag = flag || 0; if(flag==1||flag==3) str = str.replace(/'/,"&#039;"); if(flag==2||flag==3) str = str.replace(/"/g,"&quot;"); return str; } //HTML解码 F.html_decode = function(str, flag){ flag = flag || 0; if(flag==1||falg==3) str = str.replace(/&#039;/,"'"); if(flag==2||falg==3) str = str.replace(/&quot;/g,'"'); return str.replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&"); } //把对象序列化为字符串 F.serialize = function (json, isEncode) { if(F.isstr(json)){ return json; } var a = [], val; for (var key in json) { val = isEncode ? F.url_encode(json[key]) : json[key]; a.push(key+"="+val); } return a.join("&"); }; //把字符串反序列化为对象 F.unserialize = function(str){ var o = {}, a; for (var aa=str.split("&"),l=aa.length,i=0; i<l; i++) { a = aa[i].split("="); o[a[0]] = a[1]; } return o; }; //自定义编码 F.encode = function(str){ return str.replace(/[^\u0000-\u00FF]/g,function($0){ var v="",n,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" n=escape($0).replace("%u","0x")*1 do{v=l.substr(n%62,1)+v;n=parseInt(n/62)} while(n>0||v.length<3) return "{*"+v+"}" }).replace(/\}\{\*/g,"") }; //自定义解码 F.decode = function(str){ return str.replace(/\{\*[^\}]*\}/g,function($0){ return $0.slice(2,-1).replace(/\w{3}/g,function($1){ var v=$1,i,n=0,l="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" for(i=0;i<v.length;i++){ n+=l.indexOf(v.substr(i,1))*Math.pow(62,v.length-i-1) } v=n.toString(16) return unescape("%u"+(v.length<4?"0":"")+v) }) }) }; /*====================================获取框架路径及设置prototype原型继承==========================================*/ var _head = F.doms("head").item(0); var _src = F.doms("script").item(-1).src(); //路径 F.path = /^http:\/\/.+?(\/.+)F\.js.*$/.test(_src) ? RegExp.$1 : _src.replace("1st.js",""); var o = F.unserialize(_src.replace(/^.+\?/,"")); F.config = {ns:F.isset(o.ns)?o.ns:ns, pt:F.isset(o.pt)?+o.pt:pt}; if(F.config.pt){ _prototype["Array"].each = F.each; var ppt; for(var tp in _prototype){ ppt = _win[tp].prototype; F.each(_prototype[tp], function(fun, key){ if(/^[a-z]/i.test(key) && !ppt[key]){ key = key.replace(/_$/,""); ppt[key] = function(){return fun.apply(null,[this].concat(F.map(arguments)))}; } }); } } F.config.ns && (_win[F.config.ns]=F); })("F",1, {jq:"jquery1.4.2.min.js", ext:"", moo:"", "1kjs":"1k.js"}); /*===========================================七、Fw内部组件========================================*/ //动画组件 ~function(F){ F.anime = function (node, args){ var fo=F(node), tp=_EASING[args.type||'Both'], s0=0, s1=Math.ceil((args.duration||1000)/16), timer, items=[], len, o, n, additem = function(key, scale, key2){ if(F.isset(args[key])){ var n = fo[key](); var i = args[key]; var o = {method:F.proxy(fo,key), origin:n, incriment:F.isnum(i)?i-n:+i}; scale && F.merge(o,{scale:scale, method2:F.proxy(fo,key2), origin2:fo[key2]()}); items.push(o); if(key=="left"||key=="top"||scale){ fo.ps()=="static" && fo.ps("relative"); F.isie6 && (key=="width"||key=="height") && F.css("overflow", "hidden"); } } } F.isie && F.browser[1].charAt(0)<8 && fo.css("zoom",1); additem("width", args.ws, "left"); additem("height", args.hs, "top"); "left,top,opacity,scrollLeft,scrollTop".replace(/\w+/g,function(s){additem(s)}); len = items.length; function _doing(){ if(s0<s1){ for(var i=0; i<len; i++){ o = items[i]; o.method(n=tp(s0,o.origin,o.incriment,s1)) && o.scale && o.method2(o.origin2-o.scale*(n-o.origin)); } s0++; timer = setTimeout(_doing,16); }else{ for(var i=0; i<len; i++){ o = items[i]; o.method(o.origin+o.incriment) && o.scale && o.method2(o.origin2-o.scale*o.incriment); } args.after && args.after(); } args.running && args.running(fo); } args.before && args.before(); timer = setTimeout(_doing,16); return{ stop:function(){ if(!args.lock)clearTimeout(timer); args.stop && args.stop(); } }; }; //t=当前步数 b=原点 c=增量 d=总步数 var _EASING = { Linear: function(t,b,c,d){ return c*t/d + b; }, slowIn:function(t,b,c,d){return c*(t/=d)*t + b;}, slowOut:function(t,b,c,d){return -c *(t/=d)*(t-2) + b;}, slowBoth:function(t,b,c,d){ if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; }, In: function(t,b,c,d){ return c*(t/=d)*t*t*t + b; }, Out: function(t,b,c,d){ return -c * ((t=t/d-1)*t*t*t - 1) + b; }, Both: function(t,b,c,d){ if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; }, fastIn: function(t,b,c,d){ return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; }, fastOut: function(t,b,c,d){ return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; }, fastBoth: function(t,b,c,d){ if (t==0) return b; if (t==d) return b+c; if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; }, circIn: function(t,b,c,d){ return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; }, circOut: function(t,b,c,d){ return c * Math.sqrt(1 - (t=t/d-1)*t) + b; }, circBoth: function(t,b,c,d){ if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; }, elasticIn: function(t,b,c,d,a,p){ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (!a || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; }, elasticOut: function(t,b,c,d,a,p){ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; if (!a || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); return (a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b); }, elasticBoth: function(t,b,c,d,a,p){ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); if (!a || a < Math.abs(c)) { a=c; var s=p/4; } else var s = p/(2*Math.PI) * Math.asin (c/a); if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; }, backIn: function(t,b,c,d,s){ if (s == undefined) s = 1.70158; return c*(t/=d)*t*((s+1)*t - s) + b; }, backOut: function(t,b,c,d,s){ if (s == undefined) s = 1.70158; return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; }, backBoth: function(t,b,c,d,s){ if (s == undefined) s = 1.70158; if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; }, bounceIn: function(t,b,c,d){ return c - _EASING.bounceOut(d-t, 0, c, d) + b; }, bounceOut: function(t,b,c,d){ if ((t/=d) < (1/2.75)) { return c*(7.5625*t*t) + b; } else if (t < (2/2.75)) { return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; } else if (t < (2.5/2.75)) { return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; } else { return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; } }, bounceBoth: function(t,b,c,d){ if (t < d/2) return _EASING.bounceIn(t*2, 0, c, d) * .5 + b; else return _EASING.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b; } }; }($1stjs); //拖动组件 ~function(F){ F.drag = F.Class({ init : function (box, ops){ this.x = 0; this.y = 0; this.islimit = 0; this.box = F(box); this.box.css("position")=="static" && this.box.ps(); this.doc = F(document); ops = ops || {}; this.handle = F(ops.handle) || this.box; this.handle.bind("mousedown", this._down, this); //限制拖动范围 this.x1 = F.isset(ops.x1) ? ops.x1 : -Infinity; this.y1 = F.isset(ops.y1) ? ops.y1 : -Infinity; this.x2 = (F.isset(ops.x2)?ops.x2:Infinity) - this.box.width(); this.y2 = (F.isset(ops.y2)?ops.y2:Infinity) - this.box.height(); //设置事件 this.before = ops.before; this.running = ops.running; this.after = ops.after; this.allowX = !ops.lockX; this.allowY = !ops.lockY; }, //鼠标按下 _down : function (e){ e.stopPropagation(); if(e.button>0||this.box.node.___resizing)return; if(this.allowX){ this.x = e.x - this.box.left(); } if(this.allowY){ this.y = e.y - this.box.top(); } this.before && this.before(this); this.moveFun = this.doc.bind("_mousemove", this._move, this); this.upFun = this.doc.bind("_mouseup" ,this._drop, this); this.handle.node.setCapture && this.handle.node.setCapture(false); e.preventDefault(); }, //鼠标移动 _move : function (e){ window.getSelection ? window.getSelection().removeAllRanges() : document.selection.empty(); this.allowX && this.box.left(F.limit(e.clientX-this.x, this.x1, this.x2)); this.allowY && this.box.top(F.limit(e.clientY-this.y, this.y1, this.y2)); this.running && this.running(this); }, //鼠标弹起 _drop : function(e){ this.handle.node.releaseCapture && this.handle.node.releaseCapture(); this.doc.unbind("mousemove",this.moveFun).unbind("mouseup",this.upFun); this.after && this.after(this); } }); }($1stjs); //弹窗组件 //参考自ymPrompt ~function(F){ F.dialog = F.Class({ //初始化 init : function(ops){ var skin = ops.skin || "vista"; ops = ops || {}; this.title = ops.title || "1stjs对话框"; this.content = ops.content || ""; if(ops.url){ this.content = F.mix('<iframe src="$url" style="width:100%; height:100%;" frameborder="no" border="0" marginwidth="0" marginheight="0"></iframe>',ops); } this.width = ops.width || 300; this.height = ops.height || 200; this.box = F().append("div").ps().size(this.width,this.height).center().hide(); F.isie6 && this.box.full("iframe").px("borderWidth",0); var tb = this.box.full("table").attr("cellspacing=0 cellpadding=0 height="+this.height).css("font-size:12px;").append("tbody"); var tr1 = tb.append("tr.top"); tr1.append("td.topleft"); var td12 = tr1.append("td.topbar"); var title = td12.append("div.title").html(this.title); var div = td12.append("div.icon"); div.append("div.min").attr("title=最小化").click(this.hide,this); div.append("div.max").attr("title=最大化").click(this.hide,this); var closeIcon = div.append("div.close").attr("title=关闭").click(this.hide,this); tr1.append("td.topright"); this.box.drag(title); var tr2 = tb.append("tr.middle");//.bg("#fff"); tr2.append("td.leftbar").append("div"); var td22 = tr2.append("td.body"); td22.append("div.content").html(this.content); if(ops.yes||ops.no){ var div = td22.append("div.btnbox").align("right"); this._setbtn(div, "确定", ops.yes); this._setbtn(div, "取消", ops.no); } tr2.append("td.rightbar").append("div"); var tr3 = tb.append("tr.bottom"); tr3.append("td.bottomleft"); tr3.append("td.bottombar"); tr3.append("td.bottomright"); ops.init && ops.init(this); this.chgSkin(skin); return this; }, chgSkin : function(skin){ var box = this.box.cls("firstjs_dialog_"+skin), h=this.height; F.css(F.data("img/dialog/"+skin+"/skin.css"), function(){ var icon = box.cls(".close"); icon.html(icon.bgimg()=="none"?"×":""); var ch = h - box.cls(".top").height() - box.cls(".bottom").height(); var div = box.cls(".leftbar").first(); div.width() && div.height(ch) && box.cls(".rightbar").first().height(ch); var btnbox = box.cls(".btnbox"); if(btnbox){ ch -= 41;//btnbox.height(); } box.cls(".content").height(ch); }); }, //触发器 trigger : function(obj){ F(obj).click(this.show,this); return this; }, //显示 show : function(){ this.box.toggle();//.anime("top",String(-this.h),this.step).play(); return this; }, //隐藏 hide : function(){ this.box.hide(); //this.box.anime("top",String(this.h),this.step).bind("after", F.proxy(this.box,"hide")).play(); return this; }, //设置按钮 _setbtn : function(obj, text, fun){ if(fun){ obj = obj.append("input.btn").attr("type=button").val(text); if(F.isnum(fun)){ obj.click(this.hide,this); }else if(F.isfun(fun)){ obj.click(function(){ fun() && this.hide(); }, this); } } }, //定位 _pos : function(x,y){ if(arguments.length==1){ this.box.center(); }else{ this.box.pos(x,y); } } }); }($1stjs); //幻灯片组件 ~function(F){ F.slides = F.Class({ init : function(obj, ops){ obj = F(obj); ops = ops || {}; this.count = 0; this.ispause = 0; this.isplay = 0; this.nowIdx = ops.index || 0; this.oldIdx = this.oldIndex = this.nowIndex = 0; this.autoplay = ops.autoplay || 0; this.duration = ops.duration || 500; this.autoplay = 0; this.delay = 0; if(ops.autoplay){ this.autoplay = 1; this.delay = ops.autoplay; } this.increment = ops.increment || 0; this.loop = F.isset(ops.loop) ? ops.loop : 1; this.ani = {}; this.tab = this.parseAni(obj, ops, "tab"); this.panel = this.parseAni(obj, ops, "panel"); this.title = this.parseAni(obj, ops, "title"); if(this.tab){ this.tab.each(F.proxy(function(idx, fdom){ fdom.bind(ops.etype||"click", F.proxy(this,this.go2play,idx)); },this)); this.css_cur = this.tab.item(this.nowIdx).cls(); this.css_nor = this.tab.item(this.nowIdx==0?1:0).cls(); } this.prev = obj.cls(".prev"); this.next = obj.cls(".next"); this.prev && this.prev.click(this.go2prev,this); this.next && this.next.click(this.go2next,this); if(ops.onchange){ this.onchange = ops.onchange; } if(ops.aniAfter){ this.aniAfter = ops.aniAfter; } ops.init && ops.init(this); this.chk(); return this; }, //解析动画 parseAni : function(obj, ops, tag){ var dom = obj.cls("."+tag); if(!dom){ return false; } var doms = dom.child(); var me = this; this.count = Math.max(this.count, doms.len); this.itemCount = this.count; var ani = ops[tag]; if(F.isfun(ani)){ this.ani[tag] = ani; return doms; } //以下只适用于panel if(ani=="fade"){ doms.item(this.nowIdx).sibling().opacity(0.5); this.ani.panel = function(){ me.isplay = 1; doms.item(me.oldIdx).anime({ opacity: 0.5, duration: me.duration/2, after: function(){ doms.item(me.oldIdx).hide(); doms.item(me.nowIdx).show().anime({opacity:1,duration:me.duration/2,after:F.proxy(me,me.unlock,tag)}); } }); }; return doms; } if(ani=="scrollLeft"||ani=="scrollTop"){ this.method = ani; var o, box=dom; if(ani=="scrollLeft"){ var wrap = obj.cls(".wrap"); if(wrap){ var nodes = wrap.child(); var fo = nodes.item(0); wrap.width((fo.node.offsetWidth+fo.px("marginLeft")+fo.px("marginRight"))*nodes.len); nodes.float(); box = wrap; } this.boxlen = dom.node.offsetWidth; this.conlen = dom.node.scrollWidth; }else if(ani=="scrollTop"){ this.boxlen = dom.node.offsetHeight; this.conlen = dom.node.scrollHeight; } this.increment = this.increment || this.boxlen; this.itemCount = Math.ceil(this.conlen/this.increment); this.count = this.itemCount; if(this.loop==2){ //if(this.conlen<this.boxlen*2){ this.count *= 2; wrap && wrap.width(this.conlen*2); var ol = box.node.cloneNode(true); while(ol.firstChild){ box.node.appendChild(ol.firstChild); } } this.ani.panel = function(){ me.isplay = 1; var m = me.nowIdx>=me.count ? 0 : me.nowIdx; var ops = {}; ops.type = me.delay ? "circOut" : "Linear"; ops.duration = me.duration; ops[me.method] = m * me.increment; ops.after = F.proxy(me,me.unlock,"panel"); dom.anime(ops); }; return dom; } return doms; }, //解锁 unlock : function(tag){ this.isplay = 0; this.aniAfter && this.aniAfter(this,tag); this.chk(); }, //检查 chk : function(){ if(this.ispause) return; if(this.isplay==0){ this.oldIdx = this.nowIdx; this.oldIndex = this.oldIdx%this.itemCount; this.nowIndex = this.nowIdx%this.itemCount; if(this.autoplay){ if(this.delay>1){ this.timer = window.setTimeout(F.proxy(this,this.go2next), this.delay); return; } this.go2next(); } } }, //上一个 go2prev: function(){ if(this.loop==0&&this.oldIdx==0){ return; } this.nowIdx = this.oldIdx-1; if(this.nowIdx<0){ this.loop==2 && this.panel[this.method](this.conlen); this.nowIdx = this.itemCount-1; } this._switch(); }, //下一个 go2next: function(){ if(this.loop==0&&this.oldIdx==this.count-1){ return; } this.nowIdx = this.oldIdx+1; if(this.loop==2){ if(this.nowIdx>this.itemCount){ this.panel[this.method](0); this.nowIdx = 1; } }else{ if(this.nowIdx>=this.itemCount){ this.nowIdx = 0; } } this._switch(); }, //跳播 go2play : function(idx){ if(this.isplay){ return; } this.nowIdx = idx; this.nowIndex = this.nowIdx%this.itemCount; this._switch(); }, //停止 stop : function(){ window.clearTimeout(this.timer); }, //新旧切换 _switch : function(){ if(this.oldIdx==this.nowIdx){ return; } this.stop(); this.oldIndex = this.oldIdx%this.itemCount; this.nowIndex = this.nowIdx%this.itemCount; this.onchange && this.onchange(this); if(this.tab){ this.ani.tab ? this.ani.tab(this) : this.tab.item(this.oldIndex).cls(this.css_nor) && this.tab.item(this.nowIndex).cls(this.css_cur); } if(this.title){ this.ani.title ? this.ani.title(this) : this.title.item(this.oldIndex).hide() && this.title.item(this.nowIndex).show(); } if(this.panel){ this.ani.panel ? this.ani.panel(this) : this.panel.item(this.oldIndex).hide() && this.panel.item(this.nowIndex).show(); } this.chk(); } }); }($1stjs); //分页类 ~function(F){ F.pagination = F.Class({ init : function(box, cb){ this.num = 0; this.pagenum = 0; this.page = 1; this.size = 10; this.maxsize = 100; this.cb = cb; var box = F(box); this.inihtm(box); var a = box.tags("a"); var b = box.tags("b"); var i = box.tags("input"); var bt = box.tags("button"); this.fo = {box:box, num:b.item(0), pagenum:b.item(1), page:b.item(2), size:i.item(0), pageIdx:i.item(1)}; a.item(0).click(this.go2first,this); a.item(1).click(this.go2pre,this); a.item(2).click(this.go2next,this); a.item(3).click(this.go2last,this); bt.item(0).click(this.chksize,this); bt.item(1).click(this.chgsize,this); bt.item(2).click(this.chkpage,this); return this; }, //设置页个数 setsize : function(n){ this.size = n; return this; }, //设置页数 setpage : function(n){ this.page = n; return this; }, //跳到第一页 go2first : function(){ this.page!=1 && this.chgpage(1); }, //跳到上一页 go2pre : function(){ this.page-1>0 && this.chgpage(this.page-1); }, //跳到下一页 go2next : function(){ this.page+1<=this.pagenum && this.chgpage(this.page+1); }, //跳到最后一页 go2last : function(){ this.page!=this.pagenum && this.chgpage(this.pagenum); }, //改变页个数 chgsize : function(n){ this.size = isNaN(n) ? this.num : n;; this.page = 1; this.cb(); }, //改变页数 chgpage : function(n){ this.page = n; this.cb(); }, //根据记录数更新 up : function(num){ this.num = num; this.pagenum = Math.ceil(num/this.size); this.fo.num.html(this.num); this.fo.pagenum.html(this.pagenum); this.fo.page.html(this.page); this.fo.size.val(this.size); return this; }, inihtm :function(box){ var html = '总计 <b></b> 个记录分为 <b></b> 页当前第 <b></b> 页,每页 <input size="3" type="text"> <button class="btn">set</button> <button class="btn">showall</button> <a href="javascript:void(0);">第一页</a> <a href="javascript:void(0);">上一页</a> <a href="javascript:void(0);">下一页</a> <a href="javascript:void(0);">最末页</a> <input size="3" id="pageIdx" value="" type="text"> <button class="btn">go</button>'; box.html(html); }, //检查页个数 chksize : function(){ var obj = this.fo.size.node; var n = obj.value; if(n==""){ alert("请输入每页显示的个数"); obj.focus(); return; } n = +n; if(n<1||n>this.maxsize){ alert("请输入1~"+this.maxsize+"之间的数字"); obj.focus(); return; }else if(n==this.size){ alert("输入的个数不能与当前的每页个数相同"); obj.focus(); return; } this.chgsize(n); }, //检查页数 chkpage : function(){ var obj = this.fo.pageIdx.node; var n = obj.value; if(n==""){ alert("请输入页数"); obj.focus(); return; } n = +n; if(n<1){ alert("请输入正确的页数"); obj.focus(); return; }else if(n>this.pagenum){ alert("输入的页数不能大于当前总页数"); obj.focus(); return; }else if(n==this.page){ alert("输入的页数不能与当前页数相同"); obj.focus(); return; } this.chgpage(n); } }); }($1stjs); //树类 ~function(F){ F.tree = F.Class({ //初始化 init : function (root, data, settings){ var cls = "firstjs_tree"; this.img = {}; var css = []; css.push(".firstjs_tree{padding:0px; margin:0px; font-size:12px;}"); css.push(".firstjs_tree img{vertical-align:top; width:18px; height:18px;}"); css.push(".firstjs_tree ul{padding:0px; margin:0px; line-height:18px;}"); css.push(".firstjs_tree li{padding:0px; list-style-type:none; margin-left:18px; clear:both;}"); css.push(".firstjs_tree div{height:18px; line-height:18px;}"); css.push(".firstjs_tree .title div{float:left;}"); css.push(".firstjs_tree .content:after{content: \".\";display: block;height: 0;clear: both;visibility: hidden;}"); css.push(".firstjs_tree .content{*zoom:1;}"); css.push(".firstjs_tree .icon{width:18px; height:18px;}"); ("folder_close,folder_open,plus_top,plus_middle,plus_bottom,minus_top,minus_middle,minus_bottom,"+ "line_connect,elbow_middle,elbow_bottom,page,empty").replace(/\w+/g, F.proxy(this, function(v){ this.img[v] = F.data("img/tree/"+v+".gif"); css.push(F.mix(".$2 .$1{background:url($0) no-repeat 0 0; width:18px; height:18px;}",F.data("img/tree/"+v+".gif"),v,cls)); })); F.css(css); this.root = F(root).cls(cls); this.curNode = null; //设置参数 settings = settings || {}; this.opened = !!settings.opened; this.itemIcon = settings.itemIcon || this.img.page; this.itemClick = settings.itemClick; this.dirClick = settings.dirClick; this.level = isNaN(settings.level) ? 1 : settings.level; this.target = settings.target || "_blank"; //this.open(this.level); //设置显示名称和提示字段 this.items = settings.items || "items"; this.catekey = settings.catekey || settings.key || "key"; this.itemkey = settings.itemkey || settings.key || "key"; this.catedes = settings.catedes || settings.des || "des"; this.itemdes = settings.itemdes || settings.des || "des"; this.id = settings.id; this.pid = settings.pid || "pid"; F.isstr(data) ? this._showFromFile(data) : this._showFromData(data); return this; }, //打开状态 open : function (obj, a){ obj = obj.child(a.shift(),0); obj.next().css("display")=="none" && obj.fire(); a.length>0 && this.open(obj.next(), a); return this; }, //从文件读取数据 _showFromFile : function (fileName){ F.get(fileName).call2json(F.proxy(this._showFromData,this)); }, //直接读取数据 _showFromData : function (data){ if(this.id){ data = this.tranData(data); } this.add(this.root, data); var div = this.root.child(0,0); div && div.tag=="div" && div.attr("pos","top").first().src(this.img["plus_"+"top"]); !this.root.child(1) && div.fire(); this.onload && this.onload(this); }, //数据转换 tranData : function (a){ var r = []; var hash = {}; var id=this.id, pid=this.pid, items=this.items; F.each(a, function(o,i){ hash[o[id]] = o; }); F.each(a, function(o,i){ if(hash[o[pid]]){ if (!hash[o[pid]][items]){ hash[o[pid]][items] = []; } hash[o[pid]][items].push(o); }else{ r.push(o); } }); return r; }, //创建文件夹或Item add : function (ul, arr){ F.each(arr, F.proxy(this, this.addItem, ul, arr.length-1)); }, //创建文件夹 addItem : function (ul,lastIdx,o,i){ var li = ul.append("li"); var pos = i==lastIdx ? "bottom" : "middle"; var items = o[this.items]; if(items){ var div = li.append("div.title").attr("pos",pos); div.click(F.proxy(this,this.toggle,o,div)); div.append("div.plus_"+pos); if(o.icon){ o.icon = o.icon.split(" "); var icon = div.append("div.icon").bgimg(o.icon[0]); o.icon.length>1 && icon.css("background-repeat","no-repeat").bgpos(o.icon[1],o.icon[2]); }else{ div.append("div.folder_close"); } div.append("div").html(o[this.catekey]); var ul = li.append("ul.content").hide(); pos=="middle" && ul.css("background:url("+this.img.line_connect+") repeat-y;"); this.add(ul, items); }else{ li.cls("title").append("div.elbow_"+pos); if(o.icon){ o.icon = o.icon.split(" "); var icon = li.append("div.icon").bgimg(o.icon[0]); o.icon.length>1 && icon.css("background-repeat","no-repeat").bgpos(o.icon[1],o.icon[2]); }else{ li.append("div.page"); } //li.append("img").src(this.img.page); var html = o[this.itemkey]; if(o.url){ html = html.link(o.url, o.target||this.target); } var text = li.append("div").css("cursor","pointer").html(" " + html); o[this.itemdes] && text.attr("title",o[this.itemdes]); this.itemClick && li.click(F.proxy(this,this.itemClick,o)); } }, //显示或隐藏切换 toggle : function(o, obj){ obj.next().css("display")=="none" ? this.show(o,obj) : this.hide(o,obj); }, //显示 show : function(o,obj){ obj.next().show(); obj.child(0).cls("minus_"+obj.attr("pos")); !o.icon && obj.child(1).cls("folder_open") }, //隐藏 hide : function(o,obj){ obj.next().hide(); obj.child(0).cls("plus_"+obj.attr("pos")); !o.icon && obj.child(1).cls("folder_close"); }, //获取树节点 getNode : function(){ //获取子节点 var getChild = function(obj, a){ var nodes = obj.childNodes, k=0; do{ obj = nodes[k++]; if(obj.tagName.toLowerCase()=="ul") break; }while(obj); var nodes = obj.childNodes; var l = nodes.length; var idx = +a.shift(); var i; if(idx<0){ for(i=l-1; i>=0; i--){ if(nodes[i].nodeType==1&&++idx==0) break; } }else{ for(i=0; i<l; i++){ if(nodes[i].nodeType==1&&--idx<0) break; } } if(i<0||i>=l){ throw "getNode("+i+") is out range"; } return a.length>0 ? getChild(nodes[i],a) : F(nodes[i]); } return this.treeNode(this, getChild(this.root.node, F.map(arguments))); }, //树节点类 treeNode : F.Class({ init : function(tree, node){ this.tree = tree; this.node = node; }, //节点改名 rename : function(name){ this.node.html(name); return this; }, //添加子节点 add : function(o){ this.node.append("li").append("div").html('<img src="/fw4/img/tree/elbow3.gif"><img src="/fw4/img/tree/page.gif"><span style="cursor: pointer;">中国人民</span>').child(2).html(o.key); return this; }, //更新节点 edit : function(text){ this.node.child(0,2).html(text); return this; }, //删除节点 del : function(){ this.node.remove(); return this; } }) }); }($1stjs); //菜单组件 ~function(F){ F.menu = F.Class({ init : function(ops, box){ F().attr("oncontextmenu","return false"); this.box = box ? F(box) : F().append("ul").border("#ff00ff 1").ps(1).hide(); this.box.css("position:absolute; border:1px solid #ff00ff; list-style:none; line-height:25px; background-color:#000; color:#fff; width:80px;"); this.onshow = ops.onshow; this.additems(ops.data); return this; }, //添加句柄 addhand : function(obj){ F(obj).bind("contextmenu",this.show.proxy(this,obj)); return this; }, //添加菜单项 additems : function(data){ F.each(data, F.proxy(this,this.additem)); return this; }, //添加单个菜单项 additem : function(ops){ var html = ops.icon ? F.mix('<img src="$icon" />$key',ops) : ops.key; var li = this.box.append("li").bind("click", F.proxy(this,this.hide)).html(html); li.css("cursor:pointer; width:100%; height:20px; line-height:20px; margin-left:10px;"); ops.click && li.bind("click", ops.click); return this; }, //显示 show : function(obj, e){ this.box.show().pos(e.x, e.y); this.onshow && this.onshow(obj); return this; }, //隐藏 hide : function(){ this.box.hide(); return this; } }); }($1stjs); //选择器 ~function(F){ F.picker = F.Class({ init : function (ops){ this.box = ops.init(); this.box.click(this.setItem,this); return this; }, //绑定到控件中 bind : function (obj){ obj = F(obj); obj.bind("click", F.proxy(this,this.show, obj)); return this; }, //显示 showItem : function (e){ if(e.target.tagName=="TD"){ var color = e.target.title; this.view.bg(color).attr("title",color); this.input.val(color); } }, //选中 setItem : function (e){ if(e.target.tagName=="TD"||e.target.className=="view"){ this.binder.val(e.target.title); (!this.cb||this.cb(this.binder.node)!==false) && this.hide(); } }, //显示 show : function (obj){ this.binder = obj; var o = obj.abspos(1); this.box.pos(o.x, o.y+obj.offsetHeight).show(); this.ifr && this.ifr.show().sync(this.box,1); }, //隐藏 hide : function (){ this.ifr && this.ifr.hide(); this.box.hide(); return this; } }); }($1stjs); //日期选择器 ~function(F){ F.datePicker = F.Class({ init : function (){ this.box = F(arguments[0]); this.itemclick = new Function(); if(this.box.tag=="input"){ this.w = 28; this.box = this.getbox(); this.on("itemclick", this.select); F.each(F.map(arguments), F.proxy(this, this.input)); this.itemclick = this.select; }else{ this.w = 36; this.box.cls("cal"); } this.initUI(); F.get(F.data("data.php?act=getdate")).callback(F.proxy(this.chkday,this)); return this; }, //设置显示的时间 chkday : function(sd){ sd = sd.split("-"); var d = new Date(); var y = [d.getFullYear(), +sd[0]]; var m = [d.getMonth()+1, +sd[1]]; var i = +(!(y[0]==y[1]&&m[0]==m[1])&&window.confirm("您的本机时间与北京时间不同,是否设定为北京时间?")); this.y = y[i]; this.m = m[i]; this.up(0, 0); }, //设置显示的时间 setday : function(d){ this.y = d.getFullYear(); this.m = d.getMonth() + 1; return this.up(0,0); }, //初始化界面 initUI : function(){ this.ym(-1,0,"<<").ym(0,-1,"<").ti().ym(0,1,">").ym(1,0,">>"); this.wk("日").wk("一").wk("二").wk("三").wk("四").wk("五").wk("六"); this.space = this.box.append("div.space"); this.days = []; var fun = function(d){ var t = [this.y,this.m,d].join('-'); if(this.hms){ var selects = this.hms.tags("select"); var a = []; for(var i=0; i<selects.length; i++){ a[i] = selects[i].value; } t += " " + a.join(":"); } this.itemclick(t); }; for(var i=0; i<31; i++){ this.days[i] = this.box.append("a").attr("href","javascript:void(0);").html(i+1).click(F.proxy(fun,this,i+1)); } return this; }, //标题HTML ti : function(){ var fo = this.box.append("b.dateCap").html('<span></span>年<span></span>月'); this.year = fo.child(0); this.moon = fo.child(1); return this; }, //年月跳转HTML ym : function(y, m, bn){ this.box.append("b.btn").click(F.proxy(this,this.up,y,m)).html(bn); return this; }, //星期HTML wk : function(s){ this.box.append("b").html(s); return this; }, //绑定到控件中 input : function (id){ var obj = F(id).node; obj.onfocus = F.proxy(this,this.show,obj); return this; }, //增加事件 on : function(handler, fun){ this[handler] = fun; return this; }, //更新HTML up : function(y,m){ y += this.y; m += this.m; m==13 && (m=1,y++) || m==0 && (m=12,y--); this.year.html(y); this.moon.html(m); this.space.css("w", new Date(y,m-1,1).getDay()*this.w); var totaldays = new Date(y, m, 0).getDate(); for(var i=28; i<31; i++){ this.days[i].node.style.display = i<totaldays ? "block" : "none"; } this.y = y; this.m = m; return this; }, //动态添加层 getbox : function (){ var myclass = "F_datePicker"; F.css('\ .$v{border:1px solid #1F62BE;width:210px;_width:190px;position:absolute;\ font-family:Arial;background:#F0F9FF;left:-500px;overflow:hidden; }\ .$v a,\ .$v b{display:block; float:left;zoom: 1;width:20px;height:16px;line-height:16px;padding:2px;\ background:#F0F9FF;font-size:12px;text-align:center;color:#333;font-family:Arial;\ text-decoration:none;margin:0px 2px;\ }\ .$v b{background:none;}\ .$v a:hover{background:#FE8B1A;color:#fff;font-weight:bold}\ .$v .btn{cursor:pointer;width:18px;}\ .$v .dateCap{ width:80px;color:#900; }\ .$v .space{display:block; float:left; zoom:1; margin:0; width:0; height:20px;}\ .$v .time{display:block; float:left; width:100%; height:30px; line-height:30px; text-align:center;}\ .$v .time span{margin:0 5px; font-size:12px;}\ '.replace(/\$v/g,myclass)); if(F.isie6){ this.ifr = F().append("iframe").css("cssText","position:absolute; display:none; width:0px; height:0px"); } return F().append("div").cls(myclass).attr("title","点击面板空白处关闭").click(function(e){ (document.all||e.target==this.obj) && this.hide(); },this).hide(); }, //选中 select : function (d){ this.input.value = d; this.hide(); }, //显示 show : function (obj){ this.input = obj; var o = F(obj).abspos(1); this.box.pos(o.x, o.y+obj.offsetHeight).show(); this.ifr && this.ifr.show().sync(this.box,1); }, //隐藏 hide : function (){ this.ifr && this.ifr.hide(); this.box.hide(); }, //格式化时分秒 format : function (str){ var o = {}; str.replace(/./g,function(s){o[s]=1}); var hops = [], mops = [], sops = []; for(var i=0; i<60; i++){ o.h && i<24 && hops.push('<option>'+i+'</option>'); o.m && mops.push('<option>'+F.zero(i)+'</option>'); o.s && sops.push('<option>'+F.zero(i)+'</option>'); } hops = o.h ? '<span><select>'+hops.join("")+'</select>时</span>' : ''; mops = o.m ? '<span><select>'+mops.join("")+'</select>分</span>' : ''; sops = o.s ? '<span><select>'+sops.join("")+'</select>秒</span>' : ''; this.hms = this.box.append("span.time").html(hops+mops+sops); } }); }($1stjs); //颜色选择器 ~function(F){ F.colorPicker = F.Class({ init : function (){ this.box = this.create().bind("mousemove",F.proxy(this,this.showItem)).click(this.setItem,this); this.view = this.box.cls(".view"); this.input = this.box.cls(".input").bind("keyup", F.proxy(this,this.chkColor)); F.each(arguments, F.proxy(this, this.bind)); }, callback : function(cb){ this.cb = cb; return this; }, create : function (){//创建所有HTML var myclass = "F_colorPicker"; F.css(F.mix('\ .$v{width:170px;_width:175px;text-align:center;border:1px solid #666;background:#E7DFE7 url() no-repeat 97% 6%;font-size:12px;position:absolute;display:none;z-index:999}\ .$v .colorTitle{text-align:left;margin:5px 5px 0 5px;zoom:1}\ .$v .view{width:70px;height:20px;background:#000;border:1px solid #000;float:left;margin-right:4px;cursor:pointer;}\ .$v .input{padding:4px 0 0 4px;float:left;width:55px;border:1px solid #7B9EBD;height:16px;}\ .$v .colorCell{margin:0 auto;padding:5px;clear:both;}\ .$v .colorTable table{border-collapse:collapse;}\ .$v .colorTable table td{border:1px solid #000;height:8px;width:8px;overflow:hidden;font-size:1px;cursor:pointer;}\ ',{v:myclass})); var m = '00,33,66,99,CC,FF'.split(','),a,b,c,d,e,f,x,y,z, T=!!document.attachEvent?'&nbsp;':'';//谷歌会撑开表格 Html=['<div class="colorTitle"><div class="view" title="#000000"></div><input type="text" class="input" value="#000000" maxlength="7" /></div><div class="colorCell"><table cellspacing="0" cellpadding="0" class="colorTable"><tr>']; for (x = 0; x < 6; ++x) {//按规律生成颜色单元格 Html.push('<td><table cellspacing="0" cellpadding="0">'); for (y = 0,a = m[x] ; y < 6; ++y) { Html.push('<tr>'); for (z = 0,c = m[y]; z < 6; ++z) { b = m[z]; d = z==5&&x!=2&&x!=5?';border-right:none;':''; e = y ==5&&x<3?';border-bottom:none':''; f='#'+a+b+c; Html.push('<td style="background:'+f+d+e+'" title="'+f+'">'+T+'</td>'); }; Html.push('</tr>') }; Html.push('</table></td>'); if(m[x]=='66')Html.push('</tr><tr>') }; return F().append("div").cls(myclass).html(Html); }, //绑定到控件中 bind : function (obj){ obj = F(obj); obj.bind("focus", F.proxy(this,this.show, obj)); return this; }, //显示 showItem : function (e){ if(e.target.tagName=="TD"){ var color = e.target.title; this.view.bg(color).attr("title",color); this.input.val(color); } }, //选中 setItem : function (e){ if(e.target.tagName=="TD"||e.target.className=="view"){ this.binder.val(e.target.title); (!this.cb||this.cb(this.binder.node)!==false) && this.hide(); } }, //输入检查 chkColor : function(e, binder){ var key = e.keyCode; if(/[\x2E-\xff]/.test(String.fromCharCode(key))){ binder.val( "#" + binder.val().replace(/#/g,"").replace(/[^\da-f]/ig,'F').toUpperCase() ); } var color = binder.val(); if(/^#([\da-f]{3}|[\da-f]{6})$/i.test(color)){ this.view.bg(color).attr("title",color); key==13 && this.view.fire(); } }, //显示 show : function (obj){ this.binder = obj; var o = obj.abspos(1); this.box.pos(o.x, o.y+obj.offsetHeight).show(); this.ifr && this.ifr.show().sync(this.box,1); }, //隐藏 hide : function (){ this.ifr && this.ifr.hide(); this.box.hide(); return this; } }); }($1stjs); //绘图类 ~function(F){ F.canvas = F.Class({ init : function(box){ this.box = F(box||document.body); return this; }, //设置参数 ops : function(fillcolor, strokecolor, strokeweight){ if(F.isobj(fillcolor)){ F.merge(this, fillcolor); }else{ this.fillcolor = fillcolor; this.strokecolor = strokecolor; this.strokeweight = strokeweight; } return this; }, //位置尺寸大小 range : function(x,y,w,h){ this.x = x; this.y = y; this.w = w; this.h = h; return this; }, //旋转 rotate : function(angle){ this.angle = angle; return this; }, //拷贝 copy : function(obj){ return F.canvas(obj||this.box).ops(this.fillcolor,this.strokecolor,this.strokeweight).range(this.x,this.y,this.w,this.h); }, //圆 circle : function(x,y,r){ this.shape = "circle"; this.chkCanvas("v:oval"); if(F.iscanvas){ switch(arguments.length){ case 0 : this.ctx.arc(this.w/2, this.h/2, Math.min(this.w,this.h)/2,0, Math.PI*2, false); break; case 1 : this.ctx.arc(this.w/2, this.h/2, x, 0, Math.PI*2, false); break; case 3 : this.ctx.arc(x, y, r, 0, Math.PI*2, false); break; } } return this; }, //矩形 rect : function(x1,y1,x2,y2){ if(arguments.length>0&&F.isobj(arguments[0])){ return this.rect.apply(this, arguments[0]); } this.shape = "rect"; this.chkCanvas("v:rect"); if(F.iscanvas){ switch(arguments.length){ case 0 : this.ctx.rect(0,0,this.w,this.h); break; case 2 : this.ctx.rect(0,0,x1,y1); break; case 4 : this.ctx.rect(x1,y1,x2,y2); break; } } return this; }, //多边型 polygon : function(){ if(arguments.length>0&&F.isobj(arguments[0])){ return this.polygon.apply(this, arguments[0]); } this.shape = "polygon"; this.chkCanvas("v:shape"); if(F.iscanvas){ this.ctx.beginPath(); var a = arguments, l = a.length; this.ctx.moveTo(a[0], a[1]); for(var i=2; i<l; i+=2){ this.ctx.lineTo(a[i], a[i+1]); } this.ctx.closePath(); }else{ var a = F.map(arguments); this.canvas.attr({path:"m"+a.splice(0,2).join(",")+"l"+a.join(",")+"xe",coordsize:this.w+","+this.h}); } return this; }, //线条 line : function(x1,y1,x2,y2,lineType){ this.shape = "line"; this.lineType = lineType || 0; this.chkCanvas("v:shape"); if(F.iscanvas){ this.ctx.moveTo(x1, y1); if(this.lineType==1){ this.ctx.lineTo(x1, y2); }else if(this.lineType==2){ this.ctx.lineTo(x2, y1); } this.ctx.lineTo(x2, y2); this.ctx.stroke(); }else{ var wh = {width:Math.abs(x2-x1),height:Math.abs(y2-y1)}, pos; if(this.lineType==0){ pos = [x2-x1, y2-y1]; }else if(this.lineType==1){ pos = [0, y2-y1, x2-x1, y2-y1]; }else if(this.lineType==2){ pos = [x2-x1 ,0, x2-x1, y2-y1]; } this.canvas.css(wh).attr({path:"m0,0l"+pos.join(",")+"e",filled:"f",coordsize:wh.width+","+wh.height}).pos(x1,y1,1); } return this; }, //检查画布 chkCanvas : function(tag){ if(!this.canvas){ if(F.iscanvas){ this.canvas = this.box.append("canvas").ps().pos(this.x,this.y).attr({width:this.w,height:this.h}); this.ctx = this.canvas.node.getContext("2d"); this.ctx.fillStyle = this.fillcolor; this.ctx.strokeStyle = this.strokecolor; this.ctx.lineWidth = this.strokeweight; this.angle && (this.ctx.translate(15,15),this.ctx.rotate(this.angle*Math.PI/180)); }else{ var ops = F.clone(this,"fillcolor","strokecolor","strokeweight"); this.canvas = this.box.append(tag).rect(this.x,this.y,this.w,this.h,1).attr(ops); } } //alert([this.x,this.y,this.w,this.h]); F.iscanvas && this.ctx.clearRect(this.x,this.y,this.w,this.h); }, //画笔 stroke : function(){ F.iscanvas && this.ctx.stroke(); return this; }, //填充 fill : function(){ F.iscanvas && this.ctx.fill(); return this; }, //填充文字 text : function(txt){ F.iscanvas && this.ctx.fillText(txt, 20, 40); return this; } }); }($1stjs);
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ ~function(F){ //媒体播放类 F.player = { //初始化 init : function (obj,w,h){ this.box = F(obj) || F().append("div"); this.w=w||0; this.h=h||0; this.mp = {}; this.mplist = [this.wmp, this.rmp]; this.idlist = ["6bf52a52-394a-11d3-b153-00c04f79faa6","CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"]; this.typeList = ["application/x-mplayer2", "audio/x-pn-realaudio-plugin"]; this.statelist = ["初始停止暂停播放搜索搜索缓冲等待结束连接停止".match(/../g)]; this.statelist[1] = "停止连接缓冲播放暂停搜索".match(/../g); }, //window media player方法 wmp : { play : function(){ F.player.obj.controls.play() }, pause : function(){ F.player.obj.controls.pause() }, stop : function(){ F.player.obj.controls.stop() }, seturl : function(u){ F.player.obj.url = u }, setpos : function(n){ F.player.obj.controls.currentPosition=n/1000 }, setvol : function(n){ F.player.obj.settings.volume=n||me.vol }, setmute : function(){ F.player.obj.settings.mute=!F.player.obj.settings.mute }, getpos : function(){ return F.player.obj.controls.currentPosition*1000 }, getlen : function(){ return (F.player.obj.currentMedia||{duration:300}).duration*1000 }, getstate : function(){ return F.player.statelist[0][F.player.obj.playState] }, getauthor : function(){ return F.player.obj.currentMedia.getItemInfo("author") }, gettitle : function(){ return F.player.obj.currentMedia.getItemInfo("title") } }, //realplayer方法 rmp : { play : function(){ F.player.obj.DoPlay() }, pause : function(){ F.player.obj.DoPause() }, stop : function(){ F.player.obj.DoStop() }, seturl : function(u){ F.player.obj.SetSource(u) }, setpos : function(n){ F.player.obj.setPosition(n) }, setvol : function(n){ F.player.obj.setVolume(n) }, setmute : function(){ F.player.obj.setMute(!F.player.obj.getMute()) }, getpos : function(){ return F.player.obj.GetPosition() }, getlen : function(){ return F.player.obj.getLength() }, getstate : function (){ return F.player.statelist[1][F.player.obj.getPlayState()] } }, //打开MP3文件 open : function(u){ this.box.html(this.getHTML(u)); this.obj = this.box.node.firstChild; this.obj.uiMode = "None"; var i = +/\.(?:rm|rmvb|avi)$/.test(u); this.mp = this.mplist[i]; this.mp.seturl(u); this.mp.play(); }, //获取播放器HTML代码 getHTML : function(u){ var i = +/\.(?:rm|rmvb|avi)$/.test(u); if (F.isie){ return '<object classid="clsid:'+this.idlist[i]+'" width="'+this.w+'" height="'+this.h+'"></object>'; } return '<embed type="'+this.typeList[i]+'" src="'+u+'" width="'+this.w+'" height="'+this.h+'"></embed>'; } } }($1stjs);
JavaScript
var item = { init : function(dataUrl){ var box = F("panel"); F.get(dataUrl).call2json(function(json){ var data = [{cat_name:"root", cat_title:"Fw4.0API参考", items:json}]; this.tree = box.tags("ul").item(0).tree(data,{ catekey:"cat_title", catedes:"cat_name", itemkey:"name", itemdes:"title", target:"page" }); //this.tree.open(tree.root,[0]); }.proxy(this)); this.setDoor(box.child(0), box.child(1)); F.js(F.data("js/cnzz.js")); }, //展开或收缩列表 setDoor : function (leftbox, bar){ var div = bar.append("div"); var img = div.append("img"); var as = [F.data("img/door/show_out.gif"), F.data("img/door/show_over.gif")]; var ah = [F.data("img/door/hide_out.gif"), F.data("img/door/hide_over.gif")]; var s1 = leftbox.node.style; img.hover(function(){ img.src(s1.display!="none"?ah[0]:as[1]); },function(){ img.src(s1.display!="none"?ah[1]:as[0]); }).bind("mousedown",function(){ s1.display = s1.display!="none" ? "none" : ""; img.node.title = s1.display!="none" ? "显示菜单" : "隐藏菜单"; }).src(ah[1]).attr("title", "隐藏菜单"); } };
JavaScript
var item_dir = { init : function(dataUrl){ this.html = ""; this.lv = 0; this.idx = 1; F.get(dataUrl).call2json(function(json){ this.setCol(json); var box = F().append("div").ps().pos(10,2).html(this.html); var n = box.tags("a").len - 2; box.child().each(function(idx,fo){ idx<8 && fo.child(0).append("b").html(" ("+fo.tags("a").len+"/"+n+")"); }); }.proxy(this)); }, //栏目HTML setCol : function(a){ a.each(function(o,i){ this.html += '<div class="col$idx">'.mix(this); this.setHTML(o,"0,"+i); this.html += '</div>'; this.idx++; }.proxy(this)); }, //itemHTML setHTML : function(o,ii){ if(o.items && o.items.length>0){ this.lv++; this.html += '<h$lv title="$cat_name">$cat_title</h$lv><ul>'.mix(this).mix(o); var oo; for(var i=0,l=o.items.length; i<l; i++){ oo = o.items[i]; this.html += '<li>'; if(oo.name){ this.html += ('<a href="$url" title="$title" onclick="top.item.tree.open(top.item.tree.root,['+ii+'])">$name</a>').mix(oo); } this.setHTML(oo,ii+","+i); this.html += '</li>'; } this.html += '</ul>'; this.lv--; } } };
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ ~function(F){ //手风琴组件 F.accordion = F.Class({ init : function (box, ops){ this.box = F(box).border("#222"); ops = ops || {}; this.idx = ops.index || 0; this.dt = this.box.tags("dt").bg("#ccc"); var h = Math.floor(this.dt.item(0).height()/2-8); this.dt.each(function(idx,fdom){ var u = F.data("img/icon/16_222.png"); fdom.append("div").float().size(16,16).css("background", "url("+u+") no-repeat").px("marginTop",h).bgpos(idx>0?-32:-64,-16); idx>0 && fdom.css("border-top", "1px dashed #222"); fdom.click(F.proxy(this,this._switch,idx)); },this); this.dd = this.box.tags("dd"); this.h = this.dd.item(this.idx).height(); this.dd.bg("#fff"); }, //切换 _switch : function(idx){ if(idx==this.idx) return; this.dt.item(this.idx).last().bgpos(-32,-16); this.dt.item(idx).last().bgpos(-64,-16); this.dd.item(this.idx).anime({height:0, duration:500}); this.dd.item(idx).anime({height:this.h, duration:500}); this.idx = idx; } }); }($1stjs);
JavaScript
[ {key:"动画组件", icon:"../data/img/icon/widget.png 0 -768", items:[ {key:"简单动画", url:"anime/simple_anime.html"}, {key:"刮刮片", url:"anime/guaguapian.html"} ]}, {key:"拖动组件", icon:"../data/img/icon/widget.png 0 -720", items:[ {key:"简单拖动", url:"drag/simple_drag.html"}, {key:"调色器(滑动)", icon:"../data/img/icon/widget.png 0 -720", url:"drag/slide.html"} ]}, {key:"弹窗组件", icon:"../data/img/icon/widget.png 0 -390", items:[ {key:"简单弹窗", url:"dialog/01.html"}, {key:"右下角提示框", url:"dialog/02.html"}, {key:"消息框", icon:"../data/img/icon/widget.png 0 -1149", url:"dialog/03.html"} ]}, {key:"幻灯片组件", icon:"../data/img/icon/widget.png 0 -863", items:[ {key:"选项卡组件", icon:"../data/img/icon/widget.png 0 -55", items: [ {key:"横向选项卡", url:"slides/tabPanel01.html"}, {key:"竖向选项卡", url:"slides/tabPanel02.html"}, {key:"复杂选项卡", url:"slides/tabPanel03.html"} ]}, {key:"轮显", icon:"../data/img/icon/widget.png 0 -863", items: [ {key:"直接轮显", url:"slides/scroll01.html"}, {key:"淡入淡出轮显", url:"slides/scroll09.html"}, {key:"左方向循环滚动", url:"slides/scroll02.html"}, {key:"上方向循环滚动", url:"slides/scroll04.html"}, {key:"左右顺序滚动", url:"slides/scroll10.html"}, {key:"上下顺序滚动", url:"slides/scroll07.html"}, {key:"左右无缝循环滚动", url:"slides/scroll11.html"}, {key:"定向无缝循环滚动", url:"slides/scroll03.html"}, {key:"上下无缝循环滚动", url:"slides/scroll06.html"}, {key:"水平滚动文字", url:"slides/scroll12.html"}, {key:"垂直滚动文字", url:"slides/scroll13.html"}, {key:"任意滚动", url:"slides/scroll14.html"}, {key:"自定义幻灯片", url:"slides/scroll08.html"}, {key:"图片展示器", url:"slides/scroll15.html"}, {key:"百叶窗切换效果", url:"slides/scroll05.html"} ]} ]}, {key:"分页组件", icon:"../data/img/icon/widget.png 0 -481", items:[ {key:"一次性加载分页", url:"pager/full_pager.html"}, {key:"AJAX加载分页", url:"pager/ajax_pager.html"} ]}, {key:"树组件", icon:"../data/img/icon/widget.png 0 -6", items:[ {key:"标准树", url:"tree/standard_tree.html"}, {key:"数据库导出树", icon:"../data/img/icon/widget.png 0 -1200", url:"tree/database_tree.html"}, {key:"动画效果的树", url:"tree/anime_tree.html"}, {key:"异步加载的树", url:"tree/ajax_tree.html"} ]}, {key:"菜单组件", icon:"../data/img/icon/widget.png 0 -195",items:[ {key:"右键菜单", url:"menu/content_menu.html"}, {key:"多层菜单", url:"menu/start_menu.html"}, {key:"软件菜单", url:"menu/soft_menu.html"} ]}, {key:"选择器", icon:"../data/img/icon/widget.png 0 -673", items:[ {key:"普通日期选择器", icon:"../data/img/icon/widget.png 0 -958", url:"picker/datePicker.html"}, {key:"双版日期选择器", url:"picker/datePicker2.html"}, {key:"颜色选择器", icon:"../data/img/icon/widget.png 0 -675", url:"picker/colorPicker.html"}, {key:"表情选择器", url:"picker/facePicker.html"} ]}, {key:"绘图组件", icon:"../data/img/icon/widget.png 0 -910", items:[ {key:"简单图形", url:"canvas/shape.html"}, {key:"统计图", icon:"../data/img/icon/widget.png 0 -910", url:"canvas/chart.html"}, {key:"流程图定制", icon:"../data/img/icon/widget.png 0 -816", url:"canvas/flow.html"}, {key:"Web版PS工具", url:"canvas/ps.html"} ]}, {key:"手风琴组件", icon:"../data/img/icon/widget.png 0 -343", items:[ {key:"竖向", url:"accordion/01.html"}, {key:"横向", url:"accordion/02.html"} ]}, {key:"代码相关组件", icon:"../data/img/icon/widget.png 0 -245", items:[ {key:"代码压缩", url:"code/codeEncode.html"}, {key:"代码格式化", url:"code/codeFormat.html"} ]}, {key:"语法高亮", icon:"../data/img/icon/widget.png 0 -1005", items:[ {key:"JS", url:"highlight/js.html"}, {key:"CSS", url:"highlight/css.html"}, {key:"HTML", url:"highlight/html.html"}, {key:"PHP", url:"highlight/php.html"}, {key:"AS", url:"highlight/as.html"}, {key:"C", url:"highlight/c.html"} ]}, {key:"汉字相关组件", icon:"../data/img/icon/widget.png 0 -580", items:[ {key:"简繁转换", url:"cchar/cchar.html"}, {key:"汉字转拼音", url:"cchar/pinyin.html"}, {key:"汉字笔划数", url:"cchar/stroknum.html"} ]}, {key:"播放器组件", icon:"../data/img/icon/widget.png 0 -1312", items:[ {key:"歌词同步播放器", url:"player/syncLyric.html"}, {key:"MTV歌词播放器", url:"player/mtv_player.html"}, {key:"flash播放器", url:"player/flash_player.html"} ]}, {key:"表单验证", icon:"../data/img/icon/widget.png 0 -530", items:[ {key:"表单验证", url:"validate/chkForm.html"}, {key:"身份证严格验证", url:"validate/chkIdcard.html"}, {key:"车牌严格验证", url:"validate/chkCar.html"} ]}, {key:"其他组件", icon:"../data/img/icon/widget.png 0 -1096", items:[ {key:"省市县三级联动", url:"other/pca.html"}, {key:"日历", icon:"../data/img/icon/widget.png 0 -293", url:"other/calendar.html"}, {key:"数学公式", url:"other/maths.html"}, {key:"算法集合", url:"other/algorithms.html"}, {key:"兼容的复制功能", url:"other/copy.html"}, {key:"图片放大镜效果", url:"other/zoomImg.html"} ]} ]
JavaScript
/* @author : "likaituan", @email : "61114579@qq.com", @version : "4.0", @date : "2010-09-05", @lastime : "2011-8-18" */ //组合结果数组 F.combine = function (a,n,t){ if (n==0) return [t]; var r = []; for(var i=0; i<=a.length-n; i++){ r = r.concat(arguments.callee(a.slice(i+1), n-1, t.concat(a[i]))); } return r; };
JavaScript
(function($) { //Make nodes selectable by expression $.extend($.expr[':'], { draggable: "(' '+a.className+' ').indexOf(' ui-draggable ')" }); //Macros for external methods that support chaining var methods = "destroy,enable,disable".split(","); for(var i=0;i<methods.length;i++) { var cur = methods[i], f; eval('f = function() { var a = arguments; return this.each(function() { if(jQuery(this).is(".ui-draggable")) jQuery.data(this, "ui-draggable")["'+cur+'"](a); }); }'); $.fn["draggable"+cur.substr(0,1).toUpperCase()+cur.substr(1)] = f; }; //get instance method $.fn.draggableInstance = function() { if($(this[0]).is(".ui-draggable")) return $.data(this[0], "ui-draggable"); return false; }; $.fn.draggable = function(o) { return this.each(function() { new $.ui.draggable(this, o); }); } $.ui.ddmanager = { current: null, droppables: [], prepareOffsets: function(t, e) { var dropTop = $.ui.ddmanager.dropTop = []; var dropLeft = $.ui.ddmanager.dropLeft; var m = $.ui.ddmanager.droppables; for (var i = 0; i < m.length; i++) { if(m[i].item.disabled) continue; m[i].offset = $(m[i].item.element).offset(); if (t && m[i].item.options.accept(t.element)) //Activate the droppable if used directly from draggables m[i].item.activate.call(m[i].item, e); } }, fire: function(oDrag, e) { var oDrops = $.ui.ddmanager.droppables; var oOvers = $.grep(oDrops, function(oDrop) { if (!oDrop.item.disabled && $.ui.intersect(oDrag, oDrop, oDrop.item.options.tolerance)) oDrop.item.drop.call(oDrop.item, e); }); $.each(oDrops, function(i, oDrop) { if (!oDrop.item.disabled && oDrop.item.options.accept(oDrag.element)) { oDrop.out = 1; oDrop.over = 0; oDrop.item.deactivate.call(oDrop.item, e); } }); }, update: function(oDrag, e) { if(oDrag.options.refreshPositions) $.ui.ddmanager.prepareOffsets(); var oDrops = $.ui.ddmanager.droppables; var oOvers = $.grep(oDrops, function(oDrop) { if(oDrop.item.disabled) return false; var isOver = $.ui.intersect(oDrag, oDrop, oDrop.item.options.tolerance) if (!isOver && oDrop.over == 1) { oDrop.out = 1; oDrop.over = 0; oDrop.item.out.call(oDrop.item, e); } return isOver; }); $.each(oOvers, function(i, oOver) { if (oOver.over == 0) { oOver.out = 0; oOver.over = 1; oOver.item.over.call(oOver.item, e); } }); } }; $.ui.draggable = function(el, o) { var options = {}; $.extend(options, o); var self = this; $.extend(options, { _start: function(h, p, c, t, e) { self.start.apply(t, [self, e]); // Trigger the start callback }, _beforeStop: function(h, p, c, t, e) { self.stop.apply(t, [self, e]); // Trigger the start callback }, _drag: function(h, p, c, t, e) { self.drag.apply(t, [self, e]); // Trigger the start callback }, startCondition: function(e) { return !(e.target.className.indexOf("ui-resizable-handle") != -1 || self.disabled); } }); $.data(el, "ui-draggable", this); if (options.ghosting == true) options.helper = 'clone'; //legacy option check $(el).addClass("ui-draggable"); this.interaction = new $.ui.mouseInteraction(el, options); } $.extend($.ui.draggable.prototype, { plugins: {}, currentTarget: null, lastTarget: null, destroy: function() { $(this.interaction.element).removeClass("ui-draggable").removeClass("ui-draggable-disabled"); this.interaction.destroy(); }, enable: function() { $(this.interaction.element).removeClass("ui-draggable-disabled"); this.disabled = false; }, disable: function() { $(this.interaction.element).addClass("ui-draggable-disabled"); this.disabled = true; }, prepareCallbackObj: function(self) { return { helper: self.helper, position: { left: self.pos[0], top: self.pos[1] }, offset: self.options.cursorAt, draggable: self, options: self.options } }, start: function(that, e) { var o = this.options; $.ui.ddmanager.current = this; $.ui.plugin.call(that, 'start', [e, that.prepareCallbackObj(this)]); $(this.element).triggerHandler("dragstart", [e, that.prepareCallbackObj(this)], o.start); if (this.slowMode && $.ui.droppable && !o.dropBehaviour) $.ui.ddmanager.prepareOffsets(this, e); return false; }, stop: function(that, e) { var o = this.options; $.ui.plugin.call(that, 'stop', [e, that.prepareCallbackObj(this)]); $(this.element).triggerHandler("dragstop", [e, that.prepareCallbackObj(this)], o.stop); if (this.slowMode && $.ui.droppable && !o.dropBehaviour) //If cursorAt is within the helper, we must use our drop manager $.ui.ddmanager.fire(this, e); $.ui.ddmanager.current = null; $.ui.ddmanager.last = this; return false; }, drag: function(that, e) { var o = this.options; $.ui.ddmanager.update(this, e); this.pos = [this.pos[0]-o.cursorAt.left, this.pos[1]-o.cursorAt.top]; $.ui.plugin.call(that, 'drag', [e, that.prepareCallbackObj(this)]); var nv = $(this.element).triggerHandler("drag", [e, that.prepareCallbackObj(this)], o.drag); var nl = (nv && nv.left) ? nv.left : this.pos[0]; var nt = (nv && nv.top) ? nv.top : this.pos[1]; $(this.helper).css('left', nl+'px').css('top', nt+'px'); // Stick the helper to the cursor return false; } }); })($);
JavaScript
(function($) { //If the UI scope is not availalable, add it $.ui = $.ui || {}; //Add methods that are vital for all mouse interaction stuff (plugin registering) $.extend($.ui, { plugin: { add: function(w, c, o, p) { var a = $.ui[w].prototype; if(!a.plugins[c]) a.plugins[c] = []; a.plugins[c].push([o,p]); }, call: function(instance, name, arguments) { var c = instance.plugins[name]; if(!c) return; var o = instance.interaction ? instance.interaction.options : instance.options; var e = instance.interaction ? instance.interaction.element : instance.element; for (var i = 0; i < c.length; i++) { if (o[c[i][0]]) c[i][1].apply(e, arguments); } } } }); $.fn.mouseInteractionDestroy = function() { this.each(function() { if($.data(this, "ui-mouse")) $.data(this, "ui-mouse").destroy(); }); } $.ui.mouseInteraction = function(el,o) { if(!o) var o = {}; this.element = el; $.data(this.element, "ui-mouse", this); this.options = {}; $.extend(this.options, o); $.extend(this.options, { handle : o.handle ? ($(o.handle, el)[0] ? $(o.handle, el) : $(el)) : $(el), helper: o.helper || 'original', preventionDistance: o.preventionDistance || 0, dragPrevention: o.dragPrevention ? o.dragPrevention.toLowerCase().split(',') : ['input','textarea','button','select','option'], cursorAt: { top: ((o.cursorAt && o.cursorAt.top) ? o.cursorAt.top : 0), left: ((o.cursorAt && o.cursorAt.left) ? o.cursorAt.left : 0), bottom: ((o.cursorAt && o.cursorAt.bottom) ? o.cursorAt.bottom : 0), right: ((o.cursorAt && o.cursorAt.right) ? o.cursorAt.right : 0) }, cursorAtIgnore: (!o.cursorAt) ? true : false, //Internal property appendTo: o.appendTo || 'parent' }) o = this.options; //Just Lazyness if(!this.options.nonDestructive && (o.helper == 'clone' || o.helper == 'original')) { // Let's save the margins for better reference o.margins = { top: parseInt($(el).css('marginTop')) || 0, left: parseInt($(el).css('marginLeft')) || 0, bottom: parseInt($(el).css('marginBottom')) || 0, right: parseInt($(el).css('marginRight')) || 0 }; // We have to add margins to our cursorAt if(o.cursorAt.top != 0) o.cursorAt.top = o.margins.top; if(o.cursorAt.left != 0) o.cursorAt.left += o.margins.left; if(o.cursorAt.bottom != 0) o.cursorAt.bottom += o.margins.bottom; if(o.cursorAt.right != 0) o.cursorAt.right += o.margins.right; if(o.helper == 'original') o.wasPositioned = $(el).css('position'); } else { o.margins = { top: 0, left: 0, right: 0, bottom: 0 }; } var self = this; this.mousedownfunc = function(e) { // Bind the mousedown event return self.click.apply(self, [e]); } o.handle.bind('mousedown', this.mousedownfunc); //Prevent selection of text when starting the drag in IE if($.browser.msie) $(this.element).attr('unselectable', 'on'); } $.extend($.ui.mouseInteraction.prototype, { plugins: {}, currentTarget: null, lastTarget: null, timer: null, slowMode: false, init: false, destroy: function() { this.options.handle.unbind('mousedown', this.mousedownfunc); }, trigger: function(e) { return this.click.apply(this, arguments); }, click: function(e) { var o = this.options; window.focus(); if(e.which != 1) return true; //only left click starts dragging // Prevent execution on defined elements var targetName = (e.target) ? e.target.nodeName.toLowerCase() : e.srcElement.nodeName.toLowerCase(); for(var i=0;i<o.dragPrevention.length;i++) { if(targetName == o.dragPrevention[i]) return true; } //Prevent execution on condition if(o.startCondition && !o.startCondition.apply(this, [e])) return true; var self = this; this.mouseup = function(e) { return self.stop.apply(self, [e]); } this.mousemove = function(e) { return self.drag.apply(self, [e]); } var initFunc = function() { //This function get's called at bottom or after timeout $(document).bind('mouseup', self.mouseup); $(document).bind('mousemove', self.mousemove); self.opos = [e.pageX,e.pageY]; // Get the original mouse position } if(o.preventionTimeout) { //use prevention timeout if(this.timer) clearInterval(this.timer); this.timer = setTimeout(function() { initFunc(); }, o.preventionTimeout); return false; } initFunc(); return false; }, start: function(e) { var o = this.options; var a = this.element; o.co = $(a).offset(); //get the current offset this.helper = typeof o.helper == 'function' ? $(o.helper.apply(a, [e,this]))[0] : (o.helper == 'clone' ? $(a).clone()[0] : a); if(o.appendTo == 'parent') { // Let's see if we have a positioned parent var cp = a.parentNode; while (cp) { if(cp.style && ($(cp).css('position') == 'relative' || $(cp).css('position') == 'absolute')) { o.pp = cp; o.po = $(cp).offset(); o.ppOverflow = !!($(o.pp).css('overflow') == 'auto' || $(o.pp).css('overflow') == 'scroll'); //TODO! break; } cp = cp.parentNode ? cp.parentNode : null; }; if(!o.pp) o.po = { top: 0, left: 0 }; } this.pos = [this.opos[0],this.opos[1]]; //Use the relative position this.rpos = [this.pos[0],this.pos[1]]; //Save the absolute position if(o.cursorAtIgnore) { // If we want to pick the element where we clicked, we borrow cursorAt and add margins o.cursorAt.left = this.pos[0] - o.co.left + o.margins.left; o.cursorAt.top = this.pos[1] - o.co.top + o.margins.top; } if(o.pp) { // If we have a positioned parent, we pick the draggable relative to it this.pos[0] -= o.po.left; this.pos[1] -= o.po.top; } this.slowMode = (o.cursorAt && (o.cursorAt.top-o.margins.top > 0 || o.cursorAt.bottom-o.margins.bottom > 0) && (o.cursorAt.left-o.margins.left > 0 || o.cursorAt.right-o.margins.right > 0)) ? true : false; //If cursorAt is within the helper, set slowMode to true if(!o.nonDestructive) $(this.helper).css('position', 'absolute'); if(o.helper != 'original') $(this.helper).appendTo((o.appendTo == 'parent' ? a.parentNode : o.appendTo)).show(); // Remap right/bottom properties for cursorAt to left/top if(o.cursorAt.right && !o.cursorAt.left) o.cursorAt.left = this.helper.offsetWidth+o.margins.right+o.margins.left - o.cursorAt.right; if(o.cursorAt.bottom && !o.cursorAt.top) o.cursorAt.top = this.helper.offsetHeight+o.margins.top+o.margins.bottom - o.cursorAt.bottom; this.init = true; if(o._start) o._start.apply(a, [this.helper, this.pos, o.cursorAt, this, e]); // Trigger the start callback this.helperSize = { width: outerWidth(this.helper), height: outerHeight(this.helper) }; //Set helper size property return false; }, stop: function(e) { var o = this.options; var a = this.element; var self = this; $(document).unbind('mouseup', self.mouseup); $(document).unbind('mousemove', self.mousemove); if(this.init == false) return this.opos = this.pos = null; if(o._beforeStop) o._beforeStop.apply(a, [this.helper, this.pos, o.cursorAt, this, e]); if(this.helper != a && !o.beQuietAtEnd) { // Remove helper, if it's not the original node $(this.helper).remove(); this.helper = null; } if(!o.beQuietAtEnd) { //if(o.wasPositioned) $(a).css('position', o.wasPositioned); if(o._stop) o._stop.apply(a, [this.helper, this.pos, o.cursorAt, this, e]); } this.init = false; this.opos = this.pos = null; return false; }, drag: function(e) { if (!this.opos || ($.browser.msie && !e.button)) return this.stop.apply(this, [e]); // check for IE mouseup when moving into the document again var o = this.options; this.pos = [e.pageX,e.pageY]; //relative mouse position if(this.rpos && this.rpos[0] == this.pos[0] && this.rpos[1] == this.pos[1]) return false; this.rpos = [this.pos[0],this.pos[1]]; //absolute mouse position if(o.pp) { //If we have a positioned parent, use a relative position this.pos[0] -= o.po.left; this.pos[1] -= o.po.top; } if( (Math.abs(this.rpos[0]-this.opos[0]) > o.preventionDistance || Math.abs(this.rpos[1]-this.opos[1]) > o.preventionDistance) && this.init == false) //If position is more than x pixels from original position, start dragging this.start.apply(this,[e]); else { if(this.init == false) return false; } if(o._drag) o._drag.apply(this.element, [this.helper, this.pos, o.cursorAt, this, e]); return false; } }); var num = function(el, prop) { return parseInt($.css(el.jquery?el[0]:el,prop))||0; }; function outerWidth(el) { var $el = $(el), ow = $el.width(); for (var i = 0, props = ['borderLeftWidth', 'paddingLeft', 'paddingRight', 'borderRightWidth']; i < props.length; i++) ow += num($el, props[i]); return ow; } function outerHeight(el) { var $el = $(el), oh = $el.width(); for (var i = 0, props = ['borderTopWidth', 'paddingTop', 'paddingBottom', 'borderBottomWidth']; i < props.length; i++) oh += num($el, props[i]); return oh; } })($);
JavaScript
/*----------------------------------------\ | Cross Browser Tree Widget 1.1 | |-----------------------------------------| | Created by Emil A. Eklund (eae@eae.net) | | For WebFX (http://webfx.eae.net/) | |-----------------------------------------| | This script is provided as is without | | any warranty whatsoever. It may be used | | free of charge for non commerical sites | | For commerical use contact the author | | of this script for further details. | |-----------------------------------------| | Created 2000-12-11 | Updated 2001-09-06 | \----------------------------------------*/ var webFXTreeConfig = { rootIcon : 'media/images/empty.png', openRootIcon : 'media/images/empty.png', folderIcon : 'media/images/empty.png', openFolderIcon : 'media/images/empty.png', fileIcon : 'media/images/empty.png', iIcon : 'media/images/I.png', lIcon : 'media/images/L.png', lMinusIcon : 'media/images/Lminus.png', lPlusIcon : 'media/images/Lplus.png', tIcon : 'media/images/T.png', tMinusIcon : 'media/images/Tminus.png', tPlusIcon : 'media/images/Tplus.png', blankIcon : 'media/images/blank.png', defaultText : 'Tree Item', defaultAction : 'javascript:void(0);', defaultTarget : 'right', defaultBehavior : 'classic' }; var webFXTreeHandler = { idCounter : 0, idPrefix : "webfx-tree-object-", all : {}, behavior : null, selected : null, getId : function() { return this.idPrefix + this.idCounter++; }, toggle : function (oItem) { this.all[oItem.id.replace('-plus','')].toggle(); }, select : function (oItem) { this.all[oItem.id.replace('-icon','')].select(); }, focus : function (oItem) { this.all[oItem.id.replace('-anchor','')].focus(); }, blur : function (oItem) { this.all[oItem.id.replace('-anchor','')].blur(); }, keydown : function (oItem) { return this.all[oItem.id].keydown(window.event.keyCode); }, cookies : new WebFXCookie() }; /* * WebFXCookie class */ function WebFXCookie() { if (document.cookie.length) { this.cookies = ' ' + document.cookie; } } WebFXCookie.prototype.setCookie = function (key, value) { document.cookie = key + "=" + escape(value); } WebFXCookie.prototype.getCookie = function (key) { if (this.cookies) { var start = this.cookies.indexOf(' ' + key + '='); if (start == -1) { return null; } var end = this.cookies.indexOf(";", start); if (end == -1) { end = this.cookies.length; } end -= start; var cookie = this.cookies.substr(start,end); return unescape(cookie.substr(cookie.indexOf('=') + 1, cookie.length - cookie.indexOf('=') + 1)); } else { return null; } } /* * WebFXTreeAbstractNode class */ function WebFXTreeAbstractNode(sText, sAction, sTarget) { this.childNodes = []; this.id = webFXTreeHandler.getId(); this.text = sText || webFXTreeConfig.defaultText; this.action = sAction || webFXTreeConfig.defaultAction; this.targetWindow = sTarget || webFXTreeConfig.defaultTarget; this._last = false; webFXTreeHandler.all[this.id] = this; } WebFXTreeAbstractNode.prototype.add = function (node) { node.parentNode = this; this.childNodes[this.childNodes.length] = node; var root = this; if (this.childNodes.length >=2) { this.childNodes[this.childNodes.length -2]._last = false; } while (root.parentNode) { root = root.parentNode; } if (root.rendered) { if (this.childNodes.length >= 2) { document.getElementById(this.childNodes[this.childNodes.length -2].id + '-plus').src = ((this.childNodes[this.childNodes.length -2].folder)?webFXTreeConfig.tMinusIcon:webFXTreeConfig.tIcon); if (this.childNodes[this.childNodes.length -2].folder) { this.childNodes[this.childNodes.length -2].plusIcon = webFXTreeConfig.tPlusIcon; this.childNodes[this.childNodes.length -2].minusIcon = webFXTreeConfig.tMinusIcon; } this.childNodes[this.childNodes.length -2]._last = false; } this._last = true; var foo = this; while (foo.parentNode) { for (var i = 0; i < foo.parentNode.childNodes.length; i++) { if (foo.id == foo.parentNode.childNodes[i].id) { break; } } if (++i == foo.parentNode.childNodes.length) { foo.parentNode._last = true; } else { foo.parentNode._last = false; } foo = foo.parentNode; } document.getElementById(this.id + '-cont').insertAdjacentHTML("beforeEnd", node.toString()); if ((!this.folder) && (!this.openIcon)) { this.icon = webFXTreeConfig.folderIcon; this.openIcon = webFXTreeConfig.openFolderIcon; } this.folder = true; this.indent(); this.expand(); } return node; } WebFXTreeAbstractNode.prototype.toggle = function() { if (this.folder) { if (this.open) { this.collapse(); } else { this.expand(); } } } WebFXTreeAbstractNode.prototype.select = function() { document.getElementById(this.id + '-anchor').focus(); } WebFXTreeAbstractNode.prototype.focus = function() { webFXTreeHandler.selected = this; if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.openIcon; } document.getElementById(this.id + '-anchor').style.backgroundColor = 'highlight'; document.getElementById(this.id + '-anchor').style.color = 'highlighttext'; document.getElementById(this.id + '-anchor').focus(); } WebFXTreeAbstractNode.prototype.blur = function() { if ((this.openIcon) && (webFXTreeHandler.behavior != 'classic')) { document.getElementById(this.id + '-icon').src = this.icon; } document.getElementById(this.id + '-anchor').style.backgroundColor = 'transparent'; document.getElementById(this.id + '-anchor').style.color = 'menutext'; } WebFXTreeAbstractNode.prototype.doExpand = function() { if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.openIcon; } if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'block'; } this.open = true; webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '1'); } WebFXTreeAbstractNode.prototype.doCollapse = function() { if (webFXTreeHandler.behavior == 'classic') { document.getElementById(this.id + '-icon').src = this.icon; } if (this.childNodes.length) { document.getElementById(this.id + '-cont').style.display = 'none'; } this.open = false; webFXTreeHandler.cookies.setCookie(this.id.substr(18,this.id.length - 18), '0'); } WebFXTreeAbstractNode.prototype.expandAll = function() { this.expandChildren(); if ((this.folder) && (!this.open)) { this.expand(); } } WebFXTreeAbstractNode.prototype.expandChildren = function() { for (var i = 0; i < this.childNodes.length; i++) { this.childNodes[i].expandAll(); } } WebFXTreeAbstractNode.prototype.collapseAll = function() { if ((this.folder) && (this.open)) { this.collapse(); } this.collapseChildren(); } WebFXTreeAbstractNode.prototype.collapseChildren = function() { for (var i = 0; i < this.childNodes.length; i++) { this.childNodes[i].collapseAll(); } } WebFXTreeAbstractNode.prototype.indent = function(lvl, del, last, level) { /* * Since we only want to modify items one level below ourself, * and since the rightmost indentation position is occupied by * the plus icon we set this to -2 */ if (lvl == null) { lvl = -2; } var state = 0; for (var i = this.childNodes.length - 1; i >= 0 ; i--) { state = this.childNodes[i].indent(lvl + 1, del, last, level); if (state) { return; } } if (del) { if (level >= this._level) { if (this.folder) { document.getElementById(this.id + '-plus').src = (this.open)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.lPlusIcon; this.plusIcon = webFXTreeConfig.lPlusIcon; this.minusIcon = webFXTreeConfig.lMinusIcon; } else { document.getElementById(this.id + '-plus').src = webFXTreeConfig.lIcon; } return 1; } } var foo = document.getElementById(this.id + '-indent-' + lvl); if (foo) { if ((del) && (last)) { foo._last = true; } if (foo._last) { foo.src = webFXTreeConfig.blankIcon; } else { foo.src = webFXTreeConfig.iIcon; } } return 0; } /* * WebFXTree class */ function WebFXTree(sText, sAction, sBehavior, sIcon, sOpenIcon) { this.base = WebFXTreeAbstractNode; this.base(sText, sAction); this.icon = sIcon || webFXTreeConfig.rootIcon; this.openIcon = sOpenIcon || webFXTreeConfig.openRootIcon; /* Defaults to open */ this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '0')?false:true; this.folder = true; this.rendered = false; if (!webFXTreeHandler.behavior) { webFXTreeHandler.behavior = sBehavior || webFXTreeConfig.defaultBehavior; } this.targetWindow = 'right'; } WebFXTree.prototype = new WebFXTreeAbstractNode; WebFXTree.prototype.setBehavior = function (sBehavior) { webFXTreeHandler.behavior = sBehavior; }; WebFXTree.prototype.getBehavior = function (sBehavior) { return webFXTreeHandler.behavior; }; WebFXTree.prototype.getSelected = function() { if (webFXTreeHandler.selected) { return webFXTreeHandler.selected; } else { return null; } } WebFXTree.prototype.remove = function() { } WebFXTree.prototype.expand = function() { this.doExpand(); } WebFXTree.prototype.collapse = function() { this.focus(); this.doCollapse(); } WebFXTree.prototype.getFirst = function() { return null; } WebFXTree.prototype.getLast = function() { return null; } WebFXTree.prototype.getNextSibling = function() { return null; } WebFXTree.prototype.getPreviousSibling = function() { return null; } WebFXTree.prototype.keydown = function(key) { if (key == 39) { this.expand(); return false; } if (key == 37) { this.collapse(); return false; } if ((key == 40) && (this.open)) { this.childNodes[0].select(); return false; } return true; } WebFXTree.prototype.toString = function() { var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this)\">"; str += "<img id=\"" + this.id + "-icon\" class=\"webfx-tree-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\"><a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" target=\"" + this.targetWindow + "\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\">" + this.text + "</a></div>"; str += "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; for (var i = 0; i < this.childNodes.length; i++) { str += this.childNodes[i].toString(i, this.childNodes.length); } str += "</div>"; this.rendered = true; return str; }; /* * WebFXTreeItem class */ function WebFXTreeItem(sText, sAction, eParent, sIcon, sOpenIcon) { this.base = WebFXTreeAbstractNode; this.base(sText, sAction); /* Defaults to close */ this.open = (webFXTreeHandler.cookies.getCookie(this.id.substr(18,this.id.length - 18)) == '1')?true:false; if (eParent) { eParent.add(this); } if (sIcon) { this.icon = sIcon; } if (sOpenIcon) { this.openIcon = sOpenIcon; } } WebFXTreeItem.prototype = new WebFXTreeAbstractNode; WebFXTreeItem.prototype.remove = function() { var parentNode = this.parentNode; var prevSibling = this.getPreviousSibling(true); var nextSibling = this.getNextSibling(true); var folder = this.parentNode.folder; var last = ((nextSibling) && (nextSibling.parentNode) && (nextSibling.parentNode.id == parentNode.id))?false:true; this.getPreviousSibling().focus(); this._remove(); if (parentNode.childNodes.length == 0) { parentNode.folder = false; parentNode.open = false; } if (last) { if (parentNode.id == prevSibling.id) { document.getElementById(parentNode.id + '-icon').src = webFXTreeConfig.fileIcon; } else { } } if ((!prevSibling.parentNode) || (prevSibling.parentNode != parentNode)) { parentNode.indent(null, true, last, this._level); } if (document.getElementById(prevSibling.id + '-plus')) { if (nextSibling) { if ((parentNode == prevSibling) && (parentNode.getNextSibling)) { document.getElementById(prevSibling.id + '-plus').src = webFXTreeConfig.tIcon; } else if (nextSibling.parentNode != prevSibling) { document.getElementById(prevSibling.id + '-plus').src = webFXTreeConfig.lIcon; } } else { document.getElementById(prevSibling.id + '-plus').src = webFXTreeConfig.lIcon; } } } WebFXTreeItem.prototype._remove = function() { for (var i = this.childNodes.length - 1; i >= 0; i--) { this.childNodes[i]._remove(); } for (var i = 0; i < this.parentNode.childNodes.length; i++) { if (this.id == this.parentNode.childNodes[i].id) { for (var j = i; j < this.parentNode.childNodes.length; j++) { this.parentNode.childNodes[i] = this.parentNode.childNodes[i+1] } this.parentNode.childNodes.length = this.parentNode.childNodes.length - 1; if (i + 1 == this.parentNode.childNodes.length) { this.parentNode._last = true; } } } webFXTreeHandler.all[this.id] = null; if (document.getElementById(this.id)) { document.getElementById(this.id).innerHTML = ""; document.getElementById(this.id).removeNode(); } } WebFXTreeItem.prototype.expand = function() { this.doExpand(); document.getElementById(this.id + '-plus').src = this.minusIcon; } WebFXTreeItem.prototype.collapse = function() { this.focus(); this.doCollapse(); document.getElementById(this.id + '-plus').src = this.plusIcon; } WebFXTreeItem.prototype.getFirst = function() { return this.childNodes[0]; } WebFXTreeItem.prototype.getLast = function() { if (this.childNodes[this.childNodes.length - 1].open) { return this.childNodes[this.childNodes.length - 1].getLast(); } else { return this.childNodes[this.childNodes.length - 1]; } } WebFXTreeItem.prototype.getNextSibling = function() { for (var i = 0; i < this.parentNode.childNodes.length; i++) { if (this == this.parentNode.childNodes[i]) { break; } } if (++i == this.parentNode.childNodes.length) { return this.parentNode.getNextSibling(); } else { return this.parentNode.childNodes[i]; } } WebFXTreeItem.prototype.getPreviousSibling = function(b) { for (var i = 0; i < this.parentNode.childNodes.length; i++) { if (this == this.parentNode.childNodes[i]) { break; } } if (i == 0) { return this.parentNode; } else { if ((this.parentNode.childNodes[--i].open) || (b && this.parentNode.childNodes[i].folder)) { return this.parentNode.childNodes[i].getLast(); } else { return this.parentNode.childNodes[i]; } } } WebFXTreeItem.prototype.keydown = function(key) { if ((key == 39) && (this.folder)) { if (!this.open) { this.expand(); return false; } else { this.getFirst().select(); return false; } } else if (key == 37) { if (this.open) { this.collapse(); return false; } else { this.parentNode.select(); return false; } } else if (key == 40) { if (this.open) { this.getFirst().select(); return false; } else { var sib = this.getNextSibling(); if (sib) { sib.select(); return false; } } } else if (key == 38) { this.getPreviousSibling().select(); return false; } return true; } WebFXTreeItem.prototype.toString = function (nItem, nItemCount) { var foo = this.parentNode; var indent = ''; if (nItem + 1 == nItemCount) { this.parentNode._last = true; } var i = 0; while (foo.parentNode) { foo = foo.parentNode; indent = "<img id=\"" + this.id + "-indent-" + i + "\" src=\"" + ((foo._last)?webFXTreeConfig.blankIcon:webFXTreeConfig.iIcon) + "\">" + indent; i++; } this._level = i; if (this.childNodes.length) { this.folder = 1; } else { this.open = false; } if ((this.folder) || (webFXTreeHandler.behavior != 'classic')) { if (!this.icon) { this.icon = webFXTreeConfig.folderIcon; } if (!this.openIcon) { this.openIcon = webFXTreeConfig.openFolderIcon; } } else if (!this.icon) { this.icon = webFXTreeConfig.fileIcon; } var label = this.text; label = label.replace('<', '<'); label = label.replace('>', '>'); var str = "<div id=\"" + this.id + "\" ondblclick=\"webFXTreeHandler.toggle(this);\" class=\"webfx-tree-item\" onkeydown=\"return webFXTreeHandler.keydown(this)\">"; str += indent; str += "<img id=\"" + this.id + "-plus\" src=\"" + ((this.folder)?((this.open)?((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon):((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon)):((this.parentNode._last)?webFXTreeConfig.lIcon:webFXTreeConfig.tIcon)) + "\" onclick=\"webFXTreeHandler.toggle(this);\">" str += "<img id=\"" + this.id + "-icon\" src=\"" + ((webFXTreeHandler.behavior == 'classic' && this.open)?this.openIcon:this.icon) + "\" onclick=\"webFXTreeHandler.select(this);\"><a href=\"" + this.action + "\" id=\"" + this.id + "-anchor\" target=\"" + this.targetWindow + "\" onfocus=\"webFXTreeHandler.focus(this);\" onblur=\"webFXTreeHandler.blur(this);\">" + label + "</a></div>"; str += "<div id=\"" + this.id + "-cont\" class=\"webfx-tree-container\" style=\"display: " + ((this.open)?'block':'none') + ";\">"; for (var i = 0; i < this.childNodes.length; i++) { str += this.childNodes[i].toString(i,this.childNodes.length); } str += "</div>"; this.plusIcon = ((this.parentNode._last)?webFXTreeConfig.lPlusIcon:webFXTreeConfig.tPlusIcon); this.minusIcon = ((this.parentNode._last)?webFXTreeConfig.lMinusIcon:webFXTreeConfig.tMinusIcon); return str; }
JavaScript
/** * JavaScript routines for Krumo * * @version $Id: krumo.js,v 1.1.2.2 2008/06/03 20:36:03 weitzman Exp $ * @link http://sourceforge.net/projects/krumo */ ///////////////////////////////////////////////////////////////////////////// /** * Krumo JS Class */ function krumo() { } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Add a CSS class to an HTML element * * @param HtmlElement el * @param string className * @return void */ krumo.reclass = function(el, className) { if (el.className.indexOf(className) < 0) { el.className += (' ' + className); } } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Remove a CSS class to an HTML element * * @param HtmlElement el * @param string className * @return void */ krumo.unclass = function(el, className) { if (el.className.indexOf(className) > -1) { el.className = el.className.replace(className, ''); } } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Toggle the nodes connected to an HTML element * * @param HtmlElement el * @return void */ krumo.toggle = function(el) { var ul = el.parentNode.getElementsByTagName('ul'); for (var i=0; i<ul.length; i++) { if (ul[i].parentNode.parentNode == el.parentNode) { ul[i].parentNode.style.display = (ul[i].parentNode.style.display == 'none') ? 'block' : 'none'; } } // toggle class // if (ul[0].parentNode.style.display == 'block') { krumo.reclass(el, 'krumo-opened'); } else { krumo.unclass(el, 'krumo-opened'); } } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Hover over an HTML element * * @param HtmlElement el * @return void */ krumo.over = function(el) { krumo.reclass(el, 'krumo-hover'); } // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- /** * Hover out an HTML element * * @param HtmlElement el * @return void */ krumo.out = function(el) { krumo.unclass(el, 'krumo-hover'); } /////////////////////////////////////////////////////////////////////////////
JavaScript
function checkAll(checkbox){ var elems = document.getElementsByName(checkbox.name); i=0; while(el=elems[i++]){ el.checked = checkbox.checked; } } function editChecked(type,name,id){ if(document.getElementById("checkbox_"+type+"_"+id).checked){ var elems = document.getElementsByName("checkbox_"+type); i=0; while(el=elems[i++]){ if (el.checked) { var tempArray = el.id.split('_'); var checkedId = tempArray.pop(); var target = document.getElementById(name+checkedId); if (target){ target.value = document.getElementById(name+id).value; if (target.id.match("approval_status")) approvalEnable(target.value,checkedId); if (target.id.match("rejection_reason")) rejectionEnable(target.value,checkedId); } } } } }
JavaScript
/** * Show/hide custom format sections on the date-time settings page. */ Drupal.behaviors.dateDateTime = function(context) { // Show/hide custom format depending on the select's value. $('select.date-format:not(.date-time-processed)', context).change(function() { $(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"](); }); // Attach keyup handler to custom format inputs. $('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() { var input = $(this); var url = Drupal.settings.dateDateTime.lookup +(Drupal.settings.dateDateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val()); $.getJSON(url, function(data) { $("div.description span", input.parent()).html(data); }); }); // Trigger the event handler to show the form input if necessary. $('select.date-format', context).trigger('change'); };
JavaScript
// $Id: date_popup.js,v 1.1.2.3 2009/01/12 17:23:25 karens Exp $ /** * Attaches the calendar behavior to all required fields */ Drupal.behaviors.date_popup = function (context) { for (var id in Drupal.settings.datePopup) { $('#'+ id).bind('focus', Drupal.settings.datePopup[id], function(e) { if (!$(this).hasClass('date-popup-init')) { var datePopup = e.data; // Explicitely filter the methods we accept. switch (datePopup.func) { case 'datepicker': $(this) .datepicker(datePopup.settings) .addClass('date-popup-init') .focus(); break; case 'timeEntry': $(this) .timeEntry(datePopup.settings) .addClass('date-popup-init') .focus(); break; } } }); } };
JavaScript
/* jQuery Calendar v2.7 Written by Marc Grabanski (m@marcgrabanski.com) and enhanced by Keith Wood (kbwood@iprimus.com.au). Copyright (c) 2007 Marc Grabanski (http://marcgrabanski.com/code/jquery-calendar) Dual licensed under the GPL (http://www.gnu.org/licenses/gpl-3.0.txt) and CC (http://creativecommons.org/licenses/by/3.0/) licenses. "Share or Remix it but please Attribute the authors." Date: 09-03-2007 */ /* PopUp Calendar manager. Use the singleton instance of this class, popUpCal, to interact with the calendar. Settings for (groups of) calendars are maintained in an instance object (PopUpCalInstance), allowing multiple different settings on the same page. */ function PopUpCal() { this._nextId = 0; // Next ID for a calendar instance this._inst = []; // List of instances indexed by ID this._curInst = null; // The current instance in use this._disabledInputs = []; // List of calendar inputs that have been disabled this._popUpShowing = false; // True if the popup calendar is showing , false if not this._inDialog = false; // True if showing within a "dialog", false if not this.regional = []; // Available regional settings, indexed by language code this.regional[''] = { // Default regional settings clearText: 'Clear', // Display text for clear link closeText: 'Close', // Display text for close link prevText: '&lt;Prev', // Display text for previous month link nextText: 'Next&gt;', // Display text for next month link currentText: 'Today', // Display text for current month link dayNames: ['Su','Mo','Tu','We','Th','Fr','Sa'], // Names of days starting at Sunday monthNames: ['January','February','March','April','May','June', 'July','August','September','October','November','December'], // Names of months dateFormat: 'DMY/' // First three are day, month, year in the required order, // fourth (optional) is the separator, e.g. US would be 'MDY/', ISO would be 'YMD-' }; this._defaults = { // Global defaults for all the calendar instances autoPopUp: 'focus', // 'focus' for popup on focus, // 'button' for trigger button, or 'both' for either defaultDate: null, // Used when field is blank: actual date, // +/-number for offset from today, null for today appendText: '', // Display text following the input box, e.g. showing the format buttonText: '...', // Text for trigger button buttonImage: '', // URL for trigger button image buttonImageOnly: false, // True if the image appears alone, false if it appears on a button closeAtTop: true, // True to have the clear/close at the top, // false to have them at the bottom hideIfNoPrevNext: false, // True to hide next/previous month links // if not applicable, false to just disable them changeMonth: true, // True if month can be selected directly, false if only prev/next changeYear: true, // True if year can be selected directly, false if only prev/next yearRange: '-10:+10', // Range of years to display in drop-down, // either relative to current year (-nn:+nn) or absolute (nnnn:nnnn) firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ... changeFirstDay: true, // True to click on day name to change, false to remain as set showOtherMonths: false, // True to show dates in other months, false to leave blank minDate: null, // The earliest selectable date, or null for no limit maxDate: null, // The latest selectable date, or null for no limit speed: 'medium', // Speed of display/closure customDate: null, // Function that takes a date and returns an array with // [0] = true if selectable, false if not, // [1] = custom CSS class name(s) or '', e.g. popUpCal.noWeekends fieldSettings: null, // Function that takes an input field and // returns a set of custom settings for the calendar onSelect: null // Define a callback function when a date is selected }; $.extend(this._defaults, this.regional['']); this._calendarDiv = $('<div id="calendar_div"></div>'); $(document.body).append(this._calendarDiv); $(document.body).mousedown(this._checkExternalClick); } $.extend(PopUpCal.prototype, { /* Class name added to elements to indicate already configured with a calendar. */ markerClassName: 'hasCalendar', /* Register a new calendar instance - with custom settings. */ _register: function(inst) { var id = this._nextId++; this._inst[id] = inst; return id; }, /* Retrieve a particular calendar instance based on its ID. */ _getInst: function(id) { return this._inst[id] || id; }, /* Override the default settings for all instances of the calendar. @param settings object - the new settings to use as defaults (anonymous object) @return void */ setDefaults: function(settings) { extendRemove(this._defaults, settings || {}); }, /* Handle keystrokes. */ _doKeyDown: function(e) { var inst = popUpCal._getInst(this._calId); if (popUpCal._popUpShowing) { switch (e.keyCode) { case 9: popUpCal.hideCalendar(inst, ''); break; // hide on tab out case 13: popUpCal._selectDate(inst); break; // select the value on enter case 27: popUpCal.hideCalendar(inst, inst._get('speed')); break; // hide on escape case 33: popUpCal._adjustDate(inst, -1, (e.ctrlKey ? 'Y' : 'M')); break; // previous month/year on page up/+ ctrl case 34: popUpCal._adjustDate(inst, +1, (e.ctrlKey ? 'Y' : 'M')); break; // next month/year on page down/+ ctrl case 35: if (e.ctrlKey) popUpCal._clearDate(inst); break; // clear on ctrl+end case 36: if (e.ctrlKey) popUpCal._gotoToday(inst); break; // current on ctrl+home case 37: if (e.ctrlKey) popUpCal._adjustDate(inst, -1, 'D'); break; // -1 day on ctrl+left case 38: if (e.ctrlKey) popUpCal._adjustDate(inst, -7, 'D'); break; // -1 week on ctrl+up case 39: if (e.ctrlKey) popUpCal._adjustDate(inst, +1, 'D'); break; // +1 day on ctrl+right case 40: if (e.ctrlKey) popUpCal._adjustDate(inst, +7, 'D'); break; // +1 week on ctrl+down } } else if (e.keyCode == 36 && e.ctrlKey) { // display the calendar on ctrl+home popUpCal.showFor(this); } }, /* Filter entered characters. */ _doKeyPress: function(e) { var inst = popUpCal._getInst(this._calId); var chr = String.fromCharCode(e.charCode == undefined ? e.keyCode : e.charCode); return (chr < ' ' || chr == inst._get('dateFormat').charAt(3) || (chr >= '0' && chr <= '9')); // only allow numbers and separator }, /* Attach the calendar to an input field. */ _connectCalendar: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } var appendText = inst._get('appendText'); if (appendText) { input.after('<span class="calendar_append">' + appendText + '</span>'); } var autoPopUp = inst._get('autoPopUp'); if (autoPopUp == 'focus' || autoPopUp == 'both') { // pop-up calendar when in the marked field input.focus(this.showFor); } if (autoPopUp == 'button' || autoPopUp == 'both') { // pop-up calendar when button clicked var buttonText = inst._get('buttonText'); var buttonImage = inst._get('buttonImage'); var buttonImageOnly = inst._get('buttonImageOnly'); var trigger = $(buttonImageOnly ? '<img class="calendar_trigger" src="' + buttonImage + '" alt="' + buttonText + '" title="' + buttonText + '"/>' : '<button type="button" class="calendar_trigger">' + (buttonImage != '' ? '<img src="' + buttonImage + '" alt="' + buttonText + '" title="' + buttonText + '"/>' : buttonText) + '</button>'); input.wrap('<span class="calendar_wrap"></span>').after(trigger); trigger.click(this.showFor); } input.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress); input[0]._calId = inst._id; }, /* Attach an inline calendar to a div. */ _inlineCalendar: function(target, inst) { var input = $(target); if (this._hasClass(input, this.markerClassName)) { return; } input.addClass(this.markerClassName).append(inst._calendarDiv); input[0]._calId = inst._id; }, /* Does this element have a particular class? */ _hasClass: function(element, className) { var classes = element.attr('class'); return (classes && classes.indexOf(className) > -1); }, /* Pop-up the calendar in a "dialog" box. @param dateText string - the initial date to display (in the current format) @param onSelect function - the function(dateText) to call when a date is selected @param settings object - update the dialog calendar instance's settings (anonymous object) @param pos int[2] - coordinates for the dialog's position within the screen leave empty for default (screen centre) @return void */ dialogCalendar: function(dateText, onSelect, settings, pos) { var inst = this._dialogInst; // internal instance if (!inst) { inst = this._dialogInst = new PopUpCalInstance({}, false); this._dialogInput = $('<input type="text" size="1" style="position: absolute; top: -100px;"/>'); this._dialogInput.keydown(this._doKeyDown); $('body').append(this._dialogInput); this._dialogInput[0]._calId = inst._id; } extendRemove(inst._settings, settings || {}); this._dialogInput.val(dateText); /* Cross Browser Positioning */ if (self.innerHeight) { // all except Explorer windowWidth = self.innerWidth; windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // other Explorers windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } this._pos = pos || // should use actual width/height below [(windowWidth / 2) - 100, (windowHeight / 2) - 100]; // move input on screen for focus, but hidden behind dialog this._dialogInput.css('left', this._pos[0] + 'px').css('top', this._pos[1] + 'px'); inst._settings.onSelect = onSelect; this._inDialog = true; this._calendarDiv.addClass('calendar_dialog'); this.showFor(this._dialogInput[0]); if ($.blockUI) { $.blockUI(this._calendarDiv); } }, /* Enable the input field(s) for entry. @param inputs element/object - single input field or jQuery collection of input fields @return void */ enableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = false; $('../button.calendar_trigger', this).each(function() { this.disabled = false; }); $('../img.calendar_trigger', this).css({opacity:'1.0',cursor:''}); var $this = this; popUpCal._disabledInputs = $.map(popUpCal._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry }); }, /* Disable the input field(s) from entry. @param inputs element/object - single input field or jQuery collection of input fields @return void */ disableFor: function(inputs) { inputs = (inputs.jquery ? inputs : $(inputs)); inputs.each(function() { this.disabled = true; $('../button.calendar_trigger', this).each(function() { this.disabled = true; }); $('../img.calendar_trigger', this).css({opacity:'0.5',cursor:'default'}); var $this = this; popUpCal._disabledInputs = $.map(popUpCal._disabledInputs, function(value) { return (value == $this ? null : value); }); // delete entry popUpCal._disabledInputs[popUpCal._disabledInputs.length] = this; }); }, /* Update the settings for a calendar attached to an input field or division. @param control element - the input field or div/span attached to the calendar or string - the ID or other jQuery selector of the input field @param settings object - the new settings to update @return void */ reconfigureFor: function(control, settings) { control = (typeof control == 'string' ? $(control)[0] : control); var inst = this._getInst(control._calId); if (inst) { extendRemove(inst._settings, settings || {}); this._updateCalendar(inst); } }, /* Set the date for a calendar attached to an input field or division. @param control element - the input field or div/span attached to the calendar @param date Date - the new date @return void */ setDateFor: function(control, date) { var inst = this._getInst(control._calId); if (inst) { inst._setDate(date); } }, /* Retrieve the date for a calendar attached to an input field or division. @param control element - the input field or div/span attached to the calendar @return Date - the current date */ getDateFor: function(control) { var inst = this._getInst(control._calId); return (inst ? inst._getDate() : null); }, /* Pop-up the calendar for a given input field. @param target element - the input field attached to the calendar @return void */ showFor: function(target) { var input = (target.nodeName && target.nodeName.toLowerCase() == 'input' ? target : this); if (input.nodeName.toLowerCase() != 'input') { // find from button/image trigger input = $('input', input.parentNode)[0]; } if (popUpCal._lastInput == input) { // already here return; } for (var i = 0; i < popUpCal._disabledInputs.length; i++) { // check not disabled if (popUpCal._disabledInputs[i] == input) { return; } } var inst = popUpCal._getInst(input._calId); var fieldSettings = inst._get('fieldSettings'); extendRemove(inst._settings, (fieldSettings ? fieldSettings(input) : {})); popUpCal.hideCalendar(inst, ''); popUpCal._lastInput = input; inst._setDateFromField(input); if (popUpCal._inDialog) { // hide cursor input.value = ''; } if (!popUpCal._pos) { // position below input popUpCal._pos = popUpCal._findPos(input); popUpCal._pos[1] += input.offsetHeight; } inst._calendarDiv.css('position', (popUpCal._inDialog && $.blockUI ? 'static' : 'absolute')). css('left', popUpCal._pos[0] + 'px').css('top', popUpCal._pos[1] + 'px'); popUpCal._pos = null; popUpCal._showCalendar(inst); }, /* Construct and display the calendar. */ _showCalendar: function(id) { var inst = this._getInst(id); popUpCal._updateCalendar(inst); if (!inst._inline) { var speed = inst._get('speed'); inst._calendarDiv.show(speed, function() { popUpCal._popUpShowing = true; popUpCal._afterShow(inst); }); if (speed == '') { popUpCal._popUpShowing = true; popUpCal._afterShow(inst); } if (inst._input[0].type != 'hidden') { inst._input[0].focus(); } this._curInst = inst; } }, /* Generate the calendar content. */ _updateCalendar: function(inst) { inst._calendarDiv.empty().append(inst._generateCalendar()); if (inst._input && inst._input[0].type != 'hidden') { inst._input[0].focus(); } }, /* Tidy up after displaying the calendar. */ _afterShow: function(inst) { if ($.browser.msie) { // fix IE < 7 select problems $('#calendar_cover').css({width: inst._calendarDiv[0].offsetWidth + 4, height: inst._calendarDiv[0].offsetHeight + 4}); } // re-position on screen if necessary var calDiv = inst._calendarDiv[0]; var pos = popUpCal._findPos(inst._input[0]); // Get browser width and X value (IE6+, FF, Safari, Opera) if( typeof( window.innerWidth ) == 'number' ) { browserWidth = window.innerWidth; } else { browserWidth = document.documentElement.clientWidth; } if ( document.documentElement && (document.documentElement.scrollLeft)) { browserX = document.documentElement.scrollLeft; } else { browserX = document.body.scrollLeft; } // Reposition calendar if outside the browser window. if ((calDiv.offsetLeft + calDiv.offsetWidth) > (browserWidth + browserX) ) { inst._calendarDiv.css('left', (pos[0] + inst._input[0].offsetWidth - calDiv.offsetWidth) + 'px'); } // Get browser height and Y value (IE6+, FF, Safari, Opera) if( typeof( window.innerHeight ) == 'number' ) { browserHeight = window.innerHeight; } else { browserHeight = document.documentElement.clientHeight; } if ( document.documentElement && (document.documentElement.scrollTop)) { browserTopY = document.documentElement.scrollTop; } else { browserTopY = document.body.scrollTop; } // Reposition calendar if outside the browser window. if ((calDiv.offsetTop + calDiv.offsetHeight) > (browserTopY + browserHeight) ) { inst._calendarDiv.css('top', (pos[1] - calDiv.offsetHeight) + 'px'); } }, /* Hide the calendar from view. @param id string/object - the ID of the current calendar instance, or the instance itself @param speed string - the speed at which to close the calendar @return void */ hideCalendar: function(id, speed) { var inst = this._getInst(id); if (popUpCal._popUpShowing) { speed = (speed != null ? speed : inst._get('speed')); inst._calendarDiv.hide(speed, function() { popUpCal._tidyDialog(inst); }); if (speed == '') { popUpCal._tidyDialog(inst); } popUpCal._popUpShowing = false; popUpCal._lastInput = null; inst._settings.prompt = null; if (popUpCal._inDialog) { popUpCal._dialogInput.css('position', 'absolute'). css('left', '0px').css('top', '-100px'); if ($.blockUI) { $.unblockUI(); $('body').append(this._calendarDiv); } } popUpCal._inDialog = false; } popUpCal._curInst = null; }, /* Tidy up after a dialog display. */ _tidyDialog: function(inst) { inst._calendarDiv.removeClass('calendar_dialog'); $('.calendar_prompt', inst._calendarDiv).remove(); }, /* Close calendar if clicked elsewhere. */ _checkExternalClick: function(event) { if (!popUpCal._curInst) { return; } var target = $(event.target); if( (target.parents("#calendar_div").length == 0) && (target.attr('class') != 'calendar_trigger') && popUpCal._popUpShowing && !(popUpCal._inDialog && $.blockUI) ) { popUpCal.hideCalendar(popUpCal._curInst, ''); } }, /* Adjust one of the date sub-fields. */ _adjustDate: function(id, offset, period) { var inst = this._getInst(id); inst._adjustDate(offset, period); this._updateCalendar(inst); }, /* Action for current link. */ _gotoToday: function(id) { var date = new Date(); var inst = this._getInst(id); inst._selectedDay = date.getDate(); inst._selectedMonth = date.getMonth(); inst._selectedYear = date.getFullYear(); this._adjustDate(inst); }, /* Action for selecting a new month/year. */ _selectMonthYear: function(id, select, period) { var inst = this._getInst(id); inst._selectingMonthYear = false; inst[period == 'M' ? '_selectedMonth' : '_selectedYear'] = select.options[select.selectedIndex].value - 0; this._adjustDate(inst); }, /* Restore input focus after not changing month/year. */ _clickMonthYear: function(id) { var inst = this._getInst(id); if (inst._input && inst._selectingMonthYear && !$.browser.msie) { inst._input[0].focus(); } inst._selectingMonthYear = !inst._selectingMonthYear; }, /* Action for changing the first week day. */ _changeFirstDay: function(id, a) { var inst = this._getInst(id); var dayNames = inst._get('dayNames'); var value = a.firstChild.nodeValue; for (var i = 0; i < 7; i++) { if (dayNames[i] == value) { inst._settings.firstDay = i; break; } } this._updateCalendar(inst); }, /* Action for selecting a day. */ _selectDay: function(id, td) { var inst = this._getInst(id); inst._selectedDay = $("a", td).html(); this._selectDate(id); }, /* Erase the input field and hide the calendar. */ _clearDate: function(id) { this._selectDate(id, ''); }, /* Update the input field with the selected date. */ _selectDate: function(id, dateStr) { var inst = this._getInst(id); dateStr = (dateStr != null ? dateStr : inst._formatDate()); if (inst._input) { inst._input.val(dateStr); } var onSelect = inst._get('onSelect'); if (onSelect) { onSelect(dateStr, inst); // trigger custom callback } else { inst._input.trigger('change'); // fire the change event } if (inst._inline) { this._updateCalendar(inst); } else { this.hideCalendar(inst, inst._get('speed')); } }, /* Set as customDate function to prevent selection of weekends. @param date Date - the date to customise @return [boolean, string] - is this date selectable?, what is its CSS class? */ noWeekends: function(date) { var day = date.getDay(); return [(day > 0 && day < 6), '']; }, /* Find an object's position on the screen. */ _findPos: function(obj) { while (obj && (obj.type == 'hidden' || obj.nodeType != 1)) { obj = obj.nextSibling; } var curleft = curtop = 0; if (obj && obj.offsetParent) { curleft = obj.offsetLeft; curtop = obj.offsetTop; while (obj = obj.offsetParent) { var origcurleft = curleft; curleft += obj.offsetLeft; if (curleft < 0) { curleft = origcurleft; } curtop += obj.offsetTop; } } return [curleft,curtop]; } }); /* Individualised settings for calendars applied to one or more related inputs. Instances are managed and manipulated through the PopUpCal manager. */ function PopUpCalInstance(settings, inline) { this._id = popUpCal._register(this); this._selectedDay = 0; this._selectedMonth = 0; // 0-11 this._selectedYear = 0; // 4-digit year this._input = null; // The attached input field this._inline = inline; // True if showing inline, false if used in a popup this._calendarDiv = (!inline ? popUpCal._calendarDiv : $('<div id="calendar_div_' + this._id + '" class="calendar_inline"></div>')); // customise the calendar object - uses manager defaults if not overridden this._settings = extendRemove({}, settings || {}); // clone if (inline) { this._setDate(this._getDefaultDate()); } } $.extend(PopUpCalInstance.prototype, { /* Get a setting value, defaulting if necessary. */ _get: function(name) { return (this._settings[name] != null ? this._settings[name] : popUpCal._defaults[name]); }, /* Parse existing date and initialise calendar. */ _setDateFromField: function(input) { this._input = $(input); var dateFormat = this._get('dateFormat'); var currentDate = this._input.val().split(dateFormat.charAt(3)); if (currentDate.length == 3) { this._currentDay = parseInt(currentDate[dateFormat.indexOf('D')], 10); this._currentMonth = parseInt(currentDate[dateFormat.indexOf('M')], 10) - 1; this._currentYear = parseInt(currentDate[dateFormat.indexOf('Y')], 10); } else { var date = this._getDefaultDate(); this._currentDay = date.getDate(); this._currentMonth = date.getMonth(); this._currentYear = date.getFullYear(); } this._selectedDay = this._currentDay; this._selectedMonth = this._currentMonth; this._selectedYear = this._currentYear; this._adjustDate(); }, /* Retrieve the default date shown on opening. */ _getDefaultDate: function() { var offsetDate = function(offset) { var date = new Date(); date.setDate(date.getDate() + offset); return date; }; var defaultDate = this._get('defaultDate'); return (defaultDate == null ? new Date() : (typeof defaultDate == 'number' ? offsetDate(defaultDate) : defaultDate)); }, /* Set the date directly. */ _setDate: function(date) { this._selectedDay = this._currentDay = date.getDate(); this._selectedMonth = this._currentMonth = date.getMonth(); this._selectedYear = this._currentYear = date.getFullYear(); this._adjustDate(); }, /* Retrieve the date directly. */ _getDate: function() { return new Date(this._currentYear, this._currentMonth, this._currentDay); }, /* Generate the HTML for the current state of the calendar. */ _generateCalendar: function() { var today = new Date(); today = new Date(today.getFullYear(), today.getMonth(), today.getDate()); // clear time // build the calendar HTML var controls = '<div class="calendar_control">' + '<a class="calendar_clear" onclick="popUpCal._clearDate(' + this._id + ');">' + this._get('clearText') + '</a>' + '<a class="calendar_close" onclick="popUpCal.hideCalendar(' + this._id + ');">' + this._get('closeText') + '</a></div>'; var prompt = this._get('prompt'); var closeAtTop = this._get('closeAtTop'); var hideIfNoPrevNext = this._get('hideIfNoPrevNext'); // controls and links var html = (prompt ? '<div class="calendar_prompt">' + prompt + '</div>' : '') + (closeAtTop && !this._inline ? controls : '') + '<div class="calendar_links">' + (this._canAdjustMonth(-1) ? '<a class="calendar_prev" ' + 'onclick="popUpCal._adjustDate(' + this._id + ', -1, \'M\');">' + this._get('prevText') + '</a>' : (hideIfNoPrevNext ? '' : '<label class="calendar_prev">' + this._get('prevText') + '</label>')) + (this._isInRange(today) ? '<a class="calendar_current" ' + 'onclick="popUpCal._gotoToday(' + this._id + ');">' + this._get('currentText') + '</a>' : '') + (this._canAdjustMonth(+1) ? '<a class="calendar_next" ' + 'onclick="popUpCal._adjustDate(' + this._id + ', +1, \'M\');">' + this._get('nextText') + '</a>' : (hideIfNoPrevNext ? '' : '<label class="calendar_next">' + this._get('nextText') + '</label>')) + '</div><div class="calendar_header">'; var minDate = this._get('minDate'); var maxDate = this._get('maxDate'); // month selection var monthNames = this._get('monthNames'); if (!this._get('changeMonth')) { html += monthNames[this._selectedMonth] + '&nbsp;'; } else { var inMinYear = (minDate && minDate.getFullYear() == this._selectedYear); var inMaxYear = (maxDate && maxDate.getFullYear() == this._selectedYear); html += '<select class="calendar_newMonth" ' + 'onchange="popUpCal._selectMonthYear(' + this._id + ', this, \'M\');" ' + 'onclick="popUpCal._clickMonthYear(' + this._id + ');">'; for (var month = 0; month < 12; month++) { if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) { html += '<option value="' + month + '"' + (month == this._selectedMonth ? ' selected="selected"' : '') + '>' + monthNames[month] + '</option>'; } } html += '</select>'; } // year selection if (!this._get('changeYear')) { html += this._selectedYear; } else { // determine range of years to display var years = this._get('yearRange').split(':'); var year = 0; var endYear = 0; if (years.length != 2) { year = this._selectedYear - 10; endYear = this._selectedYear + 10; } else if (years[0].charAt(0) == '+' || years[0].charAt(0) == '-') { year = this._selectedYear + parseInt(years[0], 10); endYear = this._selectedYear + parseInt(years[1], 10); } else { year = parseInt(years[0], 10); endYear = parseInt(years[1], 10); } year = (minDate ? Math.max(year, minDate.getFullYear()) : year); endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear); html += '<select class="calendar_newYear" onchange="popUpCal._selectMonthYear(' + this._id + ', this, \'Y\');" ' + 'onclick="popUpCal._clickMonthYear(' + this._id + ');">'; for (; year <= endYear; year++) { html += '<option value="' + year + '"' + (year == this._selectedYear ? ' selected="selected"' : '') + '>' + year + '</option>'; } html += '</select>'; } html += '</div><table class="calendar" cellpadding="0" cellspacing="0"><thead>' + '<tr class="calendar_titleRow">'; var firstDay = this._get('firstDay'); var changeFirstDay = this._get('changeFirstDay'); var dayNames = this._get('dayNames'); for (var dow = 0; dow < 7; dow++) { // days of the week html += '<td>' + (!changeFirstDay ? '' : '<a onclick="popUpCal._changeFirstDay(' + this._id + ', this);">') + dayNames[(dow + firstDay) % 7] + (changeFirstDay ? '</a>' : '') + '</td>'; } html += '</tr></thead><tbody>'; var daysInMonth = this._getDaysInMonth(this._selectedYear, this._selectedMonth); this._selectedDay = Math.min(this._selectedDay, daysInMonth); var leadDays = (this._getFirstDayOfMonth(this._selectedYear, this._selectedMonth) - firstDay + 7) % 7; var currentDate = new Date(this._currentYear, this._currentMonth, this._currentDay); var selectedDate = new Date(this._selectedYear, this._selectedMonth, this._selectedDay); var printDate = new Date(this._selectedYear, this._selectedMonth, 1 - leadDays); var numRows = Math.ceil((leadDays + daysInMonth) / 7); var customDate = this._get('customDate'); var showOtherMonths = this._get('showOtherMonths'); for (var row = 0; row < numRows; row++) { // create calendar rows html += '<tr class="calendar_daysRow">'; for (var dow = 0; dow < 7; dow++) { // create calendar days var customSettings = (customDate ? customDate(printDate) : [true, '']); var otherMonth = (printDate.getMonth() != this._selectedMonth); var unselectable = otherMonth || !customSettings[0] || (minDate && printDate < minDate) || (maxDate && printDate > maxDate); html += '<td class="calendar_daysCell' + ((dow + firstDay + 6) % 7 >= 5 ? ' calendar_weekEndCell' : '') + // highlight weekends (otherMonth ? ' calendar_otherMonth' : '') + // highlight days from other months (printDate.getTime() == selectedDate.getTime() ? ' calendar_daysCellOver' : '') + // highlight selected day (unselectable ? ' calendar_unselectable' : '') + // highlight unselectable days (otherMonth && !showOtherMonths ? '' : ' ' + customSettings[1] + // highlight custom dates (printDate.getTime() == currentDate.getTime() ? ' calendar_currentDay' : // highlight current day (printDate.getTime() == today.getTime() ? ' calendar_today' : ''))) + '"' + // highlight today (if different) (unselectable ? '' : ' onmouseover="$(this).addClass(\'calendar_daysCellOver\');"' + ' onmouseout="$(this).removeClass(\'calendar_daysCellOver\');"' + ' onclick="popUpCal._selectDay(' + this._id + ', this);"') + '>' + // actions (otherMonth ? (showOtherMonths ? printDate.getDate() : '&nbsp;') : // display for other months (unselectable ? printDate.getDate() : '<a>' + printDate.getDate() + '</a>')) + '</td>'; // display for this month printDate.setDate(printDate.getDate() + 1); } html += '</tr>'; } html += '</tbody></table>' + (!closeAtTop && !this._inline ? controls : '') + '<div style="clear: both;"></div>' + (!$.browser.msie ? '' : '<!--[if lte IE 6.5]><iframe src="javascript:false;" class="calendar_cover"></iframe><![endif]-->'); return html; }, /* Adjust one of the date sub-fields. */ _adjustDate: function(offset, period) { var date = new Date(this._selectedYear + (period == 'Y' ? offset : 0), this._selectedMonth + (period == 'M' ? offset : 0), this._selectedDay + (period == 'D' ? offset : 0)); // ensure it is within the bounds set var minDate = this._get('minDate'); var maxDate = this._get('maxDate'); date = (minDate && date < minDate ? minDate : date); date = (maxDate && date > maxDate ? maxDate : date); this._selectedDay = date.getDate(); this._selectedMonth = date.getMonth(); this._selectedYear = date.getFullYear(); }, /* Find the number of days in a given month. */ _getDaysInMonth: function(year, month) { return 32 - new Date(year, month, 32).getDate(); }, /* Find the day of the week of the first of a month. */ _getFirstDayOfMonth: function(year, month) { return new Date(year, month, 1).getDay(); }, /* Determines if we should allow a "next/prev" month display change. */ _canAdjustMonth: function(offset) { var date = new Date(this._selectedYear, this._selectedMonth + offset, 1); if (offset < 0) { date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth())); } return this._isInRange(date); }, /* Is the given date in the accepted range? */ _isInRange: function(date) { var minDate = this._get('minDate'); var maxDate = this._get('maxDate'); return ((!minDate || date >= minDate) && (!maxDate || date <= maxDate)); }, /* Format the given date for display. */ _formatDate: function() { var day = this._currentDay = this._selectedDay; var month = this._currentMonth = this._selectedMonth; var year = this._currentYear = this._selectedYear; month++; // adjust javascript month var dateFormat = this._get('dateFormat'); var dateString = ''; for (var i = 0; i < 3; i++) { dateString += dateFormat.charAt(3) + (dateFormat.charAt(i) == 'D' ? (day < 10 ? '0' : '') + day : (dateFormat.charAt(i) == 'M' ? (month < 10 ? '0' : '') + month : (dateFormat.charAt(i) == 'Y' ? year : '?'))); } return dateString.substring(dateFormat.charAt(3) ? 1 : 0); } }); /* jQuery extend now ignores nulls! */ function extendRemove(target, props) { $.extend(target, props); for (var name in props) { if (props[name] == null) { target[name] = null; } } return target; } /* Attach the calendar to a jQuery selection. @param settings object - the new settings to use for this calendar instance (anonymous) @return jQuery object - for chaining further calls */ $.fn.calendar = function(settings) { return this.each(function() { // check for settings on the control itself - in namespace 'cal:' var inlineSettings = null; for (attrName in popUpCal._defaults) { var attrValue = this.getAttribute('cal:' + attrName); if (attrValue) { inlineSettings = inlineSettings || {}; try { inlineSettings[attrName] = eval(attrValue); } catch (err) { inlineSettings[attrName] = attrValue; } } } var nodeName = this.nodeName.toLowerCase(); if (nodeName == 'input') { var instSettings = (inlineSettings ? $.extend($.extend({}, settings || {}), inlineSettings || {}) : settings); // clone and customise var inst = (inst && !inlineSettings ? inst : new PopUpCalInstance(instSettings, false)); popUpCal._connectCalendar(this, inst); } else if (nodeName == 'div' || nodeName == 'span') { var instSettings = $.extend($.extend({}, settings || {}), inlineSettings || {}); // clone and customise var inst = new PopUpCalInstance(instSettings, true); popUpCal._inlineCalendar(this, inst); } }); }; /* Initialise the calendar. */ $(document).ready(function() { popUpCal = new PopUpCal(); // singleton instance });
JavaScript
// $Id: date_timezone.js,v 1.1.4.2.2.1 2008/06/20 12:25:30 karens Exp $ /** * Set the client's system time zone as default values of form fields. */ Drupal.setDefaultTimezone = function() { var dateString = Date(); // In some client environments, date strings include a time zone // abbreviation which can be interpreted by PHP. var matches = Date().match(/\(([A-Z]{3,5})\)/); var abbreviation = matches ? matches[1] : 0; // For all other client environments, the abbreviation is set to "0" // and the current offset from UTC and daylight saving time status are // used to guess the time zone. var dateNow = new Date(); var offsetNow = dateNow.getTimezoneOffset() * -60; // Use January 1 and July 1 as test dates for determining daylight // saving time status by comparing their offsets. var dateJan = new Date(dateNow.getFullYear(), 0, 1, 12, 0, 0, 0); var dateJul = new Date(dateNow.getFullYear(), 6, 1, 12, 0, 0, 0); var offsetJan = dateJan.getTimezoneOffset() * -60; var offsetJul = dateJul.getTimezoneOffset() * -60; // If the offset from UTC is identical on January 1 and July 1, // assume daylight saving time is not used in this time zone. if (offsetJan == offsetJul) { var isDaylightSavingTime = ''; } // If the maximum annual offset is equivalent to the current offset, // assume daylight saving time is in effect. else if (Math.max(offsetJan, offsetJul) == offsetNow) { var isDaylightSavingTime = 1; } // Otherwise, assume daylight saving time is not in effect. else { var isDaylightSavingTime = 0; } // Submit request to the user/timezone callback and set the form field // to the response time zone. var path = 'user/timezone/' + abbreviation + '/' + offsetNow + '/' + isDaylightSavingTime; $.getJSON(Drupal.settings.basePath, { q: path, date: dateString }, function (data) { if (data) { $("#edit-date-default-timezone, #edit-user-register-timezone, #edit-timezone-name").val(data); } }); };
JavaScript
// $Id: popups.js,v 1.9.2.27 2009/03/11 22:17:43 starbow Exp $ /** * Popup Modal Dialog API * * Provide an API for building and displaying JavaScript, in-page, popups modal dialogs. * Modality is provided by a fixed, semi-opaque div, positioned in front of the page contents. * */ /** * Create the popups object/namespace. */ Drupal.popups = function() {}; function isset(v) { return (typeof(v) !== 'undefined'); } /** * Attach the popups bevior to the all the requested links on the page. * * @param context * The jQuery object to apply the behaviors to. */ Drupal.behaviors.popups = function(context) { var $body = $('body'); if(!$body.hasClass('popups-processed')) { $body.addClass('popups-processed'); $(document).bind('keydown', Drupal.popups.keyHandle); $popit = $('#popit'); if ($popit.length) { $popit.remove(); Drupal.popups.message($popit.html()); } } // Add the popups-link-in-dialog behavior to links defined in Drupal.settings.popups.links array. if (Drupal.settings.popups.links) { jQuery.each(Drupal.settings.popups.links, function (link, options) { if (isset(options.noReload)) { // Using obsolete name. options.noUpdate = options.noReload; // Don't break existing sites with name change. } Drupal.popups.attach(context, link, options); }); } Drupal.popups.attach(context, '.popups', {noUpdate: true}); Drupal.popups.attach(context, '.popups-form', {}); // ajax reload. Drupal.popups.attach(context, '.popups-form-reload', {reloadWhenDone: true}); // whole page reload. Drupal.popups.attach(context, '.popups-form-noupdate', {noUpdate: true}); // no reload at all. Drupal.popups.attach(context, '.popups-form-noreload', {noUpdate: true}); // Obsolete. }; /** * Attach the popups behavior to a particular link. * * @param selector * jQuery selector for links to attach popups behavior to. * @param options * Hash of options associated with these links. */ Drupal.popups.attach = function(context, selector, options) { $(selector, context).not('.popups-processed').each(function() { var $element = $(this); // Mark the element as attached. var title = $element.attr('title') || ''; $element.attr('title', title + Drupal.t('[Popup]')); // Append note to link title. $element.addClass('popups-processed'); // Attach the on-click popup behavior to the element. $element.click(function(e){ var element = this; // If element is inside of a #popup div, show alert and bail out. if ($(element).parents('#popups').length) { alert("Sorry, popup chaining is not supported (yet)."); return false; } // If the element contains a on-popups-options attribute, use it instead of options param. if ($(element).attr('on-popups-options')) { options = eval('(' + $(element).attr('on-popups-options') + ')'); } // If the option is distructive, check if the page is already modified, and offer to save. var pageIsDirty = $('span.tabledrag-changed').size() > 0; var willModifyOriginal = !options.noUpdate; if (pageIsDirty && willModifyOriginal) { // The user will lose modifications, so popups dialog offering to save current state. var body = Drupal.t("There are unsaved changes on this page, which you will lose if you continue."); var buttons = { 'popup_save': {title: Drupal.t('Save Changes'), func: function(){Drupal.popups.savePage(element, options);}}, 'popup_submit': {title: Drupal.t('Continue'), func: function(){Drupal.popups.removePopup(); Drupal.popups.openPath(element, options);}}, 'popup_cancel': {title: Drupal.t('Cancel'), func: Drupal.popups.close} }; return Drupal.popups.open( Drupal.t('Warning: Please Confirm'), body, buttons ); } else { return Drupal.popups.openPath(element, options); } }); }); }; /** * Generic dialog builder. */ Drupal.popups.open = function(title, body, buttons, width) { Drupal.popups.addOverlay(); // TODO - nonModal option. var $popups = $(Drupal.theme('popupDialog', title, body, buttons)); // Start with dialog off the side. Making it invisible causes flash in FF2. $popups.css('left', '-9999px'); if (width) { $popups.css('width', width); } $('body').append( $popups ); // Add the popups to the DOM. // Adding button functions if (buttons) { jQuery.each(buttons, function (id, button) { $('#'+id).click(button.func); }); } $('#popups-close').click( Drupal.popups.close ); $('a.popups-close').click( Drupal.popups.close ); // center on the screen, adding in offsets if the window has been scrolled var popupWidth = $popups.width(); var windowWidth = $(window).width(); var left = (windowWidth / 2) - (popupWidth / 2) + Drupal.popups.scrollLeft(); // Get popups's height on the page. // Need to do it this way, since we get visible flash in FF2 if popups is not visible! var popupHeight = $popups.height(); var windowHeight = $(window).height(); if (popupHeight > (0.9 * windowHeight) ) { // Must fit in 90% of window. popupHeight = 0.9 * windowHeight; $popups.height(popupHeight); } var top = (windowHeight / 2) - (popupHeight / 2) + Drupal.popups.scrollTop(); $popups.css('top', top).css('left', left); // Position the popups to be visible. this.refocus(); // TODO: capture the focus when it leaves the dialog. Drupal.popups.removeLoading(); // Remove the loading img. return false; }; /** * Simple popups that functions like the browser's alert box. */ Drupal.popups.message = function(title, message) { message = message || ''; var buttons = { 'popup_ok': {title: Drupal.t('OK'), func: Drupal.popups.close} }; Drupal.popups.open(title, message, buttons); }; /** * Handle any special keys when popups is active. */ Drupal.popups.keyHandle = function(e) { if (!e) { e = window.event; } switch (e.keyCode) { case 27: // esc Drupal.popups.close(); break; case 191: // '?' key, show help. if (e.shiftKey && e.ctrlKey) { var $help = $('a.popups.more-help'); if ($help.size()) { $help.click(); } else { Drupal.popups.message(Drupal.t("Sorry, there is no additional help for this page")); } } break; } }; /***************************************************************************** * Appearence Functions (overlay, loading graphic, remove popups) ********* *****************************************************************************/ Drupal.popups.removePopup = function() { $('#popups').remove(); }; Drupal.popups.addOverlay = function() { var $overlay = $('#popups-overlay'); if (!$overlay.size()) { // Overlay does not already exist, so create it. $overlay = $(Drupal.theme('popupOverlay')); $overlay.css('opacity', '0.4'); // for ie6(?) // Doing absolute positioning, so make overlay's size equal the entire body. $doc = $(document); $overlay.width($doc.width()).height($doc.height()); $overlay.click(Drupal.popups.close); $('body').prepend($overlay); } }; Drupal.popups.removeOverlay = function() { $('#popups-overlay').remove(); }; Drupal.popups.addLoading = function() { var $loading = $('#popups-loading'); if (!$loading.size()) { // Overlay does not already exist, so create it. var waitImageSize = 100; var left = ($(window).width() / 2) - (waitImageSize / 2) + Drupal.popups.scrollLeft(); var top = ($(window).height() / 2) - (waitImageSize / 2) + Drupal.popups.scrollTop(); $loading = $( Drupal.theme('popupLoading', left, top) ); $('body').prepend($loading); } }; Drupal.popups.removeLoading = function() { $('#popups-loading').remove(); }; /** * Remove everything. */ Drupal.popups.close = function() { Drupal.popups.removePopup(); Drupal.popups.removeLoading(); Drupal.popups.removeOverlay(); location.reload(); return false; }; /** * Set the focus on the popups to the first visible form element, or the first button, or the close link. */ Drupal.popups.refocus = function() { $focus = $('#popups input:visible:eq(0)'); if (!isset(focus)) { $focus = $('#popups-close'); // Doesn't seem to work. } $focus.focus(); }; /**************************************************************************** * Theme Functions ******************************************************** ****************************************************************************/ Drupal.theme.prototype.popupLoading = function(left, top) { var loading = '<div id="popups-loading">'; loading += '<div style="left:' + left +'px; top:' + top +'px;">'; loading += '<img src="'+ Drupal.settings.basePath + Drupal.settings.popups.modulePath + '/ajax-loader.gif" />'; loading += '</div></div>'; return loading; }; Drupal.theme.prototype.popupOverlay = function() { return '<div id="popups-overlay"></div>'; }; Drupal.theme.prototype.popupButton = function(title, id) { return '<input type="button" value="'+ title +'" id="'+ id +'" />'; }; Drupal.theme.prototype.popupDialog = function(title, body, buttons) { var template = Drupal.settings.popups.template; var popups = template.replace('%title', title).replace('%body', body); var themedButtons = ''; if (buttons) { jQuery.each(buttons, function (id, button) { themedButtons += Drupal.theme('popupButton', button.title, id); }); } popups = popups.replace('%buttons', themedButtons); return popups; }; // Stolen jQuery offset Drupal.popups.scrollLeft = function() { return Math.max(document.documentElement.scrollLeft, document.body.scrollLeft); }; // Stolen jQuery offset Drupal.popups.scrollTop = function() { return Math.max(document.documentElement.scrollTop, document.body.scrollTop); }; /**************************************************************************** * Page & Form in popups functions *** ****************************************************************************/ /** * Use Ajax to open the link in a popups window. * * @param element * Element that was clicked to open the popups. * @param options * Hash of options controlling how the popups interacts with the underlying page. */ Drupal.popups.openPath = function(element, options) { // let the user know something is happening $('body').css("cursor", "wait"); // TODO - get nonmodal working. if (!options.nonModal) { Drupal.popups.addOverlay(); } Drupal.popups.addLoading(); var href = options.href ? options.href : element.href; $(document).trigger('popups_open_path', [element, href]); // Broadcast "Popups Open Path" event. var params = {}; // Force the popups to return back to the orignal page when forms are done, unless forceReturn option is set. if (!options.forceReturn) { // If forceReturn, requestor wants data from different page. href = href.replace(/destination=[^;&]*[;&]?/, ''); // Strip out any existing destination param. params.destination = Drupal.settings.popups.originalPath; // Set the destination to the original page. } ajaxOptions = { url: href, dataType: 'json', data: params, beforeSend: Drupal.popups.beforeSend, success: function(json) { Drupal.popups.openContent(json.title, json.messages + json.content, options, element); $(document).trigger('popups_open_path_done', [element, href]); // Broadcast "Popups Open Path Done" event. }, complete: function() { $('body').css("cursor", "auto"); // Return the cursor to normal state. } }; if (options.reloadOnError) { ajaxOptions.error = function() { location.reload(); // Reload on error. Is this working? }; } else { ajaxOptions.error = function() { Drupal.popups.message("Unable to open: " + href); }; } $.ajax(ajaxOptions); return false; }; /** * Open content in an ajax popups. * * @param title * String title of the popups. * @param content * HTML to show in the popups. * @param options * Hash of options controlling how the popups interacts with the underlying page. * @param element * A DOM object containing the element that was clicked to initiate the popup. */ Drupal.popups.openContent = function(title, content, options, element) { Drupal.popups.open(title, content, null, options.width); // Add behaviors to content in popups. // TODO: d-n-d: need to click to let go of selection. delete Drupal.behaviors.tableHeader; // Work-around for bug in tableheader.js (http://drupal.org/node/234377) delete Drupal.behaviors.teaser; // Work-around for bug in teaser.js (sigh). Drupal.attachBehaviors($('#popups-body')); // Adding collapse moves focus. Drupal.popups.refocus(); // If the popups contains a form, capture submits. var $form = $('form', '#popups-body'); $form.ajaxForm({ dataType: 'json', beforeSubmit: Drupal.popups.beforeSubmit, beforeSend: Drupal.popups.beforeSend, success: function(response, status) { Drupal.popups.formSuccess(response, options, element); }, error: function() { Drupal.popups.message("Bad Response form submission"); } }); }; Drupal.popups.beforeSend = function(xhr) { xhr.setRequestHeader("X-Drupal-Render-Mode", 'json/popups'); }; /** * Do before the form in the popups is submitted. */ Drupal.popups.beforeSubmit = function(formData, $form, options) { Drupal.popups.removePopup(); // Remove just the dialog, but not the overlay. Drupal.popups.addLoading(); }; /** * The form in the popups was successfully submitted * Update the originating page. * Show any messages in a popups (TODO - make this a configurable option). * * @param response * JSON object from server with status of form submission. * @param options * Hash of options controlling how the popups interacts with the underlying page. * noUpdate: bool, does the popups effect the underlying page. * nonModal: bool, does the popups block access to the underlying page. * targetSelectors: hash of jQuery selectors, overrides defaultTargetSelector. * titleSelectors: array of jQuery selectors, where to put the the new title of the page. * @param element * A DOM object containing the element that was clicked to initiate the popup. */ Drupal.popups.formSuccess = function(data, options, element) { // Determine if we are at an end point, or just moving from one popups to another. options.reloadWhenDone = true; var done = (data.path === Drupal.settings.popups.originalPath) || (data.path === options.forceReturn) || options.reloadWhenDone; if (!done) { // Not done yet, so show new page in new popups. Drupal.popups.removeLoading(); // Execute the afterSubmit callback if available. Drupal.popups.openContent(data.title, data.messages + data.content, options, element); } else { // Done. if (options.afterSubmit) { var afterSubmitResult = eval(options.afterSubmit +'(data, options, element)'); if (afterSubmitResult == false) { // Give afterSubmit callback a chance to skip normal processing. return; } } if (options.reloadWhenDone) { // Force a complete, non-ajax reload of the page. var showMessage = data.messages.length && !options.noMessage; if (showMessage) { Drupal.popups.message(data.messages); if (!Drupal.settings.popups.popupFinalMessage) { setTimeout(Drupal.popups.close, 10000); // Autoclose the message box in 2.5 seconds. } } } else { // Normal, targeted ajax, reload behavior. // show messages in dialog and embed the results in the original page. var showMessage = data.messages.length && !options.noMessage; if (showMessage) { Drupal.popups.message(data.messages); if (!Drupal.settings.popups.popupFinalMessage) { setTimeout(Drupal.popups.close, 5000); // Autoclose the message box in 2.5 seconds. } // Insert the message into the page above the content. // Might not be the standard spot, but it is the easiest to find. var $next = $(Drupal.settings.popups.defaultTargetSelector); $next.parent().find('div.messages').remove(); // Remove the current messages. $next.before(data.messages); } // Update the content area (defined by 'targetSelectors'). if (!options.noUpdate) { Drupal.popups.testContentSelector(); if (isset(options.targetSelectors)) { // Pick and choose what returned content goes where. jQuery.each(options.targetSelectors, function(t_new, t_old) { if(!isNaN(t_new)) { t_new = t_old; // handle case where targetSelectors is an array, not a hash. } var new_content = $(t_new, data.content); var $c = $(t_old).html(new_content); // Inject the new content into the original page. Drupal.attachBehaviors($c); }); } else { // Put the entire new content into default content area. $c = $(Drupal.settings.popups.defaultTargetSelector).html(data.content); Drupal.attachBehaviors($c); } } // Update the title of the page. if (isset(options.titleSelectors)) { jQuery.each(options.titleSelectors, function() { $(''+this).html(data.title); }); } // Done with changes to the original page, remove effects. Drupal.popups.removeLoading(); if (!showMessage) { // If there is not a messages popups, so remove the overlay. Drupal.popups.removeOverlay(); } } // Broadcast an event that popup form was done and successful. $(document).trigger('popups_form_success', [element]); } // End of updating original page. }; /** * Submit the page and reload the results, before popping up the real dialog. * * @param element * Element that was clicked to open the popups. * @param options * Hash of options controlling how the popups interacts with the underlying page. */ Drupal.popups.savePage = function(element, options) { var target = Drupal.settings.popups.defaultTargetSelector; var $form = $('form', target); var ajaxOptions = { dataType: 'json', beforeSubmit: Drupal.popups.beforeSubmit, beforeSend: Drupal.popups.beforeSend, success: function(response, status) { // Sync up the current page contents with the submit. var $c = $(target).html(response.content); // Inject the new content into the page. Drupal.attachBehaviors($c); // The form has been saved, the page reloaded, now safe to show the link in a popup. Drupal.popups.openPath(element, options); } }; $form.ajaxSubmit(ajaxOptions); // Submit the form. }; /** * Warn the user if ajax updates will not work * due to mismatch between the theme and the theme's popup setting. */ Drupal.popups.testContentSelector = function() { var target = Drupal.settings.popups.defaultTargetSelector; var hits = $(target).length; if (hits !== 1) { // 1 is the corrent answer. msg = Drupal.t('The popup content area for this theme is misconfigured.') + '\n'; if (hits === 0) { msg += Drupal.t('There is no element that matches ') + '"' + target + '"\n'; } else if (hits > 1) { msg += Drupal.t('There are multiple elements that match: ') + '"' + target + '"\n'; } msg += Drupal.t('Go to admin/build/themes/settings, select your theme, and edit the "Content Selector" field'); alert(msg); } };
JavaScript
<html> <head> # <script type="txt/javascript"> var persistmenu="yes" # # if (document.getElementById){ # document.write('<style type="text/css">\n') # document.write('.submenu{display: none;}\n') # document.write('</style>\n') # } # # function SwitchMenu(obj){ # if(document.getElementById){ # var el = document.getElementById(obj); # var ar = document.getElementById("masterdiv").getElementsByTagName("span"); # if(el.style.display != "block"){ # for (var i=0; i<ar.length; i++){ # if (ar[i].className=="submenu") # ar[i].style.display = "none"; # } # el.style.display = "block"; # }else{ # el.style.display = "none"; # } # } # } # # function get_cookie(Name) { # var search = Name + "=" # var returnvalue = ""; # if (document.cookie.length > 0) { # offset = document.cookie.indexOf(search) # if (offset != -1) { # offset += search.length # end = document.cookie.indexOf(";", offset); # if (end == -1) end = document.cookie.length; # returnvalue=unescape(document.cookie.substring(offset, end)) # } # } # return returnvalue; # error(1): function not defined # } # # function onloadfunction(){ # if (persistmenu=="yes"){ # var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname # var cookievalue=get_cookie(cookiename) # if (cookievalue!="") # document.getElementById(cookievalue).style.display="block" # } # } # # function savemenustate(){ # var inc=1, blockid="" # while (document.getElementById("sub"+inc)){ # if (document.getElementById("sub"+inc).style.display=="block"){ # blockid="sub"+inc # break # } # inc++ # } # var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname # var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid # document.cookie=cookiename+"="+cookievalue # } # # if (window.addEventListener) # window.addEventListener("load", onloadfunction, false) # else if (window.attachEvent) # window.attachEvent("onload", onloadfunction) # else if (document.getElementById) # window.onload=onloadfunction # # if (persistmenu=="yes" && document.getElementById) # window.onunload=savemenustate # </script> # # # </head> # <body> # <div id="masterdiv"> # <div class="menutitle" onclick="SwitchMenu('sub1')"> <a href="index.html" class="menutitle2" title="Link 1 home.">Link 1</a> # </div> # <div class="menutitle" onclick="SwitchMenu('sub2')">Link 2</div> # <span class="submenu" id="sub2"> # <a href="sublink1/" class="submenu2" title="Sublink1.">Sub-Link 1</a> # </ br> # <a href="subLink2/" class="submenu2" title="Sub-Link 2">Sub-Link 2</a> # </ br> # </div> # </div> # </body> # .menutitle # { # border: 1px 0px 1px 0px; # border-style: solid; # border-color: #9DA5A0; # color: #CDDEFC; # font-family: Verdana, Geneva, Arial, sans-serif; # font-variant: caps; # letter-spacing: 2px; # font-size: 11px; # padding: 3px 10px 3px 20px; # margin: 2px 0px 0px 0px; # cursor: hand; # } # # .menutitle:hover # { # background-color: #7A7C7B; # cursor: hand; # } # # .menutitle2 # { # font-family: Verdana, Geneva, Arial, sans-serif; # font-size: 11px; # text-decoration: none; # border-width: 0px; # color: #CDDEFC; # } # # .menutitle2:hover # { # color: #666; # } # # .submenu2 # { # background-color: #F8F8F8; # border-width: 0px; # letter-spacing: 1px; # } # # .submenu2:hover # { # color: #CDDEFC; # background-color: #E1F7BF; # } </html>
JavaScript
function VerifyEmail(input) { email= input.value; if(email.indexOf('@',0) == -1 || email.indexOf(';',0) != -1 || email.indexOf(' ',0) != -1 || email.indexOf('/',0) != -1 || email.indexOf(';',0) != -1 || email.indexOf('<',0) != -1 || email.indexOf('>',0) != -1 || email.indexOf('*',0) != -1 || email.indexOf('|',0) != -1 || email.indexOf('`',0) != -1 || email.indexOf('&',0) != -1 || email.indexOf('$',0) != -1 || email.indexOf('!',0) != -1 || email.indexOf('"',0) != -1 || email.indexOf(':',0) != -1) { alert("Bad e-mail address format: " + email + ", Please enter a valid address."); } } function VerifySpace(input) { text= input.value; if(text.indexOf(' ',0) != -1) { alert("Enter a string without space character."); return false; } else { return true; } } function VerifyLength(input,len) { text= input.value; if(text.indexOf(' ',0) != -1) { alert("Enter a string."); return false; } else if(text.length < len) { alert("Enter at least "+len+" characters."); return false; } else { return true; } } function VerifyNumeric(input) { text= input.value; for( var i=0; i< text.length; i++) { var ch= text.substring(i,i+1); if (ch < "0" || ch > "9") { alert("Enter a number"); return false; } } return true; }
JavaScript
/** * @author ZhangHuihua@msn.com */ (function($){ // jQuery validate $.extend($.validator.messages, { required: "必填字段", remote: "请修正该字段", email: "请输入正确格式的电子邮件", url: "请输入合法的网址", date: "请输入合法的日期", dateISO: "请输入合法的日期 (ISO).", number: "请输入合法的数字", digits: "只能输入整数", creditcard: "请输入合法的信用卡号", equalTo: "请再次输入相同的值", accept: "请输入拥有合法后缀名的字符串", maxlength: $.validator.format("长度最多是 {0} 的字符串"), minlength: $.validator.format("长度最少是 {0} 的字符串"), rangelength: $.validator.format("长度介于 {0} 和 {1} 之间的字符串"), range: $.validator.format("请输入一个介于 {0} 和 {1} 之间的值"), max: $.validator.format("请输入一个最大为 {0} 的值"), min: $.validator.format("请输入一个最小为 {0} 的值"), alphanumeric: "字母、数字、下划线", lettersonly: "必须是字母", phone: "数字、空格、括号" }); // DWZ regional $.setRegional("datepicker", { dayNames: ['日', '一', '二', '三', '四', '五', '六'], monthNames: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'] }); $.setRegional("alertMsg", { title:{error:"错误", info:"提示", warn:"警告", correct:"成功", confirm:"确认提示"}, butMsg:{ok:"确定", yes:"是", no:"否", cancel:"取消"} }); })(jQuery);
JavaScript
/*! * MultiUpload for xheditor * @requires xhEditor * * @author Yanis.Wang<yanis.wang@gmail.com> * @site http://xheditor.com/ * @licence LGPL(http://www.opensource.org/licenses/lgpl-license.php) * * @Version: 0.9.2 (build 100505) */ var swfu,selQueue=[],selectID,arrMsg=[],allSize=0,uploadSize=0; function removeFile() { var file; if(!selectID)return; for(var i in selQueue) { file=selQueue[i]; if(file.id==selectID) { selQueue.splice(i,1); allSize-=file.size; swfu.cancelUpload(file.id); $('#'+file.id).remove(); selectID=null; break; } } $('#btnClear').hide(); if(selQueue.length==0)$('#controlBtns').hide(); } function startUploadFiles() { if(swfu.getStats().files_queued>0) { $('#controlBtns').hide(); swfu.startUpload(); } else alert('上传前请先添加文件'); } function setFileState(fileid,txt) { $('#'+fileid+'_state').text(txt); } function fileQueued(file)//队列添加成功 { for(var i in selQueue)if(selQueue[i].name==file.name){swfu.cancelUpload(file.id);return false;}//防止同名文件重复添加 if(selQueue.length==0)$('#controlBtns').show(); selQueue.push(file); allSize+=file.size; $('#listBody').append('<tr id="'+file.id+'"><td>'+file.name+'</td><td>'+formatBytes(file.size)+'</td><td id="'+file.id+'_state">就绪</td></tr>'); $('#'+file.id).hover(function(){$(this).addClass('hover');},function(){$(this).removeClass('hover');}) .click(function(){selectID=file.id;$('#listBody tr').removeClass('select');$(this).removeClass('hover').addClass('select');$('#btnClear').show();}) } function fileQueueError(file, errorCode, message)//队列添加失败 { var errorName=''; switch (errorCode) { case SWFUpload.QUEUE_ERROR.QUEUE_LIMIT_EXCEEDED: errorName = "只能同时上传 "+this.settings.file_upload_limit+" 个文件"; break; case SWFUpload.QUEUE_ERROR.FILE_EXCEEDS_SIZE_LIMIT: errorName = "选择的文件超过了当前大小限制:"+this.settings.file_size_limit; break; case SWFUpload.QUEUE_ERROR.ZERO_BYTE_FILE: errorName = "零大小文件"; break; case SWFUpload.QUEUE_ERROR.INVALID_FILETYPE: errorName = "文件扩展名必需为:"+this.settings.file_types_description+" ("+this.settings.file_types+")"; break; default: errorName = "未知错误"; break; } alert(errorName); } function uploadStart(file)//单文件上传开始 { setFileState(file.id,'上传中…'); } function uploadProgress(file, bytesLoaded, bytesTotal)//单文件上传进度 { var percent=Math.ceil((uploadSize+bytesLoaded)/allSize*100); $('#progressBar span').text(percent+'% ('+formatBytes(uploadSize+bytesLoaded)+' / '+formatBytes(allSize)+')'); $('#progressBar div').css('width',percent+'%'); } function uploadSuccess(file, serverData)//单文件上传成功 { var data=Object; try{eval("data=" + serverData);}catch(ex){}; if(data.err!=undefined&&data.msg!=undefined) { if(!data.err) { uploadSize+=file.size; arrMsg.push(data.msg); setFileState(file.id,'上传成功'); } else { setFileState(file.id,'上传失败'); alert(data.err); } } else setFileState(file.id,'上传失败!'); } function uploadError(file, errorCode, message)//单文件上传错误 { setFileState(file.id,'上传失败!'); } function uploadComplete(file)//文件上传周期结束 { if(swfu.getStats().files_queued>0)swfu.startUpload(); else uploadAllComplete(); } function uploadAllComplete()//全部文件上传成功 { callback(arrMsg); } function formatBytes(bytes) { var s = ['Byte', 'KB', 'MB', 'GB', 'TB', 'PB']; var e = Math.floor(Math.log(bytes)/Math.log(1024)); return (bytes/Math.pow(1024, Math.floor(e))).toFixed(2)+" "+s[e]; }
JavaScript
/* Copyright (c) 2006 Brandon Aaron (http://brandonaaron.net) * Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php) * and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses. * * $LastChangedDate: 2007-07-21 18:44:59 -0500 (Sat, 21 Jul 2007) $ * $Rev: 2446 $ * * Version 2.1.1 */ (function($){ /** * The bgiframe is chainable and applies the iframe hack to get * around zIndex issues in IE6. It will only apply itself in IE6 * and adds a class to the iframe called 'bgiframe'. The iframe * is appeneded as the first child of the matched element(s) * with a tabIndex and zIndex of -1. * * By default the plugin will take borders, sized with pixel units, * into account. If a different unit is used for the border's width, * then you will need to use the top and left settings as explained below. * * NOTICE: This plugin has been reported to cause perfromance problems * when used on elements that change properties (like width, height and * opacity) a lot in IE6. Most of these problems have been caused by * the expressions used to calculate the elements width, height and * borders. Some have reported it is due to the opacity filter. All * these settings can be changed if needed as explained below. * * @example $('div').bgiframe(); * @before <div><p>Paragraph</p></div> * @result <div><iframe class="bgiframe".../><p>Paragraph</p></div> * * @name bgiframe * @type jQuery * @cat Plugins/bgiframe * @author Brandon Aaron (brandon.aaron@gmail.com || http://brandonaaron.net) */ $.fn.bgiframe = function(s) { // This is only for IE6 if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) { s = $.extend({ top : 'auto', // auto == .currentStyle.borderTopWidth left : 'auto', // auto == .currentStyle.borderLeftWidth width : 'auto', // auto == offsetWidth height : 'auto', // auto == offsetHeight opacity : true, src : 'javascript:false;' }, s || {}); var prop = function(n){return n&&n.constructor==Number?n+'px':n;}, html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+ 'style="display:block;position:absolute;z-index:-1;'+ (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+ 'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+ 'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+ 'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+ 'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+ '"/>'; return this.each(function() { if ( $('> iframe.bgiframe', this).length == 0 ) this.insertBefore( document.createElement(html), this.firstChild ); }); } return this; }; })(jQuery);
JavaScript
/** * @author Roger Wu */ /*@cc_on _d=document;eval('var document=_d')@*/ /*@cc_on eval((function(props) {var code = [];for (var i = 0,l = props.length;i<l;i++){var prop = props[i];window['_'+prop]=window[prop];code.push(prop+'=_'+prop);}return 'var '+code.join(',');})('document self top parent alert setInterval clearInterval setTimeout clearTimeout'.split(' ')))@*/
JavaScript
/** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ /** * Create a cookie with the given name and value and other optional parameters. * * @example $.cookie('the_cookie', 'the_value'); * @desc Set the value of a cookie. * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true}); * @desc Create a cookie with all available options. * @example $.cookie('the_cookie', 'the_value'); * @desc Create a session cookie. * @example $.cookie('the_cookie', null); * @desc Delete a cookie by passing null as value. * * @param String name The name of the cookie. * @param String value The value of the cookie. * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. * If set to null or omitted, the cookie will be a session cookie and will not be retained * when the the browser exits. * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will * require a secure protocol (like HTTPS). * @type undefined * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ /** * Get the value of a cookie with the given name. * * @example $.cookie('the_cookie'); * @desc Get the value of a cookie. * * @param String name The name of the cookie. * @return The value of the cookie. * @type String * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } };
JavaScript
if (!hs) { var hs = { // Language strings lang : { cssDirection: 'ltr', loadingText : '加载中...', loadingTitle : '点击取消', focusTitle : '点击前端显示', fullExpandTitle : '按F键以真实大小显示', creditsText : '', creditsTitle : '', previousText : '上一张', nextText : '下一张', moveText : '移动', closeText : '关闭', closeTitle : '关闭 (esc)', resizeTitle : '重设大小', playText : '播放', playTitle : '自动播放', pauseText : '暂停', pauseTitle : '暂停播放', previousTitle : '上一张 ', nextTitle : '下一张', moveTitle : '移动', fullExpandText : '原始大小', number: 'Image %1 of %2', restoreTitle : '点击图片可关闭,按住鼠标左键可拖动,可以使用快捷键进行图片选择!' }, // See http://highslide.com/ref for examples of settings graphicsDir : 'graphics/', expandCursor : 'zoomin.cur', // null disables restoreCursor : 'zoomout.cur', // null disables expandDuration : 250, // milliseconds restoreDuration : 250, marginLeft : 15, marginRight : 15, marginTop : 15, marginBottom : 15, zIndexCounter : 1001, // adjust to other absolutely positioned elements loadingOpacity : 0.75, allowMultipleInstances: true, numberOfImagesToPreload : 5, outlineWhileAnimating : 2, // 0 = never, 1 = always, 2 = HTML only outlineStartOffset : 3, // ends at 10 padToMinWidth : false, // pad the popup width to make room for wide caption fullExpandPosition : 'bottom right', fullExpandOpacity : 1, showCredits : true, // you can set this to false if you want creditsHref : '#', creditsTarget : '_self', enableKeyListener : true, openerTagNames : ['a'], // Add more to allow slideshow indexing transitions : [], transitionDuration: 250, dimmingOpacity: 0, // Lightbox style dimming background dimmingDuration: 50, // 0 for instant dimming anchor : 'auto', // where the image expands from align : 'auto', // position in the client (overrides anchor) targetX: null, // the id of a target element targetY: null, dragByHeading: true, minWidth: 200, minHeight: 200, allowSizeReduction: true, // allow the image to reduce to fit client size. If false, this overrides minWidth and minHeight outlineType : 'drop-shadow', // set null to disable outlines skin : { controls: '<div class="highslide-controls"><ul>'+ '<li class="highslide-previous">'+ '<a href="#" title="{hs.lang.previousTitle}">'+ '<span>{hs.lang.previousText}</span></a>'+ '</li>'+ '<li class="highslide-play">'+ '<a href="#" title="{hs.lang.playTitle}">'+ '<span>{hs.lang.playText}</span></a>'+ '</li>'+ '<li class="highslide-pause">'+ '<a href="#" title="{hs.lang.pauseTitle}">'+ '<span>{hs.lang.pauseText}</span></a>'+ '</li>'+ '<li class="highslide-next">'+ '<a href="#" title="{hs.lang.nextTitle}">'+ '<span>{hs.lang.nextText}</span></a>'+ '</li>'+ '<li class="highslide-move">'+ '<a href="#" title="{hs.lang.moveTitle}">'+ '<span>{hs.lang.moveText}</span></a>'+ '</li>'+ '<li class="highslide-full-expand">'+ '<a href="#" title="{hs.lang.fullExpandTitle}">'+ '<span>{hs.lang.fullExpandText}</span></a>'+ '</li>'+ '<li class="highslide-close">'+ '<a href="#" title="{hs.lang.closeTitle}" >'+ '<span>{hs.lang.closeText}</span></a>'+ '</li>'+ '</ul></div>' }, // END OF YOUR SETTINGS // declare internal properties preloadTheseImages : [], continuePreloading: true, expanders : [], overrides : [ 'allowSizeReduction', 'useBox', 'anchor', 'align', 'targetX', 'targetY', 'outlineType', 'outlineWhileAnimating', 'captionId', 'captionText', 'captionEval', 'captionOverlay', 'headingId', 'headingText', 'headingEval', 'headingOverlay', 'creditsPosition', 'dragByHeading', 'autoplay', 'numberPosition', 'transitions', 'dimmingOpacity', 'width', 'height', 'wrapperClassName', 'minWidth', 'minHeight', 'maxWidth', 'maxHeight', 'slideshowGroup', 'easing', 'easingClose', 'fadeInOut', 'src' ], overlays : [], idCounter : 0, oPos : { x: ['leftpanel', 'left', 'center', 'right', 'rightpanel'], y: ['above', 'top', 'middle', 'bottom', 'below'] }, mouse: {}, headingOverlay: {}, captionOverlay: {}, timers : [], slideshows : [], pendingOutlines : {}, clones : {}, onReady: [], uaVersion: /Trident\/4\.0/.test(navigator.userAgent) ? 8 : parseFloat((navigator.userAgent.toLowerCase().match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [0,'0'])[1]), ie : (document.all && !window.opera), safari : /Safari/.test(navigator.userAgent), geckoMac : /Macintosh.+rv:1\.[0-8].+Gecko/.test(navigator.userAgent), $ : function (id) { if (id) return document.getElementById(id); }, push : function (arr, val) { arr[arr.length] = val; }, createElement : function (tag, attribs, styles, parent, nopad) { var el = document.createElement(tag); if (attribs) hs.extend(el, attribs); if (nopad) hs.setStyles(el, {padding: 0, border: 'none', margin: 0}); if (styles) hs.setStyles(el, styles); if (parent) parent.appendChild(el); return el; }, extend : function (el, attribs) { for (var x in attribs) el[x] = attribs[x]; return el; }, setStyles : function (el, styles) { for (var x in styles) { if (hs.ie && x == 'opacity') { if (styles[x] > 0.99) el.style.removeAttribute('filter'); else el.style.filter = 'alpha(opacity='+ (styles[x] * 100) +')'; } else el.style[x] = styles[x]; } }, animate: function(el, prop, opt) { var start, end, unit; if (typeof opt != 'object' || opt === null) { var args = arguments; opt = { duration: args[2], easing: args[3], complete: args[4] }; } if (typeof opt.duration != 'number') opt.duration = 250; opt.easing = Math[opt.easing] || Math.easeInQuad; opt.curAnim = hs.extend({}, prop); for (var name in prop) { var e = new hs.fx(el, opt , name ); start = parseFloat(hs.css(el, name)) || 0; end = parseFloat(prop[name]); unit = name != 'opacity' ? 'px' : ''; e.custom( start, end, unit ); } }, css: function(el, prop) { if (document.defaultView) { return document.defaultView.getComputedStyle(el, null).getPropertyValue(prop); } else { if (prop == 'opacity') prop = 'filter'; var val = el.currentStyle[prop.replace(/\-(\w)/g, function (a, b){ return b.toUpperCase(); })]; if (prop == 'filter') val = val.replace(/alpha\(opacity=([0-9]+)\)/, function (a, b) { return b / 100 }); return val === '' ? 1 : val; } }, getPageSize : function () { var d = document, w = window, iebody = d.compatMode && d.compatMode != 'BackCompat' ? d.documentElement : d.body; var width = hs.ie ? iebody.clientWidth : (d.documentElement.clientWidth || self.innerWidth), height = hs.ie ? iebody.clientHeight : self.innerHeight; hs.page = { width: width, height: height, scrollLeft: hs.ie ? iebody.scrollLeft : pageXOffset, scrollTop: hs.ie ? iebody.scrollTop : pageYOffset } }, getPosition : function(el) { var p = { x: el.offsetLeft, y: el.offsetTop }; while (el.offsetParent) { el = el.offsetParent; p.x += el.offsetLeft; p.y += el.offsetTop; if (el != document.body && el != document.documentElement) { p.x -= el.scrollLeft; p.y -= el.scrollTop; } } return p; }, expand : function(a, params, custom, type) { if (!a) a = hs.createElement('a', null, { display: 'none' }, hs.container); if (typeof a.getParams == 'function') return params; try { new hs.Expander(a, params, custom); return false; } catch (e) { return true; } }, getElementByClass : function (el, tagName, className) { var els = el.getElementsByTagName(tagName); for (var i = 0; i < els.length; i++) { if ((new RegExp(className)).test(els[i].className)) { return els[i]; } } return null; }, replaceLang : function(s) { s = s.replace(/\s/g, ' '); var re = /{hs\.lang\.([^}]+)\}/g, matches = s.match(re), lang; if (matches) for (var i = 0; i < matches.length; i++) { lang = matches[i].replace(re, "$1"); if (typeof hs.lang[lang] != 'undefined') s = s.replace(matches[i], hs.lang[lang]); } return s; }, focusTopmost : function() { var topZ = 0, topmostKey = -1, expanders = hs.expanders, exp, zIndex; for (var i = 0; i < expanders.length; i++) { exp = expanders[i]; if (exp) { zIndex = exp.wrapper.style.zIndex; if (zIndex && zIndex > topZ) { topZ = zIndex; topmostKey = i; } } } if (topmostKey == -1) hs.focusKey = -1; else expanders[topmostKey].focus(); }, getParam : function (a, param) { a.getParams = a.onclick; var p = a.getParams ? a.getParams() : null; a.getParams = null; return (p && typeof p[param] != 'undefined') ? p[param] : (typeof hs[param] != 'undefined' ? hs[param] : null); }, getSrc : function (a) { var src = hs.getParam(a, 'src'); if (src) return src; return a.href; }, getNode : function (id) { var node = hs.$(id), clone = hs.clones[id], a = {}; if (!node && !clone) return null; if (!clone) { clone = node.cloneNode(true); clone.id = ''; hs.clones[id] = clone; return node; } else { return clone.cloneNode(true); } }, discardElement : function(d) { if (d) hs.garbageBin.appendChild(d); hs.garbageBin.innerHTML = ''; }, dim : function(exp) { if (!hs.dimmer) { hs.dimmer = hs.createElement ('div', { className: 'highslide-dimming highslide-viewport-size', owner: '', onclick: function() { hs.close(); } }, { visibility: 'visible', opacity: 0 }, hs.container, true); } hs.dimmer.style.display = ''; hs.dimmer.owner += '|'+ exp.key; if (hs.geckoMac && hs.dimmingGeckoFix) hs.setStyles(hs.dimmer, { background: 'url('+ hs.graphicsDir + 'geckodimmer.png)', opacity: 1 }); else hs.animate(hs.dimmer, { opacity: exp.dimmingOpacity }, hs.dimmingDuration); }, undim : function(key) { if (!hs.dimmer) return; if (typeof key != 'undefined') hs.dimmer.owner = hs.dimmer.owner.replace('|'+ key, ''); if ( (typeof key != 'undefined' && hs.dimmer.owner != '') || (hs.upcoming && hs.getParam(hs.upcoming, 'dimmingOpacity')) ) return; if (hs.geckoMac && hs.dimmingGeckoFix) hs.dimmer.style.display = 'none'; else hs.animate(hs.dimmer, { opacity: 0 }, hs.dimmingDuration, null, function() { hs.dimmer.style.display = 'none'; }); }, transit : function (adj, exp) { var last = exp = exp || hs.getExpander(); if (hs.upcoming) return false; else hs.last = last; try { hs.upcoming = adj; adj.onclick(); } catch (e){ hs.last = hs.upcoming = null; } try { if (!adj || exp.transitions[1] != 'crossfade') exp.close(); } catch (e) {} return false; }, previousOrNext : function (el, op) { var exp = hs.getExpander(el); if (exp) return hs.transit(exp.getAdjacentAnchor(op), exp); else return false; }, previous : function (el) { return hs.previousOrNext(el, -1); }, next : function (el) { return hs.previousOrNext(el, 1); }, keyHandler : function(e) { if (!e) e = window.event; if (!e.target) e.target = e.srcElement; // ie if (typeof e.target.form != 'undefined') return true; // form element has focus var exp = hs.getExpander(); var op = null; switch (e.keyCode) { case 70: // f if (exp) exp.doFullExpand(); return true; case 32: // Space op = 2; break; case 34: // Page Down case 39: // Arrow right case 40: // Arrow down op = 1; break; case 8: // Backspace case 33: // Page Up case 37: // Arrow left case 38: // Arrow up op = -1; break; case 27: // Escape case 13: // Enter op = 0; } if (op !== null) {if (op != 2)hs.removeEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler); if (!hs.enableKeyListener) return true; if (e.preventDefault) e.preventDefault(); else e.returnValue = false; if (exp) { if (op == 0) { exp.close(); } else if (op == 2) { if (exp.slideshow) exp.slideshow.hitSpace(); } else { if (exp.slideshow) exp.slideshow.pause(); hs.previousOrNext(exp.key, op); } return false; } } return true; }, registerOverlay : function (overlay) { hs.push(hs.overlays, hs.extend(overlay, { hsId: 'hsId'+ hs.idCounter++ } )); }, addSlideshow : function (options) { var sg = options.slideshowGroup; if (typeof sg == 'object') { for (var i = 0; i < sg.length; i++) { var o = {}; for (var x in options) o[x] = options[x]; o.slideshowGroup = sg[i]; hs.push(hs.slideshows, o); } } else { hs.push(hs.slideshows, options); } }, getWrapperKey : function (element, expOnly) { var el, re = /^highslide-wrapper-([0-9]+)$/; // 1. look in open expanders el = element; while (el.parentNode) { if (el.hsKey !== undefined) return el.hsKey; if (el.id && re.test(el.id)) return el.id.replace(re, "$1"); el = el.parentNode; } // 2. look in thumbnail if (!expOnly) { el = element; while (el.parentNode) { if (el.tagName && hs.isHsAnchor(el)) { for (var key = 0; key < hs.expanders.length; key++) { var exp = hs.expanders[key]; if (exp && exp.a == el) return key; } } el = el.parentNode; } } return null; }, getExpander : function (el, expOnly) { if (typeof el == 'undefined') return hs.expanders[hs.focusKey] || null; if (typeof el == 'number') return hs.expanders[el] || null; if (typeof el == 'string') el = hs.$(el); return hs.expanders[hs.getWrapperKey(el, expOnly)] || null; }, isHsAnchor : function (a) { return (a.onclick && a.onclick.toString().replace(/\s/g, ' ').match(/hs.(htmlE|e)xpand/)); }, reOrder : function () { for (var i = 0; i < hs.expanders.length; i++) if (hs.expanders[i] && hs.expanders[i].isExpanded) hs.focusTopmost(); }, mouseClickHandler : function(e) { if (!e) e = window.event; if (e.button > 1) return true; if (!e.target) e.target = e.srcElement; var el = e.target; while (el.parentNode && !(/highslide-(image|move|html|resize)/.test(el.className))) { el = el.parentNode; } var exp = hs.getExpander(el); if (exp && (exp.isClosing || !exp.isExpanded)) return true; if (exp && e.type == 'mousedown') { if (e.target.form) return true; var match = el.className.match(/highslide-(image|move|resize)/); if (match) { hs.dragArgs = { exp: exp , type: match[1], left: exp.x.pos, width: exp.x.size, top: exp.y.pos, height: exp.y.size, clickX: e.clientX, clickY: e.clientY }; hs.addEventListener(document, 'mousemove', hs.dragHandler); if (e.preventDefault) e.preventDefault(); // FF if (/highslide-(image|html)-blur/.test(exp.content.className)) { exp.focus(); hs.hasFocused = true; } return false; } } else if (e.type == 'mouseup') { hs.removeEventListener(document, 'mousemove', hs.dragHandler); if (hs.dragArgs) { if (hs.styleRestoreCursor && hs.dragArgs.type == 'image') hs.dragArgs.exp.content.style.cursor = hs.styleRestoreCursor; var hasDragged = hs.dragArgs.hasDragged; if (!hasDragged &&!hs.hasFocused && !/(move|resize)/.test(hs.dragArgs.type)) { exp.close(); } else if (hasDragged || (!hasDragged && hs.hasHtmlExpanders)) { hs.dragArgs.exp.doShowHide('hidden'); } hs.hasFocused = false; hs.dragArgs = null; } else if (/highslide-image-blur/.test(el.className)) { el.style.cursor = hs.styleRestoreCursor; } } return false; }, dragHandler : function(e) { if (!hs.dragArgs) return true; if (!e) e = window.event; var a = hs.dragArgs, exp = a.exp; a.dX = e.clientX - a.clickX; a.dY = e.clientY - a.clickY; var distance = Math.sqrt(Math.pow(a.dX, 2) + Math.pow(a.dY, 2)); if (!a.hasDragged) a.hasDragged = (a.type != 'image' && distance > 0) || (distance > (hs.dragSensitivity || 5)); if (a.hasDragged && e.clientX > 5 && e.clientY > 5) { if (a.type == 'resize') exp.resize(a); else { exp.moveTo(a.left + a.dX, a.top + a.dY); if (a.type == 'image') exp.content.style.cursor = 'move'; } } return false; }, wrapperMouseHandler : function (e) { try { if (!e) e = window.event; var over = /mouseover/i.test(e.type); if (!e.target) e.target = e.srcElement; // ie if (hs.ie) e.relatedTarget = over ? e.fromElement : e.toElement; // ie var exp = hs.getExpander(e.target); if (!exp.isExpanded) return; if (!exp || !e.relatedTarget || hs.getExpander(e.relatedTarget, true) == exp || hs.dragArgs) return; for (var i = 0; i < exp.overlays.length; i++) (function() { var o = hs.$('hsId'+ exp.overlays[i]); if (o && o.hideOnMouseOut) { if (over) hs.setStyles(o, { visibility: 'visible', display: '' }); hs.animate(o, { opacity: over ? o.opacity : 0 }, o.dur); } })(); } catch (e) {} }, addEventListener : function (el, event, func) { if (el == document && event == 'ready') hs.push(hs.onReady, func); try { el.addEventListener(event, func, false); } catch (e) { try { el.detachEvent('on'+ event, func); el.attachEvent('on'+ event, func); } catch (e) { el['on'+ event] = func; } } }, removeEventListener : function (el, event, func) { try { el.removeEventListener(event, func, false); } catch (e) { try { el.detachEvent('on'+ event, func); } catch (e) { el['on'+ event] = null; } } }, preloadFullImage : function (i) { if (hs.continuePreloading && hs.preloadTheseImages[i] && hs.preloadTheseImages[i] != 'undefined') { var img = document.createElement('img'); img.onload = function() { img = null; hs.preloadFullImage(i + 1); }; img.src = hs.preloadTheseImages[i]; } }, preloadImages : function (number) { if (number && typeof number != 'object') hs.numberOfImagesToPreload = number; var arr = hs.getAnchors(); for (var i = 0; i < arr.images.length && i < hs.numberOfImagesToPreload; i++) { hs.push(hs.preloadTheseImages, hs.getSrc(arr.images[i])); } // preload outlines if (hs.outlineType) new hs.Outline(hs.outlineType, function () { hs.preloadFullImage(0)} ); else hs.preloadFullImage(0); // preload cursor if (hs.restoreCursor) var cur = hs.createElement('img', { src: hs.graphicsDir + hs.restoreCursor }); }, init : function () { if (!hs.container) { hs.getPageSize(); hs.ieLt7 = hs.ie && hs.uaVersion < 7; for (var x in hs.langDefaults) { if (typeof hs[x] != 'undefined') hs.lang[x] = hs[x]; else if (typeof hs.lang[x] == 'undefined' && typeof hs.langDefaults[x] != 'undefined') hs.lang[x] = hs.langDefaults[x]; } hs.container = hs.createElement('div', { className: 'highslide-container' }, { position: 'absolute', left: 0, top: 0, width: '100%', zIndex: hs.zIndexCounter, direction: 'ltr' }, document.body, true ); hs.loading = hs.createElement('a', { className: 'highslide-loading', title: hs.lang.loadingTitle, innerHTML: hs.lang.loadingText, href: 'javascript:;' }, { position: 'absolute', top: '-9999px', opacity: hs.loadingOpacity, zIndex: 1 }, hs.container ); hs.garbageBin = hs.createElement('div', null, { display: 'none' }, hs.container); hs.viewport = hs.createElement('div', { className: 'highslide-viewport highslide-viewport-size' }, { visibility: (hs.safari && hs.uaVersion < 525) ? 'visible' : 'hidden' }, hs.container, 1 ); // http://www.robertpenner.com/easing/ Math.linearTween = function (t, b, c, d) { return c*t/d + b; }; Math.easeInQuad = function (t, b, c, d) { return c*(t/=d)*t + b; }; Math.easeOutQuad = function (t, b, c, d) { return -c *(t/=d)*(t-2) + b; }; hs.hideSelects = hs.ieLt7; hs.hideIframes = ((window.opera && hs.uaVersion < 9) || navigator.vendor == 'KDE' || (hs.ie && hs.uaVersion < 5.5)); } }, ready : function() { if (hs.isReady) return; hs.isReady = true; for (var i = 0; i < hs.onReady.length; i++) hs.onReady[i](); }, updateAnchors : function() { var el, els, all = [], images = [],groups = {}, re; for (var i = 0; i < hs.openerTagNames.length; i++) { els = document.getElementsByTagName(hs.openerTagNames[i]); for (var j = 0; j < els.length; j++) { el = els[j]; re = hs.isHsAnchor(el); if (re) { hs.push(all, el); if (re[0] == 'hs.expand') hs.push(images, el); var g = hs.getParam(el, 'slideshowGroup') || 'none'; if (!groups[g]) groups[g] = []; hs.push(groups[g], el); } } } hs.anchors = { all: all, groups: groups, images: images }; return hs.anchors; }, getAnchors : function() { return hs.anchors || hs.updateAnchors(); }, close : function(el) { var exp = hs.getExpander(el); if (exp) exp.close(); return false; } }; // end hs object hs.fx = function( elem, options, prop ){ this.options = options; this.elem = elem; this.prop = prop; if (!options.orig) options.orig = {}; }; hs.fx.prototype = { update: function(){ (hs.fx.step[this.prop] || hs.fx.step._default)(this); if (this.options.step) this.options.step.call(this.elem, this.now, this); }, custom: function(from, to, unit){ this.startTime = (new Date()).getTime(); this.start = from; this.end = to; this.unit = unit;// || this.unit || "px"; this.now = this.start; this.pos = this.state = 0; var self = this; function t(gotoEnd){ return self.step(gotoEnd); } t.elem = this.elem; if ( t() && hs.timers.push(t) == 1 ) { hs.timerId = setInterval(function(){ var timers = hs.timers; for ( var i = 0; i < timers.length; i++ ) if ( !timers[i]() ) timers.splice(i--, 1); if ( !timers.length ) { clearInterval(hs.timerId); } }, 13); } }, step: function(gotoEnd){ var t = (new Date()).getTime(); if ( gotoEnd || t >= this.options.duration + this.startTime ) { this.now = this.end; this.pos = this.state = 1; this.update(); this.options.curAnim[ this.prop ] = true; var done = true; for ( var i in this.options.curAnim ) if ( this.options.curAnim[i] !== true ) done = false; if ( done ) { if (this.options.complete) this.options.complete.call(this.elem); } return false; } else { var n = t - this.startTime; this.state = n / this.options.duration; this.pos = this.options.easing(n, 0, 1, this.options.duration); this.now = this.start + ((this.end - this.start) * this.pos); this.update(); } return true; } }; hs.extend( hs.fx, { step: { opacity: function(fx){ hs.setStyles(fx.elem, { opacity: fx.now }); }, _default: function(fx){ try { if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) fx.elem.style[ fx.prop ] = fx.now + fx.unit; else fx.elem[ fx.prop ] = fx.now; } catch (e) {} } } }); hs.Outline = function (outlineType, onLoad) { this.onLoad = onLoad; this.outlineType = outlineType; var v = hs.uaVersion, tr; this.hasAlphaImageLoader = hs.ie && v >= 5.5 && v < 7; if (!outlineType) { if (onLoad) onLoad(); return; } hs.init(); this.table = hs.createElement( 'table', { cellSpacing: 0 }, { visibility: 'hidden', position: 'absolute', borderCollapse: 'collapse', width: 0 }, hs.container, true ); var tbody = hs.createElement('tbody', null, null, this.table, 1); this.td = []; for (var i = 0; i <= 8; i++) { if (i % 3 == 0) tr = hs.createElement('tr', null, { height: 'auto' }, tbody, true); this.td[i] = hs.createElement('td', null, null, tr, true); var style = i != 4 ? { lineHeight: 0, fontSize: 0} : { position : 'relative' }; hs.setStyles(this.td[i], style); } this.td[4].className = outlineType +' highslide-outline'; this.preloadGraphic(); }; hs.Outline.prototype = { preloadGraphic : function () { var src = hs.graphicsDir + (hs.outlinesDir || "outlines/")+ this.outlineType +".png"; var appendTo = hs.safari ? hs.container : null; this.graphic = hs.createElement('img', null, { position: 'absolute', top: '-9999px' }, appendTo, true); // for onload trigger var pThis = this; this.graphic.onload = function() { pThis.onGraphicLoad(); }; this.graphic.src = src; }, onGraphicLoad : function () { var o = this.offset = this.graphic.width / 4, pos = [[0,0],[0,-4],[-2,0],[0,-8],0,[-2,-8],[0,-2],[0,-6],[-2,-2]], dim = { height: (2*o) +'px', width: (2*o) +'px' }; for (var i = 0; i <= 8; i++) { if (pos[i]) { if (this.hasAlphaImageLoader) { var w = (i == 1 || i == 7) ? '100%' : this.graphic.width +'px'; var div = hs.createElement('div', null, { width: '100%', height: '100%', position: 'relative', overflow: 'hidden'}, this.td[i], true); hs.createElement ('div', null, { filter: "progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale, src='"+ this.graphic.src + "')", position: 'absolute', width: w, height: this.graphic.height +'px', left: (pos[i][0]*o)+'px', top: (pos[i][1]*o)+'px' }, div, true); } else { hs.setStyles(this.td[i], { background: 'url('+ this.graphic.src +') '+ (pos[i][0]*o)+'px '+(pos[i][1]*o)+'px'}); } if (window.opera && (i == 3 || i ==5)) hs.createElement('div', null, dim, this.td[i], true); hs.setStyles (this.td[i], dim); } } this.graphic = null; if (hs.pendingOutlines[this.outlineType]) hs.pendingOutlines[this.outlineType].destroy(); hs.pendingOutlines[this.outlineType] = this; if (this.onLoad) this.onLoad(); }, setPosition : function (pos, offset, vis, dur, easing) { var exp = this.exp, stl = exp.wrapper.style, offset = offset || 0, pos = pos || { x: exp.x.pos + offset, y: exp.y.pos + offset, w: exp.x.get('wsize') - 2 * offset, h: exp.y.get('wsize') - 2 * offset }; if (vis) this.table.style.visibility = (pos.h >= 4 * this.offset) ? 'visible' : 'hidden'; hs.setStyles(this.table, { left: (pos.x - this.offset) +'px', top: (pos.y - this.offset) +'px', width: (pos.w + 2 * this.offset) +'px' }); pos.w -= 2 * this.offset; pos.h -= 2 * this.offset; hs.setStyles (this.td[4], { width: pos.w >= 0 ? pos.w +'px' : 0, height: pos.h >= 0 ? pos.h +'px' : 0 }); if (this.hasAlphaImageLoader) this.td[3].style.height = this.td[5].style.height = this.td[4].style.height; }, destroy : function(hide) { if (hide) this.table.style.visibility = 'hidden'; else hs.discardElement(this.table); } }; hs.Dimension = function(exp, dim) { this.exp = exp; this.dim = dim; this.ucwh = dim == 'x' ? 'Width' : 'Height'; this.wh = this.ucwh.toLowerCase(); this.uclt = dim == 'x' ? 'Left' : 'Top'; this.lt = this.uclt.toLowerCase(); this.ucrb = dim == 'x' ? 'Right' : 'Bottom'; this.rb = this.ucrb.toLowerCase(); this.p1 = this.p2 = 0; }; hs.Dimension.prototype = { get : function(key) { switch (key) { case 'loadingPos': return this.tpos + this.tb + (this.t - hs.loading['offset'+ this.ucwh]) / 2; case 'loadingPosXfade': return this.pos + this.cb+ this.p1 + (this.size - hs.loading['offset'+ this.ucwh]) / 2; case 'wsize': return this.size + 2 * this.cb + this.p1 + this.p2; case 'fitsize': return this.clientSize - this.marginMin - this.marginMax; case 'maxsize': return this.get('fitsize') - 2 * this.cb - this.p1 - this.p2 ; case 'opos': return this.pos - (this.exp.outline ? this.exp.outline.offset : 0); case 'osize': return this.get('wsize') + (this.exp.outline ? 2*this.exp.outline.offset : 0); case 'imgPad': return this.imgSize ? Math.round((this.size - this.imgSize) / 2) : 0; } }, calcBorders: function() { // correct for borders this.cb = (this.exp.content['offset'+ this.ucwh] - this.t) / 2; this.marginMax = hs['margin'+ this.ucrb]; }, calcThumb: function() { this.t = this.exp.el[this.wh] ? parseInt(this.exp.el[this.wh]) : this.exp.el['offset'+ this.ucwh]; this.tpos = this.exp.tpos[this.dim]; this.tb = (this.exp.el['offset'+ this.ucwh] - this.t) / 2; if (this.tpos == 0 || this.tpos == -1) { this.tpos = (hs.page[this.wh] / 2) + hs.page['scroll'+ this.uclt]; }; }, calcExpanded: function() { var exp = this.exp; this.justify = 'auto'; // get alignment if (exp.align == 'center') this.justify = 'center'; else if (new RegExp(this.lt).test(exp.anchor)) this.justify = null; else if (new RegExp(this.rb).test(exp.anchor)) this.justify = 'max'; // size and position this.pos = this.tpos - this.cb + this.tb; if (this.maxHeight && this.dim == 'x') exp.maxWidth = Math.min(exp.maxWidth || this.full, exp.maxHeight * this.full / exp.y.full); this.size = Math.min(this.full, exp['max'+ this.ucwh] || this.full); this.minSize = exp.allowSizeReduction ? Math.min(exp['min'+ this.ucwh], this.full) :this.full; if (exp.isImage && exp.useBox) { this.size = exp[this.wh]; this.imgSize = this.full; } if (this.dim == 'x' && hs.padToMinWidth) this.minSize = exp.minWidth; this.target = exp['target'+ this.dim.toUpperCase()]; this.marginMin = hs['margin'+ this.uclt]; this.scroll = hs.page['scroll'+ this.uclt]; this.clientSize = hs.page[this.wh]; }, setSize: function(i) { var exp = this.exp; if (exp.isImage && (exp.useBox || hs.padToMinWidth)) { this.imgSize = i; this.size = Math.max(this.size, this.imgSize); exp.content.style[this.lt] = this.get('imgPad')+'px'; } else this.size = i; exp.content.style[this.wh] = i +'px'; exp.wrapper.style[this.wh] = this.get('wsize') +'px'; if (exp.outline) exp.outline.setPosition(); if (this.dim == 'x' && exp.overlayBox) exp.sizeOverlayBox(true); if (this.dim == 'x' && exp.slideshow && exp.isImage) { if (i == this.full) exp.slideshow.disable('full-expand'); else exp.slideshow.enable('full-expand'); } }, setPos: function(i) { this.pos = i; this.exp.wrapper.style[this.lt] = i +'px'; if (this.exp.outline) this.exp.outline.setPosition(); } }; hs.Expander = function(a, params, custom, contentType) { if (document.readyState && hs.ie && !hs.isReady) { hs.addEventListener(document, 'ready', function() { new hs.Expander(a, params, custom, contentType); }); return; } this.a = a; this.custom = custom; this.contentType = contentType || 'image'; this.isImage = !this.isHtml; hs.continuePreloading = false; this.overlays = []; this.last = hs.last; hs.last = null; hs.init(); var key = this.key = hs.expanders.length; // override inline parameters for (var i = 0; i < hs.overrides.length; i++) { var name = hs.overrides[i]; this[name] = params && typeof params[name] != 'undefined' ? params[name] : hs[name]; } if (!this.src) this.src = a.href; // get thumb var el = (params && params.thumbnailId) ? hs.$(params.thumbnailId) : a; el = this.thumb = el.getElementsByTagName('img')[0] || el; this.thumbsUserSetId = el.id || a.id; // check if already open for (var i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && hs.expanders[i].a == a && !(this.last && this.transitions[1] == 'crossfade')) { hs.expanders[i].focus(); return false; } } // cancel other if (!hs.allowSimultaneousLoading) for (var i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && hs.expanders[i].thumb != el && !hs.expanders[i].onLoadStarted) { hs.expanders[i].cancelLoading(); } } hs.expanders[key] = this; if (!hs.allowMultipleInstances && !hs.upcoming) { if (hs.expanders[key-1]) hs.expanders[key-1].close(); if (typeof hs.focusKey != 'undefined' && hs.expanders[hs.focusKey]) hs.expanders[hs.focusKey].close(); } // initiate metrics this.el = el; this.tpos = hs.getPosition(el); hs.getPageSize(); var x = this.x = new hs.Dimension(this, 'x'); x.calcThumb(); var y = this.y = new hs.Dimension(this, 'y'); y.calcThumb(); this.wrapper = hs.createElement( 'div', { id: 'highslide-wrapper-'+ this.key, className: 'highslide-wrapper '+ this.wrapperClassName }, { visibility: 'hidden', position: 'absolute', zIndex: hs.zIndexCounter += 2 }, null, true ); this.wrapper.onmouseover = this.wrapper.onmouseout = hs.wrapperMouseHandler; if (this.contentType == 'image' && this.outlineWhileAnimating == 2) this.outlineWhileAnimating = 0; // get the outline if (!this.outlineType || (this.last && this.isImage && this.transitions[1] == 'crossfade')) { this[this.contentType +'Create'](); } else if (hs.pendingOutlines[this.outlineType]) { this.connectOutline(); this[this.contentType +'Create'](); } else { this.showLoading(); var exp = this; new hs.Outline(this.outlineType, function () { exp.connectOutline(); exp[exp.contentType +'Create'](); } ); } return true; }; hs.Expander.prototype = { error : function(e) { // alert ('Line '+ e.lineNumber +': '+ e.message); window.location.href = this.src; }, connectOutline : function() { var outline = this.outline = hs.pendingOutlines[this.outlineType]; outline.exp = this; outline.table.style.zIndex = this.wrapper.style.zIndex - 1; hs.pendingOutlines[this.outlineType] = null; }, showLoading : function() { if (this.onLoadStarted || this.loading) return; this.loading = hs.loading; var exp = this; this.loading.onclick = function() { exp.cancelLoading(); }; var exp = this, l = this.x.get('loadingPos') +'px', t = this.y.get('loadingPos') +'px'; if (!tgt && this.last && this.transitions[1] == 'crossfade') var tgt = this.last; if (tgt) { l = tgt.x.get('loadingPosXfade') +'px'; t = tgt.y.get('loadingPosXfade') +'px'; this.loading.style.zIndex = hs.zIndexCounter++; } setTimeout(function () { if (exp.loading) hs.setStyles(exp.loading, { left: l, top: t, zIndex: hs.zIndexCounter++ })} , 100); }, imageCreate : function() { var exp = this; var img = document.createElement('img'); this.content = img; img.onload = function () { if (hs.expanders[exp.key]) exp.contentLoaded(); }; if (hs.blockRightClick) img.oncontextmenu = function() { return false; }; img.className = 'highslide-image'; hs.setStyles(img, { visibility: 'hidden', display: 'block', position: 'absolute', maxWidth: '9999px', zIndex: 3 }); img.title = hs.lang.restoreTitle; if (hs.safari) hs.container.appendChild(img); if (hs.ie && hs.flushImgSize) img.src = null; img.src = this.src; this.showLoading(); }, contentLoaded : function() { try { if (!this.content) return; this.content.onload = null; if (this.onLoadStarted) return; else this.onLoadStarted = true; var x = this.x, y = this.y; if (this.loading) { hs.setStyles(this.loading, { top: '-9999px' }); this.loading = null; } x.full = this.content.width; y.full = this.content.height; hs.setStyles(this.content, { width: x.t +'px', height: y.t +'px' }); this.wrapper.appendChild(this.content); hs.container.appendChild(this.wrapper); x.calcBorders(); y.calcBorders(); hs.setStyles (this.wrapper, { left: (x.tpos + x.tb - x.cb) +'px', top: (y.tpos + x.tb - y.cb) +'px' }); this.initSlideshow(); this.getOverlays(); var ratio = x.full / y.full; x.calcExpanded(); this.justify(x); y.calcExpanded(); this.justify(y); if (this.overlayBox) this.sizeOverlayBox(0, 1); if (this.allowSizeReduction) { this.correctRatio(ratio); var ss = this.slideshow; if (ss && this.last && ss.controls && ss.fixedControls) { var pos = ss.overlayOptions.position || '', p; for (var dim in hs.oPos) for (var i = 0; i < 5; i++) { p = this[dim]; if (pos.match(hs.oPos[dim][i])) { p.pos = this.last[dim].pos + (this.last[dim].p1 - p.p1) + (this.last[dim].size - p.size) * [0, 0, .5, 1, 1][i]; if (ss.fixedControls == 'fit') { if (p.pos + p.size + p.p1 + p.p2 > p.scroll + p.clientSize - p.marginMax) p.pos = p.scroll + p.clientSize - p.size - p.marginMin - p.marginMax - p.p1 - p.p2; if (p.pos < p.scroll + p.marginMin) p.pos = p.scroll + p.marginMin; } } } } if (this.isImage && this.x.full > (this.x.imgSize || this.x.size)) { this.createFullExpand(); if (this.overlays.length == 1) this.sizeOverlayBox(); } } this.show(); } catch (e) { this.error(e); } }, justify : function (p, moveOnly) { var tgtArr, tgt = p.target, dim = p == this.x ? 'x' : 'y'; if (tgt && tgt.match(/ /)) { tgtArr = tgt.split(' '); tgt = tgtArr[0]; } if (tgt && hs.$(tgt)) { p.pos = hs.getPosition(hs.$(tgt))[dim]; if (tgtArr && tgtArr[1] && tgtArr[1].match(/^[-]?[0-9]+px$/)) p.pos += parseInt(tgtArr[1]); if (p.size < p.minSize) p.size = p.minSize; } else if (p.justify == 'auto' || p.justify == 'center') { var hasMovedMin = false; var allowReduce = p.exp.allowSizeReduction; if (p.justify == 'center') p.pos = Math.round(p.scroll + (p.clientSize + p.marginMin - p.marginMax - p.get('wsize')) / 2); else p.pos = Math.round(p.pos - ((p.get('wsize') - p.t) / 2)); if (p.pos < p.scroll + p.marginMin) { p.pos = p.scroll + p.marginMin; hasMovedMin = true; } if (!moveOnly && p.size < p.minSize) { p.size = p.minSize; allowReduce = false; } if (p.pos + p.get('wsize') > p.scroll + p.clientSize - p.marginMax) { if (!moveOnly && hasMovedMin && allowReduce) { p.size = Math.min(p.size, p.get(dim == 'y' ? 'fitsize' : 'maxsize')); } else if (p.get('wsize') < p.get('fitsize')) { p.pos = p.scroll + p.clientSize - p.marginMax - p.get('wsize'); } else { // image larger than viewport p.pos = p.scroll + p.marginMin; if (!moveOnly && allowReduce) p.size = p.get(dim == 'y' ? 'fitsize' : 'maxsize'); } } if (!moveOnly && p.size < p.minSize) { p.size = p.minSize; allowReduce = false; } } else if (p.justify == 'max') { p.pos = Math.floor(p.pos - p.size + p.t); } if (p.pos < p.marginMin) { var tmpMin = p.pos; p.pos = p.marginMin; if (allowReduce && !moveOnly) p.size = p.size - (p.pos - tmpMin); } }, correctRatio : function(ratio) { var x = this.x, y = this.y, changed = false, xSize = Math.min(x.full, x.size), ySize = Math.min(y.full, y.size), useBox = (this.useBox || hs.padToMinWidth); if (xSize / ySize > ratio) { // width greater xSize = ySize * ratio; if (xSize < x.minSize) { // below minWidth xSize = x.minSize; ySize = xSize / ratio; } changed = true; } else if (xSize / ySize < ratio) { // height greater ySize = xSize / ratio; changed = true; } if (hs.padToMinWidth && x.full < x.minSize) { x.imgSize = x.full; y.size = y.imgSize = y.full; } else if (this.useBox) { x.imgSize = xSize; y.imgSize = ySize; } else { x.size = xSize; y.size = ySize; } changed = this.fitOverlayBox(useBox ? null : ratio, changed); if (useBox && y.size < y.imgSize) { y.imgSize = y.size; x.imgSize = y.size * ratio; } if (changed || useBox) { x.pos = x.tpos - x.cb + x.tb; x.minSize = x.size; this.justify(x, true); y.pos = y.tpos - y.cb + y.tb; y.minSize = y.size; this.justify(y, true); if (this.overlayBox) this.sizeOverlayBox(); } }, fitOverlayBox : function(ratio, changed) { var x = this.x, y = this.y; if (this.overlayBox) { while (y.size > this.minHeight && x.size > this.minWidth && y.get('wsize') > y.get('fitsize')) { y.size -= 10; if (ratio) x.size = y.size * ratio; this.sizeOverlayBox(0, 1); changed = true; } } return changed; }, show : function () { var x = this.x, y = this.y; this.doShowHide('hidden'); if (this.slideshow && this.slideshow.thumbstrip) this.slideshow.thumbstrip.selectThumb(); // Apply size change this.changeSize( 1, { wrapper: { width : x.get('wsize'), height : y.get('wsize'), left: x.pos, top: y.pos }, content: { left: x.p1 + x.get('imgPad'), top: y.p1 + y.get('imgPad'), width:x.imgSize ||x.size, height:y.imgSize ||y.size } }, hs.expandDuration ); }, changeSize : function(up, to, dur) { // transition var trans = this.transitions, other = up ? (this.last ? this.last.a : null) : hs.upcoming, t = (trans[1] && other && hs.getParam(other, 'transitions')[1] == trans[1]) ? trans[1] : trans[0]; if (this[t] && t != 'expand') { this[t](up, to); return; } if (this.outline && !this.outlineWhileAnimating) { if (up) this.outline.setPosition(); else this.outline.destroy(); } if (!up) this.destroyOverlays(); var exp = this, x = exp.x, y = exp.y, easing = this.easing; if (!up) easing = this.easingClose || easing; var after = up ? function() { if (exp.outline) exp.outline.table.style.visibility = "visible"; setTimeout(function() { exp.afterExpand(); }, 50); } : function() { exp.afterClose(); }; if (up) hs.setStyles( this.wrapper, { width: x.t +'px', height: y.t +'px' }); if (this.fadeInOut) { hs.setStyles(this.wrapper, { opacity: up ? 0 : 1 }); hs.extend(to.wrapper, { opacity: up }); } hs.animate( this.wrapper, to.wrapper, { duration: dur, easing: easing, step: function(val, args) { if (exp.outline && exp.outlineWhileAnimating && args.prop == 'top') { var fac = up ? args.pos : 1 - args.pos; var pos = { w: x.t + (x.get('wsize') - x.t) * fac, h: y.t + (y.get('wsize') - y.t) * fac, x: x.tpos + (x.pos - x.tpos) * fac, y: y.tpos + (y.pos - y.tpos) * fac }; exp.outline.setPosition(pos, 0, 1); } } }); hs.animate( this.content, to.content, dur, easing, after); if (up) { this.wrapper.style.visibility = 'visible'; this.content.style.visibility = 'visible'; this.a.className += ' highslide-active-anchor'; } }, fade : function(up, to) { this.outlineWhileAnimating = false; var exp = this, t = up ? hs.expandDuration : 0; if (up) { hs.animate(this.wrapper, to.wrapper, 0); hs.setStyles(this.wrapper, { opacity: 0, visibility: 'visible' }); hs.animate(this.content, to.content, 0); this.content.style.visibility = 'visible'; hs.animate(this.wrapper, { opacity: 1 }, t, null, function() { exp.afterExpand(); }); } if (this.outline) { this.outline.table.style.zIndex = this.wrapper.style.zIndex; var dir = up || -1, offset = this.outline.offset, startOff = up ? 3 : offset, endOff = up? offset : 3; for (var i = startOff; dir * i <= dir * endOff; i += dir, t += 25) { (function() { var o = up ? endOff - i : startOff - i; setTimeout(function() { exp.outline.setPosition(0, o, 1); }, t); })(); } } if (up) {}//setTimeout(function() { exp.afterExpand(); }, t+50); else { setTimeout( function() { if (exp.outline) exp.outline.destroy(exp.preserveContent); exp.destroyOverlays(); hs.animate( exp.wrapper, { opacity: 0 }, hs.restoreDuration, null, function(){ exp.afterClose(); }); }, t); } }, crossfade : function (up, to, from) { if (!up) return; var exp = this, last = this.last, x = this.x, y = this.y, lastX = last.x, lastY = last.y, wrapper = this.wrapper, content = this.content, overlayBox = this.overlayBox; hs.removeEventListener(document, 'mousemove', hs.dragHandler); hs.setStyles(content, { width: (x.imgSize || x.size) +'px', height: (y.imgSize || y.size) +'px' }); if (overlayBox) overlayBox.style.overflow = 'visible'; this.outline = last.outline; if (this.outline) this.outline.exp = exp; last.outline = null; var fadeBox = hs.createElement('div', { className: 'highslide-image' }, { position: 'absolute', zIndex: 4, overflow: 'hidden', display: 'none' } ); var names = { oldImg: last, newImg: this }; for (var n in names) { this[n] = names[n].content.cloneNode(1); hs.setStyles(this[n], { position: 'absolute', border: 0, visibility: 'visible' }); fadeBox.appendChild(this[n]); } wrapper.appendChild(fadeBox); if (overlayBox) { overlayBox.className = ''; wrapper.appendChild(overlayBox); } fadeBox.style.display = ''; last.content.style.display = 'none'; if (hs.safari) { var match = navigator.userAgent.match(/Safari\/([0-9]{3})/); if (match && parseInt(match[1]) < 525) this.wrapper.style.visibility = 'visible'; } hs.animate(wrapper, { width: x.size }, { duration: hs.transitionDuration, step: function(val, args) { var pos = args.pos, invPos = 1 - pos; var prop, size = {}, props = ['pos', 'size', 'p1', 'p2']; for (var n in props) { prop = props[n]; size['x'+ prop] = Math.round(invPos * lastX[prop] + pos * x[prop]); size['y'+ prop] = Math.round(invPos * lastY[prop] + pos * y[prop]); size.ximgSize = Math.round( invPos * (lastX.imgSize || lastX.size) + pos * (x.imgSize || x.size)); size.ximgPad = Math.round(invPos * lastX.get('imgPad') + pos * x.get('imgPad')); size.yimgSize = Math.round( invPos * (lastY.imgSize || lastY.size) + pos * (y.imgSize || y.size)); size.yimgPad = Math.round(invPos * lastY.get('imgPad') + pos * y.get('imgPad')); } if (exp.outline) exp.outline.setPosition({ x: size.xpos, y: size.ypos, w: size.xsize + size.xp1 + size.xp2 + 2 * x.cb, h: size.ysize + size.yp1 + size.yp2 + 2 * y.cb }); last.wrapper.style.clip = 'rect(' + (size.ypos - lastY.pos)+'px, ' + (size.xsize + size.xp1 + size.xp2 + size.xpos + 2 * lastX.cb - lastX.pos) +'px, ' + (size.ysize + size.yp1 + size.yp2 + size.ypos + 2 * lastY.cb - lastY.pos) +'px, ' + (size.xpos - lastX.pos)+'px)'; hs.setStyles(content, { top: (size.yp1 + y.get('imgPad')) +'px', left: (size.xp1 + x.get('imgPad')) +'px', marginTop: (y.pos - size.ypos) +'px', marginLeft: (x.pos - size.xpos) +'px' }); hs.setStyles(wrapper, { top: size.ypos +'px', left: size.xpos +'px', width: (size.xp1 + size.xp2 + size.xsize + 2 * x.cb)+ 'px', height: (size.yp1 + size.yp2 + size.ysize + 2 * y.cb) + 'px' }); hs.setStyles(fadeBox, { width: (size.ximgSize || size.xsize) + 'px', height: (size.yimgSize || size.ysize) +'px', left: (size.xp1 + size.ximgPad) +'px', top: (size.yp1 + size.yimgPad) +'px', visibility: 'visible' }); hs.setStyles(exp.oldImg, { top: (lastY.pos - size.ypos + lastY.p1 - size.yp1 + lastY.get('imgPad') - size.yimgPad)+'px', left: (lastX.pos - size.xpos + lastX.p1 - size.xp1 + lastX.get('imgPad') - size.ximgPad)+'px' }); hs.setStyles(exp.newImg, { opacity: pos, top: (y.pos - size.ypos + y.p1 - size.yp1 + y.get('imgPad') - size.yimgPad) +'px', left: (x.pos - size.xpos + x.p1 - size.xp1 + x.get('imgPad') - size.ximgPad) +'px' }); if (overlayBox) hs.setStyles(overlayBox, { width: size.xsize + 'px', height: size.ysize +'px', left: (size.xp1 + x.cb) +'px', top: (size.yp1 + y.cb) +'px' }); }, complete: function () { wrapper.style.visibility = content.style.visibility = 'visible'; content.style.display = 'block'; fadeBox.style.display = 'none'; exp.a.className += ' highslide-active-anchor'; exp.afterExpand(); last.afterClose(); exp.last = null; } }); }, reuseOverlay : function(o, el) { if (!this.last) return false; for (var i = 0; i < this.last.overlays.length; i++) { var oDiv = hs.$('hsId'+ this.last.overlays[i]); if (oDiv && oDiv.hsId == o.hsId) { this.genOverlayBox(); oDiv.reuse = this.key; hs.push(this.overlays, this.last.overlays[i]); return true; } } return false; }, afterExpand : function() { this.isExpanded = true; this.focus(); if (this.dimmingOpacity) hs.dim(this); if (hs.upcoming && hs.upcoming == this.a) hs.upcoming = null; this.prepareNextOutline(); var p = hs.page, mX = hs.mouse.x + p.scrollLeft, mY = hs.mouse.y + p.scrollTop; this.mouseIsOver = this.x.pos < mX && mX < this.x.pos + this.x.get('wsize') && this.y.pos < mY && mY < this.y.pos + this.y.get('wsize'); if (this.overlayBox) this.showOverlays(); }, prepareNextOutline : function() { var key = this.key; var outlineType = this.outlineType; new hs.Outline(outlineType, function () { try { hs.expanders[key].preloadNext(); } catch (e) {} }); }, preloadNext : function() { var next = this.getAdjacentAnchor(1); if (next && next.onclick.toString().match(/hs\.expand/)) var img = hs.createElement('img', { src: hs.getSrc(next) }); }, getAdjacentAnchor : function(op) { var current = this.getAnchorIndex(), as = hs.anchors.groups[this.slideshowGroup || 'none']; /*< ? if ($cfg->slideshow) : ?>s*/ if (!as[current + op] && this.slideshow && this.slideshow.repeat) { if (op == 1) return as[0]; else if (op == -1) return as[as.length-1]; } /*< ? endif ?>s*/ return as[current + op] || null; }, getAnchorIndex : function() { var arr = hs.getAnchors().groups[this.slideshowGroup || 'none']; if (arr) for (var i = 0; i < arr.length; i++) { if (arr[i] == this.a) return i; } return null; }, getNumber : function() { if (this[this.numberPosition]) { var arr = hs.anchors.groups[this.slideshowGroup || 'none']; if (arr) { var s = hs.lang.number.replace('%1', this.getAnchorIndex() + 1).replace('%2', arr.length); this[this.numberPosition].innerHTML = '<div class="highslide-number">'+ s +'</div>'+ this[this.numberPosition].innerHTML; } } }, initSlideshow : function() { if (!this.last) { for (var i = 0; i < hs.slideshows.length; i++) { var ss = hs.slideshows[i], sg = ss.slideshowGroup; if (typeof sg == 'undefined' || sg === null || sg === this.slideshowGroup) this.slideshow = new hs.Slideshow(this.key, ss); } } else { this.slideshow = this.last.slideshow; } var ss = this.slideshow; if (!ss) return; var key = ss.expKey = this.key; ss.checkFirstAndLast(); ss.disable('full-expand'); if (ss.controls) { var o = ss.overlayOptions || {}; o.overlayId = ss.controls; o.hsId = 'controls'; this.createOverlay(o); } if (ss.thumbstrip) ss.thumbstrip.add(this); if (!this.last && this.autoplay) ss.play(true); if (ss.autoplay) { ss.autoplay = setTimeout(function() { hs.next(key); }, (ss.interval || 500)); } }, cancelLoading : function() { hs.discardElement (this.wrapper); hs.expanders[this.key] = null; if (hs.upcoming == this.a) hs.upcoming = null; hs.undim(this.key); if (this.loading) hs.loading.style.left = '-9999px'; }, writeCredits : function () { if (this.credits) return; this.credits = hs.createElement('a', { href: hs.creditsHref, target: hs.creditsTarget, className: 'highslide-credits', innerHTML: hs.lang.creditsText, title: hs.lang.creditsTitle }); this.createOverlay({ overlayId: this.credits, position: this.creditsPosition || 'top left', hsId: 'credits' }); }, getInline : function(types, addOverlay) { for (var i = 0; i < types.length; i++) { var type = types[i], s = null; if (!this[type +'Id'] && this.thumbsUserSetId) this[type +'Id'] = type +'-for-'+ this.thumbsUserSetId; if (this[type +'Id']) this[type] = hs.getNode(this[type +'Id']); if (!this[type] && !this[type +'Text'] && this[type +'Eval']) try { s = eval(this[type +'Eval']); } catch (e) {} if (!this[type] && this[type +'Text']) { s = this[type +'Text']; } if (!this[type] && !s) { this[type] = hs.getNode(this.a['_'+ type + 'Id']); if (!this[type]) { var next = this.a.nextSibling; while (next && !hs.isHsAnchor(next)) { if ((new RegExp('highslide-'+ type)).test(next.className || null)) { if (!next.id) this.a['_'+ type + 'Id'] = next.id = 'hsId'+ hs.idCounter++; this[type] = hs.getNode(next.id); break; } next = next.nextSibling; } } } if (!this[type] && !s && this.numberPosition == type) s = '\n'; if (!this[type] && s) this[type] = hs.createElement('div', { className: 'highslide-'+ type, innerHTML: s } ); if (addOverlay && this[type]) { var o = { position: (type == 'heading') ? 'above' : 'below' }; for (var x in this[type+'Overlay']) o[x] = this[type+'Overlay'][x]; o.overlayId = this[type]; this.createOverlay(o); } } }, // on end move and resize doShowHide : function(visibility) { if (hs.hideSelects) this.showHideElements('SELECT', visibility); if (hs.hideIframes) this.showHideElements('IFRAME', visibility); if (hs.geckoMac) this.showHideElements('*', visibility); }, showHideElements : function (tagName, visibility) { var els = document.getElementsByTagName(tagName); var prop = tagName == '*' ? 'overflow' : 'visibility'; for (var i = 0; i < els.length; i++) { if (prop == 'visibility' || (document.defaultView.getComputedStyle( els[i], "").getPropertyValue('overflow') == 'auto' || els[i].getAttribute('hidden-by') != null)) { var hiddenBy = els[i].getAttribute('hidden-by'); if (visibility == 'visible' && hiddenBy) { hiddenBy = hiddenBy.replace('['+ this.key +']', ''); els[i].setAttribute('hidden-by', hiddenBy); if (!hiddenBy) els[i].style[prop] = els[i].origProp; } else if (visibility == 'hidden') { // hide if behind var elPos = hs.getPosition(els[i]); elPos.w = els[i].offsetWidth; elPos.h = els[i].offsetHeight; if (!this.dimmingOpacity) { // hide all if dimming var clearsX = (elPos.x + elPos.w < this.x.get('opos') || elPos.x > this.x.get('opos') + this.x.get('osize')); var clearsY = (elPos.y + elPos.h < this.y.get('opos') || elPos.y > this.y.get('opos') + this.y.get('osize')); } var wrapperKey = hs.getWrapperKey(els[i]); if (!clearsX && !clearsY && wrapperKey != this.key) { // element falls behind image if (!hiddenBy) { els[i].setAttribute('hidden-by', '['+ this.key +']'); els[i].origProp = els[i].style[prop]; els[i].style[prop] = 'hidden'; } else if (hiddenBy.indexOf('['+ this.key +']') == -1) { els[i].setAttribute('hidden-by', hiddenBy + '['+ this.key +']'); } } else if ((hiddenBy == '['+ this.key +']' || hs.focusKey == wrapperKey) && wrapperKey != this.key) { // on move els[i].setAttribute('hidden-by', ''); els[i].style[prop] = els[i].origProp || ''; } else if (hiddenBy && hiddenBy.indexOf('['+ this.key +']') > -1) { els[i].setAttribute('hidden-by', hiddenBy.replace('['+ this.key +']', '')); } } } } }, focus : function() { this.wrapper.style.zIndex = hs.zIndexCounter += 2; // blur others for (var i = 0; i < hs.expanders.length; i++) { if (hs.expanders[i] && i == hs.focusKey) { var blurExp = hs.expanders[i]; blurExp.content.className += ' highslide-'+ blurExp.contentType +'-blur'; blurExp.content.style.cursor = hs.ie ? 'hand' : 'pointer'; blurExp.content.title = hs.lang.focusTitle; } } // focus this if (this.outline) this.outline.table.style.zIndex = this.wrapper.style.zIndex - 1; this.content.className = 'highslide-'+ this.contentType; this.content.title = hs.lang.restoreTitle; if (hs.restoreCursor) { hs.styleRestoreCursor = window.opera ? 'pointer' : 'url('+ hs.graphicsDir + hs.restoreCursor +'), pointer'; if (hs.ie && hs.uaVersion < 6) hs.styleRestoreCursor = 'hand'; this.content.style.cursor = hs.styleRestoreCursor; } hs.focusKey = this.key; hs.addEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler); }, moveTo: function(x, y) { this.x.setPos(x); this.y.setPos(y); }, resize : function (e) { var w, h, r = e.width / e.height; w = Math.max(e.width + e.dX, Math.min(this.minWidth, this.x.full)); if (this.isImage && Math.abs(w - this.x.full) < 12) w = this.x.full; h = w / r; if (h < Math.min(this.minHeight, this.y.full)) { h = Math.min(this.minHeight, this.y.full); if (this.isImage) w = h * r; } this.resizeTo(w, h); }, resizeTo: function(w, h) { this.y.setSize(h); this.x.setSize(w); this.wrapper.style.height = this.y.get('wsize') +'px'; }, close : function() { if (this.isClosing || !this.isExpanded) return; if (this.transitions[1] == 'crossfade' && hs.upcoming) { hs.getExpander(hs.upcoming).cancelLoading(); hs.upcoming = null; } this.isClosing = true; if (this.slideshow && !hs.upcoming) this.slideshow.pause(); hs.removeEventListener(document, window.opera ? 'keypress' : 'keydown', hs.keyHandler); try { this.content.style.cursor = 'default'; this.changeSize( 0, { wrapper: { width : this.x.t, height : this.y.t, left: this.x.tpos - this.x.cb + this.x.tb, top: this.y.tpos - this.y.cb + this.y.tb }, content: { left: 0, top: 0, width: this.x.t, height: this.y.t } }, hs.restoreDuration ); } catch (e) { this.afterClose(); } }, createOverlay : function (o) { var el = o.overlayId, relToVP = (o.relativeTo == 'viewport' && !/panel$/.test(o.position)); if (typeof el == 'string') el = hs.getNode(el); if (o.html) el = hs.createElement('div', { innerHTML: o.html }); if (!el || typeof el == 'string') return; el.style.display = 'block'; o.hsId = o.hsId || o.overlayId; if (this.transitions[1] == 'crossfade' && this.reuseOverlay(o, el)) return; this.genOverlayBox(); var width = o.width && /^[0-9]+(px|%)$/.test(o.width) ? o.width : 'auto'; if (/^(left|right)panel$/.test(o.position) && !/^[0-9]+px$/.test(o.width)) width = '200px'; var overlay = hs.createElement( 'div', { id: 'hsId'+ hs.idCounter++, hsId: o.hsId }, { position: 'absolute', visibility: 'hidden', width: width, direction: hs.lang.cssDirection || '', opacity: 0 }, relToVP ? hs.viewport :this.overlayBox, true ); if (relToVP) overlay.hsKey = this.key; overlay.appendChild(el); hs.extend(overlay, { opacity: 1, offsetX: 0, offsetY: 0, dur: (o.fade === 0 || o.fade === false || (o.fade == 2 && hs.ie)) ? 0 : 250 }); hs.extend(overlay, o); if (this.gotOverlays) { this.positionOverlay(overlay); if (!overlay.hideOnMouseOut || this.mouseIsOver) hs.animate(overlay, { opacity: overlay.opacity }, overlay.dur); } hs.push(this.overlays, hs.idCounter - 1); }, positionOverlay : function(overlay) { var p = overlay.position || 'middle center', relToVP = (overlay.relativeTo == 'viewport'), offX = overlay.offsetX, offY = overlay.offsetY; if (relToVP) { hs.viewport.style.display = 'block'; overlay.hsKey = this.key; if (overlay.offsetWidth > overlay.parentNode.offsetWidth) overlay.style.width = '100%'; } else if (overlay.parentNode != this.overlayBox) this.overlayBox.appendChild(overlay); if (/left$/.test(p)) overlay.style.left = offX +'px'; if (/center$/.test(p)) hs.setStyles (overlay, { left: '50%', marginLeft: (offX - Math.round(overlay.offsetWidth / 2)) +'px' }); if (/right$/.test(p)) overlay.style.right = - offX +'px'; if (/^leftpanel$/.test(p)) { hs.setStyles(overlay, { right: '100%', marginRight: this.x.cb +'px', top: - this.y.cb +'px', bottom: - this.y.cb +'px', overflow: 'auto' }); this.x.p1 = overlay.offsetWidth; } else if (/^rightpanel$/.test(p)) { hs.setStyles(overlay, { left: '100%', marginLeft: this.x.cb +'px', top: - this.y.cb +'px', bottom: - this.y.cb +'px', overflow: 'auto' }); this.x.p2 = overlay.offsetWidth; } var parOff = overlay.parentNode.offsetHeight; overlay.style.height = 'auto'; if (relToVP && overlay.offsetHeight > parOff) overlay.style.height = hs.ieLt7 ? parOff +'px' : '100%'; if (/^top/.test(p)) overlay.style.top = offY +'px'; if (/^middle/.test(p)) hs.setStyles (overlay, { top: '50%', marginTop: (offY - Math.round(overlay.offsetHeight / 2)) +'px' }); if (/^bottom/.test(p)) overlay.style.bottom = - offY +'px'; if (/^above$/.test(p)) { hs.setStyles(overlay, { left: (- this.x.p1 - this.x.cb) +'px', right: (- this.x.p2 - this.x.cb) +'px', bottom: '100%', marginBottom: this.y.cb +'px', width: 'auto' }); this.y.p1 = overlay.offsetHeight; } else if (/^below$/.test(p)) { hs.setStyles(overlay, { position: 'relative', left: (- this.x.p1 - this.x.cb) +'px', right: (- this.x.p2 - this.x.cb) +'px', top: '100%', marginTop: this.y.cb +'px', width: 'auto' }); this.y.p2 = overlay.offsetHeight; overlay.style.position = 'absolute'; } }, getOverlays : function() { this.getInline(['heading', 'caption'], true); this.getNumber(); if (this.heading && this.dragByHeading) this.heading.className += ' highslide-move'; if (hs.showCredits) this.writeCredits(); for (var i = 0; i < hs.overlays.length; i++) { var o = hs.overlays[i], tId = o.thumbnailId, sg = o.slideshowGroup; if ((!tId && !sg) || (tId && tId == this.thumbsUserSetId) || (sg && sg === this.slideshowGroup)) { this.createOverlay(o); } } var os = []; for (var i = 0; i < this.overlays.length; i++) { var o = hs.$('hsId'+ this.overlays[i]); if (/panel$/.test(o.position)) this.positionOverlay(o); else hs.push(os, o); } for (var i = 0; i < os.length; i++) this.positionOverlay(os[i]); this.gotOverlays = true; }, genOverlayBox : function() { if (!this.overlayBox) this.overlayBox = hs.createElement ( 'div', { className: this.wrapperClassName }, { position : 'absolute', width: (this.x.size || (this.useBox ? this.width : null) || this.x.full) +'px', height: (this.y.size || this.y.full) +'px', visibility : 'hidden', overflow : 'hidden', zIndex : hs.ie ? 4 : 'auto' }, hs.container, true ); }, sizeOverlayBox : function(doWrapper, doPanels) { var overlayBox = this.overlayBox, x = this.x, y = this.y; hs.setStyles( overlayBox, { width: x.size +'px', height: y.size +'px' }); if (doWrapper || doPanels) { for (var i = 0; i < this.overlays.length; i++) { var o = hs.$('hsId'+ this.overlays[i]); var ie6 = (hs.ieLt7 || document.compatMode == 'BackCompat'); if (o && /^(above|below)$/.test(o.position)) { if (ie6) { o.style.width = (overlayBox.offsetWidth + 2 * x.cb + x.p1 + x.p2) +'px'; } y[o.position == 'above' ? 'p1' : 'p2'] = o.offsetHeight; } if (o && ie6 && /^(left|right)panel$/.test(o.position)) { o.style.height = (overlayBox.offsetHeight + 2* y.cb) +'px'; } } } if (doWrapper) { hs.setStyles(this.content, { top: y.p1 +'px' }); hs.setStyles(overlayBox, { top: (y.p1 + y.cb) +'px' }); } }, showOverlays : function() { var b = this.overlayBox; b.className = ''; hs.setStyles(b, { top: (this.y.p1 + this.y.cb) +'px', left: (this.x.p1 + this.x.cb) +'px', overflow : 'visible' }); if (hs.safari) b.style.visibility = 'visible'; this.wrapper.appendChild (b); for (var i = 0; i < this.overlays.length; i++) { var o = hs.$('hsId'+ this.overlays[i]); o.style.zIndex = o.hsId == 'controls' ? 5 : 4; if (!o.hideOnMouseOut || this.mouseIsOver) { o.style.visibility = 'visible'; hs.setStyles(o, { visibility: 'visible', display: '' }); hs.animate(o, { opacity: o.opacity }, o.dur); } } }, destroyOverlays : function() { if (!this.overlays.length) return; if (this.slideshow) { var c = this.slideshow.controls; if (c && hs.getExpander(c) == this) c.parentNode.removeChild(c); } for (var i = 0; i < this.overlays.length; i++) { var o = hs.$('hsId'+ this.overlays[i]); if (o && o.parentNode == hs.viewport && hs.getExpander(o) == this) hs.discardElement(o); } hs.discardElement(this.overlayBox); }, createFullExpand : function () { if (this.slideshow && this.slideshow.controls) { this.slideshow.enable('full-expand'); return; } this.fullExpandLabel = hs.createElement( 'a', { href: 'javascript:hs.expanders['+ this.key +'].doFullExpand();', title: hs.lang.fullExpandTitle, className: 'highslide-full-expand' } ); this.createOverlay({ overlayId: this.fullExpandLabel, position: hs.fullExpandPosition, hideOnMouseOut: true, opacity: hs.fullExpandOpacity }); }, doFullExpand : function () { try { if (this.fullExpandLabel) hs.discardElement(this.fullExpandLabel); this.focus(); var xSize = this.x.size; this.resizeTo(this.x.full, this.y.full); var xpos = this.x.pos - (this.x.size - xSize) / 2; if (xpos < hs.marginLeft) xpos = hs.marginLeft; this.moveTo(xpos, this.y.pos); this.doShowHide('hidden'); } catch (e) { this.error(e); } }, afterClose : function () { this.a.className = this.a.className.replace('highslide-active-anchor', ''); this.doShowHide('visible'); if (this.outline && this.outlineWhileAnimating) this.outline.destroy(); hs.discardElement(this.wrapper); this.destroyOverlays(); if (!hs.viewport.childNodes.length) hs.viewport.style.display = 'none'; if (this.dimmingOpacity) hs.undim(this.key); hs.expanders[this.key] = null; hs.reOrder(); } }; hs.Slideshow = function (expKey, options) { if (hs.dynamicallyUpdateAnchors !== false) hs.updateAnchors(); this.expKey = expKey; for (var x in options) this[x] = options[x]; if (this.useControls) this.getControls(); if (this.thumbstrip) this.thumbstrip = hs.Thumbstrip(this); }; hs.Slideshow.prototype = { getControls: function() { this.controls = hs.createElement('div', { innerHTML: hs.replaceLang(hs.skin.controls) }, null, hs.container); var buttons = ['play', 'pause', 'previous', 'next', 'move', 'full-expand', 'close']; this.btn = {}; var pThis = this; for (var i = 0; i < buttons.length; i++) { this.btn[buttons[i]] = hs.getElementByClass(this.controls, 'li', 'highslide-'+ buttons[i]); this.enable(buttons[i]); } this.btn.pause.style.display = 'none'; //this.disable('full-expand'); }, checkFirstAndLast: function() { if (this.repeat || !this.controls) return; var exp = hs.expanders[this.expKey], cur = exp.getAnchorIndex(), re = /disabled$/; if (cur == 0) this.disable('previous'); else if (re.test(this.btn.previous.getElementsByTagName('a')[0].className)) this.enable('previous'); if (cur + 1 == hs.anchors.groups[exp.slideshowGroup || 'none'].length) { this.disable('next'); this.disable('play'); } else if (re.test(this.btn.next.getElementsByTagName('a')[0].className)) { this.enable('next'); this.enable('play'); } }, enable: function(btn) { if (!this.btn) return; var sls = this, a = this.btn[btn].getElementsByTagName('a')[0], re = /disabled$/; a.onclick = function() { sls[btn](); return false; }; if (re.test(a.className)) a.className = a.className.replace(re, ''); }, disable: function(btn) { if (!this.btn) return; var a = this.btn[btn].getElementsByTagName('a')[0]; a.onclick = function() { return false; }; if (!/disabled$/.test(a.className)) a.className += ' disabled'; }, hitSpace: function() { if (this.autoplay) this.pause(); else this.play(); }, play: function(wait) { if (this.btn) { this.btn.play.style.display = 'none'; this.btn.pause.style.display = ''; } this.autoplay = true; if (!wait) hs.next(this.expKey); }, pause: function() { if (this.btn) { this.btn.pause.style.display = 'none'; this.btn.play.style.display = ''; } clearTimeout(this.autoplay); this.autoplay = null; }, previous: function() { this.pause(); hs.previous(this.btn.previous); }, next: function() { this.pause(); hs.next(this.btn.next); }, move: function() {}, 'full-expand': function() { hs.getExpander().doFullExpand(); }, close: function() { hs.close(this.btn.close); } }; hs.Thumbstrip = function(slideshow) { function add (exp) { hs.extend(options || {}, { overlayId: dom, hsId: 'thumbstrip', className: 'highslide-thumbstrip-'+ mode +'-overlay ' + (options.className || '') }); if (hs.ieLt7) options.fade = 0; exp.createOverlay(options); hs.setStyles(dom.parentNode, { overflow: 'hidden' }); }; function scroll (delta) { selectThumb(undefined, Math.round(delta * dom[isX ? 'offsetWidth' : 'offsetHeight'] * 0.7)); }; function selectThumb (i, scrollBy) { if (i === undefined) for (var j = 0; j < group.length; j++) { if (group[j] == hs.expanders[slideshow.expKey].a) { i = j; break; } } if (i === undefined) return; var as = dom.getElementsByTagName('a'), active = as[i], cell = active.parentNode, left = isX ? 'Left' : 'Top', right = isX ? 'Right' : 'Bottom', width = isX ? 'Width' : 'Height', offsetLeft = 'offset' + left, offsetWidth = 'offset' + width, overlayWidth = div.parentNode.parentNode[offsetWidth], minTblPos = overlayWidth - table[offsetWidth], curTblPos = parseInt(table.style[isX ? 'left' : 'top']) || 0, tblPos = curTblPos, mgnRight = 20; if (scrollBy !== undefined) { tblPos = curTblPos - scrollBy; if (minTblPos > 0) minTblPos = 0; if (tblPos > 0) tblPos = 0; if (tblPos < minTblPos) tblPos = minTblPos; } else { for (var j = 0; j < as.length; j++) as[j].className = ''; active.className = 'highslide-active-anchor'; var activeLeft = i > 0 ? as[i - 1].parentNode[offsetLeft] : cell[offsetLeft], activeRight = cell[offsetLeft] + cell[offsetWidth] + (as[i + 1] ? as[i + 1].parentNode[offsetWidth] : 0); if (activeRight > overlayWidth - curTblPos) tblPos = overlayWidth - activeRight; else if (activeLeft < -curTblPos) tblPos = -activeLeft; } var markerPos = cell[offsetLeft] + (cell[offsetWidth] - marker[offsetWidth]) / 2 + tblPos; hs.animate(table, isX ? { left: tblPos } : { top: tblPos }, null, 'easeOutQuad'); hs.animate(marker, isX ? { left: markerPos } : { top: markerPos }, null, 'easeOutQuad'); scrollUp.style.display = tblPos < 0 ? 'block' : 'none'; scrollDown.style.display = (tblPos > minTblPos) ? 'block' : 'none'; }; // initialize var group = hs.anchors.groups[hs.expanders[slideshow.expKey].slideshowGroup || 'none'], options = slideshow.thumbstrip, mode = options.mode || 'horizontal', floatMode = (mode == 'float'), tree = floatMode ? ['div', 'ul', 'li', 'span'] : ['table', 'tbody', 'tr', 'td'], isX = (mode == 'horizontal'), dom = hs.createElement('div', { className: 'highslide-thumbstrip highslide-thumbstrip-'+ mode, innerHTML: '<div class="highslide-thumbstrip-inner">'+ '<'+ tree[0] +'><'+ tree[1] +'></'+ tree[1] +'></'+ tree[0] +'></div>'+ '<div class="highslide-scroll-up"><div></div></div>'+ '<div class="highslide-scroll-down"><div></div></div>'+ '<div class="highslide-marker"><div></div></div>' }, { display: 'none' }, hs.container), domCh = dom.childNodes, div = domCh[0], scrollUp = domCh[1], scrollDown = domCh[2], marker = domCh[3], table = div.firstChild, tbody = dom.getElementsByTagName(tree[1])[0], tr; for (var i = 0; i < group.length; i++) { if (i == 0 || !isX) tr = hs.createElement(tree[2], null, null, tbody); (function(){ var a = group[i], cell = hs.createElement(tree[3], null, null, tr), pI = i; hs.createElement('a', { href: a.href, onclick: function() { hs.getExpander(this).focus(); return hs.transit(a); }, innerHTML: hs.stripItemFormatter ? hs.stripItemFormatter(a) : a.innerHTML }, null, cell); })(); } if (!floatMode) { scrollUp.onclick = function () { scroll(-1); }; scrollDown.onclick = function() { scroll(1); }; hs.addEventListener(tbody, document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll', function(e) { var delta = 0; e = e || window.event; if (e.wheelDelta) { delta = e.wheelDelta/120; if (hs.opera) delta = -delta; } else if (e.detail) { delta = -e.detail/3; } if (delta) scroll(-delta * 0.2); if (e.preventDefault) e.preventDefault(); e.returnValue = false; }); } return { add: add, selectThumb: selectThumb } }; hs.langDefaults = hs.lang; // history var HsExpander = hs.Expander; if (hs.ie) { (function () { try { document.documentElement.doScroll('left'); } catch (e) { setTimeout(arguments.callee, 50); return; } hs.ready(); })(); } hs.addEventListener(document, 'DOMContentLoaded', hs.ready); hs.addEventListener(window, 'load', hs.ready); // set handlers hs.addEventListener(document, 'ready', function() { if (hs.expandCursor || hs.dimmingOpacity) { var style = hs.createElement('style', { type: 'text/css' }, null, document.getElementsByTagName('HEAD')[0]); function addRule(sel, dec) { if (!hs.ie) { style.appendChild(document.createTextNode(sel + " {" + dec + "}")); } else { var last = document.styleSheets[document.styleSheets.length - 1]; if (typeof(last.addRule) == "object") last.addRule(sel, dec); } } function fix(prop) { return 'expression( ( ( ignoreMe = document.documentElement.'+ prop + ' ? document.documentElement.'+ prop +' : document.body.'+ prop +' ) ) + \'px\' );'; } if (hs.expandCursor) addRule ('.highslide img', 'cursor: url('+ hs.graphicsDir + hs.expandCursor +'), pointer !important;'); addRule ('.highslide-viewport-size', hs.ie && (hs.uaVersion < 7 || document.compatMode == 'BackCompat') ? 'position: absolute; '+ 'left:'+ fix('scrollLeft') + 'top:'+ fix('scrollTop') + 'width:'+ fix('clientWidth') + 'height:'+ fix('clientHeight') : 'position: fixed; width: 100%; height: 100%; left: 0; top: 0'); } }); hs.addEventListener(window, 'resize', function() { hs.getPageSize(); if (hs.viewport) for (var i = 0; i < hs.viewport.childNodes.length; i++) { var node = hs.viewport.childNodes[i], exp = hs.getExpander(node); exp.positionOverlay(node); if (node.hsId == 'thumbstrip') exp.slideshow.thumbstrip.selectThumb(); } }); hs.addEventListener(document, 'mousemove', function(e) { hs.mouse = { x: e.clientX, y: e.clientY }; }); hs.addEventListener(document, 'mousedown', hs.mouseClickHandler); hs.addEventListener(document, 'mouseup', hs.mouseClickHandler); hs.addEventListener(document, 'ready', hs.getAnchors); hs.addEventListener(window, 'load', hs.preloadImages); }
JavaScript
/* * Mplayer */ (function($) { $.jPlayerCount = 0; var methods = { jPlayer: function(options) { $.jPlayerCount++; var config = { ready: null, cssPrefix: "jqjp", swfPath: "", quality: "high", width: 0, height: 0, top: 0, left: 0, position: "absolute", bgcolor: "#ffffff" }; $.extend(config, options); var configWithoutOptions = { id: $(this).attr("id"), swf: config.swfPath + ((config.swfPath != "") ? "/" : "") + "Jplayer.swf", fid: config.cssPrefix + "_flash_" + $.jPlayerCount, hid: config.cssPrefix + "_force_" + $.jPlayerCount }; $.extend(config, configWithoutOptions); $(this).data("jPlayer.config", config); var events = { change: function(e, f) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); m.fl_change_mp3(f); $(this).trigger("jPlayer.screenUpdate", false); }, play: function(e) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); var r = m.fl_play_mp3(); if(r) { $(this).trigger("jPlayer.screenUpdate", true); } }, pause: function(e) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); var r = m.fl_pause_mp3(); if(r) { $(this).trigger("jPlayer.screenUpdate", false); } }, stop: function(e) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); var r = m.fl_stop_mp3(); if(r) { $(this).trigger("jPlayer.screenUpdate", false); } }, playHead: function(e, p) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); var r = m.fl_play_head_mp3(p); if(r) { $(this).trigger("jPlayer.screenUpdate", true); } }, volume: function(e, v) { var fid = $(this).data("jPlayer.config").fid; var m = $(this).data("jPlayer.getMovie")(fid); m.fl_volume_mp3(v); }, screenUpdate: function(e, playing) { var playId = $(this).data("jPlayer.cssId.play"); var pauseId = $(this).data("jPlayer.cssId.pause"); var prefix = $(this).data("jPlayer.config").cssPrefix; if(playId != null && pauseId != null) { if(playing) { var style = $(this).data("jPlayer.cssDisplay.pause"); $("#"+playId).css("display", "none"); $("#"+pauseId).css("display", style); } else { var style = $(this).data("jPlayer.cssDisplay.play"); $("#"+playId).css("display", style); $("#"+pauseId).css("display", "none"); } } } }; for(var event in events) { var e = "jPlayer." + event; $(this).unbind(e); $(this).bind(e, events[event]); } var getMovie = function(fid) { if ($.browser.msie) { return window[fid]; } else { return document[fid]; } }; $(this).data("jPlayer.getMovie", getMovie); if($.browser.msie) { var html_obj = '<object id="' + config.fid + '"'; html_obj += ' classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"'; html_obj += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"'; html_obj += ' type="application/x-shockwave-flash"'; html_obj += ' width="' + config.width + '" height="' + config.height + '">'; html_obj += '</object>'; var obj_param = new Array(); obj_param[0] = '<param name="movie" value="' + config.swf + '" />'; obj_param[1] = '<param name="quality" value="high" />'; obj_param[2] = '<param name="FlashVars" value="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '" />'; obj_param[3] = '<param name="allowScriptAccess" value="always" />'; obj_param[4] = '<param name="bgcolor" value="' + config.bgcolor + '" />'; var ie_dom = document.createElement(html_obj); for(var i=0; i < obj_param.length; i++) { ie_dom.appendChild(document.createElement(obj_param[i])); } $(this).html(ie_dom); } else { var html_embed = '<embed name="' + config.fid + '" src="' + config.swf + '"'; html_embed += ' width="' + config.width + '" height="' + config.height + '" bgcolor="' + config.bgcolor + '"'; html_embed += ' quality="high" FlashVars="id=' + escape(config.id) + '&fid=' + escape(config.fid) + '"'; html_embed += ' allowScriptAccess="always"'; html_embed += ' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'; $(this).html(html_embed); } var html_hidden = '<div id="' + config.hid + '"></div>'; $(this).append(html_hidden); $(this).css({'position':config.position, 'top':config.top, 'left':config.left}); $("#"+config.hid).css({'text-indent':'-9999px'}); return $(this); }, change: function(f) { $(this).trigger("jPlayer.change", f); }, play: function() { $(this).trigger("jPlayer.play"); }, changeAndPlay: function(f) { $(this).trigger("jPlayer.change", f); $(this).trigger("jPlayer.play"); }, pause: function() { $(this).trigger("jPlayer.pause"); }, stop: function() { $(this).trigger("jPlayer.stop"); }, playHead: function(p) { $(this).trigger("jPlayer.playHead", p); }, volume: function(v) { $(this).trigger("jPlayer.volume", v); }, jPlayerId: function(fn, id) { if(id != null) { var isValid = eval("$(this)."+fn); if(isValid != null) { $(this).data("jPlayer.cssId." + fn, id); var jPlayerId = $(this).data("jPlayer.config").id; eval("var myHandler = function(e) { $(\"#" + jPlayerId + "\")." + fn + "(e); return false; }"); $("#"+id).click(myHandler).hover(this.rollOver, this.rollOut).data("jPlayerId", jPlayerId); var display = $("#"+id).css("display"); $(this).data("jPlayer.cssDisplay." + fn, display); if(fn == "pause") { $("#"+id).css("display", "none"); } } else { alert("Unknown function assigned in: jPlayerId( fn="+fn+", id="+id+" )"); } } else { id = $(this).data("jPlayer.cssId." + fn); if(id != null) { return id; } else { alert("Unknown function id requested: jPlayerId( fn="+fn+" )"); return false; } } }, loadBar: function(e) { var lbId = $(this).data("jPlayer.cssId.loadBar"); if( lbId != null ) { var offset = $("#"+lbId).offset(); var x = e.pageX - offset.left; var w = $("#"+lbId).width(); var p = 100*x/w; $(this).playHead(p); } }, playBar: function(e) { this.loadBar(e); }, onProgressChange: function(fn) { $(this).data("jPlayer.jsFn.onProgressChange", fn); }, updateProgress: function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) { // Called from Flash var lbId = $(this).data("jPlayer.cssId.loadBar"); if (lbId != null) { $("#"+lbId).width(loadPercent+"%"); } var pbId = $(this).data("jPlayer.cssId.playBar"); if (pbId != null ) { $("#"+pbId).width(playedPercentRelative+"%"); } var onProgressChangeFn = $(this).data("jPlayer.jsFn.onProgressChange"); if(onProgressChangeFn != null) { onProgressChangeFn(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime); } if (lbId != null || pbId != null || onProgressChangeFn != null) { this.forceScreenUpdate(); return true; } else { return false; } }, volumeMin: function() { $(this).volume(0); }, volumeMax: function() { $(this).volume(100); }, volumeBar: function(e) { var vbId = $(this).data("jPlayer.cssId.volumeBar"); if( vbId != null ) { var offset = $("#"+vbId).offset(); var x = e.pageX - offset.left; var w = $("#"+vbId).width(); var p = 100*x/w; $(this).volume(p); } }, volumeBarValue: function(e) { this.volumeBar(e); }, updateVolume: function(v) { // Called from Flash var vbvId = $(this).data("jPlayer.cssId.volumeBarValue"); if( vbvId != null ) { $("#"+vbvId).width(v+"%"); this.forceScreenUpdate(); return true; } }, onSoundComplete: function(fn) { $(this).data("jPlayer.jsFn.onSoundComplete", fn); }, finishedPlaying: function() { // Called from Flash var onSoundCompleteFn = $(this).data("jPlayer.jsFn.onSoundComplete"); $(this).trigger("jPlayer.screenUpdate", false); if(onSoundCompleteFn != null) { onSoundCompleteFn(); return true; } else { return false; } }, setBufferState: function (b) { // Called from Flash var lbId = $(this).data("jPlayer.cssId.loadBar"); if( lbId != null ) { var prefix = $(this).data("jPlayer.config").cssPrefix; if(b) { $("#"+lbId).addClass(prefix + "_buffer"); } else { $("#"+lbId).removeClass(prefix + "_buffer"); } return true; } else { return false; } }, bufferMsg: function() { // Empty: Initialized to enable jPlayerId() to work. // See setBufferMsg() for code. }, setBufferMsg: function (msg) { // Called from Flash var bmId = $(this).data("jPlayer.cssId.bufferMsg"); if( bmId != null ) { $("#"+bmId).html(msg); return true; } else { return false; } }, forceScreenUpdate: function() { // For Safari and Chrome var hid = $(this).data("jPlayer.config").hid; $("#"+hid).html(Math.random()); }, rollOver: function() { var jPlayerId = $(this).data("jPlayerId"); var prefix = $("#"+jPlayerId).data("jPlayer.config").cssPrefix; $(this).addClass(prefix + "_hover"); }, rollOut: function() { var jPlayerId = $(this).data("jPlayerId"); var prefix = $("#"+jPlayerId).data("jPlayer.config").cssPrefix; $(this).removeClass(prefix + "_hover"); }, flashReady: function() { // Called from Flash var readyFn = $(this).data("jPlayer.config").ready; if(readyFn != null) { readyFn(); } } }; $.each(methods, function(i) { $.fn[i] = this; }); })(jQuery); /** * 滚屏代码 */ jQuery.fn.extend({ mousewheel: function(up, down, preventDefault) { return this.hover( function() { jQuery.event.mousewheel.giveFocus(this, up, down, preventDefault); }, function() { jQuery.event.mousewheel.removeFocus(this); } ); }, mousewheeldown: function(fn, preventDefault) { return this.mousewheel(function(){}, fn, preventDefault); }, mousewheelup: function(fn, preventDefault) { return this.mousewheel(fn, function(){}, preventDefault); }, unmousewheel: function() { return this.each(function() { jQuery(this).unmouseover().unmouseout(); jQuery.event.mousewheel.removeFocus(this); }); }, unmousewheeldown: jQuery.fn.unmousewheel, unmousewheelup: jQuery.fn.unmousewheel }); jQuery.event.mousewheel = { giveFocus: function(el, up, down, preventDefault) { if (el._handleMousewheel) jQuery(el).unmousewheel(); if (preventDefault == window.undefined && down && down.constructor != Function) { preventDefault = down; down = null; } el._handleMousewheel = function(event) { if (!event) event = window.event; if (preventDefault) if (event.preventDefault) event.preventDefault(); else event.returnValue = false; var delta = 0; if (event.wheelDelta) { delta = event.wheelDelta/120; if (window.opera) delta = -delta; } else if (event.detail) { delta = -event.detail/3; } if (up && (delta > 0 || !down)) up.apply(el, [event, delta]); else if (down && delta < 0) down.apply(el, [event, delta]); }; if (window.addEventListener) window.addEventListener('DOMMouseScroll', el._handleMousewheel, false); window.onmousewheel = document.onmousewheel = el._handleMousewheel; }, removeFocus: function(el) { if (!el._handleMousewheel) return; if (window.removeEventListener) window.removeEventListener('DOMMouseScroll', el._handleMousewheel, false); window.onmousewheel = document.onmousewheel = null; el._handleMousewheel = null; } }; /* * 功能设置代码 */ $(function(){ $("#jquery_jplayer").jPlayer({ swfPath:ROOT+"/Public/Plugin/Jplayer" }); $("#jquery_jplayer").jPlayerId("play", "player_play"); $("#jquery_jplayer").jPlayerId("pause", "player_pause"); $("#jquery_jplayer").jPlayerId("stop", "player_stop"); $("#jquery_jplayer").jPlayerId("loadBar", "player_progress_load_bar"); $("#jquery_jplayer").jPlayerId("playBar", "player_progress_play_bar"); $("#jquery_jplayer").jPlayerId("volumeMin", "player_volume_min"); $("#jquery_jplayer").jPlayerId("volumeMax", "player_volume_max"); $("#jquery_jplayer").jPlayerId("volumeBar", "player_volume_bar"); $("#jquery_jplayer").jPlayerId("volumeBarValue", "player_volume_bar_value"); $("#jquery_jplayer").onProgressChange( function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) { var myPlayedTime = new Date(playedTime); //var ptMin = (myPlayedTime.getMinutes() < 10) ? "0" + myPlayedTime.getMinutes() : myPlayedTime.getMinutes(); //var ptSec = (myPlayedTime.getSeconds() < 10) ? "0" + myPlayedTime.getSeconds() : myPlayedTime.getSeconds(); var myTotalTime = new Date(totalTime); //var ttMin = (myTotalTime.getMinutes() < 10) ? "0" + myTotalTime.getMinutes() : myTotalTime.getMinutes(); //var ttSec = (myTotalTime.getSeconds() < 10) ? "0" + myTotalTime.getSeconds() : myTotalTime.getSeconds(); var secAll = dateDiff("S",myPlayedTime,myTotalTime); var sec = "00"; var min = "00"; //console.log( parseInt(secAll%60)<10 ); if( parseInt(secAll%60)<10 ){ sec = "0"+ parseInt(secAll%60); }else{ sec = parseInt(secAll%60) } if((Math.floor(secAll/60)) <10 ){ min = "0"+ (Math.floor(secAll/60)); }else{ min = (Math.floor(secAll/60)); } $("#play_time").text(min+":"+sec); }); /* 使用方法: alert(dateDiff('h','2007-4-14','2007-4-19')); H 表示 hour , D 表示 day , M 表示minute , S 表示 second 支持 豪秒,秒,分,时,天 */ function dateDiff(interval, date1, date2){ var objInterval = {'D' : 1000*60*60*24,'H' : 1000*60*60,'M' : 1000*60,'S' : 1000}; interval = interval.toUpperCase(); // var dt1 = Date.parse(date1.replace(/-/g,'/')); // var dt2 = Date.parse(date2.replace(/-/g,'/')); var dt1 = date1; var dt2 = date2; try { return Math.round((dt2 - dt1) / eval('(objInterval.' + interval + ')')); }catch(e) { return e.message; } } $("#jquery_jplayer").onSoundComplete(endOfSong); function endOfSong() { playListNext(); } $("#ctrl_prev").click( function() { playListPrev(); return false; }); $("#ctrl_next").click( function() { playListNext(); return false; }); function playListChange( src ,obj) { $("#player_progress,#play_time").remove(); $('<div id="play_time"></div><div id="player_progress"><div id="player_progress_load_bar" class="jqjp_buffer"><div id="player_progress_play_bar"></div></div></div>').prependTo(obj); $(".playlist_content li a").removeClass("controllinkpause").addClass("controllink"); $("a.controllink",obj).addClass("controllinkpause"); $("#jquery_jplayer").changeAndPlay(src); } var playItem = 0; var myPlayListLength = $(".playlist_content li").length; function playListNext() { var currentIndex = $(".playlist_content li").index($(".playlist_current")); playItem = currentIndex; var index = (playItem+1 < myPlayListLength) ? playItem+1 : 0; var $liindex = $(".playlist_content li:eq("+index+")") ; var playListSrc= $liindex.attr("jplayer"); playListChange(playListSrc , $liindex );//播放mp3 $liindex.addClass("playlist_current").siblings().removeClass("playlist_current"); } function playListPrev() { var currentIndex = $(".playlist_content li").index($(".playlist_current")); playItem = currentIndex; var index = (playItem-1 >= 0) ? playItem-1 :myPlayListLength-1; var $liindex = $(".playlist_content li:eq("+index+")") ; var playListSrc= $liindex.attr("jplayer"); playListChange(playListSrc , $liindex );//播放mp3 $liindex.addClass("playlist_current").siblings().removeClass("playlist_current"); } function play_zhijie() { var $liindex = $(".playlist_content li:eq(0)"); var playListSrc= $liindex.attr("jplayer"); playListChange(playListSrc , $liindex );//播放mp3 $liindex.addClass("playlist_current").siblings().removeClass("playlist_current"); } /*音乐列表*/ $("#playlist_list ul.playlist_content li").click(function(){ var src = $(this).attr("jplayer"); if(!$(this).hasClass("playlist_current")) { $('#jquery_jplayer').pause(); playListChange(src , $(this));//播放mp3 }else{ if( $('#jquery_jplayer').data("flag") ){ $("a",$(this)).removeClass("controllink controllinkpause").addClass("controllinkpause"); $('#jquery_jplayer').play(); $('#jquery_jplayer').data("flag",false); }else{ $("a",$(this)).removeClass("controllink controllinkpause").addClass("controllink"); $('#jquery_jplayer').pause(); $('#jquery_jplayer').data("flag",true); } } $(this).addClass("playlist_current").siblings().removeClass("playlist_current"); }).hover(function() { if (!$(this).hasClass("playlist_current")) { $(this).addClass("playlist_hover"); } },function(){ $(this).removeClass("playlist_hover"); }); /*歌曲名 自动滚屏*/ var songerTime = ""; var marginLeftWidth = $(".playlist_content_songer_txt").parent().width(); function setTime() { $(".playlist_content_songer_txt").animate({marginLeft:"-=1px"},0,function(){ if(Math.abs(parseInt($(this).css("marginLeft"))) >= marginLeftWidth){ $(this).css("marginLeft",marginLeftWidth+"px"); } }); } $(".playlist_content_songer_txt").parent().hover(function(){ if(songerTime){ clearInterval(songerTime);} },function(){ songerTime = setInterval(function(){ setTime(); },30); }); $(".list_reuturn a").click(function(){ //停止歌曲名自动滚屏 $(".playlist_content_songer_txt").parent().trigger("mouseenter"); //切换到歌曲列表 $(".playlist_wrap").animate({left:"20px"},500,function(){ $(".playlist_footer li.list_power").fadeOut(200,function(){ $(".playlist_footer li:not(.list_power)").fadeIn(200); }); }); return false; }); //暂停后 播放音乐 $("#player_play a").click(function(){ $('#jquery_jplayer').play(); return false; }); //暂停音乐 $("#player_pause a").click(function(){ $('#jquery_jplayer').pause(); return false; }); /*上下翻*/ var len = $(".playlist_content li").length; var per = 8; var num = Math.ceil(len/8); var i = 1; var height_top = $(".playlist_cc").outerHeight(true); //下翻 $(".list_down a").click(function(){ if(!$('.playlist_content').is(":animated")){ if(i>=num){ return false; }else{ $('.playlist_content').animate({top:"-="+height_top+"px"},600); } i++; } return false; }); //上翻 $(".list_up a").click(function(){ if(!$('.playlist_content').is(":animated")){ if(i<=1){ return false; }else{ $('.playlist_content').animate({top:"+="+height_top+"px"},600); } i--; } return false; }); /*鼠标滚轮事件*/ $(".playlist_cc").mousewheel(function(objEvent, intDelta){ if (intDelta > 0){ $(".list_up a").trigger("click"); }else if (intDelta < 0){ $(".list_down a").trigger("click"); } }); //随便听听 $(".list_ramdom a").click(function(){ var index = Math.round(Math.random()*len); if(index<=len){ $("#playlist_list ul.playlist_content li:eq("+index+")").trigger("click"); }else{ alert("暂时不支持随机播放!请稍后再试!"); } return false; }); /*上一首*/ $(".list_up_one").click(function(){ playListPrev(); return false; }); /*下一首*/ $(".list_down_one").click(function(){ playListNext(); return false; }); /*直接播放*/ $(".list_play_zhi").click(function(){ play_zhijie(); return false; }); });
JavaScript
sfHover = function() { var sfEls = document.getElementById("suckerfishmenu").getElementsByTagName("LI"); for (var i=0; i<sfEls.length; i++) { sfEls[i].onmouseover=function() { this.className+=" sfhover"; } sfEls[i].onmouseout=function() { this.className=this.className.replace(new RegExp(" sfhover\\b"), ""); } } } if (window.attachEvent) window.attachEvent("onload", sfHover);
JavaScript
/* * jQuery 1.2.6 - New Wave Javascript * * Copyright (c) 2008 John Resig (jquery.com) * Dual licensed under the MIT (MIT-LICENSE.txt) * and GPL (GPL-LICENSE.txt) licenses. * * Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) * Rev: 5685 */ eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(H(){J w=1b.4M,3m$=1b.$;J D=1b.4M=1b.$=H(a,b){I 2B D.17.5j(a,b)};J u=/^[^<]*(<(.|\\s)+>)[^>]*$|^#(\\w+)$/,62=/^.[^:#\\[\\.]*$/,12;D.17=D.44={5j:H(d,b){d=d||S;G(d.16){7[0]=d;7.K=1;I 7}G(1j d=="23"){J c=u.2D(d);G(c&&(c[1]||!b)){G(c[1])d=D.4h([c[1]],b);N{J a=S.61(c[3]);G(a){G(a.2v!=c[3])I D().2q(d);I D(a)}d=[]}}N I D(b).2q(d)}N G(D.1D(d))I D(S)[D.17.27?"27":"43"](d);I 7.6Y(D.2d(d))},5w:"1.2.6",8G:H(){I 7.K},K:0,3p:H(a){I a==12?D.2d(7):7[a]},2I:H(b){J a=D(b);a.5n=7;I a},6Y:H(a){7.K=0;2p.44.1p.1w(7,a);I 7},P:H(a,b){I D.P(7,a,b)},5i:H(b){J a=-1;I D.2L(b&&b.5w?b[0]:b,7)},1K:H(c,a,b){J d=c;G(c.1q==56)G(a===12)I 7[0]&&D[b||"1K"](7[0],c);N{d={};d[c]=a}I 7.P(H(i){R(c 1n d)D.1K(b?7.V:7,c,D.1i(7,d[c],b,i,c))})},1g:H(b,a){G((b==\'2h\'||b==\'1Z\')&&3d(a)<0)a=12;I 7.1K(b,a,"2a")},1r:H(b){G(1j b!="49"&&b!=U)I 7.4E().3v((7[0]&&7[0].2z||S).5F(b));J a="";D.P(b||7,H(){D.P(7.3t,H(){G(7.16!=8)a+=7.16!=1?7.76:D.17.1r([7])})});I a},5z:H(b){G(7[0])D(b,7[0].2z).5y().39(7[0]).2l(H(){J a=7;1B(a.1x)a=a.1x;I a}).3v(7);I 7},8Y:H(a){I 7.P(H(){D(7).6Q().5z(a)})},8R:H(a){I 7.P(H(){D(7).5z(a)})},3v:H(){I 7.3W(19,M,Q,H(a){G(7.16==1)7.3U(a)})},6F:H(){I 7.3W(19,M,M,H(a){G(7.16==1)7.39(a,7.1x)})},6E:H(){I 7.3W(19,Q,Q,H(a){7.1d.39(a,7)})},5q:H(){I 7.3W(19,Q,M,H(a){7.1d.39(a,7.2H)})},3l:H(){I 7.5n||D([])},2q:H(b){J c=D.2l(7,H(a){I D.2q(b,a)});I 7.2I(/[^+>] [^+>]/.11(b)||b.1h("..")>-1?D.4r(c):c)},5y:H(e){J f=7.2l(H(){G(D.14.1f&&!D.4n(7)){J a=7.6o(M),5h=S.3h("1v");5h.3U(a);I D.4h([5h.4H])[0]}N I 7.6o(M)});J d=f.2q("*").5c().P(H(){G(7[E]!=12)7[E]=U});G(e===M)7.2q("*").5c().P(H(i){G(7.16==3)I;J c=D.L(7,"3w");R(J a 1n c)R(J b 1n c[a])D.W.1e(d[i],a,c[a][b],c[a][b].L)});I f},1E:H(b){I 7.2I(D.1D(b)&&D.3C(7,H(a,i){I b.1k(a,i)})||D.3g(b,7))},4Y:H(b){G(b.1q==56)G(62.11(b))I 7.2I(D.3g(b,7,M));N b=D.3g(b,7);J a=b.K&&b[b.K-1]!==12&&!b.16;I 7.1E(H(){I a?D.2L(7,b)<0:7!=b})},1e:H(a){I 7.2I(D.4r(D.2R(7.3p(),1j a==\'23\'?D(a):D.2d(a))))},3F:H(a){I!!a&&D.3g(a,7).K>0},7T:H(a){I 7.3F("."+a)},6e:H(b){G(b==12){G(7.K){J c=7[0];G(D.Y(c,"2A")){J e=c.64,63=[],15=c.15,2V=c.O=="2A-2V";G(e<0)I U;R(J i=2V?e:0,2f=2V?e+1:15.K;i<2f;i++){J d=15[i];G(d.2W){b=D.14.1f&&!d.at.2x.an?d.1r:d.2x;G(2V)I b;63.1p(b)}}I 63}N I(7[0].2x||"").1o(/\\r/g,"")}I 12}G(b.1q==4L)b+=\'\';I 7.P(H(){G(7.16!=1)I;G(b.1q==2p&&/5O|5L/.11(7.O))7.4J=(D.2L(7.2x,b)>=0||D.2L(7.34,b)>=0);N G(D.Y(7,"2A")){J a=D.2d(b);D("9R",7).P(H(){7.2W=(D.2L(7.2x,a)>=0||D.2L(7.1r,a)>=0)});G(!a.K)7.64=-1}N 7.2x=b})},2K:H(a){I a==12?(7[0]?7[0].4H:U):7.4E().3v(a)},7b:H(a){I 7.5q(a).21()},79:H(i){I 7.3s(i,i+1)},3s:H(){I 7.2I(2p.44.3s.1w(7,19))},2l:H(b){I 7.2I(D.2l(7,H(a,i){I b.1k(a,i,a)}))},5c:H(){I 7.1e(7.5n)},L:H(d,b){J a=d.1R(".");a[1]=a[1]?"."+a[1]:"";G(b===12){J c=7.5C("9z"+a[1]+"!",[a[0]]);G(c===12&&7.K)c=D.L(7[0],d);I c===12&&a[1]?7.L(a[0]):c}N I 7.1P("9u"+a[1]+"!",[a[0],b]).P(H(){D.L(7,d,b)})},3b:H(a){I 7.P(H(){D.3b(7,a)})},3W:H(g,f,h,d){J e=7.K>1,3x;I 7.P(H(){G(!3x){3x=D.4h(g,7.2z);G(h)3x.9o()}J b=7;G(f&&D.Y(7,"1T")&&D.Y(3x[0],"4F"))b=7.3H("22")[0]||7.3U(7.2z.3h("22"));J c=D([]);D.P(3x,H(){J a=e?D(7).5y(M)[0]:7;G(D.Y(a,"1m"))c=c.1e(a);N{G(a.16==1)c=c.1e(D("1m",a).21());d.1k(b,a)}});c.P(6T)})}};D.17.5j.44=D.17;H 6T(i,a){G(a.4d)D.3Y({1a:a.4d,31:Q,1O:"1m"});N D.5u(a.1r||a.6O||a.4H||"");G(a.1d)a.1d.37(a)}H 1z(){I+2B 8J}D.1l=D.17.1l=H(){J b=19[0]||{},i=1,K=19.K,4x=Q,15;G(b.1q==8I){4x=b;b=19[1]||{};i=2}G(1j b!="49"&&1j b!="H")b={};G(K==i){b=7;--i}R(;i<K;i++)G((15=19[i])!=U)R(J c 1n 15){J a=b[c],2w=15[c];G(b===2w)6M;G(4x&&2w&&1j 2w=="49"&&!2w.16)b[c]=D.1l(4x,a||(2w.K!=U?[]:{}),2w);N G(2w!==12)b[c]=2w}I b};J E="4M"+1z(),6K=0,5r={},6G=/z-?5i|8B-?8A|1y|6B|8v-?1Z/i,3P=S.3P||{};D.1l({8u:H(a){1b.$=3m$;G(a)1b.4M=w;I D},1D:H(a){I!!a&&1j a!="23"&&!a.Y&&a.1q!=2p&&/^[\\s[]?H/.11(a+"")},4n:H(a){I a.1C&&!a.1c||a.2j&&a.2z&&!a.2z.1c},5u:H(a){a=D.3k(a);G(a){J b=S.3H("6w")[0]||S.1C,1m=S.3h("1m");1m.O="1r/4t";G(D.14.1f)1m.1r=a;N 1m.3U(S.5F(a));b.39(1m,b.1x);b.37(1m)}},Y:H(b,a){I b.Y&&b.Y.2r()==a.2r()},1Y:{},L:H(c,d,b){c=c==1b?5r:c;J a=c[E];G(!a)a=c[E]=++6K;G(d&&!D.1Y[a])D.1Y[a]={};G(b!==12)D.1Y[a][d]=b;I d?D.1Y[a][d]:a},3b:H(c,b){c=c==1b?5r:c;J a=c[E];G(b){G(D.1Y[a]){2U D.1Y[a][b];b="";R(b 1n D.1Y[a])1X;G(!b)D.3b(c)}}N{1U{2U c[E]}1V(e){G(c.5l)c.5l(E)}2U D.1Y[a]}},P:H(d,a,c){J e,i=0,K=d.K;G(c){G(K==12){R(e 1n d)G(a.1w(d[e],c)===Q)1X}N R(;i<K;)G(a.1w(d[i++],c)===Q)1X}N{G(K==12){R(e 1n d)G(a.1k(d[e],e,d[e])===Q)1X}N R(J b=d[0];i<K&&a.1k(b,i,b)!==Q;b=d[++i]){}}I d},1i:H(b,a,c,i,d){G(D.1D(a))a=a.1k(b,i);I a&&a.1q==4L&&c=="2a"&&!6G.11(d)?a+"2X":a},1F:{1e:H(c,b){D.P((b||"").1R(/\\s+/),H(i,a){G(c.16==1&&!D.1F.3T(c.1F,a))c.1F+=(c.1F?" ":"")+a})},21:H(c,b){G(c.16==1)c.1F=b!=12?D.3C(c.1F.1R(/\\s+/),H(a){I!D.1F.3T(b,a)}).6s(" "):""},3T:H(b,a){I D.2L(a,(b.1F||b).6r().1R(/\\s+/))>-1}},6q:H(b,c,a){J e={};R(J d 1n c){e[d]=b.V[d];b.V[d]=c[d]}a.1k(b);R(J d 1n c)b.V[d]=e[d]},1g:H(d,e,c){G(e=="2h"||e=="1Z"){J b,3X={30:"5x",5g:"1G",18:"3I"},35=e=="2h"?["5e","6k"]:["5G","6i"];H 5b(){b=e=="2h"?d.8f:d.8c;J a=0,2C=0;D.P(35,H(){a+=3d(D.2a(d,"57"+7,M))||0;2C+=3d(D.2a(d,"2C"+7+"4b",M))||0});b-=29.83(a+2C)}G(D(d).3F(":4j"))5b();N D.6q(d,3X,5b);I 29.2f(0,b)}I D.2a(d,e,c)},2a:H(f,l,k){J e,V=f.V;H 3E(b){G(!D.14.2k)I Q;J a=3P.54(b,U);I!a||a.52("3E")==""}G(l=="1y"&&D.14.1f){e=D.1K(V,"1y");I e==""?"1":e}G(D.14.2G&&l=="18"){J d=V.50;V.50="0 7Y 7W";V.50=d}G(l.1I(/4i/i))l=y;G(!k&&V&&V[l])e=V[l];N G(3P.54){G(l.1I(/4i/i))l="4i";l=l.1o(/([A-Z])/g,"-$1").3y();J c=3P.54(f,U);G(c&&!3E(f))e=c.52(l);N{J g=[],2E=[],a=f,i=0;R(;a&&3E(a);a=a.1d)2E.6h(a);R(;i<2E.K;i++)G(3E(2E[i])){g[i]=2E[i].V.18;2E[i].V.18="3I"}e=l=="18"&&g[2E.K-1]!=U?"2F":(c&&c.52(l))||"";R(i=0;i<g.K;i++)G(g[i]!=U)2E[i].V.18=g[i]}G(l=="1y"&&e=="")e="1"}N G(f.4g){J h=l.1o(/\\-(\\w)/g,H(a,b){I b.2r()});e=f.4g[l]||f.4g[h];G(!/^\\d+(2X)?$/i.11(e)&&/^\\d/.11(e)){J j=V.1A,66=f.65.1A;f.65.1A=f.4g.1A;V.1A=e||0;e=V.aM+"2X";V.1A=j;f.65.1A=66}}I e},4h:H(l,h){J k=[];h=h||S;G(1j h.3h==\'12\')h=h.2z||h[0]&&h[0].2z||S;D.P(l,H(i,d){G(!d)I;G(d.1q==4L)d+=\'\';G(1j d=="23"){d=d.1o(/(<(\\w+)[^>]*?)\\/>/g,H(b,a,c){I c.1I(/^(aK|4f|7E|aG|4T|7A|aB|3n|az|ay|av)$/i)?b:a+"></"+c+">"});J f=D.3k(d).3y(),1v=h.3h("1v");J e=!f.1h("<au")&&[1,"<2A 7w=\'7w\'>","</2A>"]||!f.1h("<ar")&&[1,"<7v>","</7v>"]||f.1I(/^<(aq|22|am|ak|ai)/)&&[1,"<1T>","</1T>"]||!f.1h("<4F")&&[2,"<1T><22>","</22></1T>"]||(!f.1h("<af")||!f.1h("<ad"))&&[3,"<1T><22><4F>","</4F></22></1T>"]||!f.1h("<7E")&&[2,"<1T><22></22><7q>","</7q></1T>"]||D.14.1f&&[1,"1v<1v>","</1v>"]||[0,"",""];1v.4H=e[1]+d+e[2];1B(e[0]--)1v=1v.5T;G(D.14.1f){J g=!f.1h("<1T")&&f.1h("<22")<0?1v.1x&&1v.1x.3t:e[1]=="<1T>"&&f.1h("<22")<0?1v.3t:[];R(J j=g.K-1;j>=0;--j)G(D.Y(g[j],"22")&&!g[j].3t.K)g[j].1d.37(g[j]);G(/^\\s/.11(d))1v.39(h.5F(d.1I(/^\\s*/)[0]),1v.1x)}d=D.2d(1v.3t)}G(d.K===0&&(!D.Y(d,"3V")&&!D.Y(d,"2A")))I;G(d[0]==12||D.Y(d,"3V")||d.15)k.1p(d);N k=D.2R(k,d)});I k},1K:H(d,f,c){G(!d||d.16==3||d.16==8)I 12;J e=!D.4n(d),40=c!==12,1f=D.14.1f;f=e&&D.3X[f]||f;G(d.2j){J g=/5Q|4d|V/.11(f);G(f=="2W"&&D.14.2k)d.1d.64;G(f 1n d&&e&&!g){G(40){G(f=="O"&&D.Y(d,"4T")&&d.1d)7p"O a3 a1\'t 9V 9U";d[f]=c}G(D.Y(d,"3V")&&d.7i(f))I d.7i(f).76;I d[f]}G(1f&&e&&f=="V")I D.1K(d.V,"9T",c);G(40)d.9Q(f,""+c);J h=1f&&e&&g?d.4G(f,2):d.4G(f);I h===U?12:h}G(1f&&f=="1y"){G(40){d.6B=1;d.1E=(d.1E||"").1o(/7f\\([^)]*\\)/,"")+(3r(c)+\'\'=="9L"?"":"7f(1y="+c*7a+")")}I d.1E&&d.1E.1h("1y=")>=0?(3d(d.1E.1I(/1y=([^)]*)/)[1])/7a)+\'\':""}f=f.1o(/-([a-z])/9H,H(a,b){I b.2r()});G(40)d[f]=c;I d[f]},3k:H(a){I(a||"").1o(/^\\s+|\\s+$/g,"")},2d:H(b){J a=[];G(b!=U){J i=b.K;G(i==U||b.1R||b.4I||b.1k)a[0]=b;N 1B(i)a[--i]=b[i]}I a},2L:H(b,a){R(J i=0,K=a.K;i<K;i++)G(a[i]===b)I i;I-1},2R:H(a,b){J i=0,T,2S=a.K;G(D.14.1f){1B(T=b[i++])G(T.16!=8)a[2S++]=T}N 1B(T=b[i++])a[2S++]=T;I a},4r:H(a){J c=[],2o={};1U{R(J i=0,K=a.K;i<K;i++){J b=D.L(a[i]);G(!2o[b]){2o[b]=M;c.1p(a[i])}}}1V(e){c=a}I c},3C:H(c,a,d){J b=[];R(J i=0,K=c.K;i<K;i++)G(!d!=!a(c[i],i))b.1p(c[i]);I b},2l:H(d,a){J c=[];R(J i=0,K=d.K;i<K;i++){J b=a(d[i],i);G(b!=U)c[c.K]=b}I c.7d.1w([],c)}});J v=9B.9A.3y();D.14={5B:(v.1I(/.+(?:9y|9x|9w|9v)[\\/: ]([\\d.]+)/)||[])[1],2k:/75/.11(v),2G:/2G/.11(v),1f:/1f/.11(v)&&!/2G/.11(v),42:/42/.11(v)&&!/(9s|75)/.11(v)};J y=D.14.1f?"7o":"72";D.1l({71:!D.14.1f||S.70=="6Z",3X:{"R":"9n","9k":"1F","4i":y,72:y,7o:y,9h:"9f",9e:"9d",9b:"99"}});D.P({6W:H(a){I a.1d},97:H(a){I D.4S(a,"1d")},95:H(a){I D.3a(a,2,"2H")},91:H(a){I D.3a(a,2,"4l")},8Z:H(a){I D.4S(a,"2H")},8X:H(a){I D.4S(a,"4l")},8W:H(a){I D.5v(a.1d.1x,a)},8V:H(a){I D.5v(a.1x)},6Q:H(a){I D.Y(a,"8U")?a.8T||a.8S.S:D.2d(a.3t)}},H(c,d){D.17[c]=H(b){J a=D.2l(7,d);G(b&&1j b=="23")a=D.3g(b,a);I 7.2I(D.4r(a))}});D.P({6P:"3v",8Q:"6F",39:"6E",8P:"5q",8O:"7b"},H(c,b){D.17[c]=H(){J a=19;I 7.P(H(){R(J i=0,K=a.K;i<K;i++)D(a[i])[b](7)})}});D.P({8N:H(a){D.1K(7,a,"");G(7.16==1)7.5l(a)},8M:H(a){D.1F.1e(7,a)},8L:H(a){D.1F.21(7,a)},8K:H(a){D.1F[D.1F.3T(7,a)?"21":"1e"](7,a)},21:H(a){G(!a||D.1E(a,[7]).r.K){D("*",7).1e(7).P(H(){D.W.21(7);D.3b(7)});G(7.1d)7.1d.37(7)}},4E:H(){D(">*",7).21();1B(7.1x)7.37(7.1x)}},H(a,b){D.17[a]=H(){I 7.P(b,19)}});D.P(["6N","4b"],H(i,c){J b=c.3y();D.17[b]=H(a){I 7[0]==1b?D.14.2G&&S.1c["5t"+c]||D.14.2k&&1b["5s"+c]||S.70=="6Z"&&S.1C["5t"+c]||S.1c["5t"+c]:7[0]==S?29.2f(29.2f(S.1c["4y"+c],S.1C["4y"+c]),29.2f(S.1c["2i"+c],S.1C["2i"+c])):a==12?(7.K?D.1g(7[0],b):U):7.1g(b,a.1q==56?a:a+"2X")}});H 25(a,b){I a[0]&&3r(D.2a(a[0],b,M),10)||0}J C=D.14.2k&&3r(D.14.5B)<8H?"(?:[\\\\w*3m-]|\\\\\\\\.)":"(?:[\\\\w\\8F-\\8E*3m-]|\\\\\\\\.)",6L=2B 4v("^>\\\\s*("+C+"+)"),6J=2B 4v("^("+C+"+)(#)("+C+"+)"),6I=2B 4v("^([#.]?)("+C+"*)");D.1l({6H:{"":H(a,i,m){I m[2]=="*"||D.Y(a,m[2])},"#":H(a,i,m){I a.4G("2v")==m[2]},":":{8D:H(a,i,m){I i<m[3]-0},8C:H(a,i,m){I i>m[3]-0},3a:H(a,i,m){I m[3]-0==i},79:H(a,i,m){I m[3]-0==i},3o:H(a,i){I i==0},3S:H(a,i,m,r){I i==r.K-1},6D:H(a,i){I i%2==0},6C:H(a,i){I i%2},"3o-4u":H(a){I a.1d.3H("*")[0]==a},"3S-4u":H(a){I D.3a(a.1d.5T,1,"4l")==a},"8z-4u":H(a){I!D.3a(a.1d.5T,2,"4l")},6W:H(a){I a.1x},4E:H(a){I!a.1x},8y:H(a,i,m){I(a.6O||a.8x||D(a).1r()||"").1h(m[3])>=0},4j:H(a){I"1G"!=a.O&&D.1g(a,"18")!="2F"&&D.1g(a,"5g")!="1G"},1G:H(a){I"1G"==a.O||D.1g(a,"18")=="2F"||D.1g(a,"5g")=="1G"},8w:H(a){I!a.3R},3R:H(a){I a.3R},4J:H(a){I a.4J},2W:H(a){I a.2W||D.1K(a,"2W")},1r:H(a){I"1r"==a.O},5O:H(a){I"5O"==a.O},5L:H(a){I"5L"==a.O},5p:H(a){I"5p"==a.O},3Q:H(a){I"3Q"==a.O},5o:H(a){I"5o"==a.O},6A:H(a){I"6A"==a.O},6z:H(a){I"6z"==a.O},2s:H(a){I"2s"==a.O||D.Y(a,"2s")},4T:H(a){I/4T|2A|6y|2s/i.11(a.Y)},3T:H(a,i,m){I D.2q(m[3],a).K},8t:H(a){I/h\\d/i.11(a.Y)},8s:H(a){I D.3C(D.3O,H(b){I a==b.T}).K}}},6x:[/^(\\[) *@?([\\w-]+) *([!*$^~=]*) *(\'?"?)(.*?)\\4 *\\]/,/^(:)([\\w-]+)\\("?\'?(.*?(\\(.*?\\))?[^(]*?)"?\'?\\)/,2B 4v("^([:.#]*)("+C+"+)")],3g:H(a,c,b){J d,1t=[];1B(a&&a!=d){d=a;J f=D.1E(a,c,b);a=f.t.1o(/^\\s*,\\s*/,"");1t=b?c=f.r:D.2R(1t,f.r)}I 1t},2q:H(t,o){G(1j t!="23")I[t];G(o&&o.16!=1&&o.16!=9)I[];o=o||S;J d=[o],2o=[],3S,Y;1B(t&&3S!=t){J r=[];3S=t;t=D.3k(t);J l=Q,3j=6L,m=3j.2D(t);G(m){Y=m[1].2r();R(J i=0;d[i];i++)R(J c=d[i].1x;c;c=c.2H)G(c.16==1&&(Y=="*"||c.Y.2r()==Y))r.1p(c);d=r;t=t.1o(3j,"");G(t.1h(" ")==0)6M;l=M}N{3j=/^([>+~])\\s*(\\w*)/i;G((m=3j.2D(t))!=U){r=[];J k={};Y=m[2].2r();m=m[1];R(J j=0,3i=d.K;j<3i;j++){J n=m=="~"||m=="+"?d[j].2H:d[j].1x;R(;n;n=n.2H)G(n.16==1){J g=D.L(n);G(m=="~"&&k[g])1X;G(!Y||n.Y.2r()==Y){G(m=="~")k[g]=M;r.1p(n)}G(m=="+")1X}}d=r;t=D.3k(t.1o(3j,""));l=M}}G(t&&!l){G(!t.1h(",")){G(o==d[0])d.4s();2o=D.2R(2o,d);r=d=[o];t=" "+t.6v(1,t.K)}N{J h=6J;J m=h.2D(t);G(m){m=[0,m[2],m[3],m[1]]}N{h=6I;m=h.2D(t)}m[2]=m[2].1o(/\\\\/g,"");J f=d[d.K-1];G(m[1]=="#"&&f&&f.61&&!D.4n(f)){J p=f.61(m[2]);G((D.14.1f||D.14.2G)&&p&&1j p.2v=="23"&&p.2v!=m[2])p=D(\'[@2v="\'+m[2]+\'"]\',f)[0];d=r=p&&(!m[3]||D.Y(p,m[3]))?[p]:[]}N{R(J i=0;d[i];i++){J a=m[1]=="#"&&m[3]?m[3]:m[1]!=""||m[0]==""?"*":m[2];G(a=="*"&&d[i].Y.3y()=="49")a="3n";r=D.2R(r,d[i].3H(a))}G(m[1]==".")r=D.5m(r,m[2]);G(m[1]=="#"){J e=[];R(J i=0;r[i];i++)G(r[i].4G("2v")==m[2]){e=[r[i]];1X}r=e}d=r}t=t.1o(h,"")}}G(t){J b=D.1E(t,r);d=r=b.r;t=D.3k(b.t)}}G(t)d=[];G(d&&o==d[0])d.4s();2o=D.2R(2o,d);I 2o},5m:H(r,m,a){m=" "+m+" ";J c=[];R(J i=0;r[i];i++){J b=(" "+r[i].1F+" ").1h(m)>=0;G(!a&&b||a&&!b)c.1p(r[i])}I c},1E:H(t,r,h){J d;1B(t&&t!=d){d=t;J p=D.6x,m;R(J i=0;p[i];i++){m=p[i].2D(t);G(m){t=t.8r(m[0].K);m[2]=m[2].1o(/\\\\/g,"");1X}}G(!m)1X;G(m[1]==":"&&m[2]=="4Y")r=62.11(m[3])?D.1E(m[3],r,M).r:D(r).4Y(m[3]);N G(m[1]==".")r=D.5m(r,m[2],h);N G(m[1]=="["){J g=[],O=m[3];R(J i=0,3i=r.K;i<3i;i++){J a=r[i],z=a[D.3X[m[2]]||m[2]];G(z==U||/5Q|4d|2W/.11(m[2]))z=D.1K(a,m[2])||\'\';G((O==""&&!!z||O=="="&&z==m[5]||O=="!="&&z!=m[5]||O=="^="&&z&&!z.1h(m[5])||O=="$="&&z.6v(z.K-m[5].K)==m[5]||(O=="*="||O=="~=")&&z.1h(m[5])>=0)^h)g.1p(a)}r=g}N G(m[1]==":"&&m[2]=="3a-4u"){J e={},g=[],11=/(-?)(\\d*)n((?:\\+|-)?\\d*)/.2D(m[3]=="6D"&&"2n"||m[3]=="6C"&&"2n+1"||!/\\D/.11(m[3])&&"8q+"+m[3]||m[3]),3o=(11[1]+(11[2]||1))-0,d=11[3]-0;R(J i=0,3i=r.K;i<3i;i++){J j=r[i],1d=j.1d,2v=D.L(1d);G(!e[2v]){J c=1;R(J n=1d.1x;n;n=n.2H)G(n.16==1)n.4q=c++;e[2v]=M}J b=Q;G(3o==0){G(j.4q==d)b=M}N G((j.4q-d)%3o==0&&(j.4q-d)/3o>=0)b=M;G(b^h)g.1p(j)}r=g}N{J f=D.6H[m[1]];G(1j f=="49")f=f[m[2]];G(1j f=="23")f=6u("Q||H(a,i){I "+f+";}");r=D.3C(r,H(a,i){I f(a,i,m,r)},h)}}I{r:r,t:t}},4S:H(b,c){J a=[],1t=b[c];1B(1t&&1t!=S){G(1t.16==1)a.1p(1t);1t=1t[c]}I a},3a:H(a,e,c,b){e=e||1;J d=0;R(;a;a=a[c])G(a.16==1&&++d==e)1X;I a},5v:H(n,a){J r=[];R(;n;n=n.2H){G(n.16==1&&n!=a)r.1p(n)}I r}});D.W={1e:H(f,i,g,e){G(f.16==3||f.16==8)I;G(D.14.1f&&f.4I)f=1b;G(!g.24)g.24=7.24++;G(e!=12){J h=g;g=7.3M(h,H(){I h.1w(7,19)});g.L=e}J j=D.L(f,"3w")||D.L(f,"3w",{}),1H=D.L(f,"1H")||D.L(f,"1H",H(){G(1j D!="12"&&!D.W.5k)I D.W.1H.1w(19.3L.T,19)});1H.T=f;D.P(i.1R(/\\s+/),H(c,b){J a=b.1R(".");b=a[0];g.O=a[1];J d=j[b];G(!d){d=j[b]={};G(!D.W.2t[b]||D.W.2t[b].4p.1k(f)===Q){G(f.3K)f.3K(b,1H,Q);N G(f.6t)f.6t("4o"+b,1H)}}d[g.24]=g;D.W.26[b]=M});f=U},24:1,26:{},21:H(e,h,f){G(e.16==3||e.16==8)I;J i=D.L(e,"3w"),1L,5i;G(i){G(h==12||(1j h=="23"&&h.8p(0)=="."))R(J g 1n i)7.21(e,g+(h||""));N{G(h.O){f=h.2y;h=h.O}D.P(h.1R(/\\s+/),H(b,a){J c=a.1R(".");a=c[0];G(i[a]){G(f)2U i[a][f.24];N R(f 1n i[a])G(!c[1]||i[a][f].O==c[1])2U i[a][f];R(1L 1n i[a])1X;G(!1L){G(!D.W.2t[a]||D.W.2t[a].4A.1k(e)===Q){G(e.6p)e.6p(a,D.L(e,"1H"),Q);N G(e.6n)e.6n("4o"+a,D.L(e,"1H"))}1L=U;2U i[a]}}})}R(1L 1n i)1X;G(!1L){J d=D.L(e,"1H");G(d)d.T=U;D.3b(e,"3w");D.3b(e,"1H")}}},1P:H(h,c,f,g,i){c=D.2d(c);G(h.1h("!")>=0){h=h.3s(0,-1);J a=M}G(!f){G(7.26[h])D("*").1e([1b,S]).1P(h,c)}N{G(f.16==3||f.16==8)I 12;J b,1L,17=D.1D(f[h]||U),W=!c[0]||!c[0].32;G(W){c.6h({O:h,2J:f,32:H(){},3J:H(){},4C:1z()});c[0][E]=M}c[0].O=h;G(a)c[0].6m=M;J d=D.L(f,"1H");G(d)b=d.1w(f,c);G((!17||(D.Y(f,\'a\')&&h=="4V"))&&f["4o"+h]&&f["4o"+h].1w(f,c)===Q)b=Q;G(W)c.4s();G(i&&D.1D(i)){1L=i.1w(f,b==U?c:c.7d(b));G(1L!==12)b=1L}G(17&&g!==Q&&b!==Q&&!(D.Y(f,\'a\')&&h=="4V")){7.5k=M;1U{f[h]()}1V(e){}}7.5k=Q}I b},1H:H(b){J a,1L,38,5f,4m;b=19[0]=D.W.6l(b||1b.W);38=b.O.1R(".");b.O=38[0];38=38[1];5f=!38&&!b.6m;4m=(D.L(7,"3w")||{})[b.O];R(J j 1n 4m){J c=4m[j];G(5f||c.O==38){b.2y=c;b.L=c.L;1L=c.1w(7,19);G(a!==Q)a=1L;G(1L===Q){b.32();b.3J()}}}I a},6l:H(b){G(b[E]==M)I b;J d=b;b={8o:d};J c="8n 8m 8l 8k 2s 8j 47 5d 6j 5E 8i L 8h 8g 4K 2y 5a 59 8e 8b 58 6f 8a 88 4k 87 86 84 6d 2J 4C 6c O 82 81 35".1R(" ");R(J i=c.K;i;i--)b[c[i]]=d[c[i]];b[E]=M;b.32=H(){G(d.32)d.32();d.80=Q};b.3J=H(){G(d.3J)d.3J();d.7Z=M};b.4C=b.4C||1z();G(!b.2J)b.2J=b.6d||S;G(b.2J.16==3)b.2J=b.2J.1d;G(!b.4k&&b.4K)b.4k=b.4K==b.2J?b.6c:b.4K;G(b.58==U&&b.5d!=U){J a=S.1C,1c=S.1c;b.58=b.5d+(a&&a.2e||1c&&1c.2e||0)-(a.6b||0);b.6f=b.6j+(a&&a.2c||1c&&1c.2c||0)-(a.6a||0)}G(!b.35&&((b.47||b.47===0)?b.47:b.5a))b.35=b.47||b.5a;G(!b.59&&b.5E)b.59=b.5E;G(!b.35&&b.2s)b.35=(b.2s&1?1:(b.2s&2?3:(b.2s&4?2:0)));I b},3M:H(a,b){b.24=a.24=a.24||b.24||7.24++;I b},2t:{27:{4p:H(){55();I},4A:H(){I}},3D:{4p:H(){G(D.14.1f)I Q;D(7).2O("53",D.W.2t.3D.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("53",D.W.2t.3D.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3D";I D.W.1H.1w(7,19)}},3N:{4p:H(){G(D.14.1f)I Q;D(7).2O("51",D.W.2t.3N.2y);I M},4A:H(){G(D.14.1f)I Q;D(7).4e("51",D.W.2t.3N.2y);I M},2y:H(a){G(F(a,7))I M;a.O="3N";I D.W.1H.1w(7,19)}}}};D.17.1l({2O:H(c,a,b){I c=="4X"?7.2V(c,a,b):7.P(H(){D.W.1e(7,c,b||a,b&&a)})},2V:H(d,b,c){J e=D.W.3M(c||b,H(a){D(7).4e(a,e);I(c||b).1w(7,19)});I 7.P(H(){D.W.1e(7,d,e,c&&b)})},4e:H(a,b){I 7.P(H(){D.W.21(7,a,b)})},1P:H(c,a,b){I 7.P(H(){D.W.1P(c,a,7,M,b)})},5C:H(c,a,b){I 7[0]&&D.W.1P(c,a,7[0],Q,b)},2m:H(b){J c=19,i=1;1B(i<c.K)D.W.3M(b,c[i++]);I 7.4V(D.W.3M(b,H(a){7.4Z=(7.4Z||0)%i;a.32();I c[7.4Z++].1w(7,19)||Q}))},7X:H(a,b){I 7.2O(\'3D\',a).2O(\'3N\',b)},27:H(a){55();G(D.2Q)a.1k(S,D);N D.3A.1p(H(){I a.1k(7,D)});I 7}});D.1l({2Q:Q,3A:[],27:H(){G(!D.2Q){D.2Q=M;G(D.3A){D.P(D.3A,H(){7.1k(S)});D.3A=U}D(S).5C("27")}}});J x=Q;H 55(){G(x)I;x=M;G(S.3K&&!D.14.2G)S.3K("69",D.27,Q);G(D.14.1f&&1b==1S)(H(){G(D.2Q)I;1U{S.1C.7V("1A")}1V(3e){3B(19.3L,0);I}D.27()})();G(D.14.2G)S.3K("69",H(){G(D.2Q)I;R(J i=0;i<S.4W.K;i++)G(S.4W[i].3R){3B(19.3L,0);I}D.27()},Q);G(D.14.2k){J a;(H(){G(D.2Q)I;G(S.3f!="68"&&S.3f!="1J"){3B(19.3L,0);I}G(a===12)a=D("V, 7A[7U=7S]").K;G(S.4W.K!=a){3B(19.3L,0);I}D.27()})()}D.W.1e(1b,"43",D.27)}D.P(("7R,7Q,43,85,4y,4X,4V,7P,"+"7O,7N,89,53,51,7M,2A,"+"5o,7L,7K,8d,3e").1R(","),H(i,b){D.17[b]=H(a){I a?7.2O(b,a):7.1P(b)}});J F=H(a,c){J b=a.4k;1B(b&&b!=c)1U{b=b.1d}1V(3e){b=c}I b==c};D(1b).2O("4X",H(){D("*").1e(S).4e()});D.17.1l({67:D.17.43,43:H(g,d,c){G(1j g!=\'23\')I 7.67(g);J e=g.1h(" ");G(e>=0){J i=g.3s(e,g.K);g=g.3s(0,e)}c=c||H(){};J f="2P";G(d)G(D.1D(d)){c=d;d=U}N{d=D.3n(d);f="6g"}J h=7;D.3Y({1a:g,O:f,1O:"2K",L:d,1J:H(a,b){G(b=="1W"||b=="7J")h.2K(i?D("<1v/>").3v(a.4U.1o(/<1m(.|\\s)*?\\/1m>/g,"")).2q(i):a.4U);h.P(c,[a.4U,b,a])}});I 7},aL:H(){I D.3n(7.7I())},7I:H(){I 7.2l(H(){I D.Y(7,"3V")?D.2d(7.aH):7}).1E(H(){I 7.34&&!7.3R&&(7.4J||/2A|6y/i.11(7.Y)||/1r|1G|3Q/i.11(7.O))}).2l(H(i,c){J b=D(7).6e();I b==U?U:b.1q==2p?D.2l(b,H(a,i){I{34:c.34,2x:a}}):{34:c.34,2x:b}}).3p()}});D.P("7H,7G,7F,7D,7C,7B".1R(","),H(i,o){D.17[o]=H(f){I 7.2O(o,f)}});J B=1z();D.1l({3p:H(d,b,a,c){G(D.1D(b)){a=b;b=U}I D.3Y({O:"2P",1a:d,L:b,1W:a,1O:c})},aE:H(b,a){I D.3p(b,U,a,"1m")},aD:H(c,b,a){I D.3p(c,b,a,"3z")},aC:H(d,b,a,c){G(D.1D(b)){a=b;b={}}I D.3Y({O:"6g",1a:d,L:b,1W:a,1O:c})},aA:H(a){D.1l(D.60,a)},60:{1a:5Z.5Q,26:M,O:"2P",2T:0,7z:"4R/x-ax-3V-aw",7x:M,31:M,L:U,5Y:U,3Q:U,4Q:{2N:"4R/2N, 1r/2N",2K:"1r/2K",1m:"1r/4t, 4R/4t",3z:"4R/3z, 1r/4t",1r:"1r/as",4w:"*/*"}},4z:{},3Y:H(s){s=D.1l(M,s,D.1l(M,{},D.60,s));J g,2Z=/=\\?(&|$)/g,1u,L,O=s.O.2r();G(s.L&&s.7x&&1j s.L!="23")s.L=D.3n(s.L);G(s.1O=="4P"){G(O=="2P"){G(!s.1a.1I(2Z))s.1a+=(s.1a.1I(/\\?/)?"&":"?")+(s.4P||"7u")+"=?"}N G(!s.L||!s.L.1I(2Z))s.L=(s.L?s.L+"&":"")+(s.4P||"7u")+"=?";s.1O="3z"}G(s.1O=="3z"&&(s.L&&s.L.1I(2Z)||s.1a.1I(2Z))){g="4P"+B++;G(s.L)s.L=(s.L+"").1o(2Z,"="+g+"$1");s.1a=s.1a.1o(2Z,"="+g+"$1");s.1O="1m";1b[g]=H(a){L=a;1W();1J();1b[g]=12;1U{2U 1b[g]}1V(e){}G(i)i.37(h)}}G(s.1O=="1m"&&s.1Y==U)s.1Y=Q;G(s.1Y===Q&&O=="2P"){J j=1z();J k=s.1a.1o(/(\\?|&)3m=.*?(&|$)/,"$ap="+j+"$2");s.1a=k+((k==s.1a)?(s.1a.1I(/\\?/)?"&":"?")+"3m="+j:"")}G(s.L&&O=="2P"){s.1a+=(s.1a.1I(/\\?/)?"&":"?")+s.L;s.L=U}G(s.26&&!D.4O++)D.W.1P("7H");J n=/^(?:\\w+:)?\\/\\/([^\\/?#]+)/;G(s.1O=="1m"&&O=="2P"&&n.11(s.1a)&&n.2D(s.1a)[1]!=5Z.al){J i=S.3H("6w")[0];J h=S.3h("1m");h.4d=s.1a;G(s.7t)h.aj=s.7t;G(!g){J l=Q;h.ah=h.ag=H(){G(!l&&(!7.3f||7.3f=="68"||7.3f=="1J")){l=M;1W();1J();i.37(h)}}}i.3U(h);I 12}J m=Q;J c=1b.7s?2B 7s("ae.ac"):2B 7r();G(s.5Y)c.6R(O,s.1a,s.31,s.5Y,s.3Q);N c.6R(O,s.1a,s.31);1U{G(s.L)c.4B("ab-aa",s.7z);G(s.5S)c.4B("a9-5R-a8",D.4z[s.1a]||"a7, a6 a5 a4 5N:5N:5N a2");c.4B("X-9Z-9Y","7r");c.4B("9W",s.1O&&s.4Q[s.1O]?s.4Q[s.1O]+", */*":s.4Q.4w)}1V(e){}G(s.7m&&s.7m(c,s)===Q){s.26&&D.4O--;c.7l();I Q}G(s.26)D.W.1P("7B",[c,s]);J d=H(a){G(!m&&c&&(c.3f==4||a=="2T")){m=M;G(f){7k(f);f=U}1u=a=="2T"&&"2T"||!D.7j(c)&&"3e"||s.5S&&D.7h(c,s.1a)&&"7J"||"1W";G(1u=="1W"){1U{L=D.6X(c,s.1O,s.9S)}1V(e){1u="5J"}}G(1u=="1W"){J b;1U{b=c.5I("7g-5R")}1V(e){}G(s.5S&&b)D.4z[s.1a]=b;G(!g)1W()}N D.5H(s,c,1u);1J();G(s.31)c=U}};G(s.31){J f=4I(d,13);G(s.2T>0)3B(H(){G(c){c.7l();G(!m)d("2T")}},s.2T)}1U{c.9P(s.L)}1V(e){D.5H(s,c,U,e)}G(!s.31)d();H 1W(){G(s.1W)s.1W(L,1u);G(s.26)D.W.1P("7C",[c,s])}H 1J(){G(s.1J)s.1J(c,1u);G(s.26)D.W.1P("7F",[c,s]);G(s.26&&!--D.4O)D.W.1P("7G")}I c},5H:H(s,a,b,e){G(s.3e)s.3e(a,b,e);G(s.26)D.W.1P("7D",[a,s,e])},4O:0,7j:H(a){1U{I!a.1u&&5Z.9O=="5p:"||(a.1u>=7e&&a.1u<9N)||a.1u==7c||a.1u==9K||D.14.2k&&a.1u==12}1V(e){}I Q},7h:H(a,c){1U{J b=a.5I("7g-5R");I a.1u==7c||b==D.4z[c]||D.14.2k&&a.1u==12}1V(e){}I Q},6X:H(a,c,b){J d=a.5I("9J-O"),2N=c=="2N"||!c&&d&&d.1h("2N")>=0,L=2N?a.9I:a.4U;G(2N&&L.1C.2j=="5J")7p"5J";G(b)L=b(L,c);G(c=="1m")D.5u(L);G(c=="3z")L=6u("("+L+")");I L},3n:H(a){J s=[];G(a.1q==2p||a.5w)D.P(a,H(){s.1p(3u(7.34)+"="+3u(7.2x))});N R(J j 1n a)G(a[j]&&a[j].1q==2p)D.P(a[j],H(){s.1p(3u(j)+"="+3u(7))});N s.1p(3u(j)+"="+3u(D.1D(a[j])?a[j]():a[j]));I s.6s("&").1o(/%20/g,"+")}});D.17.1l({1N:H(c,b){I c?7.2g({1Z:"1N",2h:"1N",1y:"1N"},c,b):7.1E(":1G").P(H(){7.V.18=7.5D||"";G(D.1g(7,"18")=="2F"){J a=D("<"+7.2j+" />").6P("1c");7.V.18=a.1g("18");G(7.V.18=="2F")7.V.18="3I";a.21()}}).3l()},1M:H(b,a){I b?7.2g({1Z:"1M",2h:"1M",1y:"1M"},b,a):7.1E(":4j").P(H(){7.5D=7.5D||D.1g(7,"18");7.V.18="2F"}).3l()},78:D.17.2m,2m:H(a,b){I D.1D(a)&&D.1D(b)?7.78.1w(7,19):a?7.2g({1Z:"2m",2h:"2m",1y:"2m"},a,b):7.P(H(){D(7)[D(7).3F(":1G")?"1N":"1M"]()})},9G:H(b,a){I 7.2g({1Z:"1N"},b,a)},9F:H(b,a){I 7.2g({1Z:"1M"},b,a)},9E:H(b,a){I 7.2g({1Z:"2m"},b,a)},9D:H(b,a){I 7.2g({1y:"1N"},b,a)},9M:H(b,a){I 7.2g({1y:"1M"},b,a)},9C:H(c,a,b){I 7.2g({1y:a},c,b)},2g:H(k,j,i,g){J h=D.77(j,i,g);I 7[h.36===Q?"P":"36"](H(){G(7.16!=1)I Q;J f=D.1l({},h),p,1G=D(7).3F(":1G"),46=7;R(p 1n k){G(k[p]=="1M"&&1G||k[p]=="1N"&&!1G)I f.1J.1k(7);G(p=="1Z"||p=="2h"){f.18=D.1g(7,"18");f.33=7.V.33}}G(f.33!=U)7.V.33="1G";f.45=D.1l({},k);D.P(k,H(c,a){J e=2B D.28(46,f,c);G(/2m|1N|1M/.11(a))e[a=="2m"?1G?"1N":"1M":a](k);N{J b=a.6r().1I(/^([+-]=)?([\\d+-.]+)(.*)$/),2b=e.1t(M)||0;G(b){J d=3d(b[2]),2M=b[3]||"2X";G(2M!="2X"){46.V[c]=(d||1)+2M;2b=((d||1)/e.1t(M))*2b;46.V[c]=2b+2M}G(b[1])d=((b[1]=="-="?-1:1)*d)+2b;e.3G(2b,d,2M)}N e.3G(2b,a,"")}});I M})},36:H(a,b){G(D.1D(a)||(a&&a.1q==2p)){b=a;a="28"}G(!a||(1j a=="23"&&!b))I A(7[0],a);I 7.P(H(){G(b.1q==2p)A(7,a,b);N{A(7,a).1p(b);G(A(7,a).K==1)b.1k(7)}})},9X:H(b,c){J a=D.3O;G(b)7.36([]);7.P(H(){R(J i=a.K-1;i>=0;i--)G(a[i].T==7){G(c)a[i](M);a.7n(i,1)}});G(!c)7.5A();I 7}});J A=H(b,c,a){G(b){c=c||"28";J q=D.L(b,c+"36");G(!q||a)q=D.L(b,c+"36",D.2d(a))}I q};D.17.5A=H(a){a=a||"28";I 7.P(H(){J q=A(7,a);q.4s();G(q.K)q[0].1k(7)})};D.1l({77:H(b,a,c){J d=b&&b.1q==a0?b:{1J:c||!c&&a||D.1D(b)&&b,2u:b,41:c&&a||a&&a.1q!=9t&&a};d.2u=(d.2u&&d.2u.1q==4L?d.2u:D.28.5K[d.2u])||D.28.5K.74;d.5M=d.1J;d.1J=H(){G(d.36!==Q)D(7).5A();G(D.1D(d.5M))d.5M.1k(7)};I d},41:{73:H(p,n,b,a){I b+a*p},5P:H(p,n,b,a){I((-29.9r(p*29.9q)/2)+0.5)*a+b}},3O:[],48:U,28:H(b,c,a){7.15=c;7.T=b;7.1i=a;G(!c.3Z)c.3Z={}}});D.28.44={4D:H(){G(7.15.2Y)7.15.2Y.1k(7.T,7.1z,7);(D.28.2Y[7.1i]||D.28.2Y.4w)(7);G(7.1i=="1Z"||7.1i=="2h")7.T.V.18="3I"},1t:H(a){G(7.T[7.1i]!=U&&7.T.V[7.1i]==U)I 7.T[7.1i];J r=3d(D.1g(7.T,7.1i,a));I r&&r>-9p?r:3d(D.2a(7.T,7.1i))||0},3G:H(c,b,d){7.5V=1z();7.2b=c;7.3l=b;7.2M=d||7.2M||"2X";7.1z=7.2b;7.2S=7.4N=0;7.4D();J e=7;H t(a){I e.2Y(a)}t.T=7.T;D.3O.1p(t);G(D.48==U){D.48=4I(H(){J a=D.3O;R(J i=0;i<a.K;i++)G(!a[i]())a.7n(i--,1);G(!a.K){7k(D.48);D.48=U}},13)}},1N:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1N=M;7.3G(0,7.1t());G(7.1i=="2h"||7.1i=="1Z")7.T.V[7.1i]="9m";D(7.T).1N()},1M:H(){7.15.3Z[7.1i]=D.1K(7.T.V,7.1i);7.15.1M=M;7.3G(7.1t(),0)},2Y:H(a){J t=1z();G(a||t>7.15.2u+7.5V){7.1z=7.3l;7.2S=7.4N=1;7.4D();7.15.45[7.1i]=M;J b=M;R(J i 1n 7.15.45)G(7.15.45[i]!==M)b=Q;G(b){G(7.15.18!=U){7.T.V.33=7.15.33;7.T.V.18=7.15.18;G(D.1g(7.T,"18")=="2F")7.T.V.18="3I"}G(7.15.1M)7.T.V.18="2F";G(7.15.1M||7.15.1N)R(J p 1n 7.15.45)D.1K(7.T.V,p,7.15.3Z[p])}G(b)7.15.1J.1k(7.T);I Q}N{J n=t-7.5V;7.4N=n/7.15.2u;7.2S=D.41[7.15.41||(D.41.5P?"5P":"73")](7.4N,n,0,1,7.15.2u);7.1z=7.2b+((7.3l-7.2b)*7.2S);7.4D()}I M}};D.1l(D.28,{5K:{9l:9j,9i:7e,74:9g},2Y:{2e:H(a){a.T.2e=a.1z},2c:H(a){a.T.2c=a.1z},1y:H(a){D.1K(a.T.V,"1y",a.1z)},4w:H(a){a.T.V[a.1i]=a.1z+a.2M}}});D.17.2i=H(){J b=0,1S=0,T=7[0],3q;G(T)ao(D.14){J d=T.1d,4a=T,1s=T.1s,1Q=T.2z,5U=2k&&3r(5B)<9c&&!/9a/i.11(v),1g=D.2a,3c=1g(T,"30")=="3c";G(T.7y){J c=T.7y();1e(c.1A+29.2f(1Q.1C.2e,1Q.1c.2e),c.1S+29.2f(1Q.1C.2c,1Q.1c.2c));1e(-1Q.1C.6b,-1Q.1C.6a)}N{1e(T.5X,T.5W);1B(1s){1e(1s.5X,1s.5W);G(42&&!/^t(98|d|h)$/i.11(1s.2j)||2k&&!5U)2C(1s);G(!3c&&1g(1s,"30")=="3c")3c=M;4a=/^1c$/i.11(1s.2j)?4a:1s;1s=1s.1s}1B(d&&d.2j&&!/^1c|2K$/i.11(d.2j)){G(!/^96|1T.*$/i.11(1g(d,"18")))1e(-d.2e,-d.2c);G(42&&1g(d,"33")!="4j")2C(d);d=d.1d}G((5U&&(3c||1g(4a,"30")=="5x"))||(42&&1g(4a,"30")!="5x"))1e(-1Q.1c.5X,-1Q.1c.5W);G(3c)1e(29.2f(1Q.1C.2e,1Q.1c.2e),29.2f(1Q.1C.2c,1Q.1c.2c))}3q={1S:1S,1A:b}}H 2C(a){1e(D.2a(a,"6V",M),D.2a(a,"6U",M))}H 1e(l,t){b+=3r(l,10)||0;1S+=3r(t,10)||0}I 3q};D.17.1l({30:H(){J a=0,1S=0,3q;G(7[0]){J b=7.1s(),2i=7.2i(),4c=/^1c|2K$/i.11(b[0].2j)?{1S:0,1A:0}:b.2i();2i.1S-=25(7,\'94\');2i.1A-=25(7,\'aF\');4c.1S+=25(b,\'6U\');4c.1A+=25(b,\'6V\');3q={1S:2i.1S-4c.1S,1A:2i.1A-4c.1A}}I 3q},1s:H(){J a=7[0].1s;1B(a&&(!/^1c|2K$/i.11(a.2j)&&D.1g(a,\'30\')==\'93\'))a=a.1s;I D(a)}});D.P([\'5e\',\'5G\'],H(i,b){J c=\'4y\'+b;D.17[c]=H(a){G(!7[0])I;I a!=12?7.P(H(){7==1b||7==S?1b.92(!i?a:D(1b).2e(),i?a:D(1b).2c()):7[c]=a}):7[0]==1b||7[0]==S?46[i?\'aI\':\'aJ\']||D.71&&S.1C[c]||S.1c[c]:7[0][c]}});D.P(["6N","4b"],H(i,b){J c=i?"5e":"5G",4f=i?"6k":"6i";D.17["5s"+b]=H(){I 7[b.3y()]()+25(7,"57"+c)+25(7,"57"+4f)};D.17["90"+b]=H(a){I 7["5s"+b]()+25(7,"2C"+c+"4b")+25(7,"2C"+4f+"4b")+(a?25(7,"6S"+c)+25(7,"6S"+4f):0)}})})();',62,669,'|||||||this|||||||||||||||||||||||||||||||||||if|function|return|var|length|data|true|else|type|each|false|for|document|elem|null|style|event||nodeName|||test|undefined||browser|options|nodeType|fn|display|arguments|url|window|body|parentNode|add|msie|css|indexOf|prop|typeof|call|extend|script|in|replace|push|constructor|text|offsetParent|cur|status|div|apply|firstChild|opacity|now|left|while|documentElement|isFunction|filter|className|hidden|handle|match|complete|attr|ret|hide|show|dataType|trigger|doc|split|top|table|try|catch|success|break|cache|height||remove|tbody|string|guid|num|global|ready|fx|Math|curCSS|start|scrollTop|makeArray|scrollLeft|max|animate|width|offset|tagName|safari|map|toggle||done|Array|find|toUpperCase|button|special|duration|id|copy|value|handler|ownerDocument|select|new|border|exec|stack|none|opera|nextSibling|pushStack|target|html|inArray|unit|xml|bind|GET|isReady|merge|pos|timeout|delete|one|selected|px|step|jsre|position|async|preventDefault|overflow|name|which|queue|removeChild|namespace|insertBefore|nth|removeData|fixed|parseFloat|error|readyState|multiFilter|createElement|rl|re|trim|end|_|param|first|get|results|parseInt|slice|childNodes|encodeURIComponent|append|events|elems|toLowerCase|json|readyList|setTimeout|grep|mouseenter|color|is|custom|getElementsByTagName|block|stopPropagation|addEventListener|callee|proxy|mouseleave|timers|defaultView|password|disabled|last|has|appendChild|form|domManip|props|ajax|orig|set|easing|mozilla|load|prototype|curAnim|self|charCode|timerId|object|offsetChild|Width|parentOffset|src|unbind|br|currentStyle|clean|float|visible|relatedTarget|previousSibling|handlers|isXMLDoc|on|setup|nodeIndex|unique|shift|javascript|child|RegExp|_default|deep|scroll|lastModified|teardown|setRequestHeader|timeStamp|update|empty|tr|getAttribute|innerHTML|setInterval|checked|fromElement|Number|jQuery|state|active|jsonp|accepts|application|dir|input|responseText|click|styleSheets|unload|not|lastToggle|outline|mouseout|getPropertyValue|mouseover|getComputedStyle|bindReady|String|padding|pageX|metaKey|keyCode|getWH|andSelf|clientX|Left|all|visibility|container|index|init|triggered|removeAttribute|classFilter|prevObject|submit|file|after|windowData|inner|client|globalEval|sibling|jquery|absolute|clone|wrapAll|dequeue|version|triggerHandler|oldblock|ctrlKey|createTextNode|Top|handleError|getResponseHeader|parsererror|speeds|checkbox|old|00|radio|swing|href|Modified|ifModified|lastChild|safari2|startTime|offsetTop|offsetLeft|username|location|ajaxSettings|getElementById|isSimple|values|selectedIndex|runtimeStyle|rsLeft|_load|loaded|DOMContentLoaded|clientTop|clientLeft|toElement|srcElement|val|pageY|POST|unshift|Bottom|clientY|Right|fix|exclusive|detachEvent|cloneNode|removeEventListener|swap|toString|join|attachEvent|eval|substr|head|parse|textarea|reset|image|zoom|odd|even|before|prepend|exclude|expr|quickClass|quickID|uuid|quickChild|continue|Height|textContent|appendTo|contents|open|margin|evalScript|borderTopWidth|borderLeftWidth|parent|httpData|setArray|CSS1Compat|compatMode|boxModel|cssFloat|linear|def|webkit|nodeValue|speed|_toggle|eq|100|replaceWith|304|concat|200|alpha|Last|httpNotModified|getAttributeNode|httpSuccess|clearInterval|abort|beforeSend|splice|styleFloat|throw|colgroup|XMLHttpRequest|ActiveXObject|scriptCharset|callback|fieldset|multiple|processData|getBoundingClientRect|contentType|link|ajaxSend|ajaxSuccess|ajaxError|col|ajaxComplete|ajaxStop|ajaxStart|serializeArray|notmodified|keypress|keydown|change|mouseup|mousedown|dblclick|focus|blur|stylesheet|hasClass|rel|doScroll|black|hover|solid|cancelBubble|returnValue|wheelDelta|view|round|shiftKey|resize|screenY|screenX|relatedNode|mousemove|prevValue|originalTarget|offsetHeight|keyup|newValue|offsetWidth|eventPhase|detail|currentTarget|cancelable|bubbles|attrName|attrChange|altKey|originalEvent|charAt|0n|substring|animated|header|noConflict|line|enabled|innerText|contains|only|weight|font|gt|lt|uFFFF|u0128|size|417|Boolean|Date|toggleClass|removeClass|addClass|removeAttr|replaceAll|insertAfter|prependTo|wrap|contentWindow|contentDocument|iframe|children|siblings|prevAll|wrapInner|nextAll|outer|prev|scrollTo|static|marginTop|next|inline|parents|able|cellSpacing|adobeair|cellspacing|522|maxLength|maxlength|readOnly|400|readonly|fast|600|class|slow|1px|htmlFor|reverse|10000|PI|cos|compatible|Function|setData|ie|ra|it|rv|getData|userAgent|navigator|fadeTo|fadeIn|slideToggle|slideUp|slideDown|ig|responseXML|content|1223|NaN|fadeOut|300|protocol|send|setAttribute|option|dataFilter|cssText|changed|be|Accept|stop|With|Requested|Object|can|GMT|property|1970|Jan|01|Thu|Since|If|Type|Content|XMLHTTP|th|Microsoft|td|onreadystatechange|onload|cap|charset|colg|host|tfoot|specified|with|1_|thead|leg|plain|attributes|opt|embed|urlencoded|www|area|hr|ajaxSetup|meta|post|getJSON|getScript|marginLeft|img|elements|pageYOffset|pageXOffset|abbr|serialize|pixelLeft'.split('|'),0,{})); var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} }; /** * Set the variable that indicates if JavaScript behaviors should be applied */ Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById; /** * Attach all registered behaviors to a page element. * * Behaviors are event-triggered actions that attach to page elements, enhancing * default non-Javascript UIs. Behaviors are registered in the Drupal.behaviors * object as follows: * @code * Drupal.behaviors.behaviorName = function () { * ... * }; * @endcode * * Drupal.attachBehaviors is added below to the jQuery ready event and so * runs on initial page load. Developers implementing AHAH/AJAX in their * solutions should also call this function after new page content has been * loaded, feeding in an element to be processed, in order to attach all * behaviors to the new content. * * Behaviors should use a class in the form behaviorName-processed to ensure * the behavior is attached only once to a given element. (Doing so enables * the reprocessing of given elements, which may be needed on occasion despite * the ability to limit behavior attachment to a particular element.) * * @param context * An element to attach behaviors to. If none is given, the document element * is used. */ Drupal.attachBehaviors = function(context) { context = context || document; if (Drupal.jsEnabled) { // Execute all of them. jQuery.each(Drupal.behaviors, function() { this(context); }); } }; /** * Encode special characters in a plain-text string for display as HTML. */ Drupal.checkPlain = function(str) { str = String(str); var replace = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' }; for (var character in replace) { var regex = new RegExp(character, 'g'); str = str.replace(regex, replace[character]); } return str; }; /** * Translate strings to the page language or a given language. * * See the documentation of the server-side t() function for further details. * * @param str * A string containing the English string to translate. * @param args * An object of replacements pairs to make after translation. Incidences * of any key in this array are replaced with the corresponding value. * Based on the first character of the key, the value is escaped and/or themed: * - !variable: inserted as is * - @variable: escape plain text to HTML (Drupal.checkPlain) * - %variable: escape text and theme as a placeholder for user-submitted * content (checkPlain + Drupal.theme('placeholder')) * @return * The translated string. */ Drupal.t = function(str, args) { // Fetch the localized version of the string. if (Drupal.locale.strings && Drupal.locale.strings[str]) { str = Drupal.locale.strings[str]; } if (args) { // Transform arguments before inserting them for (var key in args) { switch (key.charAt(0)) { // Escaped only case '@': args[key] = Drupal.checkPlain(args[key]); break; // Pass-through case '!': break; // Escaped and placeholder case '%': default: args[key] = Drupal.theme('placeholder', args[key]); break; } str = str.replace(key, args[key]); } } return str; }; /** * Format a string containing a count of items. * * This function ensures that the string is pluralized correctly. Since Drupal.t() is * called by this function, make sure not to pass already-localized strings to it. * * See the documentation of the server-side format_plural() function for further details. * * @param count * The item count to display. * @param singular * The string for the singular case. Please make sure it is clear this is * singular, to ease translation (e.g. use "1 new comment" instead of "1 new"). * Do not use @count in the singular string. * @param plural * The string for the plural case. Please make sure it is clear this is plural, * to ease translation. Use @count in place of the item count, as in "@count * new comments". * @param args * An object of replacements pairs to make after translation. Incidences * of any key in this array are replaced with the corresponding value. * Based on the first character of the key, the value is escaped and/or themed: * - !variable: inserted as is * - @variable: escape plain text to HTML (Drupal.checkPlain) * - %variable: escape text and theme as a placeholder for user-submitted * content (checkPlain + Drupal.theme('placeholder')) * Note that you do not need to include @count in this array. * This replacement is done automatically for the plural case. * @return * A translated string. */ Drupal.formatPlural = function(count, singular, plural, args) { var args = args || {}; args['@count'] = count; // Determine the index of the plural form. var index = Drupal.locale.pluralFormula ? Drupal.locale.pluralFormula(args['@count']) : ((args['@count'] == 1) ? 0 : 1); if (index == 0) { return Drupal.t(singular, args); } else if (index == 1) { return Drupal.t(plural, args); } else { args['@count['+ index +']'] = args['@count']; delete args['@count']; return Drupal.t(plural.replace('@count', '@count['+ index +']')); } }; /** * Generate the themed representation of a Drupal object. * * All requests for themed output must go through this function. It examines * the request and routes it to the appropriate theme function. If the current * theme does not provide an override function, the generic theme function is * called. * * For example, to retrieve the HTML that is output by theme_placeholder(text), * call Drupal.theme('placeholder', text). * * @param func * The name of the theme function to call. * @param ... * Additional arguments to pass along to the theme function. * @return * Any data the theme function returns. This could be a plain HTML string, * but also a complex object. */ Drupal.theme = function(func) { for (var i = 1, args = []; i < arguments.length; i++) { args.push(arguments[i]); } return (Drupal.theme[func] || Drupal.theme.prototype[func]).apply(this, args); }; /** * Parse a JSON response. * * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message. */ Drupal.parseJson = function (data) { if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) { return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') }; } return eval('(' + data + ');'); }; /** * Freeze the current body height (as minimum height). Used to prevent * unnecessary upwards scrolling when doing DOM manipulations. */ Drupal.freezeHeight = function () { Drupal.unfreezeHeight(); var div = document.createElement('div'); $(div).css({ position: 'absolute', top: '0px', left: '0px', width: '1px', height: $('body').css('height') }).attr('id', 'freeze-height'); $('body').append(div); }; /** * Unfreeze the body height */ Drupal.unfreezeHeight = function () { $('#freeze-height').remove(); }; /** * Wrapper around encodeURIComponent() which avoids Apache quirks (equivalent of * drupal_urlencode() in PHP). This function should only be used on paths, not * on query string arguments. */ Drupal.encodeURIComponent = function (item, uri) { uri = uri || location.href; item = encodeURIComponent(item).replace(/%2F/g, '/'); return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F'); }; /** * Get the text selection in a textarea. */ Drupal.getSelection = function (element) { if (typeof(element.selectionStart) != 'number' && document.selection) { // The current selection var range1 = document.selection.createRange(); var range2 = range1.duplicate(); // Select all text. range2.moveToElementText(element); // Now move 'dummy' end point to end point of original range. range2.setEndPoint('EndToEnd', range1); // Now we can calculate start and end points. var start = range2.text.length - range1.text.length; var end = start + range1.text.length; return { 'start': start, 'end': end }; } return { 'start': element.selectionStart, 'end': element.selectionEnd }; }; /** * Build an error message from ahah response. */ Drupal.ahahError = function(xmlhttp, uri) { if (xmlhttp.status == 200) { if (jQuery.trim($(xmlhttp.responseText).text())) { var message = Drupal.t("An error occurred. \n@uri\n@text", {'@uri': uri, '@text': xmlhttp.responseText }); } else { var message = Drupal.t("An error occurred. \n@uri\n(no information available).", {'@uri': uri, '@text': xmlhttp.responseText }); } } else { var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status }); } return message; } // Global Killswitch on the <html> element if (Drupal.jsEnabled) { // Global Killswitch on the <html> element $(document.documentElement).addClass('js'); // 'js enabled' cookie document.cookie = 'has_js=1; path=/'; // Attach all behaviors. $(document).ready(function() { Drupal.attachBehaviors(this); }); } /** * The default themes. */ Drupal.theme.prototype = { /** * Formats text for emphasized display in a placeholder inside a sentence. * * @param str * The text to format (plain-text). * @return * The formatted text (html). */ placeholder: function(str) { return '<em>' + Drupal.checkPlain(str) + '</em>'; } }; ; // $Id: lightbox_modal.js,v 1.1.2.5 2010/06/07 17:22:03 snpower Exp $ function lightbox2_login() { $("a[href*='/user/login'], a[href*='?q=user/login']").each(function() { $(this).attr({ href: this.href.replace(/user\/login?/,"user/login/lightbox2"), rel: 'lightmodal[|width:250px; height:210px;]' }); $(this).addClass('lightmodal-login'); }); } function lightbox2_contact() { $("a[href$='/contact'], a[href$='?q=contact']").each(function() { if (!this.href.match('admin/build/contact')) { $(this).attr({ href: this.href.replace(/contact?/,"contact/lightbox2"), rel: 'lightmodal[|width:450px; height:450px;]' }); $(this).addClass('lightmodal-contact'); } }); } Drupal.behaviors.initLightboxModal = function (context) { if (Drupal.settings.lightbox2.enable_login) { lightbox2_login(); } if (Drupal.settings.lightbox2.enable_contact) { lightbox2_contact(); } }; ; /* $Id: lightbox.js,v 1.5.2.6.2.136 2010/09/24 08:39:40 snpower Exp $ */ /** * jQuery Lightbox * @author * Stella Power, <http://drupal.org/user/66894> * * Based on Lightbox v2.03.3 by Lokesh Dhakar * <http://www.huddletogether.com/projects/lightbox2/> * Also partially based on the jQuery Lightbox by Warren Krewenki * <http://warren.mesozen.com> * * Permission has been granted to Mark Ashmead & other Drupal Lightbox2 module * maintainers to distribute this file via Drupal.org * Under GPL license. * * Slideshow, iframe and video functionality added by Stella Power. */ var Lightbox = { auto_modal : false, overlayOpacity : 0.8, // Controls transparency of shadow overlay. overlayColor : '000', // Controls colour of shadow overlay. disableCloseClick : true, // Controls the order of the lightbox resizing animation sequence. resizeSequence: 0, // 0: simultaneous, 1: width then height, 2: height then width. resizeSpeed: 'normal', // Controls the speed of the lightbox resizing animation. fadeInSpeed: 'normal', // Controls the speed of the image appearance. slideDownSpeed: 'slow', // Controls the speed of the image details appearance. minWidth: 240, borderSize : 10, boxColor : 'fff', fontColor : '000', topPosition : '', infoHeight: 20, alternative_layout : false, imageArray : [], imageNum : null, total : 0, activeImage : null, inprogress : false, disableResize : false, disableZoom : false, isZoomedIn : false, rtl : false, loopItems : false, keysClose : ['c', 'x', 27], keysPrevious : ['p', 37], keysNext : ['n', 39], keysZoom : ['z'], keysPlayPause : [32], // Slideshow options. slideInterval : 5000, // In milliseconds. showPlayPause : true, autoStart : true, autoExit : true, pauseOnNextClick : false, // True to pause the slideshow when the "Next" button is clicked. pauseOnPrevClick : true, // True to pause the slideshow when the "Prev" button is clicked. slideIdArray : [], slideIdCount : 0, isSlideshow : false, isPaused : false, loopSlides : false, // Iframe options. isLightframe : false, iframe_width : 600, iframe_height : 400, iframe_border : 1, // Video and modal options. enableVideo : false, flvPlayer : '/flvplayer.swf', flvFlashvars : '', isModal : false, isVideo : false, videoId : false, modalWidth : 400, modalHeight : 400, modalHTML : null, // initialize() // Constructor runs on completion of the DOM loading. // The function inserts html at the bottom of the page which is used // to display the shadow overlay and the image container. initialize: function() { var s = Drupal.settings.lightbox2; Lightbox.overlayOpacity = s.overlay_opacity; Lightbox.overlayColor = s.overlay_color; Lightbox.disableCloseClick = s.disable_close_click; Lightbox.resizeSequence = s.resize_sequence; Lightbox.resizeSpeed = s.resize_speed; Lightbox.fadeInSpeed = s.fade_in_speed; Lightbox.slideDownSpeed = s.slide_down_speed; Lightbox.borderSize = s.border_size; Lightbox.boxColor = s.box_color; Lightbox.fontColor = s.font_color; Lightbox.topPosition = s.top_position; Lightbox.rtl = s.rtl; Lightbox.loopItems = s.loop_items; Lightbox.keysClose = s.keys_close.split(" "); Lightbox.keysPrevious = s.keys_previous.split(" "); Lightbox.keysNext = s.keys_next.split(" "); Lightbox.keysZoom = s.keys_zoom.split(" "); Lightbox.keysPlayPause = s.keys_play_pause.split(" "); Lightbox.disableResize = s.disable_resize; Lightbox.disableZoom = s.disable_zoom; Lightbox.slideInterval = s.slideshow_interval; Lightbox.showPlayPause = s.show_play_pause; Lightbox.showCaption = s.show_caption; Lightbox.autoStart = s.slideshow_automatic_start; Lightbox.autoExit = s.slideshow_automatic_exit; Lightbox.pauseOnNextClick = s.pause_on_next_click; Lightbox.pauseOnPrevClick = s.pause_on_previous_click; Lightbox.loopSlides = s.loop_slides; Lightbox.alternative_layout = s.use_alt_layout; Lightbox.iframe_width = s.iframe_width; Lightbox.iframe_height = s.iframe_height; Lightbox.iframe_border = s.iframe_border; Lightbox.enableVideo = s.enable_video; if (s.enable_video) { Lightbox.flvPlayer = s.flvPlayer; Lightbox.flvFlashvars = s.flvFlashvars; } // Make the lightbox divs. var layout_class = (s.use_alt_layout ? 'lightbox2-alt-layout' : 'lightbox2-orig-layout'); var output = '<div id="lightbox2-overlay" style="display: none;"></div>\ <div id="lightbox" style="display: none;" class="' + layout_class + '">\ <div id="outerImageContainer"></div>\ <div id="imageDataContainer" class="clearfix">\ <div id="imageData"></div>\ </div>\ </div>'; var loading = '<div id="loading"><a href="#" id="loadingLink"></a></div>'; var modal = '<div id="modalContainer" style="display: none;"></div>'; var frame = '<div id="frameContainer" style="display: none;"></div>'; var imageContainer = '<div id="imageContainer" style="display: none;"></div>'; var details = '<div id="imageDetails"></div>'; var bottomNav = '<div id="bottomNav"></div>'; var image = '<img id="lightboxImage" alt="" />'; var hoverNav = '<div id="hoverNav"><a id="prevLink" href="#"></a><a id="nextLink" href="#"></a></div>'; var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" href="#"></a><a id="frameNextLink" href="#"></a></div>'; var hoverNav = '<div id="hoverNav"><a id="prevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="nextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>'; var frameNav = '<div id="frameHoverNav"><a id="framePrevLink" title="' + Drupal.t('Previous') + '" href="#"></a><a id="frameNextLink" title="' + Drupal.t('Next') + '" href="#"></a></div>'; var caption = '<span id="caption"></span>'; var numberDisplay = '<span id="numberDisplay"></span>'; var close = '<a id="bottomNavClose" title="' + Drupal.t('Close') + '" href="#"></a>'; var zoom = '<a id="bottomNavZoom" href="#"></a>'; var zoomOut = '<a id="bottomNavZoomOut" href="#"></a>'; var pause = '<a id="lightshowPause" title="' + Drupal.t('Pause Slideshow') + '" href="#" style="display: none;"></a>'; var play = '<a id="lightshowPlay" title="' + Drupal.t('Play Slideshow') + '" href="#" style="display: none;"></a>'; $("body").append(output); $('#outerImageContainer').append(modal + frame + imageContainer + loading); if (!s.use_alt_layout) { $('#imageContainer').append(image + hoverNav); $('#imageData').append(details + bottomNav); $('#imageDetails').append(caption + numberDisplay); $('#bottomNav').append(frameNav + close + zoom + zoomOut + pause + play); } else { $('#outerImageContainer').append(bottomNav); $('#imageContainer').append(image); $('#bottomNav').append(close + zoom + zoomOut); $('#imageData').append(hoverNav + details); $('#imageDetails').append(caption + numberDisplay + pause + play); } // Setup onclick handlers. if (Lightbox.disableCloseClick) { $('#lightbox2-overlay').click(function() { Lightbox.end(); return false; } ).hide(); } $('#loadingLink, #bottomNavClose').click(function() { Lightbox.end('forceClose'); return false; } ); $('#prevLink, #framePrevLink').click(function() { Lightbox.changeData(Lightbox.activeImage - 1); return false; } ); $('#nextLink, #frameNextLink').click(function() { Lightbox.changeData(Lightbox.activeImage + 1); return false; } ); $('#bottomNavZoom').click(function() { Lightbox.changeData(Lightbox.activeImage, true); return false; } ); $('#bottomNavZoomOut').click(function() { Lightbox.changeData(Lightbox.activeImage, false); return false; } ); $('#lightshowPause').click(function() { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); return false; } ); $('#lightshowPlay').click(function() { Lightbox.togglePlayPause("lightshowPlay", "lightshowPause"); return false; } ); // Fix positioning. $('#prevLink, #nextLink, #framePrevLink, #frameNextLink').css({ 'paddingTop': Lightbox.borderSize + 'px'}); $('#imageContainer, #frameContainer, #modalContainer').css({ 'padding': Lightbox.borderSize + 'px'}); $('#outerImageContainer, #imageDataContainer, #bottomNavClose').css({'backgroundColor': '#' + Lightbox.boxColor, 'color': '#'+Lightbox.fontColor}); if (Lightbox.alternative_layout) { $('#bottomNavZoom, #bottomNavZoomOut').css({'bottom': Lightbox.borderSize + 'px', 'right': Lightbox.borderSize + 'px'}); } else if (Lightbox.rtl == 1 && $.browser.msie) { $('#bottomNavZoom, #bottomNavZoomOut').css({'left': '0px'}); } // Force navigation links to always be displayed if (s.force_show_nav) { $('#prevLink, #nextLink').addClass("force_show_nav"); } }, // initList() // Loops through anchor tags looking for 'lightbox', 'lightshow' and // 'lightframe', etc, references and applies onclick events to appropriate // links. You can rerun after dynamically adding images w/ajax. initList : function(context) { if (context == undefined || context == null) { context = document; } // Attach lightbox to any links with rel 'lightbox', 'lightshow' or // 'lightframe', etc. $("a[rel^='lightbox']:not(.lightbox-processed), area[rel^='lightbox']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { if (Lightbox.disableCloseClick) { $('#lightbox').unbind('click'); $('#lightbox').click(function() { Lightbox.end('forceClose'); } ); } Lightbox.start(this, false, false, false, false); if (e.preventDefault) { e.preventDefault(); } return false; }); $("a[rel^='lightshow']:not(.lightbox-processed), area[rel^='lightshow']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { if (Lightbox.disableCloseClick) { $('#lightbox').unbind('click'); $('#lightbox').click(function() { Lightbox.end('forceClose'); } ); } Lightbox.start(this, true, false, false, false); if (e.preventDefault) { e.preventDefault(); } return false; }); $("a[rel^='lightframe']:not(.lightbox-processed), area[rel^='lightframe']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { if (Lightbox.disableCloseClick) { $('#lightbox').unbind('click'); $('#lightbox').click(function() { Lightbox.end('forceClose'); } ); } Lightbox.start(this, false, true, false, false); if (e.preventDefault) { e.preventDefault(); } return false; }); if (Lightbox.enableVideo) { $("a[rel^='lightvideo']:not(.lightbox-processed), area[rel^='lightvideo']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { if (Lightbox.disableCloseClick) { $('#lightbox').unbind('click'); $('#lightbox').click(function() { Lightbox.end('forceClose'); } ); } Lightbox.start(this, false, false, true, false); if (e.preventDefault) { e.preventDefault(); } return false; }); } $("a[rel^='lightmodal']:not(.lightbox-processed), area[rel^='lightmodal']:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { $('#lightbox').unbind('click'); // Add classes from the link to the lightbox div - don't include lightbox-processed $('#lightbox').addClass($(this).attr('class')); $('#lightbox').removeClass('lightbox-processed'); Lightbox.start(this, false, false, false, true); if (e.preventDefault) { e.preventDefault(); } return false; }); $("#lightboxAutoModal:not(.lightbox-processed)", context).addClass('lightbox-processed').click(function(e) { Lightbox.auto_modal = true; $('#lightbox').unbind('click'); Lightbox.start(this, false, false, false, true); if (e.preventDefault) { e.preventDefault(); } return false; }); }, // start() // Display overlay and lightbox. If image is part of a set, add siblings to // imageArray. start: function(imageLink, slideshow, lightframe, lightvideo, lightmodal) { Lightbox.isPaused = !Lightbox.autoStart; // Replaces hideSelectBoxes() and hideFlash() calls in original lightbox2. Lightbox.toggleSelectsFlash('hide'); // Stretch overlay to fill page and fade in. var arrayPageSize = Lightbox.getPageSize(); $("#lightbox2-overlay").hide().css({ 'width': '100%', 'zIndex': '10090', 'height': arrayPageSize[1] + 'px', 'backgroundColor' : '#' + Lightbox.overlayColor }); // Detect OS X FF2 opacity + flash issue. if (lightvideo && this.detectMacFF2()) { $("#lightbox2-overlay").removeClass("overlay_default"); $("#lightbox2-overlay").addClass("overlay_macff2"); $("#lightbox2-overlay").css({'opacity' : null}); } else { $("#lightbox2-overlay").removeClass("overlay_macff2"); $("#lightbox2-overlay").addClass("overlay_default"); $("#lightbox2-overlay").css({'opacity' : Lightbox.overlayOpacity}); } $("#lightbox2-overlay").fadeIn(Lightbox.fadeInSpeed); Lightbox.isSlideshow = slideshow; Lightbox.isLightframe = lightframe; Lightbox.isVideo = lightvideo; Lightbox.isModal = lightmodal; Lightbox.imageArray = []; Lightbox.imageNum = 0; var anchors = $(imageLink.tagName); var anchor = null; var rel_parts = Lightbox.parseRel(imageLink); var rel = rel_parts["rel"]; var rel_group = rel_parts["group"]; var title = (rel_parts["title"] ? rel_parts["title"] : imageLink.title); var rel_style = null; var i = 0; if (rel_parts["flashvars"]) { Lightbox.flvFlashvars = Lightbox.flvFlashvars + '&' + rel_parts["flashvars"]; } // Set the title for image alternative text. var alt = imageLink.title; if (!alt) { var img = $(imageLink).find("img"); if (img && $(img).attr("alt")) { alt = $(img).attr("alt"); } else { alt = title; } } if ($(imageLink).attr('id') == 'lightboxAutoModal') { rel_style = rel_parts["style"]; Lightbox.imageArray.push(['#lightboxAutoModal > *', title, alt, rel_style, 1]); } else { // Handle lightbox images with no grouping. if ((rel == 'lightbox' || rel == 'lightshow') && !rel_group) { Lightbox.imageArray.push([imageLink.href, title, alt]); } // Handle other items with no grouping. else if (!rel_group) { rel_style = rel_parts["style"]; Lightbox.imageArray.push([imageLink.href, title, alt, rel_style]); } // Handle grouped items. else { // Loop through anchors and add them to imageArray. for (i = 0; i < anchors.length; i++) { anchor = anchors[i]; if (anchor.href && typeof(anchor.href) == "string" && $(anchor).attr('rel')) { var rel_data = Lightbox.parseRel(anchor); var anchor_title = (rel_data["title"] ? rel_data["title"] : anchor.title); img_alt = anchor.title; if (!img_alt) { var anchor_img = $(anchor).find("img"); if (anchor_img && $(anchor_img).attr("alt")) { img_alt = $(anchor_img).attr("alt"); } else { img_alt = title; } } if (rel_data["rel"] == rel) { if (rel_data["group"] == rel_group) { if (Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) { rel_style = rel_data["style"]; } Lightbox.imageArray.push([anchor.href, anchor_title, img_alt, rel_style]); } } } } // Remove duplicates. for (i = 0; i < Lightbox.imageArray.length; i++) { for (j = Lightbox.imageArray.length-1; j > i; j--) { if (Lightbox.imageArray[i][0] == Lightbox.imageArray[j][0]) { Lightbox.imageArray.splice(j,1); } } } while (Lightbox.imageArray[Lightbox.imageNum][0] != imageLink.href) { Lightbox.imageNum++; } } } if (Lightbox.isSlideshow && Lightbox.showPlayPause && Lightbox.isPaused) { $('#lightshowPlay').show(); $('#lightshowPause').hide(); } // Calculate top and left offset for the lightbox. var arrayPageScroll = Lightbox.getPageScroll(); var lightboxTop = arrayPageScroll[1] + (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1; var lightboxLeft = arrayPageScroll[0]; $('#frameContainer, #modalContainer, #lightboxImage').hide(); $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide(); $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide(); $('#outerImageContainer').css({'width': '250px', 'height': '250px'}); $('#lightbox').css({ 'zIndex': '10500', 'top': lightboxTop + 'px', 'left': lightboxLeft + 'px' }).show(); Lightbox.total = Lightbox.imageArray.length; Lightbox.changeData(Lightbox.imageNum); }, // changeData() // Hide most elements and preload image in preparation for resizing image // container. changeData: function(imageNum, zoomIn) { if (Lightbox.inprogress === false) { if (Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) { if (imageNum >= Lightbox.total) imageNum = 0; if (imageNum < 0) imageNum = Lightbox.total - 1; } if (Lightbox.isSlideshow) { for (var i = 0; i < Lightbox.slideIdCount; i++) { window.clearTimeout(Lightbox.slideIdArray[i]); } } Lightbox.inprogress = true; Lightbox.activeImage = imageNum; if (Lightbox.disableResize && !Lightbox.isSlideshow) { zoomIn = true; } Lightbox.isZoomedIn = zoomIn; // Hide elements during transition. $('#loading').css({'zIndex': '10500'}).show(); if (!Lightbox.alternative_layout) { $('#imageContainer').hide(); } $('#frameContainer, #modalContainer, #lightboxImage').hide(); $('#hoverNav, #prevLink, #nextLink, #frameHoverNav, #framePrevLink, #frameNextLink').hide(); $('#imageDataContainer, #numberDisplay, #bottomNavZoom, #bottomNavZoomOut').hide(); // Preload image content, but not iframe pages. if (!Lightbox.isLightframe && !Lightbox.isVideo && !Lightbox.isModal) { $("#lightbox #imageDataContainer").removeClass('lightbox2-alt-layout-data'); imgPreloader = new Image(); imgPreloader.onerror = function() { Lightbox.imgNodeLoadingError(this); }; imgPreloader.onload = function() { var photo = document.getElementById('lightboxImage'); photo.src = Lightbox.imageArray[Lightbox.activeImage][0]; photo.alt = Lightbox.imageArray[Lightbox.activeImage][2]; var imageWidth = imgPreloader.width; var imageHeight = imgPreloader.height; // Resize code. var arrayPageSize = Lightbox.getPageSize(); var targ = { w:arrayPageSize[2] - (Lightbox.borderSize * 2), h:arrayPageSize[3] - (Lightbox.borderSize * 6) - (Lightbox.infoHeight * 4) - (arrayPageSize[3] / 10) }; var orig = { w:imgPreloader.width, h:imgPreloader.height }; // Image is very large, so show a smaller version of the larger image // with zoom button. if (zoomIn !== true) { var ratio = 1.0; // Shrink image with the same aspect. $('#bottomNavZoomOut, #bottomNavZoom').hide(); if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) { ratio = ((targ.w / orig.w) < (targ.h / orig.h)) ? targ.w / orig.w : targ.h / orig.h; if (!Lightbox.disableZoom && !Lightbox.isSlideshow) { $('#bottomNavZoom').css({'zIndex': '10500'}).show(); } } imageWidth = Math.floor(orig.w * ratio); imageHeight = Math.floor(orig.h * ratio); } else { $('#bottomNavZoom').hide(); // Only display zoom out button if the image is zoomed in already. if ((orig.w >= targ.w || orig.h >= targ.h) && orig.h && orig.w) { // Only display zoom out button if not a slideshow and if the // buttons aren't disabled. if (!Lightbox.disableResize && Lightbox.isSlideshow === false && !Lightbox.disableZoom) { $('#bottomNavZoomOut').css({'zIndex': '10500'}).show(); } } } photo.style.width = (imageWidth) + 'px'; photo.style.height = (imageHeight) + 'px'; Lightbox.resizeContainer(imageWidth, imageHeight); // Clear onLoad, IE behaves irratically with animated gifs otherwise. imgPreloader.onload = function() {}; }; imgPreloader.src = Lightbox.imageArray[Lightbox.activeImage][0]; imgPreloader.alt = Lightbox.imageArray[Lightbox.activeImage][2]; } // Set up frame size, etc. else if (Lightbox.isLightframe) { $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data'); var src = Lightbox.imageArray[Lightbox.activeImage][0]; $('#frameContainer').html('<iframe id="lightboxFrame" style="display: none;" src="'+src+'"></iframe>'); // Enable swf support in Gecko browsers. if ($.browser.mozilla && src.indexOf('.swf') != -1) { setTimeout(function () { document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0]; }, 1000); } if (!Lightbox.iframe_border) { $('#lightboxFrame').css({'border': 'none'}); $('#lightboxFrame').attr('frameborder', '0'); } var iframe = document.getElementById('lightboxFrame'); var iframeStyles = Lightbox.imageArray[Lightbox.activeImage][3]; iframe = Lightbox.setStyles(iframe, iframeStyles); Lightbox.resizeContainer(parseInt(iframe.width, 10), parseInt(iframe.height, 10)); } else if (Lightbox.isVideo || Lightbox.isModal) { $("#lightbox #imageDataContainer").addClass('lightbox2-alt-layout-data'); var container = document.getElementById('modalContainer'); var modalStyles = Lightbox.imageArray[Lightbox.activeImage][3]; container = Lightbox.setStyles(container, modalStyles); if (Lightbox.isVideo) { Lightbox.modalHeight = parseInt(container.height, 10) - 10; Lightbox.modalWidth = parseInt(container.width, 10) - 10; Lightvideo.startVideo(Lightbox.imageArray[Lightbox.activeImage][0]); } Lightbox.resizeContainer(parseInt(container.width, 10), parseInt(container.height, 10)); } } }, // imgNodeLoadingError() imgNodeLoadingError: function(image) { var s = Drupal.settings.lightbox2; var original_image = Lightbox.imageArray[Lightbox.activeImage][0]; if (s.display_image_size !== "") { original_image = original_image.replace(new RegExp("."+s.display_image_size), ""); } Lightbox.imageArray[Lightbox.activeImage][0] = original_image; image.onerror = function() { Lightbox.imgLoadingError(image); }; image.src = original_image; }, // imgLoadingError() imgLoadingError: function(image) { var s = Drupal.settings.lightbox2; Lightbox.imageArray[Lightbox.activeImage][0] = s.default_image; image.src = s.default_image; }, // resizeContainer() resizeContainer: function(imgWidth, imgHeight) { imgWidth = (imgWidth < Lightbox.minWidth ? Lightbox.minWidth : imgWidth); this.widthCurrent = $('#outerImageContainer').width(); this.heightCurrent = $('#outerImageContainer').height(); var widthNew = (imgWidth + (Lightbox.borderSize * 2)); var heightNew = (imgHeight + (Lightbox.borderSize * 2)); // Scalars based on change from old to new. this.xScale = ( widthNew / this.widthCurrent) * 100; this.yScale = ( heightNew / this.heightCurrent) * 100; // Calculate size difference between new and old image, and resize if // necessary. wDiff = this.widthCurrent - widthNew; hDiff = this.heightCurrent - heightNew; $('#modalContainer').css({'width': imgWidth, 'height': imgHeight}); // Detect animation sequence. if (Lightbox.resizeSequence) { var animate1 = {width: widthNew}; var animate2 = {height: heightNew}; if (Lightbox.resizeSequence == 2) { animate1 = {height: heightNew}; animate2 = {width: widthNew}; } $('#outerImageContainer').animate(animate1, Lightbox.resizeSpeed).animate(animate2, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); }); } // Simultaneous. else { $('#outerImageContainer').animate({'width': widthNew, 'height': heightNew}, Lightbox.resizeSpeed, 'linear', function() { Lightbox.showData(); }); } // If new and old image are same size and no scaling transition is necessary // do a quick pause to prevent image flicker. if ((hDiff === 0) && (wDiff === 0)) { if ($.browser.msie) { Lightbox.pause(250); } else { Lightbox.pause(100); } } var s = Drupal.settings.lightbox2; if (!s.use_alt_layout) { $('#prevLink, #nextLink').css({'height': imgHeight + 'px'}); } $('#imageDataContainer').css({'width': widthNew + 'px'}); }, // showData() // Display image and begin preloading neighbors. showData: function() { $('#loading').hide(); if (Lightbox.isLightframe || Lightbox.isVideo || Lightbox.isModal) { Lightbox.updateDetails(); if (Lightbox.isLightframe) { $('#frameContainer').show(); if ($.browser.safari || Lightbox.fadeInSpeed === 0) { $('#lightboxFrame').css({'zIndex': '10500'}).show(); } else { $('#lightboxFrame').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed); } } else { if (Lightbox.isVideo) { $("#modalContainer").html(Lightbox.modalHTML).click(function(){return false;}).css('zIndex', '10500').show(); } else { var src = unescape(Lightbox.imageArray[Lightbox.activeImage][0]); if (Lightbox.imageArray[Lightbox.activeImage][4]) { $(src).appendTo("#modalContainer"); $('#modalContainer').css({'zIndex': '10500'}).show(); } else { // Use a callback to show the new image, otherwise you get flicker. $("#modalContainer").hide().load(src, function () {$('#modalContainer').css({'zIndex': '10500'}).show();}); } $('#modalContainer').unbind('click'); } // This might be needed in the Lightframe section above. //$('#modalContainer').css({'zIndex': '10500'}).show(); } } // Handle display of image content. else { $('#imageContainer').show(); if ($.browser.safari || Lightbox.fadeInSpeed === 0) { $('#lightboxImage').css({'zIndex': '10500'}).show(); } else { $('#lightboxImage').css({'zIndex': '10500'}).fadeIn(Lightbox.fadeInSpeed); } Lightbox.updateDetails(); this.preloadNeighborImages(); } Lightbox.inprogress = false; // Slideshow specific stuff. if (Lightbox.isSlideshow) { if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) { if (Lightbox.autoExit) { Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.end('slideshow');}, Lightbox.slideInterval); } } else { if (!Lightbox.isPaused && Lightbox.total > 1) { Lightbox.slideIdArray[Lightbox.slideIdCount++] = setTimeout(function () {Lightbox.changeData(Lightbox.activeImage + 1);}, Lightbox.slideInterval); } } if (Lightbox.showPlayPause && Lightbox.total > 1 && !Lightbox.isPaused) { $('#lightshowPause').show(); $('#lightshowPlay').hide(); } else if (Lightbox.showPlayPause && Lightbox.total > 1) { $('#lightshowPause').hide(); $('#lightshowPlay').show(); } } // Adjust the page overlay size. var arrayPageSize = Lightbox.getPageSize(); var arrayPageScroll = Lightbox.getPageScroll(); var pageHeight = arrayPageSize[1]; if (Lightbox.isZoomedIn && arrayPageSize[1] > arrayPageSize[3]) { var lightboxTop = (Lightbox.topPosition == '' ? (arrayPageSize[3] / 10) : Lightbox.topPosition) * 1; pageHeight = pageHeight + arrayPageScroll[1] + lightboxTop; } $('#lightbox2-overlay').css({'height': pageHeight + 'px', 'width': arrayPageSize[0] + 'px'}); // Gecko browsers (e.g. Firefox, SeaMonkey, etc) don't handle pdfs as // expected. if ($.browser.mozilla) { if (Lightbox.imageArray[Lightbox.activeImage][0].indexOf(".pdf") != -1) { setTimeout(function () { document.getElementById("lightboxFrame").src = Lightbox.imageArray[Lightbox.activeImage][0]; }, 1000); } } }, // updateDetails() // Display caption, image number, and bottom nav. updateDetails: function() { $("#imageDataContainer").hide(); var s = Drupal.settings.lightbox2; if (s.show_caption) { var caption = Lightbox.filterXSS(Lightbox.imageArray[Lightbox.activeImage][1]); if (!caption) caption = ''; $('#caption').html(caption).css({'zIndex': '10500'}).show(); } // If image is part of set display 'Image x of x'. var numberDisplay = null; if (s.image_count && Lightbox.total > 1) { var currentImage = Lightbox.activeImage + 1; if (!Lightbox.isLightframe && !Lightbox.isModal && !Lightbox.isVideo) { numberDisplay = s.image_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total); } else if (Lightbox.isVideo) { numberDisplay = s.video_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total); } else { numberDisplay = s.page_count.replace(/\!current/, currentImage).replace(/\!total/, Lightbox.total); } $('#numberDisplay').html(numberDisplay).css({'zIndex': '10500'}).show(); } else { $('#numberDisplay').hide(); } $("#imageDataContainer").hide().slideDown(Lightbox.slideDownSpeed, function() { $("#bottomNav").show(); }); if (Lightbox.rtl == 1) { $("#bottomNav").css({'float': 'left'}); } Lightbox.updateNav(); }, // updateNav() // Display appropriate previous and next hover navigation. updateNav: function() { $('#hoverNav').css({'zIndex': '10500'}).show(); var prevLink = '#prevLink'; var nextLink = '#nextLink'; // Slideshow is separated as we need to show play / pause button. if (Lightbox.isSlideshow) { if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage !== 0) { $(prevLink).css({'zIndex': '10500'}).show().click(function() { if (Lightbox.pauseOnPrevClick) { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); } Lightbox.changeData(Lightbox.activeImage - 1); return false; }); } else { $(prevLink).hide(); } // If not last image in set, display next image button. if ((Lightbox.total > 1 && Lightbox.loopSlides) || Lightbox.activeImage != (Lightbox.total - 1)) { $(nextLink).css({'zIndex': '10500'}).show().click(function() { if (Lightbox.pauseOnNextClick) { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); } Lightbox.changeData(Lightbox.activeImage + 1); return false; }); } // Safari browsers need to have hide() called again. else { $(nextLink).hide(); } } // All other types of content. else { if ((Lightbox.isLightframe || Lightbox.isModal || Lightbox.isVideo) && !Lightbox.alternative_layout) { $('#frameHoverNav').css({'zIndex': '10500'}).show(); $('#hoverNav').css({'zIndex': '10500'}).hide(); prevLink = '#framePrevLink'; nextLink = '#frameNextLink'; } // If not first image in set, display prev image button. if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage !== 0) { // Unbind any other click handlers, otherwise this adds a new click handler // each time the arrow is clicked. $(prevLink).css({'zIndex': '10500'}).show().unbind().click(function() { Lightbox.changeData(Lightbox.activeImage - 1); return false; }); } // Safari browsers need to have hide() called again. else { $(prevLink).hide(); } // If not last image in set, display next image button. if ((Lightbox.total > 1 && Lightbox.loopItems) || Lightbox.activeImage != (Lightbox.total - 1)) { // Unbind any other click handlers, otherwise this adds a new click handler // each time the arrow is clicked. $(nextLink).css({'zIndex': '10500'}).show().unbind().click(function() { Lightbox.changeData(Lightbox.activeImage + 1); return false; }); } // Safari browsers need to have hide() called again. else { $(nextLink).hide(); } } // Don't enable keyboard shortcuts so forms will work. if (!Lightbox.isModal) { this.enableKeyboardNav(); } }, // enableKeyboardNav() enableKeyboardNav: function() { $(document).bind("keydown", this.keyboardAction); }, // disableKeyboardNav() disableKeyboardNav: function() { $(document).unbind("keydown", this.keyboardAction); }, // keyboardAction() keyboardAction: function(e) { if (e === null) { // IE. keycode = event.keyCode; escapeKey = 27; } else { // Mozilla. keycode = e.keyCode; escapeKey = e.DOM_VK_ESCAPE; } key = String.fromCharCode(keycode).toLowerCase(); // Close lightbox. if (Lightbox.checkKey(Lightbox.keysClose, key, keycode)) { Lightbox.end('forceClose'); } // Display previous image (p, <-). else if (Lightbox.checkKey(Lightbox.keysPrevious, key, keycode)) { if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage !== 0) { Lightbox.changeData(Lightbox.activeImage - 1); } } // Display next image (n, ->). else if (Lightbox.checkKey(Lightbox.keysNext, key, keycode)) { if ((Lightbox.total > 1 && ((Lightbox.isSlideshow && Lightbox.loopSlides) || (!Lightbox.isSlideshow && Lightbox.loopItems))) || Lightbox.activeImage != (Lightbox.total - 1)) { Lightbox.changeData(Lightbox.activeImage + 1); } } // Zoom in. else if (Lightbox.checkKey(Lightbox.keysZoom, key, keycode) && !Lightbox.disableResize && !Lightbox.disableZoom && !Lightbox.isSlideshow && !Lightbox.isLightframe) { if (Lightbox.isZoomedIn) { Lightbox.changeData(Lightbox.activeImage, false); } else if (!Lightbox.isZoomedIn) { Lightbox.changeData(Lightbox.activeImage, true); } return false; } // Toggle play / pause (space). else if (Lightbox.checkKey(Lightbox.keysPlayPause, key, keycode) && Lightbox.isSlideshow) { if (Lightbox.isPaused) { Lightbox.togglePlayPause("lightshowPlay", "lightshowPause"); } else { Lightbox.togglePlayPause("lightshowPause", "lightshowPlay"); } return false; } }, preloadNeighborImages: function() { if ((Lightbox.total - 1) > Lightbox.activeImage) { preloadNextImage = new Image(); preloadNextImage.src = Lightbox.imageArray[Lightbox.activeImage + 1][0]; } if (Lightbox.activeImage > 0) { preloadPrevImage = new Image(); preloadPrevImage.src = Lightbox.imageArray[Lightbox.activeImage - 1][0]; } }, end: function(caller) { var closeClick = (caller == 'slideshow' ? false : true); if (Lightbox.isSlideshow && Lightbox.isPaused && !closeClick) { return; } // To prevent double clicks on navigation links. if (Lightbox.inprogress === true && caller != 'forceClose') { return; } Lightbox.disableKeyboardNav(); $('#lightbox').hide(); $("#lightbox2-overlay").fadeOut(); Lightbox.isPaused = true; Lightbox.inprogress = false; // Replaces calls to showSelectBoxes() and showFlash() in original // lightbox2. Lightbox.toggleSelectsFlash('visible'); if (Lightbox.isSlideshow) { for (var i = 0; i < Lightbox.slideIdCount; i++) { window.clearTimeout(Lightbox.slideIdArray[i]); } $('#lightshowPause, #lightshowPlay').hide(); } else if (Lightbox.isLightframe) { $('#frameContainer').empty().hide(); } else if (Lightbox.isVideo || Lightbox.isModal) { if (!Lightbox.auto_modal) { $('#modalContainer').hide().html(""); } Lightbox.auto_modal = false; } }, // getPageScroll() // Returns array with x,y page scroll values. // Core code from - quirksmode.com. getPageScroll : function() { var xScroll, yScroll; if (self.pageYOffset || self.pageXOffset) { yScroll = self.pageYOffset; xScroll = self.pageXOffset; } else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) { // Explorer 6 Strict. yScroll = document.documentElement.scrollTop; xScroll = document.documentElement.scrollLeft; } else if (document.body) {// All other Explorers. yScroll = document.body.scrollTop; xScroll = document.body.scrollLeft; } arrayPageScroll = [xScroll,yScroll]; return arrayPageScroll; }, // getPageSize() // Returns array with page width, height and window width, height. // Core code from - quirksmode.com. // Edit for Firefox by pHaez. getPageSize : function() { var xScroll, yScroll; if (window.innerHeight && window.scrollMaxY) { xScroll = window.innerWidth + window.scrollMaxX; yScroll = window.innerHeight + window.scrollMaxY; } else if (document.body.scrollHeight > document.body.offsetHeight) { // All but Explorer Mac. xScroll = document.body.scrollWidth; yScroll = document.body.scrollHeight; } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari. xScroll = document.body.offsetWidth; yScroll = document.body.offsetHeight; } var windowWidth, windowHeight; if (self.innerHeight) { // All except Explorer. if (document.documentElement.clientWidth) { windowWidth = document.documentElement.clientWidth; } else { windowWidth = self.innerWidth; } windowHeight = self.innerHeight; } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode. windowWidth = document.documentElement.clientWidth; windowHeight = document.documentElement.clientHeight; } else if (document.body) { // Other Explorers. windowWidth = document.body.clientWidth; windowHeight = document.body.clientHeight; } // For small pages with total height less than height of the viewport. if (yScroll < windowHeight) { pageHeight = windowHeight; } else { pageHeight = yScroll; } // For small pages with total width less than width of the viewport. if (xScroll < windowWidth) { pageWidth = xScroll; } else { pageWidth = windowWidth; } arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight); return arrayPageSize; }, // pause(numberMillis) pause : function(ms) { var date = new Date(); var curDate = null; do { curDate = new Date(); } while (curDate - date < ms); }, // toggleSelectsFlash() // Hide / unhide select lists and flash objects as they appear above the // lightbox in some browsers. toggleSelectsFlash: function (state) { if (state == 'visible') { $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").show(); } else if (state == 'hide') { $("select:visible, embed:visible, object:visible").not('#lightboxAutoModal select, #lightboxAutoModal embed, #lightboxAutoModal object').addClass("lightbox_hidden"); $("select.lightbox_hidden, embed.lightbox_hidden, object.lightbox_hidden").hide(); } }, // parseRel() parseRel: function (link) { var parts = []; parts["rel"] = parts["title"] = parts["group"] = parts["style"] = parts["flashvars"] = null; if (!$(link).attr('rel')) return parts; parts["rel"] = $(link).attr('rel').match(/\w+/)[0]; if ($(link).attr('rel').match(/\[(.*)\]/)) { var info = $(link).attr('rel').match(/\[(.*?)\]/)[1].split('|'); parts["group"] = info[0]; parts["style"] = info[1]; if (parts["style"] != undefined && parts["style"].match(/flashvars:\s?(.*?);/)) { parts["flashvars"] = parts["style"].match(/flashvars:\s?(.*?);/)[1]; } } if ($(link).attr('rel').match(/\[.*\]\[(.*)\]/)) { parts["title"] = $(link).attr('rel').match(/\[.*\]\[(.*)\]/)[1]; } return parts; }, // setStyles() setStyles: function(item, styles) { item.width = Lightbox.iframe_width; item.height = Lightbox.iframe_height; item.scrolling = "auto"; if (!styles) return item; var stylesArray = styles.split(';'); for (var i = 0; i< stylesArray.length; i++) { if (stylesArray[i].indexOf('width:') >= 0) { var w = stylesArray[i].replace('width:', ''); item.width = jQuery.trim(w); } else if (stylesArray[i].indexOf('height:') >= 0) { var h = stylesArray[i].replace('height:', ''); item.height = jQuery.trim(h); } else if (stylesArray[i].indexOf('scrolling:') >= 0) { var scrolling = stylesArray[i].replace('scrolling:', ''); item.scrolling = jQuery.trim(scrolling); } else if (stylesArray[i].indexOf('overflow:') >= 0) { var overflow = stylesArray[i].replace('overflow:', ''); item.overflow = jQuery.trim(overflow); } } return item; }, // togglePlayPause() // Hide the pause / play button as appropriate. If pausing the slideshow also // clear the timers, otherwise move onto the next image. togglePlayPause: function(hideId, showId) { if (Lightbox.isSlideshow && hideId == "lightshowPause") { for (var i = 0; i < Lightbox.slideIdCount; i++) { window.clearTimeout(Lightbox.slideIdArray[i]); } } $('#' + hideId).hide(); $('#' + showId).show(); if (hideId == "lightshowPlay") { Lightbox.isPaused = false; if (!Lightbox.loopSlides && Lightbox.activeImage == (Lightbox.total - 1)) { Lightbox.end(); } else if (Lightbox.total > 1) { Lightbox.changeData(Lightbox.activeImage + 1); } } else { Lightbox.isPaused = true; } }, triggerLightbox: function (rel_type, rel_group) { if (rel_type.length) { if (rel_group && rel_group.length) { $("a[rel^='" + rel_type +"\[" + rel_group + "\]'], area[rel^='" + rel_type +"\[" + rel_group + "\]']").eq(0).trigger("click"); } else { $("a[rel^='" + rel_type +"'], area[rel^='" + rel_type +"']").eq(0).trigger("click"); } } }, detectMacFF2: function() { var ua = navigator.userAgent.toLowerCase(); if (/firefox[\/\s](\d+\.\d+)/.test(ua)) { var ffversion = new Number(RegExp.$1); if (ffversion < 3 && ua.indexOf('mac') != -1) { return true; } } return false; }, checkKey: function(keys, key, code) { return (jQuery.inArray(key, keys) != -1 || jQuery.inArray(String(code), keys) != -1); }, filterXSS: function(str, allowed_tags) { var output = ""; $.ajax({ url: Drupal.settings.basePath + 'system/lightbox2/filter-xss', data: { 'string' : str, 'allowed_tags' : allowed_tags }, type: "POST", async: false, dataType: "json", success: function(data) { output = data; } }); return output; } }; // Initialize the lightbox. Drupal.behaviors.initLightbox = function (context) { $('body:not(.lightbox-processed)', context).addClass('lightbox-processed').each(function() { Lightbox.initialize(); return false; // Break the each loop. }); // Attach lightbox to any links with lightbox rels. Lightbox.initList(context); $('#lightboxAutoModal', context).triggerHandler('click'); }; ; // $Id: base.js,v 1.11.2.1 2010/03/10 20:08:58 merlinofchaos Exp $ /** * @file base.js * * Some basic behaviors and utility functions for Views. */ Drupal.Views = {}; /** * jQuery UI tabs, Views integration component */ Drupal.behaviors.viewsTabs = function (context) { $('#views-tabset:not(.views-processed)').addClass('views-processed').each(function() { new Drupal.Views.Tabs($(this), {selectedClass: 'active'}); }); $('a.views-remove-link') .addClass('views-processed') .click(function() { var id = $(this).attr('id').replace('views-remove-link-', ''); $('#views-row-' + id).hide(); $('#views-removed-' + id).attr('checked', true); return false; }); } /** * For IE, attach some javascript so that our hovers do what they're supposed * to do. */ Drupal.behaviors.viewsHoverlinks = function() { if ($.browser.msie) { // If IE, attach a hover event so we can see our admin links. $("div.view:not(.views-hover-processed)").addClass('views-hover-processed').hover( function() { $('div.views-hide', this).addClass("views-hide-hover"); return true; }, function(){ $('div.views-hide', this).removeClass("views-hide-hover"); return true; } ); $("div.views-admin-links:not(.views-hover-processed)") .addClass('views-hover-processed') .hover( function() { $(this).addClass("views-admin-links-hover"); return true; }, function(){ $(this).removeClass("views-admin-links-hover"); return true; } ); } } /** * Helper function to parse a querystring. */ Drupal.Views.parseQueryString = function (query) { var args = {}; var pos = query.indexOf('?'); if (pos != -1) { query = query.substring(pos + 1); } var pairs = query.split('&'); for(var i in pairs) { var pair = pairs[i].split('='); // Ignore the 'q' path argument, if present. if (pair[0] != 'q' && pair[1]) { args[pair[0]] = decodeURIComponent(pair[1].replace(/\+/g, ' ')); } } return args; }; /** * Helper function to return a view's arguments based on a path. */ Drupal.Views.parseViewArgs = function (href, viewPath) { var returnObj = {}; var path = Drupal.Views.getPath(href); // Ensure we have a correct path. if (viewPath && path.substring(0, viewPath.length + 1) == viewPath + '/') { var args = decodeURIComponent(path.substring(viewPath.length + 1, path.length)); returnObj.view_args = args; returnObj.view_path = path; } return returnObj; }; /** * Strip off the protocol plus domain from an href. */ Drupal.Views.pathPortion = function (href) { // Remove e.g. http://example.com if present. var protocol = window.location.protocol; if (href.substring(0, protocol.length) == protocol) { // 2 is the length of the '//' that normally follows the protocol href = href.substring(href.indexOf('/', protocol.length + 2)); } return href; }; /** * Return the Drupal path portion of an href. */ Drupal.Views.getPath = function (href) { href = Drupal.Views.pathPortion(href); href = href.substring(Drupal.settings.basePath.length, href.length); // 3 is the length of the '?q=' added to the url without clean urls. if (href.substring(0, 3) == '?q=') { href = href.substring(3, href.length); } var chars = ['#', '?', '&']; for (i in chars) { if (href.indexOf(chars[i]) > -1) { href = href.substr(0, href.indexOf(chars[i])); } } return href; }; ; // $Id: ajax_view.js,v 1.19.2.5 2010/03/25 18:25:28 merlinofchaos Exp $ /** * @file ajaxView.js * * Handles AJAX fetching of views, including filter submission and response. */ Drupal.Views.Ajax = Drupal.Views.Ajax || {}; /** * An ajax responder that accepts a packet of JSON data and acts appropriately. * * The following fields control behavior. * - 'display': Display the associated data in the view area. */ Drupal.Views.Ajax.ajaxViewResponse = function(target, response) { if (response.debug) { alert(response.debug); } var $view = $(target); // Check the 'display' for data. if (response.status && response.display) { var $newView = $(response.display); $view.replaceWith($newView); $view = $newView; Drupal.attachBehaviors($view.parent()); } if (response.messages) { // Show any messages (but first remove old ones, if there are any). $view.find('.views-messages').remove().end().prepend(response.messages); } }; /** * Ajax behavior for views. */ Drupal.behaviors.ViewsAjaxView = function() { if (Drupal.settings && Drupal.settings.views && Drupal.settings.views.ajaxViews) { var ajax_path = Drupal.settings.views.ajax_path; // If there are multiple views this might've ended up showing up multiple times. if (ajax_path.constructor.toString().indexOf("Array") != -1) { ajax_path = ajax_path[0]; } $.each(Drupal.settings.views.ajaxViews, function(i, settings) { var view = '.view-dom-id-' + settings.view_dom_id; if (!$(view).size()) { // Backward compatibility: if 'views-view.tpl.php' is old and doesn't // contain the 'view-dom-id-#' class, we fall back to the old way of // locating the view: view = '.view-id-' + settings.view_name + '.view-display-id-' + settings.view_display_id; } // Process exposed filter forms. $('form#views-exposed-form-' + settings.view_name.replace(/_/g, '-') + '-' + settings.view_display_id.replace(/_/g, '-')) .filter(':not(.views-processed)') .each(function () { // remove 'q' from the form; it's there for clean URLs // so that it submits to the right place with regular submit // but this method is submitting elsewhere. $('input[name=q]', this).remove(); var form = this; // ajaxSubmit doesn't accept a data argument, so we have to // pass additional fields this way. $.each(settings, function(key, setting) { $(form).append('<input type="hidden" name="'+ key + '" value="'+ setting +'"/>'); }); }) .addClass('views-processed') .submit(function () { $('input[type=submit], button', this).after('<span class="views-throbbing">&nbsp</span>'); var object = this; $(this).ajaxSubmit({ url: ajax_path, type: 'GET', success: function(response) { // Call all callbacks. if (response.__callbacks) { $.each(response.__callbacks, function(i, callback) { eval(callback)(view, response); }); $('.views-throbbing', object).remove(); } }, error: function(xhr) { Drupal.Views.Ajax.handleErrors(xhr, ajax_path); $('.views-throbbing', object).remove(); }, dataType: 'json' }); return false; }); $(view).filter(':not(.views-processed)') // Don't attach to nested views. Doing so would attach multiple behaviors // to a given element. .filter(function() { // If there is at least one parent with a view class, this view // is nested (e.g., an attachment). Bail. return !$(this).parents('.view').size(); }) .each(function() { // Set a reference that will work in subsequent calls. var target = this; $(this) .addClass('views-processed') // Process pager, tablesort, and attachment summary links. .find('ul.pager > li > a, th.views-field a, .attachment .views-summary a') .each(function () { var viewData = { 'js': 1 }; // Construct an object using the settings defaults and then overriding // with data specific to the link. $.extend( viewData, Drupal.Views.parseQueryString($(this).attr('href')), // Extract argument data from the URL. Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path), // Settings must be used last to avoid sending url aliases to the server. settings ); $(this).click(function () { $.extend(viewData, Drupal.Views.parseViewArgs($(this).attr('href'), settings.view_base_path)); $(this).addClass('views-throbbing'); $.ajax({ url: ajax_path, type: 'GET', data: viewData, success: function(response) { $(this).removeClass('views-throbbing'); // Scroll to the top of the view. This will allow users // to browse newly loaded content after e.g. clicking a pager // link. var offset = $(target).offset(); // We can't guarantee that the scrollable object should be // the body, as the view could be embedded in something // more complex such as a modal popup. Recurse up the DOM // and scroll the first element that has a non-zero top. var scrollTarget = target; while ($(scrollTarget).scrollTop() == 0 && $(scrollTarget).parent()) { scrollTarget = $(scrollTarget).parent() } // Only scroll upward if (offset.top - 10 < $(scrollTarget).scrollTop()) { $(scrollTarget).animate({scrollTop: (offset.top - 10)}, 500); } // Call all callbacks. if (response.__callbacks) { $.each(response.__callbacks, function(i, callback) { eval(callback)(target, response); }); } }, error: function(xhr) { $(this).removeClass('views-throbbing'); Drupal.Views.Ajax.handleErrors(xhr, ajax_path); }, dataType: 'json' }); return false; }); }); // .each function () { }); // $view.filter().each }); // .each Drupal.settings.views.ajaxViews } // if }; ; /** * -------------------------------------------------------------------- * jQuery-Plugin "pngFix" * by Andreas Eberhard, andreas.eberhard@gmail.com * http://jquery.andreaseberhard.de/ * * Copyright (c) 2007 Andreas Eberhard * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php) * * Version: 1.0, 31.05.2007 * Changelog: * 31.05.2007 initial Version 1.0 * -------------------------------------------------------------------- */ (function(jQuery) { jQuery.fn.pngFix = function() { var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1); var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1); if (jQuery.browser.msie && (ie55 || ie6)) { jQuery(this).find("img[@src$=.png]").each(function() { var prevStyle = ''; var strNewHTML = ''; var imgId = (jQuery(this).attr('id')) ? 'id="' + jQuery(this).attr('id') + '" ' : ''; var imgClass = (jQuery(this).attr('class')) ? 'class="' + jQuery(this).attr('class') + '" ' : ''; var imgTitle = (jQuery(this).attr('title')) ? 'title="' + jQuery(this).attr('title') + '" ' : ''; var imgAlt = (jQuery(this).attr('alt')) ? 'alt="' + jQuery(this).attr('alt') + '" ' : ''; var imgAlign = (jQuery(this).attr('align')) ? 'float:' + jQuery(this).attr('align') + ';' : ''; var imgHand = (jQuery(this).parent().attr('href')) ? 'cursor:hand;' : ''; if (this.style.border) { prevStyle += 'border:'+this.style.border+';'; this.style.border = ''; } if (this.style.padding) { prevStyle += 'padding:'+this.style.padding+';'; this.style.padding = ''; } if (this.style.margin) { prevStyle += 'margin:'+this.style.margin+';'; this.style.margin = ''; } var imgStyle = (this.style.cssText); strNewHTML += '<span '+imgId+imgClass+imgTitle+imgAlt; strNewHTML += 'style="position:relative;white-space:pre-line;display:inline-block;background:transparent;'+imgAlign+imgHand; strNewHTML += 'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'; strNewHTML += 'filter:progid:DXImageTransform.Microsoft.AlphaImageLoader' + '(src=\'' + jQuery(this).attr('src') + '\', sizingMethod=\'scale\');'; strNewHTML += imgStyle+'"></span>'; if (prevStyle != ''){ strNewHTML = '<span style="position:relative;display:inline-block;'+prevStyle+imgHand+'width:' + jQuery(this).width() + 'px;' + 'height:' + jQuery(this).height() + 'px;'+'">' + strNewHTML + '</span>'; } jQuery(this).hide(); jQuery(this).after(strNewHTML); }); } }; })(jQuery); ;
JavaScript
function pickstyle(whichstyle) { var expireDate = new Date() var expstring=expireDate.setDate(expireDate.getDate()+30) document.cookie = "litejazzstyle=" + whichstyle + "; expires="+expireDate.toGMTString() }
JavaScript
(function(){ //get the background-color for each tile and apply it as background color for the cooresponding screen $('.tile').each(function(){ var $this= $(this), page = $this.data('page-name'), bgcolor = $this.css('background-color'), textColor = $this.css('color'); //if the tile rotates, we'll use the colors of the front face if($this.hasClass('rotate3d')) { frontface = $this.find('.front'); bgcolor = frontface.css('background-color'); textColor = frontface.css('color'); } //if the tile has an image and a caption, we'll use the caption styles if($this.hasClass('fig-tile')) { caption = $this.find('figcaption'); bgcolor = caption.css('background-color'); textColor = caption.css('color'); } $this.on('click',function(){ $('.'+page).css({'background-color': bgcolor, 'color': textColor}) .find('.close-button').css({'background-color': textColor, 'color': bgcolor}); }); }); function showDashBoard(){ for(var i = 1; i <= 3; i++) { $('.col'+i).each(function(){ $(this).addClass('fadeInForward-'+i).removeClass('fadeOutback'); }); } } function fadeDashBoard(){ for(var i = 1; i <= 3; i++) { $('.col'+i).addClass('fadeOutback').removeClass('fadeInForward-'+i); } } //listen for when a tile is clicked //retrieve the type of page it opens from its data attribute //based on the type of page, add corresponding class to page and fade the dashboard $('.tile').each(function(){ var $this= $(this), pageType = $this.data('page-type'), page = $this.data('page-name'); $this.on('click',function(){ if(pageType === "s-page"){ fadeDashBoard(); $('.'+page).addClass('slidePageInFromLeft').removeClass('slidePageBackLeft'); } else{ $('.'+page).addClass('openpage'); fadeDashBoard(); } }); }); //when a close button is clicked: //close the page //wait till the page is closed and fade dashboard back in $('.r-close-button').click(function(){ $(this).parent().addClass('slidePageLeft') .one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function(e) { $(this).removeClass('slidePageLeft').removeClass('openpage'); }); showDashBoard(); }); $('.s-close-button').click(function(){ $(this).parent().removeClass('slidePageInFromLeft').addClass('slidePageBackLeft'); showDashBoard(); }); })();
JavaScript
/** * Cookie plugin * * Copyright (c) 2006 Klaus Hartl (stilbuero.de) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * */ /** * Create a cookie with the given name and value and other optional parameters. * * @example $.cookie('the_cookie', 'the_value'); * @desc Set the value of a cookie. * @example $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true}); * @desc Create a cookie with all available options. * @example $.cookie('the_cookie', 'the_value'); * @desc Create a session cookie. * @example $.cookie('the_cookie', null); * @desc Delete a cookie by passing null as value. * * @param String name The name of the cookie. * @param String value The value of the cookie. * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. * If set to null or omitted, the cookie will be a session cookie and will not be retained * when the the browser exits. * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will * require a secure protocol (like HTTPS). * @type undefined * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ /** * Get the value of a cookie with the given name. * * @example $.cookie('the_cookie'); * @desc Get the value of a cookie. * * @param String name The name of the cookie. * @return The value of the cookie. * @type String * * @name $.cookie * @cat Plugins/Cookie * @author Klaus Hartl/klaus.hartl@stilbuero.de */ jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } };
JavaScript
$(document).ready(function(){ // first example $("#browser").treeview(); // second example $("#navigation").treeview({ persist: "location", collapsed: true, unique: true }); // third example $("#red").treeview({ animated: "fast", collapsed: true, unique: true, persist: "cookie", toggle: function() { window.console && console.log("%o was toggled", this); } }); // fourth example $("#black, #gray").treeview({ control: "#treecontrol", persist: "cookie", cookieId: "treeview-black" }); });
JavaScript
/* * Treeview 1.5pre - jQuery plugin to hide and show branches of a tree * * http://bassistance.de/jquery-plugins/jquery-plugin-treeview/ * http://docs.jquery.com/Plugins/Treeview * * Copyright (c) 2007 Jörn Zaefferer * * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Revision: $Id: jquery.treeview.js 5759 2008-07-01 07:50:28Z joern.zaefferer $ * */ ;(function($) { // TODO rewrite as a widget, removing all the extra plugins $.extend($.fn, { swapClass: function(c1, c2) { var c1Elements = this.filter('.' + c1); this.filter('.' + c2).removeClass(c2).addClass(c1); c1Elements.removeClass(c1).addClass(c2); return this; }, replaceClass: function(c1, c2) { return this.filter('.' + c1).removeClass(c1).addClass(c2).end(); }, hoverClass: function(className) { className = className || "hover"; return this.hover(function() { $(this).addClass(className); }, function() { $(this).removeClass(className); }); }, heightToggle: function(animated, callback) { animated ? this.animate({ height: "toggle" }, animated, callback) : this.each(function(){ jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ](); if(callback) callback.apply(this, arguments); }); }, heightHide: function(animated, callback) { if (animated) { this.animate({ height: "hide" }, animated, callback); } else { this.hide(); if (callback) this.each(callback); } }, prepareBranches: function(settings) { if (!settings.prerendered) { // mark last tree items this.filter(":last-child:not(ul)").addClass(CLASSES.last); // collapse whole tree, or only those marked as closed, anyway except those marked as open this.filter((settings.collapsed ? "" : "." + CLASSES.closed) + ":not(." + CLASSES.open + ")").find(">ul").hide(); } // return all items with sublists return this.filter(":has(>ul)"); }, applyClasses: function(settings, toggler) { // TODO use event delegation this.filter(":has(>ul):not(:has(>a))").find(">span").unbind("click.treeview").bind("click.treeview", function(event) { // don't handle click events on children, eg. checkboxes if ( this == event.target ) toggler.apply($(this).next()); }).add( $("a", this) ).hoverClass(); if (!settings.prerendered) { // handle closed ones first this.filter(":has(>ul:hidden)") .addClass(CLASSES.expandable) .replaceClass(CLASSES.last, CLASSES.lastExpandable); // handle open ones this.not(":has(>ul:hidden)") .addClass(CLASSES.collapsable) .replaceClass(CLASSES.last, CLASSES.lastCollapsable); // create hitarea if not present var hitarea = this.find("div." + CLASSES.hitarea); if (!hitarea.length) hitarea = this.prepend("<div class=\"" + CLASSES.hitarea + "\"/>").find("div." + CLASSES.hitarea); hitarea.removeClass().addClass(CLASSES.hitarea).each(function() { var classes = ""; $.each($(this).parent().attr("class").split(" "), function() { classes += this + "-hitarea "; }); $(this).addClass( classes ); }) } // apply event to hitarea this.find("div." + CLASSES.hitarea).click( toggler ); }, treeview: function(settings) { settings = $.extend({ cookieId: "treeview" }, settings); if ( settings.toggle ) { var callback = settings.toggle; settings.toggle = function() { return callback.apply($(this).parent()[0], arguments); }; } // factory for treecontroller function treeController(tree, control) { // factory for click handlers function handler(filter) { return function() { // reuse toggle event handler, applying the elements to toggle // start searching for all hitareas toggler.apply( $("div." + CLASSES.hitarea, tree).filter(function() { // for plain toggle, no filter is provided, otherwise we need to check the parent element return filter ? $(this).parent("." + filter).length : true; }) ); return false; }; } // click on first element to collapse tree $("a:eq(0)", control).click( handler(CLASSES.collapsable) ); // click on second to expand tree $("a:eq(1)", control).click( handler(CLASSES.expandable) ); // click on third to toggle tree $("a:eq(2)", control).click( handler() ); } // handle toggle event function toggler() { $(this) .parent() // swap classes for hitarea .find(">.hitarea") .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) .end() // swap classes for parent li .swapClass( CLASSES.collapsable, CLASSES.expandable ) .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) // find child lists .find( ">ul" ) // toggle them .heightToggle( settings.animated, settings.toggle ); if ( settings.unique ) { $(this).parent() .siblings() // swap classes for hitarea .find(">.hitarea") .replaceClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) .replaceClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ) .end() .replaceClass( CLASSES.collapsable, CLASSES.expandable ) .replaceClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) .find( ">ul" ) .heightHide( settings.animated, settings.toggle ); } } this.data("toggler", toggler); function serialize() { function binary(arg) { return arg ? 1 : 0; } var data = []; branches.each(function(i, e) { data[i] = $(e).is(":has(>ul:visible)") ? 1 : 0; }); $.cookie(settings.cookieId, data.join(""), settings.cookieOptions ); } function deserialize() { var stored = $.cookie(settings.cookieId); if ( stored ) { var data = stored.split(""); branches.each(function(i, e) { $(e).find(">ul")[ parseInt(data[i]) ? "show" : "hide" ](); }); } } // add treeview class to activate styles this.addClass("treeview"); // prepare branches and find all tree items with child lists var branches = this.find("li").prepareBranches(settings); switch(settings.persist) { case "cookie": var toggleCallback = settings.toggle; settings.toggle = function() { serialize(); if (toggleCallback) { toggleCallback.apply(this, arguments); } }; deserialize(); break; case "location": var current = this.find("a").filter(function() { return this.href.toLowerCase() == location.href.toLowerCase(); }); if ( current.length ) { // TODO update the open/closed classes var items = current.addClass("selected").parents("ul, li").add( current.next() ).show(); if (settings.prerendered) { // if prerendered is on, replicate the basic class swapping items.filter("li") .swapClass( CLASSES.collapsable, CLASSES.expandable ) .swapClass( CLASSES.lastCollapsable, CLASSES.lastExpandable ) .find(">.hitarea") .swapClass( CLASSES.collapsableHitarea, CLASSES.expandableHitarea ) .swapClass( CLASSES.lastCollapsableHitarea, CLASSES.lastExpandableHitarea ); } } break; } branches.applyClasses(settings, toggler); // if control option is set, create the treecontroller and show it if ( settings.control ) { treeController(this, settings.control); $(settings.control).show(); } return this; } }); // classes used by the plugin // need to be styled via external stylesheet, see first example $.treeview = {}; var CLASSES = ($.treeview.classes = { open: "open", closed: "closed", expandable: "expandable", expandableHitarea: "expandable-hitarea", lastExpandableHitarea: "lastExpandable-hitarea", collapsable: "collapsable", collapsableHitarea: "collapsable-hitarea", lastCollapsableHitarea: "lastCollapsable-hitarea", lastCollapsable: "lastCollapsable", lastExpandable: "lastExpandable", last: "last", hitarea: "hitarea" }); })(jQuery);
JavaScript
/* * jQuery-lazyload-any v0.1.6 * https://github.com/emn178/jquery-lazyload-any * * Copyright 2014, emn178@gmail.com * * Licensed under the MIT license: * http://www.opensource.org/licenses/MIT */ ;(function($, window, document, undefined) { var KEY = 'jquery-lazyload-any'; var EVENT = 'appear'; var SELECTOR_KEY = KEY + '-' + EVENT; var SELECTOR = ':' + SELECTOR_KEY; $.expr[':'][SELECTOR_KEY] = function(element) { return !!$(element).data(SELECTOR_KEY); }; function test() { var element = $(this); if(element.is(':visible') && visible(element)) element.trigger(EVENT); } function visible(element) { var rect = element[0].getBoundingClientRect(); var x1 = y1 = -element.data(KEY).threshold; var y2 = screenHeight - y1; var x2 = screenWidth - x1; return (rect.top >= y1 && rect.top <= y2 || rect.bottom >= y1 && rect.bottom <= y2) && (rect.left >= x1 && rect.left <= x2 || rect.right >= x1 && rect.right <= x2); } var screenHeight, screenWidth; function resize() { screenHeight = window.innerHeight || document.documentElement.clientHeight; screenWidth = window.innerWidth || document.documentElement.clientWidth; scroll(); } function scroll() { $(SELECTOR).each(test); } function show() { var element = $(this); var options = element.data(KEY); element.off(options.trigger); var comment = element.contents().filter(function() { return this.nodeType === 8; }).get(0); var newElement = $(comment && comment.data.trim()); element.replaceWith(newElement); if($.isFunction(options.load)) options.load.call(newElement, newElement); } $.fn.lazyload = function(options) { var opts = { threshold: 0, trigger: EVENT }; $.extend(opts, options); var trigger = opts.trigger.split(' '); this.data(SELECTOR_KEY, $.inArray(EVENT, trigger) != -1); this.data(KEY, opts); this.on(opts.trigger, show); this.each(test); }; $(document).ready(function() { $(window).on('resize', resize); $(window).on('scroll', scroll); resize(); }); })(jQuery, window, document);
JavaScript
(function(root, factory) { if(typeof exports === 'object') { module.exports = factory(); } else if(typeof define === 'function' && define.amd) { define('salvattore', [], factory); } else { root.salvattore = factory(); } }(this, function() { /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */ window.matchMedia || (window.matchMedia = function() { "use strict"; // For browsers that support matchMedium api such as IE 9 and webkit var styleMedia = (window.styleMedia || window.media); // For those that don't support matchMedium if (!styleMedia) { var style = document.createElement('style'), script = document.getElementsByTagName('script')[0], info = null; style.type = 'text/css'; style.id = 'matchmediajs-test'; script.parentNode.insertBefore(style, script); // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle; styleMedia = { matchMedium: function(media) { var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }'; // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers if (style.styleSheet) { style.styleSheet.cssText = text; } else { style.textContent = text; } // Test if media query is true or false return info.width === '1px'; } }; } return function(media) { return { matches: styleMedia.matchMedium(media || 'all'), media: media || 'all' }; }; }()); ;/*! matchMedia() polyfill addListener/removeListener extension. Author & copyright (c) 2012: Scott Jehl. Dual MIT/BSD license */ (function(){ // Bail out for browsers that have addListener support if (window.matchMedia && window.matchMedia('all').addListener) { return false; } var localMatchMedia = window.matchMedia, hasMediaQueries = localMatchMedia('only all').matches, isListening = false, timeoutID = 0, // setTimeout for debouncing 'handleChange' queries = [], // Contains each 'mql' and associated 'listeners' if 'addListener' is used handleChange = function(evt) { // Debounce clearTimeout(timeoutID); timeoutID = setTimeout(function() { for (var i = 0, il = queries.length; i < il; i++) { var mql = queries[i].mql, listeners = queries[i].listeners || [], matches = localMatchMedia(mql.media).matches; // Update mql.matches value and call listeners // Fire listeners only if transitioning to or from matched state if (matches !== mql.matches) { mql.matches = matches; for (var j = 0, jl = listeners.length; j < jl; j++) { listeners[j].call(window, mql); } } } }, 30); }; window.matchMedia = function(media) { var mql = localMatchMedia(media), listeners = [], index = 0; mql.addListener = function(listener) { // Changes would not occur to css media type so return now (Affects IE <= 8) if (!hasMediaQueries) { return; } // Set up 'resize' listener for browsers that support CSS3 media queries (Not for IE <= 8) // There should only ever be 1 resize listener running for performance if (!isListening) { isListening = true; window.addEventListener('resize', handleChange, true); } // Push object only if it has not been pushed already if (index === 0) { index = queries.push({ mql : mql, listeners : listeners }); } listeners.push(listener); }; mql.removeListener = function(listener) { for (var i = 0, il = listeners.length; i < il; i++){ if (listeners[i] === listener){ listeners.splice(i, 1); } } }; return mql; }; }()); ;// http://paulirish.com/2011/requestanimationframe-for-smart-animating/ // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel // MIT license (function() { var lastTime = 0; var vendors = ['ms', 'moz', 'webkit', 'o']; for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame']; window.cancelAnimationFrame = window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame']; } if (!window.requestAnimationFrame) window.requestAnimationFrame = function(callback, element) { var currTime = new Date().getTime(); var timeToCall = Math.max(0, 16 - (currTime - lastTime)); var id = window.setTimeout(function() { callback(currTime + timeToCall); }, timeToCall); lastTime = currTime + timeToCall; return id; }; if (!window.cancelAnimationFrame) window.cancelAnimationFrame = function(id) { clearTimeout(id); }; }()); ;var salvattore = (function (global, document, undefined) { "use strict"; var self = {}, grids = [], add_to_dataset = function(element, key, value) { // uses dataset function or a fallback for <ie10 if (element.dataset) { element.dataset[key] = value; } else { element.setAttribute("data-" + key, value); } return; }; self.obtain_grid_settings = function obtain_grid_settings(element) { // returns the number of columns and the classes a column should have, // from computing the style of the ::before pseudo-element of the grid. var computedStyle = global.getComputedStyle(element, ":before") , content = computedStyle.getPropertyValue("content").slice(1, -1) , matchResult = content.match(/^\s*(\d+)(?:\s?\.(.+))?\s*$/) , numberOfColumns , columnClasses ; if (matchResult) { numberOfColumns = matchResult[1]; columnClasses = matchResult[2]; columnClasses = columnClasses? columnClasses.split(".") : ["column"]; } else { matchResult = content.match(/^\s*\.(.+)\s+(\d+)\s*$/); columnClasses = matchResult[1]; numberOfColumns = matchResult[2]; if (numberOfColumns) { numberOfColumns = numberOfColumns.split("."); } } return { numberOfColumns: numberOfColumns, columnClasses: columnClasses }; }; self.add_columns = function add_columns(grid, items) { // from the settings obtained, it creates columns with // the configured classes and adds to them a list of items. var settings = self.obtain_grid_settings(grid) , numberOfColumns = settings.numberOfColumns , columnClasses = settings.columnClasses , columnsItems = new Array(+numberOfColumns) , columnsFragment = document.createDocumentFragment() , i = numberOfColumns , selector ; while (i-- !== 0) { selector = "[data-columns] > *:nth-child(" + numberOfColumns + "n-" + i + ")"; columnsItems.push(items.querySelectorAll(selector)); } columnsItems.forEach(function append_to_grid_fragment(rows) { var column = document.createElement("div") , rowsFragment = document.createDocumentFragment() ; column.className = columnClasses.join(" "); Array.prototype.forEach.call(rows, function append_to_column(row) { rowsFragment.appendChild(row); }); column.appendChild(rowsFragment); columnsFragment.appendChild(column); }); grid.appendChild(columnsFragment); add_to_dataset(grid, 'columns', numberOfColumns); }; self.remove_columns = function remove_columns(grid) { // removes all the columns from a grid, and returns a list // of items sorted by the ordering of columns. var range = document.createRange(); range.selectNodeContents(grid); var columns = Array.prototype.filter.call(range.extractContents().childNodes, function filter_elements(node) { return node instanceof global.HTMLElement; }); var numberOfColumns = columns.length , numberOfRowsInFirstColumn = columns[0].childNodes.length , sortedRows = new Array(numberOfRowsInFirstColumn * numberOfColumns) ; Array.prototype.forEach.call(columns, function iterate_columns(column, columnIndex) { Array.prototype.forEach.call(column.children, function iterate_rows(row, rowIndex) { sortedRows[rowIndex * numberOfColumns + columnIndex] = row; }); }); var container = document.createElement("div"); add_to_dataset(container, 'columns', 0); sortedRows.filter(function filter_non_null(child) { return !!child; }).forEach(function append_row(child) { container.appendChild(child); }); return container; }; self.recreate_columns = function recreate_columns(grid) { // removes all the columns from the grid, and adds them again, // it is used when the number of columns change. global.requestAnimationFrame(function render_after_css_media_query_change() { self.add_columns(grid, self.remove_columns(grid)); }); }; self.media_query_change = function media_query_change(mql) { // recreates the columns when a media query matches the current state // of the browser. if (mql.matches) { Array.prototype.forEach.call(grids, self.recreate_columns); } }; self.get_css_rules = function get_css_rules(stylesheet) { // returns a list of css rules from a stylesheet var cssRules; try { cssRules = stylesheet.sheet.cssRules || stylesheet.sheet.rules; } catch (e) { return []; } return cssRules || []; }; self.get_stylesheets = function get_stylesheets() { // returns a list of all the styles in the document (that are accessible). return Array.prototype.concat.call( Array.prototype.slice.call(document.querySelectorAll("style[type='text/css']")), Array.prototype.slice.call(document.querySelectorAll("link[rel='stylesheet']")) ); }; self.media_rule_has_columns_selector = function media_rule_has_columns_selector(rules) { // checks if a media query css rule has in its contents a selector that // styles the grid. var i = rules.length , rule ; while (i--) { rule = rules[i]; if (rule.selectorText && rule.selectorText.match(/\[data-columns\](.*)::?before$/)) { return true; } } return false; }; self.scan_media_queries = function scan_media_queries() { // scans all the stylesheets for selectors that style grids, // if the matchMedia API is supported. var mediaQueries = []; if (!global.matchMedia) { return; } self.get_stylesheets().forEach(function extract_rules(stylesheet) { Array.prototype.forEach.call(self.get_css_rules(stylesheet), function filter_by_column_selector(rule) { if (rule.media && self.media_rule_has_columns_selector(rule.cssRules)) { mediaQueries.push(global.matchMedia(rule.media.mediaText)); } }); }); mediaQueries.forEach(function listen_to_changes(mql) { mql.addListener(self.media_query_change); }); }; self.next_element_column_index = function next_element_column_index(grid, fragments) { // returns the index of the column where the given element must be added. var children = grid.children , m = children.length , lowestRowCount = 0 , child , currentRowCount , i , index = 0 ; for (i = 0; i < m; i++) { child = children[i]; currentRowCount = child.children.length + fragments[i].children.length; if(lowestRowCount === 0) { lowestRowCount = currentRowCount; } if(currentRowCount < lowestRowCount) { index = i; lowestRowCount = currentRowCount; } } return index; }; self.create_list_of_fragments = function create_list_of_fragments(quantity) { // returns a list of fragments var fragments = new Array(quantity) , i = 0 ; while (i !== quantity) { fragments[i] = document.createDocumentFragment(); i++; } return fragments; }; self.append_elements = function append_elements(grid, elements) { // adds a list of elements to the end of a grid var columns = grid.children , numberOfColumns = columns.length , fragments = self.create_list_of_fragments(numberOfColumns) ; elements.forEach(function append_to_next_fragment(element) { var columnIndex = self.next_element_column_index(grid, fragments); fragments[columnIndex].appendChild(element); }); Array.prototype.forEach.call(columns, function insert_column(column, index) { column.appendChild(fragments[index]); }); }; self.prepend_elements = function prepend_elements(grid, elements) { // adds a list of elements to the start of a grid var columns = grid.children , numberOfColumns = columns.length , fragments = self.create_list_of_fragments(numberOfColumns) , columnIndex = numberOfColumns - 1 ; elements.forEach(function append_to_next_fragment(element) { var fragment = fragments[columnIndex]; fragment.insertBefore(element, fragment.firstChild); if (columnIndex === 0) { columnIndex = numberOfColumns - 1; } else { columnIndex--; } }); Array.prototype.forEach.call(columns, function insert_column(column, index) { column.insertBefore(fragments[index], column.firstChild); }); // populates a fragment with n columns till the right var fragment = document.createDocumentFragment() , numberOfColumnsToExtract = elements.length % numberOfColumns ; while (numberOfColumnsToExtract-- !== 0) { fragment.appendChild(grid.lastChild); } // adds the fragment to the left grid.insertBefore(fragment, grid.firstChild); }; self.register_grid = function register_grid (grid) { if (global.getComputedStyle(grid).display === "none") { return; } // retrieve the list of items from the grid itself var range = document.createRange(); range.selectNodeContents(grid); var items = document.createElement("div"); items.appendChild(range.extractContents()); add_to_dataset(items, 'columns', 0); self.add_columns(grid, items); grids.push(grid); }; self.init = function init() { // adds required CSS rule to hide 'content' based // configuration. var css = document.createElement("style"); css.innerHTML = "[data-columns]::before{visibility:hidden;position:absolute;font-size:1px;}"; document.head.appendChild(css); // scans all the grids in the document and generates // columns from their configuration. var gridElements = document.querySelectorAll("[data-columns]"); Array.prototype.forEach.call(gridElements, self.register_grid); self.scan_media_queries(); }; self.init(); return { append_elements: self.append_elements, prepend_elements: self.prepend_elements, register_grid: self.register_grid }; })(window, window.document); return salvattore; }));
JavaScript
/* StreamWave Flash Title Widget _ Javascript for Embedding 2008. 10. 29. scripted by MinsangK (http://minsangk.com) */ // main function function showTitle(srcUrl, srcFilename, width, height, titleStr, linkStr, hAlign, tColor) { var str = "<embed id=\"viewTitle\" name=\"viewTitle\" type=\"application/x-shockwave-flash\" src=\"" + srcUrl + srcFilename + "\" width=\"" + width + "\" height=\"" + height + "\" wmode=\"transparent\"" + " allowScriptAccess=\"always\"" + "FlashVars=\"" + "articleTitle="+ pEncode(titleStr) +"&linkTo=" + linkStr + "&hAlign=" + hAlign + "&tColor="+ tColor + "\"/>"; // window.alert(str); document.write(str); } // percent-encoding function pEncode(str) { str = str.replace(/&amp;/g, "%26"); //str = str.replace(/[&]/g, "%26"); str = str.replace(/[+]/g, "%2b"); return str; }
JavaScript
$(function() { // Side Bar Toggle $('.hide-sidebar').click(function() { $('#sidebar').hide('fast', function() { $('#content').removeClass('span9'); $('#content').addClass('span12'); $('.hide-sidebar').hide(); $('.show-sidebar').show(); }); }); $('.show-sidebar').click(function() { $('#content').removeClass('span12'); $('#content').addClass('span9'); $('.show-sidebar').hide(); $('.hide-sidebar').show(); $('#sidebar').show('fast'); }); });
JavaScript
/* Set the defaults for DataTables initialisation */ $.extend( true, $.fn.dataTable.defaults, { "sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page" } } ); /* Default class modification */ $.extend( $.fn.dataTableExt.oStdClasses, { "sWrapper": "dataTables_wrapper form-inline" } ); /* API method to get paging information */ $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings ) { return { "iStart": oSettings._iDisplayStart, "iEnd": oSettings.fnDisplayEnd(), "iLength": oSettings._iDisplayLength, "iTotal": oSettings.fnRecordsTotal(), "iFilteredTotal": oSettings.fnRecordsDisplay(), "iPage": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ), "iTotalPages": oSettings._iDisplayLength === -1 ? 0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength ) }; }; /* Bootstrap style pagination control */ $.extend( $.fn.dataTableExt.oPagination, { "bootstrap": { "fnInit": function( oSettings, nPaging, fnDraw ) { var oLang = oSettings.oLanguage.oPaginate; var fnClickHandler = function ( e ) { e.preventDefault(); if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) { fnDraw( oSettings ); } }; $(nPaging).addClass('pagination').append( '<ul>'+ '<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+ '<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+ '</ul>' ); var els = $('a', nPaging); $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler ); $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler ); }, "fnUpdate": function ( oSettings, fnDraw ) { var iListLength = 5; var oPaging = oSettings.oInstance.fnPagingInfo(); var an = oSettings.aanFeatures.p; var i, ien, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2); if ( oPaging.iTotalPages < iListLength) { iStart = 1; iEnd = oPaging.iTotalPages; } else if ( oPaging.iPage <= iHalf ) { iStart = 1; iEnd = iListLength; } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) { iStart = oPaging.iTotalPages - iListLength + 1; iEnd = oPaging.iTotalPages; } else { iStart = oPaging.iPage - iHalf + 1; iEnd = iStart + iListLength - 1; } for ( i=0, ien=an.length ; i<ien ; i++ ) { // Remove the middle elements $('li:gt(0)', an[i]).filter(':not(:last)').remove(); // Add the new list items and their event handlers for ( j=iStart ; j<=iEnd ; j++ ) { sClass = (j==oPaging.iPage+1) ? 'class="active"' : ''; $('<li '+sClass+'><a href="#">'+j+'</a></li>') .insertBefore( $('li:last', an[i])[0] ) .bind('click', function (e) { e.preventDefault(); oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength; fnDraw( oSettings ); } ); } // Add / remove disabled classes from the static elements if ( oPaging.iPage === 0 ) { $('li:first', an[i]).addClass('disabled'); } else { $('li:first', an[i]).removeClass('disabled'); } if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) { $('li:last', an[i]).addClass('disabled'); } else { $('li:last', an[i]).removeClass('disabled'); } } } } } ); /* * TableTools Bootstrap compatibility * Required TableTools 2.1+ */ if ( $.fn.DataTable.TableTools ) { // Set the classes that TableTools uses to something suitable for Bootstrap $.extend( true, $.fn.DataTable.TableTools.classes, { "container": "DTTT btn-group", "buttons": { "normal": "btn", "disabled": "disabled" }, "collection": { "container": "DTTT_dropdown dropdown-menu", "buttons": { "normal": "", "disabled": "disabled" } }, "print": { "info": "DTTT_print_info modal" }, "select": { "row": "active" } } ); // Have the collection use a bootstrap compatible dropdown $.extend( true, $.fn.DataTable.TableTools.DEFAULTS.oTags, { "collection": { "container": "ul", "button": "li", "liner": "a" } } ); } /* Table initialisation */ $(document).ready(function() { $('#example').dataTable( { "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page" } } ); $('#example2').dataTable( { "sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>", "sPaginationType": "bootstrap", "oLanguage": { "sLengthMenu": "_MENU_ records per page" } } ); } );
JavaScript
var FormValidation = function () { var handleValidation1 = function() { // for more info visit the official plugin documentation: // http://docs.jquery.com/Plugins/Validation var form1 = $('#form_sample_1'); var error1 = $('.alert-error', form1); var success1 = $('.alert-success', form1); form1.validate({ errorElement: 'span', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { name: { minlength: 2, required: true }, email: { required: true, email: true }, url: { required: true, url: true }, number: { required: true, number: true }, digits: { required: true, digits: true }, creditcard: { required: true, creditcard: true }, occupation: { minlength: 5, }, category: { required: true } }, invalidHandler: function (event, validator) { //display error alert on form submit success1.hide(); error1.show(); FormValidation.scrollTo(error1, -200); }, highlight: function (element) { // hightlight error inputs $(element) .closest('.help-inline').removeClass('ok'); // display OK icon $(element) .closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group }, unhighlight: function (element) { // revert the change done by hightlight $(element) .closest('.control-group').removeClass('error'); // set error class to the control group }, success: function (label) { label .addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon .closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group }, submitHandler: function (form) { success1.show(); error1.hide(); } }); } return { //main function to initiate the module init: function () { handleValidation1(); }, // wrapper function to scroll to an element scrollTo: function (el, offeset) { pos = el ? el.offset().top : 0; jQuery('html,body').animate({ scrollTop: pos + (offeset ? offeset : 0) }, 'slow'); } }; }();
JavaScript
(function($) { var aux = { // navigates left / right navigate : function( dir, $el, $wrapper, opts, cache ) { var scroll = opts.scroll, factor = 1, idxClicked = 0; if( cache.expanded ) { scroll = 1; // scroll is always 1 in full mode factor = 3; // the width of the expanded item will be 3 times bigger than 1 collapsed item idxClicked = cache.idxClicked; // the index of the clicked item } // clone the elements on the right / left and append / prepend them according to dir and scroll if( dir === 1 ) { $wrapper.find('div.ca-item:lt(' + scroll + ')').each(function(i) { $(this).clone(true).css( 'left', ( cache.totalItems - idxClicked + i ) * cache.itemW * factor + 'px' ).appendTo( $wrapper ); }); } else { var $first = $wrapper.children().eq(0); $wrapper.find('div.ca-item:gt(' + ( cache.totalItems - 1 - scroll ) + ')').each(function(i) { // insert before $first so they stay in the right order $(this).clone(true).css( 'left', - ( scroll - i + idxClicked ) * cache.itemW * factor + 'px' ).insertBefore( $first ); }); } // animate the left of each item // the calculations are dependent on dir and on the cache.expanded value $wrapper.find('div.ca-item').each(function(i) { var $item = $(this); $item.stop().animate({ left : ( dir === 1 ) ? '-=' + ( cache.itemW * factor * scroll ) + 'px' : '+=' + ( cache.itemW * factor * scroll ) + 'px' }, opts.sliderSpeed, opts.sliderEasing, function() { if( ( dir === 1 && $item.position().left < - idxClicked * cache.itemW * factor ) || ( dir === -1 && $item.position().left > ( ( cache.totalItems - 1 - idxClicked ) * cache.itemW * factor ) ) ) { // remove the item that was cloned $item.remove(); } cache.isAnimating = false; }); }); }, // opens an item (animation) -> opens all the others openItem : function( $wrapper, $item, opts, cache ) { cache.idxClicked = $item.index(); // the item's position (1, 2, or 3) on the viewport (the visible items) cache.winpos = aux.getWinPos( $item.position().left, cache ); $wrapper.find('div.ca-item').not( $item ).hide(); $item.find('div.ca-content-wrapper').css( 'left', cache.itemW + 'px' ).stop().animate({ width : cache.itemW * 2 + 'px', left : cache.itemW + 'px' }, opts.itemSpeed, opts.itemEasing) .end() .stop() .animate({ left : '0px' }, opts.itemSpeed, opts.itemEasing, function() { cache.isAnimating = false; cache.expanded = true; aux.openItems( $wrapper, $item, opts, cache ); }); }, // opens all the items openItems : function( $wrapper, $openedItem, opts, cache ) { var openedIdx = $openedItem.index(); $wrapper.find('div.ca-item').each(function(i) { var $item = $(this), idx = $item.index(); if( idx !== openedIdx ) { $item.css( 'left', - ( openedIdx - idx ) * ( cache.itemW * 3 ) + 'px' ).show().find('div.ca-content-wrapper').css({ left : cache.itemW + 'px', width : cache.itemW * 2 + 'px' }); // hide more link aux.toggleMore( $item, false ); } }); }, // show / hide the item's more button toggleMore : function( $item, show ) { ( show ) ? $item.find('a.ca-more').show() : $item.find('a.ca-more').hide(); }, // close all the items // the current one is animated closeItems : function( $wrapper, $openedItem, opts, cache ) { var openedIdx = $openedItem.index(); $openedItem.find('div.ca-content-wrapper').stop().animate({ width : '0px' }, opts.itemSpeed, opts.itemEasing) .end() .stop() .animate({ left : cache.itemW * ( cache.winpos - 1 ) + 'px' }, opts.itemSpeed, opts.itemEasing, function() { cache.isAnimating = false; cache.expanded = false; }); // show more link aux.toggleMore( $openedItem, true ); $wrapper.find('div.ca-item').each(function(i) { var $item = $(this), idx = $item.index(); if( idx !== openedIdx ) { $item.find('div.ca-content-wrapper').css({ width : '0px' }) .end() .css( 'left', ( ( cache.winpos - 1 ) - ( openedIdx - idx ) ) * cache.itemW + 'px' ) .show(); // show more link aux.toggleMore( $item, true ); } }); }, // gets the item's position (1, 2, or 3) on the viewport (the visible items) // val is the left of the item getWinPos : function( val, cache ) { switch( val ) { case 0 : return 1; break; case cache.itemW : return 2; break; case cache.itemW * 2 : return 3; break; } } }, methods = { init : function( options ) { if( this.length ) { var settings = { sliderSpeed : 500, // speed for the sliding animation sliderEasing : 'easeOutExpo',// easing for the sliding animation itemSpeed : 500, // speed for the item animation (open / close) itemEasing : 'easeOutExpo',// easing for the item animation (open / close) scroll : 1 // number of items to scroll at a time }; return this.each(function() { // if options exist, lets merge them with our default settings if ( options ) { $.extend( settings, options ); } var $el = $(this), $wrapper = $el.find('div.ca-wrapper'), $items = $wrapper.children('div.ca-item'), cache = {}; // save the with of one item cache.itemW = $items.width(); // save the number of total items cache.totalItems = $items.length; // add navigation buttons if( cache.totalItems > 3 ) $el.prepend('<div class="ca-nav"><span class="ca-nav-prev">Previous</span><span class="ca-nav-next">Next</span></div>') // control the scroll value if( settings.scroll < 1 ) settings.scroll = 1; else if( settings.scroll > 3 ) settings.scroll = 3; var $navPrev = $el.find('span.ca-nav-prev'), $navNext = $el.find('span.ca-nav-next'); // hide the items except the first 3 $wrapper.css( 'overflow', 'hidden' ); // the items will have position absolute // calculate the left of each item $items.each(function(i) { $(this).css({ position : 'absolute', left : i * cache.itemW + 'px' }); }); // click to open the item(s) $el.find('a.ca-more').live('click.contentcarousel', function( event ) { if( cache.isAnimating ) return false; cache.isAnimating = true; $(this).hide(); var $item = $(this).closest('div.ca-item'); aux.openItem( $wrapper, $item, settings, cache ); return false; }); // click to close the item(s) $el.find('a.ca-close').live('click.contentcarousel', function( event ) { if( cache.isAnimating ) return false; cache.isAnimating = true; var $item = $(this).closest('div.ca-item'); aux.closeItems( $wrapper, $item, settings, cache ); return false; }); // navigate left $navPrev.bind('click.contentcarousel', function( event ) { if( cache.isAnimating ) return false; cache.isAnimating = true; aux.navigate( -1, $el, $wrapper, settings, cache ); }); // navigate right $navNext.bind('click.contentcarousel', function( event ) { if( cache.isAnimating ) return false; cache.isAnimating = true; aux.navigate( 1, $el, $wrapper, settings, cache ); }); // adds events to the mouse $el.bind('mousewheel.contentcarousel', function(e, delta) { if(delta > 0) { if( cache.isAnimating ) return false; cache.isAnimating = true; aux.navigate( -1, $el, $wrapper, settings, cache ); } else { if( cache.isAnimating ) return false; cache.isAnimating = true; aux.navigate( 1, $el, $wrapper, settings, cache ); } return false; }); }); } } }; $.fn.contentcarousel = function(method) { if ( methods[method] ) { return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 )); } else if ( typeof method === 'object' || ! method ) { return methods.init.apply( this, arguments ); } else { $.error( 'Method ' + method + ' does not exist on jQuery.contentcarousel' ); } }; })(jQuery);
JavaScript
/** * LavaLamp - A menu plugin for jQuery with cool hover effects. * @requires jQuery v1.1.3.1 or above * * http://gmarwaha.com/blog/?p=7 * * Copyright (c) 2007 Ganeshji Marwaha (gmarwaha.com) * Dual licensed under the MIT and GPL licenses: * http://www.opensource.org/licenses/mit-license.php * http://www.gnu.org/licenses/gpl.html * * Version: 0.1.0 */ /** * Creates a menu with an unordered list of menu-items. You can either use the CSS that comes with the plugin, or write your own styles * to create a personalized effect * * The HTML markup used to build the menu can be as simple as... * * <ul class="lavaLamp"> * <li><a href="#">Home</a></li> * <li><a href="#">Plant a tree</a></li> * <li><a href="#">Travel</a></li> * <li><a href="#">Ride an elephant</a></li> * </ul> * * Once you have included the style sheet that comes with the plugin, you will have to include * a reference to jquery library, easing plugin(optional) and the LavaLamp(this) plugin. * * Use the following snippet to initialize the menu. * $(function() { $(".lavaLamp").lavaLamp({ fx: "backout", speed: 700}) }); * * Thats it. Now you should have a working lavalamp menu. * * @param an options object - You can specify all the options shown below as an options object param. * * @option fx - default is "linear" * @example * $(".lavaLamp").lavaLamp({ fx: "backout" }); * @desc Creates a menu with "backout" easing effect. You need to include the easing plugin for this to work. * * @option speed - default is 500 ms * @example * $(".lavaLamp").lavaLamp({ speed: 500 }); * @desc Creates a menu with an animation speed of 500 ms. * * @option click - no defaults * @example * $(".lavaLamp").lavaLamp({ click: function(event, menuItem) { return false; } }); * @desc You can supply a callback to be executed when the menu item is clicked. * The event object and the menu-item that was clicked will be passed in as arguments. */ (function($) { $.fn.lavaLamp = function(o) { o = $.extend({ fx: "linear", speed: 500, click: function(){} }, o || {}); return this.each(function() { var me = $(this), noop = function(){}, $back = $('<li class="back"><div class="left"></div></li>').appendTo(me), $li = $("li", this), curr = $("li.current", this)[0] || $($li[0]).addClass("current")[0]; $li.not(".back").hover(function() { move(this); }, noop); $(this).hover(noop, function() { move(curr); }); $li.click(function(e) { setCurr(this); return o.click.apply(this, [e, this]); }); setCurr(curr); function setCurr(el) { $back.css({ "left": el.offsetLeft+"px", "width": el.offsetWidth+"px" }); curr = el; }; function move(el) { $back.each(function() { $.dequeue(this, "fx"); } ).animate({ width: el.offsetWidth, left: el.offsetLeft }, o.speed, o.fx); }; }); }; })(jQuery);
JavaScript
$(document).ready(function() { $('.single-item').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 1, slidesToScroll: 1 }); $('.multiple-items').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 3, slidesToScroll: 3 }); $('.one-time').slick({ dots: true, infinite: false, placeholders: false, speed: 300, slidesToShow: 5, touchMove: false, slidesToScroll: 1 }); $('.uneven').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 4, slidesToScroll: 4 }); $('.responsive').slick({ dots: true, infinite: false, speed: 300, slidesToShow: 4, slidesToScroll: 4, responsive: [{ breakpoint: 1024, settings: { slidesToShow: 3, slidesToScroll: 3, infinite: true, dots: true } }, { breakpoint: 600, settings: { slidesToShow: 2, slidesToScroll: 2 } }, { breakpoint: 480, settings: { slidesToShow: 1, slidesToScroll: 1 } }] }); $('.center').slick({ centerMode: true, centerPadding: '60px', slidesToShow: 3, responsive: [{ breakpoint: 768, settings: { arrows: false, centerMode: true, centerPadding: '40px', slidesToShow: 3 } }, { breakpoint: 480, settings: { arrows: false, centerMode: true, centerPadding: '40px', slidesToShow: 1 } }] }); $('.lazy').slick({ lazyLoad: 'ondemand', slidesToShow: 3, slidesToScroll: 1 }); $('.autoplay').slick({ dots: true, infinite: true, speed: 300, slidesToShow: 3, slidesToScroll: 1, autoplay: true, autoplaySpeed: 2000 }); $('.fade').slick({ dots: true, infinite: true, speed: 500, fade: true, slide: 'div', cssEase: 'linear' }); $('.add-remove').slick({ dots: true, slidesToShow: 3, slidesToScroll: 3 }); var slideIndex = 1; $('.js-add-slide').on('click', function() { slideIndex++; $('.add-remove').slickAdd('<div><h3>' + slideIndex + '</h3></div>'); }); $('.js-remove-slide').on('click', function() { $('.add-remove').slickRemove(slideIndex - 1); if (slideIndex !== 0){ slideIndex--; } }); $('.filtering').slick({ dots: true, slidesToShow: 4, slidesToScroll: 4 }); var filtered = false; $('.js-filter').on('click', function() { if (filtered === false) { $('.filtering').slickFilter(':even'); $(this).text('Unfilter Slides'); filtered = true; } else { $('.filtering').slickUnfilter(); $(this).text('Filter Slides'); filtered = false; } }); $(window).on('scroll', function() { if ($(window).scrollTop() > 166) { $('.fixed-header').show(); } else { $('.fixed-header').hide(); } }); $('ul.nav a').on('click', function(event) { event.preventDefault(); var targetID = $(this).attr('href'); var targetST = $(targetID).offset().top - 48; $('body, html').animate({ scrollTop: targetST + 'px' }, 300); }); });
JavaScript
/** * SWFObject v1.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ * * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * * **SWFObject is the SWF embed script formarly known as FlashObject. The name was changed for * legal reasons. */ if(typeof deconcept=="undefined"){var deconcept=new Object();} if(typeof deconcept.util=="undefined"){deconcept.util=new Object();} if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();} deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a,_b){ if(!document.createElement||!document.getElementById){return;} this.DETECT_KEY=_b?_b:"detectflash"; this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY); this.params=new Object(); this.variables=new Object(); this.attributes=new Array(); if(_1){this.setAttribute("swf",_1);} if(id){this.setAttribute("id",id);} if(w){this.setAttribute("width",w);} if(h){this.setAttribute("height",h);} if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));} this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute("version"),_7); if(c){this.addParam("bgcolor",c);} var q=_8?_8:"high"; this.addParam("quality",q); this.setAttribute("useExpressInstall",_7); this.setAttribute("doExpressInstall",false); var _d=(_9)?_9:window.location; this.setAttribute("xiRedirectUrl",_d); this.setAttribute("redirectUrl",""); if(_a){this.setAttribute("redirectUrl",_a);}}; deconcept.SWFObject.prototype={setAttribute:function(_e,_f){ this.attributes[_e]=_f; },getAttribute:function(_10){ return this.attributes[_10]; },addParam:function(_11,_12){ this.params[_11]=_12; },getParams:function(){ return this.params; },addVariable:function(_13,_14){ this.variables[_13]=_14; },getVariable:function(_15){ return this.variables[_15]; },getVariables:function(){ return this.variables; },getVariablePairs:function(){ var _16=new Array(); var key; var _18=this.getVariables(); for(key in _18){ _16.push(key+"="+_18[key]);} return _16; },getSWFHTML:function(){ var _19=""; if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){ if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");} _19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\""; _19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" "; var _1a=this.getParams(); for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";} var _1c=this.getVariablePairs().join("&"); if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";} _19+="/>"; }else{ if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");} _19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\">"; _19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />"; var _1d=this.getParams(); for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";} var _1f=this.getVariablePairs().join("&"); if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";} _19+="</object>";} return _19; },write:function(_20){ if(this.getAttribute("useExpressInstall")){ var _21=new deconcept.PlayerVersion([6,0,65]); if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){ this.setAttribute("doExpressInstall",true); this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl"))); document.title=document.title.slice(0,47)+" - Flash Player Installation"; this.addVariable("MMdoctitle",document.title);}} if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){ var n=(typeof _20=="string")?document.getElementById(_20):_20; n.innerHTML=this.getSWFHTML(); return true; }else{ if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}} return false;}}; deconcept.SWFObjectUtil.getPlayerVersion=function(_23,_24){ var _25=new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins&&navigator.mimeTypes.length){ var x=navigator.plugins["Shockwave Flash"]; if(x&&x.description){_25=new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));} }else{try{ var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); for(var i=3;axo!=null;i++){ axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i); _25=new deconcept.PlayerVersion([i,0,0]);}} catch(e){} if(_23&&_25.major>_23.major){return _25;} if(!_23||((_23.minor!=0||_23.rev!=0)&&_25.major==_23.major)||_25.major!=6||_24){ try{_25=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));} catch(e){}}} return _25;}; deconcept.PlayerVersion=function(_29){ this.major=parseInt(_29[0])!=null?parseInt(_29[0]):0; this.minor=parseInt(_29[1])||0; this.rev=parseInt(_29[2])||0;}; deconcept.PlayerVersion.prototype.versionIsValid=function(fv){ if(this.major<fv.major){return false;} if(this.major>fv.major){return true;} if(this.minor<fv.minor){return false;} if(this.minor>fv.minor){return true;} if(this.rev<fv.rev){return false;}return true;}; deconcept.util={getRequestParameter:function(_2b){ var q=document.location.search||document.location.hash; if(q){ var _2d=q.indexOf(_2b+"="); var _2e=(q.indexOf("&",_2d)>-1)?q.indexOf("&",_2d):q.length; if(q.length>1&&_2d>-1){ return q.substring(q.indexOf("=",_2d)+1,_2e); }}return "";}}; if(Array.prototype.push==null){ Array.prototype.push=function(_2f){ this[this.length]=_2f; return this.length;};} var getQueryParamValue=deconcept.util.getRequestParameter; var FlashObject=deconcept.SWFObject; // for backwards compatibility var SWFObject=deconcept.SWFObject;
JavaScript
/*! Copyright (c) 2010 Brandon Aaron (http://brandonaaron.net) * Licensed under the MIT License (LICENSE.txt). * * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. * Thanks to: Seamus Leahy for adding deltaX and deltaY * * Version: 3.0.4 * * Requires: 1.2.2+ */ (function($) { var types = ['DOMMouseScroll', 'mousewheel']; $.event.special.mousewheel = { setup: function() { if ( this.addEventListener ) { for ( var i=types.length; i; ) { this.addEventListener( types[--i], handler, false ); } } else { this.onmousewheel = handler; } }, teardown: function() { if ( this.removeEventListener ) { for ( var i=types.length; i; ) { this.removeEventListener( types[--i], handler, false ); } } else { this.onmousewheel = null; } } }; $.fn.extend({ mousewheel: function(fn) { return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); }, unmousewheel: function(fn) { return this.unbind("mousewheel", fn); } }); function handler(event) { var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0; event = $.event.fix(orgEvent); event.type = "mousewheel"; // Old school scrollwheel delta if ( event.wheelDelta ) { delta = event.wheelDelta/120; } if ( event.detail ) { delta = -event.detail/3; } // New school multidimensional scroll (touchpads) deltas deltaY = delta; // Gecko if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) { deltaY = 0; deltaX = -1*delta; } // Webkit if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; } if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; } // Add event and delta to the front of the arguments args.unshift(event, delta, deltaX, deltaY); return $.event.handle.apply(this, args); } })(jQuery);
JavaScript
/* Plugin: 3D Tag Sphere Version: 0.1 Author: Ian George Website: http://www.iangeorge.net Tools: Emacs, js2-mode Tested on: IE6, IE7, IE8, Firefox 3.6 Linux, Firefox 3.5 Windows, Chrome Linux / Windows Requirements: Optional jquery.mousewheel for zooming Description: 3d tag cloud, rotates with the mouse and zooms in and out. Fixed camera position to simplify calculations Known issues: Breaks badly on IE5.5 Looks a bit rough on page load TODO: Performance is horrible when more than one instance is present in the page Would be much quicker if instead of recalculating all values on mouse move a global phi/theta value pair is stored and the values calculated on-the-fly in Draw() Options: Option default Comments -------------------------------------------------- zoom 75 Initial zoom level min_zoom 0 max_zoom 100 zoom_factor 2 Speed of zoom by the mouse wheel rotate_by -1.75 In degrees, the amount that the sphere rotates. Negative values reverse the direction. fps 10 Defines the (target) number of times the animation will be updated per second centrex 250 Horizontal rotation centre in the container <div> centrey 250 Vertical rotation centre in the container <div> min_font_size 12 max_font_size 32 font_units 'px' random_points 50 Adds some random points on to the sphere to enhance the effect Usage: Vanilla: $('.tags').tagcloud(); Centreed in a 200 x 200 container: $('.tags').tagcloud({centrex:100,centrey:100}); With a different update speed $('.selector').tagcloud({fps:24}); Markup: Must be an unordered list in a div with links in the list items. rel="[number]" is optional but necessary for ranking by font-size. <div class="tags"> <ul> <li><a href="#" rel="20">link 1</a></li> <li><a href="#" rel="20">link 2</a></li> <li><a href="#" rel="20">link 3</a></li> <li><a href="#" rel="20">link 4</a></li> <li><a href="#" rel="20">link 5</a></li> </ul> */ (function($){ // jquery plugin hook $.fn.tagcloud = function(options){ // overwrite defaults with user-specified var opts = $.extend($.fn.tagcloud.defaults, options); opts.drawing_interval = 1/(opts.fps/1000); //create a new class for every matching element $(this).each(function(){ new TagCloudClass($(this), opts); }); return this; }; //default values for setup $.fn.tagcloud.defaults = { zoom: 75, max_zoom: 120, min_zoom: 25, zoom_factor: 2, //multiplication factor for wheel delta rotate_by: -1.75, // degrees fps: 10, // frames per second centrex: 250, // set centre of display centrey: 250, min_font_size: 12, //font limits and units max_font_size: 32, font_units: 'px', random_points: 0 }; var TagCloudClass = function(el, options){ $(el).css('position', 'relative'); $('ul', el).css('display', 'none'); // general values var eyez = -500; // set rotation (in this case, 5degrees) var rad = Math.PI/180; var basecos = Math.cos(options.rotate_by*rad); var basesin = Math.sin(options.rotate_by*rad); // initial rotation var sin = basesin; var cos = basecos; var hex = new Array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"); // per-instance values var container = $(el); var id_stub = 'tc_' + $(this).attr('id') + "_"; var opts = options; var zoom = opts.zoom; var depth; var lastx = 0; var lasty = 0; var points = []; points['data'] = []; var drawing_interval; var cmx = options.centrex; var cmy = options.centrey; function getgrey(num){ if(num>256){num=256;} if(num<0){num=0;} var rem = num%16; var div = (num-rem)/16; var dig = hex[div] + hex[Math.floor(rem)]; return dig+dig+dig; } //drawing and rotation... function rotx(){ for(var p in points.data) { var temp = sin * points.data[p].y + cos * points.data[p].z; points.data[p].y = cos * points.data[p].y - sin * points.data[p].z; points.data[p].z = temp; } } function roty(){ for(var p in points.data){ var temp = - sin * points.data[p].x + cos * points.data[p].z; points.data[p].x = cos * points.data[p].x + sin * points.data[p].z; points.data[p].z = temp; } } function rotz(){ for(var p in points.data) { var temp = sin * points.data[p].x + cos * points.data[p].y; points.data[p].x = cos * points.data[p].x - sin * points.data[p].y; points.data[p].y = temp; } } function zoomed(by){ zoom += by*opts.zoom_factor; if (zoom>opts.max_zoom) { zoom = opts.max_zoom; } if (zoom<opts.min_zoom) { zoom = opts.min_zoom; } depth = -(zoom*(eyez-opts.max_zoom)/100)+eyez; } function moved(mx,my){ if(mx>lastx){ sin=-basesin; roty(); } if(mx<lastx){ sin=basesin; roty(); } if(my>lasty){ sin=basesin; rotx(); } if(my<lasty){ sin=-basesin; rotx(); } lastx = mx; lasty = my; } function draw(){ // calculate 2D coordinates var normalz = depth * depth; var minz = 0; var maxz = 0; for(var r_p in points.data){ if(points.data[r_p].z < minz){minz = points.data[r_p].z;} if(points.data[r_p].z > maxz){maxz = points.data[r_p].z;} } var diffz = minz-maxz; for(var s_p in points.data){ //normalise depth var u = (depth - eyez)/(points.data[s_p].z - eyez); // calculate normalised grey value var grey = parseInt((points.data[s_p].z/diffz)*165+80); var grey_hex = getgrey(grey); //set new 2d positions for the data $('#'+points.data[s_p].id + ' a', container).css('color','#'+grey_hex); $('#'+points.data[s_p].id, container).css('z-index',grey); $('#'+points.data[s_p].id, container).css('left', u * points.data[s_p].x + cmx - points.data[s_p].cwidth); $('#'+points.data[s_p].id, container).css('top', u * points.data[s_p].y + cmy); } } // number of elements we're adding and placeholders for range values points.count = $('li a', container).length; points.largest = 1; points.smallest = 0; // Run through each li > a in the container and create an absolutely-positioned div in its place // Also need to create a data structure to keep state between calls to draw() // Data structure is as follows: // // points{ // 'count':0, //Total number of points // 'largest':0, //largest 'size' value // 'smallest':0, //Smallest 'size' value // 'data':{ // 'id':"", //HTML id for element // 'size':0, //Size (from rel attribute on <a>) // 'theta':0.0, //Angle on sphere (used to calculate initial cartesian position) // 'phi': 0.0, //Angle on sphere (used to calculate initial cartesian position) // 'x':0.0, //Cartesian position in 3d space // 'y':0.0, //Cartesian position in 3d space // 'z':0.0, //Cartesian position in 3d space // } // } $('li a', container).each(function(idx, val){ var sz = parseInt($(this).attr('rel')); if(sz == 0) sz = 1; points.data[idx] = { id:id_stub + idx, size:sz }; // plot the points on a sphere // from: http://www.math.niu.edu/~rusin/known-math/97/spherefaq // for k=1 to N do // h = -1 + 2*(k-1)/(N-1) // theta[k] = arccos(h) // if k=1 or k=N then phi[k] = 0 // else phi[k] = (phi[k-1] + 3.6/sqrt(N*(1-h^2))) mod (2*pi) // endfor // In Cartesian coordinates the required point on a sphere of radius 1 is // (cos(theta)*sin(phi), sin(theta)*sin(phi), cos(phi)) var h = -1 + 2*(idx)/(points.count-1); points.data[idx].theta = Math.acos(h); if(idx == 0 || idx == points.count-1){ points.data[idx].phi = 0; } else{ points.data[idx].phi = (points.data[idx-1].phi + 3.6/Math.sqrt(points.count*(1-Math.pow(h,2)))) % (2 * Math.PI); } points.data[idx].x = Math.cos(points.data[idx].phi) * Math.sin(points.data[idx].theta) * (cmx/2); points.data[idx].y = Math.sin(points.data[idx].phi) * Math.sin(points.data[idx].theta) * (cmy/2); points.data[idx].z = Math.cos(points.data[idx].theta) * (cmx/2); if(sz > points.largest) points.largest = sz; if(sz < points.smallest) points.smallest = sz; container.append('<div id="'+ id_stub + idx +'" class="point" style="position:absolute;"><a href=' + $(this).attr('href') + '>' + $(this).html() + '</a></div>'); }); //if required to do so (by opts.random_points being > 0) we need to generate some random points on the sphere //bit cheezy, but can make more sparse data sets look a bit more believable if(opts.random_points > 0){ for(b=0; b<opts.random_points; b++){ points.count++; points.data[points.count] = { id:id_stub + points.count, size:1 }; points.data[points.count].theta = Math.random() * 2 * Math.PI; points.data[points.count].phi = Math.random() * 2 * Math.PI; points.data[points.count].x = Math.cos(points.data[points.count].phi) * Math.sin(points.data[points.count].theta) * (cmx/2); points.data[points.count].y = Math.sin(points.data[points.count].phi) * Math.sin(points.data[points.count].theta) * (cmy/2); points.data[points.count].z = Math.cos(points.data[points.count].theta) * (cmx/2); container.append('<div id="'+ id_stub + points.count +'" class="point" style="position:absolute;"><a>.</a></div>'); } } //tag size and font size ranges var sz_range = points.largest - points.smallest + 1; var sz_n_range = opts.max_font_size - opts.min_font_size + 1; //set font size to normalised tag size for(var p in points.data){ var sz = points.data[p].size; var sz_n = parseInt((sz / sz_range) * sz_n_range) + opts.min_font_size; if(!$('#' + points.data[p].id, container).hasClass('background')){ $('#' + points.data[p].id, container).css('font-size', sz_n); } //store element width / 2 so we can centre the text around the point later. points.data[p].cwidth = $('#' + points.data[p].id, container).width()/2; } // bin original html $('ul', container).remove(); //set up initial view zoomed(opts.zoom); moved(cmx, cmy); //call draw every so often drawing_interval = setInterval(draw, opts.drawing_interval); //events to change position of items container.mousemove(function(evt){ moved(evt.clientX, evt.clientY); }); container.mousewheel(function(evt, delta){ zoomed(delta); evt.preventDefault(); return false; }); }; })(jQuery);
JavaScript
AmCharts.themes.black = { themeName: "black", AmChart: { color: "#e7e7e7" }, AmCoordinateChart: { colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"] }, AmStockChart: { colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"] }, AmSlicedChart: { outlineAlpha: 1, outlineThickness: 2, labelTickColor: "#FFFFFF", labelTickAlpha: 0.3, colors: ["#de4c4f", "#d8854f", "#eea638", "#a7a737", "#86a965", "#8aabb0", "#69c8ff", "#cfd27e", "#9d9888", "#916b8a", "#724887", "#7256bc"] }, AmRectangularChart: { zoomOutButtonColor: '#FFFFFF', zoomOutButtonRollOverAlpha: 0.15, zoomOutButtonImage: "lensWhite.png" }, AxisBase: { axisColor: "#FFFFFF", axisAlpha: 0.3, gridAlpha: 0.1, gridColor: "#FFFFFF", dashLength: 3 }, ChartScrollbar: { backgroundColor: "#000000", backgroundAlpha: 0.2, graphFillAlpha: 0.2, graphLineAlpha: 0, graphFillColor: "#FFFFFF", selectedGraphFillColor: "#FFFFFF", selectedGraphFillAlpha: 0.4, selectedGraphLineColor: "#FFFFFF", selectedBackgroundColor: "#FFFFFF", selectedBackgroundAlpha: 0.09, gridAlpha: 0.15 }, ChartCursor: { cursorColor: "#FFFFFF", color: "#000000", cursorAlpha: 0.5 }, AmLegend: { color: "#e7e7e7" }, AmGraph: { lineAlpha: 0.9 }, GaugeArrow: { color: "#FFFFFF", alpha: 0.8, nailAlpha: 0, innerRadius: "40%", nailRadius: 15, startWidth: 15, borderAlpha: 0.8, nailBorderAlpha: 0 }, GaugeAxis: { tickColor: "#FFFFFF", tickAlpha: 1, tickLength: 15, minorTickLength: 8, axisThickness: 3, axisColor: '#FFFFFF', axisAlpha: 1, bandAlpha: 0.8 }, TrendLine: { lineColor: "#c03246", lineAlpha: 0.8 }, // ammap AreasSettings: { alpha: 0.8, color: "#FFFFFF", colorSolid: "#000000", unlistedAreasAlpha: 0.4, unlistedAreasColor: "#FFFFFF", outlineColor: "#000000", outlineAlpha: 0.5, outlineThickness: 0.5, rollOverColor: "#3c5bdc", rollOverOutlineColor: "#000000", selectedOutlineColor: "#000000", selectedColor: "#f15135", unlistedAreasOutlineColor: "#000000", unlistedAreasOutlineAlpha: 0.5 }, LinesSettings: { color: "#FFFFFF", alpha: 0.8 }, ImagesSettings: { alpha: 0.8, labelColor: "#FFFFFF", color: "#FFFFFF", labelRollOverColor: "#3c5bdc" }, ZoomControl: { buttonRollOverColor: "#3c5bdc", buttonFillColor: "#738f58", buttonBorderColor: "#738f58", buttonFillAlpha: 0.8, gridBackgroundColor: "#FFFFFF", buttonBorderAlpha:0, buttonCornerRadius:2, gridAlpha:0.5, gridBackgroundColor:"#FFFFFF", homeIconFile:"homeIconWhite.gif", buttonIconAlpha:0.6, gridAlpha: 0.2, buttonSize:20 }, SmallMap: { mapColor: "#FFFFFF", rectangleColor: "#FFFFFF", backgroundColor: "#000000", backgroundAlpha: 0.7, borderThickness: 1, borderAlpha: 0.8 }, // the defaults below are set using CSS syntax, you can use any existing css property // if you don't use Stock chart, you can delete lines below PeriodSelector: { color: "#e7e7e7" }, PeriodButton: { color: "#e7e7e7", background: "transparent", opacity: 0.7, border: "1px solid rgba(255, 255, 255, .15)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", boxSizing: "border-box" }, PeriodButtonSelected: { color: "#e7e7e7", backgroundColor: "rgba(255, 255, 255, 0.1)", border: "1px solid rgba(255, 255, 255, .3)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", opacity: 1, boxSizing: "border-box" }, PeriodInputField: { color: "#e7e7e7", background: "transparent", border: "1px solid rgba(255, 255, 255, .15)", outline: "none" }, DataSetSelector: { color: "#e7e7e7", selectedBackgroundColor: "rgba(255, 255, 255, .25)", rollOverBackgroundColor: "rgba(255, 255, 255, .15)" }, DataSetCompareList: { color: "#e7e7e7", lineHeight: "100%", boxSizing: "initial", webkitBoxSizing: "initial", border: "1px solid rgba(255, 255, 255, .15)" }, DataSetSelect: { border: "1px solid rgba(255, 255, 255, .15)", outline: "none" } };
JavaScript
AmCharts.themes.dark = { themeName: "dark", AmChart: { color: "#e7e7e7" }, AmCoordinateChart: { colors: ["#ae85c9", "#aab9f7", "#b6d2ff", "#c9e6f2", "#c9f0e1", "#e8d685", "#e0ad63", "#d48652", "#d27362", "#495fba", "#7a629b", "#8881cc"] }, AmStockChart: { colors: ["#639dbd", "#e8d685", "#ae85c9", "#c9f0e1", "#d48652", "#629b6d", "#719dc3", "#719dc3"] }, AmSlicedChart: { outlineAlpha: 1, outlineThickness: 2, labelTickColor: "#FFFFFF", labelTickAlpha: 0.3, colors: ["#495fba", "#e8d685", "#ae85c9", "#c9f0e1", "#d48652", "#629b6d", "#719dc3", "#719dc3"] }, AmRectangularChart: { zoomOutButtonColor: '#FFFFFF', zoomOutButtonRollOverAlpha: 0.15, zoomOutButtonImage: "lensWhite.png" }, AxisBase: { axisColor: "#FFFFFF", axisAlpha: 0.3, gridAlpha: 0.1, gridColor: "#FFFFFF", dashLength: 3 }, ChartScrollbar: { backgroundColor: "#000000", backgroundAlpha: 0.2, graphFillAlpha: 0.2, graphLineAlpha: 0, graphFillColor: "#FFFFFF", selectedGraphFillColor: "#FFFFFF", selectedGraphFillAlpha: 0.4, selectedGraphLineColor: "#FFFFFF", selectedBackgroundColor: "#FFFFFF", selectedBackgroundAlpha: 0.09, gridAlpha: 0.15 }, ChartCursor: { cursorColor: "#FFFFFF", color: "#000000", cursorAlpha: 0.5 }, AmLegend: { color: "#e7e7e7" }, AmGraph: { lineAlpha: 0.9 }, GaugeArrow: { color: "#FFFFFF", alpha: 0.8, nailAlpha: 0, innerRadius: "40%", nailRadius: 15, startWidth: 15, borderAlpha: 0.8, nailBorderAlpha: 0 }, GaugeAxis: { tickColor: "#FFFFFF", tickAlpha: 1, tickLength: 15, minorTickLength: 8, axisThickness: 3, axisColor: '#FFFFFF', axisAlpha: 1, bandAlpha: 0.8 }, TrendLine: { lineColor: "#c03246", lineAlpha: 0.8 }, // ammap AreasSettings: { alpha: 0.8, color: "#FFFFFF", colorSolid: "#000000", unlistedAreasAlpha: 0.4, unlistedAreasColor: "#FFFFFF", outlineColor: "#000000", outlineAlpha: 0.5, outlineThickness: 0.5, rollOverColor: "#3c5bdc", rollOverOutlineColor: "#000000", selectedOutlineColor: "#000000", selectedColor: "#f15135", unlistedAreasOutlineColor: "#000000", unlistedAreasOutlineAlpha: 0.5 }, LinesSettings: { color: "#FFFFFF", alpha: 0.8 }, ImagesSettings: { alpha: 0.8, labelColor: "#FFFFFF", color: "#FFFFFF", labelRollOverColor: "#3c5bdc" }, ZoomControl: { buttonRollOverColor: "#3c5bdc", buttonFillColor: "#f15135", buttonFillAlpha: 0.8, gridBackgroundColor: "#FFFFFF", buttonBorderAlpha:0, buttonCornerRadius:2, gridAlpha:0.5, gridBackgroundColor:"#FFFFFF", homeIconFile:"homeIconWhite.gif", buttonIconAlpha:0.6, gridAlpha: 0.2, buttonSize:20 }, SmallMap: { mapColor: "#FFFFFF", rectangleColor: "#FFFFFF", backgroundColor: "#000000", backgroundAlpha: 0.7, borderThickness: 1, borderAlpha: 0.8 }, // the defaults below are set using CSS syntax, you can use any existing css property // if you don't use Stock chart, you can delete lines below PeriodSelector: { color: "#e7e7e7" }, PeriodButton: { color: "#e7e7e7", background: "transparent", opacity: 0.7, border: "1px solid rgba(255, 255, 255, .15)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", boxSizing: "border-box" }, PeriodButtonSelected: { color: "#e7e7e7", backgroundColor: "rgba(255, 255, 255, 0.1)", border: "1px solid rgba(255, 255, 255, .3)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", opacity: 1, boxSizing: "border-box" }, PeriodInputField: { color: "#e7e7e7", background: "transparent", border: "1px solid rgba(255, 255, 255, .15)", outline: "none" }, DataSetSelector: { color: "#e7e7e7", selectedBackgroundColor: "rgba(255, 255, 255, .25)", rollOverBackgroundColor: "rgba(255, 255, 255, .15)" }, DataSetCompareList: { color: "#e7e7e7", lineHeight: "100%", boxSizing: "initial", webkitBoxSizing: "initial", border: "1px solid rgba(255, 255, 255, .15)" }, DataSetSelect: { border: "1px solid rgba(255, 255, 255, .15)", outline: "none" } };
JavaScript
AmCharts.themes.light = { themeName:"light", AmChart: { color: "#000000" }, AmCoordinateChart: { colors: ["#67b7dc", "#fdd400", "#84b761", "#cc4748", "#cd82ad", "#2f4074", "#448e4d", "#b7b83f", "#b9783f", "#b93e3d", "#913167"] }, AmStockChart: { colors: ["#67b7dc", "#fdd400", "#84b761", "#cc4748", "#cd82ad", "#2f4074", "#448e4d", "#b7b83f", "#b9783f", "#b93e3d", "#913167"] }, AmSlicedChart: { colors: ["#67b7dc", "#fdd400", "#84b761", "#cc4748", "#cd82ad", "#2f4074", "#448e4d", "#b7b83f", "#b9783f", "#b93e3d", "#913167"], outlineAlpha: 1, outlineThickness: 2, labelTickColor: "#000000", labelTickAlpha: 0.3 }, AmRectangularChart: { zoomOutButtonColor: '#000000', zoomOutButtonRollOverAlpha: 0.15, zoomOutButtonImage: "lens.png" }, AxisBase: { axisColor: "#000000", axisAlpha: 0.3, gridAlpha: 0.1, gridColor: "#000000" }, ChartScrollbar: { backgroundColor: "#000000", backgroundAlpha: 0.12, graphFillAlpha: 0.5, graphLineAlpha: 0, selectedBackgroundColor: "#FFFFFF", selectedBackgroundAlpha: 0.4, gridAlpha: 0.15 }, ChartCursor: { cursorColor: "#000000", color: "#FFFFFF", cursorAlpha: 0.5 }, AmLegend: { color: "#000000" }, AmGraph: { lineAlpha: 0.9 }, GaugeArrow: { color: "#000000", alpha: 0.8, nailAlpha: 0, innerRadius: "40%", nailRadius: 15, startWidth: 15, borderAlpha: 0.8, nailBorderAlpha: 0 }, GaugeAxis: { tickColor: "#000000", tickAlpha: 1, tickLength: 15, minorTickLength: 8, axisThickness: 3, axisColor: '#000000', axisAlpha: 1, bandAlpha: 0.8 }, TrendLine: { lineColor: "#c03246", lineAlpha: 0.8 }, // ammap AreasSettings: { alpha: 0.8, color: "#67b7dc", colorSolid: "#003767", unlistedAreasAlpha: 0.4, unlistedAreasColor: "#000000", outlineColor: "#FFFFFF", outlineAlpha: 0.5, outlineThickness: 0.5, rollOverColor: "#3c5bdc", rollOverOutlineColor: "#FFFFFF", selectedOutlineColor: "#FFFFFF", selectedColor: "#f15135", unlistedAreasOutlineColor: "#FFFFFF", unlistedAreasOutlineAlpha: 0.5 }, LinesSettings: { color: "#000000", alpha: 0.8 }, ImagesSettings: { alpha: 0.8, labelColor: "#000000", color: "#000000", labelRollOverColor: "#3c5bdc" }, ZoomControl: { buttonRollOverColor: "#3c5bdc", buttonFillColor: "#3994e2", buttonBorderColor: "#3994e2", buttonFillAlpha: 0.8, gridBackgroundColor: "#FFFFFF", buttonBorderAlpha:0, buttonCornerRadius:2, gridColor:"#FFFFFF", gridBackgroundColor:"#000000", buttonIconAlpha:0.6, gridAlpha: 0.6, buttonSize:20 }, SmallMap: { mapColor: "#000000", rectangleColor: "#f15135", backgroundColor: "#FFFFFF", backgroundAlpha: 0.7, borderThickness: 1, borderAlpha: 0.8 }, // the defaults below are set using CSS syntax, you can use any existing css property // if you don't use Stock chart, you can delete lines below PeriodSelector: { color: "#000000" }, PeriodButton: { color: "#000000", background: "transparent", opacity: 0.7, border: "1px solid rgba(0, 0, 0, .3)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", boxSizing: "border-box" }, PeriodButtonSelected: { color: "#000000", backgroundColor: "#b9cdf5", border: "1px solid rgba(0, 0, 0, .3)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", opacity: 1, boxSizing: "border-box" }, PeriodInputField: { color: "#000000", background: "transparent", border: "1px solid rgba(0, 0, 0, .3)", outline: "none" }, DataSetSelector: { color: "#000000", selectedBackgroundColor: "#b9cdf5", rollOverBackgroundColor: "#a8b0e4" }, DataSetCompareList: { color: "#000000", lineHeight: "100%", boxSizing: "initial", webkitBoxSizing: "initial", border: "1px solid rgba(0, 0, 0, .3)" }, DataSetSelect: { border: "1px solid rgba(0, 0, 0, .3)", outline: "none" } };
JavaScript
AmCharts.themes.chalk = { themeName: "chalk", AmChart: { color: "#e7e7e7", fontFamily: "Covered By Your Grace", fontSize: 18, handDrawn: true }, AmCoordinateChart: { colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"] }, AmSlicedChart: { outlineAlpha: 1, labelTickColor: "#FFFFFF", labelTickAlpha: 0.3, colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"] }, AmStockChart: { colors: ["#FFFFFF", "#e384a6", "#f4d499", "#4d90d6", "#c7e38c", "#9986c8", "#edf28c", "#ffd1d4", "#5ee1dc", "#b0eead", "#fef85a", "#8badd2"] }, AmRectangularChart: { zoomOutButtonColor: '#FFFFFF', zoomOutButtonRollOverAlpha: 0.15, zoomOutButtonImage: "lensWhite.png" }, AxisBase: { axisColor: "#FFFFFF", gridColor: "#FFFFFF" }, ChartScrollbar: { backgroundColor: "#FFFFFF", backgroundAlpha: 0.2, graphFillAlpha: 0.5, graphLineAlpha: 0, selectedBackgroundColor: "#000000", selectedBackgroundAlpha: 0.25, fontSize: 15, gridAlpha: 0.15 }, ChartCursor: { cursorColor: "#FFFFFF", color: "#000000" }, AmLegend: { color: "#e7e7e7", markerSize: 20 }, AmGraph: { lineAlpha: 0.8 }, GaugeArrow: { color: "#FFFFFF", alpha: 0.1, nailAlpha: 0, innerRadius: "40%", nailRadius: 15, startWidth: 15, borderAlpha: 0.8, nailBorderAlpha: 0 }, GaugeAxis: { tickColor: "#FFFFFF", tickAlpha: 0.8, tickLength: 15, minorTickLength: 8, axisThickness: 3, axisColor: '#FFFFFF', axisAlpha: 0.8, bandAlpha: 0.4 }, TrendLine: { lineColor: "#c03246", lineAlpha: 0.8 }, // ammap AmMap: { handDrawn: false }, AreasSettings: { alpha: 0.8, color: "#FFFFFF", colorSolid: "#000000", unlistedAreasAlpha: 0.4, unlistedAreasColor: "#FFFFFF", outlineColor: "#000000", outlineAlpha: 0.5, outlineThickness: 0.5, rollOverColor: "#4d90d6", rollOverOutlineColor: "#000000", selectedOutlineColor: "#000000", selectedColor: "#e384a6", unlistedAreasOutlineColor: "#000000", unlistedAreasOutlineAlpha: 0.5 }, LinesSettings: { color: "#FFFFFF", alpha: 0.8 }, ImagesSettings: { alpha: 0.8, labelFontSize: 16, labelColor: "#FFFFFF", color: "#FFFFFF", labelRollOverColor: "#4d90d6" }, ZoomControl: { buttonRollOverColor: "#4d90d6", buttonFillColor: "#e384a6", buttonFillAlpha: 0.8, buttonBorderColor: "#FFFFFF", gridBackgroundColor: "#FFFFFF", gridAlpha: 0.8 }, SmallMap: { mapColor: "#FFFFFF", rectangleColor: "#FFFFFF", backgroundColor: "#000000", backgroundAlpha: 0.7, borderThickness: 1, borderAlpha: 0.8 }, // the defaults below are set using CSS syntax, you can use any existing css property // if you don't use Stock chart, you can delete lines below PeriodSelector: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7" }, PeriodButton: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7", background: "transparent", opacity: 0.7, border: "1px solid rgba(255, 255, 255, .15)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", boxSizing: "border-box" }, PeriodButtonSelected: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7", backgroundColor: "rgba(255, 255, 255, 0.1)", border: "1px solid rgba(255, 255, 255, .3)", MozBorderRadius: "5px", borderRadius: "5px", margin: "1px", outline: "none", opacity: 1, boxSizing: "border-box" }, PeriodInputField: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7", background: "transparent", border: "1px solid rgba(255, 255, 255, .15)", outline: "none" }, DataSetSelector: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7", selectedBackgroundColor: "rgba(255, 255, 255, .25)", rollOverBackgroundColor: "rgba(255, 255, 255, .15)" }, DataSetCompareList: { fontFamily: "Covered By Your Grace", fontSize:"16px", color: "#e7e7e7", lineHeight: "100%", boxSizing: "initial", webkitBoxSizing: "initial", border: "1px solid rgba(255, 255, 255, .15)" }, DataSetSelect: { fontFamily: "Covered By Your Grace", fontSize:"16px", border: "1px solid rgba(255, 255, 255, .15)", outline: "none" } };
JavaScript
// (c) ammap.com | SVG (in JSON format) map of Belgium // areas: {id:"BE-VAN"},{id:"BE-BWR"},{id:"BE-BRU"},{id:"BE-WHT"},{id:"BE-WLG"},{id:"BE-VLI"},{id:"BEW-LX"},{id:"BE-WNA"},{id:"BE-VOV"},{id:"BE-VBR"},{id:"BE-VWV"} AmCharts.maps.belgiumLow={ "svg": { "defs": { "amcharts:ammap": { "projection":"mercator", "leftLongitude":"2.543698", "topLatitude":"51.499939", "rightLongitude":"6.408540", "bottomLatitude":"49.497691" } }, "g":{ "path":[ { "id":"BE-VAN", "title":"Antwerp", "d":"M435.75,1.31l11.07,5.98l1.3,18.09l-14.38,2.36l22.27,-0.87l6.24,7.37l21.16,-28.48l9.67,4.64l5.1,12.2l-6.34,11.98l12.24,24.36l20.56,3.44l-0.62,13.46l0,0l-4.49,12.64l9.3,21.54l-48.55,23.15l-6.09,12.47l0,0l-31.92,7.25l-5.06,-8.57l-18.38,12.34l-2.57,-8.05l-19.61,10.45l-36.53,-1.36l-2.88,-10.76l-27.31,-2.13l0,0l-9.63,-1.02l-3.05,-18.77l27.04,-7.7l3.35,-9.06l-8.19,-30.53l6.24,-9.27l-16.4,-21.42l0,0l-4.08,-6.56l41.88,3.11L356.72,18l18.44,-9.75l12.66,-1.28l-0.49,18.24l20.25,0.12L435.75,1.31z" }, { "id":"BE-WBR", "title":"Walloon Brabant", "d":"M302.66,246.58L313.34,239.28L331.33,251.94L348.45,238L355.88,243.42L379.34,231.41L385.53,239.93L399.24,228.83L406.81,235.36L408.44,218.03L431.34,215.73L463.43,235.21L474.48,226.96L481.78,233.03L481.78,233.03L474.66,266.23L474.66,266.23L437.15,282.31L412.45,277.36L413.42,289.64L400.16,288.76L395.72,297.19L395.72,297.19L374.09,301.21L374.69,291.9L363.45,289.92L347.91,296.39L318.55,260.26L303.87,269.26z" }, { "id":"BE-BRU", "title":"Brussels Capital Region", "d":"M366.21,187.61L366.99,188.19L366.99,188.19L378.5,220.21L358,228.61L330.96,212.1L341.25,192.28L356.93,187.64L356.93,187.64L356.93,187.64L356.93,187.64L365.59,186.22L365.59,186.22z" }, { "id":"BE-WHT", "title":"Hainaut", "d":"M178.07,227.85l33.19,14.35l9.22,-15.76l15.85,-2.7l3.21,10.27l23.56,4.72l0,0l3.11,12.74l36.45,-4.9l0,0l1.21,22.68l14.69,-8.99l29.35,36.13l15.54,-6.47l11.24,1.99l-0.6,9.31l21.63,-4.03l0,0l-1.36,30.58l8.91,5.12l-4.55,29.48l-37.02,4.68l-22.45,16.94l21.96,7.04l-7.37,19.33l13.67,68.37l0,0l-56.49,-11.19l3.52,-20.77l13.64,-6.38l-5.88,-19.26l-13.97,-0.21l15.56,-42.01l-8.99,-5.19l-4.8,9.47l-22,-30.68l-23.85,9.73l-30.07,-7.36l-7.7,14.01l-9.69,-19.6l0.31,-26.39l-10.13,-12.01l-21.01,2.68l3.54,-11.07l-8.58,-2.93l-19.2,12.81l-16.44,-10.13l-10.15,-40.79l4.16,-13.35l-16.17,-16.73l0,0l25,0.18l10.5,14.04L178.07,227.85zM61.92,246.39l-4.07,-13.33l23.17,-7.24l-4.61,-6.08l12.39,-5.19l3.62,11.51l0,0l-15.46,8.86l-5.82,15.75L61.92,246.39z" }, { "id":"BE-WLG", "title":"Liege", "d":"M612.63,214.16L610.61,230.61L610.61,230.61L649.55,245.57L651.44,231.37L651.44,231.37L676.4,231.47L680.21,242.69L695.23,241.61L706.98,271L724.8,270.97L707.19,296.7L716.45,310.98L740.65,312.99L745.63,329.08L738.78,346.22L751.62,359.84L742.63,369.32L732.13,364.79L726.84,380.46L706.71,390.08L709.53,405.99L700.83,408.2L699.57,422.04L694.51,411.02L684.3,414.98L677.22,405.84L677.22,405.84L668.4,361.27L645.7,356.07L642.32,376.24L649.3,376.7L635,384.31L618.72,382.16L618.31,353.03L582.29,342.53L577.5,332.64L568.96,338L559.72,331.24L554.49,346.67L554.49,346.67L535.82,350.99L523.66,339.28L516.4,316.16L509.59,319.33L505.33,305.91L484.73,299.66L474.66,266.23L474.66,266.23L481.78,233.03L481.78,233.03L497.46,245.66L497.46,245.66L510.08,249.73L511.87,241L537.14,243.36L553.19,233.74L559.18,242.62L570.62,241.15L611.54,214.13L611.54,214.13z" }, { "id":"BE-VLI", "title":"Limburg", "d":"M630.3,227.39l21.14,3.99l0,0l-1.89,14.19l-38.94,-14.96l0,0L630.3,227.39zM581.9,70.45l5.1,17.2l56.92,24.11l-26.01,56.17l7.12,3.79l-21.88,24.15l8.4,18.25l0,0l-40.93,27.02l-11.44,1.47l-5.99,-8.89l-16.05,9.62L511.87,241l-1.79,8.73l-12.63,-4.07l0,0l16.55,-59.62l-18.38,-1.66l-9.43,-10.31l14.34,-24.04l8.05,-1.11l-7.84,-7.9l-11.65,10.83l-14.9,-6.2l0,0l6.09,-12.47l48.55,-23.15l-9.3,-21.54l4.49,-12.64l0,0l34.94,-0.56l13.34,-11.82L581.9,70.45z" }, { "id":"BE-WLX", "title":"Luxembourg", "d":"M554.49,346.67L559.72,331.24L568.96,338L577.5,332.64L582.29,342.53L618.31,353.03L618.72,382.16L635,384.31L649.3,376.7L642.32,376.24L645.7,356.07L668.4,361.27L677.22,405.84L677.22,405.84L652.43,427.39L637.26,457.43L640.65,467.02L628.76,473.09L620.9,491.68L630.38,497.82L621.89,510.7L624.58,524.29L631.17,523L638.51,544.86L649.96,548.91L645.96,558.65L654.79,562.46L641.29,595.59L604.11,596.01L596.64,609.19L585.98,602.41L569.66,612L561.26,582.67L545.6,572.22L538.79,578.12L542.2,565.3L531.4,553.76L510.04,553.52L496,532.67L471.58,521.01L471.58,521.01L475.61,505.53L501.07,484.63L472.54,452.72L485.96,445.32L490.61,424.37L492.61,433.38L530.23,427.24L525.02,421.1L532.53,413.32L518.21,396.14L554.55,374.3L553.48,365.88L544.53,366.28L554.59,359.81z" }, { "id":"BE-WNA", "title":"Namur", "d":"M395.72,297.19L400.16,288.76L413.42,289.64L412.45,277.36L437.15,282.31L474.66,266.23L474.66,266.23L484.73,299.66L505.33,305.91L509.59,319.33L516.4,316.16L523.66,339.28L535.82,350.99L554.49,346.67L554.49,346.67L554.59,359.81L544.53,366.28L553.48,365.88L554.55,374.3L518.21,396.14L532.53,413.32L525.02,421.1L530.23,427.24L492.61,433.38L490.61,424.37L485.96,445.32L472.54,452.72L501.07,484.63L475.61,505.53L471.58,521.01L471.58,521.01L448.75,523.54L447.89,501.4L455.89,488.52L436.69,470.67L446.72,449.76L442.62,441.63L457.44,419.95L443.92,410.35L418.03,435.56L417.86,462.5L367.51,478.72L367.51,478.72L353.84,410.35L361.21,391.02L339.25,383.98L361.7,367.04L398.72,362.36L403.27,332.88L394.36,327.77z" }, { "id":"BE-VOV", "title":"East Flanders", "d":"M329.29,47.05L345.69,68.47L339.44,77.74L347.63,108.27L344.29,117.33L317.25,125.03L320.3,143.8L329.93,144.82L329.93,144.82L328.51,155.8L311.39,166.06L314.97,177.15L301.77,177.02L291.34,205.99L295.42,221.01L273.44,225.27L273.99,238.73L263.09,238.73L263.09,238.73L239.54,234.01L236.33,223.74L220.47,226.44L211.25,242.2L178.07,227.85L178.07,227.85L190.13,216.09L176.73,197.02L181.78,187.82L169.64,185.61L178.32,173.76L169.26,169.48L175.56,141.61L153.21,125.68L168.63,106.66L158.77,96.98L162.91,71.35L162.91,71.35L172.06,80.62L191.26,80.25L189,67.48L203.73,61.61L240,74.86L242.65,89.89L261.36,87.22L261.27,94.25L295.13,80.72z" }, { "id":"BE-VBR", "title":"Flemish Brabant", "d":"M474.19,145.65l14.9,6.2l11.65,-10.83l7.84,7.9l-8.05,1.11l-14.34,24.04l9.43,10.31l18.38,1.66l-16.55,59.62l0,0l-15.68,-12.63l0,0l-7.29,-6.07l-11.05,8.25l-32.1,-19.48l-22.9,2.3l-1.63,17.33l-7.57,-6.53l-13.71,11.1l-6.19,-8.52l-23.46,12.02l-7.43,-5.42l-17.12,13.94l-17.99,-12.65l-10.68,7.29l0,0l-36.45,4.9l-3.11,-12.74l0,0h10.89l-0.54,-13.46l21.98,-4.26l-4.08,-15.01l10.43,-28.97l13.21,0.12l-3.58,-11.09l17.12,-10.26l1.42,-10.98l0,0l27.31,2.13l2.88,10.76l36.53,1.36l19.61,-10.45l2.57,8.05l18.38,-12.34l5.06,8.57L474.19,145.65zM365.59,186.22L365.59,186.22l-20.99,2.95l-13.52,23.29L358,228.61l20.5,-8.41l-11.52,-32.01L365.59,186.22z" }, { "id":"BE-VWV", "title":"West Flanders", "d":"M160.4,42.39L162.91,71.35L162.91,71.35L158.77,96.98L168.63,106.66L153.21,125.68L175.56,141.61L169.26,169.48L178.32,173.76L169.64,185.61L181.78,187.82L176.73,197.02L190.13,216.09L178.07,227.85L178.07,227.85L158.63,245.6L148.13,231.56L123.13,231.37L123.13,231.37L117.84,220.98L92.42,226.07L92.42,226.07L88.8,214.56L76.41,219.75L81.02,225.82L57.85,233.06L61.92,246.39L61.92,246.39L47.74,240.45L34.84,214.74L17.8,214.1L10.85,202.67L9.05,181.12L17.14,172.59L0,128.86L124.26,53.82L124.77,43.66L127.12,54.29L127.18,43.41L132.98,50.62z" } ] } } };
JavaScript
AmCharts.mapTranslations.si = {"Sri Lanka":"ශ්‍රී ලංකාව"}
JavaScript
AmCharts.mapTranslations.ku = {"Africa":"Cîhan","Turkey":"Tirkiye"}
JavaScript
AmCharts.mapTranslations.kok = {"India":"भारत"}
JavaScript
AmCharts.mapTranslations.kl = {"Greenland":"Kalaallit Nunaat"}
JavaScript
AmCharts.mapTranslations.ha = {"Ghana":"Gaana","Niger":"Nijer","Nigeria":"Nijeriya"}
JavaScript
AmCharts.mapTranslations.dv = {"Maldives":"ދިވެހި ރާއްޖެ"}
JavaScript
AmCharts.mapTranslations.tg = {"Afghanistan":"Афғонистан","Tonga":"Тонга"}
JavaScript
AmCharts.mapTranslations.syr = {"Syria":"ܣܘܪܝܝܐ"}
JavaScript
AmCharts.mapTranslations.rw = {"Tonga":"Igitonga"}
JavaScript
AmCharts.mapTranslations.kk = {"Kazakhstan":"Қазақстан","Tonga":"Тонга"}
JavaScript
AmCharts.mapTranslations.tt = {"Russia":"Россия"}
JavaScript