Version Description
Download this release
Release Info
Developer | jmash |
Plugin | ![]() |
Version | 0.1.3 |
Comparing to | |
See all releases |
Code changes from version 1.0.0 to 0.1.3
- README.txt +15 -5
- collapse.png +0 -0
- expand.png +0 -0
- hide.png +0 -0
- mootools-1.11.js +248 -0
- myjson.php +0 -806
- nest-mootools.v1.11.js +0 -7102
- nested.js +0 -254
- page.png +0 -0
- pagemash.php +132 -215
- reorder.php +15 -0
- saveList.php +0 -44
- screenshot-1.png +0 -0
- screenshot-2.png +0 -0
README.txt
CHANGED
@@ -15,13 +15,13 @@ If you want to see an example of the admin page check out: http://joelstarnes.co
|
|
15 |
|
16 |
|
17 |
|
18 |
-
= Development Version 1.0.
|
19 |
|
20 |
-
|
21 |
|
22 |
-
http://joelstarnes.co.uk/pagemash/example_v1.0.
|
23 |
|
24 |
-
http://wordpress.org/
|
25 |
|
26 |
|
27 |
== Installation ==
|
@@ -31,9 +31,19 @@ http://wordpress.org/extend/plugins/pagemash/download/pagemash.1.0.0.zip
|
|
31 |
1. Activate in 'Plugins' admin menu
|
32 |
1. {Edit your Template}
|
33 |
|
34 |
-
In most cases the plugin should work straight out the box
|
35 |
|
36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
== Frequently Asked Questions ==
|
38 |
|
39 |
If you have any questions or comments,
|
15 |
|
16 |
|
17 |
|
18 |
+
= Development Version 1.0.1 beta =
|
19 |
|
20 |
+
Version 1.0.0 major rebuild of the plugin gives full recursive suppot for unlimited nested children in a collapsable list. [version 1.0.1 fixes a text-select bug in IE]. Give the beta app a download from the link below and if you have any feedback drop me a mail, [even if it works all fine and dandy its nice to know :D] http://joelstarnes.co.uk/contact
|
21 |
|
22 |
+
http://joelstarnes.co.uk/pagemash/example_v1.0.1
|
23 |
|
24 |
+
http://downloads.wordpress.org/plugin/pagemash.zip
|
25 |
|
26 |
|
27 |
== Installation ==
|
31 |
1. Activate in 'Plugins' admin menu
|
32 |
1. {Edit your Template}
|
33 |
|
34 |
+
In most cases the plugin should work straight out the box, since most templates will include something similar to: `wp_list_pages('title_li=<h2>Pages</h2>);`
|
35 |
|
36 |
|
37 |
+
However to achieve full functionality including the 'exclude pages' feature you should replace the wp_list_pages() function with the following php code:
|
38 |
+
|
39 |
+
`if(function_exists('pageMash_exclude_pages'))`
|
40 |
+
`{$exclude_pages=pageMash_exclude_pages();} else{$exclude_pages='';}`
|
41 |
+
`wp_list_pages('title_li=<h2>Pages</h2>&exclude='.$exclude_pages);`
|
42 |
+
|
43 |
+
|
44 |
+
You can place the code wherever you would like your page listings to appear;
|
45 |
+
usually either the header.php or sidebar.php file found in: `wp-content\themes\theme_name`
|
46 |
+
|
47 |
== Frequently Asked Questions ==
|
48 |
|
49 |
If you have any questions or comments,
|
collapse.png
DELETED
Binary file
|
expand.png
DELETED
Binary file
|
hide.png
ADDED
Binary file
|
mootools-1.11.js
ADDED
@@ -0,0 +1,248 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
//MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.
|
2 |
+
|
3 |
+
var MooTools={version:"1.11"};function $defined(A){return(A!=undefined);}function $type(B){if(!$defined(B)){return false;}if(B.htmlElement){return"element";
|
4 |
+
}var A=typeof B;if(A=="object"&&B.nodeName){switch(B.nodeType){case 1:return"element";case 3:return(/\S/).test(B.nodeValue)?"textnode":"whitespace";}}if(A=="object"||A=="function"){switch(B.constructor){case Array:return"array";
|
5 |
+
case RegExp:return"regexp";case Class:return"class";}if(typeof B.length=="number"){if(B.item){return"collection";}if(B.callee){return"arguments";}}}return A;
|
6 |
+
}function $merge(){var C={};for(var B=0;B<arguments.length;B++){for(var E in arguments[B]){var A=arguments[B][E];var D=C[E];if(D&&$type(A)=="object"&&$type(D)=="object"){C[E]=$merge(D,A);
|
7 |
+
}else{C[E]=A;}}}return C;}var $extend=function(){var A=arguments;if(!A[1]){A=[this,A[0]];}for(var B in A[1]){A[0][B]=A[1][B];}return A[0];};var $native=function(){for(var B=0,A=arguments.length;
|
8 |
+
B<A;B++){arguments[B].extend=function(C){for(var D in C){if(!this.prototype[D]){this.prototype[D]=C[D];}if(!this[D]){this[D]=$native.generic(D);}}};}};
|
9 |
+
$native.generic=function(A){return function(B){return this.prototype[A].apply(B,Array.prototype.slice.call(arguments,1));};};$native(Function,Array,String,Number);
|
10 |
+
function $chk(A){return !!(A||A===0);}function $pick(B,A){return $defined(B)?B:A;}function $random(B,A){return Math.floor(Math.random()*(A-B+1)+B);}function $time(){return new Date().getTime();
|
11 |
+
}function $clear(A){clearTimeout(A);clearInterval(A);return null;}var Abstract=function(A){A=A||{};A.extend=$extend;return A;};var Window=new Abstract(window);
|
12 |
+
var Document=new Abstract(document);document.head=document.getElementsByTagName("head")[0];window.xpath=!!(document.evaluate);if(window.ActiveXObject){window.ie=window[window.XMLHttpRequest?"ie7":"ie6"]=true;
|
13 |
+
}else{if(document.childNodes&&!document.all&&!navigator.taintEnabled){window.webkit=window[window.xpath?"webkit420":"webkit419"]=true;}else{if(document.getBoxObjectFor!=null){window.gecko=true;
|
14 |
+
}}}window.khtml=window.webkit;Object.extend=$extend;if(typeof HTMLElement=="undefined"){var HTMLElement=function(){};if(window.webkit){document.createElement("iframe");
|
15 |
+
}HTMLElement.prototype=(window.webkit)?window["[[DOMElement.prototype]]"]:{};}HTMLElement.prototype.htmlElement=function(){};if(window.ie6){try{document.execCommand("BackgroundImageCache",false,true);
|
16 |
+
}catch(e){}}var Class=function(B){var A=function(){return(arguments[0]!==null&&this.initialize&&$type(this.initialize)=="function")?this.initialize.apply(this,arguments):this;
|
17 |
+
};$extend(A,this);A.prototype=B;A.constructor=Class;return A;};Class.empty=function(){};Class.prototype={extend:function(B){var C=new this(null);for(var D in B){var A=C[D];
|
18 |
+
C[D]=Class.Merge(A,B[D]);}return new Class(C);},implement:function(){for(var B=0,A=arguments.length;B<A;B++){$extend(this.prototype,arguments[B]);}}};Class.Merge=function(C,D){if(C&&C!=D){var B=$type(D);
|
19 |
+
if(B!=$type(C)){return D;}switch(B){case"function":var A=function(){this.parent=arguments.callee.parent;return D.apply(this,arguments);};A.parent=C;return A;
|
20 |
+
case"object":return $merge(C,D);}}return D;};var Chain=new Class({chain:function(A){this.chains=this.chains||[];this.chains.push(A);return this;},callChain:function(){if(this.chains&&this.chains.length){this.chains.shift().delay(10,this);
|
21 |
+
}},clearChain:function(){this.chains=[];}});var Events=new Class({addEvent:function(B,A){if(A!=Class.empty){this.$events=this.$events||{};this.$events[B]=this.$events[B]||[];
|
22 |
+
this.$events[B].include(A);}return this;},fireEvent:function(C,B,A){if(this.$events&&this.$events[C]){this.$events[C].each(function(D){D.create({bind:this,delay:A,arguments:B})();
|
23 |
+
},this);}return this;},removeEvent:function(B,A){if(this.$events&&this.$events[B]){this.$events[B].remove(A);}return this;}});var Options=new Class({setOptions:function(){this.options=$merge.apply(null,[this.options].extend(arguments));
|
24 |
+
if(this.addEvent){for(var A in this.options){if($type(this.options[A]=="function")&&(/^on[A-Z]/).test(A)){this.addEvent(A,this.options[A]);}}}return this;
|
25 |
+
}});Array.extend({forEach:function(C,D){for(var B=0,A=this.length;B<A;B++){C.call(D,this[B],B,this);}},filter:function(D,E){var C=[];for(var B=0,A=this.length;
|
26 |
+
B<A;B++){if(D.call(E,this[B],B,this)){C.push(this[B]);}}return C;},map:function(D,E){var C=[];for(var B=0,A=this.length;B<A;B++){C[B]=D.call(E,this[B],B,this);
|
27 |
+
}return C;},every:function(C,D){for(var B=0,A=this.length;B<A;B++){if(!C.call(D,this[B],B,this)){return false;}}return true;},some:function(C,D){for(var B=0,A=this.length;
|
28 |
+
B<A;B++){if(C.call(D,this[B],B,this)){return true;}}return false;},indexOf:function(C,D){var A=this.length;for(var B=(D<0)?Math.max(0,A+D):D||0;B<A;B++){if(this[B]===C){return B;
|
29 |
+
}}return -1;},copy:function(D,C){D=D||0;if(D<0){D=this.length+D;}C=C||(this.length-D);var A=[];for(var B=0;B<C;B++){A[B]=this[D++];}return A;},remove:function(C){var B=0;
|
30 |
+
var A=this.length;while(B<A){if(this[B]===C){this.splice(B,1);A--;}else{B++;}}return this;},contains:function(A,B){return this.indexOf(A,B)!=-1;},associate:function(C){var D={},B=Math.min(this.length,C.length);
|
31 |
+
for(var A=0;A<B;A++){D[C[A]]=this[A];}return D;},extend:function(C){for(var B=0,A=C.length;B<A;B++){this.push(C[B]);}return this;},merge:function(C){for(var B=0,A=C.length;
|
32 |
+
B<A;B++){this.include(C[B]);}return this;},include:function(A){if(!this.contains(A)){this.push(A);}return this;},getRandom:function(){return this[$random(0,this.length-1)]||null;
|
33 |
+
},getLast:function(){return this[this.length-1]||null;}});Array.prototype.each=Array.prototype.forEach;Array.each=Array.forEach;function $A(A){return Array.copy(A);
|
34 |
+
}function $each(C,B,D){if(C&&typeof C.length=="number"&&$type(C)!="object"){Array.forEach(C,B,D);}else{for(var A in C){B.call(D||C,C[A],A);}}}Array.prototype.test=Array.prototype.contains;
|
35 |
+
String.extend({test:function(A,B){return(($type(A)=="string")?new RegExp(A,B):A).test(this);},toInt:function(){return parseInt(this,10);},toFloat:function(){return parseFloat(this);
|
36 |
+
},camelCase:function(){return this.replace(/-\D/g,function(A){return A.charAt(1).toUpperCase();});},hyphenate:function(){return this.replace(/\w[A-Z]/g,function(A){return(A.charAt(0)+"-"+A.charAt(1).toLowerCase());
|
37 |
+
});},capitalize:function(){return this.replace(/\b[a-z]/g,function(A){return A.toUpperCase();});},trim:function(){return this.replace(/^\s+|\s+#x2F;g,"");
|
38 |
+
},clean:function(){return this.replace(/\s{2,}/g," ").trim();},rgbToHex:function(B){var A=this.match(/\d{1,3}/g);return(A)?A.rgbToHex(B):false;},hexToRgb:function(B){var A=this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})#x2F;);
|
39 |
+
return(A)?A.slice(1).hexToRgb(B):false;},contains:function(A,B){return(B)?(B+this+B).indexOf(B+A+B)>-1:this.indexOf(A)>-1;},escapeRegExp:function(){return this.replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");
|
40 |
+
}});Array.extend({rgbToHex:function(D){if(this.length<3){return false;}if(this.length==4&&this[3]==0&&!D){return"transparent";}var B=[];for(var A=0;A<3;
|
41 |
+
A++){var C=(this[A]-0).toString(16);B.push((C.length==1)?"0"+C:C);}return D?B:"#"+B.join("");},hexToRgb:function(C){if(this.length!=3){return false;}var A=[];
|
42 |
+
for(var B=0;B<3;B++){A.push(parseInt((this[B].length==1)?this[B]+this[B]:this[B],16));}return C?A:"rgb("+A.join(",")+")";}});Function.extend({create:function(A){var B=this;
|
43 |
+
A=$merge({bind:B,event:false,arguments:null,delay:false,periodical:false,attempt:false},A);if($chk(A.arguments)&&$type(A.arguments)!="array"){A.arguments=[A.arguments];
|
44 |
+
}return function(E){var C;if(A.event){E=E||window.event;C=[(A.event===true)?E:new A.event(E)];if(A.arguments){C.extend(A.arguments);}}else{C=A.arguments||arguments;
|
45 |
+
}var F=function(){return B.apply($pick(A.bind,B),C);};if(A.delay){return setTimeout(F,A.delay);}if(A.periodical){return setInterval(F,A.periodical);}if(A.attempt){try{return F();
|
46 |
+
}catch(D){return false;}}return F();};},pass:function(A,B){return this.create({arguments:A,bind:B});},attempt:function(A,B){return this.create({arguments:A,bind:B,attempt:true})();
|
47 |
+
},bind:function(B,A){return this.create({bind:B,arguments:A});},bindAsEventListener:function(B,A){return this.create({bind:B,event:true,arguments:A});},delay:function(B,C,A){return this.create({delay:B,bind:C,arguments:A})();
|
48 |
+
},periodical:function(A,C,B){return this.create({periodical:A,bind:C,arguments:B})();}});Number.extend({toInt:function(){return parseInt(this);},toFloat:function(){return parseFloat(this);
|
49 |
+
},limit:function(B,A){return Math.min(A,Math.max(B,this));},round:function(A){A=Math.pow(10,A||0);return Math.round(this*A)/A;},times:function(B){for(var A=0;
|
50 |
+
A<this;A++){B(A);}}});var Element=new Class({initialize:function(D,C){if($type(D)=="string"){if(window.ie&&C&&(C.name||C.type)){var A=(C.name)?' name="'+C.name+'"':"";
|
51 |
+
var B=(C.type)?' type="'+C.type+'"':"";delete C.name;delete C.type;D="<"+D+A+B+">";}D=document.createElement(D);}D=$(D);return(!C||!D)?D:D.set(C);}});var Elements=new Class({initialize:function(A){return(A)?$extend(A,this):this;
|
52 |
+
}});Elements.extend=function(A){for(var B in A){this.prototype[B]=A[B];this[B]=$native.generic(B);}};function $(B){if(!B){return null;}if(B.htmlElement){return Garbage.collect(B);
|
53 |
+
}if([window,document].contains(B)){return B;}var A=$type(B);if(A=="string"){B=document.getElementById(B);A=(B)?"element":false;}if(A!="element"){return null;
|
54 |
+
}if(B.htmlElement){return Garbage.collect(B);}if(["object","embed"].contains(B.tagName.toLowerCase())){return B;}$extend(B,Element.prototype);B.htmlElement=function(){};
|
55 |
+
return Garbage.collect(B);}document.getElementsBySelector=document.getElementsByTagName;function $(){var D=[];for(var C=0,B=arguments.length;C<B;C++){var A=arguments[C];
|
56 |
+
switch($type(A)){case"element":D.push(A);case"boolean":break;case false:break;case"string":A=document.getElementsBySelector(A,true);default:D.extend(A);
|
57 |
+
}}return $.unique(D);}$.unique=function(G){var D=[];for(var C=0,A=G.length;C<A;C++){if(G[C].$included){continue;}var B=$(G[C]);if(B&&!B.$included){B.$included=true;
|
58 |
+
D.push(B);}}for(var F=0,E=D.length;F<E;F++){D[F].$included=null;}return new Elements(D);};Elements.Multi=function(A){return function(){var D=arguments;
|
59 |
+
var B=[];var G=true;for(var E=0,C=this.length,F;E<C;E++){F=this[E][A].apply(this[E],D);if($type(F)!="element"){G=false;}B.push(F);}return(G)?$.unique(B):B;
|
60 |
+
};};Element.extend=function(A){for(var B in A){HTMLElement.prototype[B]=A[B];Element.prototype[B]=A[B];Element[B]=$native.generic(B);var C=(Array.prototype[B])?B+"Elements":B;
|
61 |
+
Elements.prototype[C]=Elements.Multi(B);}};Element.extend({set:function(A){for(var C in A){var B=A[C];switch(C){case"styles":this.setStyles(B);break;case"events":if(this.addEvents){this.addEvents(B);
|
62 |
+
}break;case"properties":this.setProperties(B);break;default:this.setProperty(C,B);}}return this;},inject:function(C,A){C=$(C);switch(A){case"before":C.parentNode.insertBefore(this,C);
|
63 |
+
break;case"after":var B=C.getNext();if(!B){C.parentNode.appendChild(this);}else{C.parentNode.insertBefore(this,B);}break;case"top":var D=C.firstChild;if(D){C.insertBefore(this,D);
|
64 |
+
break;}default:C.appendChild(this);}return this;},injectBefore:function(A){return this.inject(A,"before");},injectAfter:function(A){return this.inject(A,"after");
|
65 |
+
},injectInside:function(A){return this.inject(A,"bottom");},injectTop:function(A){return this.inject(A,"top");},adopt:function(){var A=[];$each(arguments,function(B){A=A.concat(B);
|
66 |
+
});$(A).inject(this);return this;},remove:function(){return this.parentNode.removeChild(this);},clone:function(C){var B=$(this.cloneNode(C!==false));if(!B.$events){return B;
|
67 |
+
}B.$events={};for(var A in this.$events){B.$events[A]={keys:$A(this.$events[A].keys),values:$A(this.$events[A].values)};}return B.removeEvents();},replaceWith:function(A){A=$(A);
|
68 |
+
this.parentNode.replaceChild(A,this);return A;},appendText:function(A){this.appendChild(document.createTextNode(A));return this;},hasClass:function(A){return this.className.contains(A," ");
|
69 |
+
},addClass:function(A){if(!this.hasClass(A)){this.className=(this.className+" "+A).clean();}return this;},removeClass:function(A){this.className=this.className.replace(new RegExp("(^|\\s)"+A+"(?:\\s|$)"),"$1").clean();
|
70 |
+
return this;},toggleClass:function(A){return this.hasClass(A)?this.removeClass(A):this.addClass(A);},setStyle:function(B,A){switch(B){case"opacity":return this.setOpacity(parseFloat(A));
|
71 |
+
case"float":B=(window.ie)?"styleFloat":"cssFloat";}B=B.camelCase();switch($type(A)){case"number":if(!["zIndex","zoom"].contains(B)){A+="px";}break;case"array":A="rgb("+A.join(",")+")";
|
72 |
+
}this.style[B]=A;return this;},setStyles:function(A){switch($type(A)){case"object":Element.setMany(this,"setStyle",A);break;case"string":this.style.cssText=A;
|
73 |
+
}return this;},setOpacity:function(A){if(A==0){if(this.style.visibility!="hidden"){this.style.visibility="hidden";}}else{if(this.style.visibility!="visible"){this.style.visibility="visible";
|
74 |
+
}}if(!this.currentStyle||!this.currentStyle.hasLayout){this.style.zoom=1;}if(window.ie){this.style.filter=(A==1)?"":"alpha(opacity="+A*100+")";}this.style.opacity=this.$tmp.opacity=A;
|
75 |
+
return this;},getStyle:function(C){C=C.camelCase();var A=this.style[C];if(!$chk(A)){if(C=="opacity"){return this.$tmp.opacity;}A=[];for(var B in Element.Styles){if(C==B){Element.Styles[B].each(function(F){var E=this.getStyle(F);
|
76 |
+
A.push(parseInt(E)?E:"0px");},this);if(C=="border"){var D=A.every(function(E){return(E==A[0]);});return(D)?A[0]:false;}return A.join(" ");}}if(C.contains("border")){if(Element.Styles.border.contains(C)){return["Width","Style","Color"].map(function(E){return this.getStyle(C+E);
|
77 |
+
},this).join(" ");}else{if(Element.borderShort.contains(C)){return["Top","Right","Bottom","Left"].map(function(E){return this.getStyle("border"+E+C.replace("border",""));
|
78 |
+
},this).join(" ");}}}if(document.defaultView){A=document.defaultView.getComputedStyle(this,null).getPropertyValue(C.hyphenate());}else{if(this.currentStyle){A=this.currentStyle[C];
|
79 |
+
}}}if(window.ie){A=Element.fixStyle(C,A,this);}if(A&&C.test(/color/i)&&A.contains("rgb")){return A.split("rgb").splice(1,4).map(function(E){return E.rgbToHex();
|
80 |
+
}).join(" ");}return A;},getStyles:function(){return Element.getMany(this,"getStyle",arguments);},walk:function(A,C){A+="Sibling";var B=(C)?this[C]:this[A];
|
81 |
+
while(B&&$type(B)!="element"){B=B[A];}return $(B);},getPrevious:function(){return this.walk("previous");},getNext:function(){return this.walk("next");},getFirst:function(){return this.walk("next","firstChild");
|
82 |
+
},getLast:function(){return this.walk("previous","lastChild");},getParent:function(){return $(this.parentNode);},getChildren:function(){return $(this.childNodes);
|
83 |
+
},hasChild:function(A){return !!$A(this.getElementsByTagName("*")).contains(A);},getProperty:function(D){var B=Element.Properties[D];if(B){return this[B];
|
84 |
+
}var A=Element.PropertiesIFlag[D]||0;if(!window.ie||A){return this.getAttribute(D,A);}var C=this.attributes[D];return(C)?C.nodeValue:null;},removeProperty:function(B){var A=Element.Properties[B];
|
85 |
+
if(A){this[A]="";}else{this.removeAttribute(B);}return this;},getProperties:function(){return Element.getMany(this,"getProperty",arguments);},setProperty:function(C,B){var A=Element.Properties[C];
|
86 |
+
if(A){this[A]=B;}else{this.setAttribute(C,B);}return this;},setProperties:function(A){return Element.setMany(this,"setProperty",A);},setHTML:function(){this.innerHTML=$A(arguments).join("");
|
87 |
+
return this;},setText:function(B){var A=this.getTag();if(["style","script"].contains(A)){if(window.ie){if(A=="style"){this.styleSheet.cssText=B;}else{if(A=="script"){this.setProperty("text",B);
|
88 |
+
}}return this;}else{this.removeChild(this.firstChild);return this.appendText(B);}}this[$defined(this.innerText)?"innerText":"textContent"]=B;return this;
|
89 |
+
},getText:function(){var A=this.getTag();if(["style","script"].contains(A)){if(window.ie){if(A=="style"){return this.styleSheet.cssText;}else{if(A=="script"){return this.getProperty("text");
|
90 |
+
}}}else{return this.innerHTML;}}return($pick(this.innerText,this.textContent));},getTag:function(){return this.tagName.toLowerCase();},empty:function(){Garbage.trash(this.getElementsByTagName("*"));
|
91 |
+
return this.setHTML("");}});Element.fixStyle=function(E,A,D){if($chk(parseInt(A))){return A;}if(["height","width"].contains(E)){var B=(E=="width")?["left","right"]:["top","bottom"];
|
92 |
+
var C=0;B.each(function(F){C+=D.getStyle("border-"+F+"-width").toInt()+D.getStyle("padding-"+F).toInt();});return D["offset"+E.capitalize()]-C+"px";}else{if(E.test(/border(.+)Width|margin|padding/)){return"0px";
|
93 |
+
}}return A;};Element.Styles={border:[],padding:[],margin:[]};["Top","Right","Bottom","Left"].each(function(B){for(var A in Element.Styles){Element.Styles[A].push(A+B);
|
94 |
+
}});Element.borderShort=["borderWidth","borderStyle","borderColor"];Element.getMany=function(B,D,C){var A={};$each(C,function(E){A[E]=B[D](E);});return A;
|
95 |
+
};Element.setMany=function(B,D,C){for(var A in C){B[D](A,C[A]);}return B;};Element.Properties=new Abstract({"class":"className","for":"htmlFor",colspan:"colSpan",rowspan:"rowSpan",accesskey:"accessKey",tabindex:"tabIndex",maxlength:"maxLength",readonly:"readOnly",frameborder:"frameBorder",value:"value",disabled:"disabled",checked:"checked",multiple:"multiple",selected:"selected"});
|
96 |
+
Element.PropertiesIFlag={href:2,src:2};Element.Methods={Listeners:{addListener:function(B,A){if(this.addEventListener){this.addEventListener(B,A,false);
|
97 |
+
}else{this.attachEvent("on"+B,A);}return this;},removeListener:function(B,A){if(this.removeEventListener){this.removeEventListener(B,A,false);}else{this.detachEvent("on"+B,A);
|
98 |
+
}return this;}}};window.extend(Element.Methods.Listeners);document.extend(Element.Methods.Listeners);Element.extend(Element.Methods.Listeners);var Garbage={elements:[],collect:function(A){if(!A.$tmp){Garbage.elements.push(A);
|
99 |
+
A.$tmp={opacity:1};}return A;},trash:function(D){for(var B=0,A=D.length,C;B<A;B++){if(!(C=D[B])||!C.$tmp){continue;}if(C.$events){C.fireEvent("trash").removeEvents();
|
100 |
+
}for(var E in C.$tmp){C.$tmp[E]=null;}for(var F in Element.prototype){C[F]=null;}Garbage.elements[Garbage.elements.indexOf(C)]=null;C.htmlElement=C.$tmp=C=null;
|
101 |
+
}Garbage.elements.remove(null);},empty:function(){Garbage.collect(window);Garbage.collect(document);Garbage.trash(Garbage.elements);}};window.addListener("beforeunload",function(){window.addListener("unload",Garbage.empty);
|
102 |
+
if(window.ie){window.addListener("unload",CollectGarbage);}});var Event=new Class({initialize:function(C){if(C&&C.$extended){return C;}this.$extended=true;
|
103 |
+
C=C||window.event;this.event=C;this.type=C.type;this.target=C.target||C.srcElement;if(this.target.nodeType==3){this.target=this.target.parentNode;}this.shift=C.shiftKey;
|
104 |
+
this.control=C.ctrlKey;this.alt=C.altKey;this.meta=C.metaKey;if(["DOMMouseScroll","mousewheel"].contains(this.type)){this.wheel=(C.wheelDelta)?C.wheelDelta/120:-(C.detail||0)/3;
|
105 |
+
}else{if(this.type.contains("key")){this.code=C.which||C.keyCode;for(var B in Event.keys){if(Event.keys[B]==this.code){this.key=B;break;}}if(this.type=="keydown"){var A=this.code-111;
|
106 |
+
if(A>0&&A<13){this.key="f"+A;}}this.key=this.key||String.fromCharCode(this.code).toLowerCase();}else{if(this.type.test(/(click|mouse|menu)/)){this.page={x:C.pageX||C.clientX+document.documentElement.scrollLeft,y:C.pageY||C.clientY+document.documentElement.scrollTop};
|
107 |
+
this.client={x:C.pageX?C.pageX-window.pageXOffset:C.clientX,y:C.pageY?C.pageY-window.pageYOffset:C.clientY};this.rightClick=(C.which==3)||(C.button==2);
|
108 |
+
switch(this.type){case"mouseover":this.relatedTarget=C.relatedTarget||C.fromElement;break;case"mouseout":this.relatedTarget=C.relatedTarget||C.toElement;
|
109 |
+
}this.fixRelatedTarget();}}}return this;},stop:function(){return this.stopPropagation().preventDefault();},stopPropagation:function(){if(this.event.stopPropagation){this.event.stopPropagation();
|
110 |
+
}else{this.event.cancelBubble=true;}return this;},preventDefault:function(){if(this.event.preventDefault){this.event.preventDefault();}else{this.event.returnValue=false;
|
111 |
+
}return this;}});Event.fix={relatedTarget:function(){if(this.relatedTarget&&this.relatedTarget.nodeType==3){this.relatedTarget=this.relatedTarget.parentNode;
|
112 |
+
}},relatedTargetGecko:function(){try{Event.fix.relatedTarget.call(this);}catch(A){this.relatedTarget=this.target;}}};Event.prototype.fixRelatedTarget=(window.gecko)?Event.fix.relatedTargetGecko:Event.fix.relatedTarget;
|
113 |
+
Event.keys=new Abstract({enter:13,up:38,down:40,left:37,right:39,esc:27,space:32,backspace:8,tab:9,"delete":46});Element.Methods.Events={addEvent:function(C,B){this.$events=this.$events||{};
|
114 |
+
this.$events[C]=this.$events[C]||{keys:[],values:[]};if(this.$events[C].keys.contains(B)){return this;}this.$events[C].keys.push(B);var A=C;var D=Element.Events[C];
|
115 |
+
if(D){if(D.add){D.add.call(this,B);}if(D.map){B=D.map;}if(D.type){A=D.type;}}if(!this.addEventListener){B=B.create({bind:this,event:true});}this.$events[C].values.push(B);
|
116 |
+
return(Element.NativeEvents.contains(A))?this.addListener(A,B):this;},removeEvent:function(C,B){if(!this.$events||!this.$events[C]){return this;}var F=this.$events[C].keys.indexOf(B);
|
117 |
+
if(F==-1){return this;}var A=this.$events[C].keys.splice(F,1)[0];var E=this.$events[C].values.splice(F,1)[0];var D=Element.Events[C];if(D){if(D.remove){D.remove.call(this,B);
|
118 |
+
}if(D.type){C=D.type;}}return(Element.NativeEvents.contains(C))?this.removeListener(C,E):this;},addEvents:function(A){return Element.setMany(this,"addEvent",A);
|
119 |
+
},removeEvents:function(A){if(!this.$events){return this;}if(!A){for(var B in this.$events){this.removeEvents(B);}this.$events=null;}else{if(this.$events[A]){this.$events[A].keys.each(function(C){this.removeEvent(A,C);
|
120 |
+
},this);this.$events[A]=null;}}return this;},fireEvent:function(C,B,A){if(this.$events&&this.$events[C]){this.$events[C].keys.each(function(D){D.create({bind:this,delay:A,arguments:B})();
|
121 |
+
},this);}return this;},cloneEvents:function(C,A){if(!C.$events){return this;}if(!A){for(var B in C.$events){this.cloneEvents(C,B);}}else{if(C.$events[A]){C.$events[A].keys.each(function(D){this.addEvent(A,D);
|
122 |
+
},this);}}return this;}};window.extend(Element.Methods.Events);document.extend(Element.Methods.Events);Element.extend(Element.Methods.Events);Element.Events=new Abstract({mouseenter:{type:"mouseover",map:function(A){A=new Event(A);
|
123 |
+
if(A.relatedTarget!=this&&!this.hasChild(A.relatedTarget)){this.fireEvent("mouseenter",A);}}},mouseleave:{type:"mouseout",map:function(A){A=new Event(A);
|
124 |
+
if(A.relatedTarget!=this&&!this.hasChild(A.relatedTarget)){this.fireEvent("mouseleave",A);}}},mousewheel:{type:(window.gecko)?"DOMMouseScroll":"mousewheel"}});
|
125 |
+
Element.NativeEvents=["click","dblclick","mouseup","mousedown","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","keydown","keypress","keyup","load","unload","beforeunload","resize","move","focus","blur","change","submit","reset","select","error","abort","contextmenu","scroll"];
|
126 |
+
Function.extend({bindWithEvent:function(B,A){return this.create({bind:B,arguments:A,event:Event});}});Elements.extend({filterByTag:function(A){return new Elements(this.filter(function(B){return(Element.getTag(B)==A);
|
127 |
+
}));},filterByClass:function(A,C){var B=this.filter(function(D){return(D.className&&D.className.contains(A," "));});return(C)?B:new Elements(B);},filterById:function(C,B){var A=this.filter(function(D){return(D.id==C);
|
128 |
+
});return(B)?A:new Elements(A);},filterByAttribute:function(B,A,D,E){var C=this.filter(function(F){var G=Element.getProperty(F,B);if(!G){return false;}if(!A){return true;
|
129 |
+
}switch(A){case"=":return(G==D);case"*=":return(G.contains(D));case"^=":return(G.substr(0,D.length)==D);case"$=":return(G.substr(G.length-D.length)==D);
|
130 |
+
case"!=":return(G!=D);case"~=":return G.contains(D," ");}return false;});return(E)?C:new Elements(C);}});function $E(A,B){return($(B)||document).getElement(A);
|
131 |
+
}function $ES(A,B){return($(B)||document).getElementsBySelector(A);}$.shared={regexp:/^(\w*|\*)(?:#([\w-]+)|\.([\w-]+))?(?:\[(\w+)(?:([!*^$]?=)["']?([^"'\]]*)["']?)?])?#x2F;,xpath:{getParam:function(B,D,E,C){var A=[D.namespaceURI?"xhtml:":"",E[1]];
|
132 |
+
if(E[2]){A.push('[@id="',E[2],'"]');}if(E[3]){A.push('[contains(concat(" ", @class, " "), " ',E[3],' ")]');}if(E[4]){if(E[5]&&E[6]){switch(E[5]){case"*=":A.push("[contains(@",E[4],', "',E[6],'")]');
|
133 |
+
break;case"^=":A.push("[starts-with(@",E[4],', "',E[6],'")]');break;case"$=":A.push("[substring(@",E[4],", string-length(@",E[4],") - ",E[6].length,' + 1) = "',E[6],'"]');
|
134 |
+
break;case"=":A.push("[@",E[4],'="',E[6],'"]');break;case"!=":A.push("[@",E[4],'!="',E[6],'"]');}}else{A.push("[@",E[4],"]");}}B.push(A.join(""));return B;
|
135 |
+
},getItems:function(B,E,G){var F=[];var A=document.evaluate(".//"+B.join("//"),E,$.shared.resolver,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);for(var D=0,C=A.snapshotLength;
|
136 |
+
D<C;D++){F.push(A.snapshotItem(D));}return(G)?F:new Elements(F.map($));}},normal:{getParam:function(A,C,E,B){if(B==0){if(E[2]){var D=C.getElementById(E[2]);
|
137 |
+
if(!D||((E[1]!="*")&&(Element.getTag(D)!=E[1]))){return false;}A=[D];}else{A=$A(C.getElementsByTagName(E[1]));}}else{A=$.shared.getElementsByTagName(A,E[1]);
|
138 |
+
if(E[2]){A=Elements.filterById(A,E[2],true);}}if(E[3]){A=Elements.filterByClass(A,E[3],true);}if(E[4]){A=Elements.filterByAttribute(A,E[4],E[5],E[6],true);
|
139 |
+
}return A;},getItems:function(A,B,C){return(C)?A:$.unique(A);}},resolver:function(A){return(A=="xhtml")?"http://www.w3.org/1999/xhtml":false;},getElementsByTagName:function(D,C){var E=[];
|
140 |
+
for(var B=0,A=D.length;B<A;B++){E.extend(D[B].getElementsByTagName(C));}return E;}};$.shared.method=(window.xpath)?"xpath":"normal";Element.Methods.Dom={getElements:function(A,H){var C=[];
|
141 |
+
A=A.trim().split(" ");for(var E=0,D=A.length;E<D;E++){var F=A[E];var G=F.match($.shared.regexp);if(!G){break;}G[1]=G[1]||"*";var B=$.shared[$.shared.method].getParam(C,this,G,E);
|
142 |
+
if(!B){break;}C=B;}return $.shared[$.shared.method].getItems(C,this,H);},getElement:function(A){return $(this.getElements(A,true)[0]||false);},getElementsBySelector:function(A,E){var D=[];
|
143 |
+
A=A.split(",");for(var C=0,B=A.length;C<B;C++){D=D.concat(this.getElements(A[C],true));}return(E)?D:$.unique(D);}};Element.extend({getElementById:function(C){var B=document.getElementById(C);
|
144 |
+
if(!B){return false;}for(var A=B.parentNode;A!=this;A=A.parentNode){if(!A){return false;}}return B;},getElementsByClassName:function(A){return this.getElements("."+A);
|
145 |
+
}});document.extend(Element.Methods.Dom);Element.extend(Element.Methods.Dom);Element.extend({getValue:function(){switch(this.getTag()){case"select":var A=[];
|
146 |
+
$each(this.options,function(B){if(B.selected){A.push($pick(B.value,B.text));}});return(this.multiple)?A:A[0];case"input":if(!(this.checked&&["checkbox","radio"].contains(this.type))&&!["hidden","text","password"].contains(this.type)){break;
|
147 |
+
}case"textarea":return this.value;}return false;},getFormElements:function(){return $(this.getElementsByTagName("input"),this.getElementsByTagName("select"),this.getElementsByTagName("textarea"));
|
148 |
+
},toQueryString:function(){var A=[];this.getFormElements().each(function(D){var C=D.name;var E=D.getValue();if(E===false||!C||D.disabled){return ;}var B=function(F){A.push(C+"="+encodeURIComponent(F));
|
149 |
+
};if($type(E)=="array"){E.each(B);}else{B(E);}});return A.join("&");}});Element.extend({scrollTo:function(A,B){this.scrollLeft=A;this.scrollTop=B;},getSize:function(){return{scroll:{x:this.scrollLeft,y:this.scrollTop},size:{x:this.offsetWidth,y:this.offsetHeight},scrollSize:{x:this.scrollWidth,y:this.scrollHeight}};
|
150 |
+
},getPosition:function(A){A=A||[];var B=this,D=0,C=0;do{D+=B.offsetLeft||0;C+=B.offsetTop||0;B=B.offsetParent;}while(B);A.each(function(E){D-=E.scrollLeft||0;
|
151 |
+
C-=E.scrollTop||0;});return{x:D,y:C};},getTop:function(A){return this.getPosition(A).y;},getLeft:function(A){return this.getPosition(A).x;},getCoordinates:function(B){var A=this.getPosition(B);
|
152 |
+
var C={width:this.offsetWidth,height:this.offsetHeight,left:A.x,top:A.y};C.right=C.left+C.width;C.bottom=C.top+C.height;return C;}});Element.Events.domready={add:function(B){if(window.loaded){B.call(this);
|
153 |
+
return ;}var A=function(){if(window.loaded){return ;}window.loaded=true;window.timer=$clear(window.timer);this.fireEvent("domready");}.bind(this);if(document.readyState&&window.webkit){window.timer=function(){if(["loaded","complete"].contains(document.readyState)){A();
|
154 |
+
}}.periodical(50);}else{if(document.readyState&&window.ie){if(!$("ie_ready")){var C=(window.location.protocol=="https:")?"://0":"javascript:void(0)";document.write('<script id="ie_ready" defer src="'+C+'"><\/script>');
|
155 |
+
$("ie_ready").onreadystatechange=function(){if(this.readyState=="complete"){A();}};}}else{window.addListener("load",A);document.addListener("DOMContentLoaded",A);
|
156 |
+
}}}};window.onDomReady=function(A){return this.addEvent("domready",A);};var Fx={};Fx.Base=new Class({options:{onStart:Class.empty,onComplete:Class.empty,onCancel:Class.empty,transition:function(A){return -(Math.cos(Math.PI*A)-1)/2;
|
157 |
+
},duration:500,unit:"px",wait:true,fps:50},initialize:function(A){this.element=this.element||null;this.setOptions(A);if(this.options.initialize){this.options.initialize.call(this);
|
158 |
+
}},step:function(){var A=$time();if(A<this.time+this.options.duration){this.delta=this.options.transition((A-this.time)/this.options.duration);this.setNow();
|
159 |
+
this.increase();}else{this.stop(true);this.set(this.to);this.fireEvent("onComplete",this.element,10);this.callChain();}},set:function(A){this.now=A;this.increase();
|
160 |
+
return this;},setNow:function(){this.now=this.compute(this.from,this.to);},compute:function(B,A){return(A-B)*this.delta+B;},start:function(B,A){if(!this.options.wait){this.stop();
|
161 |
+
}else{if(this.timer){return this;}}this.from=B;this.to=A;this.change=this.to-this.from;this.time=$time();this.timer=this.step.periodical(Math.round(1000/this.options.fps),this);
|
162 |
+
this.fireEvent("onStart",this.element);return this;},stop:function(A){if(!this.timer){return this;}this.timer=$clear(this.timer);if(!A){this.fireEvent("onCancel",this.element);
|
163 |
+
}return this;},custom:function(B,A){return this.start(B,A);},clearTimer:function(A){return this.stop(A);}});Fx.Base.implement(new Chain,new Events,new Options);
|
164 |
+
Fx.CSS={select:function(B,C){if(B.test(/color/i)){return this.Color;}var A=$type(C);if((A=="array")||(A=="string"&&C.contains(" "))){return this.Multi;
|
165 |
+
}return this.Single;},parse:function(C,D,A){if(!A.push){A=[A];}var F=A[0],E=A[1];if(!$chk(E)){E=F;F=C.getStyle(D);}var B=this.select(D,E);return{from:B.parse(F),to:B.parse(E),css:B};
|
166 |
+
}};Fx.CSS.Single={parse:function(A){return parseFloat(A);},getNow:function(C,B,A){return A.compute(C,B);},getValue:function(C,A,B){if(A=="px"&&B!="opacity"){C=Math.round(C);
|
167 |
+
}return C+A;}};Fx.CSS.Multi={parse:function(A){return A.push?A:A.split(" ").map(function(B){return parseFloat(B);});},getNow:function(E,D,C){var A=[];for(var B=0;
|
168 |
+
B<E.length;B++){A[B]=C.compute(E[B],D[B]);}return A;},getValue:function(C,A,B){if(A=="px"&&B!="opacity"){C=C.map(Math.round);}return C.join(A+" ")+A;}};
|
169 |
+
Fx.CSS.Color={parse:function(A){return A.push?A:A.hexToRgb(true);},getNow:function(E,D,C){var A=[];for(var B=0;B<E.length;B++){A[B]=Math.round(C.compute(E[B],D[B]));
|
170 |
+
}return A;},getValue:function(A){return"rgb("+A.join(",")+")";}};Fx.Style=Fx.Base.extend({initialize:function(B,C,A){this.element=$(B);this.property=C;
|
171 |
+
this.parent(A);},hide:function(){return this.set(0);},setNow:function(){this.now=this.css.getNow(this.from,this.to,this);},set:function(A){this.css=Fx.CSS.select(this.property,A);
|
172 |
+
return this.parent(this.css.parse(A));},start:function(C,B){if(this.timer&&this.options.wait){return this;}var A=Fx.CSS.parse(this.element,this.property,[C,B]);
|
173 |
+
this.css=A.css;return this.parent(A.from,A.to);},increase:function(){this.element.setStyle(this.property,this.css.getValue(this.now,this.options.unit,this.property));
|
174 |
+
}});Element.extend({effect:function(B,A){return new Fx.Style(this,B,A);}});Fx.Elements=Fx.Base.extend({initialize:function(B,A){this.elements=$(B);this.parent(A);
|
175 |
+
},setNow:function(){for(var C in this.from){var F=this.from[C],E=this.to[C],B=this.css[C],A=this.now[C]={};for(var D in F){A[D]=B[D].getNow(F[D],E[D],this);
|
176 |
+
}}},set:function(G){var B={};this.css={};for(var D in G){var F=G[D],C=this.css[D]={},A=B[D]={};for(var E in F){C[E]=Fx.CSS.select(E,F[E]);A[E]=C[E].parse(F[E]);
|
177 |
+
}}return this.parent(B);},start:function(D){if(this.timer&&this.options.wait){return this;}this.now={};this.css={};var I={},J={};for(var E in D){var G=D[E],A=I[E]={},H=J[E]={},C=this.css[E]={};
|
178 |
+
for(var B in G){var F=Fx.CSS.parse(this.elements[E],B,G[B]);A[B]=F.from;H[B]=F.to;C[B]=F.css;}}return this.parent(I,J);},increase:function(){for(var C in this.now){var A=this.now[C],B=this.css[C];
|
179 |
+
for(var D in A){this.elements[C].setStyle(D,B[D].getValue(A[D],this.options.unit,D));}}}});Fx.Slide=Fx.Base.extend({options:{mode:"vertical"},initialize:function(B,A){this.element=$(B);
|
180 |
+
this.wrapper=new Element("div",{styles:$extend(this.element.getStyles("margin"),{overflow:"hidden"})}).injectAfter(this.element).adopt(this.element);this.element.setStyle("margin",0);
|
181 |
+
this.setOptions(A);this.now=[];this.parent(this.options);this.open=true;this.addEvent("onComplete",function(){this.open=(this.now[0]===0);});if(window.webkit419){this.addEvent("onComplete",function(){if(this.open){this.element.remove().inject(this.wrapper);
|
182 |
+
}});}},setNow:function(){for(var A=0;A<2;A++){this.now[A]=this.compute(this.from[A],this.to[A]);}},vertical:function(){this.margin="margin-top";this.layout="height";
|
183 |
+
this.offset=this.element.offsetHeight;},horizontal:function(){this.margin="margin-left";this.layout="width";this.offset=this.element.offsetWidth;},slideIn:function(A){this[A||this.options.mode]();
|
184 |
+
return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[0,this.offset]);},slideOut:function(A){this[A||this.options.mode]();
|
185 |
+
return this.start([this.element.getStyle(this.margin).toInt(),this.wrapper.getStyle(this.layout).toInt()],[-this.offset,0]);},hide:function(A){this[A||this.options.mode]();
|
186 |
+
this.open=false;return this.set([-this.offset,0]);},show:function(A){this[A||this.options.mode]();this.open=true;return this.set([0,this.offset]);},toggle:function(A){if(this.wrapper.offsetHeight==0||this.wrapper.offsetWidth==0){return this.slideIn(A);
|
187 |
+
}return this.slideOut(A);},increase:function(){this.element.setStyle(this.margin,this.now[0]+this.options.unit);this.wrapper.setStyle(this.layout,this.now[1]+this.options.unit);
|
188 |
+
}});var Drag={};Drag.Base=new Class({options:{handle:false,unit:"px",onStart:Class.empty,onBeforeStart:Class.empty,onComplete:Class.empty,onSnap:Class.empty,onDrag:Class.empty,limit:false,modifiers:{x:"left",y:"top"},grid:false,snap:6},initialize:function(B,A){this.setOptions(A);
|
189 |
+
this.element=$(B);this.handle=$(this.options.handle)||this.element;this.mouse={now:{},pos:{}};this.value={start:{},now:{}};this.bound={start:this.start.bindWithEvent(this),check:this.check.bindWithEvent(this),drag:this.drag.bindWithEvent(this),stop:this.stop.bind(this)};
|
190 |
+
this.attach();if(this.options.initialize){this.options.initialize.call(this);}},attach:function(){this.handle.addEvent("mousedown",this.bound.start);return this;
|
191 |
+
},detach:function(){this.handle.removeEvent("mousedown",this.bound.start);return this;},start:function(C){this.fireEvent("onBeforeStart",this.element);
|
192 |
+
this.mouse.start=C.page;var A=this.options.limit;this.limit={x:[],y:[]};for(var D in this.options.modifiers){if(!this.options.modifiers[D]){continue;}this.value.now[D]=this.element.getStyle(this.options.modifiers[D]).toInt();
|
193 |
+
this.mouse.pos[D]=C.page[D]-this.value.now[D];if(A&&A[D]){for(var B=0;B<2;B++){if($chk(A[D][B])){this.limit[D][B]=($type(A[D][B])=="function")?A[D][B]():A[D][B];
|
194 |
+
}}}}if($type(this.options.grid)=="number"){this.options.grid={x:this.options.grid,y:this.options.grid};}document.addListener("mousemove",this.bound.check);
|
195 |
+
document.addListener("mouseup",this.bound.stop);this.fireEvent("onStart",this.element);C.stop();},check:function(A){var B=Math.round(Math.sqrt(Math.pow(A.page.x-this.mouse.start.x,2)+Math.pow(A.page.y-this.mouse.start.y,2)));
|
196 |
+
if(B>this.options.snap){document.removeListener("mousemove",this.bound.check);document.addListener("mousemove",this.bound.drag);this.drag(A);this.fireEvent("onSnap",this.element);
|
197 |
+
}A.stop();},drag:function(A){this.out=false;this.mouse.now=A.page;for(var B in this.options.modifiers){if(!this.options.modifiers[B]){continue;}this.value.now[B]=this.mouse.now[B]-this.mouse.pos[B];
|
198 |
+
if(this.limit[B]){if($chk(this.limit[B][1])&&(this.value.now[B]>this.limit[B][1])){this.value.now[B]=this.limit[B][1];this.out=true;}else{if($chk(this.limit[B][0])&&(this.value.now[B]<this.limit[B][0])){this.value.now[B]=this.limit[B][0];
|
199 |
+
this.out=true;}}}if(this.options.grid[B]){this.value.now[B]-=(this.value.now[B]%this.options.grid[B]);}this.element.setStyle(this.options.modifiers[B],this.value.now[B]+this.options.unit);
|
200 |
+
}this.fireEvent("onDrag",this.element);A.stop();},stop:function(){document.removeListener("mousemove",this.bound.check);document.removeListener("mousemove",this.bound.drag);
|
201 |
+
document.removeListener("mouseup",this.bound.stop);this.fireEvent("onComplete",this.element);}});Drag.Base.implement(new Events,new Options);Element.extend({makeResizable:function(A){return new Drag.Base(this,$merge({modifiers:{x:"width",y:"height"}},A));
|
202 |
+
}});var XHR=new Class({options:{method:"post",async:true,onRequest:Class.empty,onSuccess:Class.empty,onFailure:Class.empty,urlEncoded:true,encoding:"utf-8",autoCancel:false,headers:{}},setTransport:function(){this.transport=(window.XMLHttpRequest)?new XMLHttpRequest():(window.ie?new ActiveXObject("Microsoft.XMLHTTP"):false);
|
203 |
+
return this;},initialize:function(A){this.setTransport().setOptions(A);this.options.isSuccess=this.options.isSuccess||this.isSuccess;this.headers={};if(this.options.urlEncoded&&this.options.method=="post"){var B=(this.options.encoding)?"; charset="+this.options.encoding:"";
|
204 |
+
this.setHeader("Content-type","application/x-www-form-urlencoded"+B);}if(this.options.initialize){this.options.initialize.call(this);}},onStateChange:function(){if(this.transport.readyState!=4||!this.running){return ;
|
205 |
+
}this.running=false;var A=0;try{A=this.transport.status;}catch(B){}if(this.options.isSuccess.call(this,A)){this.onSuccess();}else{this.onFailure();}this.transport.onreadystatechange=Class.empty;
|
206 |
+
},isSuccess:function(A){return((A>=200)&&(A<300));},onSuccess:function(){this.response={text:this.transport.responseText,xml:this.transport.responseXML};
|
207 |
+
this.fireEvent("onSuccess",[this.response.text,this.response.xml]);this.callChain();},onFailure:function(){this.fireEvent("onFailure",this.transport);},setHeader:function(A,B){this.headers[A]=B;
|
208 |
+
return this;},send:function(A,C){if(this.options.autoCancel){this.cancel();}else{if(this.running){return this;}}this.running=true;if(C&&this.options.method=="get"){A=A+(A.contains("?")?"&":"?")+C;
|
209 |
+
C=null;}this.transport.open(this.options.method.toUpperCase(),A,this.options.async);this.transport.onreadystatechange=this.onStateChange.bind(this);if((this.options.method=="post")&&this.transport.overrideMimeType){this.setHeader("Connection","close");
|
210 |
+
}$extend(this.headers,this.options.headers);for(var B in this.headers){try{this.transport.setRequestHeader(B,this.headers[B]);}catch(D){}}this.fireEvent("onRequest");
|
211 |
+
this.transport.send($pick(C,null));return this;},cancel:function(){if(!this.running){return this;}this.running=false;this.transport.abort();this.transport.onreadystatechange=Class.empty;
|
212 |
+
this.setTransport();this.fireEvent("onCancel");return this;}});XHR.implement(new Chain,new Events,new Options);var Ajax=XHR.extend({options:{data:null,update:null,onComplete:Class.empty,evalScripts:false,evalResponse:false},initialize:function(B,A){this.addEvent("onSuccess",this.onComplete);
|
213 |
+
this.setOptions(A);this.options.data=this.options.data||this.options.postBody;if(!["post","get"].contains(this.options.method)){this._method="_method="+this.options.method;
|
214 |
+
this.options.method="post";}this.parent();this.setHeader("X-Requested-With","XMLHttpRequest");this.setHeader("Accept","text/javascript, text/html, application/xml, text/xml, */*");
|
215 |
+
this.url=B;},onComplete:function(){if(this.options.update){$(this.options.update).empty().setHTML(this.response.text);}if(this.options.evalScripts||this.options.evalResponse){this.evalScripts();
|
216 |
+
}this.fireEvent("onComplete",[this.response.text,this.response.xml],20);},request:function(A){A=A||this.options.data;switch($type(A)){case"element":A=$(A).toQueryString();
|
217 |
+
break;case"object":A=Object.toQueryString(A);}if(this._method){A=(A)?[this._method,A].join("&"):this._method;}return this.send(this.url,A);},evalScripts:function(){var B,A;
|
218 |
+
if(this.options.evalResponse||(/(ecma|java)script/).test(this.getHeader("Content-type"))){A=this.response.text;}else{A=[];var C=/<script[^>]*>([\s\S]*?)<\/script>/gi;
|
219 |
+
while((B=C.exec(this.response.text))){A.push(B[1]);}A=A.join("\n");}if(A){(window.execScript)?window.execScript(A):window.setTimeout(A,0);}},getHeader:function(A){try{return this.transport.getResponseHeader(A);
|
220 |
+
}catch(B){}return null;}});Object.toQueryString=function(B){var C=[];for(var A in B){C.push(encodeURIComponent(A)+"="+encodeURIComponent(B[A]));}return C.join("&");
|
221 |
+
};Element.extend({send:function(A){return new Ajax(this.getProperty("action"),$merge({data:this.toQueryString()},A,{method:"post"})).request();}});var Sortables=new Class({options:{handles:false,onStart:Class.empty,onComplete:Class.empty,ghost:true,snap:3,onDragStart:function(A,B){B.setStyle("opacity",0.7);
|
222 |
+
A.setStyle("opacity",0.7);},onDragComplete:function(A,B){A.setStyle("opacity",1);B.remove();this.trash.remove();}},initialize:function(D,B){this.setOptions(B);
|
223 |
+
this.list=$(D);this.elements=this.list.getChildren();this.handles=(this.options.handles)?$(this.options.handles):this.elements;this.bound={start:[],moveGhost:this.moveGhost.bindWithEvent(this)};
|
224 |
+
for(var C=0,A=this.handles.length;C<A;C++){this.bound.start[C]=this.start.bindWithEvent(this,this.elements[C]);}this.attach();if(this.options.initialize){this.options.initialize.call(this);
|
225 |
+
}this.bound.move=this.move.bindWithEvent(this);this.bound.end=this.end.bind(this);},attach:function(){this.handles.each(function(B,A){B.addEvent("mousedown",this.bound.start[A]);
|
226 |
+
},this);},detach:function(){this.handles.each(function(B,A){B.removeEvent("mousedown",this.bound.start[A]);},this);},start:function(C,B){this.active=B;
|
227 |
+
this.coordinates=this.list.getCoordinates();if(this.options.ghost){var A=B.getPosition();this.offset=C.page.y-A.y;this.trash=new Element("div").inject(document.body);
|
228 |
+
this.ghost=B.clone().inject(this.trash).setStyles({position:"absolute",left:A.x,top:C.page.y-this.offset});document.addListener("mousemove",this.bound.moveGhost);
|
229 |
+
this.fireEvent("onDragStart",[B,this.ghost]);}document.addListener("mousemove",this.bound.move);document.addListener("mouseup",this.bound.end);this.fireEvent("onStart",B);
|
230 |
+
C.stop();},moveGhost:function(A){var B=A.page.y-this.offset;B=B.limit(this.coordinates.top,this.coordinates.bottom-this.ghost.offsetHeight);this.ghost.setStyle("top",B);
|
231 |
+
A.stop();},move:function(E){var B=E.page.y;this.previous=this.previous||B;var A=((this.previous-B)>0);var D=this.active.getPrevious();var C=this.active.getNext();
|
232 |
+
if(D&&A&&B<D.getCoordinates().bottom){this.active.injectBefore(D);}if(C&&!A&&B>C.getCoordinates().top){this.active.injectAfter(C);}this.previous=B;},serialize:function(A){return this.list.getChildren().map(A||function(B){return this.elements.indexOf(B);
|
233 |
+
},this);},end:function(){this.previous=null;document.removeListener("mousemove",this.bound.move);document.removeListener("mouseup",this.bound.end);if(this.options.ghost){document.removeListener("mousemove",this.bound.moveGhost);
|
234 |
+
this.fireEvent("onDragComplete",[this.active,this.ghost]);}this.fireEvent("onComplete",this.active);}});Sortables.implement(new Events,new Options);var Accordion=Fx.Elements.extend({options:{onActive:Class.empty,onBackground:Class.empty,display:0,show:false,height:true,width:false,opacity:true,fixedHeight:false,fixedWidth:false,wait:false,alwaysHide:false},initialize:function(){var C,E,F,B;
|
235 |
+
$each(arguments,function(I,H){switch($type(I)){case"object":C=I;break;case"element":B=$(I);break;default:var G=$(I);if(!E){E=G;}else{F=G;}}});this.togglers=E||[];
|
236 |
+
this.elements=F||[];this.container=$(B);this.setOptions(C);this.previous=-1;if(this.options.alwaysHide){this.options.wait=true;}if($chk(this.options.show)){this.options.display=false;
|
237 |
+
this.previous=this.options.show;}if(this.options.start){this.options.display=false;this.options.show=false;}this.effects={};if(this.options.opacity){this.effects.opacity="fullOpacity";
|
238 |
+
}if(this.options.width){this.effects.width=this.options.fixedWidth?"fullWidth":"offsetWidth";}if(this.options.height){this.effects.height=this.options.fixedHeight?"fullHeight":"scrollHeight";
|
239 |
+
}for(var D=0,A=this.togglers.length;D<A;D++){this.addSection(this.togglers[D],this.elements[D]);}this.elements.each(function(H,G){if(this.options.show===G){this.fireEvent("onActive",[this.togglers[G],H]);
|
240 |
+
}else{for(var I in this.effects){H.setStyle(I,0);}}},this);this.parent(this.elements);if($chk(this.options.display)){this.display(this.options.display);
|
241 |
+
}},addSection:function(E,C,G){E=$(E);C=$(C);var F=this.togglers.contains(E);var B=this.togglers.length;this.togglers.include(E);this.elements.include(C);
|
242 |
+
if(B&&(!F||G)){G=$pick(G,B-1);E.injectBefore(this.togglers[G]);C.injectAfter(E);}else{if(this.container&&!F){E.inject(this.container);C.inject(this.container);
|
243 |
+
}}var A=this.togglers.indexOf(E);E.addEvent("click",this.display.bind(this,A));if(this.options.height){C.setStyles({"padding-top":0,"border-top":"none","padding-bottom":0,"border-bottom":"none"});
|
244 |
+
}if(this.options.width){C.setStyles({"padding-left":0,"border-left":"none","padding-right":0,"border-right":"none"});}C.fullOpacity=1;if(this.options.fixedWidth){C.fullWidth=this.options.fixedWidth;
|
245 |
+
}if(this.options.fixedHeight){C.fullHeight=this.options.fixedHeight;}C.setStyle("overflow","hidden");if(!F){for(var D in this.effects){C.setStyle(D,0);
|
246 |
+
}}return this;},display:function(A){A=($type(A)=="element")?this.elements.indexOf(A):A;if((this.timer&&this.options.wait)||(A===this.previous&&!this.options.alwaysHide)){return this;
|
247 |
+
}this.previous=A;var B={};this.elements.each(function(E,D){B[D]={};var C=(D!=A)||(this.options.alwaysHide&&(E.offsetHeight>0));this.fireEvent(C?"onBackground":"onActive",[this.togglers[D],E]);
|
248 |
+
for(var F in this.effects){B[D][F]=C?0:E[this.effects[F]];}},this);return this.start(B);},showThisHideOpen:function(A){return this.display(A);}});Fx.Accordion=Accordion;
|
myjson.php
DELETED
@@ -1,806 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Converts to and from JSON format.
|
6 |
-
*
|
7 |
-
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
8 |
-
* format. It is easy for humans to read and write. It is easy for machines
|
9 |
-
* to parse and generate. It is based on a subset of the JavaScript
|
10 |
-
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
11 |
-
* This feature can also be found in Python. JSON is a text format that is
|
12 |
-
* completely language independent but uses conventions that are familiar
|
13 |
-
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
14 |
-
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
15 |
-
* ideal data-interchange language.
|
16 |
-
*
|
17 |
-
* This package provides a simple encoder and decoder for JSON notation. It
|
18 |
-
* is intended for use with client-side Javascript applications that make
|
19 |
-
* use of HTTPRequest to perform server communication functions - data can
|
20 |
-
* be encoded into JSON notation for use in a client-side javascript, or
|
21 |
-
* decoded from incoming Javascript requests. JSON format is native to
|
22 |
-
* Javascript, and can be directly eval()'ed with no further parsing
|
23 |
-
* overhead
|
24 |
-
*
|
25 |
-
* All strings should be in ASCII or UTF-8 format!
|
26 |
-
*
|
27 |
-
* LICENSE: Redistribution and use in source and binary forms, with or
|
28 |
-
* without modification, are permitted provided that the following
|
29 |
-
* conditions are met: Redistributions of source code must retain the
|
30 |
-
* above copyright notice, this list of conditions and the following
|
31 |
-
* disclaimer. Redistributions in binary form must reproduce the above
|
32 |
-
* copyright notice, this list of conditions and the following disclaimer
|
33 |
-
* in the documentation and/or other materials provided with the
|
34 |
-
* distribution.
|
35 |
-
*
|
36 |
-
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
37 |
-
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
38 |
-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
39 |
-
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
40 |
-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
41 |
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
42 |
-
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
43 |
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
44 |
-
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
45 |
-
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
46 |
-
* DAMAGE.
|
47 |
-
*
|
48 |
-
* @category
|
49 |
-
* @package Services_JSON
|
50 |
-
* @author Michal Migurski <mike-json@teczno.com>
|
51 |
-
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
52 |
-
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
53 |
-
* @copyright 2005 Michal Migurski
|
54 |
-
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
55 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
56 |
-
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
57 |
-
*/
|
58 |
-
|
59 |
-
/**
|
60 |
-
* Marker constant for Services_JSON::decode(), used to flag stack state
|
61 |
-
*/
|
62 |
-
define('SERVICES_JSON_SLICE', 1);
|
63 |
-
|
64 |
-
/**
|
65 |
-
* Marker constant for Services_JSON::decode(), used to flag stack state
|
66 |
-
*/
|
67 |
-
define('SERVICES_JSON_IN_STR', 2);
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Marker constant for Services_JSON::decode(), used to flag stack state
|
71 |
-
*/
|
72 |
-
define('SERVICES_JSON_IN_ARR', 3);
|
73 |
-
|
74 |
-
/**
|
75 |
-
* Marker constant for Services_JSON::decode(), used to flag stack state
|
76 |
-
*/
|
77 |
-
define('SERVICES_JSON_IN_OBJ', 4);
|
78 |
-
|
79 |
-
/**
|
80 |
-
* Marker constant for Services_JSON::decode(), used to flag stack state
|
81 |
-
*/
|
82 |
-
define('SERVICES_JSON_IN_CMT', 5);
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Behavior switch for Services_JSON::decode()
|
86 |
-
*/
|
87 |
-
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
88 |
-
|
89 |
-
/**
|
90 |
-
* Behavior switch for Services_JSON::decode()
|
91 |
-
*/
|
92 |
-
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
93 |
-
|
94 |
-
/**
|
95 |
-
* Converts to and from JSON format.
|
96 |
-
*
|
97 |
-
* Brief example of use:
|
98 |
-
*
|
99 |
-
* <code>
|
100 |
-
* // create a new instance of Services_JSON
|
101 |
-
* $json = new Services_JSON();
|
102 |
-
*
|
103 |
-
* // convert a complexe value to JSON notation, and send it to the browser
|
104 |
-
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
105 |
-
* $output = $json->encode($value);
|
106 |
-
*
|
107 |
-
* print($output);
|
108 |
-
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
109 |
-
*
|
110 |
-
* // accept incoming POST data, assumed to be in JSON notation
|
111 |
-
* $input = file_get_contents('php://input', 1000000);
|
112 |
-
* $value = $json->decode($input);
|
113 |
-
* </code>
|
114 |
-
*/
|
115 |
-
class Services_JSON
|
116 |
-
{
|
117 |
-
/**
|
118 |
-
* constructs a new JSON instance
|
119 |
-
*
|
120 |
-
* @param int $use object behavior flags; combine with boolean-OR
|
121 |
-
*
|
122 |
-
* possible values:
|
123 |
-
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
124 |
-
* "{...}" syntax creates associative arrays
|
125 |
-
* instead of objects in decode().
|
126 |
-
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
127 |
-
* Values which can't be encoded (e.g. resources)
|
128 |
-
* appear as NULL instead of throwing errors.
|
129 |
-
* By default, a deeply-nested resource will
|
130 |
-
* bubble up with an error, so all return values
|
131 |
-
* from encode() should be checked with isError()
|
132 |
-
*/
|
133 |
-
function Services_JSON($use = 0)
|
134 |
-
{
|
135 |
-
$this->use = $use;
|
136 |
-
}
|
137 |
-
|
138 |
-
/**
|
139 |
-
* convert a string from one UTF-16 char to one UTF-8 char
|
140 |
-
*
|
141 |
-
* Normally should be handled by mb_convert_encoding, but
|
142 |
-
* provides a slower PHP-only method for installations
|
143 |
-
* that lack the multibye string extension.
|
144 |
-
*
|
145 |
-
* @param string $utf16 UTF-16 character
|
146 |
-
* @return string UTF-8 character
|
147 |
-
* @access private
|
148 |
-
*/
|
149 |
-
function utf162utf8($utf16)
|
150 |
-
{
|
151 |
-
// oh please oh please oh please oh please oh please
|
152 |
-
if(function_exists('mb_convert_encoding')) {
|
153 |
-
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
154 |
-
}
|
155 |
-
|
156 |
-
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
157 |
-
|
158 |
-
switch(true) {
|
159 |
-
case ((0x7F & $bytes) == $bytes):
|
160 |
-
// this case should never be reached, because we are in ASCII range
|
161 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
162 |
-
return chr(0x7F & $bytes);
|
163 |
-
|
164 |
-
case (0x07FF & $bytes) == $bytes:
|
165 |
-
// return a 2-byte UTF-8 character
|
166 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
167 |
-
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
168 |
-
. chr(0x80 | ($bytes & 0x3F));
|
169 |
-
|
170 |
-
case (0xFFFF & $bytes) == $bytes:
|
171 |
-
// return a 3-byte UTF-8 character
|
172 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
173 |
-
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
174 |
-
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
175 |
-
. chr(0x80 | ($bytes & 0x3F));
|
176 |
-
}
|
177 |
-
|
178 |
-
// ignoring UTF-32 for now, sorry
|
179 |
-
return '';
|
180 |
-
}
|
181 |
-
|
182 |
-
/**
|
183 |
-
* convert a string from one UTF-8 char to one UTF-16 char
|
184 |
-
*
|
185 |
-
* Normally should be handled by mb_convert_encoding, but
|
186 |
-
* provides a slower PHP-only method for installations
|
187 |
-
* that lack the multibye string extension.
|
188 |
-
*
|
189 |
-
* @param string $utf8 UTF-8 character
|
190 |
-
* @return string UTF-16 character
|
191 |
-
* @access private
|
192 |
-
*/
|
193 |
-
function utf82utf16($utf8)
|
194 |
-
{
|
195 |
-
// oh please oh please oh please oh please oh please
|
196 |
-
if(function_exists('mb_convert_encoding')) {
|
197 |
-
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
198 |
-
}
|
199 |
-
|
200 |
-
switch(strlen($utf8)) {
|
201 |
-
case 1:
|
202 |
-
// this case should never be reached, because we are in ASCII range
|
203 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
204 |
-
return $utf8;
|
205 |
-
|
206 |
-
case 2:
|
207 |
-
// return a UTF-16 character from a 2-byte UTF-8 char
|
208 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
209 |
-
return chr(0x07 & (ord($utf8{0}) >> 2))
|
210 |
-
. chr((0xC0 & (ord($utf8{0}) << 6))
|
211 |
-
| (0x3F & ord($utf8{1})));
|
212 |
-
|
213 |
-
case 3:
|
214 |
-
// return a UTF-16 character from a 3-byte UTF-8 char
|
215 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
216 |
-
return chr((0xF0 & (ord($utf8{0}) << 4))
|
217 |
-
| (0x0F & (ord($utf8{1}) >> 2)))
|
218 |
-
. chr((0xC0 & (ord($utf8{1}) << 6))
|
219 |
-
| (0x7F & ord($utf8{2})));
|
220 |
-
}
|
221 |
-
|
222 |
-
// ignoring UTF-32 for now, sorry
|
223 |
-
return '';
|
224 |
-
}
|
225 |
-
|
226 |
-
/**
|
227 |
-
* encodes an arbitrary variable into JSON format
|
228 |
-
*
|
229 |
-
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
230 |
-
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
231 |
-
* if var is a strng, note that encode() always expects it
|
232 |
-
* to be in ASCII or UTF-8 format!
|
233 |
-
*
|
234 |
-
* @return mixed JSON string representation of input var or an error if a problem occurs
|
235 |
-
* @access public
|
236 |
-
*/
|
237 |
-
function encode($var)
|
238 |
-
{
|
239 |
-
switch (gettype($var)) {
|
240 |
-
case 'boolean':
|
241 |
-
return $var ? 'true' : 'false';
|
242 |
-
|
243 |
-
case 'NULL':
|
244 |
-
return 'null';
|
245 |
-
|
246 |
-
case 'integer':
|
247 |
-
return (int) $var;
|
248 |
-
|
249 |
-
case 'double':
|
250 |
-
case 'float':
|
251 |
-
return (float) $var;
|
252 |
-
|
253 |
-
case 'string':
|
254 |
-
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
255 |
-
$ascii = '';
|
256 |
-
$strlen_var = strlen($var);
|
257 |
-
|
258 |
-
/*
|
259 |
-
* Iterate over every character in the string,
|
260 |
-
* escaping with a slash or encoding to UTF-8 where necessary
|
261 |
-
*/
|
262 |
-
for ($c = 0; $c < $strlen_var; ++$c) {
|
263 |
-
|
264 |
-
$ord_var_c = ord($var{$c});
|
265 |
-
|
266 |
-
switch (true) {
|
267 |
-
case $ord_var_c == 0x08:
|
268 |
-
$ascii .= '\b';
|
269 |
-
break;
|
270 |
-
case $ord_var_c == 0x09:
|
271 |
-
$ascii .= '\t';
|
272 |
-
break;
|
273 |
-
case $ord_var_c == 0x0A:
|
274 |
-
$ascii .= '\n';
|
275 |
-
break;
|
276 |
-
case $ord_var_c == 0x0C:
|
277 |
-
$ascii .= '\f';
|
278 |
-
break;
|
279 |
-
case $ord_var_c == 0x0D:
|
280 |
-
$ascii .= '\r';
|
281 |
-
break;
|
282 |
-
|
283 |
-
case $ord_var_c == 0x22:
|
284 |
-
case $ord_var_c == 0x2F:
|
285 |
-
case $ord_var_c == 0x5C:
|
286 |
-
// double quote, slash, slosh
|
287 |
-
$ascii .= '\\'.$var{$c};
|
288 |
-
break;
|
289 |
-
|
290 |
-
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
291 |
-
// characters U-00000000 - U-0000007F (same as ASCII)
|
292 |
-
$ascii .= $var{$c};
|
293 |
-
break;
|
294 |
-
|
295 |
-
case (($ord_var_c & 0xE0) == 0xC0):
|
296 |
-
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
297 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
298 |
-
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
299 |
-
$c += 1;
|
300 |
-
$utf16 = $this->utf82utf16($char);
|
301 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
302 |
-
break;
|
303 |
-
|
304 |
-
case (($ord_var_c & 0xF0) == 0xE0):
|
305 |
-
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
306 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
307 |
-
$char = pack('C*', $ord_var_c,
|
308 |
-
ord($var{$c + 1}),
|
309 |
-
ord($var{$c + 2}));
|
310 |
-
$c += 2;
|
311 |
-
$utf16 = $this->utf82utf16($char);
|
312 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
313 |
-
break;
|
314 |
-
|
315 |
-
case (($ord_var_c & 0xF8) == 0xF0):
|
316 |
-
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
317 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
318 |
-
$char = pack('C*', $ord_var_c,
|
319 |
-
ord($var{$c + 1}),
|
320 |
-
ord($var{$c + 2}),
|
321 |
-
ord($var{$c + 3}));
|
322 |
-
$c += 3;
|
323 |
-
$utf16 = $this->utf82utf16($char);
|
324 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
325 |
-
break;
|
326 |
-
|
327 |
-
case (($ord_var_c & 0xFC) == 0xF8):
|
328 |
-
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
329 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
330 |
-
$char = pack('C*', $ord_var_c,
|
331 |
-
ord($var{$c + 1}),
|
332 |
-
ord($var{$c + 2}),
|
333 |
-
ord($var{$c + 3}),
|
334 |
-
ord($var{$c + 4}));
|
335 |
-
$c += 4;
|
336 |
-
$utf16 = $this->utf82utf16($char);
|
337 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
338 |
-
break;
|
339 |
-
|
340 |
-
case (($ord_var_c & 0xFE) == 0xFC):
|
341 |
-
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
342 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
343 |
-
$char = pack('C*', $ord_var_c,
|
344 |
-
ord($var{$c + 1}),
|
345 |
-
ord($var{$c + 2}),
|
346 |
-
ord($var{$c + 3}),
|
347 |
-
ord($var{$c + 4}),
|
348 |
-
ord($var{$c + 5}));
|
349 |
-
$c += 5;
|
350 |
-
$utf16 = $this->utf82utf16($char);
|
351 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
352 |
-
break;
|
353 |
-
}
|
354 |
-
}
|
355 |
-
|
356 |
-
return '"'.$ascii.'"';
|
357 |
-
|
358 |
-
case 'array':
|
359 |
-
/*
|
360 |
-
* As per JSON spec if any array key is not an integer
|
361 |
-
* we must treat the the whole array as an object. We
|
362 |
-
* also try to catch a sparsely populated associative
|
363 |
-
* array with numeric keys here because some JS engines
|
364 |
-
* will create an array with empty indexes up to
|
365 |
-
* max_index which can cause memory issues and because
|
366 |
-
* the keys, which may be relevant, will be remapped
|
367 |
-
* otherwise.
|
368 |
-
*
|
369 |
-
* As per the ECMA and JSON specification an object may
|
370 |
-
* have any string as a property. Unfortunately due to
|
371 |
-
* a hole in the ECMA specification if the key is a
|
372 |
-
* ECMA reserved word or starts with a digit the
|
373 |
-
* parameter is only accessible using ECMAScript's
|
374 |
-
* bracket notation.
|
375 |
-
*/
|
376 |
-
|
377 |
-
// treat as a JSON object
|
378 |
-
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
379 |
-
$properties = array_map(array($this, 'name_value'),
|
380 |
-
array_keys($var),
|
381 |
-
array_values($var));
|
382 |
-
|
383 |
-
foreach($properties as $property) {
|
384 |
-
if(Services_JSON::isError($property)) {
|
385 |
-
return $property;
|
386 |
-
}
|
387 |
-
}
|
388 |
-
|
389 |
-
return '{' . join(',', $properties) . '}';
|
390 |
-
}
|
391 |
-
|
392 |
-
// treat it like a regular array
|
393 |
-
$elements = array_map(array($this, 'encode'), $var);
|
394 |
-
|
395 |
-
foreach($elements as $element) {
|
396 |
-
if(Services_JSON::isError($element)) {
|
397 |
-
return $element;
|
398 |
-
}
|
399 |
-
}
|
400 |
-
|
401 |
-
return '[' . join(',', $elements) . ']';
|
402 |
-
|
403 |
-
case 'object':
|
404 |
-
$vars = get_object_vars($var);
|
405 |
-
|
406 |
-
$properties = array_map(array($this, 'name_value'),
|
407 |
-
array_keys($vars),
|
408 |
-
array_values($vars));
|
409 |
-
|
410 |
-
foreach($properties as $property) {
|
411 |
-
if(Services_JSON::isError($property)) {
|
412 |
-
return $property;
|
413 |
-
}
|
414 |
-
}
|
415 |
-
|
416 |
-
return '{' . join(',', $properties) . '}';
|
417 |
-
|
418 |
-
default:
|
419 |
-
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
420 |
-
? 'null'
|
421 |
-
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
422 |
-
}
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* array-walking function for use in generating JSON-formatted name-value pairs
|
427 |
-
*
|
428 |
-
* @param string $name name of key to use
|
429 |
-
* @param mixed $value reference to an array element to be encoded
|
430 |
-
*
|
431 |
-
* @return string JSON-formatted name-value pair, like '"name":value'
|
432 |
-
* @access private
|
433 |
-
*/
|
434 |
-
function name_value($name, $value)
|
435 |
-
{
|
436 |
-
$encoded_value = $this->encode($value);
|
437 |
-
|
438 |
-
if(Services_JSON::isError($encoded_value)) {
|
439 |
-
return $encoded_value;
|
440 |
-
}
|
441 |
-
|
442 |
-
return $this->encode(strval($name)) . ':' . $encoded_value;
|
443 |
-
}
|
444 |
-
|
445 |
-
/**
|
446 |
-
* reduce a string by removing leading and trailing comments and whitespace
|
447 |
-
*
|
448 |
-
* @param $str string string value to strip of comments and whitespace
|
449 |
-
*
|
450 |
-
* @return string string value stripped of comments and whitespace
|
451 |
-
* @access private
|
452 |
-
*/
|
453 |
-
function reduce_string($str)
|
454 |
-
{
|
455 |
-
$str = preg_replace(array(
|
456 |
-
|
457 |
-
// eliminate single line comments in '// ...' form
|
458 |
-
'#^\s*//(.+)$#m',
|
459 |
-
|
460 |
-
// eliminate multi-line comments in '/* ... */' form, at start of string
|
461 |
-
'#^\s*/\*(.+)\*/#Us',
|
462 |
-
|
463 |
-
// eliminate multi-line comments in '/* ... */' form, at end of string
|
464 |
-
'#/\*(.+)\*/\s*$#Us'
|
465 |
-
|
466 |
-
), '', $str);
|
467 |
-
|
468 |
-
// eliminate extraneous space
|
469 |
-
return trim($str);
|
470 |
-
}
|
471 |
-
|
472 |
-
/**
|
473 |
-
* decodes a JSON string into appropriate variable
|
474 |
-
*
|
475 |
-
* @param string $str JSON-formatted string
|
476 |
-
*
|
477 |
-
* @return mixed number, boolean, string, array, or object
|
478 |
-
* corresponding to given JSON input string.
|
479 |
-
* See argument 1 to Services_JSON() above for object-output behavior.
|
480 |
-
* Note that decode() always returns strings
|
481 |
-
* in ASCII or UTF-8 format!
|
482 |
-
* @access public
|
483 |
-
*/
|
484 |
-
function decode($str)
|
485 |
-
{
|
486 |
-
$str = $this->reduce_string($str);
|
487 |
-
|
488 |
-
switch (strtolower($str)) {
|
489 |
-
case 'true':
|
490 |
-
return true;
|
491 |
-
|
492 |
-
case 'false':
|
493 |
-
return false;
|
494 |
-
|
495 |
-
case 'null':
|
496 |
-
return null;
|
497 |
-
|
498 |
-
default:
|
499 |
-
$m = array();
|
500 |
-
|
501 |
-
if (is_numeric($str)) {
|
502 |
-
// Lookie-loo, it's a number
|
503 |
-
|
504 |
-
// This would work on its own, but I'm trying to be
|
505 |
-
// good about returning integers where appropriate:
|
506 |
-
// return (float)$str;
|
507 |
-
|
508 |
-
// Return float or int, as appropriate
|
509 |
-
return ((float)$str == (integer)$str)
|
510 |
-
? (integer)$str
|
511 |
-
: (float)$str;
|
512 |
-
|
513 |
-
} elseif (preg_match('/^("|\').*(\1)#x2F;s', $str, $m) && $m[1] == $m[2]) {
|
514 |
-
// STRINGS RETURNED IN UTF-8 FORMAT
|
515 |
-
$delim = substr($str, 0, 1);
|
516 |
-
$chrs = substr($str, 1, -1);
|
517 |
-
$utf8 = '';
|
518 |
-
$strlen_chrs = strlen($chrs);
|
519 |
-
|
520 |
-
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
521 |
-
|
522 |
-
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
523 |
-
$ord_chrs_c = ord($chrs{$c});
|
524 |
-
|
525 |
-
switch (true) {
|
526 |
-
case $substr_chrs_c_2 == '\b':
|
527 |
-
$utf8 .= chr(0x08);
|
528 |
-
++$c;
|
529 |
-
break;
|
530 |
-
case $substr_chrs_c_2 == '\t':
|
531 |
-
$utf8 .= chr(0x09);
|
532 |
-
++$c;
|
533 |
-
break;
|
534 |
-
case $substr_chrs_c_2 == '\n':
|
535 |
-
$utf8 .= chr(0x0A);
|
536 |
-
++$c;
|
537 |
-
break;
|
538 |
-
case $substr_chrs_c_2 == '\f':
|
539 |
-
$utf8 .= chr(0x0C);
|
540 |
-
++$c;
|
541 |
-
break;
|
542 |
-
case $substr_chrs_c_2 == '\r':
|
543 |
-
$utf8 .= chr(0x0D);
|
544 |
-
++$c;
|
545 |
-
break;
|
546 |
-
|
547 |
-
case $substr_chrs_c_2 == '\\"':
|
548 |
-
case $substr_chrs_c_2 == '\\\'':
|
549 |
-
case $substr_chrs_c_2 == '\\\\':
|
550 |
-
case $substr_chrs_c_2 == '\\/':
|
551 |
-
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
552 |
-
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
553 |
-
$utf8 .= $chrs{++$c};
|
554 |
-
}
|
555 |
-
break;
|
556 |
-
|
557 |
-
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
|
558 |
-
// single, escaped unicode character
|
559 |
-
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
|
560 |
-
. chr(hexdec(substr($chrs, ($c + 4), 2)));
|
561 |
-
$utf8 .= $this->utf162utf8($utf16);
|
562 |
-
$c += 5;
|
563 |
-
break;
|
564 |
-
|
565 |
-
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
566 |
-
$utf8 .= $chrs{$c};
|
567 |
-
break;
|
568 |
-
|
569 |
-
case ($ord_chrs_c & 0xE0) == 0xC0:
|
570 |
-
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
571 |
-
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
572 |
-
$utf8 .= substr($chrs, $c, 2);
|
573 |
-
++$c;
|
574 |
-
break;
|
575 |
-
|
576 |
-
case ($ord_chrs_c & 0xF0) == 0xE0:
|
577 |
-
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
578 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
579 |
-
$utf8 .= substr($chrs, $c, 3);
|
580 |
-
$c += 2;
|
581 |
-
break;
|
582 |
-
|
583 |
-
case ($ord_chrs_c & 0xF8) == 0xF0:
|
584 |
-
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
585 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
586 |
-
$utf8 .= substr($chrs, $c, 4);
|
587 |
-
$c += 3;
|
588 |
-
break;
|
589 |
-
|
590 |
-
case ($ord_chrs_c & 0xFC) == 0xF8:
|
591 |
-
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
592 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
593 |
-
$utf8 .= substr($chrs, $c, 5);
|
594 |
-
$c += 4;
|
595 |
-
break;
|
596 |
-
|
597 |
-
case ($ord_chrs_c & 0xFE) == 0xFC:
|
598 |
-
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
599 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
600 |
-
$utf8 .= substr($chrs, $c, 6);
|
601 |
-
$c += 5;
|
602 |
-
break;
|
603 |
-
|
604 |
-
}
|
605 |
-
|
606 |
-
}
|
607 |
-
|
608 |
-
return $utf8;
|
609 |
-
|
610 |
-
} elseif (preg_match('/^\[.*\]#x2F;s', $str) || preg_match('/^\{.*\}#x2F;s', $str)) {
|
611 |
-
// array, or object notation
|
612 |
-
|
613 |
-
if ($str{0} == '[') {
|
614 |
-
$stk = array(SERVICES_JSON_IN_ARR);
|
615 |
-
$arr = array();
|
616 |
-
} else {
|
617 |
-
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
618 |
-
$stk = array(SERVICES_JSON_IN_OBJ);
|
619 |
-
$obj = array();
|
620 |
-
} else {
|
621 |
-
$stk = array(SERVICES_JSON_IN_OBJ);
|
622 |
-
$obj = new stdClass();
|
623 |
-
}
|
624 |
-
}
|
625 |
-
|
626 |
-
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
627 |
-
'where' => 0,
|
628 |
-
'delim' => false));
|
629 |
-
|
630 |
-
$chrs = substr($str, 1, -1);
|
631 |
-
$chrs = $this->reduce_string($chrs);
|
632 |
-
|
633 |
-
if ($chrs == '') {
|
634 |
-
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
635 |
-
return $arr;
|
636 |
-
|
637 |
-
} else {
|
638 |
-
return $obj;
|
639 |
-
|
640 |
-
}
|
641 |
-
}
|
642 |
-
|
643 |
-
//print("\nparsing {$chrs}\n");
|
644 |
-
|
645 |
-
$strlen_chrs = strlen($chrs);
|
646 |
-
|
647 |
-
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
648 |
-
|
649 |
-
$top = end($stk);
|
650 |
-
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
651 |
-
|
652 |
-
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
653 |
-
// found a comma that is not inside a string, array, etc.,
|
654 |
-
// OR we've reached the end of the character list
|
655 |
-
$slice = substr($chrs, $top['where'], ($c - $top['where']));
|
656 |
-
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
657 |
-
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
658 |
-
|
659 |
-
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
660 |
-
// we are in an array, so just push an element onto the stack
|
661 |
-
array_push($arr, $this->decode($slice));
|
662 |
-
|
663 |
-
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
664 |
-
// we are in an object, so figure
|
665 |
-
// out the property name and set an
|
666 |
-
// element in an associative array,
|
667 |
-
// for now
|
668 |
-
$parts = array();
|
669 |
-
|
670 |
-
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?#x2F;Uis', $slice, $parts)) {
|
671 |
-
// "name":value pair
|
672 |
-
$key = $this->decode($parts[1]);
|
673 |
-
$val = $this->decode($parts[2]);
|
674 |
-
|
675 |
-
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
676 |
-
$obj[$key] = $val;
|
677 |
-
} else {
|
678 |
-
$obj->$key = $val;
|
679 |
-
}
|
680 |
-
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?#x2F;Uis', $slice, $parts)) {
|
681 |
-
// name:value pair, where name is unquoted
|
682 |
-
$key = $parts[1];
|
683 |
-
$val = $this->decode($parts[2]);
|
684 |
-
|
685 |
-
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
686 |
-
$obj[$key] = $val;
|
687 |
-
} else {
|
688 |
-
$obj->$key = $val;
|
689 |
-
}
|
690 |
-
}
|
691 |
-
|
692 |
-
}
|
693 |
-
|
694 |
-
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
695 |
-
// found a quote, and we are not inside a string
|
696 |
-
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
697 |
-
//print("Found start of string at {$c}\n");
|
698 |
-
|
699 |
-
} elseif (($chrs{$c} == $top['delim']) &&
|
700 |
-
($top['what'] == SERVICES_JSON_IN_STR) &&
|
701 |
-
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
702 |
-
// found a quote, we're in a string, and it's not escaped
|
703 |
-
// we know that it's not escaped becase there is _not_ an
|
704 |
-
// odd number of backslashes at the end of the string so far
|
705 |
-
array_pop($stk);
|
706 |
-
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
707 |
-
|
708 |
-
} elseif (($chrs{$c} == '[') &&
|
709 |
-
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
710 |
-
// found a left-bracket, and we are in an array, object, or slice
|
711 |
-
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
712 |
-
//print("Found start of array at {$c}\n");
|
713 |
-
|
714 |
-
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
715 |
-
// found a right-bracket, and we're in an array
|
716 |
-
array_pop($stk);
|
717 |
-
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
718 |
-
|
719 |
-
} elseif (($chrs{$c} == '{') &&
|
720 |
-
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
721 |
-
// found a left-brace, and we are in an array, object, or slice
|
722 |
-
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
723 |
-
//print("Found start of object at {$c}\n");
|
724 |
-
|
725 |
-
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
726 |
-
// found a right-brace, and we're in an object
|
727 |
-
array_pop($stk);
|
728 |
-
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
729 |
-
|
730 |
-
} elseif (($substr_chrs_c_2 == '/*') &&
|
731 |
-
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
732 |
-
// found a comment start, and we are in an array, object, or slice
|
733 |
-
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
734 |
-
$c++;
|
735 |
-
//print("Found start of comment at {$c}\n");
|
736 |
-
|
737 |
-
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
738 |
-
// found a comment end, and we're in one now
|
739 |
-
array_pop($stk);
|
740 |
-
$c++;
|
741 |
-
|
742 |
-
for ($i = $top['where']; $i <= $c; ++$i)
|
743 |
-
$chrs = substr_replace($chrs, ' ', $i, 1);
|
744 |
-
|
745 |
-
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
746 |
-
|
747 |
-
}
|
748 |
-
|
749 |
-
}
|
750 |
-
|
751 |
-
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
752 |
-
return $arr;
|
753 |
-
|
754 |
-
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
755 |
-
return $obj;
|
756 |
-
|
757 |
-
}
|
758 |
-
|
759 |
-
}
|
760 |
-
}
|
761 |
-
}
|
762 |
-
|
763 |
-
/**
|
764 |
-
* @todo Ultimately, this should just call PEAR::isError()
|
765 |
-
*/
|
766 |
-
function isError($data, $code = null)
|
767 |
-
{
|
768 |
-
if (class_exists('pear')) {
|
769 |
-
return PEAR::isError($data, $code);
|
770 |
-
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
771 |
-
is_subclass_of($data, 'services_json_error'))) {
|
772 |
-
return true;
|
773 |
-
}
|
774 |
-
|
775 |
-
return false;
|
776 |
-
}
|
777 |
-
}
|
778 |
-
|
779 |
-
if (class_exists('PEAR_Error')) {
|
780 |
-
|
781 |
-
class Services_JSON_Error extends PEAR_Error
|
782 |
-
{
|
783 |
-
function Services_JSON_Error($message = 'unknown error', $code = null,
|
784 |
-
$mode = null, $options = null, $userinfo = null)
|
785 |
-
{
|
786 |
-
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
787 |
-
}
|
788 |
-
}
|
789 |
-
|
790 |
-
} else {
|
791 |
-
|
792 |
-
/**
|
793 |
-
* @todo Ultimately, this class shall be descended from PEAR_Error
|
794 |
-
*/
|
795 |
-
class Services_JSON_Error
|
796 |
-
{
|
797 |
-
function Services_JSON_Error($message = 'unknown error', $code = null,
|
798 |
-
$mode = null, $options = null, $userinfo = null)
|
799 |
-
{
|
800 |
-
|
801 |
-
}
|
802 |
-
}
|
803 |
-
|
804 |
-
}
|
805 |
-
|
806 |
-
?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nest-mootools.v1.11.js
DELETED
@@ -1,7102 +0,0 @@
|
|
1 |
-
/*
|
2 |
-
Script: Core.js
|
3 |
-
Mootools - My Object Oriented javascript.
|
4 |
-
|
5 |
-
License:
|
6 |
-
MIT-style license.
|
7 |
-
|
8 |
-
MooTools Copyright:
|
9 |
-
copyright (c) 2007 Valerio Proietti, <http://mad4milk.net>
|
10 |
-
|
11 |
-
MooTools Credits:
|
12 |
-
- Class is slightly based on Base.js <http://dean.edwards.name/weblog/2006/03/base/> (c) 2006 Dean Edwards, License <http://creativecommons.org/licenses/LGPL/2.1/>
|
13 |
-
- Some functions are inspired by those found in prototype.js <http://prototype.conio.net/> (c) 2005 Sam Stephenson sam [at] conio [dot] net, MIT-style license
|
14 |
-
- Documentation by Aaron Newton (aaron.newton [at] cnet [dot] com) and Valerio Proietti.
|
15 |
-
*/
|
16 |
-
|
17 |
-
var MooTools = {
|
18 |
-
version: '1.11'
|
19 |
-
};
|
20 |
-
|
21 |
-
/* Section: Core Functions */
|
22 |
-
|
23 |
-
/*
|
24 |
-
Function: $defined
|
25 |
-
Returns true if the passed in value/object is defined, that means is not null or undefined.
|
26 |
-
|
27 |
-
Arguments:
|
28 |
-
obj - object to inspect
|
29 |
-
*/
|
30 |
-
|
31 |
-
function $defined(obj){
|
32 |
-
return (obj != undefined);
|
33 |
-
};
|
34 |
-
|
35 |
-
/*
|
36 |
-
Function: $type
|
37 |
-
Returns the type of object that matches the element passed in.
|
38 |
-
|
39 |
-
Arguments:
|
40 |
-
obj - the object to inspect.
|
41 |
-
|
42 |
-
Example:
|
43 |
-
>var myString = 'hello';
|
44 |
-
>$type(myString); //returns "string"
|
45 |
-
|
46 |
-
Returns:
|
47 |
-
'element' - if obj is a DOM element node
|
48 |
-
'textnode' - if obj is a DOM text node
|
49 |
-
'whitespace' - if obj is a DOM whitespace node
|
50 |
-
'arguments' - if obj is an arguments object
|
51 |
-
'object' - if obj is an object
|
52 |
-
'string' - if obj is a string
|
53 |
-
'number' - if obj is a number
|
54 |
-
'boolean' - if obj is a boolean
|
55 |
-
'function' - if obj is a function
|
56 |
-
'regexp' - if obj is a regular expression
|
57 |
-
'class' - if obj is a Class. (created with new Class, or the extend of another class).
|
58 |
-
'collection' - if obj is a native htmlelements collection, such as childNodes, getElementsByTagName .. etc.
|
59 |
-
false - (boolean) if the object is not defined or none of the above.
|
60 |
-
*/
|
61 |
-
|
62 |
-
function $type(obj){
|
63 |
-
if (!$defined(obj)) return false;
|
64 |
-
if (obj.htmlElement) return 'element';
|
65 |
-
var type = typeof obj;
|
66 |
-
if (type == 'object' && obj.nodeName){
|
67 |
-
switch(obj.nodeType){
|
68 |
-
case 1: return 'element';
|
69 |
-
case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
|
70 |
-
}
|
71 |
-
}
|
72 |
-
if (type == 'object' || type == 'function'){
|
73 |
-
switch(obj.constructor){
|
74 |
-
case Array: return 'array';
|
75 |
-
case RegExp: return 'regexp';
|
76 |
-
case Class: return 'class';
|
77 |
-
}
|
78 |
-
if (typeof obj.length == 'number'){
|
79 |
-
if (obj.item) return 'collection';
|
80 |
-
if (obj.callee) return 'arguments';
|
81 |
-
}
|
82 |
-
}
|
83 |
-
return type;
|
84 |
-
};
|
85 |
-
|
86 |
-
/*
|
87 |
-
Function: $merge
|
88 |
-
merges a number of objects recursively without referencing them or their sub-objects.
|
89 |
-
|
90 |
-
Arguments:
|
91 |
-
any number of objects.
|
92 |
-
|
93 |
-
Example:
|
94 |
-
>var mergedObj = $merge(obj1, obj2, obj3);
|
95 |
-
>//obj1, obj2, and obj3 are unaltered
|
96 |
-
*/
|
97 |
-
|
98 |
-
function $merge(){
|
99 |
-
var mix = {};
|
100 |
-
for (var i = 0; i < arguments.length; i++){
|
101 |
-
for (var property in arguments[i]){
|
102 |
-
var ap = arguments[i][property];
|
103 |
-
var mp = mix[property];
|
104 |
-
if (mp && $type(ap) == 'object' && $type(mp) == 'object') mix[property] = $merge(mp, ap);
|
105 |
-
else mix[property] = ap;
|
106 |
-
}
|
107 |
-
}
|
108 |
-
return mix;
|
109 |
-
};
|
110 |
-
|
111 |
-
/*
|
112 |
-
Function: $extend
|
113 |
-
Copies all the properties from the second passed object to the first passed Object.
|
114 |
-
If you do myWhatever.extend = $extend the first parameter will become myWhatever, and your extend function will only need one parameter.
|
115 |
-
|
116 |
-
Example:
|
117 |
-
(start code)
|
118 |
-
var firstOb = {
|
119 |
-
'name': 'John',
|
120 |
-
'lastName': 'Doe'
|
121 |
-
};
|
122 |
-
var secondOb = {
|
123 |
-
'age': '20',
|
124 |
-
'sex': 'male',
|
125 |
-
'lastName': 'Dorian'
|
126 |
-
};
|
127 |
-
$extend(firstOb, secondOb);
|
128 |
-
//firstOb will become:
|
129 |
-
{
|
130 |
-
'name': 'John',
|
131 |
-
'lastName': 'Dorian',
|
132 |
-
'age': '20',
|
133 |
-
'sex': 'male'
|
134 |
-
};
|
135 |
-
(end)
|
136 |
-
|
137 |
-
Returns:
|
138 |
-
The first object, extended.
|
139 |
-
*/
|
140 |
-
|
141 |
-
var $extend = function(){
|
142 |
-
var args = arguments;
|
143 |
-
if (!args[1]) args = [this, args[0]];
|
144 |
-
for (var property in args[1]) args[0][property] = args[1][property];
|
145 |
-
return args[0];
|
146 |
-
};
|
147 |
-
|
148 |
-
/*
|
149 |
-
Function: $native
|
150 |
-
Will add a .extend method to the objects passed as a parameter, but the property passed in will be copied to the object's prototype only if non previously existent.
|
151 |
-
Its handy if you dont want the .extend method of an object to overwrite existing methods.
|
152 |
-
Used automatically in MooTools to implement Array/String/Function/Number methods to browser that dont support them whitout manual checking.
|
153 |
-
|
154 |
-
Arguments:
|
155 |
-
a number of classes/native javascript objects
|
156 |
-
|
157 |
-
*/
|
158 |
-
|
159 |
-
var $native = function(){
|
160 |
-
for (var i = 0, l = arguments.length; i < l; i++){
|
161 |
-
arguments[i].extend = function(props){
|
162 |
-
for (var prop in props){
|
163 |
-
if (!this.prototype[prop]) this.prototype[prop] = props[prop];
|
164 |
-
if (!this[prop]) this[prop] = $native.generic(prop);
|
165 |
-
}
|
166 |
-
};
|
167 |
-
}
|
168 |
-
};
|
169 |
-
|
170 |
-
$native.generic = function(prop){
|
171 |
-
return function(bind){
|
172 |
-
return this.prototype[prop].apply(bind, Array.prototype.slice.call(arguments, 1));
|
173 |
-
};
|
174 |
-
};
|
175 |
-
|
176 |
-
$native(Function, Array, String, Number);
|
177 |
-
|
178 |
-
/*
|
179 |
-
Function: $chk
|
180 |
-
Returns true if the passed in value/object exists or is 0, otherwise returns false.
|
181 |
-
Useful to accept zeroes.
|
182 |
-
|
183 |
-
Arguments:
|
184 |
-
obj - object to inspect
|
185 |
-
*/
|
186 |
-
|
187 |
-
function $chk(obj){
|
188 |
-
return !!(obj || obj === 0);
|
189 |
-
};
|
190 |
-
|
191 |
-
/*
|
192 |
-
Function: $pick
|
193 |
-
Returns the first object if defined, otherwise returns the second.
|
194 |
-
|
195 |
-
Arguments:
|
196 |
-
obj - object to test
|
197 |
-
picked - the default to return
|
198 |
-
|
199 |
-
Example:
|
200 |
-
(start code)
|
201 |
-
function say(msg){
|
202 |
-
alert($pick(msg, 'no meessage supplied'));
|
203 |
-
}
|
204 |
-
(end)
|
205 |
-
*/
|
206 |
-
|
207 |
-
function $pick(obj, picked){
|
208 |
-
return $defined(obj) ? obj : picked;
|
209 |
-
};
|
210 |
-
|
211 |
-
/*
|
212 |
-
Function: $random
|
213 |
-
Returns a random integer number between the two passed in values.
|
214 |
-
|
215 |
-
Arguments:
|
216 |
-
min - integer, the minimum value (inclusive).
|
217 |
-
max - integer, the maximum value (inclusive).
|
218 |
-
|
219 |
-
Returns:
|
220 |
-
a random integer between min and max.
|
221 |
-
*/
|
222 |
-
|
223 |
-
function $random(min, max){
|
224 |
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
225 |
-
};
|
226 |
-
|
227 |
-
/*
|
228 |
-
Function: $time
|
229 |
-
Returns the current timestamp
|
230 |
-
|
231 |
-
Returns:
|
232 |
-
a timestamp integer.
|
233 |
-
*/
|
234 |
-
|
235 |
-
function $time(){
|
236 |
-
return new Date().getTime();
|
237 |
-
};
|
238 |
-
|
239 |
-
/*
|
240 |
-
Function: $clear
|
241 |
-
clears a timeout or an Interval.
|
242 |
-
|
243 |
-
Returns:
|
244 |
-
null
|
245 |
-
|
246 |
-
Arguments:
|
247 |
-
timer - the setInterval or setTimeout to clear.
|
248 |
-
|
249 |
-
Example:
|
250 |
-
>var myTimer = myFunction.delay(5000); //wait 5 seconds and execute my function.
|
251 |
-
>myTimer = $clear(myTimer); //nevermind
|
252 |
-
|
253 |
-
See also:
|
254 |
-
<Function.delay>, <Function.periodical>
|
255 |
-
*/
|
256 |
-
|
257 |
-
function $clear(timer){
|
258 |
-
clearTimeout(timer);
|
259 |
-
clearInterval(timer);
|
260 |
-
return null;
|
261 |
-
};
|
262 |
-
|
263 |
-
/*
|
264 |
-
Class: Abstract
|
265 |
-
Abstract class, to be used as singleton. Will add .extend to any object
|
266 |
-
|
267 |
-
Arguments:
|
268 |
-
an object
|
269 |
-
|
270 |
-
Returns:
|
271 |
-
the object with an .extend property, equivalent to <$extend>.
|
272 |
-
*/
|
273 |
-
|
274 |
-
var Abstract = function(obj){
|
275 |
-
obj = obj || {};
|
276 |
-
obj.extend = $extend;
|
277 |
-
return obj;
|
278 |
-
};
|
279 |
-
|
280 |
-
//window, document
|
281 |
-
|
282 |
-
var Window = new Abstract(window);
|
283 |
-
var Document = new Abstract(document);
|
284 |
-
document.head = document.getElementsByTagName('head')[0];
|
285 |
-
|
286 |
-
/*
|
287 |
-
Class: window
|
288 |
-
Some properties are attached to the window object by the browser detection.
|
289 |
-
|
290 |
-
Note:
|
291 |
-
browser detection is entirely object-based. We dont sniff.
|
292 |
-
|
293 |
-
Properties:
|
294 |
-
window.ie - will be set to true if the current browser is internet explorer (any).
|
295 |
-
window.ie6 - will be set to true if the current browser is internet explorer 6.
|
296 |
-
window.ie7 - will be set to true if the current browser is internet explorer 7.
|
297 |
-
window.gecko - will be set to true if the current browser is Mozilla/Gecko.
|
298 |
-
window.webkit - will be set to true if the current browser is Safari/Konqueror.
|
299 |
-
window.webkit419 - will be set to true if the current browser is Safari2 / webkit till version 419.
|
300 |
-
window.webkit420 - will be set to true if the current browser is Safari3 (Webkit SVN Build) / webkit over version 419.
|
301 |
-
window.opera - is set to true by opera itself.
|
302 |
-
*/
|
303 |
-
|
304 |
-
window.xpath = !!(document.evaluate);
|
305 |
-
if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
|
306 |
-
else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
|
307 |
-
else if (document.getBoxObjectFor != null) window.gecko = true;
|
308 |
-
|
309 |
-
/*compatibility*/
|
310 |
-
|
311 |
-
window.khtml = window.webkit;
|
312 |
-
|
313 |
-
Object.extend = $extend;
|
314 |
-
|
315 |
-
/*end compatibility*/
|
316 |
-
|
317 |
-
//htmlelement
|
318 |
-
|
319 |
-
if (typeof HTMLElement == 'undefined'){
|
320 |
-
var HTMLElement = function(){};
|
321 |
-
if (window.webkit) document.createElement("iframe"); //fixes safari
|
322 |
-
HTMLElement.prototype = (window.webkit) ? window["[[DOMElement.prototype]]"] : {};
|
323 |
-
}
|
324 |
-
HTMLElement.prototype.htmlElement = function(){};
|
325 |
-
|
326 |
-
//enables background image cache for internet explorer 6
|
327 |
-
|
328 |
-
if (window.ie6) try {document.execCommand("BackgroundImageCache", false, true);} catch(e){};
|
329 |
-
|
330 |
-
/*
|
331 |
-
Script: Class.js
|
332 |
-
Contains the Class Function, aims to ease the creation of reusable Classes.
|
333 |
-
|
334 |
-
License:
|
335 |
-
MIT-style license.
|
336 |
-
*/
|
337 |
-
|
338 |
-
/*
|
339 |
-
Class: Class
|
340 |
-
The base class object of the <http://mootools.net> framework.
|
341 |
-
Creates a new class, its initialize method will fire upon class instantiation.
|
342 |
-
Initialize wont fire on instantiation when you pass *null*.
|
343 |
-
|
344 |
-
Arguments:
|
345 |
-
properties - the collection of properties that apply to the class.
|
346 |
-
|
347 |
-
Example:
|
348 |
-
(start code)
|
349 |
-
var Cat = new Class({
|
350 |
-
initialize: function(name){
|
351 |
-
this.name = name;
|
352 |
-
}
|
353 |
-
});
|
354 |
-
var myCat = new Cat('Micia');
|
355 |
-
alert(myCat.name); //alerts 'Micia'
|
356 |
-
(end)
|
357 |
-
*/
|
358 |
-
|
359 |
-
var Class = function(properties){
|
360 |
-
var klass = function(){
|
361 |
-
return (arguments[0] !== null && this.initialize && $type(this.initialize) == 'function') ? this.initialize.apply(this, arguments) : this;
|
362 |
-
};
|
363 |
-
$extend(klass, this);
|
364 |
-
klass.prototype = properties;
|
365 |
-
klass.constructor = Class;
|
366 |
-
return klass;
|
367 |
-
};
|
368 |
-
|
369 |
-
/*
|
370 |
-
Property: empty
|
371 |
-
Returns an empty function
|
372 |
-
*/
|
373 |
-
|
374 |
-
Class.empty = function(){};
|
375 |
-
|
376 |
-
Class.prototype = {
|
377 |
-
|
378 |
-
/*
|
379 |
-
Property: extend
|
380 |
-
Returns the copy of the Class extended with the passed in properties.
|
381 |
-
|
382 |
-
Arguments:
|
383 |
-
properties - the properties to add to the base class in this new Class.
|
384 |
-
|
385 |
-
Example:
|
386 |
-
(start code)
|
387 |
-
var Animal = new Class({
|
388 |
-
initialize: function(age){
|
389 |
-
this.age = age;
|
390 |
-
}
|
391 |
-
});
|
392 |
-
var Cat = Animal.extend({
|
393 |
-
initialize: function(name, age){
|
394 |
-
this.parent(age); //will call the previous initialize;
|
395 |
-
this.name = name;
|
396 |
-
}
|
397 |
-
});
|
398 |
-
var myCat = new Cat('Micia', 20);
|
399 |
-
alert(myCat.name); //alerts 'Micia'
|
400 |
-
alert(myCat.age); //alerts 20
|
401 |
-
(end)
|
402 |
-
*/
|
403 |
-
|
404 |
-
extend: function(properties){
|
405 |
-
var proto = new this(null);
|
406 |
-
for (var property in properties){
|
407 |
-
var pp = proto[property];
|
408 |
-
proto[property] = Class.Merge(pp, properties[property]);
|
409 |
-
}
|
410 |
-
return new Class(proto);
|
411 |
-
},
|
412 |
-
|
413 |
-
/*
|
414 |
-
Property: implement
|
415 |
-
Implements the passed in properties to the base Class prototypes, altering the base class, unlike <Class.extend>.
|
416 |
-
|
417 |
-
Arguments:
|
418 |
-
properties - the properties to add to the base class.
|
419 |
-
|
420 |
-
Example:
|
421 |
-
(start code)
|
422 |
-
var Animal = new Class({
|
423 |
-
initialize: function(age){
|
424 |
-
this.age = age;
|
425 |
-
}
|
426 |
-
});
|
427 |
-
Animal.implement({
|
428 |
-
setName: function(name){
|
429 |
-
this.name = name
|
430 |
-
}
|
431 |
-
});
|
432 |
-
var myAnimal = new Animal(20);
|
433 |
-
myAnimal.setName('Micia');
|
434 |
-
alert(myAnimal.name); //alerts 'Micia'
|
435 |
-
(end)
|
436 |
-
*/
|
437 |
-
|
438 |
-
implement: function(){
|
439 |
-
for (var i = 0, l = arguments.length; i < l; i++) $extend(this.prototype, arguments[i]);
|
440 |
-
}
|
441 |
-
|
442 |
-
};
|
443 |
-
|
444 |
-
//internal
|
445 |
-
|
446 |
-
Class.Merge = function(previous, current){
|
447 |
-
if (previous && previous != current){
|
448 |
-
var type = $type(current);
|
449 |
-
if (type != $type(previous)) return current;
|
450 |
-
switch(type){
|
451 |
-
case 'function':
|
452 |
-
var merged = function(){
|
453 |
-
this.parent = arguments.callee.parent;
|
454 |
-
return current.apply(this, arguments);
|
455 |
-
};
|
456 |
-
merged.parent = previous;
|
457 |
-
return merged;
|
458 |
-
case 'object': return $merge(previous, current);
|
459 |
-
}
|
460 |
-
}
|
461 |
-
return current;
|
462 |
-
};
|
463 |
-
|
464 |
-
/*
|
465 |
-
Script: Class.Extras.js
|
466 |
-
Contains common implementations for custom classes. In Mootools is implemented in <Ajax>, <XHR> and <Fx.Base> and many more.
|
467 |
-
|
468 |
-
License:
|
469 |
-
MIT-style license.
|
470 |
-
*/
|
471 |
-
|
472 |
-
/*
|
473 |
-
Class: Chain
|
474 |
-
An "Utility" Class. Its methods can be implemented with <Class.implement> into any <Class>.
|
475 |
-
Currently implemented in <Fx.Base>, <XHR> and <Ajax>. In <Fx.Base> for example, is used to execute a list of function, one after another, once the effect is completed.
|
476 |
-
The functions will not be fired all togheter, but one every completion, to create custom complex animations.
|
477 |
-
|
478 |
-
Example:
|
479 |
-
(start code)
|
480 |
-
var myFx = new Fx.Style('element', 'opacity');
|
481 |
-
|
482 |
-
myFx.start(1,0).chain(function(){
|
483 |
-
myFx.start(0,1);
|
484 |
-
}).chain(function(){
|
485 |
-
myFx.start(1,0);
|
486 |
-
}).chain(function(){
|
487 |
-
myFx.start(0,1);
|
488 |
-
});
|
489 |
-
//the element will appear and disappear three times
|
490 |
-
(end)
|
491 |
-
*/
|
492 |
-
|
493 |
-
var Chain = new Class({
|
494 |
-
|
495 |
-
/*
|
496 |
-
Property: chain
|
497 |
-
adds a function to the Chain instance stack.
|
498 |
-
|
499 |
-
Arguments:
|
500 |
-
fn - the function to append.
|
501 |
-
*/
|
502 |
-
|
503 |
-
chain: function(fn){
|
504 |
-
this.chains = this.chains || [];
|
505 |
-
this.chains.push(fn);
|
506 |
-
return this;
|
507 |
-
},
|
508 |
-
|
509 |
-
/*
|
510 |
-
Property: callChain
|
511 |
-
Executes the first function of the Chain instance stack, then removes it. The first function will then become the second.
|
512 |
-
*/
|
513 |
-
|
514 |
-
callChain: function(){
|
515 |
-
if (this.chains && this.chains.length) this.chains.shift().delay(10, this);
|
516 |
-
},
|
517 |
-
|
518 |
-
/*
|
519 |
-
Property: clearChain
|
520 |
-
Clears the stack of a Chain instance.
|
521 |
-
*/
|
522 |
-
|
523 |
-
clearChain: function(){
|
524 |
-
this.chains = [];
|
525 |
-
}
|
526 |
-
|
527 |
-
});
|
528 |
-
|
529 |
-
/*
|
530 |
-
Class: Events
|
531 |
-
An "Utility" Class. Its methods can be implemented with <Class.implement> into any <Class>.
|
532 |
-
In <Fx.Base> Class, for example, is used to give the possibility add any number of functions to the Effects events, like onComplete, onStart, onCancel.
|
533 |
-
Events in a Class that implements <Events> can be either added as an option, or with addEvent. Never with .options.onEventName.
|
534 |
-
|
535 |
-
Example:
|
536 |
-
(start code)
|
537 |
-
var myFx = new Fx.Style('element', 'opacity').addEvent('onComplete', function(){
|
538 |
-
alert('the effect is completed');
|
539 |
-
}).addEvent('onComplete', function(){
|
540 |
-
alert('I told you the effect is completed');
|
541 |
-
});
|
542 |
-
|
543 |
-
myFx.start(0,1);
|
544 |
-
//upon completion it will display the 2 alerts, in order.
|
545 |
-
(end)
|
546 |
-
|
547 |
-
Implementing:
|
548 |
-
This class can be implemented into other classes to add the functionality to them.
|
549 |
-
Goes well with the <Options> class.
|
550 |
-
|
551 |
-
Example:
|
552 |
-
(start code)
|
553 |
-
var Widget = new Class({
|
554 |
-
initialize: function(){},
|
555 |
-
finish: function(){
|
556 |
-
this.fireEvent('onComplete');
|
557 |
-
}
|
558 |
-
});
|
559 |
-
Widget.implement(new Events);
|
560 |
-
//later...
|
561 |
-
var myWidget = new Widget();
|
562 |
-
myWidget.addEvent('onComplete', myfunction);
|
563 |
-
(end)
|
564 |
-
*/
|
565 |
-
|
566 |
-
var Events = new Class({
|
567 |
-
|
568 |
-
/*
|
569 |
-
Property: addEvent
|
570 |
-
adds an event to the stack of events of the Class instance.
|
571 |
-
|
572 |
-
Arguments:
|
573 |
-
type - string; the event name (e.g. 'onComplete')
|
574 |
-
fn - function to execute
|
575 |
-
*/
|
576 |
-
|
577 |
-
addEvent: function(type, fn){
|
578 |
-
if (fn != Class.empty){
|
579 |
-
this.$events = this.$events || {};
|
580 |
-
this.$events[type] = this.$events[type] || [];
|
581 |
-
this.$events[type].include(fn);
|
582 |
-
}
|
583 |
-
return this;
|
584 |
-
},
|
585 |
-
|
586 |
-
/*
|
587 |
-
Property: fireEvent
|
588 |
-
fires all events of the specified type in the Class instance.
|
589 |
-
|
590 |
-
Arguments:
|
591 |
-
type - string; the event name (e.g. 'onComplete')
|
592 |
-
args - array or single object; arguments to pass to the function; if more than one argument, must be an array
|
593 |
-
delay - (integer) delay (in ms) to wait to execute the event
|
594 |
-
|
595 |
-
Example:
|
596 |
-
(start code)
|
597 |
-
var Widget = new Class({
|
598 |
-
initialize: function(arg1, arg2){
|
599 |
-
...
|
600 |
-
this.fireEvent("onInitialize", [arg1, arg2], 50);
|
601 |
-
}
|
602 |
-
});
|
603 |
-
Widget.implement(new Events);
|
604 |
-
(end)
|
605 |
-
*/
|
606 |
-
|
607 |
-
fireEvent: function(type, args, delay){
|
608 |
-
if (this.$events && this.$events[type]){
|
609 |
-
this.$events[type].each(function(fn){
|
610 |
-
fn.create({'bind': this, 'delay': delay, 'arguments': args})();
|
611 |
-
}, this);
|
612 |
-
}
|
613 |
-
return this;
|
614 |
-
},
|
615 |
-
|
616 |
-
/*
|
617 |
-
Property: removeEvent
|
618 |
-
removes an event from the stack of events of the Class instance.
|
619 |
-
|
620 |
-
Arguments:
|
621 |
-
type - string; the event name (e.g. 'onComplete')
|
622 |
-
fn - function that was added
|
623 |
-
*/
|
624 |
-
|
625 |
-
removeEvent: function(type, fn){
|
626 |
-
if (this.$events && this.$events[type]) this.$events[type].remove(fn);
|
627 |
-
return this;
|
628 |
-
}
|
629 |
-
|
630 |
-
});
|
631 |
-
|
632 |
-
/*
|
633 |
-
Class: Options
|
634 |
-
An "Utility" Class. Its methods can be implemented with <Class.implement> into any <Class>.
|
635 |
-
Used to automate the options settings, also adding Class <Events> when the option begins with on.
|
636 |
-
|
637 |
-
Example:
|
638 |
-
(start code)
|
639 |
-
var Widget = new Class({
|
640 |
-
options: {
|
641 |
-
color: '#fff',
|
642 |
-
size: {
|
643 |
-
width: 100
|
644 |
-
height: 100
|
645 |
-
}
|
646 |
-
},
|
647 |
-
initialize: function(options){
|
648 |
-
this.setOptions(options);
|
649 |
-
}
|
650 |
-
});
|
651 |
-
Widget.implement(new Options);
|
652 |
-
//later...
|
653 |
-
var myWidget = new Widget({
|
654 |
-
color: '#f00',
|
655 |
-
size: {
|
656 |
-
width: 200
|
657 |
-
}
|
658 |
-
});
|
659 |
-
//myWidget.options = {color: #f00, size: {width: 200, height: 100}}
|
660 |
-
(end)
|
661 |
-
*/
|
662 |
-
|
663 |
-
var Options = new Class({
|
664 |
-
|
665 |
-
/*
|
666 |
-
Property: setOptions
|
667 |
-
sets this.options
|
668 |
-
|
669 |
-
Arguments:
|
670 |
-
defaults - object; the default set of options
|
671 |
-
options - object; the user entered options. can be empty too.
|
672 |
-
|
673 |
-
Note:
|
674 |
-
if your Class has <Events> implemented, every option beginning with on, followed by a capital letter (onComplete) becomes an Class instance event.
|
675 |
-
*/
|
676 |
-
|
677 |
-
setOptions: function(){
|
678 |
-
this.options = $merge.apply(null, [this.options].extend(arguments));
|
679 |
-
if (this.addEvent){
|
680 |
-
for (var option in this.options){
|
681 |
-
if ($type(this.options[option] == 'function') && (/^on[A-Z]/).test(option)) this.addEvent(option, this.options[option]);
|
682 |
-
}
|
683 |
-
}
|
684 |
-
return this;
|
685 |
-
}
|
686 |
-
|
687 |
-
});
|
688 |
-
|
689 |
-
/*
|
690 |
-
Script: Array.js
|
691 |
-
Contains Array prototypes, <$A>, <$each>
|
692 |
-
|
693 |
-
License:
|
694 |
-
MIT-style license.
|
695 |
-
*/
|
696 |
-
|
697 |
-
/*
|
698 |
-
Class: Array
|
699 |
-
A collection of The Array Object prototype methods.
|
700 |
-
*/
|
701 |
-
|
702 |
-
//custom methods
|
703 |
-
|
704 |
-
Array.extend({
|
705 |
-
|
706 |
-
/*
|
707 |
-
Property: forEach
|
708 |
-
Iterates through an array; This method is only available for browsers without native *forEach* support.
|
709 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:forEach>
|
710 |
-
|
711 |
-
*forEach* executes the provided function (callback) once for each element present in the array. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
|
712 |
-
|
713 |
-
Arguments:
|
714 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
715 |
-
bind - the object to bind "this" to (see <Function.bind>)
|
716 |
-
|
717 |
-
Example:
|
718 |
-
>['apple','banana','lemon'].each(function(item, index){
|
719 |
-
> alert(index + " = " + item); //alerts "0 = apple" etc.
|
720 |
-
>}, bindObj); //optional second arg for binding, not used here
|
721 |
-
*/
|
722 |
-
|
723 |
-
forEach: function(fn, bind){
|
724 |
-
for (var i = 0, j = this.length; i < j; i++) fn.call(bind, this[i], i, this);
|
725 |
-
},
|
726 |
-
|
727 |
-
/*
|
728 |
-
Property: filter
|
729 |
-
This method is provided only for browsers without native *filter* support.
|
730 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter>
|
731 |
-
|
732 |
-
*filter* calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a true value. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. Array elements which do not pass the callback test are simply skipped, and are not included in the new array.
|
733 |
-
|
734 |
-
Arguments:
|
735 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
736 |
-
bind - the object to bind "this" to (see <Function.bind>)
|
737 |
-
|
738 |
-
Example:
|
739 |
-
>var biggerThanTwenty = [10,3,25,100].filter(function(item, index){
|
740 |
-
> return item > 20;
|
741 |
-
>});
|
742 |
-
>//biggerThanTwenty = [25,100]
|
743 |
-
*/
|
744 |
-
|
745 |
-
filter: function(fn, bind){
|
746 |
-
var results = [];
|
747 |
-
for (var i = 0, j = this.length; i < j; i++){
|
748 |
-
if (fn.call(bind, this[i], i, this)) results.push(this[i]);
|
749 |
-
}
|
750 |
-
return results;
|
751 |
-
},
|
752 |
-
|
753 |
-
/*
|
754 |
-
Property: map
|
755 |
-
This method is provided only for browsers without native *map* support.
|
756 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:map>
|
757 |
-
|
758 |
-
*map* calls a provided callback function once for each element in an array, in order, and constructs a new array from the results. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
|
759 |
-
|
760 |
-
Arguments:
|
761 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
762 |
-
bind - the object to bind "this" to (see <Function.bind>)
|
763 |
-
|
764 |
-
Example:
|
765 |
-
>var timesTwo = [1,2,3].map(function(item, index){
|
766 |
-
> return item*2;
|
767 |
-
>});
|
768 |
-
>//timesTwo = [2,4,6];
|
769 |
-
*/
|
770 |
-
|
771 |
-
map: function(fn, bind){
|
772 |
-
var results = [];
|
773 |
-
for (var i = 0, j = this.length; i < j; i++) results[i] = fn.call(bind, this[i], i, this);
|
774 |
-
return results;
|
775 |
-
},
|
776 |
-
|
777 |
-
/*
|
778 |
-
Property: every
|
779 |
-
This method is provided only for browsers without native *every* support.
|
780 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:every>
|
781 |
-
|
782 |
-
*every* executes the provided callback function once for each element present in the array until it finds one where callback returns a false value. If such an element is found, the every method immediately returns false. Otherwise, if callback returned a true value for all elements, every will return true. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
|
783 |
-
|
784 |
-
Arguments:
|
785 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
786 |
-
bind - the object to bind "this" to (see <Function.bind>)
|
787 |
-
|
788 |
-
Example:
|
789 |
-
>var areAllBigEnough = [10,4,25,100].every(function(item, index){
|
790 |
-
> return item > 20;
|
791 |
-
>});
|
792 |
-
>//areAllBigEnough = false
|
793 |
-
*/
|
794 |
-
|
795 |
-
every: function(fn, bind){
|
796 |
-
for (var i = 0, j = this.length; i < j; i++){
|
797 |
-
if (!fn.call(bind, this[i], i, this)) return false;
|
798 |
-
}
|
799 |
-
return true;
|
800 |
-
},
|
801 |
-
|
802 |
-
/*
|
803 |
-
Property: some
|
804 |
-
This method is provided only for browsers without native *some* support.
|
805 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:some>
|
806 |
-
|
807 |
-
*some* executes the callback function once for each element present in the array until it finds one where callback returns a true value. If such an element is found, some immediately returns true. Otherwise, some returns false. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values.
|
808 |
-
|
809 |
-
Arguments:
|
810 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
811 |
-
bind - the object to bind "this" to (see <Function.bind>)
|
812 |
-
|
813 |
-
Example:
|
814 |
-
>var isAnyBigEnough = [10,4,25,100].some(function(item, index){
|
815 |
-
> return item > 20;
|
816 |
-
>});
|
817 |
-
>//isAnyBigEnough = true
|
818 |
-
*/
|
819 |
-
|
820 |
-
some: function(fn, bind){
|
821 |
-
for (var i = 0, j = this.length; i < j; i++){
|
822 |
-
if (fn.call(bind, this[i], i, this)) return true;
|
823 |
-
}
|
824 |
-
return false;
|
825 |
-
},
|
826 |
-
|
827 |
-
/*
|
828 |
-
Property: indexOf
|
829 |
-
This method is provided only for browsers without native *indexOf* support.
|
830 |
-
For more info see <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Global_Objects:Array:indexOf>
|
831 |
-
|
832 |
-
*indexOf* compares a search element to elements of the Array using strict equality (the same method used by the ===, or triple-equals, operator).
|
833 |
-
|
834 |
-
Arguments:
|
835 |
-
item - any type of object; element to locate in the array
|
836 |
-
from - integer; optional; the index of the array at which to begin the search (defaults to 0)
|
837 |
-
|
838 |
-
Example:
|
839 |
-
>['apple','lemon','banana'].indexOf('lemon'); //returns 1
|
840 |
-
>['apple','lemon'].indexOf('banana'); //returns -1
|
841 |
-
*/
|
842 |
-
|
843 |
-
indexOf: function(item, from){
|
844 |
-
var len = this.length;
|
845 |
-
for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){
|
846 |
-
if (this[i] === item) return i;
|
847 |
-
}
|
848 |
-
return -1;
|
849 |
-
},
|
850 |
-
|
851 |
-
/*
|
852 |
-
Property: each
|
853 |
-
Same as <Array.forEach>.
|
854 |
-
|
855 |
-
Arguments:
|
856 |
-
fn - function to execute with each item in the array; passed the item and the index of that item in the array
|
857 |
-
bind - optional, the object that the "this" of the function will refer to.
|
858 |
-
|
859 |
-
Example:
|
860 |
-
>var Animals = ['Cat', 'Dog', 'Coala'];
|
861 |
-
>Animals.each(function(animal){
|
862 |
-
> document.write(animal)
|
863 |
-
>});
|
864 |
-
*/
|
865 |
-
|
866 |
-
/*
|
867 |
-
Property: copy
|
868 |
-
returns a copy of the array.
|
869 |
-
|
870 |
-
Returns:
|
871 |
-
a new array which is a copy of the current one.
|
872 |
-
|
873 |
-
Arguments:
|
874 |
-
start - integer; optional; the index where to start the copy, default is 0. If negative, it is taken as the offset from the end of the array.
|
875 |
-
length - integer; optional; the number of elements to copy. By default, copies all elements from start to the end of the array.
|
876 |
-
|
877 |
-
Example:
|
878 |
-
>var letters = ["a","b","c"];
|
879 |
-
>var copy = letters.copy(); // ["a","b","c"] (new instance)
|
880 |
-
*/
|
881 |
-
|
882 |
-
copy: function(start, length){
|
883 |
-
start = start || 0;
|
884 |
-
if (start < 0) start = this.length + start;
|
885 |
-
length = length || (this.length - start);
|
886 |
-
var newArray = [];
|
887 |
-
for (var i = 0; i < length; i++) newArray[i] = this[start++];
|
888 |
-
return newArray;
|
889 |
-
},
|
890 |
-
|
891 |
-
/*
|
892 |
-
Property: remove
|
893 |
-
Removes all occurrences of an item from the array.
|
894 |
-
|
895 |
-
Arguments:
|
896 |
-
item - the item to remove
|
897 |
-
|
898 |
-
Returns:
|
899 |
-
the Array with all occurrences of the item removed.
|
900 |
-
|
901 |
-
Example:
|
902 |
-
>["1","2","3","2"].remove("2") // ["1","3"];
|
903 |
-
*/
|
904 |
-
|
905 |
-
remove: function(item){
|
906 |
-
var i = 0;
|
907 |
-
var len = this.length;
|
908 |
-
while (i < len){
|
909 |
-
if (this[i] === item){
|
910 |
-
this.splice(i, 1);
|
911 |
-
len--;
|
912 |
-
} else {
|
913 |
-
i++;
|
914 |
-
}
|
915 |
-
}
|
916 |
-
return this;
|
917 |
-
},
|
918 |
-
|
919 |
-
/*
|
920 |
-
Property: contains
|
921 |
-
Tests an array for the presence of an item.
|
922 |
-
|
923 |
-
Arguments:
|
924 |
-
item - the item to search for in the array.
|
925 |
-
from - integer; optional; the index at which to begin the search, default is 0. If negative, it is taken as the offset from the end of the array.
|
926 |
-
|
927 |
-
Returns:
|
928 |
-
true - the item was found
|
929 |
-
false - it wasn't
|
930 |
-
|
931 |
-
Example:
|
932 |
-
>["a","b","c"].contains("a"); // true
|
933 |
-
>["a","b","c"].contains("d"); // false
|
934 |
-
*/
|
935 |
-
|
936 |
-
contains: function(item, from){
|
937 |
-
return this.indexOf(item, from) != -1;
|
938 |
-
},
|
939 |
-
|
940 |
-
/*
|
941 |
-
Property: associate
|
942 |
-
Creates an object with key-value pairs based on the array of keywords passed in
|
943 |
-
and the current content of the array.
|
944 |
-
|
945 |
-
Arguments:
|
946 |
-
keys - the array of keywords.
|
947 |
-
|
948 |
-
Example:
|
949 |
-
(start code)
|
950 |
-
var Animals = ['Cat', 'Dog', 'Coala', 'Lizard'];
|
951 |
-
var Speech = ['Miao', 'Bau', 'Fruuu', 'Mute'];
|
952 |
-
var Speeches = Animals.associate(Speech);
|
953 |
-
//Speeches['Miao'] is now Cat.
|
954 |
-
//Speeches['Bau'] is now Dog.
|
955 |
-
//...
|
956 |
-
(end)
|
957 |
-
*/
|
958 |
-
|
959 |
-
associate: function(keys){
|
960 |
-
var obj = {}, length = Math.min(this.length, keys.length);
|
961 |
-
for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
|
962 |
-
return obj;
|
963 |
-
},
|
964 |
-
|
965 |
-
/*
|
966 |
-
Property: extend
|
967 |
-
Extends an array with another one.
|
968 |
-
|
969 |
-
Arguments:
|
970 |
-
array - the array to extend ours with
|
971 |
-
|
972 |
-
Example:
|
973 |
-
>var Animals = ['Cat', 'Dog', 'Coala'];
|
974 |
-
>Animals.extend(['Lizard']);
|
975 |
-
>//Animals is now: ['Cat', 'Dog', 'Coala', 'Lizard'];
|
976 |
-
*/
|
977 |
-
|
978 |
-
extend: function(array){
|
979 |
-
for (var i = 0, j = array.length; i < j; i++) this.push(array[i]);
|
980 |
-
return this;
|
981 |
-
},
|
982 |
-
|
983 |
-
/*
|
984 |
-
Property: merge
|
985 |
-
merges an array in another array, without duplicates. (case- and type-sensitive)
|
986 |
-
|
987 |
-
Arguments:
|
988 |
-
array - the array to merge from.
|
989 |
-
|
990 |
-
Example:
|
991 |
-
>['Cat','Dog'].merge(['Dog','Coala']); //returns ['Cat','Dog','Coala']
|
992 |
-
*/
|
993 |
-
|
994 |
-
merge: function(array){
|
995 |
-
for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
|
996 |
-
return this;
|
997 |
-
},
|
998 |
-
|
999 |
-
/*
|
1000 |
-
Property: include
|
1001 |
-
includes the passed in element in the array, only if its not already present. (case- and type-sensitive)
|
1002 |
-
|
1003 |
-
Arguments:
|
1004 |
-
item - item to add to the array (if not present)
|
1005 |
-
|
1006 |
-
Example:
|
1007 |
-
>['Cat','Dog'].include('Dog'); //returns ['Cat','Dog']
|
1008 |
-
>['Cat','Dog'].include('Coala'); //returns ['Cat','Dog','Coala']
|
1009 |
-
*/
|
1010 |
-
|
1011 |
-
include: function(item){
|
1012 |
-
if (!this.contains(item)) this.push(item);
|
1013 |
-
return this;
|
1014 |
-
},
|
1015 |
-
|
1016 |
-
/*
|
1017 |
-
Property: getRandom
|
1018 |
-
returns a random item in the Array
|
1019 |
-
*/
|
1020 |
-
|
1021 |
-
getRandom: function(){
|
1022 |
-
return this[$random(0, this.length - 1)] || null;
|
1023 |
-
},
|
1024 |
-
|
1025 |
-
/*
|
1026 |
-
Property: getLast
|
1027 |
-
returns the last item in the Array
|
1028 |
-
*/
|
1029 |
-
|
1030 |
-
getLast: function(){
|
1031 |
-
return this[this.length - 1] || null;
|
1032 |
-
}
|
1033 |
-
|
1034 |
-
});
|
1035 |
-
|
1036 |
-
//copies
|
1037 |
-
|
1038 |
-
Array.prototype.each = Array.prototype.forEach;
|
1039 |
-
Array.each = Array.forEach;
|
1040 |
-
|
1041 |
-
/* Section: Utility Functions */
|
1042 |
-
|
1043 |
-
/*
|
1044 |
-
Function: $A()
|
1045 |
-
Same as <Array.copy>, but as function.
|
1046 |
-
Useful to apply Array prototypes to iterable objects, as a collection of DOM elements or the arguments object.
|
1047 |
-
|
1048 |
-
Example:
|
1049 |
-
(start code)
|
1050 |
-
function myFunction(){
|
1051 |
-
$A(arguments).each(argument, function(){
|
1052 |
-
alert(argument);
|
1053 |
-
});
|
1054 |
-
};
|
1055 |
-
//the above will alert all the arguments passed to the function myFunction.
|
1056 |
-
(end)
|
1057 |
-
*/
|
1058 |
-
|
1059 |
-
function $A(array){
|
1060 |
-
return Array.copy(array);
|
1061 |
-
};
|
1062 |
-
|
1063 |
-
/*
|
1064 |
-
Function: $each
|
1065 |
-
Use to iterate through iterables that are not regular arrays, such as builtin getElementsByTagName calls, arguments of a function, or an object.
|
1066 |
-
|
1067 |
-
Arguments:
|
1068 |
-
iterable - an iterable element or an objct.
|
1069 |
-
function - function to apply to the iterable.
|
1070 |
-
bind - optional, the 'this' of the function will refer to this object.
|
1071 |
-
|
1072 |
-
Function argument:
|
1073 |
-
The function argument will be passed the following arguments.
|
1074 |
-
|
1075 |
-
item - the current item in the iterator being procesed
|
1076 |
-
index - integer; the index of the item, or key in case of an object.
|
1077 |
-
|
1078 |
-
Examples:
|
1079 |
-
(start code)
|
1080 |
-
$each(['Sun','Mon','Tue'], function(day, index){
|
1081 |
-
alert('name:' + day + ', index: ' + index);
|
1082 |
-
});
|
1083 |
-
//alerts "name: Sun, index: 0", "name: Mon, index: 1", etc.
|
1084 |
-
//over an object
|
1085 |
-
$each({first: "Sunday", second: "Monday", third: "Tuesday"}, function(value, key){
|
1086 |
-
alert("the " + key + " day of the week is " + value);
|
1087 |
-
});
|
1088 |
-
//alerts "the first day of the week is Sunday",
|
1089 |
-
//"the second day of the week is Monday", etc.
|
1090 |
-
(end)
|
1091 |
-
*/
|
1092 |
-
|
1093 |
-
function $each(iterable, fn, bind){
|
1094 |
-
if (iterable && typeof iterable.length == 'number' && $type(iterable) != 'object'){
|
1095 |
-
Array.forEach(iterable, fn, bind);
|
1096 |
-
} else {
|
1097 |
-
for (var name in iterable) fn.call(bind || iterable, iterable[name], name);
|
1098 |
-
}
|
1099 |
-
};
|
1100 |
-
|
1101 |
-
/*compatibility*/
|
1102 |
-
|
1103 |
-
Array.prototype.test = Array.prototype.contains;
|
1104 |
-
|
1105 |
-
/*end compatibility*/
|
1106 |
-
|
1107 |
-
/*
|
1108 |
-
Script: String.js
|
1109 |
-
Contains String prototypes.
|
1110 |
-
|
1111 |
-
License:
|
1112 |
-
MIT-style license.
|
1113 |
-
*/
|
1114 |
-
|
1115 |
-
/*
|
1116 |
-
Class: String
|
1117 |
-
A collection of The String Object prototype methods.
|
1118 |
-
*/
|
1119 |
-
|
1120 |
-
String.extend({
|
1121 |
-
|
1122 |
-
/*
|
1123 |
-
Property: test
|
1124 |
-
Tests a string with a regular expression.
|
1125 |
-
|
1126 |
-
Arguments:
|
1127 |
-
regex - a string or regular expression object, the regular expression you want to match the string with
|
1128 |
-
params - optional, if first parameter is a string, any parameters you want to pass to the regex ('g' has no effect)
|
1129 |
-
|
1130 |
-
Returns:
|
1131 |
-
true if a match for the regular expression is found in the string, false if not.
|
1132 |
-
See <http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Reference:Objects:RegExp:test>
|
1133 |
-
|
1134 |
-
Example:
|
1135 |
-
>"I like cookies".test("cookie"); // returns true
|
1136 |
-
>"I like cookies".test("COOKIE", "i") // ignore case, returns true
|
1137 |
-
>"I like cookies".test("cake"); // returns false
|
1138 |
-
*/
|
1139 |
-
|
1140 |
-
test: function(regex, params){
|
1141 |
-
return (($type(regex) == 'string') ? new RegExp(regex, params) : regex).test(this);
|
1142 |
-
},
|
1143 |
-
|
1144 |
-
/*
|
1145 |
-
Property: toInt
|
1146 |
-
parses a string to an integer.
|
1147 |
-
|
1148 |
-
Returns:
|
1149 |
-
either an int or "NaN" if the string is not a number.
|
1150 |
-
|
1151 |
-
Example:
|
1152 |
-
>var value = "10px".toInt(); // value is 10
|
1153 |
-
*/
|
1154 |
-
|
1155 |
-
toInt: function(){
|
1156 |
-
return parseInt(this, 10);
|
1157 |
-
},
|
1158 |
-
|
1159 |
-
/*
|
1160 |
-
Property: toFloat
|
1161 |
-
parses a string to an float.
|
1162 |
-
|
1163 |
-
Returns:
|
1164 |
-
either a float or "NaN" if the string is not a number.
|
1165 |
-
|
1166 |
-
Example:
|
1167 |
-
>var value = "10.848".toFloat(); // value is 10.848
|
1168 |
-
*/
|
1169 |
-
|
1170 |
-
toFloat: function(){
|
1171 |
-
return parseFloat(this);
|
1172 |
-
},
|
1173 |
-
|
1174 |
-
/*
|
1175 |
-
Property: camelCase
|
1176 |
-
Converts a hiphenated string to a camelcase string.
|
1177 |
-
|
1178 |
-
Example:
|
1179 |
-
>"I-like-cookies".camelCase(); //"ILikeCookies"
|
1180 |
-
|
1181 |
-
Returns:
|
1182 |
-
the camel cased string
|
1183 |
-
*/
|
1184 |
-
|
1185 |
-
camelCase: function(){
|
1186 |
-
return this.replace(/-\D/g, function(match){
|
1187 |
-
return match.charAt(1).toUpperCase();
|
1188 |
-
});
|
1189 |
-
},
|
1190 |
-
|
1191 |
-
/*
|
1192 |
-
Property: hyphenate
|
1193 |
-
Converts a camelCased string to a hyphen-ated string.
|
1194 |
-
|
1195 |
-
Example:
|
1196 |
-
>"ILikeCookies".hyphenate(); //"I-like-cookies"
|
1197 |
-
*/
|
1198 |
-
|
1199 |
-
hyphenate: function(){
|
1200 |
-
return this.replace(/\w[A-Z]/g, function(match){
|
1201 |
-
return (match.charAt(0) + '-' + match.charAt(1).toLowerCase());
|
1202 |
-
});
|
1203 |
-
},
|
1204 |
-
|
1205 |
-
/*
|
1206 |
-
Property: capitalize
|
1207 |
-
Converts the first letter in each word of a string to Uppercase.
|
1208 |
-
|
1209 |
-
Example:
|
1210 |
-
>"i like cookies".capitalize(); //"I Like Cookies"
|
1211 |
-
|
1212 |
-
Returns:
|
1213 |
-
the capitalized string
|
1214 |
-
*/
|
1215 |
-
|
1216 |
-
capitalize: function(){
|
1217 |
-
return this.replace(/\b[a-z]/g, function(match){
|
1218 |
-
return match.toUpperCase();
|
1219 |
-
});
|
1220 |
-
},
|
1221 |
-
|
1222 |
-
/*
|
1223 |
-
Property: trim
|
1224 |
-
Trims the leading and trailing spaces off a string.
|
1225 |
-
|
1226 |
-
Example:
|
1227 |
-
>" i like cookies ".trim() //"i like cookies"
|
1228 |
-
|
1229 |
-
Returns:
|
1230 |
-
the trimmed string
|
1231 |
-
*/
|
1232 |
-
|
1233 |
-
trim: function(){
|
1234 |
-
return this.replace(/^\s+|\s+#x2F;g, '');
|
1235 |
-
},
|
1236 |
-
|
1237 |
-
/*
|
1238 |
-
Property: clean
|
1239 |
-
trims (<String.trim>) a string AND removes all the double spaces in a string.
|
1240 |
-
|
1241 |
-
Returns:
|
1242 |
-
the cleaned string
|
1243 |
-
|
1244 |
-
Example:
|
1245 |
-
>" i like cookies \n\n".clean() //"i like cookies"
|
1246 |
-
*/
|
1247 |
-
|
1248 |
-
clean: function(){
|
1249 |
-
return this.replace(/\s{2,}/g, ' ').trim();
|
1250 |
-
},
|
1251 |
-
|
1252 |
-
/*
|
1253 |
-
Property: rgbToHex
|
1254 |
-
Converts an RGB value to hexidecimal. The string must be in the format of "rgb(255,255,255)" or "rgba(255,255,255,1)";
|
1255 |
-
|
1256 |
-
Arguments:
|
1257 |
-
array - boolean value, defaults to false. Use true if you want the array ['FF','33','00'] as output instead of "#FF3300"
|
1258 |
-
|
1259 |
-
Returns:
|
1260 |
-
hex string or array. returns "transparent" if the output is set as string and the fourth value of rgba in input string is 0.
|
1261 |
-
|
1262 |
-
Example:
|
1263 |
-
>"rgb(17,34,51)".rgbToHex(); //"#112233"
|
1264 |
-
>"rgba(17,34,51,0)".rgbToHex(); //"transparent"
|
1265 |
-
>"rgb(17,34,51)".rgbToHex(true); //['11','22','33']
|
1266 |
-
*/
|
1267 |
-
|
1268 |
-
rgbToHex: function(array){
|
1269 |
-
var rgb = this.match(/\d{1,3}/g);
|
1270 |
-
return (rgb) ? rgb.rgbToHex(array) : false;
|
1271 |
-
},
|
1272 |
-
|
1273 |
-
/*
|
1274 |
-
Property: hexToRgb
|
1275 |
-
Converts a hexidecimal color value to RGB. Input string must be the hex color value (with or without the hash). Also accepts triplets ('333');
|
1276 |
-
|
1277 |
-
Arguments:
|
1278 |
-
array - boolean value, defaults to false. Use true if you want the array [255,255,255] as output instead of "rgb(255,255,255)";
|
1279 |
-
|
1280 |
-
Returns:
|
1281 |
-
rgb string or array.
|
1282 |
-
|
1283 |
-
Example:
|
1284 |
-
>"#112233".hexToRgb(); //"rgb(17,34,51)"
|
1285 |
-
>"#112233".hexToRgb(true); //[17,34,51]
|
1286 |
-
*/
|
1287 |
-
|
1288 |
-
hexToRgb: function(array){
|
1289 |
-
var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})#x2F;);
|
1290 |
-
return (hex) ? hex.slice(1).hexToRgb(array) : false;
|
1291 |
-
},
|
1292 |
-
|
1293 |
-
/*
|
1294 |
-
Property: contains
|
1295 |
-
checks if the passed in string is contained in the String. also accepts an optional second parameter, to check if the string is contained in a list of separated values.
|
1296 |
-
|
1297 |
-
Example:
|
1298 |
-
>'a b c'.contains('c', ' '); //true
|
1299 |
-
>'a bc'.contains('bc'); //true
|
1300 |
-
>'a bc'.contains('b', ' '); //false
|
1301 |
-
*/
|
1302 |
-
|
1303 |
-
contains: function(string, s){
|
1304 |
-
return (s) ? (s + this + s).indexOf(s + string + s) > -1 : this.indexOf(string) > -1;
|
1305 |
-
},
|
1306 |
-
|
1307 |
-
/*
|
1308 |
-
Property: escapeRegExp
|
1309 |
-
Returns string with escaped regular expression characters
|
1310 |