This commit is contained in:
2025-02-26 14:49:25 +07:00
commit 1c1d9c4474
6403 changed files with 1953774 additions and 0 deletions

View File

@@ -0,0 +1,148 @@
/**
* BinFileReader.js
* You can find more about this function at
* http://nagoon97.com/reading-binary-files-using-ajax/
*
* Copyright (c) 2008 Andy G.P. Na <nagoon97@naver.com>
* The source code is freely distributable under the terms of an MIT-style license.
*/
function BinFileReader(fileURL){
var _exception = {};
_exception.FileLoadFailed = 1;
_exception.EOFReached = 2;
var filePointer = 0;
var fileSize = -1;
var fileContents;
this.getFileSize = function(){
return fileSize;
}
this.getFilePointer = function(){
return filePointer;
}
this.readBytes=function()
{
return fileContents;
}
this.movePointerTo = function(iTo){
if(iTo < 0) filePointer = 0;
else if(iTo > this.getFileSize()) throwException(_exception.EOFReached);
else filePointer = iTo;
return filePointer;
};
this.movePointer = function(iDirection){
this.movePointerTo(filePointer + iDirection);
return filePointer;
};
this.readNumber = function(iNumBytes, iFrom){
iNumBytes = iNumBytes || 1;
iFrom = iFrom || filePointer;
this.movePointerTo(iFrom + iNumBytes);
var result = 0;
for(var i=iFrom + iNumBytes; i>iFrom; i--){
result = result * 256 + this.readByteAt(i-1);
}
return result;
};
this.readString = function(iNumChars, iFrom){
iNumChars = iNumChars || 1;
iFrom = iFrom || filePointer;
this.movePointerTo(iFrom);
var result = "";
var tmpTo = iFrom + iNumChars;
for(var i=iFrom; i<tmpTo; i++){
result += String.fromCharCode(this.readNumber(1));
}
return result;
};
this.getBytes = function(iFrom) {
this.movePointerTo(iFrom);
var tmpTo = fileContents.length;
var result = new Uint8Array(tmpTo-iFrom);
var index = 0;
for(var i=iFrom;i<tmpTo;i++) {
result[index] = this.readByteAt(i);
index++;
}
return result;
};
this.readUnicodeString = function(iNumChars, iFrom){
iNumChars = iNumChars || 1;
iFrom = iFrom || filePointer;
this.movePointerTo(iFrom);
var result = "";
var tmpTo = iFrom + iNumChars*2;
for(var i=iFrom; i<tmpTo; i+=2){
result += String.fromCharCode(this.readNumber(2));
}
return result;
};
function throwException(errorCode){
switch(errorCode){
case _exception.FileLoadFailed:
throw new Error('Error: Filed to load "'+fileURL+'"');
break;
case _exception.EOFReached:
throw new Error("Error: EOF reached");
break;
}
}
function BinFileReaderImpl_IE(fileURL){
var vbArr = BinFileReaderImpl_IE_VBAjaxLoader(fileURL);
fileContents = vbArr.toArray();
fileSize = fileContents.length-1;
if(fileSize < 0) throwException(_exception.FileLoadFailed);
this.readByteAt = function(i){
return fileContents[i];
}
}
function BinFileReaderImpl(fileURL){
var req = new XMLHttpRequest();
req.open('GET', fileURL, false);
//XHR binary charset opt by Marcus Granado 2006 [http://mgran.blogspot.com]
req.overrideMimeType('text/plain; charset=x-user-defined');
req.send(null);
if (req.status != 200) throwException(_exception.FileLoadFailed);
{
fileContents = req.responseText;
}
fileSize = fileContents.length;
this.readByteAt = function(i){
return fileContents.charCodeAt(i) & 0xff;
}
}
if(/msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent))
BinFileReaderImpl_IE.apply(this, [fileURL]);
else
BinFileReaderImpl.apply(this, [fileURL]);
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,104 @@
/**
* Version: 1.0 Alpha-1
* Build Date: 13-Nov-2007
* Copyright (c) 2006-2007, Coolite Inc. (http://www.coolite.com/). All rights reserved.
* License: Licensed under The MIT License. See license.txt and http://www.datejs.com/license/.
* Website: http://www.datejs.com/ or http://www.coolite.com/datejs/
*/
Date.CultureInfo={name:"en-US",englishName:"English (United States)",nativeName:"English (United States)",dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],abbreviatedDayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],shortestDayNames:["Su","Mo","Tu","We","Th","Fr","Sa"],firstLetterDayNames:["S","M","T","W","T","F","S"],monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],abbreviatedMonthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],amDesignator:"AM",pmDesignator:"PM",firstDayOfWeek:0,twoDigitYearMax:2029,dateElementOrder:"mdy",formatPatterns:{shortDate:"M/d/yyyy",longDate:"dddd, MMMM dd, yyyy",shortTime:"h:mm tt",longTime:"h:mm:ss tt",fullDateTime:"dddd, MMMM dd, yyyy h:mm:ss tt",sortableDateTime:"yyyy-MM-ddTHH:mm:ss",universalSortableDateTime:"yyyy-MM-dd HH:mm:ssZ",rfc1123:"ddd, dd MMM yyyy HH:mm:ss GMT",monthDay:"MMMM dd",yearMonth:"MMMM, yyyy"},regexPatterns:{jan:/^jan(uary)?/i,feb:/^feb(ruary)?/i,mar:/^mar(ch)?/i,apr:/^apr(il)?/i,may:/^may/i,jun:/^jun(e)?/i,jul:/^jul(y)?/i,aug:/^aug(ust)?/i,sep:/^sep(t(ember)?)?/i,oct:/^oct(ober)?/i,nov:/^nov(ember)?/i,dec:/^dec(ember)?/i,sun:/^su(n(day)?)?/i,mon:/^mo(n(day)?)?/i,tue:/^tu(e(s(day)?)?)?/i,wed:/^we(d(nesday)?)?/i,thu:/^th(u(r(s(day)?)?)?)?/i,fri:/^fr(i(day)?)?/i,sat:/^sa(t(urday)?)?/i,future:/^next/i,past:/^last|past|prev(ious)?/i,add:/^(\+|after|from)/i,subtract:/^(\-|before|ago)/i,yesterday:/^yesterday/i,today:/^t(oday)?/i,tomorrow:/^tomorrow/i,now:/^n(ow)?/i,millisecond:/^ms|milli(second)?s?/i,second:/^sec(ond)?s?/i,minute:/^min(ute)?s?/i,hour:/^h(ou)?rs?/i,week:/^w(ee)?k/i,month:/^m(o(nth)?s?)?/i,day:/^d(ays?)?/i,year:/^y((ea)?rs?)?/i,shortMeridian:/^(a|p)/i,longMeridian:/^(a\.?m?\.?|p\.?m?\.?)/i,timezone:/^((e(s|d)t|c(s|d)t|m(s|d)t|p(s|d)t)|((gmt)?\s*(\+|\-)\s*\d\d\d\d?)|gmt)/i,ordinalSuffix:/^\s*(st|nd|rd|th)/i,timeContext:/^\s*(\:|a|p)/i},abbreviatedTimeZoneStandard:{GMT:"-000",EST:"-0400",CST:"-0500",MST:"-0600",PST:"-0700"},abbreviatedTimeZoneDST:{GMT:"-000",EDT:"-0500",CDT:"-0600",MDT:"-0700",PDT:"-0800"}};
Date.getMonthNumberFromName=function(name){var n=Date.CultureInfo.monthNames,m=Date.CultureInfo.abbreviatedMonthNames,s=name.toLowerCase();for(var i=0;i<n.length;i++){if(n[i].toLowerCase()==s||m[i].toLowerCase()==s){return i;}}
return-1;};Date.getDayNumberFromName=function(name){var n=Date.CultureInfo.dayNames,m=Date.CultureInfo.abbreviatedDayNames,o=Date.CultureInfo.shortestDayNames,s=name.toLowerCase();for(var i=0;i<n.length;i++){if(n[i].toLowerCase()==s||m[i].toLowerCase()==s){return i;}}
return-1;};Date.isLeapYear=function(year){return(((year%4===0)&&(year%100!==0))||(year%400===0));};Date.getDaysInMonth=function(year,month){return[31,(Date.isLeapYear(year)?29:28),31,30,31,30,31,31,30,31,30,31][month];};Date.getTimezoneOffset=function(s,dst){return(dst||false)?Date.CultureInfo.abbreviatedTimeZoneDST[s.toUpperCase()]:Date.CultureInfo.abbreviatedTimeZoneStandard[s.toUpperCase()];};Date.getTimezoneAbbreviation=function(offset,dst){var n=(dst||false)?Date.CultureInfo.abbreviatedTimeZoneDST:Date.CultureInfo.abbreviatedTimeZoneStandard,p;for(p in n){if(n[p]===offset){return p;}}
return null;};Date.prototype.clone=function(){return new Date(this.getTime());};Date.prototype.compareTo=function(date){if(isNaN(this)){throw new Error(this);}
if(date instanceof Date&&!isNaN(date)){return(this>date)?1:(this<date)?-1:0;}else{throw new TypeError(date);}};Date.prototype.equals=function(date){return(this.compareTo(date)===0);};Date.prototype.between=function(start,end){var t=this.getTime();return t>=start.getTime()&&t<=end.getTime();};Date.prototype.addMilliseconds=function(value){this.setMilliseconds(this.getMilliseconds()+value);return this;};Date.prototype.addSeconds=function(value){return this.addMilliseconds(value*1000);};Date.prototype.addMinutes=function(value){return this.addMilliseconds(value*60000);};Date.prototype.addHours=function(value){return this.addMilliseconds(value*3600000);};Date.prototype.addDays=function(value){return this.addMilliseconds(value*86400000);};Date.prototype.addWeeks=function(value){return this.addMilliseconds(value*604800000);};Date.prototype.addMonths=function(value){var n=this.getDate();this.setDate(1);this.setMonth(this.getMonth()+value);this.setDate(Math.min(n,this.getDaysInMonth()));return this;};Date.prototype.addYears=function(value){return this.addMonths(value*12);};Date.prototype.add=function(config){if(typeof config=="number"){this._orient=config;return this;}
var x=config;if(x.millisecond||x.milliseconds){this.addMilliseconds(x.millisecond||x.milliseconds);}
if(x.second||x.seconds){this.addSeconds(x.second||x.seconds);}
if(x.minute||x.minutes){this.addMinutes(x.minute||x.minutes);}
if(x.hour||x.hours){this.addHours(x.hour||x.hours);}
if(x.month||x.months){this.addMonths(x.month||x.months);}
if(x.year||x.years){this.addYears(x.year||x.years);}
if(x.day||x.days){this.addDays(x.day||x.days);}
return this;};Date._validate=function(value,min,max,name){if(typeof value!="number"){throw new TypeError(value+" is not a Number.");}else if(value<min||value>max){throw new RangeError(value+" is not a valid value for "+name+".");}
return true;};Date.validateMillisecond=function(n){return Date._validate(n,0,999,"milliseconds");};Date.validateSecond=function(n){return Date._validate(n,0,59,"seconds");};Date.validateMinute=function(n){return Date._validate(n,0,59,"minutes");};Date.validateHour=function(n){return Date._validate(n,0,23,"hours");};Date.validateDay=function(n,year,month){return Date._validate(n,1,Date.getDaysInMonth(year,month),"days");};Date.validateMonth=function(n){return Date._validate(n,0,11,"months");};Date.validateYear=function(n){return Date._validate(n,1,9999,"seconds");};Date.prototype.set=function(config){var x=config;if(!x.millisecond&&x.millisecond!==0){x.millisecond=-1;}
if(!x.second&&x.second!==0){x.second=-1;}
if(!x.minute&&x.minute!==0){x.minute=-1;}
if(!x.hour&&x.hour!==0){x.hour=-1;}
if(!x.day&&x.day!==0){x.day=-1;}
if(!x.month&&x.month!==0){x.month=-1;}
if(!x.year&&x.year!==0){x.year=-1;}
if(x.millisecond!=-1&&Date.validateMillisecond(x.millisecond)){this.addMilliseconds(x.millisecond-this.getMilliseconds());}
if(x.second!=-1&&Date.validateSecond(x.second)){this.addSeconds(x.second-this.getSeconds());}
if(x.minute!=-1&&Date.validateMinute(x.minute)){this.addMinutes(x.minute-this.getMinutes());}
if(x.hour!=-1&&Date.validateHour(x.hour)){this.addHours(x.hour-this.getHours());}
if(x.month!==-1&&Date.validateMonth(x.month)){this.addMonths(x.month-this.getMonth());}
if(x.year!=-1&&Date.validateYear(x.year)){this.addYears(x.year-this.getFullYear());}
if(x.day!=-1&&Date.validateDay(x.day,this.getFullYear(),this.getMonth())){this.addDays(x.day-this.getDate());}
if(x.timezone){this.setTimezone(x.timezone);}
if(x.timezoneOffset){this.setTimezoneOffset(x.timezoneOffset);}
return this;};Date.prototype.clearTime=function(){this.setHours(0);this.setMinutes(0);this.setSeconds(0);this.setMilliseconds(0);return this;};Date.prototype.isLeapYear=function(){var y=this.getFullYear();return(((y%4===0)&&(y%100!==0))||(y%400===0));};Date.prototype.isWeekday=function(){return!(this.is().sat()||this.is().sun());};Date.prototype.getDaysInMonth=function(){return Date.getDaysInMonth(this.getFullYear(),this.getMonth());};Date.prototype.moveToFirstDayOfMonth=function(){return this.set({day:1});};Date.prototype.moveToLastDayOfMonth=function(){return this.set({day:this.getDaysInMonth()});};Date.prototype.moveToDayOfWeek=function(day,orient){var diff=(day-this.getDay()+7*(orient||+1))%7;return this.addDays((diff===0)?diff+=7*(orient||+1):diff);};Date.prototype.moveToMonth=function(month,orient){var diff=(month-this.getMonth()+12*(orient||+1))%12;return this.addMonths((diff===0)?diff+=12*(orient||+1):diff);};Date.prototype.getDayOfYear=function(){return Math.floor((this-new Date(this.getFullYear(),0,1))/86400000);};Date.prototype.getWeekOfYear=function(firstDayOfWeek){var y=this.getFullYear(),m=this.getMonth(),d=this.getDate();var dow=firstDayOfWeek||Date.CultureInfo.firstDayOfWeek;var offset=7+1-new Date(y,0,1).getDay();if(offset==8){offset=1;}
var daynum=((Date.UTC(y,m,d,0,0,0)-Date.UTC(y,0,1,0,0,0))/86400000)+1;var w=Math.floor((daynum-offset+7)/7);if(w===dow){y--;var prevOffset=7+1-new Date(y,0,1).getDay();if(prevOffset==2||prevOffset==8){w=53;}else{w=52;}}
return w;};Date.prototype.isDST=function(){console.log('isDST');return this.toString().match(/(E|C|M|P)(S|D)T/)[2]=="D";};Date.prototype.getTimezone=function(){return Date.getTimezoneAbbreviation(this.getUTCOffset,this.isDST());};Date.prototype.setTimezoneOffset=function(s){var here=this.getTimezoneOffset(),there=Number(s)*-6/10;this.addMinutes(there-here);return this;};Date.prototype.setTimezone=function(s){return this.setTimezoneOffset(Date.getTimezoneOffset(s));};Date.prototype.getUTCOffset=function(){var n=this.getTimezoneOffset()*-10/6,r;if(n<0){r=(n-10000).toString();return r[0]+r.substr(2);}else{r=(n+10000).toString();return"+"+r.substr(1);}};Date.prototype.getDayName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedDayNames[this.getDay()]:Date.CultureInfo.dayNames[this.getDay()];};Date.prototype.getMonthName=function(abbrev){return abbrev?Date.CultureInfo.abbreviatedMonthNames[this.getMonth()]:Date.CultureInfo.monthNames[this.getMonth()];};Date.prototype._toString=Date.prototype.toString;Date.prototype.toString=function(format){var self=this;var p=function p(s){return(s.toString().length==1)?"0"+s:s;};return format?format.replace(/dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?/g,function(format){switch(format){case"hh":return p(self.getHours()<13?self.getHours():(self.getHours()-12));case"h":return self.getHours()<13?self.getHours():(self.getHours()-12);case"HH":return p(self.getHours());case"H":return self.getHours();case"mm":return p(self.getMinutes());case"m":return self.getMinutes();case"ss":return p(self.getSeconds());case"s":return self.getSeconds();case"yyyy":return self.getFullYear();case"yy":return self.getFullYear().toString().substring(2,4);case"dddd":return self.getDayName();case"ddd":return self.getDayName(true);case"dd":return p(self.getDate());case"d":return self.getDate().toString();case"MMMM":return self.getMonthName();case"MMM":return self.getMonthName(true);case"MM":return p((self.getMonth()+1));case"M":return self.getMonth()+1;case"t":return self.getHours()<12?Date.CultureInfo.amDesignator.substring(0,1):Date.CultureInfo.pmDesignator.substring(0,1);case"tt":return self.getHours()<12?Date.CultureInfo.amDesignator:Date.CultureInfo.pmDesignator;case"zzz":case"zz":case"z":return"";}}):this._toString();};
Date.now=function(){return new Date();};Date.today=function(){return Date.now().clearTime();};Date.prototype._orient=+1;Date.prototype.next=function(){this._orient=+1;return this;};Date.prototype.last=Date.prototype.prev=Date.prototype.previous=function(){this._orient=-1;return this;};Date.prototype._is=false;Date.prototype.is=function(){this._is=true;return this;};Number.prototype._dateElement="day";Number.prototype.fromNow=function(){var c={};c[this._dateElement]=this;return Date.now().add(c);};Number.prototype.ago=function(){var c={};c[this._dateElement]=this*-1;return Date.now().add(c);};(function(){var $D=Date.prototype,$N=Number.prototype;var dx=("sunday monday tuesday wednesday thursday friday saturday").split(/\s/),mx=("january february march april may june july august september october november december").split(/\s/),px=("Millisecond Second Minute Hour Day Week Month Year").split(/\s/),de;var df=function(n){return function(){if(this._is){this._is=false;return this.getDay()==n;}
return this.moveToDayOfWeek(n,this._orient);};};for(var i=0;i<dx.length;i++){$D[dx[i]]=$D[dx[i].substring(0,3)]=df(i);}
var mf=function(n){return function(){if(this._is){this._is=false;return this.getMonth()===n;}
return this.moveToMonth(n,this._orient);};};for(var j=0;j<mx.length;j++){$D[mx[j]]=$D[mx[j].substring(0,3)]=mf(j);}
var ef=function(j){return function(){if(j.substring(j.length-1)!="s"){j+="s";}
return this["add"+j](this._orient);};};var nf=function(n){return function(){this._dateElement=n;return this;};};for(var k=0;k<px.length;k++){de=px[k].toLowerCase();$D[de]=$D[de+"s"]=ef(px[k]);$N[de]=$N[de+"s"]=nf(de);}}());Date.prototype.toJSONString=function(){return this.toString("yyyy-MM-ddThh:mm:ssZ");};Date.prototype.toShortDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortDatePattern);};Date.prototype.toLongDateString=function(){return this.toString(Date.CultureInfo.formatPatterns.longDatePattern);};Date.prototype.toShortTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.shortTimePattern);};Date.prototype.toLongTimeString=function(){return this.toString(Date.CultureInfo.formatPatterns.longTimePattern);};Date.prototype.getOrdinal=function(){switch(this.getDate()){case 1:case 21:case 31:return"st";case 2:case 22:return"nd";case 3:case 23:return"rd";default:return"th";}};
(function(){Date.Parsing={Exception:function(s){this.message="Parse error at '"+s.substring(0,10)+" ...'";}};var $P=Date.Parsing;var _=$P.Operators={rtoken:function(r){return function(s){var mx=s.match(r);if(mx){return([mx[0],s.substring(mx[0].length)]);}else{throw new $P.Exception(s);}};},token:function(s){return function(s){return _.rtoken(new RegExp("^\s*"+s+"\s*"))(s);};},stoken:function(s){return _.rtoken(new RegExp("^"+s));},until:function(p){return function(s){var qx=[],rx=null;while(s.length){try{rx=p.call(this,s);}catch(e){qx.push(rx[0]);s=rx[1];continue;}
break;}
return[qx,s];};},many:function(p){return function(s){var rx=[],r=null;while(s.length){try{r=p.call(this,s);}catch(e){return[rx,s];}
rx.push(r[0]);s=r[1];}
return[rx,s];};},optional:function(p){return function(s){var r=null;try{r=p.call(this,s);}catch(e){return[null,s];}
return[r[0],r[1]];};},not:function(p){return function(s){try{p.call(this,s);}catch(e){return[null,s];}
throw new $P.Exception(s);};},ignore:function(p){return p?function(s){var r=null;r=p.call(this,s);return[null,r[1]];}:null;},product:function(){var px=arguments[0],qx=Array.prototype.slice.call(arguments,1),rx=[];for(var i=0;i<px.length;i++){rx.push(_.each(px[i],qx));}
return rx;},cache:function(rule){var cache={},r=null;return function(s){try{r=cache[s]=(cache[s]||rule.call(this,s));}catch(e){r=cache[s]=e;}
if(r instanceof $P.Exception){throw r;}else{return r;}};},any:function(){var px=arguments;return function(s){var r=null;for(var i=0;i<px.length;i++){if(px[i]==null){continue;}
try{r=(px[i].call(this,s));}catch(e){r=null;}
if(r){return r;}}
throw new $P.Exception(s);};},each:function(){var px=arguments;return function(s){var rx=[],r=null;for(var i=0;i<px.length;i++){if(px[i]==null){continue;}
try{r=(px[i].call(this,s));}catch(e){throw new $P.Exception(s);}
rx.push(r[0]);s=r[1];}
return[rx,s];};},all:function(){var px=arguments,_=_;return _.each(_.optional(px));},sequence:function(px,d,c){d=d||_.rtoken(/^\s*/);c=c||null;if(px.length==1){return px[0];}
return function(s){var r=null,q=null;var rx=[];for(var i=0;i<px.length;i++){try{r=px[i].call(this,s);}catch(e){break;}
rx.push(r[0]);try{q=d.call(this,r[1]);}catch(ex){q=null;break;}
s=q[1];}
if(!r){throw new $P.Exception(s);}
if(q){throw new $P.Exception(q[1]);}
if(c){try{r=c.call(this,r[1]);}catch(ey){throw new $P.Exception(r[1]);}}
return[rx,(r?r[1]:s)];};},between:function(d1,p,d2){d2=d2||d1;var _fn=_.each(_.ignore(d1),p,_.ignore(d2));return function(s){var rx=_fn.call(this,s);return[[rx[0][0],r[0][2]],rx[1]];};},list:function(p,d,c){d=d||_.rtoken(/^\s*/);c=c||null;return(p instanceof Array?_.each(_.product(p.slice(0,-1),_.ignore(d)),p.slice(-1),_.ignore(c)):_.each(_.many(_.each(p,_.ignore(d))),px,_.ignore(c)));},set:function(px,d,c){d=d||_.rtoken(/^\s*/);c=c||null;return function(s){var r=null,p=null,q=null,rx=null,best=[[],s],last=false;for(var i=0;i<px.length;i++){q=null;p=null;r=null;last=(px.length==1);try{r=px[i].call(this,s);}catch(e){continue;}
rx=[[r[0]],r[1]];if(r[1].length>0&&!last){try{q=d.call(this,r[1]);}catch(ex){last=true;}}else{last=true;}
if(!last&&q[1].length===0){last=true;}
if(!last){var qx=[];for(var j=0;j<px.length;j++){if(i!=j){qx.push(px[j]);}}
p=_.set(qx,d).call(this,q[1]);if(p[0].length>0){rx[0]=rx[0].concat(p[0]);rx[1]=p[1];}}
if(rx[1].length<best[1].length){best=rx;}
if(best[1].length===0){break;}}
if(best[0].length===0){return best;}
if(c){try{q=c.call(this,best[1]);}catch(ey){throw new $P.Exception(best[1]);}
best[1]=q[1];}
return best;};},forward:function(gr,fname){return function(s){return gr[fname].call(this,s);};},replace:function(rule,repl){return function(s){var r=rule.call(this,s);return[repl,r[1]];};},process:function(rule,fn){return function(s){var r=rule.call(this,s);return[fn.call(this,r[0]),r[1]];};},min:function(min,rule){return function(s){var rx=rule.call(this,s);if(rx[0].length<min){throw new $P.Exception(s);}
return rx;};}};var _generator=function(op){return function(){var args=null,rx=[];if(arguments.length>1){args=Array.prototype.slice.call(arguments);}else if(arguments[0]instanceof Array){args=arguments[0];}
if(args){for(var i=0,px=args.shift();i<px.length;i++){args.unshift(px[i]);rx.push(op.apply(null,args));args.shift();return rx;}}else{return op.apply(null,arguments);}};};var gx="optional not ignore cache".split(/\s/);for(var i=0;i<gx.length;i++){_[gx[i]]=_generator(_[gx[i]]);}
var _vector=function(op){return function(){if(arguments[0]instanceof Array){return op.apply(null,arguments[0]);}else{return op.apply(null,arguments);}};};var vx="each any all".split(/\s/);for(var j=0;j<vx.length;j++){_[vx[j]]=_vector(_[vx[j]]);}}());(function(){var flattenAndCompact=function(ax){var rx=[];for(var i=0;i<ax.length;i++){if(ax[i]instanceof Array){rx=rx.concat(flattenAndCompact(ax[i]));}else{if(ax[i]){rx.push(ax[i]);}}}
return rx;};Date.Grammar={};Date.Translator={hour:function(s){return function(){this.hour=Number(s);};},minute:function(s){return function(){this.minute=Number(s);};},second:function(s){return function(){this.second=Number(s);};},meridian:function(s){return function(){this.meridian=s.slice(0,1).toLowerCase();};},timezone:function(s){return function(){var n=s.replace(/[^\d\+\-]/g,"");if(n.length){this.timezoneOffset=Number(n);}else{this.timezone=s.toLowerCase();}};},day:function(x){var s=x[0];return function(){this.day=Number(s.match(/\d+/)[0]);};},month:function(s){return function(){this.month=((s.length==3)?Date.getMonthNumberFromName(s):(Number(s)-1));};},year:function(s){return function(){var n=Number(s);this.year=((s.length>2)?n:(n+(((n+2000)<Date.CultureInfo.twoDigitYearMax)?2000:1900)));};},rday:function(s){return function(){switch(s){case"yesterday":this.days=-1;break;case"tomorrow":this.days=1;break;case"today":this.days=0;break;case"now":this.days=0;this.now=true;break;}};},finishExact:function(x){x=(x instanceof Array)?x:[x];var now=new Date();this.year=now.getFullYear();this.month=now.getMonth();this.day=1;this.hour=0;this.minute=0;this.second=0;for(var i=0;i<x.length;i++){if(x[i]){x[i].call(this);}}
this.hour=(this.meridian=="p"&&this.hour<13)?this.hour+12:this.hour;if(this.day>Date.getDaysInMonth(this.year,this.month)){throw new RangeError(this.day+" is not a valid value for days.");}
var r=new Date(this.year,this.month,this.day,this.hour,this.minute,this.second);if(this.timezone){r.set({timezone:this.timezone});}else if(this.timezoneOffset){r.set({timezoneOffset:this.timezoneOffset});}
return r;},finish:function(x){x=(x instanceof Array)?flattenAndCompact(x):[x];if(x.length===0){return null;}
for(var i=0;i<x.length;i++){if(typeof x[i]=="function"){x[i].call(this);}}
if(this.now){return new Date();}
var today=Date.today();var method=null;var expression=!!(this.days!=null||this.orient||this.operator);if(expression){var gap,mod,orient;orient=((this.orient=="past"||this.operator=="subtract")?-1:1);if(this.weekday){this.unit="day";gap=(Date.getDayNumberFromName(this.weekday)-today.getDay());mod=7;this.days=gap?((gap+(orient*mod))%mod):(orient*mod);}
if(this.month){this.unit="month";gap=(this.month-today.getMonth());mod=12;this.months=gap?((gap+(orient*mod))%mod):(orient*mod);this.month=null;}
if(!this.unit){this.unit="day";}
if(this[this.unit+"s"]==null||this.operator!=null){if(!this.value){this.value=1;}
if(this.unit=="week"){this.unit="day";this.value=this.value*7;}
this[this.unit+"s"]=this.value*orient;}
return today.add(this);}else{if(this.meridian&&this.hour){this.hour=(this.hour<13&&this.meridian=="p")?this.hour+12:this.hour;}
if(this.weekday&&!this.day){this.day=(today.addDays((Date.getDayNumberFromName(this.weekday)-today.getDay()))).getDate();}
if(this.month&&!this.day){this.day=1;}
return today.set(this);}}};var _=Date.Parsing.Operators,g=Date.Grammar,t=Date.Translator,_fn;g.datePartDelimiter=_.rtoken(/^([\s\-\.\,\/\x27]+)/);g.timePartDelimiter=_.stoken(":");g.whiteSpace=_.rtoken(/^\s*/);g.generalDelimiter=_.rtoken(/^(([\s\,]|at|on)+)/);var _C={};g.ctoken=function(keys){var fn=_C[keys];if(!fn){var c=Date.CultureInfo.regexPatterns;var kx=keys.split(/\s+/),px=[];for(var i=0;i<kx.length;i++){px.push(_.replace(_.rtoken(c[kx[i]]),kx[i]));}
fn=_C[keys]=_.any.apply(null,px);}
return fn;};g.ctoken2=function(key){return _.rtoken(Date.CultureInfo.regexPatterns[key]);};g.h=_.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2]|[1-9])/),t.hour));g.hh=_.cache(_.process(_.rtoken(/^(0[0-9]|1[0-2])/),t.hour));g.H=_.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3]|[0-9])/),t.hour));g.HH=_.cache(_.process(_.rtoken(/^([0-1][0-9]|2[0-3])/),t.hour));g.m=_.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/),t.minute));g.mm=_.cache(_.process(_.rtoken(/^[0-5][0-9]/),t.minute));g.s=_.cache(_.process(_.rtoken(/^([0-5][0-9]|[0-9])/),t.second));g.ss=_.cache(_.process(_.rtoken(/^[0-5][0-9]/),t.second));g.hms=_.cache(_.sequence([g.H,g.mm,g.ss],g.timePartDelimiter));g.t=_.cache(_.process(g.ctoken2("shortMeridian"),t.meridian));g.tt=_.cache(_.process(g.ctoken2("longMeridian"),t.meridian));g.z=_.cache(_.process(_.rtoken(/^(\+|\-)?\s*\d\d\d\d?/),t.timezone));g.zz=_.cache(_.process(_.rtoken(/^(\+|\-)\s*\d\d\d\d/),t.timezone));g.zzz=_.cache(_.process(g.ctoken2("timezone"),t.timezone));g.timeSuffix=_.each(_.ignore(g.whiteSpace),_.set([g.tt,g.zzz]));g.time=_.each(_.optional(_.ignore(_.stoken("T"))),g.hms,g.timeSuffix);g.d=_.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1]|\d)/),_.optional(g.ctoken2("ordinalSuffix"))),t.day));g.dd=_.cache(_.process(_.each(_.rtoken(/^([0-2]\d|3[0-1])/),_.optional(g.ctoken2("ordinalSuffix"))),t.day));g.ddd=g.dddd=_.cache(_.process(g.ctoken("sun mon tue wed thu fri sat"),function(s){return function(){this.weekday=s;};}));g.M=_.cache(_.process(_.rtoken(/^(1[0-2]|0\d|\d)/),t.month));g.MM=_.cache(_.process(_.rtoken(/^(1[0-2]|0\d)/),t.month));g.MMM=g.MMMM=_.cache(_.process(g.ctoken("jan feb mar apr may jun jul aug sep oct nov dec"),t.month));g.y=_.cache(_.process(_.rtoken(/^(\d\d?)/),t.year));g.yy=_.cache(_.process(_.rtoken(/^(\d\d)/),t.year));g.yyy=_.cache(_.process(_.rtoken(/^(\d\d?\d?\d?)/),t.year));g.yyyy=_.cache(_.process(_.rtoken(/^(\d\d\d\d)/),t.year));_fn=function(){return _.each(_.any.apply(null,arguments),_.not(g.ctoken2("timeContext")));};g.day=_fn(g.d,g.dd);g.month=_fn(g.M,g.MMM);g.year=_fn(g.yyyy,g.yy);g.orientation=_.process(g.ctoken("past future"),function(s){return function(){this.orient=s;};});g.operator=_.process(g.ctoken("add subtract"),function(s){return function(){this.operator=s;};});g.rday=_.process(g.ctoken("yesterday tomorrow today now"),t.rday);g.unit=_.process(g.ctoken("minute hour day week month year"),function(s){return function(){this.unit=s;};});g.value=_.process(_.rtoken(/^\d\d?(st|nd|rd|th)?/),function(s){return function(){this.value=s.replace(/\D/g,"");};});g.expression=_.set([g.rday,g.operator,g.value,g.unit,g.orientation,g.ddd,g.MMM]);_fn=function(){return _.set(arguments,g.datePartDelimiter);};g.mdy=_fn(g.ddd,g.month,g.day,g.year);g.ymd=_fn(g.ddd,g.year,g.month,g.day);g.dmy=_fn(g.ddd,g.day,g.month,g.year);g.date=function(s){return((g[Date.CultureInfo.dateElementOrder]||g.mdy).call(this,s));};g.format=_.process(_.many(_.any(_.process(_.rtoken(/^(dd?d?d?|MM?M?M?|yy?y?y?|hh?|HH?|mm?|ss?|tt?|zz?z?)/),function(fmt){if(g[fmt]){return g[fmt];}else{throw Date.Parsing.Exception(fmt);}}),_.process(_.rtoken(/^[^dMyhHmstz]+/),function(s){return _.ignore(_.stoken(s));}))),function(rules){return _.process(_.each.apply(null,rules),t.finishExact);});var _F={};var _get=function(f){return _F[f]=(_F[f]||g.format(f)[0]);};g.formats=function(fx){if(fx instanceof Array){var rx=[];for(var i=0;i<fx.length;i++){rx.push(_get(fx[i]));}
return _.any.apply(null,rx);}else{return _get(fx);}};g._formats=g.formats(["yyyy-MM-ddTHH:mm:ss","ddd, MMM dd, yyyy H:mm:ss tt","ddd MMM d yyyy HH:mm:ss zzz","d"]);g._start=_.process(_.set([g.date,g.time,g.expression],g.generalDelimiter,g.whiteSpace),t.finish);g.start=function(s){try{var r=g._formats.call({},s);if(r[1].length===0){return r;}}catch(e){}
return g._start.call({},s);};}());Date._parse=Date.parse;Date.parse=function(s){var r=null;if(!s){return null;}
try{r=Date.Grammar.start.call({},s);}catch(e){return null;}
return((r[1].length===0)?r[0]:null);};Date.getParseFunction=function(fx){var fn=Date.Grammar.formats(fx);return function(s){var r=null;try{r=fn.call({},s);}catch(e){return null;}
return((r[1].length===0)?r[0]:null);};};Date.parseExact=function(s,fx){return Date.getParseFunction(fx)(s);};

View File

@@ -0,0 +1,350 @@
/*
* DEMO HELPERS
*/
/**
* debugData
*
* Pass me a data structure {} and I'll output all the key/value pairs - recursively
*
* @example var HTML = debugData( oElem.style, "Element.style", { keys: "top,left,width,height", recurse: true, sort: true, display: true, returnHTML: true });
*
* @param Object o_Data A JSON-style data structure
* @param String s_Title Title for dialog (optional)
* @param Hash options Pass additional options in a hash
*/
function debugData (o_Data, s_Title, options) {
options = options || {};
var
str=(s_Title||s_Title==='' ? s_Title : 'DATA')
// maintain backward compatibility with OLD 'recurseData' param
, recurse=(typeof options=='boolean' ? options : options.recurse !==false)
, keys=(options.keys?','+options.keys+',':false)
, display=options.display !==false
, html=options.returnHTML !==false
, sort=options.sort !==false
, D=[], i=0 // Array to hold data, i=counter
, hasSubKeys = false
, k, t, skip, x // loop vars
;
if (typeof o_Data != 'object') {
alert( (s_Title ? s_Title +': ' : '')+ o_Data );
return;
}
if (o_Data.jquery) {
str=s_Title+'jQuery Collection ('+ o_Data.length +')\n context="'+ o_Data.context +'"';
}
else if (o_Data.tagName && typeof o_Data.style == 'object') {
str=s_Title+o_Data.tagName;
var id = o_Data.id, cls=o_Data.className, src=o_Data.src, hrf=o_Data.href;
if (id) str+='\n id="'+ id+'"';
if (cls) str+='\n class="'+ cls+'"';
if (src) str+='\n src="'+ src+'"';
if (hrf) str+='\n href="'+ hrf+'"';
}
else {
parse(o_Data,''); // recursive parsing
if (sort && !hasSubKeys) D.sort(); // sort by keyName - but NOT if has subKeys!
if (str) str += '\n***'+ '****************************'.substr(0,str.length) +'\n';
str += D.join('\n'); // add line-breaks
}
if (display) alert(str); // display data
if (html) str=str.replace(/\n/g, ' <br>').replace(/ /g, ' &nbsp;'); // format as HTML
return str;
function parse ( data, prefix ) {
if (typeof prefix=='undefined') prefix='';
try {
$.each( data, function (key, val) {
k = prefix+key+': ';
skip = (keys && keys.indexOf(','+key+',') == -1);
if (typeof val==='function') { // FUNCTION
if (!skip) D[i++] = k +'function()';
}
else if (typeof val==='string') { // STRING
if (!skip) D[i++] = k +'"'+ val +'"';
}
else if (val===null || val===undefined || typeof val !=='object') { // NULL, UNDEFINED, NUMBER or BOOLEAN
if (!skip) D[i++] = k + val;
}
else if (debugIsArray(val)) { // ARRAY
if (!skip) {
if (val.length && typeof val[0] == "object") { // array of objects (hashs or arrays)
D[i++] = k +'{';
parse( val, prefix+' '); // RECURSE
D[i++] = prefix +'}';
}
else
D[i++] = k +'[ '+ val.toString() +' ]'; // output delimited array
}
}
else if (val.jquery) {
if (!skip) D[i++] = k +'jQuery ('+ val.length +') context="'+ val.context +'"';
}
else if (val.tagName && typeof val.style == 'object') {
var id = val.id, cls=val.className, src=val.src, hrf=val.href;
if (skip) D[i++] = k +' '+
id ? 'id="'+ id+'"' :
src ? 'src="'+ src+'"' :
hrf ? 'href="'+ hrf+'"' :
cls ? 'class="'+cls+'"' :
'';
}
else { // Object or JSON
if (!recurse || !hasKeys(val)) { // show an empty hash
if (!skip) D[i++] = k +'{ }';
}
else { // recurse into JSON hash - indent output
D[i++] = k +'{';
parse( val, prefix+' '); // RECURSE
D[i++] = prefix +'}';
}
}
});
} catch (e) {}
function hasKeys(o) {
var c=0;
for (x in o) c++;
if (!hasSubKeys) hasSubKeys = !!c;
return !!c;
}
}
};
function debugIsArray(o) { return (o && typeof o==='object' && !o.propertyIsEnumerable('length') && typeof o.length==='number'); };
function debugStackTrace (s_Title, options) {
var
callstack = []
, isCallstackPopulated = false
;
try {
i.dont.exist += 0; // doesn't exist- that's the point
} catch(e) {
if (e.stack) { // Firefox
var lines = e.stack.split('\n');
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
callstack.push(lines[i]);
}
}
//Remove call to printStackTrace()
callstack.shift();
isCallstackPopulated = true;
}
else if (window.opera && e.message) { // Opera
var lines = e.message.split('\n');
for (var i=0, len=lines.length; i<len; i++) {
if (lines[i].match(/^\s*[A-Za-z0-9\-_\$]+\(/)) {
var entry = lines[i];
//Append next line also since it has the file info
if (lines[i+1]) {
entry += ' at ' + lines[i+1];
i++;
}
callstack.push(entry);
}
}
//Remove call to printStackTrace()
callstack.shift();
isCallstackPopulated = true;
}
}
if (!isCallstackPopulated) { // IE and Safari
var currentFunction = arguments.callee.caller;
while (currentFunction) {
var fn = currentFunction.toString();
var fname = fn.substring(fn.indexOf('function') + 8, fn.indexOf('')) || 'anonymous';
callstack.push(fname);
currentFunction = currentFunction.caller;
}
}
debugData( callstack, s_Title, options );
};
// this end up displaying errors when layout.showErrorMessages = false, so disable it
//if (!window.console) window.console = { log: debugData };
if (window.console) {
if (!window.console.trace)
window.console.trace = function (s_Title) {
window.console.log( debugStackTrace(s_Title, { display: false, returnHTML: false, sort: false }) );
};
// add method to output 'hash data' inside an string
window.console.data = function (o_Data) {
var A = debugIsArray( o_Data ) ? o_Data : [ o_Data ], S='', i=0, c=A.length;
for (; i<c; i++)
S += (S ? '\n' : '') +'{\n'+ debugData( A[i], '', { display: false, returnHTML: false, sort: false }) +'\n}';
return S;
};
};
/**
* timer
*
* Utility for debug timing of events
* Can track multiple timers and returns either a total time or interval from last event
* @param String timerName Name of the timer - defaults to debugTimer
* @param String action Keyword for action or return-value...
* action: 'reset' = reset; 'clear' = delete; 'total' = ms since init; 'step' or '' = ms since last event
*/
/**
* timer
*
* Utility method for timing performance
* Can track multiple timers and returns either a total time or interval from last event
*
* returns time-data: {
* start: Date Object
* , last: Date Object
* , step: 99 // time since 'last'
* , total: 99 // time since 'start'
* }
*
* USAGE SAMPLES
* =============
* timer('name'); // create/init timer
* timer('name', 'reset'); // re-init timer
* timer('name', 'clear'); // clear/remove timer
* var i = timer('name'); // how long since last timer request?
* var i = timer('name', 'total'); // how long since timer started?
*
* @param String timerName Name of the timer - defaults to debugTimer
* @param String action Keyword for action or return-value...
* @param Hash options Options to customize return data
* action: 'reset' = reset; 'clear' = delete; 'total' = ms since init; 'step' or '' = ms since last event
*/
function timer (timerName, action, options) {
var
name = timerName || 'debugTimer'
, Timer = window[ name ]
, defaults = {
returnString: true
, padNumbers: true
, timePrefix: ''
, timeSuffix: ''
}
;
// init the timer first time called
if (!Timer || action == 'reset') { // init timer
Timer = window[ name ] = {
start: new Date()
, last: new Date()
, step: 0 // time since 'last'
, total: 0 // time since 'start'
, options: $.extend({}, defaults, options)
};
}
else if (action == 'clear') { // remove timer
window[ name ] = null;
return null;
}
else { // update existing timer
Timer.step = (new Date()) - Timer.last; // time since 'last'
Timer.total = (new Date()) - Timer.start; // time since 'start'
Timer.last = new Date();
}
var
time = (action == 'total') ? Timer.total : Timer.step
, o = Timer.options // alias
;
if (o.returnString) {
time += ""; // convert integer to string
// pad time to 4 chars with underscores
if (o.padNumbers)
switch (time.length) {
case 1: time = "&ensp;&ensp;&ensp;"+ time; break;
case 2: time = "&ensp;&ensp;"+ time; break;
case 3: time = "&ensp;"+ time; break;
}
// add prefix and suffix
if (o.timePrefix || o.timeSuffix)
time = o.timePrefix + time + o.timeSuffix;
}
return time;
};
/**
* showOptions
*
* Pass a layout-options object, and the pane/key you want to display
*/
function showOptions (Layout, key, debugOpts) {
var data = Layout.options;
$.each(key.split("."), function() {
data = data[this]; // recurse through multiple key-levels
});
debugData( data, 'options.'+key, debugOpts );
};
/**
* showState
*
* Pass a layout-options object, and the pane/key you want to display
*/
function showState (Layout, key, debugOpts) {
var data = Layout.state;
$.each(key.split("."), function() {
data = data[this]; // recurse through multiple key-levels
});
debugData( data, 'state.'+key, debugOpts );
};
/**
* addThemeSwitcher
*
* Remove the cookie set by the UI Themeswitcher to reset a page to default styles
*
* Dependancies: /lib/js/themeswitchertool.js
*/
function addThemeSwitcher ( container, position ) {
var pos = { top: '10px', right: '10px', zIndex: 10 };
$('<div id="themeContainer" style="position: absolute; overflow-x: hidden;"></div>')
.css( $.extend( pos, position ) )
.appendTo( container || 'body')
.themeswitcher()
;
};
/**
* removeUITheme
*
* Remove the cookie set by the UI Themeswitcher to reset a page to default styles
*/
function removeUITheme ( cookieName, removeCookie ) {
$('link.ui-theme').remove();
$('.jquery-ui-themeswitcher-title').text( 'Switch Theme' );
if (removeCookie !== false)
$.cookie( cookieName || 'jquery-ui-theme', null );
};
function debugWindow ( content, options ) {
var defaults = {
css: {
position: 'fixed'
, top: 0
}
};
$.extend( true, (options || {}), defaults );
var $W = $('<div></div>')
.html( content.replace(/\n/g, '<br>').replace(/ /g, ' &nbsp;') ) // format as HTML
.css( options.css )
;
};

View File

@@ -0,0 +1,108 @@
// JavaScript Document
$(document).ready(function() {
$.widget( "ui.combobox", {
_create: function() {
var input,
self = this,
select = this.element.hide(),
selected = select.children( ":selected" ),
value = selected.val() ? selected.text() : "",
wrapper = $( "<span>" )
.addClass( "ui-combobox" )
.insertAfter( select );
input = $( "<input>" )
.appendTo( wrapper )
.val( value )
.addClass( "ui-state-default" )
.autocomplete({
delay: 0,
minLength: 0,
source: function( request, response ) {
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
response( select.children( "option" ).map(function() {
var text = $( this ).text();
if ( this.value && ( !request.term || matcher.test(text) ) )
return {
label: text.replace(
new RegExp(
"(?![^&;]+;)(?!<[^<>]*)(" +
$.ui.autocomplete.escapeRegex(request.term) +
")(?![^<>]*>)(?![^&;]+;)", "gi"
), "<strong>$1</strong>" ),
value: text,
option: this
};
}) );
},
select: function( event, ui ) {
ui.item.option.selected = true;
self._trigger( "selected", event, {
item: ui.item.option
});
},
change: function( event, ui ) {
if ( !ui.item ) {
var matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( $(this).val() ) + "$", "i" ),
valid = false;
select.children( "option" ).each(function() {
if ( $( this ).text().match( matcher ) ) {
this.selected = valid = true;
return false;
}
});
if ( !valid ) {
// remove invalid value, as it didn't match anything
$( this ).val( "" );
select.val( "" );
input.data( "autocomplete" ).term = "";
return false;
}
}
}
})
.addClass( "ui-widget ui-widget-content ui-corner-left" );
input.data( "autocomplete" )._renderItem = function( ul, item ) {
return $( "<li></li>" )
.data( "item.autocomplete", item )
.append( "<a>" + item.label + "</a>" )
.appendTo( ul );
};
$( "<a>" )
.attr( "tabIndex", -1 )
.attr( "title", "Show All Items" )
.appendTo( wrapper )
.button({
icons: {
primary: "ui-icon-triangle-1-s"
},
text: false
})
.removeClass( "ui-corner-all" )
.addClass( "ui-corner-right ui-button-icon" )
.click(function() {
// close if already visible
if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
input.autocomplete( "close" );
return;
}
// work around a bug (likely same cause as #5265)
$( this ).blur();
// pass empty string as value to search for, displaying all results
input.autocomplete( "search", "" );
input.focus();
});
},
destroy: function() {
this.wrapper.remove();
this.element.show();
$.Widget.prototype.destroy.call( this );
}
});
});

View File

@@ -0,0 +1,112 @@
/* jQuery Context Menu
* Created: Dec 16th, 2009 by DynamicDrive.com. This notice must stay intact for usage
* Author: Dynamic Drive at http://www.dynamicdrive.com/
* Visit http://www.dynamicdrive.com/ for full source code
*/
jQuery.noConflict()
var jquerycontextmenu={
arrowpath: 'images/arrow.gif', //full URL or path to arrow image
contextmenuoffsets: [1, -1], //additional x and y offset from mouse cursor for contextmenus
//***** NO NEED TO EDIT BEYOND HERE
builtcontextmenuids: [], //ids of context menus already built (to prevent repeated building of same context menu)
positionul:function($, $ul, e){
var istoplevel=$ul.hasClass('jqcontextmenu') //Bool indicating whether $ul is top level context menu DIV
var docrightedge=$(document).scrollLeft()+$(window).width()-40 //40 is to account for shadows in FF
var docbottomedge=$(document).scrollTop()+$(window).height()-40
if (istoplevel){ //if main context menu DIV
var x=e.pageX+this.contextmenuoffsets[0] //x pos of main context menu UL
var y=e.pageY+this.contextmenuoffsets[1]
x=(x+$ul.data('dimensions').w > docrightedge)? docrightedge-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge of the cursor
y=(y+$ul.data('dimensions').h > docbottomedge)? docbottomedge-$ul.data('dimensions').h : y
}
else{ //if sub level context menu UL
var $parentli=$ul.data('$parentliref')
var parentlioffset=$parentli.offset()
var x=$ul.data('dimensions').parentliw //x pos of sub UL
var y=0
x=(parentlioffset.left+x+$ul.data('dimensions').w > docrightedge)? x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge parent LI
y=(parentlioffset.top+$ul.data('dimensions').h > docbottomedge)? y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih : y
}
$ul.css({left:x, top:y})
},
showbox:function($, $contextmenu, e){
$contextmenu.show()
},
hidebox:function($, $contextmenu){
$contextmenu.find('ul').andSelf().hide() //hide context menu plus all of its sub ULs
},
buildcontextmenu:function($, $menu){
$menu.css({display:'block', visibility:'hidden'}).appendTo(document.body)
$menu.data('dimensions', {w:$menu.outerWidth(), h:$menu.outerHeight()}) //remember main menu's dimensions
var $lis=$menu.find("ul").parent() //find all LIs within menu with a sub UL
$lis.each(function(i){
var $li=$(this).css({zIndex: 1000+i})
var $subul=$li.find('ul:eq(0)').css({display:'block'}) //set sub UL to "block" so we can get dimensions
$subul.data('dimensions', {w:$subul.outerWidth(), h:$subul.outerHeight(), parentliw:this.offsetWidth, parentlih:this.offsetHeight})
$subul.data('$parentliref', $li) //cache parent LI of each sub UL
$li.data('$subulref', $subul) //cache sub UL of each parent LI
$li.children("a:eq(0)").append( //add arrow images
'<img src="'+jquerycontextmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />'
)
$li.bind('mouseenter', function(e){ //show sub UL when mouse moves over parent LI
var $targetul=$(this).data('$subulref')
if ($targetul.queue().length<=1){ //if 1 or less queued animations
jquerycontextmenu.positionul($, $targetul, e)
$targetul.show()
}
})
$li.bind('mouseleave', function(e){ //hide sub UL when mouse moves out of parent LI
$(this).data('$subulref').hide()
})
})
$menu.find('ul').andSelf().css({display:'none', visibility:'visible'}) //collapse all ULs again
this.builtcontextmenuids.push($menu.get(0).id) //remember id of context menu that was just built
},
init:function($, $target, $contextmenu){
if (this.builtcontextmenuids.length==0){ //only bind click event to document once
$(document).bind("click", function(e){
if (e.button==0){ //hide all context menus (and their sub ULs) when left mouse button is clicked
jquerycontextmenu.hidebox($, $('.jqcontextmenu'))
}
})
}
if (jQuery.inArray($contextmenu.get(0).id, this.builtcontextmenuids)==-1) //if this context menu hasn't been built yet
this.buildcontextmenu($, $contextmenu)
$(document).bind("click", function(e){
if (e.button==0){ //hide all context menus (and their sub ULs) when left mouse button is clicked
jquerycontextmenu.hidebox($, $('.jqcontextmenu'))
}
})
if ($target.parents().filter('ul.jqcontextmenu').length>0) //if $target matches an element within the context menu markup, don't bind oncontextmenu to that element
return
$target.bind("contextmenu", function(e){
jquerycontextmenu.hidebox($, $('.jqcontextmenu')) //hide all context menus (and their sub ULs)
jquerycontextmenu.positionul($, $contextmenu, e)
jquerycontextmenu.showbox($, $contextmenu, e)
return false
})
}
}
jQuery.fn.addcontextmenu=function(contextmenuid){
var $=jQuery
return this.each(function(){ //return jQuery obj
var $target=$(this)
jquerycontextmenu.init($, $target, $('#'+contextmenuid))
})
};
//Usage: $(elementselector).addcontextmenu('id_of_context_menu_on_page')

View File

@@ -0,0 +1,300 @@
/*
* jQuery gentleSelect plugin
* http://shawnchin.github.com/jquery-gentleSelect
*
* Copyright (c) 2010 Shawn Chin.
* Licensed under the MIT license.
*
* Usage:
* (JS)
*
* $('#myselect').gentleSelect(); // default. single column
*
* $('#myselect').gentleSelect({ // 3 columns, 150px wide each
* itemWidth : 150,
* columns : 3,
* });
*
* (HTML)
* <select id='myselect'><options> .... </options></select>
*
*/
(function($) {
var defaults = {
minWidth : 100, // only applies if columns and itemWidth not set
itemWidth : undefined,
columns : undefined,
rows : undefined,
title : undefined,
prompt : "Make A Selection",
maxDisplay: 0, // set to 0 for unlimited
openSpeed : 400,
closeSpeed : 400,
openEffect : "slide",
closeEffect : "slide",
hideOnMouseOut : true
}
function defined(obj) {
if (typeof obj == "undefined") { return false; }
else { return true; }
}
function hasError(c, o) {
if (defined(o.columns) && defined(o.rows)) {
$.error("gentleSelect: You cannot supply both 'rows' and 'columns'");
return true;
}
if (defined(o.columns) && !defined(o.itemWidth)) {
$.error("gentleSelect: itemWidth must be supplied if 'columns' is specified");
return true;
}
if (defined(o.rows) && !defined(o.itemWidth)) {
$.error("gentleSelect: itemWidth must be supplied if 'rows' is specified");
return true;
}
if (!defined(o.openSpeed) || typeof o.openSpeed != "number" &&
(typeof o.openSpeed == "string" && (o.openSpeed != "slow" && o.openSpeed != "fast"))) {
$.error("gentleSelect: openSpeed must be an integer or \"slow\" or \"fast\"");
return true;
}
if (!defined(o.closeSpeed) || typeof o.closeSpeed != "number" &&
(typeof o.closeSpeed == "string" && (o.closeSpeed != "slow" && o.closeSpeed != "fast"))) {
$.error("gentleSelect: closeSpeed must be an integer or \"slow\" or \"fast\"");
return true;
}
if (!defined(o.openEffect) || (o.openEffect != "fade" && o.openEffect != "slide")) {
$.error("gentleSelect: openEffect must be either 'fade' or 'slide'!");
return true;
}
if (!defined(o.closeEffect)|| (o.closeEffect != "fade" && o.closeEffect != "slide")) {
$.error("gentleSelect: closeEffect must be either 'fade' or 'slide'!");
return true;
}
if (!defined(o.hideOnMouseOut) || (typeof o.hideOnMouseOut != "boolean")) {
$.error("gentleSelect: hideOnMouseOut must be supplied and either \"true\" or \"false\"!");
return true;
}
return false;
}
function optionOverrides(c, o) {
if (c.attr("multiple")) {
o.hideOnMouseOut = true; // must be true or dialog will never hide
}
}
function getSelectedAsText(elemList, opts) {
// If no items selected, return prompt
if (elemList.length < 1) { return opts.prompt; }
// Truncate if exceed maxDisplay
if (opts.maxDisplay != 0 && elemList.length > opts.maxDisplay) {
var arr = elemList.slice(0, opts.maxDisplay).map(function(){return $(this).text();});
arr.push("...");
} else {
var arr = elemList.map(function(){return $(this).text();});
}
return arr.get().join(", ");
}
var methods = {
init : function(options) {
var o = $.extend({}, defaults, options);
if (hasError(this, o)) { return this; }; // check for errors
optionOverrides(this, o); //
this.hide(); // hide original select box
// initialise <span> to replace select box
label_text = getSelectedAsText(this.find(":selected"), o);
var label = $("<span class='gentleselect-label'>" + label_text + "</span>")
.insertBefore(this)
.bind("mouseenter.gentleselect", event_handlers.labelHoverIn)
.bind("mouseleave.gentleselect", event_handlers.labelHoverOut)
.bind("click.gentleselect", event_handlers.labelClick)
.data("root", this);
this.data("label", label)
.data("options", o);
// generate list of options
var ul = $("<ul></ul>");
this.find("option").each(function() {
var li = $("<li>" + $(this).text() + "</li>")
.data("value", $(this).attr("value"))
.data("name", $(this).text())
.appendTo(ul);
if ($(this).attr("selected")) { li.addClass("selected"); }
});
// build dialog box
var dialog = $("<div class='gentleselect-dialog'></div>")
.append(ul)
.insertAfter(label)
.bind("click.gentleselect", event_handlers.dialogClick)
.bind("mouseleave.gentleselect", event_handlers.dialogHoverOut)
.data("label", label)
.data("root", this);
this.data("dialog", dialog);
// if to be displayed in columns
if (defined(o.columns) || defined(o.rows)) {
// Update CSS
ul.css("float", "left")
.find("li").width(o.itemWidth).css("float","left");
var f = ul.find("li:first");
var actualWidth = o.itemWidth
+ parseInt(f.css("padding-left"))
+ parseInt(f.css("padding-right"));
var elemCount = ul.find("li").length;
if (defined(o.columns)) {
var cols = parseInt(o.columns);
var rows = Math.ceil(elemCount / cols);
} else {
var rows = parseInt(o.rows);
var cols = Math.ceil(elemCount / rows);
}
dialog.width(actualWidth * cols);
// add padding
for (var i = 0; i < (rows * cols) - elemCount; i++) {
$("<li style='float:left' class='gentleselect-dummy'><span>&nbsp;</span></li>").appendTo(ul);
}
// reorder elements
var ptr = [];
var idx = 0;
ul.find("li").each(function() {
if (idx < rows) {
ptr[idx] = $(this);
} else {
var p = idx % rows;
$(this).insertAfter(ptr[p]);
ptr[p] = $(this);
}
idx++;
});
} else if (typeof o.minWidth == "number") {
dialog.css("min-width", o.minWidth);
}
if (defined(o.title)) {
$("<div class='gentleselect-title'>" + o.title + "</div>").prependTo(dialog);
}
// ESC key should hide all dialog boxes
$(document).bind("keyup.gentleselect", event_handlers.keyUp);
return this;
},
// if select box was updated externally, we need to bring everything
// else up to speed.
update : function() {
var opts = this.data("options");
// Update li with selected data
var v = (this.attr("multiple")) ? this.val() : [this.val()];
$("li", this.data("dialog")).each(function() {
var $li = $(this);
var isSelected = ($.inArray($li.data("value"), v) != -1);
$li.toggleClass("selected", isSelected);
});
// Update label
var label = getSelectedAsText(this.find(":selected"), opts);
this.data("label").text(label);
return this;
}
};
var event_handlers = {
labelHoverIn : function() {
$(this).addClass('gentleselect-label-highlight');
},
labelHoverOut : function() {
$(this).removeClass('gentleselect-label-highlight');
},
labelClick : function() {
var $this = $(this);
var pos = $this.position();
var root = $this.data("root");
var opts = root.data("options");
var dialog = root.data("dialog")
.css("top", pos.top + $this.height())
.css("left", pos.left + 1);
if (opts.openEffect == "fade") {
dialog.fadeIn(opts.openSpeed);
} else {
dialog.slideDown(opts.openSpeed);
}
},
dialogHoverOut : function() {
var $this = $(this);
if ($this.data("root").data("options").hideOnMouseOut) {
$this.hide();
}
},
dialogClick : function(e) {
var clicked = $(e.target);
var $this = $(this);
var root = $this.data("root");
var opts = root.data("options");
if (!root.attr("multiple")) {
if (opts.closeEffect == "fade") {
$this.fadeOut(opts.closeSpeed);
} else {
$this.slideUp(opts.closeSpeed);
}
}
if (clicked.is("li") && !clicked.hasClass("gentleselect-dummy")) {
var value = clicked.data("value");
var name = clicked.data("name");
var label = $this.data("label")
if ($this.data("root").attr("multiple")) {
clicked.toggleClass("selected");
var s = $this.find("li.selected");
label.text(getSelectedAsText(s, opts));
var v = s.map(function(){ return $(this).data("value"); });
// update actual selectbox and trigger change event
root.val(v.get()).trigger("change");
} else {
$this.find("li.selected").removeClass("selected");
clicked.addClass("selected");
label.text(clicked.data("name"));
// update actual selectbox and trigger change event
root.val(value).trigger("change");
}
}
},
keyUp : function(e) {
if (e.keyCode == 27 ) { // ESC
$(".gentleselect-dialog").hide();
}
}
};
$.fn.gentleSelect = 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.gentleSelect' );
}
};
})(jQuery);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,234 @@
// jQuery Alert Dialogs Plugin
//
// Version 1.0
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
// 29 December 2008
//
// Visit http://abeautifulsite.net/notebook/87 for more information
//
// Usage:
// jAlert( message, [title, callback] )
// jConfirm( message, [title, callback] )
// jPrompt( message, [value, title, callback] )
//
// History:
//
// 1.00 - Released (29 December 2008)
//
// License:
//
// This plugin is licensed under the GNU General Public License: http://www.gnu.org/licenses/gpl.html
//
(function($) {
$.alerts = {
// These properties can be read/written by accessing $.alerts.propertyName from your scripts at any time
verticalOffset: -75, // vertical offset of the dialog from center screen, in pixels
horizontalOffset: 0, // horizontal offset of the dialog from center screen, in pixels/
repositionOnResize: true, // re-centers the dialog on window resize
overlayOpacity: .01, // transparency level of overlay
overlayColor: '#FFF', // base color of overlay
draggable: true, // make the dialogs draggable (requires UI Draggables plugin)
okButton: '&nbsp;OK&nbsp;', // text for the OK button
cancelButton: '&nbsp;Cancel&nbsp;', // text for the Cancel button
dialogClass: null, // if specified, this class will be applied to all dialogs
// Public methods
alert: function(message, title, callback) {
if( title == null ) title = 'Alert';
$.alerts._show(title, message, null, 'alert', function(result) {
if( callback ) callback(result);
});
},
confirm: function(message, title, callback) {
if( title == null ) title = 'Confirm';
$.alerts._show(title, message, null, 'confirm', function(result) {
if( callback ) callback(result);
});
},
prompt: function(message, value, title, callback) {
if( title == null ) title = 'Prompt';
$.alerts._show(title, message, value, 'prompt', function(result) {
if( callback ) callback(result);
});
},
// Private methods
_show: function(title, msg, value, type, callback) {
$.alerts._hide();
$.alerts._overlay('show');
$("BODY").append(
'<div id="popup_container">' +
'<h1 id="popup_title"></h1>' +
'<div id="popup_content">' +
'<div id="popup_message"></div>' +
'</div>' +
'</div>');
if( $.alerts.dialogClass ) $("#popup_container").addClass($.alerts.dialogClass);
// IE6 Fix
var pos = ($.browser.msie && parseInt($.browser.version) <= 6 ) ? 'absolute' : 'fixed';
$("#popup_container").css({
position: pos,
zIndex: 99999,
padding: 0,
margin: 0
});
$("#popup_title").text(title);
$("#popup_content").addClass(type);
$("#popup_message").text(msg);
$("#popup_message").html( $("#popup_message").text().replace(/\n/g, '<br />') );
$("#popup_container").css({
minWidth: $("#popup_container").outerWidth(),
maxWidth: $("#popup_container").outerWidth()
});
$.alerts._reposition();
$.alerts._maintainPosition(true);
switch( type ) {
case 'alert':
$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /></div>');
$("#popup_ok").click( function() {
$.alerts._hide();
callback(true);
});
$("#popup_ok").focus().keypress( function(e) {
if( e.keyCode == 13 || e.keyCode == 27 ) $("#popup_ok").trigger('click');
});
break;
case 'confirm':
$("#popup_message").after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
$("#popup_ok").click( function() {
$.alerts._hide();
if( callback ) callback(true);
});
$("#popup_cancel").click( function() {
$.alerts._hide();
if( callback ) callback(false);
});
$("#popup_ok").focus();
$("#popup_ok, #popup_cancel").keypress( function(e) {
if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
});
break;
case 'prompt':
$("#popup_message").append('<br /><input type="text" size="30" id="popup_prompt" />').after('<div id="popup_panel"><input type="button" value="' + $.alerts.okButton + '" id="popup_ok" /> <input type="button" value="' + $.alerts.cancelButton + '" id="popup_cancel" /></div>');
$("#popup_prompt").width( $("#popup_message").width() );
$("#popup_ok").click( function() {
var val = $("#popup_prompt").val();
$.alerts._hide();
if( callback ) callback( val );
});
$("#popup_cancel").click( function() {
$.alerts._hide();
if( callback ) callback( null );
});
$("#popup_prompt, #popup_ok, #popup_cancel").keypress( function(e) {
if( e.keyCode == 13 ) $("#popup_ok").trigger('click');
if( e.keyCode == 27 ) $("#popup_cancel").trigger('click');
});
if( value ) $("#popup_prompt").val(value);
$("#popup_prompt").focus().select();
break;
}
// Make draggable
if( $.alerts.draggable ) {
try {
$("#popup_container").draggable({ handle: $("#popup_title") });
$("#popup_title").css({ cursor: 'move' });
} catch(e) { /* requires jQuery UI draggables */ }
}
},
_hide: function() {
$("#popup_container").remove();
$.alerts._overlay('hide');
$.alerts._maintainPosition(false);
},
_overlay: function(status) {
switch( status ) {
case 'show':
$.alerts._overlay('hide');
$("BODY").append('<div id="popup_overlay"></div>');
$("#popup_overlay").css({
position: 'absolute',
zIndex: 99998,
top: '0px',
left: '0px',
width: '100%',
height: $(document).height(),
background: $.alerts.overlayColor,
opacity: $.alerts.overlayOpacity
});
break;
case 'hide':
$("#popup_overlay").remove();
break;
}
},
_reposition: function() {
var top = (($(window).height() / 2) - ($("#popup_container").outerHeight() / 2)) + $.alerts.verticalOffset;
var left = (($(window).width() / 2) - ($("#popup_container").outerWidth() / 2)) + $.alerts.horizontalOffset;
if( top < 0 ) top = 0;
if( left < 0 ) left = 0;
// IE6 fix
if( $.browser.msie && parseInt($.browser.version) <= 6 ) top = top + $(window).scrollTop();
$("#popup_container").css({
top: top + 'px',
left: left + 'px'
});
$("#popup_overlay").height( $(document).height() );
},
_maintainPosition: function(status) {
if( $.alerts.repositionOnResize ) {
switch(status) {
case true:
$(window).bind('resize', function() {
$.alerts._reposition();
});
break;
case false:
$(window).unbind('resize');
break;
}
}
}
}
// Shortuct functions
jAlert = function(message, title, callback) {
$.alerts.alert(message, title, callback);
}
jConfirm = function(message, title, callback) {
$.alerts.confirm(message, title, callback);
};
jPrompt = function(message, value, title, callback) {
$.alerts.prompt(message, value, title, callback);
};
})(jQuery);

View File

@@ -0,0 +1,87 @@
/*!
* Ambiance - Notification Plugin for jQuery
* Version 1.0.1
* @requires jQuery v1.7.2
*
* Copyright (c) 2012 Richard Hsu
* Documentation: http://www.github.com/richardhsu/jquery.ambiance
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
(function($) {
$.fn.ambiance = function(options) {
var defaults = {
title: "",
message: "",
type: "default",
permanent: false,
timeout: 2,
fade: true,
width: 300
};
var options = $.extend(defaults, options);
var note_area = $("#ambiance-notification");
// Construct the new notification.
var note = $(window.document.createElement('div'))
.addClass("ambiance")
.addClass("ambiance-" + options['type']);
note.css({width: options['width']});
// Deal with adding the close feature or not.
if (!options['permanent']) {
note.prepend($(window.document.createElement('a'))
.addClass("ambiance-close")
.attr("href", "#_")
.html("&times;"));
}
// Deal with adding the title if given.
if (options['title'] !== "") {
note.append($(window.document.createElement('div'))
.addClass("ambiance-title")
.append(options['title']));
}
// Append the message (this can also be HTML or even an object!).
note.append(options['message']);
// Add the notification to the notification area.
note_area.append(note);
// Deal with non-permanent note.
if (!options['permanent']) {
if (options['timeout'] != 0) {
if (options['fade']) {
note.delay(options['timeout'] * 1000).fadeOut('slow');
note.queue(function() { $(this).remove(); });
} else {
note.delay(options['timeout'] * 1000)
.queue(function() { $(this).remove(); });
}
}
}
};
$.ambiance = $.fn.ambiance; // Rename for easier calling.
})(jQuery);
$(document).ready(function() {
// Deal with adding the notification area to the page.
if ($("#ambiance-notification").length == 0) {
var note_area = $(window.document.createElement('div'))
.attr("id", "ambiance-notification");
$('body').append(note_area);
}
});
// Deal with close event on a note.
$(document).on("click", ".ambiance-close", function () {
$(this).parent().remove();
return false;
});

View File

@@ -0,0 +1,211 @@
// jQuery Context Menu Plugin
//
// Version 1.01
//
// Cory S.N. LaViska
// A Beautiful Site (http://abeautifulsite.net/)
//
// More info: http://abeautifulsite.net/2008/09/jquery-context-menu-plugin/
//
// Terms of Use
//
// This plugin is dual-licensed under the GNU General Public License
// and the MIT License and is copyright A Beautiful Site, LLC.
//
if(jQuery)( function() {
$.extend($.fn, {
contextMenu: function(o, callback) {
// Defaults
if( o.menu == undefined ) return false;
if( o.inSpeed == undefined ) o.inSpeed = 150;
if( o.outSpeed == undefined ) o.outSpeed = 75;
// 0 needs to be -1 for expected results (no fade)
if( o.inSpeed == 0 ) o.inSpeed = -1;
if( o.outSpeed == 0 ) o.outSpeed = -1;
// Loop each context menu
$(this).each( function() {
var el = $(this);
var offset = $(el).offset();
// Add contextMenu class
$('#' + o.menu).addClass('contextMenu');
// Simulate a true right click
$(this).mousedown( function(e) {
var evt = e;
evt.stopPropagation();
$(this).mouseup( function(e) {
e.stopPropagation();
var srcElement = $(this);
$(this).unbind('mouseup');
if( evt.button == 2 ) {
// Hide context menus that may be showing
$(".contextMenu").hide();
// Get this context menu
var menu = $('#' + o.menu);
if( $(el).hasClass('disabled') ) return false;
// Detect mouse position
var d = {}, x, y;
if( self.innerHeight ) {
d.pageYOffset = self.pageYOffset;
d.pageXOffset = self.pageXOffset;
d.innerHeight = self.innerHeight;
d.innerWidth = self.innerWidth;
} else if( document.documentElement &&
document.documentElement.clientHeight ) {
d.pageYOffset = document.documentElement.scrollTop;
d.pageXOffset = document.documentElement.scrollLeft;
d.innerHeight = document.documentElement.clientHeight;
d.innerWidth = document.documentElement.clientWidth;
} else if( document.body ) {
d.pageYOffset = document.body.scrollTop;
d.pageXOffset = document.body.scrollLeft;
d.innerHeight = document.body.clientHeight;
d.innerWidth = document.body.clientWidth;
}
(e.pageX) ? x = e.pageX : x = e.clientX + d.scrollLeft;
(e.pageY) ? y = e.pageY : y = e.clientY + d.scrollTop;
// Show the menu
$(document).unbind('click');
$(menu).css({ top: y, left: x }).fadeIn(o.inSpeed);
// Hover events
$(menu).find('A').mouseover( function() {
$(menu).find('LI.hover').removeClass('hover');
$(this).parent().addClass('hover');
}).mouseout( function() {
$(menu).find('LI.hover').removeClass('hover');
});
// Keyboard
$(document).keypress( function(e) {
switch( e.keyCode ) {
case 38: // up
if( $(menu).find('LI.hover').size() == 0 ) {
$(menu).find('LI:last').addClass('hover');
} else {
$(menu).find('LI.hover').removeClass('hover').prevAll('LI:not(.disabled)').eq(0).addClass('hover');
if( $(menu).find('LI.hover').size() == 0 ) $(menu).find('LI:last').addClass('hover');
}
break;
case 40: // down
if( $(menu).find('LI.hover').size() == 0 ) {
$(menu).find('LI:first').addClass('hover');
} else {
$(menu).find('LI.hover').removeClass('hover').nextAll('LI:not(.disabled)').eq(0).addClass('hover');
if( $(menu).find('LI.hover').size() == 0 ) $(menu).find('LI:first').addClass('hover');
}
break;
case 13: // enter
$(menu).find('LI.hover A').trigger('click');
break;
case 27: // esc
$(document).trigger('click');
break
}
});
// When items are selected
$('#' + o.menu).find('A').unbind('click');
$('#' + o.menu).find('LI:not(.disabled) A').click( function() {
$(document).unbind('click').unbind('keypress');
$(".contextMenu").hide();
// Callback
if( callback ) callback( $(this).attr('href').substr(1), $(srcElement), {x: x - offset.left, y: y - offset.top, docX: x, docY: y} );
return false;
});
// Hide bindings
setTimeout( function() { // Delay for Mozilla
$(document).click( function() {
$(document).unbind('click').unbind('keypress');
$(menu).fadeOut(o.outSpeed);
return false;
});
}, 0);
}
});
});
// Disable text selection
if( $.browser.mozilla ) {
$('#' + o.menu).each( function() { $(this).css({ 'MozUserSelect' : 'none' }); });
} else if( $.browser.msie ) {
$('#' + o.menu).each( function() { $(this).bind('selectstart.disableTextSelect', function() { return false; }); });
} else {
$('#' + o.menu).each(function() { $(this).bind('mousedown.disableTextSelect', function() { return false; }); });
}
// Disable browser context menu (requires both selectors to work in IE/Safari + FF/Chrome)
$(el).add($('UL.contextMenu')).bind('contextmenu', function() { return false; });
});
return $(this);
},
// Disable context menu items on the fly
disableContextMenuItems: function(o) {
if( o == undefined ) {
// Disable all
$(this).find('LI').addClass('disabled');
return( $(this) );
}
$(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
$(this).find('A[href="' + d[i] + '"]').parent().addClass('disabled');
}
}
});
return( $(this) );
},
// Enable context menu items on the fly
enableContextMenuItems: function(o) {
if( o == undefined ) {
// Enable all
$(this).find('LI.disabled').removeClass('disabled');
return( $(this) );
}
$(this).each( function() {
if( o != undefined ) {
var d = o.split(',');
for( var i = 0; i < d.length; i++ ) {
$(this).find('A[href="' + d[i] + '"]').parent().removeClass('disabled');
}
}
});
return( $(this) );
},
// Disable context menu(s)
disableContextMenu: function() {
$(this).each( function() {
$(this).addClass('disabled');
});
return( $(this) );
},
// Enable context menu(s)
enableContextMenu: function() {
$(this).each( function() {
$(this).removeClass('disabled');
});
return( $(this) );
},
// Destroy context menu(s)
destroyContextMenu: function() {
// Destroy specified context menus
$(this).each( function() {
// Disable action
$(this).unbind('mousedown').unbind('mouseup');
});
return( $(this) );
}
});
})(jQuery);

View File

@@ -0,0 +1,18 @@
/**
* Copyright (c) 2005 - 2010, James Auldridge
* All rights reserved.
*
* Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
* http://code.google.com/p/cookies/wiki/License
*
*/
var jaaulde=window.jaaulde||{};jaaulde.utils=jaaulde.utils||{};jaaulde.utils.cookies=(function(){var resolveOptions,assembleOptionsString,parseCookies,constructor,defaultOptions={expiresAt:null,path:'/',domain:null,secure:false};resolveOptions=function(options){var returnValue,expireDate;if(typeof options!=='object'||options===null){returnValue=defaultOptions;}else
{returnValue={expiresAt:defaultOptions.expiresAt,path:defaultOptions.path,domain:defaultOptions.domain,secure:defaultOptions.secure};if(typeof options.expiresAt==='object'&&options.expiresAt instanceof Date){returnValue.expiresAt=options.expiresAt;}else if(typeof options.hoursToLive==='number'&&options.hoursToLive!==0){expireDate=new Date();expireDate.setTime(expireDate.getTime()+(options.hoursToLive*60*60*1000));returnValue.expiresAt=expireDate;}if(typeof options.path==='string'&&options.path!==''){returnValue.path=options.path;}if(typeof options.domain==='string'&&options.domain!==''){returnValue.domain=options.domain;}if(options.secure===true){returnValue.secure=options.secure;}}return returnValue;};assembleOptionsString=function(options){options=resolveOptions(options);return((typeof options.expiresAt==='object'&&options.expiresAt instanceof Date?'; expires='+options.expiresAt.toGMTString():'')+'; path='+options.path+(typeof options.domain==='string'?'; domain='+options.domain:'')+(options.secure===true?'; secure':''));};parseCookies=function(){var cookies={},i,pair,name,value,separated=document.cookie.split(';'),unparsedValue;for(i=0;i<separated.length;i=i+1){pair=separated[i].split('=');name=pair[0].replace(/^\s*/,'').replace(/\s*$/,'');try
{value=decodeURIComponent(pair[1]);}catch(e1){value=pair[1];}if(typeof JSON==='object'&&JSON!==null&&typeof JSON.parse==='function'){try
{unparsedValue=value;value=JSON.parse(value);}catch(e2){value=unparsedValue;}}cookies[name]=value;}return cookies;};constructor=function(){};constructor.prototype.get=function(cookieName){var returnValue,item,cookies=parseCookies();if(typeof cookieName==='string'){returnValue=(typeof cookies[cookieName]!=='undefined')?cookies[cookieName]:null;}else if(typeof cookieName==='object'&&cookieName!==null){returnValue={};for(item in cookieName){if(typeof cookies[cookieName[item]]!=='undefined'){returnValue[cookieName[item]]=cookies[cookieName[item]];}else
{returnValue[cookieName[item]]=null;}}}else
{returnValue=cookies;}return returnValue;};constructor.prototype.filter=function(cookieNameRegExp){var cookieName,returnValue={},cookies=parseCookies();if(typeof cookieNameRegExp==='string'){cookieNameRegExp=new RegExp(cookieNameRegExp);}for(cookieName in cookies){if(cookieName.match(cookieNameRegExp)){returnValue[cookieName]=cookies[cookieName];}}return returnValue;};constructor.prototype.set=function(cookieName,value,options){if(typeof options!=='object'||options===null){options={};}if(typeof value==='undefined'||value===null){value='';options.hoursToLive=-8760;}else if(typeof value!=='string'){if(typeof JSON==='object'&&JSON!==null&&typeof JSON.stringify==='function'){value=JSON.stringify(value);}else
{throw new Error('cookies.set() received non-string value and could not serialize.');}}var optionsString=assembleOptionsString(options);document.cookie=cookieName+'='+encodeURIComponent(value)+optionsString;};constructor.prototype.del=function(cookieName,options){var allCookies={},name;if(typeof options!=='object'||options===null){options={};}if(typeof cookieName==='boolean'&&cookieName===true){allCookies=this.get();}else if(typeof cookieName==='string'){allCookies[cookieName]=true;}for(name in allCookies){if(typeof name==='string'&&name!==''){this.set(name,null,options);}}};constructor.prototype.test=function(){var returnValue=false,testName='cT',testValue='data';this.set(testName,testValue);if(this.get(testName)===testValue){this.del(testName);returnValue=true;}return returnValue;};constructor.prototype.setOptions=function(options){if(typeof options!=='object'){options=null;}defaultOptions=resolveOptions(options);};return new constructor();})();(function(){if(window.jQuery){(function($){$.cookies=jaaulde.utils.cookies;var extensions={cookify:function(options){return this.each(function(){var i,nameAttrs=['name','id'],name,$this=$(this),value;for(i in nameAttrs){if(!isNaN(i)){name=$this.attr(nameAttrs[i]);if(typeof name==='string'&&name!==''){if($this.is(':checkbox, :radio')){if($this.attr('checked')){value=$this.val();}}else if($this.is(':input')){value=$this.val();}else
{value=$this.html();}if(typeof value!=='string'||value===''){value=null;}$.cookies.set(name,value,options);break;}}}});},cookieFill:function(){return this.each(function(){var n,getN,nameAttrs=['name','id'],name,$this=$(this),value;getN=function(){n=nameAttrs.pop();return!!n;};while(getN()){name=$this.attr(n);if(typeof name==='string'&&name!==''){value=$.cookies.get(name);if(value!==null){if($this.is(':checkbox, :radio')){if($this.val()===value){$this.attr('checked','checked');}else
{$this.removeAttr('checked');}}else if($this.is(':input')){$this.val(value);}else
{$this.html(value);}}break;}}});},cookieBind:function(options){return this.each(function(){var $this=$(this);$this.cookieFill().change(function(){$this.cookify(options);});});}};$.each(extensions,function(i){$.fn[i]=this;});})(window.jQuery);}})();

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,727 @@
/* jshint forin:true, noarg:true, noempty:true, eqeqeq:true, boss:true, undef:true, curly:true, browser:true, jquery:true */
/*
* jQuery MultiSelect UI Widget 1.14pre
* Copyright (c) 2012 Eric Hynds
*
* http://www.erichynds.com/jquery/jquery-ui-multiselect-widget/
*
* Depends:
* - jQuery 1.4.2+
* - jQuery UI 1.8 widget factory
*
* Optional:
* - jQuery UI effects
* - jQuery UI position utility
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($, undefined) {
var multiselectID = 0;
var $doc = $(document);
$.widget("ech.multiselect", {
// default options
options: {
header: true,
height: 175,
minWidth: 225,
classes: '',
checkAllText: 'Check all',
uncheckAllText: 'Uncheck all',
noneSelectedText: 'Select options',
selectedText: '# selected',
selectedList: 0,
show: null,
hide: null,
autoOpen: false,
multiple: true,
position: {}
},
_create: function() {
var el = this.element.hide();
var o = this.options;
this.speed = $.fx.speeds._default; // default speed for effects
this._isOpen = false; // assume no
// create a unique namespace for events that the widget
// factory cannot unbind automatically. Use eventNamespace if on
// jQuery UI 1.9+, and otherwise fallback to a custom string.
this._namespaceID = this.eventNamespace || ('multiselect' + multiselectID);
var button = (this.button = $('<button type="button"><span class="ui-icon ui-icon-triangle-2-n-s"></span></button>'))
.addClass('ui-multiselect ui-widget ui-state-default ui-corner-all')
.addClass(o.classes)
.attr({ 'title':el.attr('title'), 'aria-haspopup':true, 'tabIndex':el.attr('tabIndex') })
.insertAfter(el),
buttonlabel = (this.buttonlabel = $('<span />'))
.html(o.noneSelectedText)
.appendTo(button),
menu = (this.menu = $('<div />'))
.addClass('ui-multiselect-menu ui-widget ui-widget-content ui-corner-all')
.addClass(o.classes)
.appendTo(document.body),
header = (this.header = $('<div />'))
.addClass('ui-widget-header ui-corner-all ui-multiselect-header ui-helper-clearfix')
.appendTo(menu),
headerLinkContainer = (this.headerLinkContainer = $('<ul />'))
.addClass('ui-helper-reset')
.html(function() {
if(o.header === true) {
return '<li><a class="ui-multiselect-all" href="#"><span class="ui-icon ui-icon-check"></span><span>' + o.checkAllText + '</span></a></li><li><a class="ui-multiselect-none" href="#"><span class="ui-icon ui-icon-closethick"></span><span>' + o.uncheckAllText + '</span></a></li>';
} else if(typeof o.header === "string") {
return '<li>' + o.header + '</li>';
} else {
return '';
}
})
.append('<li class="ui-multiselect-close"><a href="#" class="ui-multiselect-close"><span class="ui-icon ui-icon-circle-close"></span></a></li>')
.appendTo(header),
checkboxContainer = (this.checkboxContainer = $('<ul />'))
.addClass('ui-multiselect-checkboxes ui-helper-reset')
.appendTo(menu);
// perform event bindings
this._bindEvents();
// build menu
this.refresh(true);
// some addl. logic for single selects
if(!o.multiple) {
menu.addClass('ui-multiselect-single');
}
// bump unique ID
multiselectID++;
},
_init: function() {
if(this.options.header === false) {
this.header.hide();
}
if(!this.options.multiple) {
this.headerLinkContainer.find('.ui-multiselect-all, .ui-multiselect-none').hide();
}
if(this.options.autoOpen) {
this.open();
}
if(this.element.is(':disabled')) {
this.disable();
}
},
refresh: function(init) {
var el = this.element;
var o = this.options;
var menu = this.menu;
var checkboxContainer = this.checkboxContainer;
var optgroups = [];
var html = "";
var id = el.attr('id') || multiselectID++; // unique ID for the label & option tags
// build items
el.find('option').each(function(i) {
var $this = $(this);
var parent = this.parentNode;
var title = this.innerHTML;
var description = this.title;
var value = this.value;
var inputID = 'ui-multiselect-' + (this.id || id + '-option-' + i);
var isDisabled = this.disabled;
var isSelected = this.selected;
var labelClasses = [ 'ui-corner-all' ];
var liClasses = (isDisabled ? 'ui-multiselect-disabled ' : ' ') + this.className;
var optLabel;
// is this an optgroup?
if(parent.tagName === 'OPTGROUP') {
optLabel = parent.getAttribute('label');
// has this optgroup been added already?
if($.inArray(optLabel, optgroups) === -1) {
html += '<li class="ui-multiselect-optgroup-label ' + parent.className + '"><a href="#">' + optLabel + '</a></li>';
optgroups.push(optLabel);
}
}
if(isDisabled) {
labelClasses.push('ui-state-disabled');
}
// browsers automatically select the first option
// by default with single selects
if(isSelected && !o.multiple) {
labelClasses.push('ui-state-active');
}
html += '<li class="' + liClasses + '">';
// create the label
html += '<label for="' + inputID + '" title="' + description + '" class="' + labelClasses.join(' ') + '">';
html += '<input id="' + inputID + '" name="multiselect_' + id + '" type="' + (o.multiple ? "checkbox" : "radio") + '" value="' + value + '" title="' + title + '"';
// pre-selected?
if(isSelected) {
html += ' checked="checked"';
html += ' aria-selected="true"';
}
// disabled?
if(isDisabled) {
html += ' disabled="disabled"';
html += ' aria-disabled="true"';
}
// add the title and close everything off
html += ' /><span>' + title + '</span></label></li>';
});
// insert into the DOM
checkboxContainer.html(html);
// cache some moar useful elements
this.labels = menu.find('label');
this.inputs = this.labels.children('input');
// set widths
this._setButtonWidth();
this._setMenuWidth();
// remember default value
this.button[0].defaultValue = this.update();
// broadcast refresh event; useful for widgets
if(!init) {
this._trigger('refresh');
}
},
// updates the button text. call refresh() to rebuild
update: function() {
var o = this.options;
var $inputs = this.inputs;
var $checked = $inputs.filter(':checked');
var numChecked = $checked.length;
var value;
if(numChecked === 0) {
value = o.noneSelectedText;
} else {
if($.isFunction(o.selectedText)) {
value = o.selectedText.call(this, numChecked, $inputs.length, $checked.get());
} else if(/\d/.test(o.selectedList) && o.selectedList > 0 && numChecked <= o.selectedList) {
value = $checked.map(function() { return $(this).next().html(); }).get().join(', ');
} else {
value = o.selectedText.replace('#', numChecked).replace('#', $inputs.length);
}
}
this._setButtonValue(value);
return value;
},
// this exists as a separate method so that the developer
// can easily override it.
_setButtonValue: function(value) {
this.buttonlabel.text(value);
},
// binds events
_bindEvents: function() {
var self = this;
var button = this.button;
function clickHandler() {
self[ self._isOpen ? 'close' : 'open' ]();
return false;
}
// webkit doesn't like it when you click on the span :(
button
.find('span')
.bind('click.multiselect', clickHandler);
// button events
button.bind({
click: clickHandler,
keypress: function(e) {
switch(e.which) {
case 27: // esc
case 38: // up
case 37: // left
self.close();
break;
case 39: // right
case 40: // down
self.open();
break;
}
},
mouseenter: function() {
if(!button.hasClass('ui-state-disabled')) {
$(this).addClass('ui-state-hover');
}
},
mouseleave: function() {
$(this).removeClass('ui-state-hover');
},
focus: function() {
if(!button.hasClass('ui-state-disabled')) {
$(this).addClass('ui-state-focus');
}
},
blur: function() {
$(this).removeClass('ui-state-focus');
}
});
// header links
this.header.delegate('a', 'click.multiselect', function(e) {
// close link
if($(this).hasClass('ui-multiselect-close')) {
self.close();
// check all / uncheck all
} else {
self[$(this).hasClass('ui-multiselect-all') ? 'checkAll' : 'uncheckAll']();
}
e.preventDefault();
});
// optgroup label toggle support
this.menu.delegate('li.ui-multiselect-optgroup-label a', 'click.multiselect', function(e) {
e.preventDefault();
var $this = $(this);
var $inputs = $this.parent().nextUntil('li.ui-multiselect-optgroup-label').find('input:visible:not(:disabled)');
var nodes = $inputs.get();
var label = $this.parent().text();
// trigger event and bail if the return is false
if(self._trigger('beforeoptgrouptoggle', e, { inputs:nodes, label:label }) === false) {
return;
}
// toggle inputs
self._toggleChecked(
$inputs.filter(':checked').length !== $inputs.length,
$inputs
);
self._trigger('optgrouptoggle', e, {
inputs: nodes,
label: label,
checked: nodes[0].checked
});
})
.delegate('label', 'mouseenter.multiselect', function() {
if(!$(this).hasClass('ui-state-disabled')) {
self.labels.removeClass('ui-state-hover');
$(this).addClass('ui-state-hover').find('input').focus();
}
})
.delegate('label', 'keydown.multiselect', function(e) {
e.preventDefault();
switch(e.which) {
case 9: // tab
case 27: // esc
self.close();
break;
case 38: // up
case 40: // down
case 37: // left
case 39: // right
self._traverse(e.which, this);
break;
case 13: // enter
$(this).find('input')[0].click();
break;
}
})
.delegate('input[type="checkbox"], input[type="radio"]', 'click.multiselect', function(e) {
var $this = $(this);
var val = this.value;
var checked = this.checked;
var tags = self.element.find('option');
// bail if this input is disabled or the event is cancelled
if(this.disabled || self._trigger('click', e, { value: val, text: this.title, checked: checked }) === false) {
e.preventDefault();
return;
}
// make sure the input has focus. otherwise, the esc key
// won't close the menu after clicking an item.
$this.focus();
// toggle aria state
$this.attr('aria-selected', checked);
// change state on the original option tags
tags.each(function() {
if(this.value === val) {
this.selected = checked;
} else if(!self.options.multiple) {
this.selected = false;
}
});
// some additional single select-specific logic
if(!self.options.multiple) {
self.labels.removeClass('ui-state-active');
$this.closest('label').toggleClass('ui-state-active', checked);
// close menu
self.close();
}
// fire change on the select box
self.element.trigger("change");
// setTimeout is to fix multiselect issue #14 and #47. caused by jQuery issue #3827
// http://bugs.jquery.com/ticket/3827
setTimeout($.proxy(self.update, self), 10);
});
// close each widget when clicking on any other element/anywhere else on the page
$doc.bind('mousedown.' + this._namespaceID, function(e) {
if(self._isOpen && !$.contains(self.menu[0], e.target) && !$.contains(self.button[0], e.target) && e.target !== self.button[0]) {
self.close();
}
});
// deal with form resets. the problem here is that buttons aren't
// restored to their defaultValue prop on form reset, and the reset
// handler fires before the form is actually reset. delaying it a bit
// gives the form inputs time to clear.
$(this.element[0].form).bind('reset.multiselect', function() {
setTimeout($.proxy(self.refresh, self), 10);
});
},
// set button width
_setButtonWidth: function() {
var width = this.element.outerWidth();
var o = this.options;
if(/\d/.test(o.minWidth) && width < o.minWidth) {
width = o.minWidth;
}
// set widths
this.button.outerWidth(width);
},
// set menu width
_setMenuWidth: function() {
var m = this.menu;
m.outerWidth(this.button.outerWidth());
},
// move up or down within the menu
_traverse: function(which, start) {
var $start = $(start);
var moveToLast = which === 38 || which === 37;
// select the first li that isn't an optgroup label / disabled
$next = $start.parent()[moveToLast ? 'prevAll' : 'nextAll']('li:not(.ui-multiselect-disabled, .ui-multiselect-optgroup-label)')[ moveToLast ? 'last' : 'first']();
// if at the first/last element
if(!$next.length) {
var $container = this.menu.find('ul').last();
// move to the first/last
this.menu.find('label')[ moveToLast ? 'last' : 'first' ]().trigger('mouseover');
// set scroll position
$container.scrollTop(moveToLast ? $container.height() : 0);
} else {
$next.find('label').trigger('mouseover');
}
},
// This is an internal function to toggle the checked property and
// other related attributes of a checkbox.
//
// The context of this function should be a checkbox; do not proxy it.
_toggleState: function(prop, flag) {
return function() {
if(!this.disabled) {
this[ prop ] = flag;
}
if(flag) {
this.setAttribute('aria-selected', true);
} else {
this.removeAttribute('aria-selected');
}
};
},
_toggleChecked: function(flag, group) {
var $inputs = (group && group.length) ? group : this.inputs;
var self = this;
// toggle state on inputs
$inputs.each(this._toggleState('checked', flag));
// give the first input focus
$inputs.eq(0).focus();
// update button text
this.update();
// gather an array of the values that actually changed
var values = $inputs.map(function() {
return this.value;
}).get();
// toggle state on original option tags
this.element
.find('option')
.each(function() {
if(!this.disabled && $.inArray(this.value, values) > -1) {
self._toggleState('selected', flag).call(this);
}
});
// trigger the change event on the select
if($inputs.length) {
this.element.trigger("change");
}
},
_toggleDisabled: function(flag) {
this.button.attr({ 'disabled':flag, 'aria-disabled':flag })[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
var inputs = this.menu.find('input');
var key = "ech-multiselect-disabled";
if(flag) {
// remember which elements this widget disabled (not pre-disabled)
// elements, so that they can be restored if the widget is re-enabled.
inputs = inputs.filter(':enabled').data(key, true)
} else {
inputs = inputs.filter(function() {
return $.data(this, key) === true;
}).removeData(key);
}
inputs
.attr({ 'disabled':flag, 'arial-disabled':flag })
.parent()[ flag ? 'addClass' : 'removeClass' ]('ui-state-disabled');
this.element.attr({
'disabled':flag,
'aria-disabled':flag
});
},
// open the menu
open: function(e) {
var self = this;
var button = this.button;
var menu = this.menu;
var speed = this.speed;
var o = this.options;
var args = [];
// bail if the multiselectopen event returns false, this widget is disabled, or is already open
if(this._trigger('beforeopen') === false || button.hasClass('ui-state-disabled') || this._isOpen) {
return;
}
var $container = menu.find('ul').last();
var effect = o.show;
// figure out opening effects/speeds
if($.isArray(o.show)) {
effect = o.show[0];
speed = o.show[1] || self.speed;
}
// if there's an effect, assume jQuery UI is in use
// build the arguments to pass to show()
if(effect) {
args = [ effect, speed ];
}
// set the scroll of the checkbox container
$container.scrollTop(0).height(o.height);
// positon
this.position();
// show the menu, maybe with a speed/effect combo
$.fn.show.apply(menu, args);
// select the first option
// triggering both mouseover and mouseover because 1.4.2+ has a bug where triggering mouseover
// will actually trigger mouseenter. the mouseenter trigger is there for when it's eventually fixed
this.labels.eq(0).trigger('mouseover').trigger('mouseenter').find('input').trigger('focus');
button.addClass('ui-state-active');
this._isOpen = true;
this._trigger('open');
},
// close the menu
close: function() {
if(this._trigger('beforeclose') === false) {
return;
}
var o = this.options;
var effect = o.hide;
var speed = this.speed;
var args = [];
// figure out opening effects/speeds
if($.isArray(o.hide)) {
effect = o.hide[0];
speed = o.hide[1] || this.speed;
}
if(effect) {
args = [ effect, speed ];
}
$.fn.hide.apply(this.menu, args);
this.button.removeClass('ui-state-active').trigger('blur').trigger('mouseleave');
this._isOpen = false;
this._trigger('close');
},
enable: function() {
this._toggleDisabled(false);
},
disable: function() {
this._toggleDisabled(true);
},
checkAll: function(e) {
this._toggleChecked(true);
this._trigger('checkAll');
},
uncheckAll: function() {
this._toggleChecked(false);
this._trigger('uncheckAll');
},
getChecked: function() {
return this.menu.find('input').filter(':checked');
},
destroy: function() {
// remove classes + data
$.Widget.prototype.destroy.call(this);
// unbind events
$doc.unbind(this._namespaceID);
this.button.remove();
this.menu.remove();
this.element.show();
return this;
},
isOpen: function() {
return this._isOpen;
},
widget: function() {
return this.menu;
},
getButton: function() {
return this.button;
},
position: function() {
var o = this.options;
// use the position utility if it exists and options are specifified
if($.ui.position && !$.isEmptyObject(o.position)) {
o.position.of = o.position.of || this.button;
this.menu
.show()
.position(o.position)
.hide();
// otherwise fallback to custom positioning
} else {
var pos = this.button.offset();
this.menu.css({
top: pos.top + this.button.outerHeight(),
left: pos.left
});
}
},
// react to option changes after initialization
_setOption: function(key, value) {
var menu = this.menu;
switch(key) {
case 'header':
menu.find('div.ui-multiselect-header')[value ? 'show' : 'hide']();
break;
case 'checkAllText':
menu.find('a.ui-multiselect-all span').eq(-1).text(value);
break;
case 'uncheckAllText':
menu.find('a.ui-multiselect-none span').eq(-1).text(value);
break;
case 'height':
menu.find('ul').last().height(parseInt(value, 10));
break;
case 'minWidth':
this.options[key] = parseInt(value, 10);
this._setButtonWidth();
this._setMenuWidth();
break;
case 'selectedText':
case 'selectedList':
case 'noneSelectedText':
this.options[key] = value; // these all needs to update immediately for the update() call
this.update();
break;
case 'classes':
menu.add(this.button).removeClass(this.options.classes).addClass(value);
break;
case 'multiple':
menu.toggleClass('ui-multiselect-single', !value);
this.options.multiple = value;
this.element[0].multiple = value;
this.refresh();
break;
case 'position':
this.position();
}
$.Widget.prototype._setOption.apply(this, arguments);
}
});
})(jQuery);

View File

@@ -0,0 +1,265 @@
/**
* noty - jQuery Notification Plugin v1.2.1
* Contributors: https://github.com/needim/noty/graphs/contributors
*
* Examples and Documentation - http://needim.github.com/noty/
*
* Licensed under the MIT licenses:
* http://www.opensource.org/licenses/mit-license.php
*
**/
(function($) {
$.noty = function(options, customContainer) {
var base = {};
var $noty = null;
var isCustom = false;
base.init = function(options) {
base.options = $.extend({}, $.noty.defaultOptions, options);
base.options.type = base.options.cssPrefix+base.options.type;
base.options.id = base.options.type+'_'+new Date().getTime();
base.options.layout = base.options.cssPrefix+'layout_'+base.options.layout;
if (base.options.custom.container) customContainer = base.options.custom.container;
isCustom = ($.type(customContainer) === 'object') ? true : false;
return base.addQueue();
};
// Push notification to queue
base.addQueue = function() {
var isGrowl = ($.inArray(base.options.layout, $.noty.growls) == -1) ? false : true;
if (!isGrowl) (base.options.force) ? $.noty.queue.unshift({options: base.options}) : $.noty.queue.push({options: base.options});
return base.render(isGrowl);
};
// Render the noty
base.render = function(isGrowl) {
// Layout spesific container settings
var container = (isCustom) ? customContainer.addClass(base.options.theme+' '+base.options.layout+' noty_custom_container') : $('body');
if (isGrowl) {
if ($('ul.noty_cont.' + base.options.layout).length == 0)
container.prepend($('<ul/>').addClass('noty_cont ' + base.options.layout));
container = $('ul.noty_cont.' + base.options.layout);
} else {
if ($.noty.available) {
var fromQueue = $.noty.queue.shift(); // Get noty from queue
if ($.type(fromQueue) === 'object') {
$.noty.available = false;
base.options = fromQueue.options;
} else {
$.noty.available = true; // Queue is over
return base.options.id;
}
} else {
return base.options.id;
}
}
base.container = container;
// Generating noty bar
base.bar = $('<div class="noty_bar"/>').attr('id', base.options.id).addClass(base.options.theme+' '+base.options.layout+' '+base.options.type);
$noty = base.bar;
$noty.append(base.options.template).find('.noty_text').html(base.options.text);
$noty.data('noty_options', base.options);
// Close button display
(base.options.closeButton) ? $noty.addClass('noty_closable').find('.noty_close').show() : $noty.find('.noty_close').remove();
// Bind close event to button
$noty.find('.noty_close').bind('click', function() { $noty.trigger('noty.close'); });
// If we have a button we must disable closeOnSelfClick and closeOnSelfOver option
if (base.options.buttons) base.options.closeOnSelfClick = base.options.closeOnSelfOver = false;
// Close on self click
if (base.options.closeOnSelfClick) $noty.bind('click', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer');
// Close on self mouseover
if (base.options.closeOnSelfOver) $noty.bind('mouseover', function() { $noty.trigger('noty.close'); }).css('cursor', 'pointer');
// Set buttons if available
if (base.options.buttons) {
$buttons = $('<div/>').addClass('noty_buttons');
$noty.find('.noty_message').append($buttons);
$.each(base.options.buttons, function(i, button) {
bclass = (button.type) ? button.type : 'gray';
$button = $('<button/>').addClass(bclass).html(button.text).appendTo($noty.find('.noty_buttons'))
.bind('click', function() {
if ($.isFunction(button.click)) {
button.click.call($button, $noty);
}
});
});
}
return base.show(isGrowl);
};
base.show = function(isGrowl) {
// is Modal?
if (base.options.modal) $('<div/>').addClass('noty_modal').addClass(base.options.theme).prependTo($('body')).fadeIn('fast');
$noty.close = function() { return this.trigger('noty.close'); };
// Prepend noty to container
(isGrowl) ? base.container.prepend($('<li/>').append($noty)) : base.container.prepend($noty);
// topCenter and center specific options
if (base.options.layout == 'noty_layout_topCenter' || base.options.layout == 'noty_layout_center') {
$.noty.reCenter($noty);
}
$noty.bind('noty.setText', function(event, text) {
$noty.find('.noty_text').html(text);
if (base.options.layout == 'noty_layout_topCenter' || base.options.layout == 'noty_layout_center') {
$.noty.reCenter($noty);
}
});
$noty.bind('noty.setType', function(event, type) {
$noty.removeClass($noty.data('noty_options').type);
type = $noty.data('noty_options').cssPrefix+type;
$noty.data('noty_options').type = type;
$noty.addClass(type);
if (base.options.layout == 'noty_layout_topCenter' || base.options.layout == 'noty_layout_center') {
$.noty.reCenter($noty);
}
});
$noty.bind('noty.getId', function(event) {
return $noty.data('noty_options').id;
});
// Bind close event
$noty.one('noty.close', function(event) {
var options = $noty.data('noty_options');
if(options.onClose){options.onClose();}
// Modal Cleaning
if (options.modal) $('.noty_modal').fadeOut('fast', function() { $(this).remove(); });
$noty.clearQueue().stop().animate(
$noty.data('noty_options').animateClose,
$noty.data('noty_options').speed,
$noty.data('noty_options').easing,
$noty.data('noty_options').onClosed)
.promise().done(function() {
// Layout spesific cleaning
if ($.inArray($noty.data('noty_options').layout, $.noty.growls) > -1) {
$noty.parent().remove();
} else {
$noty.remove();
// queue render
$.noty.available = true;
base.render(false);
}
});
});
// Start the show
if(base.options.onShow){base.options.onShow();}
$noty.animate(base.options.animateOpen, base.options.speed, base.options.easing, base.options.onShown);
// If noty is have a timeout option
if (base.options.timeout) $noty.delay(base.options.timeout).promise().done(function() { $noty.trigger('noty.close'); });
return base.options.id;
};
// Run initializer
return base.init(options);
};
// API
$.noty.get = function(id) { return $('#'+id); };
$.noty.close = function(id) {
//remove from queue if not already visible
for(var i=0;i<$.noty.queue.length;) {
if($.noty.queue[i].options.id==id)
$.noty.queue.splice(id,1);
else
i++;
}
//close if already visible
$.noty.get(id).trigger('noty.close');
};
$.noty.setText = function(id, text) {
$.noty.get(id).trigger('noty.setText', text);
};
$.noty.setType = function(id, type) {
$.noty.get(id).trigger('noty.setType', type);
};
$.noty.closeAll = function() {
$.noty.clearQueue();
$('.noty_bar').trigger('noty.close');
};
$.noty.reCenter = function(noty) {
noty.css({'left': ($(window).width() - noty.outerWidth()) / 2 + 'px'});
};
$.noty.clearQueue = function() {
$.noty.queue = [];
};
var windowAlert = window.alert;
$.noty.consumeAlert = function(options){
window.alert = function(text){
if(options){options.text = text;}
else{options = {text:text};}
$.noty(options);
};
}
$.noty.stopConsumeAlert = function(){
window.alert = windowAlert;
}
$.noty.queue = [];
$.noty.growls = ['noty_layout_topLeft', 'noty_layout_topRight', 'noty_layout_bottomLeft', 'noty_layout_bottomRight'];
$.noty.available = true;
$.noty.defaultOptions = {
layout: 'top',
theme: 'noty_theme_default',
animateOpen: {height: 'toggle'},
animateClose: {height: 'toggle'},
easing: 'swing',
text: '',
type: 'alert',
speed: 500,
timeout: 5000,
closeButton: false,
closeOnSelfClick: true,
closeOnSelfOver: false,
force: false,
onShow: false,
onShown: false,
onClose: false,
onClosed: false,
buttons: false,
modal: false,
template: '<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',
cssPrefix: 'noty_',
custom: {
container: null
}
};
$.fn.noty = function(options) {
return this.each(function() {
(new $.noty(options, $(this)));
});
};
})(jQuery);
//Helper
function noty(options) {
return jQuery.noty(options); // returns an id
}

View File

@@ -0,0 +1,9 @@
/**
* jQuery Generic Plugin Module
* Version 0.1
* Copyright (c) 2011 Cyntax Technologies - http://cyntaxtech.com
* Licensed under the Cyntax Open Technology License
* http://code.cyntax.com/licenses/cyntax-open-technology
*/
(function(a){a.jQueryPlugin=function(b){a.fn[b]=function(c){var d=Array.prototype.slice.call(arguments,1);if(this.length){return this.each(function(){var e=a.data(this,b)||a.data(this,b,(new cyntax.plugins[b](this,c))._init());if(typeof c==="string"){c=c.replace(/^_/,"");if(e[c]){e[c].apply(e,d)}}})}}}})(jQuery);var cyntax={plugins:{}}

View File

@@ -0,0 +1,37 @@
/*
Sleep by Mark Hughes (AKA huzi8t9)
http://www.360Gamer.net/
Usage:
$.sleep ( 3, function()
{
alert ( "I slept for 3 seconds!" );
});
Use at free will, distribute free of charge
*/
;(function(jQuery)
{
var _sleeptimer;
jQuery.sleep = function( time2sleep, callback )
{
jQuery.sleep._sleeptimer = time2sleep;
jQuery.sleep._cback = callback;
jQuery.sleep.timer = setInterval('jQuery.sleep.count()', 1000);
}
jQuery.extend (jQuery.sleep, {
current_i : 1,
_sleeptimer : 0,
_cback : null,
timer : null,
count : function()
{
if ( jQuery.sleep.current_i === jQuery.sleep._sleeptimer )
{
clearInterval(jQuery.sleep.timer);
jQuery.sleep._cback.call(this);
}
jQuery.sleep.current_i++;
}
});
})(jQuery);

View File

@@ -0,0 +1,14 @@
/**
* jQuery Timer Plugin
* Project page - http://code.cyntaxtech.com/plugins/jquery-timer
* Version 0.1.1
* Copyright (c) 2011 Cyntax Technologies - http://cyntaxtech.com
* dependencies: jquery.plugin.js
* Licensed under the Cyntax Open Technology License
* http://code.cyntax.com/licenses/cyntax-open-technology
* ------------------------------------
* For details, please visit:
* http://code.cyntaxtech.com/plugins/jquery-timer
*/
(function(a){cyntax.plugins.timer=function(b,c){this.$this=a(b);this.options=a.extend({},this.defaults,c);this.timer_info={id:null,index:null,state:0}};cyntax.plugins.timer.prototype={defaults:{delay:1e3,repeat:false,autostart:true,callback:null,url:"",post:""},_init:function(){if(this.options.autostart){this.timer_info.state=1;this.timer_info.id=setTimeout(a.proxy(this._timer_fn,this),this.options.delay)}return this},_timer_fn:function(){if(typeof this.options.callback=="function")a.proxy(this.options.callback,this.$this).call(this,++this.timer_info.index);else if(typeof this.options.url=="string"){ajax_options={url:this.options.url,context:this,type:typeof this.options.post=="string"&&typeof this.options.post!=""==""?"POST":"GET",success:function(a,b,c){this.$this.html(a)}};if(typeof this.options.post=="string"&&typeof this.options.post!="")ajax_options.data=this.options.post;a.ajax(ajax_options)}if(this.options.repeat&&this.timer_info.state==1&&(typeof this.options.repeat=="boolean"||parseInt(this.options.repeat)>this.timer_info.index))this.timer_info.id=setTimeout(a.proxy(this._timer_fn,this),this.options.delay);else this.timer_id=null},start:function(){if(this.timer_info.state==0){this.timer_info.index=0;this.timer_info.state=1;this.timer_id=setTimeout(a.proxy(this._timer_fn,this),this.options.delay)}},stop:function(){if(this.timer_info.state==1&&this.timer_info.id){clearTimeout(this.timer_info.id);this.timer_id=null}this.timer_info.state=0},pause:function(){if(this.timer_info.state==1&&this.timer_info.id)clearTimeout(this.timer_info.id);this.timer_info.state=0},resume:function(){this.timer_info.state=1;this.timer_id=setTimeout(a.proxy(this._timer_fn,this),this.options.delay)}};a.jQueryPlugin("timer")})(jQuery)

View File

@@ -0,0 +1,2 @@
/*! waitForImages jQuery Plugin 2013-07-20 */
!function(a){var b="waitForImages";a.waitForImages={hasImageProperties:["backgroundImage","listStyleImage","borderImage","borderCornerImage","cursor"]},a.expr[":"].uncached=function(b){if(!a(b).is('img[src!=""]'))return!1;var c=new Image;return c.src=b.src,!c.complete},a.fn.waitForImages=function(c,d,e){var f=0,g=0;if(a.isPlainObject(arguments[0])&&(e=arguments[0].waitForAll,d=arguments[0].each,c=arguments[0].finished),c=c||a.noop,d=d||a.noop,e=!!e,!a.isFunction(c)||!a.isFunction(d))throw new TypeError("An invalid callback was supplied.");return this.each(function(){var h=a(this),i=[],j=a.waitForImages.hasImageProperties||[],k=/url\(\s*(['"]?)(.*?)\1\s*\)/g;e?h.find("*").addBack().each(function(){var b=a(this);b.is("img:uncached")&&i.push({src:b.attr("src"),element:b[0]}),a.each(j,function(a,c){var d,e=b.css(c);if(!e)return!0;for(;d=k.exec(e);)i.push({src:d[2],element:b[0]})})}):h.find("img:uncached").each(function(){i.push({src:this.src,element:this})}),f=i.length,g=0,0===f&&c.call(h[0]),a.each(i,function(e,i){var j=new Image;a(j).on("load."+b+" error."+b,function(a){return g++,d.call(i.element,g,f,"load"==a.type),g==f?(c.call(h[0]),!1):void 0}),j.src=i.src})})}}(jQuery);

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,210 @@
/*
* Drag and drop for Raphael elements.
*
* Original Author: Gabe Hollombe. Rewritten several times over by Clifford Heath.
* (c) Copyright. Subject to MIT License.
*
* You need to include jquery and Raphael first.
*
* When you call draggable() on any Raphael object, it becomes a handle that can start a drag.
* A mousedown on the handle followed by enough motion causes a drag to start.
*
* The dragged object may be the handle itself, another object defined in the options to
* draggable(), or an object returned from the handle's dragStart method (if defined).
*
* The drag proceeds by calling drag_obj.dragUpdate for each mouse motion, see below.
* If no dragUpdate is defined, a Raphael translate() is used to provide simple motion.
*
* If the Escape key is pressed during the drag, the motion is reverted and the drag stops.
* In this case, dragCancel will be called, see below.
*
* When a drag finished normally, dragFinish is called as defined below.
*
* Options:
* drag_obj
* A click on the handle will start a drag on this object.
* Otherwise handle will be dragged, unless handle.dragStart()
* returns a different draggable object.
* right_button
* unset means drag using either button, otherwise false/true means left/right only.
* reluctance
* Number of pixels of motion before a drag starts (default 3).
*
* Optional method on handle. The events are passed so you can see the modifier keys.
* dragStart(x, y, mousedownevent, mousemoveevent)
* called (after reluctance) with the mousedown event and canvas location.
* Must return the object to drag. Good place to call toFront so the drag_obj doesn't hide.
*
* Optional methods on drag_obj. The event is passed so you can see the modifier keys.
* dragUpdate(dragging_over, dx, dy, event)
* dragging_over: the object under the cursor (after hiding drag_obj)
* dx,dy: the number of units of motion
* event: the mousemotion event
* dragFinish(dropped_on, x, y, event)
* dropped_on: the object under the cursor (after hiding drag_obj)
* x,y: the page location
* event: the mouseup event
* dragCancel()
* called if the drag is cancelled
*/
Raphael.el.draggable = function(options) {
var handle = this; // The object you click on
if (!options) options = {};
// If you define drag_obj to be null, you must provide a dragStart that returns one:
var drag_obj = typeof options.drag_obj !== 'undefined' ? options.drag_obj : handle;
// Set right_button to true for right-click dragging only, to false for left-click only. Otherwise you get both.
var right_button = options.right_button;
// Check that this is an ok thing to even think about doing
if (!(handle.node && handle.node.raphael)) {
alert(handle+' is not a Raphael object so you can\'t make it draggable');
return;
}
if (drag_obj && !(drag_obj.node && drag_obj.node.raphael)) {
alert(drag_obj+' is not a Raphael object so you can\'t make it draggable');
return;
}
// options.reluctance is the number of pixels of motion before a drag will start:
var reluctance = options.reluctance;
if (typeof reluctance == 'undefined') reluctance = 3;
var skip_click;
var mousedown = function(event) {
if (typeof right_button != 'undefined' && (right_button === false) === (event.button > 1))
return true;
skip_click = false; // Used to skip a click after dragging
var started = false; // Has the drag started?
var start_event = event; // The starting mousedown
var last_x = event.pageX, last_y = event.pageY; // Where did we move from last?
// Figure out what object (other than drag_obj) is under the pointer
var over = function(event) {
var paper = handle.paper || drag_obj.paper;
if (!paper) return null; // Something was deleted
if (drag_obj) drag_obj.hide();
// Unfortunately Opera's elementFromPoint seems to be hopelessly broken in SVG
var dragging_over = document.elementFromPoint(event.pageX, event.pageY);
if (drag_obj) drag_obj.show();
if (!dragging_over)
return null;
if (dragging_over.nodeType == 3)
return dragging_over.parentNode; // Safari/Opera
if (dragging_over.tagName != 'svg' && dragging_over == paper.canvas.parentNode)
return paper.canvas; // Safari
if (dragging_over == paper.canvas)
return dragging_over;
if (!dragging_over.raphael)
return dragging_over.parentNode; // A tspan inside a Raphael text object perhaps?
return dragging_over;
};
var mousemove = function(event) {
var delta_x = event.pageX-last_x;
var delta_y = event.pageY-last_y;
if (!started && (delta_x>reluctance || delta_x<-reluctance || delta_y>reluctance || delta_y<-reluctance)) {
if (handle.dragStart) {
var position = jQuery.browser.opera ? jQuery(handle.paper.canvas.parentNode).offset() : jQuery(handle.paper.canvas).offset();
var o = handle.dragStart(event.pageX-delta_x-position.left, event.pageY-delta_y-position.top, start_event, event);
if (!o) return false; // Don't start the drag yet if told not to
drag_obj = o;
}
started = true;
skip_click = true;
}
if (!started || !drag_obj) return false;
var dragging_over = over(event);
// console.log("Move "+drag_obj.node.id+" over "+dragging_over.id+" to X="+event.pageX+", Y="+event.pageY);
var update = drag_obj.dragUpdate ? drag_obj.dragUpdate : function(o, dx, dy, e) { drag_obj.translate(dx, dy); };
update(dragging_over, delta_x, delta_y, event);
last_x = event.pageX;
last_y = event.pageY;
return false;
};
if (reluctance == 0 && handle.dragStart) {
var o = handle.dragStart(0, 0, event, event);
if (!o) return false;
drag_obj = o;
started = true;
skip_click = true;
}
var revert;
var cancel;
// Process keyboard input so we can cancel
var keydown = function(event) {
if (event.keyCode == 27) { // Escape
revert(event);
if (drag_obj.dragCancel)
drag_obj.dragCancel();
cancel();
return false;
}
return true;
};
// Revert to starting location
revert = function(event) {
if (!started) return;
if (drag_obj && drag_obj.dragUpdate)
drag_obj.dragUpdate(null, start_event.pageX-last_x, start_event.pageY-last_y, event);
started = false; // Sometimes get the same event twice.
};
// The drag has ended, deal with it.
var mouseup = function(event) {
if (started) {
var dropped_on = over(event);
if (drag_obj && drag_obj.dragFinish) {
var position = jQuery.browser.opera ? jQuery(handle.paper.canvas.parentNode).offset() : jQuery(handle.paper.canvas).offset();
drag_obj.dragFinish(dropped_on, event.pageX-position.left, event.pageY-position.top, event);
}
cancel();
return true; // Don't let it bubble
}
cancel();
return true;
};
// Undo event bindings after the drag
handle.originalDraggableNode = handle.node;
cancel = function() {
jQuery(handle.node).unbind('mouseup', mouseup);
jQuery(handle.node).unbind('mousemove', mousemove);
jQuery(handle.node).unbind('keydown', keydown);
if (jQuery.browser.msie) {
// Rebind the mousedown if it got lost when the node was recreated:
if (handle.originalDraggableNode != handle.node)
jQuery(handle.node).bind('mousedown', mousedown);
handle.originalDraggableNode = handle.node;
}
started = false;
};
// Bind the appropriate events for the duration of the drag:
jQuery(handle.node).bind('keydown', keydown);
jQuery(handle.node).bind('mousemove', mousemove);
jQuery(handle.node).bind('mouseup', mouseup);
event.stopImmediatePropagation(); // Ensure that whatever drag we start, there's only one!
return false;
};
var click = function(event) {
if (skip_click)
event.stopImmediatePropagation();
skip_click = false; // Used to skip a click after dragging
return true;
};
jQuery(handle.node).bind('mousedown', mousedown);
jQuery(handle.node).bind('click', click); // Bind click now so that we can stop other click handlers
};

View File

@@ -0,0 +1,215 @@
(function($) {
$.fn.extend({
strackbar: function(options) {
var settings = $.extend({
style: 'style1',
defaultValue: 0,
sliderHeight: 4,
sliderWidth: 200,
trackerHeight: 20,
trackerWidth: 19,
minValue: 0,
maxValue: 10,
borderWidth: 1,
animate: true,
ticks: true,
labels: true,
callback: null
}, options);
return this.each(function() {
var mousecaptured = false;
var mouseDown = false;
var previousMousePosition = 0;
var stepValue = parseFloat(settings.sliderWidth / settings.maxValue);
var currentValue = settings.minValue;
var sliderLeft = 0;
var sliderRight = 0;
var ltop = 0;
var element = $(this);
var minvallabel = $('<div></div>').attr('id', 'min-val').css('float', 'left');
var maxvallabel = $('<div></div>').attr('id', 'max-val').css('float', 'left');
var wrapper = $('<div></div>').css('float', 'left');
var contents = $('<div></div>').attr('id', 'jscroll').addClass('jscroller');
var slider = $('<div></div>').attr('id', 'slider').addClass('slider');
var selection = $('<div></div>').attr('id', 'inner').html('&nbsp').addClass('inner');
var ltracker = $('<div></div>').attr('id', 'lgripper').addClass('lgripper');
if (settings.labels)
element.append(minvallabel);
element.append(wrapper);
wrapper.append(contents);
contents.append(slider);
slider.append(selection);
contents.append(ltracker);
if (settings.labels)
element.append(maxvallabel);
ltracker.css('height', settings.trackerHeight + 'px').css('width', settings.trackerWidth + 'px').css('left', '0');
slider.css('width', settings.sliderWidth - (settings.borderWidth * 2)).css('height', settings.sliderHeight);
slider.css('-moz-border-radius', (settings.sliderHeight) + 'px');
slider.css('-webkit-border-radius', (settings.sliderHeight) + 'px');
slider.css('border-radius', (settings.sliderHeight) + 'px');
slider.css('top', '40%');
selection.css('-moz-border-radius', (settings.sliderHeight) + 'px');
selection.css('-webkit-border-radius', (settings.sliderHeight) + 'px');
selection.css('border-radius', (settings.sliderHeight) + 'px');
slider.addClass(settings.style);
selection.addClass(settings.style);
ltracker.addClass(settings.style);
contents.addClass(settings.style);
//element.css('padding-top', settings.trackerHeight / 2);
var clear = $('<div></div>');
clear.css('clear', 'both');
element.append(clear);
wrapper.css('width', settings.sliderWidth + 'px');
//maxvallabel.html(settings.maxValue).css('margin-top', -(settings.trackerHeight / 4) + 'px').css('padding-left', '6px');
//minvallabel.html(settings.minValue).css('margin-top', -(settings.trackerHeight / 4) + 'px').css('padding-right', '4px');
maxvallabel.html(settings.maxValue).css('padding-left', '6px'); //.css('margin-top', '-2px');
minvallabel.html(settings.minValue).css('padding-right', '4px'); //.css('margin-top', '-2px');
var sliderBottom = settings.sliderHeight;
sliderLeft = slider.offset().left;
sliderRight = sliderLeft + settings.sliderWidth;
ltop = (settings.trackerHeight / 2) - settings.sliderHeight / 2;
previousMousePosition = sliderLeft;
/*generates tick marks */
var ticks = $("<ul></ul>");
ticks.css('position', 'absolute');
var height = slider.get(0).offsetHeight - 4;
//var height = settings.sliderHeight;
var sliderBorder = slider.get(0).offsetHeight - settings.sliderHeight;
ltop -= sliderBorder / 2;
ticks.css('top', height + 'px')
ticks.attr('id', 'ticks');
ticks.addClass('ticks');
ticks.css('width', settings.sliderWidth + 'px');
ticks.css('margin-left', stepValue / 2 + 'px');
ticks.css('margin-top', '0px');
var totalTicks = settings.sliderWidth / stepValue;
for (var count = 0; count < totalTicks; count++) {
var tick = $('<li><span>|</span></li>');
tick.css('width', stepValue + 'px');
ticks.append(tick);
}
if (settings.ticks)
slider.after(ticks);
ltracker.css('top', -ltop + 'px');
//set the default position
if (settings.defaultValue != 0) {
setPosition(settings.defaultValue * stepValue);
previousMousePosition = sliderLeft + settings.defaultValue * stepValue;
if (settings.callback != null)
settings.callback(settings.defaultValue);
}
ltracker.mousedown(function(e) {
mousecaptured = true;
previousMousePosition = e.pageX;
$(this).css('cursor', 'pointer');
});
ltracker.mouseup(function(e) {
mousecaptured = false;
$(this).css('cursor', 'default');
});
$(document).mouseup(function() {
mousecaptured = false;
$(this).css('cursor', 'default');
});
$(document).mousemove(function(e) {
if (mousecaptured) {
setTrackerPosition(e.pageX);
e.stopPropagation();
e.preventDefault();
e.stopImmediatePropagation();
}
});
slider.mouseenter(function(e) { $(this).css('cursor', 'pointer'); });
slider.mouseout(function(e) { $(this).css('cursor', 'default'); });
slider.mousedown(function(e) {
if (!mouseDown) {
mouseDown = true;
$(this).css('cursor', 'pointer');
mousecaptured = false;
setTrackerPosition(e.pageX);
}
});
function getpositionvalue(pos) {
var val = parseInt(pos.replace('px', ''));
return val;
}
function getDragAmount(cursorCurrentPosition, cursorPreviousPosition) {
var dragAmount = cursorCurrentPosition - cursorPreviousPosition;
if (cursorPreviousPosition <= 0) {
dragAmount = cursorCurrentPosition - sliderLeft;
previousMousePosition = sliderLeft + dragAmount;
}
if (cursorPreviousPosition > cursorCurrentPosition)
dragAmount = cursorPreviousPosition - cursorCurrentPosition;
return dragAmount;
}
function isForwardDirection(cursorCurrentPosition, cursorPreviousPosition) {
if (cursorCurrentPosition > cursorPreviousPosition)
return true;
else
return false;
}
function validatePosition(position) {
if (position >= 0 && position <= settings.sliderWidth)
return true;
else
return false;
}
function setPosition(position) {
if (validatePosition(position)) {
var selectionWidth = getpositionvalue(ltracker.css('left')) + settings.trackerWidth / 2;
if (settings.animate && !mousecaptured) {
ltracker.animate({ 'left': position + 'px' }, 500, function() {
selectionWidth = getpositionvalue(ltracker.css('left')) + settings.trackerWidth / 2;
selection.css('width', selectionWidth + 'px');
mouseDown = false;
});
/*settings.animate = false;*/
}
else {
ltracker.css('left', position + 'px');
selectionWidth = getpositionvalue(ltracker.css('left')) + settings.trackerWidth / 2;
selection.css('width', selectionWidth + 'px');
mouseDown = false;
}
}
}
function setTrackerPosition(cursorPosition) {
var dragAmount = getDragAmount(cursorPosition, previousMousePosition);
var isForward = isForwardDirection(cursorPosition, previousMousePosition);
var trackerPosition = getpositionvalue(ltracker.css('left'));
if (cursorPosition >= sliderLeft && cursorPosition <= (sliderRight - stepValue / 10)) {
if (trackerPosition >= 0 && trackerPosition <= settings.sliderWidth - stepValue / 10) {
if (isForward)
trackerPosition += dragAmount;
else
trackerPosition -= dragAmount;
setPosition(trackerPosition);
var newPosition = cursorPosition - sliderLeft;
var cVal = newPosition / stepValue;
currentValue = parseInt(cVal);
if (trackerPosition > (settings.sliderWidth - stepValue) + stepValue / 10) {
currentValue = parseInt(settings.sliderWidth / stepValue);
}
if (settings.callback != null)
settings.callback(currentValue);
}
previousMousePosition = cursorPosition;
}
}
});
}
});
})(jQuery);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long