init
This commit is contained in:
8
jssource/src_files/include/javascript/yui3/build/anim/anim-base-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-base-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-base",function(B){var C="running",N="startTime",L="elapsedTime",J="start",I="tween",M="end",D="node",K="paused",P="reverse",H="iterationCount",A=Number;var F={},O={},E;B.Anim=function(){B.Anim.superclass.constructor.apply(this,arguments);O[B.stamp(this)]=this;};B.Anim.NAME="anim";B.Anim.RE_DEFAULT_UNIT=/^width|height|top|right|bottom|left|margin.*|padding.*|border.*$/i;B.Anim.DEFAULT_UNIT="px";B.Anim.DEFAULT_EASING=function(R,Q,T,S){return T*R/S+Q;};B.Anim.behaviors={left:{get:function(R,Q){return R._getOffset(Q);}}};B.Anim.behaviors.top=B.Anim.behaviors.left;B.Anim.DEFAULT_SETTER=function(U,R,X,W,Q,V,S,T){T=T||"";U._node.setStyle(R,S(Q,A(X),A(W)-A(X),V)+T);};B.Anim.DEFAULT_GETTER=function(Q,R){return Q._node.getComputedStyle(R);};B.Anim.ATTRS={node:{setter:function(Q){Q=B.get(Q);this._node=Q;if(!Q){}return Q;}},duration:{value:1},easing:{value:B.Anim.DEFAULT_EASING,setter:function(Q){if(typeof Q==="string"&&B.Easing){return B.Easing[Q];}}},from:{},to:{},startTime:{value:0,readOnly:true},elapsedTime:{value:0,readOnly:true},running:{getter:function(){return !!F[B.stamp(this)];},value:false,readOnly:true},iterations:{value:1},iterationCount:{value:0,readOnly:true},direction:{value:"normal"},paused:{readOnly:true,value:false},reverse:{value:false}};B.Anim.run=function(){for(var Q in O){if(O[Q].run){O[Q].run();}}};B.Anim.pause=function(){for(var Q in F){if(F[Q].pause){F[Q].pause();}}B.Anim._stopTimer();};B.Anim.stop=function(){for(var Q in F){if(F[Q].stop){F[Q].stop();}}B.Anim._stopTimer();};B.Anim._startTimer=function(){if(!E){E=setInterval(B.Anim._runFrame,1);}};B.Anim._stopTimer=function(){clearInterval(E);E=0;};B.Anim._runFrame=function(){var Q=true;for(var R in F){if(F[R]._runFrame){Q=false;F[R]._runFrame();}}if(Q){B.Anim._stopTimer();}};B.Anim.RE_UNITS=/^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/;var G={run:function(){if(!this.get(C)){this._start();}else{if(this.get(K)){this._resume();}}return this;},pause:function(){if(this.get(C)){this._pause();}return this;},stop:function(Q){if(this.get(C)||this.get(K)){this._end(Q);}return this;},_added:false,_start:function(){this._set(N,new Date()-this.get(L));this._actualFrames=0;if(!this.get(K)){this._initAnimAttr();}F[B.stamp(this)]=this;B.Anim._startTimer();this.fire(J);},_pause:function(){this._set(N,null);this._set(K,true);delete F[B.stamp(this)];this.fire("pause");},_resume:function(){this._set(K,false);F[B.stamp(this)]=this;this.fire("resume");},_end:function(Q){this._set(N,null);this._set(L,0);this._set(K,false);delete F[B.stamp(this)];this.fire(M,{elapsed:this.get(L)});},_runFrame:function(){var X=this._runtimeAttr,S=B.Anim.behaviors,Y=X.easing,Z=X.duration,a=new Date()-this.get(N),W=this.get(P),U=(a>=Z),Q=Z,R,T;if(W){a=Z-a;U=(a<=0);Q=0;}for(var V in X){if(X[V].to){R=X[V];T=(V in S&&"set" in S[V])?S[V].set:B.Anim.DEFAULT_SETTER;if(!U){T(this,V,R.from,R.to,a,Z,Y,R.unit);}else{T(this,V,R.from,R.to,Q,Z,Y,R.unit);}}}this._actualFrames+=1;this._set(L,a);this.fire(I);if(U){this._lastFrame();}},_lastFrame:function(){var Q=this.get("iterations"),R=this.get(H);R+=1;if(Q==="infinite"||R<Q){if(this.get("direction")==="alternate"){this.set(P,!this.get(P));}this.fire("iteration");}else{R=0;this._end();}this._set(N,new Date());this._set(H,R);},_initAnimAttr:function(){var X=this.get("from")||{},Y=this.get("to")||{},Q=this.get("duration")*1000,T=this.get(D),W=this.get("easing")||{},V={},R=B.Anim.behaviors,Z,S,U;B.each(Y,function(d,b){if(typeof d==="function"){d=d.call(this,T);}S=X[b];if(S===undefined){S=(b in R&&"get" in R[b])?R[b].get(this,b):B.Anim.DEFAULT_GETTER(this,b);}else{if(typeof S==="function"){S=S.call(this,T);}}var a=B.Anim.RE_UNITS.exec(S);var c=B.Anim.RE_UNITS.exec(d);S=a?a[1]:S;U=c?c[1]:d;Z=c?c[2]:a?a[2]:"";if(!Z&&B.Anim.RE_DEFAULT_UNIT.test(b)){Z=B.Anim.DEFAULT_UNIT;}if(!S||!U){B.error('invalid "from" or "to" for "'+b+'"',"Anim");return;}V[b]={from:S,to:U,unit:Z};V.duration=Q;V.easing=W;},this);this._runtimeAttr=V;},_getOffset:function(R){var T=this._node,U=T.getComputedStyle(R),S=(R==="left")?"getX":"getY",V=(R==="left")?"setX":"setY";if(U==="auto"){var Q=T.getStyle("position");if(Q==="absolute"||Q==="fixed"){U=T[S]();T[V](U);}else{U=0;}}return U;}};B.extend(B.Anim,B.Base,G);},"3.0.0",{requires:["base-base","node-style"]});
|
||||
602
jssource/src_files/include/javascript/yui3/build/anim/anim-base.js
vendored
Normal file
602
jssource/src_files/include/javascript/yui3/build/anim/anim-base.js
vendored
Normal file
@@ -0,0 +1,602 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The Animation Utility provides an API for creating advanced transitions.
|
||||
* @module anim
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base Anim class, for animating numeric properties.
|
||||
*
|
||||
* @module anim
|
||||
* @submodule anim-base
|
||||
*/
|
||||
|
||||
/**
|
||||
* A class for constructing animation instances.
|
||||
* @class Anim
|
||||
* @for Anim
|
||||
* @constructor
|
||||
* @extends Base
|
||||
*/
|
||||
|
||||
var RUNNING = 'running',
|
||||
START_TIME = 'startTime',
|
||||
ELAPSED_TIME = 'elapsedTime',
|
||||
/**
|
||||
* @for Anim
|
||||
* @event start
|
||||
* @description fires when an animation begins.
|
||||
* @param {Event} ev The start event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
START = 'start',
|
||||
|
||||
/**
|
||||
* @event tween
|
||||
* @description fires every frame of the animation.
|
||||
* @param {Event} ev The tween event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
TWEEN = 'tween',
|
||||
|
||||
/**
|
||||
* @event end
|
||||
* @description fires after the animation completes.
|
||||
* @param {Event} ev The end event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
END = 'end',
|
||||
NODE = 'node',
|
||||
PAUSED = 'paused',
|
||||
REVERSE = 'reverse', // TODO: cleanup
|
||||
ITERATION_COUNT = 'iterationCount',
|
||||
|
||||
NUM = Number;
|
||||
|
||||
var _running = {},
|
||||
_instances = {},
|
||||
_timer;
|
||||
|
||||
Y.Anim = function() {
|
||||
Y.Anim.superclass.constructor.apply(this, arguments);
|
||||
_instances[Y.stamp(this)] = this;
|
||||
};
|
||||
|
||||
Y.Anim.NAME = 'anim';
|
||||
|
||||
/**
|
||||
* Regex of properties that should use the default unit.
|
||||
*
|
||||
* @property RE_DEFAULT_UNIT
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.RE_DEFAULT_UNIT = /^width|height|top|right|bottom|left|margin.*|padding.*|border.*$/i;
|
||||
|
||||
/**
|
||||
* The default unit to use with properties that pass the RE_DEFAULT_UNIT test.
|
||||
*
|
||||
* @property DEFAULT_UNIT
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.DEFAULT_UNIT = 'px';
|
||||
|
||||
Y.Anim.DEFAULT_EASING = function (t, b, c, d) {
|
||||
return c * t / d + b; // linear easing
|
||||
};
|
||||
|
||||
/**
|
||||
* Bucket for custom getters and setters
|
||||
*
|
||||
* @property behaviors
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.behaviors = {
|
||||
left: {
|
||||
get: function(anim, attr) {
|
||||
return anim._getOffset(attr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Y.Anim.behaviors.top = Y.Anim.behaviors.left;
|
||||
|
||||
/**
|
||||
* The default setter to use when setting object properties.
|
||||
*
|
||||
* @property DEFAULT_SETTER
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.DEFAULT_SETTER = function(anim, att, from, to, elapsed, duration, fn, unit) {
|
||||
unit = unit || '';
|
||||
anim._node.setStyle(att, fn(elapsed, NUM(from), NUM(to) - NUM(from), duration) + unit);
|
||||
};
|
||||
|
||||
/**
|
||||
* The default getter to use when getting object properties.
|
||||
*
|
||||
* @property DEFAULT_GETTER
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.DEFAULT_GETTER = function(anim, prop) {
|
||||
return anim._node.getComputedStyle(prop);
|
||||
};
|
||||
|
||||
Y.Anim.ATTRS = {
|
||||
/**
|
||||
* The object to be animated.
|
||||
* @attribute node
|
||||
* @type Node
|
||||
*/
|
||||
node: {
|
||||
setter: function(node) {
|
||||
node = Y.get(node);
|
||||
this._node = node;
|
||||
if (!node) {
|
||||
}
|
||||
return node;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The length of the animation. Defaults to "1" (second).
|
||||
* @attribute duration
|
||||
* @type NUM
|
||||
*/
|
||||
duration: {
|
||||
value: 1
|
||||
},
|
||||
|
||||
/**
|
||||
* The method that will provide values to the attribute(s) during the animation.
|
||||
* Defaults to "Easing.easeNone".
|
||||
* @attribute easing
|
||||
* @type Function
|
||||
*/
|
||||
easing: {
|
||||
value: Y.Anim.DEFAULT_EASING,
|
||||
|
||||
setter: function(val) {
|
||||
if (typeof val === 'string' && Y.Easing) {
|
||||
return Y.Easing[val];
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The starting values for the animated properties.
|
||||
* Fields may be strings, numbers, or functions.
|
||||
* If a function is used, the return value becomes the from value.
|
||||
* If no from value is specified, the DEFAULT_GETTER will be used.
|
||||
* @attribute from
|
||||
* @type Object
|
||||
*/
|
||||
from: {},
|
||||
|
||||
/**
|
||||
* The ending values for the animated properties.
|
||||
* Fields may be strings, numbers, or functions.
|
||||
* @attribute to
|
||||
* @type Object
|
||||
*/
|
||||
to: {},
|
||||
|
||||
/**
|
||||
* Date stamp for the first frame of the animation.
|
||||
* @attribute startTime
|
||||
* @type Int
|
||||
* @default 0
|
||||
* @readOnly
|
||||
*/
|
||||
startTime: {
|
||||
value: 0,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Current time the animation has been running.
|
||||
* @attribute elapsedTime
|
||||
* @type Int
|
||||
* @default 0
|
||||
* @readOnly
|
||||
*/
|
||||
elapsedTime: {
|
||||
value: 0,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether or not the animation is currently running.
|
||||
* @attribute running
|
||||
* @type Boolean
|
||||
* @default false
|
||||
* @readOnly
|
||||
*/
|
||||
running: {
|
||||
getter: function() {
|
||||
return !!_running[Y.stamp(this)];
|
||||
},
|
||||
value: false,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* The number of times the animation should run
|
||||
* @attribute iterations
|
||||
* @type Int
|
||||
* @default 1
|
||||
*/
|
||||
iterations: {
|
||||
value: 1
|
||||
},
|
||||
|
||||
/**
|
||||
* The number of iterations that have occurred.
|
||||
* Resets when an animation ends (reaches iteration count or stop() called).
|
||||
* @attribute iterationCount
|
||||
* @type Int
|
||||
* @default 0
|
||||
* @readOnly
|
||||
*/
|
||||
iterationCount: {
|
||||
value: 0,
|
||||
readOnly: true
|
||||
},
|
||||
|
||||
/**
|
||||
* How iterations of the animation should behave.
|
||||
* Possible values are "normal" and "alternate".
|
||||
* Normal will repeat the animation, alternate will reverse on every other pass.
|
||||
*
|
||||
* @attribute direction
|
||||
* @type String
|
||||
* @default "normal"
|
||||
*/
|
||||
direction: {
|
||||
value: 'normal' // | alternate (fwd on odd, rev on even per spec)
|
||||
},
|
||||
|
||||
/**
|
||||
* Whether or not the animation is currently paused.
|
||||
* @attribute paused
|
||||
* @type Boolean
|
||||
* @default false
|
||||
* @readOnly
|
||||
*/
|
||||
paused: {
|
||||
readOnly: true,
|
||||
value: false
|
||||
},
|
||||
|
||||
/**
|
||||
* If true, animation begins from last frame
|
||||
* @attribute reverse
|
||||
* @type Boolean
|
||||
* @default false
|
||||
*/
|
||||
reverse: {
|
||||
value: false
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* Runs all animation instances.
|
||||
* @method run
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.run = function() {
|
||||
for (var i in _instances) {
|
||||
if (_instances[i].run) {
|
||||
_instances[i].run();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Pauses all animation instances.
|
||||
* @method pause
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.pause = function() {
|
||||
for (var i in _running) { // stop timer if nothing running
|
||||
if (_running[i].pause) {
|
||||
_running[i].pause();
|
||||
}
|
||||
}
|
||||
Y.Anim._stopTimer();
|
||||
};
|
||||
|
||||
/**
|
||||
* Stops all animation instances.
|
||||
* @method stop
|
||||
* @static
|
||||
*/
|
||||
Y.Anim.stop = function() {
|
||||
for (var i in _running) { // stop timer if nothing running
|
||||
if (_running[i].stop) {
|
||||
_running[i].stop();
|
||||
}
|
||||
}
|
||||
Y.Anim._stopTimer();
|
||||
};
|
||||
|
||||
Y.Anim._startTimer = function() {
|
||||
if (!_timer) {
|
||||
_timer = setInterval(Y.Anim._runFrame, 1);
|
||||
}
|
||||
};
|
||||
|
||||
Y.Anim._stopTimer = function() {
|
||||
clearInterval(_timer);
|
||||
_timer = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Called per Interval to handle each animation frame.
|
||||
* @method _runFrame
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
Y.Anim._runFrame = function() {
|
||||
var done = true;
|
||||
for (var anim in _running) {
|
||||
if (_running[anim]._runFrame) {
|
||||
done = false;
|
||||
_running[anim]._runFrame();
|
||||
}
|
||||
}
|
||||
|
||||
if (done) {
|
||||
Y.Anim._stopTimer();
|
||||
}
|
||||
};
|
||||
|
||||
Y.Anim.RE_UNITS = /^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/;
|
||||
|
||||
var proto = {
|
||||
/**
|
||||
* Starts or resumes an animation.
|
||||
* percent start time marker.
|
||||
* @method run
|
||||
* @chainable
|
||||
*/
|
||||
run: function() {
|
||||
if (!this.get(RUNNING)) {
|
||||
this._start();
|
||||
} else if (this.get(PAUSED)) {
|
||||
this._resume();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Pauses the animation and
|
||||
* freezes it in its current state and time.
|
||||
* Calling run() will continue where it left off.
|
||||
* @method pause
|
||||
* @chainable
|
||||
*/
|
||||
pause: function() {
|
||||
if (this.get(RUNNING)) {
|
||||
this._pause();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops the animation and resets its time.
|
||||
* @method stop
|
||||
* @chainable
|
||||
*/
|
||||
stop: function(finish) {
|
||||
if (this.get(RUNNING) || this.get(PAUSED)) {
|
||||
this._end(finish);
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
_added: false,
|
||||
|
||||
_start: function() {
|
||||
this._set(START_TIME, new Date() - this.get(ELAPSED_TIME));
|
||||
this._actualFrames = 0;
|
||||
if (!this.get(PAUSED)) {
|
||||
this._initAnimAttr();
|
||||
}
|
||||
_running[Y.stamp(this)] = this;
|
||||
Y.Anim._startTimer();
|
||||
|
||||
this.fire(START);
|
||||
},
|
||||
|
||||
_pause: function() {
|
||||
this._set(START_TIME, null);
|
||||
this._set(PAUSED, true);
|
||||
delete _running[Y.stamp(this)];
|
||||
|
||||
/**
|
||||
* @event pause
|
||||
* @description fires when an animation is paused.
|
||||
* @param {Event} ev The pause event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
this.fire('pause');
|
||||
},
|
||||
|
||||
_resume: function() {
|
||||
this._set(PAUSED, false);
|
||||
_running[Y.stamp(this)] = this;
|
||||
|
||||
/**
|
||||
* @event resume
|
||||
* @description fires when an animation is resumed (run from pause).
|
||||
* @param {Event} ev The pause event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
this.fire('resume');
|
||||
},
|
||||
|
||||
_end: function(finish) {
|
||||
this._set(START_TIME, null);
|
||||
this._set(ELAPSED_TIME, 0);
|
||||
this._set(PAUSED, false);
|
||||
|
||||
delete _running[Y.stamp(this)];
|
||||
this.fire(END, {elapsed: this.get(ELAPSED_TIME)});
|
||||
},
|
||||
|
||||
_runFrame: function() {
|
||||
var attr = this._runtimeAttr,
|
||||
customAttr = Y.Anim.behaviors,
|
||||
easing = attr.easing,
|
||||
d = attr.duration,
|
||||
t = new Date() - this.get(START_TIME),
|
||||
reversed = this.get(REVERSE),
|
||||
done = (t >= d),
|
||||
lastFrame = d,
|
||||
attribute,
|
||||
setter;
|
||||
|
||||
if (reversed) {
|
||||
t = d - t;
|
||||
done = (t <= 0);
|
||||
lastFrame = 0;
|
||||
}
|
||||
|
||||
for (var i in attr) {
|
||||
if (attr[i].to) {
|
||||
attribute = attr[i];
|
||||
setter = (i in customAttr && 'set' in customAttr[i]) ?
|
||||
customAttr[i].set : Y.Anim.DEFAULT_SETTER;
|
||||
|
||||
if (!done) {
|
||||
setter(this, i, attribute.from, attribute.to, t, d, easing, attribute.unit);
|
||||
} else { // ensure final frame value is set
|
||||
// TODO: handle keyframes
|
||||
setter(this, i, attribute.from, attribute.to, lastFrame, d, easing, attribute.unit);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._actualFrames += 1;
|
||||
this._set(ELAPSED_TIME, t);
|
||||
|
||||
this.fire(TWEEN);
|
||||
if (done) {
|
||||
this._lastFrame();
|
||||
}
|
||||
},
|
||||
|
||||
_lastFrame: function() {
|
||||
var iter = this.get('iterations'),
|
||||
iterCount = this.get(ITERATION_COUNT);
|
||||
|
||||
iterCount += 1;
|
||||
if (iter === 'infinite' || iterCount < iter) {
|
||||
if (this.get('direction') === 'alternate') {
|
||||
this.set(REVERSE, !this.get(REVERSE)); // flip it
|
||||
}
|
||||
/**
|
||||
* @event iteration
|
||||
* @description fires when an animation begins an iteration.
|
||||
* @param {Event} ev The iteration event.
|
||||
* @type Event.Custom
|
||||
*/
|
||||
this.fire('iteration');
|
||||
} else {
|
||||
iterCount = 0;
|
||||
this._end();
|
||||
}
|
||||
|
||||
this._set(START_TIME, new Date());
|
||||
this._set(ITERATION_COUNT, iterCount);
|
||||
},
|
||||
|
||||
_initAnimAttr: function() {
|
||||
var from = this.get('from') || {},
|
||||
to = this.get('to') || {},
|
||||
dur = this.get('duration') * 1000,
|
||||
node = this.get(NODE),
|
||||
easing = this.get('easing') || {},
|
||||
attr = {},
|
||||
customAttr = Y.Anim.behaviors,
|
||||
unit, begin, end;
|
||||
|
||||
Y.each(to, function(val, name) {
|
||||
if (typeof val === 'function') {
|
||||
val = val.call(this, node);
|
||||
}
|
||||
|
||||
begin = from[name];
|
||||
if (begin === undefined) {
|
||||
begin = (name in customAttr && 'get' in customAttr[name]) ?
|
||||
customAttr[name].get(this, name) : Y.Anim.DEFAULT_GETTER(this, name);
|
||||
} else if (typeof begin === 'function') {
|
||||
begin = begin.call(this, node);
|
||||
}
|
||||
|
||||
var mFrom = Y.Anim.RE_UNITS.exec(begin);
|
||||
var mTo = Y.Anim.RE_UNITS.exec(val);
|
||||
|
||||
begin = mFrom ? mFrom[1] : begin;
|
||||
end = mTo ? mTo[1] : val;
|
||||
unit = mTo ? mTo[2] : mFrom ? mFrom[2] : ''; // one might be zero TODO: mixed units
|
||||
|
||||
if (!unit && Y.Anim.RE_DEFAULT_UNIT.test(name)) {
|
||||
unit = Y.Anim.DEFAULT_UNIT;
|
||||
}
|
||||
|
||||
if (!begin || !end) {
|
||||
Y.error('invalid "from" or "to" for "' + name + '"', 'Anim');
|
||||
return;
|
||||
}
|
||||
|
||||
attr[name] = {
|
||||
from: begin,
|
||||
to: end,
|
||||
unit: unit
|
||||
};
|
||||
|
||||
attr.duration = dur;
|
||||
attr.easing = easing;
|
||||
|
||||
}, this);
|
||||
|
||||
this._runtimeAttr = attr;
|
||||
},
|
||||
|
||||
|
||||
// TODO: move to computedStyle? (browsers dont agree on default computed offsets)
|
||||
_getOffset: function(attr) {
|
||||
var node = this._node,
|
||||
val = node.getComputedStyle(attr),
|
||||
get = (attr === 'left') ? 'getX': 'getY',
|
||||
set = (attr === 'left') ? 'setX': 'setY';
|
||||
|
||||
if (val === 'auto') {
|
||||
var position = node.getStyle('position');
|
||||
if (position === 'absolute' || position === 'fixed') {
|
||||
val = node[get]();
|
||||
node[set](val);
|
||||
} else {
|
||||
val = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
Y.extend(Y.Anim, Y.Base, proto);
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base-base', 'node-style']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/anim/anim-color-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-color-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-color",function(B){var A=Number;B.Anim.behaviors.color={set:function(F,D,I,H,C,G,E){I=B.Color.re_RGB.exec(B.Color.toRGB(I));H=B.Color.re_RGB.exec(B.Color.toRGB(H));if(!I||I.length<3||!H||H.length<3){B.error("invalid from or to passed to color behavior");}F._node.setStyle(D,"rgb("+[Math.floor(E(C,A(I[1]),A(H[1])-A(I[1]),G)),Math.floor(E(C,A(I[2]),A(H[2])-A(I[2]),G)),Math.floor(E(C,A(I[3]),A(H[3])-A(I[3]),G))].join(", ")+")");},get:function(D,C){var E=D._node.getComputedStyle(C);E=(E==="transparent")?"rgb(255, 255, 255)":E;return E;}};B.each(["backgroundColor","borderColor","borderTopColor","borderRightColor","borderBottomColor","borderLeftColor"],function(C,D){B.Anim.behaviors[C]=B.Anim.behaviors.color;});},"3.0.0",{requires:["anim-base"]});
|
||||
55
jssource/src_files/include/javascript/yui3/build/anim/anim-color.js
vendored
Normal file
55
jssource/src_files/include/javascript/yui3/build/anim/anim-color.js
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-color', function(Y) {
|
||||
|
||||
/**
|
||||
* Adds support for color properties in <code>to</code>
|
||||
* and <code>from</code> attributes.
|
||||
* @module anim
|
||||
* @submodule anim-color
|
||||
*/
|
||||
|
||||
var NUM = Number;
|
||||
|
||||
Y.Anim.behaviors.color = {
|
||||
set: function(anim, att, from, to, elapsed, duration, fn) {
|
||||
from = Y.Color.re_RGB.exec(Y.Color.toRGB(from));
|
||||
to = Y.Color.re_RGB.exec(Y.Color.toRGB(to));
|
||||
|
||||
if (!from || from.length < 3 || !to || to.length < 3) {
|
||||
Y.error('invalid from or to passed to color behavior');
|
||||
}
|
||||
|
||||
anim._node.setStyle(att, 'rgb(' + [
|
||||
Math.floor(fn(elapsed, NUM(from[1]), NUM(to[1]) - NUM(from[1]), duration)),
|
||||
Math.floor(fn(elapsed, NUM(from[2]), NUM(to[2]) - NUM(from[2]), duration)),
|
||||
Math.floor(fn(elapsed, NUM(from[3]), NUM(to[3]) - NUM(from[3]), duration))
|
||||
].join(', ') + ')');
|
||||
},
|
||||
|
||||
// TODO: default bgcolor const
|
||||
get: function(anim, att) {
|
||||
var val = anim._node.getComputedStyle(att);
|
||||
val = (val === 'transparent') ? 'rgb(255, 255, 255)' : val;
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
Y.each(['backgroundColor',
|
||||
'borderColor',
|
||||
'borderTopColor',
|
||||
'borderRightColor',
|
||||
'borderBottomColor',
|
||||
'borderLeftColor'],
|
||||
function(v, i) {
|
||||
Y.Anim.behaviors[v] = Y.Anim.behaviors.color;
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['anim-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/anim/anim-curve-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-curve-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-curve",function(A){A.Anim.behaviors.curve={set:function(F,C,I,H,B,G,E){I=I.slice.call(I);H=H.slice.call(H);var D=E(B,0,100,G)/100;H.unshift(I);F._node.setXY(A.Anim.getBezier(H,D));},get:function(C,B){return C._node.getXY();}};A.Anim.getBezier=function(F,E){var G=F.length;var D=[];for(var C=0;C<G;++C){D[C]=[F[C][0],F[C][1]];}for(var B=1;B<G;++B){for(C=0;C<G-B;++C){D[C][0]=(1-E)*D[C][0]+E*D[parseInt(C+1,10)][0];D[C][1]=(1-E)*D[C][1]+E*D[parseInt(C+1,10)][1];}}return[D[0][0],D[0][1]];};},"3.0.0",{requires:["anim-xy"]});
|
||||
64
jssource/src_files/include/javascript/yui3/build/anim/anim-curve.js
vendored
Normal file
64
jssource/src_files/include/javascript/yui3/build/anim/anim-curve.js
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-curve', function(Y) {
|
||||
|
||||
/**
|
||||
* Adds support for the <code>curve</code> property for the <code>to</code>
|
||||
* attribute. A curve is zero or more control points and an end point.
|
||||
* @module anim
|
||||
* @submodule anim-curve
|
||||
*/
|
||||
|
||||
Y.Anim.behaviors.curve = {
|
||||
set: function(anim, att, from, to, elapsed, duration, fn) {
|
||||
from = from.slice.call(from);
|
||||
to = to.slice.call(to);
|
||||
var t = fn(elapsed, 0, 100, duration) / 100;
|
||||
to.unshift(from);
|
||||
anim._node.setXY(Y.Anim.getBezier(to, t));
|
||||
},
|
||||
|
||||
get: function(anim, att) {
|
||||
return anim._node.getXY();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the current position of the animated element based on t.
|
||||
* Each point is an array of "x" and "y" values (0 = x, 1 = y)
|
||||
* At least 2 points are required (start and end).
|
||||
* First point is start. Last point is end.
|
||||
* Additional control points are optional.
|
||||
* @for Anim
|
||||
* @method getBezier
|
||||
* @static
|
||||
* @param {Array} points An array containing Bezier points
|
||||
* @param {Number} t A number between 0 and 1 which is the basis for determining current position
|
||||
* @return {Array} An array containing int x and y member data
|
||||
*/
|
||||
Y.Anim.getBezier = function(points, t) {
|
||||
var n = points.length;
|
||||
var tmp = [];
|
||||
|
||||
for (var i = 0; i < n; ++i){
|
||||
tmp[i] = [points[i][0], points[i][1]]; // save input
|
||||
}
|
||||
|
||||
for (var j = 1; j < n; ++j) {
|
||||
for (i = 0; i < n - j; ++i) {
|
||||
tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
|
||||
tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
|
||||
}
|
||||
}
|
||||
|
||||
return [ tmp[0][0], tmp[0][1] ];
|
||||
|
||||
};
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['anim-xy']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/anim/anim-easing-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-easing-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-easing",function(A){A.Easing={easeNone:function(C,B,E,D){return E*C/D+B;},easeIn:function(C,B,E,D){return E*(C/=D)*C+B;},easeOut:function(C,B,E,D){return -E*(C/=D)*(C-2)+B;},easeBoth:function(C,B,E,D){if((C/=D/2)<1){return E/2*C*C+B;}return -E/2*((--C)*(C-2)-1)+B;},easeInStrong:function(C,B,E,D){return E*(C/=D)*C*C*C+B;},easeOutStrong:function(C,B,E,D){return -E*((C=C/D-1)*C*C*C-1)+B;},easeBothStrong:function(C,B,E,D){if((C/=D/2)<1){return E/2*C*C*C*C+B;}return -E/2*((C-=2)*C*C*C-2)+B;},elasticIn:function(D,B,H,G,C,F){var E;if(D===0){return B;}if((D/=G)===1){return B+H;}if(!F){F=G*0.3;}if(!C||C<Math.abs(H)){C=H;E=F/4;}else{E=F/(2*Math.PI)*Math.asin(H/C);}return -(C*Math.pow(2,10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F))+B;},elasticOut:function(D,B,H,G,C,F){var E;if(D===0){return B;}if((D/=G)===1){return B+H;}if(!F){F=G*0.3;}if(!C||C<Math.abs(H)){C=H;E=F/4;}else{E=F/(2*Math.PI)*Math.asin(H/C);}return C*Math.pow(2,-10*D)*Math.sin((D*G-E)*(2*Math.PI)/F)+H+B;},elasticBoth:function(D,B,H,G,C,F){var E;if(D===0){return B;}if((D/=G/2)===2){return B+H;}if(!F){F=G*(0.3*1.5);}if(!C||C<Math.abs(H)){C=H;E=F/4;}else{E=F/(2*Math.PI)*Math.asin(H/C);}if(D<1){return -0.5*(C*Math.pow(2,10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F))+B;}return C*Math.pow(2,-10*(D-=1))*Math.sin((D*G-E)*(2*Math.PI)/F)*0.5+H+B;},backIn:function(C,B,F,E,D){if(D===undefined){D=1.70158;}if(C===E){C-=0.001;}return F*(C/=E)*C*((D+1)*C-D)+B;},backOut:function(C,B,F,E,D){if(typeof D==="undefined"){D=1.70158;}return F*((C=C/E-1)*C*((D+1)*C+D)+1)+B;},backBoth:function(C,B,F,E,D){if(typeof D==="undefined"){D=1.70158;}if((C/=E/2)<1){return F/2*(C*C*(((D*=(1.525))+1)*C-D))+B;}return F/2*((C-=2)*C*(((D*=(1.525))+1)*C+D)+2)+B;},bounceIn:function(C,B,E,D){return E-A.Easing.bounceOut(D-C,0,E,D)+B;},bounceOut:function(C,B,E,D){if((C/=D)<(1/2.75)){return E*(7.5625*C*C)+B;}else{if(C<(2/2.75)){return E*(7.5625*(C-=(1.5/2.75))*C+0.75)+B;}else{if(C<(2.5/2.75)){return E*(7.5625*(C-=(2.25/2.75))*C+0.9375)+B;}}}return E*(7.5625*(C-=(2.625/2.75))*C+0.984375)+B;},bounceBoth:function(C,B,E,D){if(C<D/2){return A.Easing.bounceIn(C*2,0,E,D)*0.5+B;}return A.Easing.bounceOut(C*2-D,0,E,D)*0.5+E*0.5+B;}};},"3.0.0",{requires:["anim-base"]});
|
||||
355
jssource/src_files/include/javascript/yui3/build/anim/anim-easing.js
vendored
Normal file
355
jssource/src_files/include/javascript/yui3/build/anim/anim-easing.js
vendored
Normal file
@@ -0,0 +1,355 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-easing', function(Y) {
|
||||
|
||||
/*
|
||||
TERMS OF USE - EASING EQUATIONS
|
||||
Open source under the BSD License.
|
||||
Copyright 2001 Robert Penner All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The easing module provides methods for customizing
|
||||
* how an animation behaves during each run.
|
||||
* @class Easing
|
||||
* @module anim
|
||||
* @submodule anim-easing
|
||||
*/
|
||||
|
||||
Y.Easing = {
|
||||
|
||||
/**
|
||||
* Uniform speed between points.
|
||||
* @for Easing
|
||||
* @method easeNone
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeNone: function (t, b, c, d) {
|
||||
return c*t/d + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins slowly and accelerates towards end. (quadratic)
|
||||
* @method easeIn
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeIn: function (t, b, c, d) {
|
||||
return c*(t/=d)*t + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins quickly and decelerates towards end. (quadratic)
|
||||
* @method easeOut
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeOut: function (t, b, c, d) {
|
||||
return -c *(t/=d)*(t-2) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins slowly and decelerates towards end. (quadratic)
|
||||
* @method easeBoth
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeBoth: function (t, b, c, d) {
|
||||
if ((t/=d/2) < 1) {
|
||||
return c/2*t*t + b;
|
||||
}
|
||||
|
||||
return -c/2 * ((--t)*(t-2) - 1) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins slowly and accelerates towards end. (quartic)
|
||||
* @method easeInStrong
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeInStrong: function (t, b, c, d) {
|
||||
return c*(t/=d)*t*t*t + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins quickly and decelerates towards end. (quartic)
|
||||
* @method easeOutStrong
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeOutStrong: function (t, b, c, d) {
|
||||
return -c * ((t=t/d-1)*t*t*t - 1) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Begins slowly and decelerates towards end. (quartic)
|
||||
* @method easeBothStrong
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
easeBothStrong: function (t, b, c, d) {
|
||||
if ((t/=d/2) < 1) {
|
||||
return c/2*t*t*t*t + b;
|
||||
}
|
||||
|
||||
return -c/2 * ((t-=2)*t*t*t - 2) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Snap in elastic effect.
|
||||
* @method elasticIn
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} a Amplitude (optional)
|
||||
* @param {Number} p Period (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
|
||||
elasticIn: function (t, b, c, d, a, p) {
|
||||
var s;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
if ( (t /= d) === 1 ) {
|
||||
return b+c;
|
||||
}
|
||||
if (!p) {
|
||||
p = d* 0.3;
|
||||
}
|
||||
|
||||
if (!a || a < Math.abs(c)) {
|
||||
a = c;
|
||||
s = p/4;
|
||||
}
|
||||
else {
|
||||
s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
}
|
||||
|
||||
return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Snap out elastic effect.
|
||||
* @method elasticOut
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} a Amplitude (optional)
|
||||
* @param {Number} p Period (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
elasticOut: function (t, b, c, d, a, p) {
|
||||
var s;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
if ( (t /= d) === 1 ) {
|
||||
return b+c;
|
||||
}
|
||||
if (!p) {
|
||||
p=d * 0.3;
|
||||
}
|
||||
|
||||
if (!a || a < Math.abs(c)) {
|
||||
a = c;
|
||||
s = p / 4;
|
||||
}
|
||||
else {
|
||||
s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
}
|
||||
|
||||
return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Snap both elastic effect.
|
||||
* @method elasticBoth
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} a Amplitude (optional)
|
||||
* @param {Number} p Period (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
elasticBoth: function (t, b, c, d, a, p) {
|
||||
var s;
|
||||
if (t === 0) {
|
||||
return b;
|
||||
}
|
||||
|
||||
if ( (t /= d/2) === 2 ) {
|
||||
return b+c;
|
||||
}
|
||||
|
||||
if (!p) {
|
||||
p = d*(0.3*1.5);
|
||||
}
|
||||
|
||||
if ( !a || a < Math.abs(c) ) {
|
||||
a = c;
|
||||
s = p/4;
|
||||
}
|
||||
else {
|
||||
s = p/(2*Math.PI) * Math.asin (c/a);
|
||||
}
|
||||
|
||||
if (t < 1) {
|
||||
return -0.5*(a*Math.pow(2,10*(t-=1)) *
|
||||
Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
|
||||
}
|
||||
return a*Math.pow(2,-10*(t-=1)) *
|
||||
Math.sin( (t*d-s)*(2*Math.PI)/p )*0.5 + c + b;
|
||||
},
|
||||
|
||||
|
||||
/**
|
||||
* Backtracks slightly, then reverses direction and moves to end.
|
||||
* @method backIn
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} s Overshoot (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
backIn: function (t, b, c, d, s) {
|
||||
if (s === undefined) {
|
||||
s = 1.70158;
|
||||
}
|
||||
if (t === d) {
|
||||
t -= 0.001;
|
||||
}
|
||||
return c*(t/=d)*t*((s+1)*t - s) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Overshoots end, then reverses and comes back to end.
|
||||
* @method backOut
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} s Overshoot (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
backOut: function (t, b, c, d, s) {
|
||||
if (typeof s === 'undefined') {
|
||||
s = 1.70158;
|
||||
}
|
||||
return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Backtracks slightly, then reverses direction, overshoots end,
|
||||
* then reverses and comes back to end.
|
||||
* @method backBoth
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @param {Number} s Overshoot (optional)
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
backBoth: function (t, b, c, d, s) {
|
||||
if (typeof s === 'undefined') {
|
||||
s = 1.70158;
|
||||
}
|
||||
|
||||
if ((t /= d/2 ) < 1) {
|
||||
return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
|
||||
}
|
||||
return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Bounce off of start.
|
||||
* @method bounceIn
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
bounceIn: function (t, b, c, d) {
|
||||
return c - Y.Easing.bounceOut(d-t, 0, c, d) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Bounces off end.
|
||||
* @method bounceOut
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
bounceOut: function (t, b, c, d) {
|
||||
if ((t/=d) < (1/2.75)) {
|
||||
return c*(7.5625*t*t) + b;
|
||||
} else if (t < (2/2.75)) {
|
||||
return c*(7.5625*(t-=(1.5/2.75))*t + 0.75) + b;
|
||||
} else if (t < (2.5/2.75)) {
|
||||
return c*(7.5625*(t-=(2.25/2.75))*t + 0.9375) + b;
|
||||
}
|
||||
return c*(7.5625*(t-=(2.625/2.75))*t + 0.984375) + b;
|
||||
},
|
||||
|
||||
/**
|
||||
* Bounces off start and end.
|
||||
* @method bounceBoth
|
||||
* @param {Number} t Time value used to compute current value
|
||||
* @param {Number} b Starting value
|
||||
* @param {Number} c Delta between start and end values
|
||||
* @param {Number} d Total length of animation
|
||||
* @return {Number} The computed value for the current animation frame
|
||||
*/
|
||||
bounceBoth: function (t, b, c, d) {
|
||||
if (t < d/2) {
|
||||
return Y.Easing.bounceIn(t * 2, 0, c, d) * 0.5 + b;
|
||||
}
|
||||
return Y.Easing.bounceOut(t * 2 - d, 0, c, d) * 0.5 + c * 0.5 + b;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['anim-base']});
|
||||
9
jssource/src_files/include/javascript/yui3/build/anim/anim-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/anim/anim-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
jssource/src_files/include/javascript/yui3/build/anim/anim-node-plugin-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-node-plugin-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-node-plugin",function(B){var A=function(C){C=(C)?B.merge(C):{};C.node=C.host;A.superclass.constructor.apply(this,arguments);};A.NAME="nodefx";A.NS="fx";B.extend(A,B.Anim);B.namespace("Plugin");B.Plugin.NodeFX=A;},"3.0.0",{requires:["node-pluginhost","anim-base"]});
|
||||
33
jssource/src_files/include/javascript/yui3/build/anim/anim-node-plugin.js
vendored
Normal file
33
jssource/src_files/include/javascript/yui3/build/anim/anim-node-plugin.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-node-plugin', function(Y) {
|
||||
|
||||
/**
|
||||
* Binds an Anim instance to a Node instance
|
||||
* @module anim
|
||||
* @class Plugin.NodeFX
|
||||
* @extends Base
|
||||
* @submodule anim-node-plugin
|
||||
*/
|
||||
|
||||
var NodeFX = function(config) {
|
||||
config = (config) ? Y.merge(config) : {};
|
||||
config.node = config.host;
|
||||
NodeFX.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
NodeFX.NAME = "nodefx";
|
||||
NodeFX.NS = "fx";
|
||||
|
||||
Y.extend(NodeFX, Y.Anim);
|
||||
|
||||
Y.namespace('Plugin');
|
||||
Y.Plugin.NodeFX = NodeFX;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['node-pluginhost', 'anim-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/anim/anim-scroll-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-scroll-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-scroll",function(B){var A=Number;B.Anim.behaviors.scroll={set:function(F,G,I,J,K,E,H){var D=F._node,C=([H(K,A(I[0]),A(J[0])-A(I[0]),E),H(K,A(I[1]),A(J[1])-A(I[1]),E)]);if(C[0]){D.set("scrollLeft",C[0]);}if(C[1]){D.set("scrollTop",C[1]);}},get:function(D){var C=D._node;return[C.get("scrollLeft"),C.get("scrollTop")];}};},"3.0.0",{requires:["anim-base"]});
|
||||
45
jssource/src_files/include/javascript/yui3/build/anim/anim-scroll.js
vendored
Normal file
45
jssource/src_files/include/javascript/yui3/build/anim/anim-scroll.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-scroll', function(Y) {
|
||||
|
||||
/**
|
||||
* Adds support for the <code>scroll</code> property in <code>to</code>
|
||||
* and <code>from</code> attributes.
|
||||
* @module anim
|
||||
* @submodule anim-scroll
|
||||
*/
|
||||
|
||||
var NUM = Number;
|
||||
|
||||
//TODO: deprecate for scrollTop/Left properties?
|
||||
Y.Anim.behaviors.scroll = {
|
||||
set: function(anim, att, from, to, elapsed, duration, fn) {
|
||||
var
|
||||
node = anim._node,
|
||||
val = ([
|
||||
fn(elapsed, NUM(from[0]), NUM(to[0]) - NUM(from[0]), duration),
|
||||
fn(elapsed, NUM(from[1]), NUM(to[1]) - NUM(from[1]), duration)
|
||||
]);
|
||||
|
||||
if (val[0]) {
|
||||
node.set('scrollLeft', val[0]);
|
||||
}
|
||||
|
||||
if (val[1]) {
|
||||
node.set('scrollTop', val[1]);
|
||||
}
|
||||
},
|
||||
get: function(anim) {
|
||||
var node = anim._node;
|
||||
return [node.get('scrollLeft'), node.get('scrollTop')];
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['anim-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/anim/anim-xy-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/anim/anim-xy-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("anim-xy",function(B){var A=Number;B.Anim.behaviors.xy={set:function(F,D,I,H,C,G,E){F._node.setXY([E(C,A(I[0]),A(H[0])-A(I[0]),G),E(C,A(I[1]),A(H[1])-A(I[1]),G)]);},get:function(C){return C._node.getXY();}};},"3.0.0",{requires:["anim-base","node-screen"]});
|
||||
33
jssource/src_files/include/javascript/yui3/build/anim/anim-xy.js
vendored
Normal file
33
jssource/src_files/include/javascript/yui3/build/anim/anim-xy.js
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('anim-xy', function(Y) {
|
||||
|
||||
/**
|
||||
* Adds support for the <code>xy</code> property in <code>from</code> and
|
||||
* <code>to</code> attributes.
|
||||
* @module anim
|
||||
* @submodule anim-xy
|
||||
*/
|
||||
|
||||
var NUM = Number;
|
||||
|
||||
Y.Anim.behaviors.xy = {
|
||||
set: function(anim, att, from, to, elapsed, duration, fn) {
|
||||
anim._node.setXY([
|
||||
fn(elapsed, NUM(from[0]), NUM(to[0]) - NUM(from[0]), duration),
|
||||
fn(elapsed, NUM(from[1]), NUM(to[1]) - NUM(from[1]), duration)
|
||||
]);
|
||||
},
|
||||
get: function(anim) {
|
||||
return anim._node.getXY();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['anim-base', 'node-screen']});
|
||||
1149
jssource/src_files/include/javascript/yui3/build/anim/anim.js
vendored
Normal file
1149
jssource/src_files/include/javascript/yui3/build/anim/anim.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
jssource/src_files/include/javascript/yui3/build/async-queue/async-queue-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/async-queue/async-queue-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("async-queue",function(G){G.AsyncQueue=function(){this._init();this.add.apply(this,arguments);};var E=G.AsyncQueue,C="execute",B="shift",D="promote",H="remove",A=G.Lang.isObject,F=G.Lang.isFunction;E.defaults=G.mix({autoContinue:true,iterations:1,timeout:10,until:function(){this.iterations|=0;return this.iterations<=0;}},G.config.queueDefaults||{});G.extend(E,G.EventTarget,{_running:false,_init:function(){G.EventTarget.call(this,{emitFacade:true});this._q=[];this.defaults={};this._initEvents();},_initEvents:function(){this.publish("execute",{defaultFn:this._defExecFn,emitFacade:true});this.publish("shift",{defaultFn:this._defShiftFn,emitFacade:true});this.publish("add",{defaultFn:this._defAddFn,emitFacade:true});this.publish("promote",{defaultFn:this._defPromoteFn,emitFacade:true});this.publish("remove",{defaultFn:this._defRemoveFn,emitFacade:true});},next:function(){var I;while(this._q.length){I=this._q[0]=this._prepare(this._q[0]);if(I&&I.until()){this.fire(B,{callback:I});I=null;}else{break;}}return I||null;},_defShiftFn:function(I){if(this.indexOf(I.callback)===0){this._q.shift();}},_prepare:function(K){if(F(K)&&K._prepared){return K;}var I=G.merge(E.defaults,{context:this,args:[],_prepared:true},this.defaults,(F(K)?{fn:K}:K)),J=G.bind(function(){if(!J._running){J.iterations--;}if(F(J.fn)){J.fn.apply(J.context||G,G.Array(J.args));}},this);return G.mix(J,I);},run:function(){var J,I=true;for(J=this.next();I&&J&&!this.isRunning();J=this.next()){I=(J.timeout<0)?this._execute(J):this._schedule(J);}if(!J){this.fire("complete");}return this;},_execute:function(J){this._running=J._running=true;J.iterations--;this.fire(C,{callback:J});var I=this._running&&J.autoContinue;this._running=J._running=false;return I;},_schedule:function(I){this._running=G.later(I.timeout,this,function(){if(this._execute(I)){this.run();}});return false;},isRunning:function(){return !!this._running;},_defExecFn:function(I){I.callback();},add:function(){this.fire("add",{callbacks:G.Array(arguments,0,true)});return this;},_defAddFn:function(J){var K=this._q,I=[];G.Array.each(J.callbacks,function(L){if(A(L)){K.push(L);I.push(L);}});J.added=I;},pause:function(){if(A(this._running)){this._running.cancel();}this._running=false;return this;},stop:function(){this._q=[];return this.pause();},indexOf:function(L){var J=0,I=this._q.length,K;for(;J<I;++J){K=this._q[J];if(K===L||K.id===L){return J;}}return -1;},getCallback:function(J){var I=this.indexOf(J);return(I>-1)?this._q[I]:null;},promote:function(K){var J={callback:K},I;if(this.isRunning()){I=this.after(B,function(){this.fire(D,J);I.detach();},this);}else{this.fire(D,J);}return this;},_defPromoteFn:function(K){var I=this.indexOf(K.callback),J=(I>-1)?this._q.splice(I,1)[0]:null;K.promoted=J;if(J){this._q.unshift(J);}},remove:function(K){var J={callback:K},I;if(this.isRunning()){I=this.after(B,function(){this.fire(H,J);I.detach();},this);}else{this.fire(H,J);}return this;},_defRemoveFn:function(J){var I=this.indexOf(J.callback);J.removed=(I>-1)?this._q.splice(I,1)[0]:null;},size:function(){if(!this.isRunning()){this.next();}return this._q.length;}});},"3.0.0",{requires:["event-custom"]});
|
||||
536
jssource/src_files/include/javascript/yui3/build/async-queue/async-queue.js
vendored
Normal file
536
jssource/src_files/include/javascript/yui3/build/async-queue/async-queue.js
vendored
Normal file
@@ -0,0 +1,536 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('async-queue', function(Y) {
|
||||
|
||||
/**
|
||||
* <p>AsyncQueue allows you create a chain of function callbacks executed
|
||||
* via setTimeout (or synchronously) that are guaranteed to run in order.
|
||||
* Items in the queue can be promoted or removed. Start or resume the
|
||||
* execution chain with run(). pause() to temporarily delay execution, or
|
||||
* stop() to halt and clear the queue.</p>
|
||||
*
|
||||
* @module async-queue
|
||||
*/
|
||||
|
||||
/**
|
||||
* <p>A specialized queue class that supports scheduling callbacks to execute
|
||||
* sequentially, iteratively, even asynchronously.</p>
|
||||
*
|
||||
* <p>Callbacks can be function refs or objects with the following keys. Only
|
||||
* the <code>fn</code> key is required.</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>fn</code> -- The callback function</li>
|
||||
* <li><code>context</code> -- The execution context for the callbackFn.</li>
|
||||
* <li><code>args</code> -- Arguments to pass to callbackFn.</li>
|
||||
* <li><code>timeout</code> -- Millisecond delay before executing callbackFn.
|
||||
* (Applies to each iterative execution of callback)</li>
|
||||
* <li><code>iterations</code> -- Number of times to repeat the callback.
|
||||
* <li><code>until</code> -- Repeat the callback until this function returns
|
||||
* true. This setting trumps iterations.</li>
|
||||
* <li><code>autoContinue</code> -- Set to false to prevent the AsyncQueue from
|
||||
* executing the next callback in the Queue after
|
||||
* the callback completes.</li>
|
||||
* <li><code>id</code> -- Name that can be used to get, promote, get the
|
||||
* indexOf, or delete this callback.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @class AsyncQueue
|
||||
* @extends EventTarget
|
||||
* @constructor
|
||||
* @param callback* {Function|Object} 0..n callbacks to seed the queue
|
||||
*/
|
||||
Y.AsyncQueue = function() {
|
||||
this._init();
|
||||
this.add.apply(this, arguments);
|
||||
};
|
||||
|
||||
var Queue = Y.AsyncQueue,
|
||||
EXECUTE = 'execute',
|
||||
SHIFT = 'shift',
|
||||
PROMOTE = 'promote',
|
||||
REMOVE = 'remove',
|
||||
|
||||
isObject = Y.Lang.isObject,
|
||||
isFunction = Y.Lang.isFunction;
|
||||
|
||||
/**
|
||||
* <p>Static default values used to populate callback configuration properties.
|
||||
* Preconfigured defaults include:</p>
|
||||
*
|
||||
* <ul>
|
||||
* <li><code>autoContinue</code>: <code>true</code></li>
|
||||
* <li><code>iterations</code>: 1</li>
|
||||
* <li><code>timeout</code>: 10 (10ms between callbacks)</li>
|
||||
* <li><code>until</code>: (function to run until iterations <= 0)</li>
|
||||
* </ul>
|
||||
*
|
||||
* @property AsyncQueue.defaults
|
||||
* @type {Object}
|
||||
* @static
|
||||
*/
|
||||
Queue.defaults = Y.mix({
|
||||
autoContinue : true,
|
||||
iterations : 1,
|
||||
timeout : 10,
|
||||
until : function () {
|
||||
this.iterations |= 0;
|
||||
return this.iterations <= 0;
|
||||
}
|
||||
}, Y.config.queueDefaults || {});
|
||||
|
||||
Y.extend(Queue, Y.EventTarget, {
|
||||
/**
|
||||
* Used to indicate the queue is currently executing a callback.
|
||||
*
|
||||
* @property _running
|
||||
* @type {Boolean|Object} true for synchronous callback execution, the
|
||||
* return handle from Y.later for async callbacks.
|
||||
* Otherwise false.
|
||||
* @protected
|
||||
*/
|
||||
_running : false,
|
||||
|
||||
/**
|
||||
* Initializes the AsyncQueue instance properties and events.
|
||||
*
|
||||
* @method _init
|
||||
* @protected
|
||||
*/
|
||||
_init : function () {
|
||||
Y.EventTarget.call(this, { emitFacade: true });
|
||||
|
||||
this._q = [];
|
||||
|
||||
/**
|
||||
* Callback defaults for this instance. Static defaults that are not
|
||||
* overridden are also included.
|
||||
*
|
||||
* @property defaults
|
||||
* @type {Object}
|
||||
*/
|
||||
this.defaults = {};
|
||||
|
||||
this._initEvents();
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the instance events.
|
||||
*
|
||||
* @method _initEvents
|
||||
* @protected
|
||||
*/
|
||||
_initEvents : function () {
|
||||
/*
|
||||
this.publish({
|
||||
'execute' : { defaultFn : this._defExecFn },
|
||||
'shift' : { defaultFn : this._defShiftFn },
|
||||
'add' : { defaultFn : this._defAddFn },
|
||||
'promote' : { defaultFn : this._defPromoteFn },
|
||||
'remove' : { defaultFn : this._defRemoveFn }
|
||||
});
|
||||
*/
|
||||
this.publish('execute' , { defaultFn : this._defExecFn, emitFacade: true });
|
||||
this.publish('shift' , { defaultFn : this._defShiftFn, emitFacade: true });
|
||||
this.publish('add' , { defaultFn : this._defAddFn, emitFacade: true });
|
||||
this.publish('promote' , { defaultFn : this._defPromoteFn, emitFacade: true });
|
||||
this.publish('remove' , { defaultFn : this._defRemoveFn, emitFacade: true });
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the next callback needing execution. If a callback is
|
||||
* configured to repeat via iterations or until, it will be returned until
|
||||
* the completion criteria is met.
|
||||
*
|
||||
* When the queue is empty, null is returned.
|
||||
*
|
||||
* @method next
|
||||
* @return {Function} the callback to execute
|
||||
*/
|
||||
next : function () {
|
||||
var callback;
|
||||
|
||||
while (this._q.length) {
|
||||
callback = this._q[0] = this._prepare(this._q[0]);
|
||||
if (callback && callback.until()) {
|
||||
this.fire(SHIFT, { callback: callback });
|
||||
callback = null;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return callback || null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default functionality for the "shift" event. Shifts the
|
||||
* callback stored in the event object's <em>callback</em> property from
|
||||
* the queue if it is the first item.
|
||||
*
|
||||
* @method _defShiftFn
|
||||
* @param e {Event} The event object
|
||||
* @protected
|
||||
*/
|
||||
_defShiftFn : function (e) {
|
||||
if (this.indexOf(e.callback) === 0) {
|
||||
this._q.shift();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a wrapper function to execute the callback using the aggregated
|
||||
* configuration generated by combining the static AsyncQueue.defaults, the
|
||||
* instance defaults, and the specified callback settings.
|
||||
*
|
||||
* The wrapper function is decorated with the callback configuration as
|
||||
* properties for runtime modification.
|
||||
*
|
||||
* @method _prepare
|
||||
* @param callback {Object|Function} the raw callback
|
||||
* @return {Function} a decorated function wrapper to execute the callback
|
||||
* @protected
|
||||
*/
|
||||
_prepare: function (callback) {
|
||||
if (isFunction(callback) && callback._prepared) {
|
||||
return callback;
|
||||
}
|
||||
|
||||
var config = Y.merge(
|
||||
Queue.defaults,
|
||||
{ context : this, args: [], _prepared: true },
|
||||
this.defaults,
|
||||
(isFunction(callback) ? { fn: callback } : callback)),
|
||||
|
||||
wrapper = Y.bind(function () {
|
||||
if (!wrapper._running) {
|
||||
wrapper.iterations--;
|
||||
}
|
||||
if (isFunction(wrapper.fn)) {
|
||||
wrapper.fn.apply(wrapper.context || Y,
|
||||
Y.Array(wrapper.args));
|
||||
}
|
||||
}, this);
|
||||
|
||||
return Y.mix(wrapper, config);
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets the queue in motion. All queued callbacks will be executed in
|
||||
* order unless pause() or stop() is called or if one of the callbacks is
|
||||
* configured with autoContinue: false.
|
||||
*
|
||||
* @method run
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
run : function () {
|
||||
var callback,
|
||||
cont = true;
|
||||
|
||||
for (callback = this.next();
|
||||
cont && callback && !this.isRunning();
|
||||
callback = this.next())
|
||||
{
|
||||
cont = (callback.timeout < 0) ?
|
||||
this._execute(callback) :
|
||||
this._schedule(callback);
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
/**
|
||||
* Event fired after the last queued callback is executed.
|
||||
* @event complete
|
||||
*/
|
||||
this.fire('complete');
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Handles the execution of callbacks. Returns a boolean indicating
|
||||
* whether it is appropriate to continue running.
|
||||
*
|
||||
* @method _execute
|
||||
* @param callback {Object} the callback object to execute
|
||||
* @return {Boolean} whether the run loop should continue
|
||||
* @protected
|
||||
*/
|
||||
_execute : function (callback) {
|
||||
this._running = callback._running = true;
|
||||
|
||||
callback.iterations--;
|
||||
this.fire(EXECUTE, { callback: callback });
|
||||
|
||||
var cont = this._running && callback.autoContinue;
|
||||
|
||||
this._running = callback._running = false;
|
||||
|
||||
return cont;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schedules the execution of asynchronous callbacks.
|
||||
*
|
||||
* @method _schedule
|
||||
* @param callback {Object} the callback object to execute
|
||||
* @return {Boolean} whether the run loop should continue
|
||||
* @protected
|
||||
*/
|
||||
_schedule : function (callback) {
|
||||
this._running = Y.later(callback.timeout, this, function () {
|
||||
if (this._execute(callback)) {
|
||||
this.run();
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
* Determines if the queue is waiting for a callback to complete execution.
|
||||
*
|
||||
* @method isRunning
|
||||
* @return {Boolean} true if queue is waiting for a
|
||||
* from any initiated transactions
|
||||
*/
|
||||
isRunning : function () {
|
||||
return !!this._running;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default functionality for the "execute" event. Executes the
|
||||
* callback function
|
||||
*
|
||||
* @method _defExecFn
|
||||
* @param e {Event} the event object
|
||||
* @protected
|
||||
*/
|
||||
_defExecFn : function (e) {
|
||||
e.callback();
|
||||
},
|
||||
|
||||
/**
|
||||
* Add any number of callbacks to the end of the queue. Callbacks may be
|
||||
* provided as functions or objects.
|
||||
*
|
||||
* @method add
|
||||
* @param callback* {Function|Object} 0..n callbacks
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
add : function () {
|
||||
this.fire('add', { callbacks: Y.Array(arguments,0,true) });
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default functionality for the "add" event. Adds the callbacks
|
||||
* in the event facade to the queue. Callbacks successfully added to the
|
||||
* queue are present in the event's <code>added</code> property in the
|
||||
* after phase.
|
||||
*
|
||||
* @method _defAddFn
|
||||
* @param e {Event} the event object
|
||||
* @protected
|
||||
*/
|
||||
_defAddFn : function(e) {
|
||||
var _q = this._q,
|
||||
added = [];
|
||||
|
||||
Y.Array.each(e.callbacks, function (c) {
|
||||
if (isObject(c)) {
|
||||
_q.push(c);
|
||||
added.push(c);
|
||||
}
|
||||
});
|
||||
|
||||
e.added = added;
|
||||
},
|
||||
|
||||
/**
|
||||
* Pause the execution of the queue after the execution of the current
|
||||
* callback completes. If called from code outside of a queued callback,
|
||||
* clears the timeout for the pending callback. Paused queue can be
|
||||
* restarted with q.run()
|
||||
*
|
||||
* @method pause
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
pause: function () {
|
||||
if (isObject(this._running)) {
|
||||
this._running.cancel();
|
||||
}
|
||||
|
||||
this._running = false;
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Stop and clear the queue after the current execution of the
|
||||
* current callback completes.
|
||||
*
|
||||
* @method stop
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
stop : function () {
|
||||
this._q = [];
|
||||
|
||||
return this.pause();
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the current index of a callback. Pass in either the id or
|
||||
* callback function from getCallback.
|
||||
*
|
||||
* @method indexOf
|
||||
* @param callback {String|Function} the callback or its specified id
|
||||
* @return {Number} index of the callback or -1 if not found
|
||||
*/
|
||||
indexOf : function (callback) {
|
||||
var i = 0, len = this._q.length, c;
|
||||
|
||||
for (; i < len; ++i) {
|
||||
c = this._q[i];
|
||||
if (c === callback || c.id === callback) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
},
|
||||
|
||||
/**
|
||||
* Retrieve a callback by its id. Useful to modify the configuration
|
||||
* while the queue is running.
|
||||
*
|
||||
* @method getCallback
|
||||
* @param id {String} the id assigned to the callback
|
||||
* @return {Object} the callback object
|
||||
*/
|
||||
getCallback : function (id) {
|
||||
var i = this.indexOf(id);
|
||||
|
||||
return (i > -1) ? this._q[i] : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Promotes the named callback to the top of the queue. If a callback is
|
||||
* currently executing or looping (via until or iterations), the promotion
|
||||
* is scheduled to occur after the current callback has completed.
|
||||
*
|
||||
* @method promote
|
||||
* @param callback {String|Object} the callback object or a callback's id
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
promote : function (callback) {
|
||||
var payload = { callback : callback },e;
|
||||
|
||||
if (this.isRunning()) {
|
||||
e = this.after(SHIFT, function () {
|
||||
this.fire(PROMOTE, payload);
|
||||
e.detach();
|
||||
}, this);
|
||||
} else {
|
||||
this.fire(PROMOTE, payload);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Default functionality for the "promote" event. Promotes the
|
||||
* named callback to the head of the queue.</p>
|
||||
*
|
||||
* <p>The event object will contain a property "callback", which
|
||||
* holds the id of a callback or the callback object itself.</p>
|
||||
*
|
||||
* @method _defPromoteFn
|
||||
* @param e {Event} the custom event
|
||||
* @protected
|
||||
*/
|
||||
_defPromoteFn : function (e) {
|
||||
var i = this.indexOf(e.callback),
|
||||
promoted = (i > -1) ? this._q.splice(i,1)[0] : null;
|
||||
|
||||
e.promoted = promoted;
|
||||
|
||||
if (promoted) {
|
||||
this._q.unshift(promoted);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the callback from the queue. If the queue is active, the
|
||||
* removal is scheduled to occur after the current callback has completed.
|
||||
*
|
||||
* @method remove
|
||||
* @param callback {String|Object} the callback object or a callback's id
|
||||
* @return {AsyncQueue} the AsyncQueue instance
|
||||
* @chainable
|
||||
*/
|
||||
remove : function (callback) {
|
||||
var payload = { callback : callback },e;
|
||||
|
||||
// Can't return the removed callback because of the deferral until
|
||||
// current callback is complete
|
||||
if (this.isRunning()) {
|
||||
e = this.after(SHIFT, function () {
|
||||
this.fire(REMOVE, payload);
|
||||
e.detach();
|
||||
},this);
|
||||
} else {
|
||||
this.fire(REMOVE, payload);
|
||||
}
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Default functionality for the "remove" event. Removes the
|
||||
* callback from the queue.</p>
|
||||
*
|
||||
* <p>The event object will contain a property "callback", which
|
||||
* holds the id of a callback or the callback object itself.</p>
|
||||
*
|
||||
* @method _defRemoveFn
|
||||
* @param e {Event} the custom event
|
||||
* @protected
|
||||
*/
|
||||
_defRemoveFn : function (e) {
|
||||
var i = this.indexOf(e.callback);
|
||||
|
||||
e.removed = (i > -1) ? this._q.splice(i,1)[0] : null;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the number of callbacks in the queue.
|
||||
*
|
||||
* @method size
|
||||
* @return {Number}
|
||||
*/
|
||||
size : function () {
|
||||
// next() flushes callbacks that have met their until() criteria and
|
||||
// therefore shouldn't count since they wouldn't execute anyway.
|
||||
if (!this.isRunning()) {
|
||||
this.next();
|
||||
}
|
||||
|
||||
return this._q.length;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['event-custom']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/attribute/attribute-base-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/attribute/attribute-base-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1064
jssource/src_files/include/javascript/yui3/build/attribute/attribute-base.js
vendored
Normal file
1064
jssource/src_files/include/javascript/yui3/build/attribute/attribute-base.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
jssource/src_files/include/javascript/yui3/build/attribute/attribute-complex-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/attribute/attribute-complex-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("attribute-complex",function(B){var A=B.Object,C=".";B.Attribute.Complex=function(){};B.Attribute.Complex.prototype={_normAttrVals:function(G){var I={},H={},J,D,F,E;if(G){for(E in G){if(G.hasOwnProperty(E)){if(E.indexOf(C)!==-1){J=E.split(C);D=J.shift();F=H[D]=H[D]||[];F[F.length]={path:J,value:G[E]};}else{I[E]=G[E];}}}return{simple:I,complex:H};}else{return null;}},_getAttrInitVal:function(K,I,M){var E=(I.valueFn)?I.valueFn.call(this):I.value,D,F,H,G,N,L,J;if(!I.readOnly&&M){D=M.simple;if(D&&D.hasOwnProperty(K)){E=D[K];}F=M.complex;if(F&&F.hasOwnProperty(K)){J=F[K];for(H=0,G=J.length;H<G;++H){N=J[H].path;L=J[H].value;A.setValue(E,N,L);}}}return E;}};B.mix(B.Attribute,B.Attribute.Complex,true,null,1);},"3.0.0",{requires:["attribute-base"]});
|
||||
120
jssource/src_files/include/javascript/yui3/build/attribute/attribute-complex.js
vendored
Normal file
120
jssource/src_files/include/javascript/yui3/build/attribute/attribute-complex.js
vendored
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('attribute-complex', function(Y) {
|
||||
|
||||
/**
|
||||
* Adds support for attribute providers to handle complex attributes in the constructor
|
||||
*
|
||||
* @module attribute
|
||||
* @submodule attribute-complex
|
||||
* @for Attribute
|
||||
*/
|
||||
|
||||
var O = Y.Object,
|
||||
DOT = ".";
|
||||
|
||||
Y.Attribute.Complex = function() {};
|
||||
Y.Attribute.Complex.prototype = {
|
||||
|
||||
/**
|
||||
* Utility method to split out simple attribute name/value pairs ("x")
|
||||
* from complex attribute name/value pairs ("x.y.z"), so that complex
|
||||
* attributes can be keyed by the top level attribute name.
|
||||
*
|
||||
* @method _normAttrVals
|
||||
* @param {Object} valueHash An object with attribute name/value pairs
|
||||
*
|
||||
* @return {Object} An object literal with 2 properties - "simple" and "complex",
|
||||
* containing simple and complex attribute values respectively keyed
|
||||
* by the top level attribute name, or null, if valueHash is falsey.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
_normAttrVals : function(valueHash) {
|
||||
var vals = {},
|
||||
subvals = {},
|
||||
path,
|
||||
attr,
|
||||
v, k;
|
||||
|
||||
if (valueHash) {
|
||||
for (k in valueHash) {
|
||||
if (valueHash.hasOwnProperty(k)) {
|
||||
if (k.indexOf(DOT) !== -1) {
|
||||
path = k.split(DOT);
|
||||
attr = path.shift();
|
||||
v = subvals[attr] = subvals[attr] || [];
|
||||
v[v.length] = {
|
||||
path : path,
|
||||
value: valueHash[k]
|
||||
};
|
||||
} else {
|
||||
vals[k] = valueHash[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
return { simple:vals, complex:subvals };
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the initial value of the given attribute from
|
||||
* either the default configuration provided, or the
|
||||
* over-ridden value if it exists in the set of initValues
|
||||
* provided and the attribute is not read-only.
|
||||
*
|
||||
* @param {String} attr The name of the attribute
|
||||
* @param {Object} cfg The attribute configuration object
|
||||
* @param {Object} initValues The object with simple and complex attribute name/value pairs returned from _normAttrVals
|
||||
*
|
||||
* @return {Any} The initial value of the attribute.
|
||||
*
|
||||
* @method _getAttrInitVal
|
||||
* @private
|
||||
*/
|
||||
_getAttrInitVal : function(attr, cfg, initValues) {
|
||||
|
||||
var val = (cfg.valueFn) ? cfg.valueFn.call(this) : cfg.value,
|
||||
simple,
|
||||
complex,
|
||||
i,
|
||||
l,
|
||||
path,
|
||||
subval,
|
||||
subvals;
|
||||
|
||||
if (!cfg.readOnly && initValues) {
|
||||
|
||||
// Simple Attributes
|
||||
simple = initValues.simple;
|
||||
if (simple && simple.hasOwnProperty(attr)) {
|
||||
val = simple[attr];
|
||||
}
|
||||
|
||||
// Complex Attributes (complex values applied, after simple, incase both are set)
|
||||
complex = initValues.complex;
|
||||
if (complex && complex.hasOwnProperty(attr)) {
|
||||
subvals = complex[attr];
|
||||
for (i = 0, l = subvals.length; i < l; ++i) {
|
||||
path = subvals[i].path;
|
||||
subval = subvals[i].value;
|
||||
O.setValue(val, path, subval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return val;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.Attribute, Y.Attribute.Complex, true, null, 1);
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['attribute-base']});
|
||||
9
jssource/src_files/include/javascript/yui3/build/attribute/attribute-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/attribute/attribute-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1181
jssource/src_files/include/javascript/yui3/build/attribute/attribute.js
vendored
Normal file
1181
jssource/src_files/include/javascript/yui3/build/attribute/attribute.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
jssource/src_files/include/javascript/yui3/build/base/base-base-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/base/base-base-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("base-base",function(B){var H=B.Object,J=B.Lang,I=".",F="destroy",P="init",N="initialized",G="destroyed",D="initializer",C=Object.prototype.constructor,K="deep",Q="shallow",M="destructor",A=B.Attribute;function E(){A.call(this);var L=B.Plugin&&B.Plugin.Host;if(this._initPlugins&&L){L.call(this);}if(this._lazyAddAttrs!==false){this._lazyAddAttrs=true;}this.init.apply(this,arguments);}E._ATTR_CFG=A._ATTR_CFG.concat("cloneDefaultValue");E.NAME="base";E.ATTRS={initialized:{readOnly:true,value:false},destroyed:{readOnly:true,value:false}};E.prototype={init:function(L){this._yuievt.config.prefix=this.name=this.constructor.NAME;this.publish(P,{queuable:false,defaultFn:this._defInitFn});if(L){if(L.on){this.on(L.on);}if(L.after){this.after(L.after);}}this.fire(P,{cfg:L});return this;},destroy:function(){this.publish(F,{queuable:false,defaultFn:this._defDestroyFn});this.fire(F);return this;},_defInitFn:function(L){this._initHierarchy(L.cfg);if(this._initPlugins){this._initPlugins(L.cfg);}this._set(N,true);},_defDestroyFn:function(L){this._destroyHierarchy();if(this._destroyPlugins){this._destroyPlugins();}this._set(G,true);},_getClasses:function(){if(!this._classes){this._initHierarchyData();}return this._classes;},_getAttrCfgs:function(){if(!this._attrs){this._initHierarchyData();}return this._attrs;},_filterAttrCfgs:function(T,O){var R=null,L,S=T.ATTRS;if(S){for(L in S){if(S.hasOwnProperty(L)&&O[L]){R=R||{};R[L]=O[L];delete O[L];}}}return R;},_initHierarchyData:function(){var R=this.constructor,O=[],L=[];while(R){O[O.length]=R;if(R.ATTRS){L[L.length]=R.ATTRS;}R=R.superclass?R.superclass.constructor:null;}this._classes=O;this._attrs=this._aggregateAttrs(L);},_aggregateAttrs:function(W){var T,X,S,L,Y,O,V,R=E._ATTR_CFG,U={};if(W){for(O=W.length-1;O>=0;--O){X=W[O];for(T in X){if(X.hasOwnProperty(T)){S=B.mix({},X[T],true,R);L=S.value;V=S.cloneDefaultValue;if(L){if((V===undefined&&(C===L.constructor||J.isArray(L)))||V===K||V===true){S.value=B.clone(L);}else{if(V===Q){S.value=B.merge(L);}}}Y=null;if(T.indexOf(I)!==-1){Y=T.split(I);T=Y.shift();}if(Y&&U[T]&&U[T].value){H.setValue(U[T].value,Y,L);}else{if(!Y){if(!U[T]){U[T]=S;}else{B.mix(U[T],S,true,R);}}}}}}}return U;},_initHierarchy:function(U){var R=this._lazyAddAttrs,V,W,X,S,O,T=this._getClasses(),L=this._getAttrCfgs();for(X=T.length-1;X>=0;X--){V=T[X];W=V.prototype;if(V._yuibuild&&V._yuibuild.exts&&!V._yuibuild.dynamic){for(S=0,O=V._yuibuild.exts.length;S<O;S++){V._yuibuild.exts[S].apply(this,arguments);}}this.addAttrs(this._filterAttrCfgs(V,L),U,R);if(W.hasOwnProperty(D)){W.initializer.apply(this,arguments);}}},_destroyHierarchy:function(){var T,O,S,L,R=this._getClasses();for(S=0,L=R.length;S<L;S++){T=R[S];O=T.prototype;if(O.hasOwnProperty(M)){O.destructor.apply(this,arguments);}}},toString:function(){return this.constructor.NAME+"["+B.stamp(this)+"]";}};B.mix(E,A,false,null,1);E.prototype.constructor=E;B.Base=E;E.prototype.constructor=E;},"3.0.0",{requires:["attribute-base"]});
|
||||
531
jssource/src_files/include/javascript/yui3/build/base/base-base.js
vendored
Normal file
531
jssource/src_files/include/javascript/yui3/build/base/base-base.js
vendored
Normal file
@@ -0,0 +1,531 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('base-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The base module provides the Base class, which objects requiring attribute and custom event support can extend.
|
||||
* The module also provides two ways to reuse code - An augmentable Plugin.Host interface which provides plugin support
|
||||
* (which is augmented to the Base class) and Base.build which provides a way to
|
||||
* build custom classes using extensions.
|
||||
*
|
||||
* @module base
|
||||
*/
|
||||
|
||||
/**
|
||||
* The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host,
|
||||
* and without the extension support provided by Base.build.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-base
|
||||
*/
|
||||
var O = Y.Object,
|
||||
L = Y.Lang,
|
||||
DOT = ".",
|
||||
DESTROY = "destroy",
|
||||
INIT = "init",
|
||||
INITIALIZED = "initialized",
|
||||
DESTROYED = "destroyed",
|
||||
INITIALIZER = "initializer",
|
||||
OBJECT_CONSTRUCTOR = Object.prototype.constructor,
|
||||
DEEP = "deep",
|
||||
SHALLOW = "shallow",
|
||||
DESTRUCTOR = "destructor",
|
||||
|
||||
Attribute = Y.Attribute;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A base class which objects requiring attributes and custom event support can
|
||||
* extend. Base also handles the chaining of initializer and destructor methods across
|
||||
* the hierarchy as part of object construction and destruction. Additionally, attributes configured
|
||||
* through the static <a href="#property_Base.ATTRS">ATTRS</a> property for each class
|
||||
* in the hierarchy will be initialized by Base.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The static <a href="#property_Base.NAME">NAME</a> property of each class extending
|
||||
* from Base will be used as the identifier for the class, and is used by Base to prefix
|
||||
* all events fired by instances of that class.
|
||||
* </p>
|
||||
* @class Base
|
||||
* @constructor
|
||||
* @uses Attribute
|
||||
* @uses Plugin.Host
|
||||
*
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
*/
|
||||
function Base() {
|
||||
|
||||
Attribute.call(this);
|
||||
|
||||
// If Plugin.Host has been augmented [ through base-pluginhost ], setup it's
|
||||
// initial state, but don't initialize Plugins yet. That's done after initialization.
|
||||
var PluginHost = Y.Plugin && Y.Plugin.Host;
|
||||
if (this._initPlugins && PluginHost) {
|
||||
PluginHost.call(this);
|
||||
}
|
||||
|
||||
if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }
|
||||
|
||||
this.init.apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of properties which can be configured for
|
||||
* each attribute (e.g. setter, getter, writeOnce, readOnly etc.)
|
||||
*
|
||||
* @property Base._ATTR_CFG
|
||||
* @type Array
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
Base._ATTR_CFG = Attribute._ATTR_CFG.concat("cloneDefaultValue");
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The string to be used to identify instances of
|
||||
* this class, for example in prefixing events.
|
||||
* </p>
|
||||
* <p>
|
||||
* Classes extending Base, should define their own
|
||||
* static NAME property, which should be camelCase by
|
||||
* convention (e.g. MyClass.NAME = "myClass";).
|
||||
* </p>
|
||||
* @property Base.NAME
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
Base.NAME = "base";
|
||||
|
||||
/**
|
||||
* The default set of attributes which will be available for instances of this class, and
|
||||
* their configuration. In addition to the configuration properties listed by
|
||||
* Attribute's <a href="Attribute.html#method_addAttr">addAttr</a> method, the attribute
|
||||
* can also be configured with a "cloneDefaultValue" property, which defines how the statically
|
||||
* defined value field should be protected ("shallow", "deep" and false are supported values).
|
||||
*
|
||||
* By default if the value is an object literal or an array it will be "shallow" cloned, to
|
||||
* protect the default value.
|
||||
*
|
||||
* @property Base.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
Base.ATTRS = {
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the init lifecycle phase.
|
||||
*
|
||||
* @attribute initialized
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
initialized: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
},
|
||||
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the destroy lifecycle phase.
|
||||
*
|
||||
* @attribute destroyed
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
destroyed: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
}
|
||||
};
|
||||
|
||||
Base.prototype = {
|
||||
|
||||
/**
|
||||
* Init lifecycle method, invoked during construction.
|
||||
* Fires the init event prior to setting up attributes and
|
||||
* invoking initializers for the class hierarchy.
|
||||
*
|
||||
* @method init
|
||||
* @final
|
||||
* @chainable
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
* @return {Base} A reference to this object
|
||||
*/
|
||||
init: function(config) {
|
||||
|
||||
/**
|
||||
* The string used to identify the class of this object.
|
||||
*
|
||||
* @deprecated Use this.constructor.NAME
|
||||
* @property name
|
||||
* @type String
|
||||
*/
|
||||
this._yuievt.config.prefix = this.name = this.constructor.NAME;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the init phase, fired prior to initialization.
|
||||
* Invoking the preventDefault() method on the event object provided
|
||||
* to subscribers will prevent initialization from occuring.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" momemt of this event, will be notified
|
||||
* after initialization of the object is complete (and therefore
|
||||
* cannot prevent initialization).
|
||||
* </p>
|
||||
*
|
||||
* @event init
|
||||
* @preventable _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
*/
|
||||
this.publish(INIT, {
|
||||
queuable:false,
|
||||
defaultFn:this._defInitFn
|
||||
});
|
||||
|
||||
if (config) {
|
||||
if (config.on) {
|
||||
this.on(config.on);
|
||||
}
|
||||
if (config.after) {
|
||||
this.after(config.after);
|
||||
}
|
||||
}
|
||||
|
||||
this.fire(INIT, {cfg: config});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Destroy lifecycle method. Fires the destroy
|
||||
* event, prior to invoking destructors for the
|
||||
* class hierarchy.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the destroy
|
||||
* event can invoke preventDefault on the event object, to prevent destruction
|
||||
* from proceeding.
|
||||
* </p>
|
||||
* @method destroy
|
||||
* @return {Base} A reference to this object
|
||||
* @final
|
||||
* @chainable
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the destroy phase,
|
||||
* fired prior to destruction. Invoking the preventDefault
|
||||
* method on the event object provided to subscribers will
|
||||
* prevent destruction from proceeding.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" moment of this event, will be notified
|
||||
* after destruction is complete (and as a result cannot prevent
|
||||
* destruction).
|
||||
* </p>
|
||||
* @event destroy
|
||||
* @preventable _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
*/
|
||||
this.publish(DESTROY, {
|
||||
queuable:false,
|
||||
defaultFn: this._defDestroyFn
|
||||
});
|
||||
this.fire(DESTROY);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default init event handler
|
||||
*
|
||||
* @method _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
* @protected
|
||||
*/
|
||||
_defInitFn : function(e) {
|
||||
this._initHierarchy(e.cfg);
|
||||
if (this._initPlugins) {
|
||||
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
|
||||
this._initPlugins(e.cfg);
|
||||
}
|
||||
this._set(INITIALIZED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default destroy event handler
|
||||
*
|
||||
* @method _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
* @protected
|
||||
*/
|
||||
_defDestroyFn : function(e) {
|
||||
this._destroyHierarchy();
|
||||
if (this._destroyPlugins) {
|
||||
this._destroyPlugins();
|
||||
}
|
||||
this._set(DESTROYED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the class hierarchy for this object, with Base being the last class in the array.
|
||||
*
|
||||
* @method _getClasses
|
||||
* @protected
|
||||
* @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object.
|
||||
* This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the
|
||||
* cached value.
|
||||
*/
|
||||
_getClasses : function() {
|
||||
if (!this._classes) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._classes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an aggregated set of attribute configurations, by traversing the class hierarchy.
|
||||
*
|
||||
* @method _getAttrCfgs
|
||||
* @protected
|
||||
* @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy
|
||||
* This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return
|
||||
* the cached value.
|
||||
*/
|
||||
_getAttrCfgs : function() {
|
||||
if (!this._attrs) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._attrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used when processing ATTRS across the class hierarchy during
|
||||
* initialization. Returns a disposable object with the attributes defined for
|
||||
* the provided class, extracted from the set of all attributes passed in .
|
||||
*
|
||||
* @method _filterAttrCfs
|
||||
* @private
|
||||
*
|
||||
* @param {Function} clazz The class for which the desired attributes are required.
|
||||
* @param {Object} allCfgs The set of all attribute configurations for this instance.
|
||||
* Attributes will be removed from this set, if they belong to the filtered class, so
|
||||
* that by the time all classes are processed, allCfgs will be empty.
|
||||
*
|
||||
* @return {Object} The set of attributes belonging to the class passed in, in the form
|
||||
* of an object with attribute name/configuration pairs.
|
||||
*/
|
||||
_filterAttrCfgs : function(clazz, allCfgs) {
|
||||
var cfgs = null, attr, attrs = clazz.ATTRS;
|
||||
|
||||
if (attrs) {
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr) && allCfgs[attr]) {
|
||||
cfgs = cfgs || {};
|
||||
cfgs[attr] = allCfgs[attr];
|
||||
delete allCfgs[attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfgs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used by _getClasses and _getAttrCfgs, which determines both
|
||||
* the array of classes and aggregate set of attribute configurations
|
||||
* across the class hierarchy for the instance.
|
||||
*
|
||||
* @method _initHierarchyData
|
||||
* @private
|
||||
*/
|
||||
_initHierarchyData : function() {
|
||||
var c = this.constructor,
|
||||
classes = [],
|
||||
attrs = [];
|
||||
|
||||
while (c) {
|
||||
// Add to classes
|
||||
classes[classes.length] = c;
|
||||
|
||||
// Add to attributes
|
||||
if (c.ATTRS) {
|
||||
attrs[attrs.length] = c.ATTRS;
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
this._classes = classes;
|
||||
this._attrs = this._aggregateAttrs(attrs);
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method, used by _initHierarchyData to aggregate
|
||||
* attribute configuration across the instances class hierarchy.
|
||||
*
|
||||
* The method will potect the attribute configuration value to protect the statically defined
|
||||
* default value in ATTRS if required (if the value is an object literal, array or the
|
||||
* attribute configuration has cloneDefaultValue set to shallow or deep).
|
||||
*
|
||||
* @method _aggregateAttrs
|
||||
* @private
|
||||
* @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy
|
||||
* (subclass first, Base last)
|
||||
* @return {Object} The aggregate set of ATTRS definitions for the instance
|
||||
*/
|
||||
_aggregateAttrs : function(allAttrs) {
|
||||
var attr,
|
||||
attrs,
|
||||
cfg,
|
||||
val,
|
||||
path,
|
||||
i,
|
||||
clone,
|
||||
cfgProps = Base._ATTR_CFG,
|
||||
aggAttrs = {};
|
||||
|
||||
if (allAttrs) {
|
||||
for (i = allAttrs.length-1; i >= 0; --i) {
|
||||
attrs = allAttrs[i];
|
||||
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr)) {
|
||||
|
||||
// Protect config passed in
|
||||
cfg = Y.mix({}, attrs[attr], true, cfgProps);
|
||||
|
||||
val = cfg.value;
|
||||
clone = cfg.cloneDefaultValue;
|
||||
|
||||
if (val) {
|
||||
if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {
|
||||
cfg.value = Y.clone(val);
|
||||
} else if (clone === SHALLOW) {
|
||||
cfg.value = Y.merge(val);
|
||||
}
|
||||
// else if (clone === false), don't clone the static default value.
|
||||
// It's intended to be used by reference.
|
||||
}
|
||||
|
||||
path = null;
|
||||
if (attr.indexOf(DOT) !== -1) {
|
||||
path = attr.split(DOT);
|
||||
attr = path.shift();
|
||||
}
|
||||
|
||||
if (path && aggAttrs[attr] && aggAttrs[attr].value) {
|
||||
O.setValue(aggAttrs[attr].value, path, val);
|
||||
} else if (!path){
|
||||
if (!aggAttrs[attr]) {
|
||||
aggAttrs[attr] = cfg;
|
||||
} else {
|
||||
Y.mix(aggAttrs[attr], cfg, true, cfgProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aggAttrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the class hierarchy for the instance, which includes
|
||||
* initializing attributes for each class defined in the class's
|
||||
* static <a href="#property_Base.ATTRS">ATTRS</a> property and
|
||||
* invoking the initializer method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _initHierarchy
|
||||
* @param {Object} userVals Object with configuration property name/value pairs
|
||||
* @private
|
||||
*/
|
||||
_initHierarchy : function(userVals) {
|
||||
var lazy = this._lazyAddAttrs,
|
||||
constr,
|
||||
constrProto,
|
||||
ci,
|
||||
ei,
|
||||
el,
|
||||
classes = this._getClasses(),
|
||||
attrCfgs = this._getAttrCfgs();
|
||||
|
||||
for (ci = classes.length-1; ci >= 0; ci--) {
|
||||
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
|
||||
if (constr._yuibuild && constr._yuibuild.exts && !constr._yuibuild.dynamic) {
|
||||
for (ei = 0, el = constr._yuibuild.exts.length; ei < el; ei++) {
|
||||
constr._yuibuild.exts[ei].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);
|
||||
|
||||
if (constrProto.hasOwnProperty(INITIALIZER)) {
|
||||
constrProto.initializer.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys the class hierarchy for this instance by invoking
|
||||
* the descructor method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _destroyHierarchy
|
||||
* @private
|
||||
*/
|
||||
_destroyHierarchy : function() {
|
||||
var constr,
|
||||
constrProto,
|
||||
ci, cl,
|
||||
classes = this._getClasses();
|
||||
|
||||
for (ci = 0, cl = classes.length; ci < cl; ci++) {
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
if (constrProto.hasOwnProperty(DESTRUCTOR)) {
|
||||
constrProto.destructor.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default toString implementation. Provides the constructor NAME
|
||||
* and the instance ID.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String} String representation for this object
|
||||
*/
|
||||
toString: function() {
|
||||
return this.constructor.NAME + "[" + Y.stamp(this) + "]";
|
||||
}
|
||||
};
|
||||
|
||||
// Straightup augment, no wrapper functions
|
||||
Y.mix(Base, Attribute, false, null, 1);
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
Y.Base = Base;
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['attribute-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/base/base-build-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/base/base-build-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("base-build",function(C){var B=C.Base,A=C.Lang;B._buildCfg={aggregates:["ATTRS","_PLUG","_UNPLUG"]};B.build=function(D,I,M,L){var O=B.build,E=O._getClass(I,L),K=O._getAggregates(I,L),G=E._yuibuild.dynamic,J,H,F,N;if(G){if(K){for(J=0,H=K.length;J<H;++J){F=K[J];if(I.hasOwnProperty(F)){E[F]=A.isArray(I[F])?[]:{};}}C.aggregate(E,I,true,K);}}for(J=0,H=M.length;J<H;J++){N=M[J];if(K){C.aggregate(E,N,true,K);}C.mix(E,N,true,null,1);E._yuibuild.exts.push(N);}E.prototype.hasImpl=O._hasImpl;if(G){E.NAME=D;E.prototype.constructor=E;}return E;};C.mix(B.build,{_template:function(D){function E(){E.superclass.constructor.apply(this,arguments);var H=E._yuibuild.exts,F=H.length,G;for(G=0;G<F;G++){H[G].apply(this,arguments);}return this;}C.extend(E,D);return E;},_hasImpl:function(G){var J=this._getClasses();for(var I=0,E=J.length;I<E;I++){var D=J[I];if(D._yuibuild){var H=D._yuibuild.exts,K=H.length,F;for(F=0;F<K;F++){if(H[F]===G){return true;}}}}return false;},_getClass:function(D,E){var F=(E&&false===E.dynamic)?false:true,G=(F)?B.build._template(D):D;G._yuibuild={id:null,exts:[],dynamic:F};return G;},_getAggregates:function(D,E){var F=[],H=(E&&E.aggregates),I=D,G;while(I&&I.prototype){G=I._buildCfg&&I._buildCfg.aggregates;if(G){F=F.concat(G);}I=I.superclass?I.superclass.constructor:null;}if(H){F=F.concat(H);}return F;}});},"3.0.0",{requires:["base-base"]});
|
||||
201
jssource/src_files/include/javascript/yui3/build/base/base-build.js
vendored
Normal file
201
jssource/src_files/include/javascript/yui3/build/base/base-build.js
vendored
Normal file
@@ -0,0 +1,201 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('base-build', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-build submodule provides Base.build functionality, which
|
||||
* can be used to create custom classes, by aggregating extensions onto
|
||||
* a main class.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-build
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
L = Y.Lang;
|
||||
|
||||
/**
|
||||
* The build configuration for the Base class.
|
||||
*
|
||||
* Defines the static fields which need to be aggregated
|
||||
* when the Base class is used as the main class passed to
|
||||
* the <a href="#method_Base.build">Base.build</a> method.
|
||||
*
|
||||
* @property Base._buildCfg
|
||||
* @type Object
|
||||
* @static
|
||||
* @final
|
||||
* @private
|
||||
*/
|
||||
Base._buildCfg = {
|
||||
aggregates : ["ATTRS", "_PLUG", "_UNPLUG"]
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Builds a custom constructor function (class) from the
|
||||
* main function, and array of extension functions (classes)
|
||||
* provided. The NAME field for the constructor function is
|
||||
* defined by the first argument passed in.
|
||||
* </p>
|
||||
* <p>
|
||||
* The cfg object supports the following properties
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>dynamic <boolean></dt>
|
||||
* <dd>
|
||||
* <p>If true (default), a completely new class
|
||||
* is created which extends the main class, and acts as the
|
||||
* host on which the extension classes are augmented.</p>
|
||||
* <p>If false, the extensions classes are augmented directly to
|
||||
* the main class, modifying the main class' prototype.</p>
|
||||
* </dd>
|
||||
* <dt>aggregates <String[]></dt>
|
||||
* <dd>An array of static property names, which will get aggregated
|
||||
* on to the built class, in addition to the default properties build
|
||||
* will always aggregate as defined by the main class' static _buildCfg
|
||||
* property.
|
||||
* </dd>
|
||||
* </dl>
|
||||
*
|
||||
* @method Base.build
|
||||
* @static
|
||||
* @param {Function} name The name of the new class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The main class on which to base the built class
|
||||
* @param {Function[]} extensions The set of extension classes which will be
|
||||
* augmented/aggregated to the built class.
|
||||
* @param {Object} cfg Optional. Build configuration for the class (see description).
|
||||
* @return {Function} A custom class, created from the provided main and extension classes
|
||||
*/
|
||||
Base.build = function(name, main, extensions, cfg) {
|
||||
|
||||
var build = Base.build,
|
||||
builtClass = build._getClass(main, cfg),
|
||||
aggregates = build._getAggregates(main, cfg),
|
||||
dynamic = builtClass._yuibuild.dynamic,
|
||||
i, l, val, extClass;
|
||||
|
||||
// Shallow isolate aggregates
|
||||
if (dynamic) {
|
||||
if (aggregates) {
|
||||
for (i = 0, l = aggregates.length; i < l; ++i) {
|
||||
val = aggregates[i];
|
||||
if (main.hasOwnProperty(val)) {
|
||||
builtClass[val] = L.isArray(main[val]) ? [] : {};
|
||||
}
|
||||
}
|
||||
Y.aggregate(builtClass, main, true, aggregates);
|
||||
}
|
||||
}
|
||||
|
||||
// Augment/Aggregate
|
||||
for (i = 0, l = extensions.length; i < l; i++) {
|
||||
extClass = extensions[i];
|
||||
|
||||
if (aggregates) {
|
||||
Y.aggregate(builtClass, extClass, true, aggregates);
|
||||
}
|
||||
|
||||
// Old augment
|
||||
Y.mix(builtClass, extClass, true, null, 1);
|
||||
|
||||
builtClass._yuibuild.exts.push(extClass);
|
||||
}
|
||||
|
||||
builtClass.prototype.hasImpl = build._hasImpl;
|
||||
|
||||
if (dynamic) {
|
||||
builtClass.NAME = name;
|
||||
builtClass.prototype.constructor = builtClass;
|
||||
}
|
||||
|
||||
return builtClass;
|
||||
};
|
||||
|
||||
Y.mix(Base.build, {
|
||||
|
||||
_template: function(main) {
|
||||
|
||||
function BuiltClass() {
|
||||
|
||||
BuiltClass.superclass.constructor.apply(this, arguments);
|
||||
|
||||
var f = BuiltClass._yuibuild.exts,
|
||||
l = f.length,
|
||||
i;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
f[i].apply(this, arguments);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
Y.extend(BuiltClass, main);
|
||||
|
||||
return BuiltClass;
|
||||
},
|
||||
|
||||
_hasImpl : function(extClass) {
|
||||
var classes = this._getClasses();
|
||||
for (var i = 0, l = classes.length; i < l; i++) {
|
||||
var cls = classes[i];
|
||||
|
||||
if (cls._yuibuild) {
|
||||
var exts = cls._yuibuild.exts,
|
||||
ll = exts.length,
|
||||
j;
|
||||
|
||||
for (j = 0; j < ll; j++) {
|
||||
if (exts[j] === extClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_getClass : function(main, cfg) {
|
||||
|
||||
var dynamic = (cfg && false === cfg.dynamic) ? false : true,
|
||||
builtClass = (dynamic) ? Base.build._template(main) : main;
|
||||
|
||||
builtClass._yuibuild = {
|
||||
id: null,
|
||||
exts : [],
|
||||
dynamic : dynamic
|
||||
};
|
||||
|
||||
return builtClass;
|
||||
},
|
||||
|
||||
_getAggregates : function(main, cfg) {
|
||||
var aggr = [],
|
||||
cfgAggr = (cfg && cfg.aggregates),
|
||||
c = main,
|
||||
classAggr;
|
||||
|
||||
while (c && c.prototype) {
|
||||
classAggr = c._buildCfg && c._buildCfg.aggregates;
|
||||
if (classAggr) {
|
||||
aggr = aggr.concat(classAggr);
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
if (cfgAggr) {
|
||||
aggr = aggr.concat(cfgAggr);
|
||||
}
|
||||
|
||||
return aggr;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/base/base-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/base/base-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("base-base",function(B){var H=B.Object,J=B.Lang,I=".",F="destroy",P="init",N="initialized",G="destroyed",D="initializer",C=Object.prototype.constructor,K="deep",Q="shallow",M="destructor",A=B.Attribute;function E(){A.call(this);var L=B.Plugin&&B.Plugin.Host;if(this._initPlugins&&L){L.call(this);}if(this._lazyAddAttrs!==false){this._lazyAddAttrs=true;}this.init.apply(this,arguments);}E._ATTR_CFG=A._ATTR_CFG.concat("cloneDefaultValue");E.NAME="base";E.ATTRS={initialized:{readOnly:true,value:false},destroyed:{readOnly:true,value:false}};E.prototype={init:function(L){this._yuievt.config.prefix=this.name=this.constructor.NAME;this.publish(P,{queuable:false,defaultFn:this._defInitFn});if(L){if(L.on){this.on(L.on);}if(L.after){this.after(L.after);}}this.fire(P,{cfg:L});return this;},destroy:function(){this.publish(F,{queuable:false,defaultFn:this._defDestroyFn});this.fire(F);return this;},_defInitFn:function(L){this._initHierarchy(L.cfg);if(this._initPlugins){this._initPlugins(L.cfg);}this._set(N,true);},_defDestroyFn:function(L){this._destroyHierarchy();if(this._destroyPlugins){this._destroyPlugins();}this._set(G,true);},_getClasses:function(){if(!this._classes){this._initHierarchyData();}return this._classes;},_getAttrCfgs:function(){if(!this._attrs){this._initHierarchyData();}return this._attrs;},_filterAttrCfgs:function(T,O){var R=null,L,S=T.ATTRS;if(S){for(L in S){if(S.hasOwnProperty(L)&&O[L]){R=R||{};R[L]=O[L];delete O[L];}}}return R;},_initHierarchyData:function(){var R=this.constructor,O=[],L=[];while(R){O[O.length]=R;if(R.ATTRS){L[L.length]=R.ATTRS;}R=R.superclass?R.superclass.constructor:null;}this._classes=O;this._attrs=this._aggregateAttrs(L);},_aggregateAttrs:function(W){var T,X,S,L,Y,O,V,R=E._ATTR_CFG,U={};if(W){for(O=W.length-1;O>=0;--O){X=W[O];for(T in X){if(X.hasOwnProperty(T)){S=B.mix({},X[T],true,R);L=S.value;V=S.cloneDefaultValue;if(L){if((V===undefined&&(C===L.constructor||J.isArray(L)))||V===K||V===true){S.value=B.clone(L);}else{if(V===Q){S.value=B.merge(L);}}}Y=null;if(T.indexOf(I)!==-1){Y=T.split(I);T=Y.shift();}if(Y&&U[T]&&U[T].value){H.setValue(U[T].value,Y,L);}else{if(!Y){if(!U[T]){U[T]=S;}else{B.mix(U[T],S,true,R);}}}}}}}return U;},_initHierarchy:function(U){var R=this._lazyAddAttrs,V,W,X,S,O,T=this._getClasses(),L=this._getAttrCfgs();for(X=T.length-1;X>=0;X--){V=T[X];W=V.prototype;if(V._yuibuild&&V._yuibuild.exts&&!V._yuibuild.dynamic){for(S=0,O=V._yuibuild.exts.length;S<O;S++){V._yuibuild.exts[S].apply(this,arguments);}}this.addAttrs(this._filterAttrCfgs(V,L),U,R);if(W.hasOwnProperty(D)){W.initializer.apply(this,arguments);}}},_destroyHierarchy:function(){var T,O,S,L,R=this._getClasses();for(S=0,L=R.length;S<L;S++){T=R[S];O=T.prototype;if(O.hasOwnProperty(M)){O.destructor.apply(this,arguments);}}},toString:function(){return this.constructor.NAME+"["+B.stamp(this)+"]";}};B.mix(E,A,false,null,1);E.prototype.constructor=E;B.Base=E;E.prototype.constructor=E;},"3.0.0",{requires:["attribute-base"]});YUI.add("base-pluginhost",function(C){var A=C.Base,B=C.Plugin.Host;C.mix(A,B,false,null,1);A.plug=B.plug;A.unplug=B.unplug;},"3.0.0",{requires:["base-base","pluginhost"]});YUI.add("base-build",function(C){var B=C.Base,A=C.Lang;B._buildCfg={aggregates:["ATTRS","_PLUG","_UNPLUG"]};B.build=function(D,I,M,L){var O=B.build,E=O._getClass(I,L),K=O._getAggregates(I,L),G=E._yuibuild.dynamic,J,H,F,N;if(G){if(K){for(J=0,H=K.length;J<H;++J){F=K[J];if(I.hasOwnProperty(F)){E[F]=A.isArray(I[F])?[]:{};}}C.aggregate(E,I,true,K);}}for(J=0,H=M.length;J<H;J++){N=M[J];if(K){C.aggregate(E,N,true,K);}C.mix(E,N,true,null,1);E._yuibuild.exts.push(N);}E.prototype.hasImpl=O._hasImpl;if(G){E.NAME=D;E.prototype.constructor=E;}return E;};C.mix(B.build,{_template:function(D){function E(){E.superclass.constructor.apply(this,arguments);var H=E._yuibuild.exts,F=H.length,G;for(G=0;G<F;G++){H[G].apply(this,arguments);}return this;}C.extend(E,D);return E;},_hasImpl:function(G){var J=this._getClasses();for(var I=0,E=J.length;I<E;I++){var D=J[I];if(D._yuibuild){var H=D._yuibuild.exts,K=H.length,F;for(F=0;F<K;F++){if(H[F]===G){return true;}}}}return false;},_getClass:function(D,E){var F=(E&&false===E.dynamic)?false:true,G=(F)?B.build._template(D):D;G._yuibuild={id:null,exts:[],dynamic:F};return G;},_getAggregates:function(D,E){var F=[],H=(E&&E.aggregates),I=D,G;while(I&&I.prototype){G=I._buildCfg&&I._buildCfg.aggregates;if(G){F=F.concat(G);}I=I.superclass?I.superclass.constructor:null;}if(H){F=F.concat(H);}return F;}});},"3.0.0",{requires:["base-base"]});YUI.add("base",function(A){},"3.0.0",{use:["base-base","base-pluginhost","base-build"]});
|
||||
8
jssource/src_files/include/javascript/yui3/build/base/base-pluginhost-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/base/base-pluginhost-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("base-pluginhost",function(C){var A=C.Base,B=C.Plugin.Host;C.mix(A,B,false,null,1);A.plug=B.plug;A.unplug=B.unplug;},"3.0.0",{requires:["base-base","pluginhost"]});
|
||||
43
jssource/src_files/include/javascript/yui3/build/base/base-pluginhost.js
vendored
Normal file
43
jssource/src_files/include/javascript/yui3/build/base/base-pluginhost.js
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('base-pluginhost', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-pluginhost submodule adds Plugin support to Base, by augmenting Base with
|
||||
* Plugin.Host and setting up static (class level) Base.plug and Base.unplug methods.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-pluginhost
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
PluginHost = Y.Plugin.Host;
|
||||
|
||||
Y.mix(Base, PluginHost, false, null, 1);
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.plug">Plugin.Host.plug</a>. See aliased
|
||||
* method for argument and return value details.
|
||||
*
|
||||
* @method Base.plug
|
||||
* @static
|
||||
*/
|
||||
Base.plug = PluginHost.plug;
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.unplug">Plugin.Host.unplug</a>. See the
|
||||
* aliased method for argument and return value details.
|
||||
*
|
||||
* @method Base.unplug
|
||||
* @static
|
||||
*/
|
||||
Base.unplug = PluginHost.unplug;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base-base', 'pluginhost']});
|
||||
765
jssource/src_files/include/javascript/yui3/build/base/base.js
vendored
Normal file
765
jssource/src_files/include/javascript/yui3/build/base/base.js
vendored
Normal file
@@ -0,0 +1,765 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('base-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The base module provides the Base class, which objects requiring attribute and custom event support can extend.
|
||||
* The module also provides two ways to reuse code - An augmentable Plugin.Host interface which provides plugin support
|
||||
* (which is augmented to the Base class) and Base.build which provides a way to
|
||||
* build custom classes using extensions.
|
||||
*
|
||||
* @module base
|
||||
*/
|
||||
|
||||
/**
|
||||
* The base-base submodule provides the Base class without the Plugin support, provided by Plugin.Host,
|
||||
* and without the extension support provided by Base.build.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-base
|
||||
*/
|
||||
var O = Y.Object,
|
||||
L = Y.Lang,
|
||||
DOT = ".",
|
||||
DESTROY = "destroy",
|
||||
INIT = "init",
|
||||
INITIALIZED = "initialized",
|
||||
DESTROYED = "destroyed",
|
||||
INITIALIZER = "initializer",
|
||||
OBJECT_CONSTRUCTOR = Object.prototype.constructor,
|
||||
DEEP = "deep",
|
||||
SHALLOW = "shallow",
|
||||
DESTRUCTOR = "destructor",
|
||||
|
||||
Attribute = Y.Attribute;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* A base class which objects requiring attributes and custom event support can
|
||||
* extend. Base also handles the chaining of initializer and destructor methods across
|
||||
* the hierarchy as part of object construction and destruction. Additionally, attributes configured
|
||||
* through the static <a href="#property_Base.ATTRS">ATTRS</a> property for each class
|
||||
* in the hierarchy will be initialized by Base.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The static <a href="#property_Base.NAME">NAME</a> property of each class extending
|
||||
* from Base will be used as the identifier for the class, and is used by Base to prefix
|
||||
* all events fired by instances of that class.
|
||||
* </p>
|
||||
* @class Base
|
||||
* @constructor
|
||||
* @uses Attribute
|
||||
* @uses Plugin.Host
|
||||
*
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
*/
|
||||
function Base() {
|
||||
|
||||
Attribute.call(this);
|
||||
|
||||
// If Plugin.Host has been augmented [ through base-pluginhost ], setup it's
|
||||
// initial state, but don't initialize Plugins yet. That's done after initialization.
|
||||
var PluginHost = Y.Plugin && Y.Plugin.Host;
|
||||
if (this._initPlugins && PluginHost) {
|
||||
PluginHost.call(this);
|
||||
}
|
||||
|
||||
if (this._lazyAddAttrs !== false) { this._lazyAddAttrs = true; }
|
||||
|
||||
this.init.apply(this, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* The list of properties which can be configured for
|
||||
* each attribute (e.g. setter, getter, writeOnce, readOnly etc.)
|
||||
*
|
||||
* @property Base._ATTR_CFG
|
||||
* @type Array
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
Base._ATTR_CFG = Attribute._ATTR_CFG.concat("cloneDefaultValue");
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* The string to be used to identify instances of
|
||||
* this class, for example in prefixing events.
|
||||
* </p>
|
||||
* <p>
|
||||
* Classes extending Base, should define their own
|
||||
* static NAME property, which should be camelCase by
|
||||
* convention (e.g. MyClass.NAME = "myClass";).
|
||||
* </p>
|
||||
* @property Base.NAME
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
Base.NAME = "base";
|
||||
|
||||
/**
|
||||
* The default set of attributes which will be available for instances of this class, and
|
||||
* their configuration. In addition to the configuration properties listed by
|
||||
* Attribute's <a href="Attribute.html#method_addAttr">addAttr</a> method, the attribute
|
||||
* can also be configured with a "cloneDefaultValue" property, which defines how the statically
|
||||
* defined value field should be protected ("shallow", "deep" and false are supported values).
|
||||
*
|
||||
* By default if the value is an object literal or an array it will be "shallow" cloned, to
|
||||
* protect the default value.
|
||||
*
|
||||
* @property Base.ATTRS
|
||||
* @type Object
|
||||
* @static
|
||||
*/
|
||||
Base.ATTRS = {
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the init lifecycle phase.
|
||||
*
|
||||
* @attribute initialized
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
initialized: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
},
|
||||
|
||||
/**
|
||||
* Flag indicating whether or not this object
|
||||
* has been through the destroy lifecycle phase.
|
||||
*
|
||||
* @attribute destroyed
|
||||
* @readonly
|
||||
* @default false
|
||||
* @type boolean
|
||||
*/
|
||||
destroyed: {
|
||||
readOnly:true,
|
||||
value:false
|
||||
}
|
||||
};
|
||||
|
||||
Base.prototype = {
|
||||
|
||||
/**
|
||||
* Init lifecycle method, invoked during construction.
|
||||
* Fires the init event prior to setting up attributes and
|
||||
* invoking initializers for the class hierarchy.
|
||||
*
|
||||
* @method init
|
||||
* @final
|
||||
* @chainable
|
||||
* @param {Object} config Object with configuration property name/value pairs
|
||||
* @return {Base} A reference to this object
|
||||
*/
|
||||
init: function(config) {
|
||||
|
||||
/**
|
||||
* The string used to identify the class of this object.
|
||||
*
|
||||
* @deprecated Use this.constructor.NAME
|
||||
* @property name
|
||||
* @type String
|
||||
*/
|
||||
this._yuievt.config.prefix = this.name = this.constructor.NAME;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the init phase, fired prior to initialization.
|
||||
* Invoking the preventDefault() method on the event object provided
|
||||
* to subscribers will prevent initialization from occuring.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" momemt of this event, will be notified
|
||||
* after initialization of the object is complete (and therefore
|
||||
* cannot prevent initialization).
|
||||
* </p>
|
||||
*
|
||||
* @event init
|
||||
* @preventable _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
*/
|
||||
this.publish(INIT, {
|
||||
queuable:false,
|
||||
defaultFn:this._defInitFn
|
||||
});
|
||||
|
||||
if (config) {
|
||||
if (config.on) {
|
||||
this.on(config.on);
|
||||
}
|
||||
if (config.after) {
|
||||
this.after(config.after);
|
||||
}
|
||||
}
|
||||
|
||||
this.fire(INIT, {cfg: config});
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Destroy lifecycle method. Fires the destroy
|
||||
* event, prior to invoking destructors for the
|
||||
* class hierarchy.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the destroy
|
||||
* event can invoke preventDefault on the event object, to prevent destruction
|
||||
* from proceeding.
|
||||
* </p>
|
||||
* @method destroy
|
||||
* @return {Base} A reference to this object
|
||||
* @final
|
||||
* @chainable
|
||||
*/
|
||||
destroy: function() {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Lifecycle event for the destroy phase,
|
||||
* fired prior to destruction. Invoking the preventDefault
|
||||
* method on the event object provided to subscribers will
|
||||
* prevent destruction from proceeding.
|
||||
* </p>
|
||||
* <p>
|
||||
* Subscribers to the "after" moment of this event, will be notified
|
||||
* after destruction is complete (and as a result cannot prevent
|
||||
* destruction).
|
||||
* </p>
|
||||
* @event destroy
|
||||
* @preventable _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
*/
|
||||
this.publish(DESTROY, {
|
||||
queuable:false,
|
||||
defaultFn: this._defDestroyFn
|
||||
});
|
||||
this.fire(DESTROY);
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Default init event handler
|
||||
*
|
||||
* @method _defInitFn
|
||||
* @param {EventFacade} e Event object, with a cfg property which
|
||||
* refers to the configuration object passed to the constructor.
|
||||
* @protected
|
||||
*/
|
||||
_defInitFn : function(e) {
|
||||
this._initHierarchy(e.cfg);
|
||||
if (this._initPlugins) {
|
||||
// Need to initPlugins manually, to handle constructor parsing, static Plug parsing
|
||||
this._initPlugins(e.cfg);
|
||||
}
|
||||
this._set(INITIALIZED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Default destroy event handler
|
||||
*
|
||||
* @method _defDestroyFn
|
||||
* @param {EventFacade} e Event object
|
||||
* @protected
|
||||
*/
|
||||
_defDestroyFn : function(e) {
|
||||
this._destroyHierarchy();
|
||||
if (this._destroyPlugins) {
|
||||
this._destroyPlugins();
|
||||
}
|
||||
this._set(DESTROYED, true);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the class hierarchy for this object, with Base being the last class in the array.
|
||||
*
|
||||
* @method _getClasses
|
||||
* @protected
|
||||
* @return {Function[]} An array of classes (constructor functions), making up the class hierarchy for this object.
|
||||
* This value is cached the first time the method, or _getAttrCfgs, is invoked. Subsequent invocations return the
|
||||
* cached value.
|
||||
*/
|
||||
_getClasses : function() {
|
||||
if (!this._classes) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._classes;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an aggregated set of attribute configurations, by traversing the class hierarchy.
|
||||
*
|
||||
* @method _getAttrCfgs
|
||||
* @protected
|
||||
* @return {Object} The hash of attribute configurations, aggregated across classes in the hierarchy
|
||||
* This value is cached the first time the method, or _getClasses, is invoked. Subsequent invocations return
|
||||
* the cached value.
|
||||
*/
|
||||
_getAttrCfgs : function() {
|
||||
if (!this._attrs) {
|
||||
this._initHierarchyData();
|
||||
}
|
||||
return this._attrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used when processing ATTRS across the class hierarchy during
|
||||
* initialization. Returns a disposable object with the attributes defined for
|
||||
* the provided class, extracted from the set of all attributes passed in .
|
||||
*
|
||||
* @method _filterAttrCfs
|
||||
* @private
|
||||
*
|
||||
* @param {Function} clazz The class for which the desired attributes are required.
|
||||
* @param {Object} allCfgs The set of all attribute configurations for this instance.
|
||||
* Attributes will be removed from this set, if they belong to the filtered class, so
|
||||
* that by the time all classes are processed, allCfgs will be empty.
|
||||
*
|
||||
* @return {Object} The set of attributes belonging to the class passed in, in the form
|
||||
* of an object with attribute name/configuration pairs.
|
||||
*/
|
||||
_filterAttrCfgs : function(clazz, allCfgs) {
|
||||
var cfgs = null, attr, attrs = clazz.ATTRS;
|
||||
|
||||
if (attrs) {
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr) && allCfgs[attr]) {
|
||||
cfgs = cfgs || {};
|
||||
cfgs[attr] = allCfgs[attr];
|
||||
delete allCfgs[attr];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cfgs;
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method used by _getClasses and _getAttrCfgs, which determines both
|
||||
* the array of classes and aggregate set of attribute configurations
|
||||
* across the class hierarchy for the instance.
|
||||
*
|
||||
* @method _initHierarchyData
|
||||
* @private
|
||||
*/
|
||||
_initHierarchyData : function() {
|
||||
var c = this.constructor,
|
||||
classes = [],
|
||||
attrs = [];
|
||||
|
||||
while (c) {
|
||||
// Add to classes
|
||||
classes[classes.length] = c;
|
||||
|
||||
// Add to attributes
|
||||
if (c.ATTRS) {
|
||||
attrs[attrs.length] = c.ATTRS;
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
this._classes = classes;
|
||||
this._attrs = this._aggregateAttrs(attrs);
|
||||
},
|
||||
|
||||
/**
|
||||
* A helper method, used by _initHierarchyData to aggregate
|
||||
* attribute configuration across the instances class hierarchy.
|
||||
*
|
||||
* The method will potect the attribute configuration value to protect the statically defined
|
||||
* default value in ATTRS if required (if the value is an object literal, array or the
|
||||
* attribute configuration has cloneDefaultValue set to shallow or deep).
|
||||
*
|
||||
* @method _aggregateAttrs
|
||||
* @private
|
||||
* @param {Array} allAttrs An array of ATTRS definitions across classes in the hierarchy
|
||||
* (subclass first, Base last)
|
||||
* @return {Object} The aggregate set of ATTRS definitions for the instance
|
||||
*/
|
||||
_aggregateAttrs : function(allAttrs) {
|
||||
var attr,
|
||||
attrs,
|
||||
cfg,
|
||||
val,
|
||||
path,
|
||||
i,
|
||||
clone,
|
||||
cfgProps = Base._ATTR_CFG,
|
||||
aggAttrs = {};
|
||||
|
||||
if (allAttrs) {
|
||||
for (i = allAttrs.length-1; i >= 0; --i) {
|
||||
attrs = allAttrs[i];
|
||||
|
||||
for (attr in attrs) {
|
||||
if (attrs.hasOwnProperty(attr)) {
|
||||
|
||||
// Protect config passed in
|
||||
cfg = Y.mix({}, attrs[attr], true, cfgProps);
|
||||
|
||||
val = cfg.value;
|
||||
clone = cfg.cloneDefaultValue;
|
||||
|
||||
if (val) {
|
||||
if ( (clone === undefined && (OBJECT_CONSTRUCTOR === val.constructor || L.isArray(val))) || clone === DEEP || clone === true) {
|
||||
cfg.value = Y.clone(val);
|
||||
} else if (clone === SHALLOW) {
|
||||
cfg.value = Y.merge(val);
|
||||
}
|
||||
// else if (clone === false), don't clone the static default value.
|
||||
// It's intended to be used by reference.
|
||||
}
|
||||
|
||||
path = null;
|
||||
if (attr.indexOf(DOT) !== -1) {
|
||||
path = attr.split(DOT);
|
||||
attr = path.shift();
|
||||
}
|
||||
|
||||
if (path && aggAttrs[attr] && aggAttrs[attr].value) {
|
||||
O.setValue(aggAttrs[attr].value, path, val);
|
||||
} else if (!path){
|
||||
if (!aggAttrs[attr]) {
|
||||
aggAttrs[attr] = cfg;
|
||||
} else {
|
||||
Y.mix(aggAttrs[attr], cfg, true, cfgProps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return aggAttrs;
|
||||
},
|
||||
|
||||
/**
|
||||
* Initializes the class hierarchy for the instance, which includes
|
||||
* initializing attributes for each class defined in the class's
|
||||
* static <a href="#property_Base.ATTRS">ATTRS</a> property and
|
||||
* invoking the initializer method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _initHierarchy
|
||||
* @param {Object} userVals Object with configuration property name/value pairs
|
||||
* @private
|
||||
*/
|
||||
_initHierarchy : function(userVals) {
|
||||
var lazy = this._lazyAddAttrs,
|
||||
constr,
|
||||
constrProto,
|
||||
ci,
|
||||
ei,
|
||||
el,
|
||||
classes = this._getClasses(),
|
||||
attrCfgs = this._getAttrCfgs();
|
||||
|
||||
for (ci = classes.length-1; ci >= 0; ci--) {
|
||||
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
|
||||
if (constr._yuibuild && constr._yuibuild.exts && !constr._yuibuild.dynamic) {
|
||||
for (ei = 0, el = constr._yuibuild.exts.length; ei < el; ei++) {
|
||||
constr._yuibuild.exts[ei].apply(this, arguments);
|
||||
}
|
||||
}
|
||||
|
||||
this.addAttrs(this._filterAttrCfgs(constr, attrCfgs), userVals, lazy);
|
||||
|
||||
if (constrProto.hasOwnProperty(INITIALIZER)) {
|
||||
constrProto.initializer.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Destroys the class hierarchy for this instance by invoking
|
||||
* the descructor method on the prototype of each class in the hierarchy.
|
||||
*
|
||||
* @method _destroyHierarchy
|
||||
* @private
|
||||
*/
|
||||
_destroyHierarchy : function() {
|
||||
var constr,
|
||||
constrProto,
|
||||
ci, cl,
|
||||
classes = this._getClasses();
|
||||
|
||||
for (ci = 0, cl = classes.length; ci < cl; ci++) {
|
||||
constr = classes[ci];
|
||||
constrProto = constr.prototype;
|
||||
if (constrProto.hasOwnProperty(DESTRUCTOR)) {
|
||||
constrProto.destructor.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Default toString implementation. Provides the constructor NAME
|
||||
* and the instance ID.
|
||||
*
|
||||
* @method toString
|
||||
* @return {String} String representation for this object
|
||||
*/
|
||||
toString: function() {
|
||||
return this.constructor.NAME + "[" + Y.stamp(this) + "]";
|
||||
}
|
||||
};
|
||||
|
||||
// Straightup augment, no wrapper functions
|
||||
Y.mix(Base, Attribute, false, null, 1);
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
Y.Base = Base;
|
||||
|
||||
// Fix constructor
|
||||
Base.prototype.constructor = Base;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['attribute-base']});
|
||||
YUI.add('base-pluginhost', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-pluginhost submodule adds Plugin support to Base, by augmenting Base with
|
||||
* Plugin.Host and setting up static (class level) Base.plug and Base.unplug methods.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-pluginhost
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
PluginHost = Y.Plugin.Host;
|
||||
|
||||
Y.mix(Base, PluginHost, false, null, 1);
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.plug">Plugin.Host.plug</a>. See aliased
|
||||
* method for argument and return value details.
|
||||
*
|
||||
* @method Base.plug
|
||||
* @static
|
||||
*/
|
||||
Base.plug = PluginHost.plug;
|
||||
|
||||
/**
|
||||
* Alias for <a href="Plugin.Host.html#method_Plugin.Host.unplug">Plugin.Host.unplug</a>. See the
|
||||
* aliased method for argument and return value details.
|
||||
*
|
||||
* @method Base.unplug
|
||||
* @static
|
||||
*/
|
||||
Base.unplug = PluginHost.unplug;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base-base', 'pluginhost']});
|
||||
YUI.add('base-build', function(Y) {
|
||||
|
||||
/**
|
||||
* The base-build submodule provides Base.build functionality, which
|
||||
* can be used to create custom classes, by aggregating extensions onto
|
||||
* a main class.
|
||||
*
|
||||
* @module base
|
||||
* @submodule base-build
|
||||
* @for Base
|
||||
*/
|
||||
|
||||
var Base = Y.Base,
|
||||
L = Y.Lang;
|
||||
|
||||
/**
|
||||
* The build configuration for the Base class.
|
||||
*
|
||||
* Defines the static fields which need to be aggregated
|
||||
* when the Base class is used as the main class passed to
|
||||
* the <a href="#method_Base.build">Base.build</a> method.
|
||||
*
|
||||
* @property Base._buildCfg
|
||||
* @type Object
|
||||
* @static
|
||||
* @final
|
||||
* @private
|
||||
*/
|
||||
Base._buildCfg = {
|
||||
aggregates : ["ATTRS", "_PLUG", "_UNPLUG"]
|
||||
};
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Builds a custom constructor function (class) from the
|
||||
* main function, and array of extension functions (classes)
|
||||
* provided. The NAME field for the constructor function is
|
||||
* defined by the first argument passed in.
|
||||
* </p>
|
||||
* <p>
|
||||
* The cfg object supports the following properties
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>dynamic <boolean></dt>
|
||||
* <dd>
|
||||
* <p>If true (default), a completely new class
|
||||
* is created which extends the main class, and acts as the
|
||||
* host on which the extension classes are augmented.</p>
|
||||
* <p>If false, the extensions classes are augmented directly to
|
||||
* the main class, modifying the main class' prototype.</p>
|
||||
* </dd>
|
||||
* <dt>aggregates <String[]></dt>
|
||||
* <dd>An array of static property names, which will get aggregated
|
||||
* on to the built class, in addition to the default properties build
|
||||
* will always aggregate as defined by the main class' static _buildCfg
|
||||
* property.
|
||||
* </dd>
|
||||
* </dl>
|
||||
*
|
||||
* @method Base.build
|
||||
* @static
|
||||
* @param {Function} name The name of the new class. Used to defined the NAME property for the new class.
|
||||
* @param {Function} main The main class on which to base the built class
|
||||
* @param {Function[]} extensions The set of extension classes which will be
|
||||
* augmented/aggregated to the built class.
|
||||
* @param {Object} cfg Optional. Build configuration for the class (see description).
|
||||
* @return {Function} A custom class, created from the provided main and extension classes
|
||||
*/
|
||||
Base.build = function(name, main, extensions, cfg) {
|
||||
|
||||
var build = Base.build,
|
||||
builtClass = build._getClass(main, cfg),
|
||||
aggregates = build._getAggregates(main, cfg),
|
||||
dynamic = builtClass._yuibuild.dynamic,
|
||||
i, l, val, extClass;
|
||||
|
||||
// Shallow isolate aggregates
|
||||
if (dynamic) {
|
||||
if (aggregates) {
|
||||
for (i = 0, l = aggregates.length; i < l; ++i) {
|
||||
val = aggregates[i];
|
||||
if (main.hasOwnProperty(val)) {
|
||||
builtClass[val] = L.isArray(main[val]) ? [] : {};
|
||||
}
|
||||
}
|
||||
Y.aggregate(builtClass, main, true, aggregates);
|
||||
}
|
||||
}
|
||||
|
||||
// Augment/Aggregate
|
||||
for (i = 0, l = extensions.length; i < l; i++) {
|
||||
extClass = extensions[i];
|
||||
|
||||
if (aggregates) {
|
||||
Y.aggregate(builtClass, extClass, true, aggregates);
|
||||
}
|
||||
|
||||
// Old augment
|
||||
Y.mix(builtClass, extClass, true, null, 1);
|
||||
|
||||
builtClass._yuibuild.exts.push(extClass);
|
||||
}
|
||||
|
||||
builtClass.prototype.hasImpl = build._hasImpl;
|
||||
|
||||
if (dynamic) {
|
||||
builtClass.NAME = name;
|
||||
builtClass.prototype.constructor = builtClass;
|
||||
}
|
||||
|
||||
return builtClass;
|
||||
};
|
||||
|
||||
Y.mix(Base.build, {
|
||||
|
||||
_template: function(main) {
|
||||
|
||||
function BuiltClass() {
|
||||
|
||||
BuiltClass.superclass.constructor.apply(this, arguments);
|
||||
|
||||
var f = BuiltClass._yuibuild.exts,
|
||||
l = f.length,
|
||||
i;
|
||||
|
||||
for (i = 0; i < l; i++) {
|
||||
f[i].apply(this, arguments);
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
Y.extend(BuiltClass, main);
|
||||
|
||||
return BuiltClass;
|
||||
},
|
||||
|
||||
_hasImpl : function(extClass) {
|
||||
var classes = this._getClasses();
|
||||
for (var i = 0, l = classes.length; i < l; i++) {
|
||||
var cls = classes[i];
|
||||
|
||||
if (cls._yuibuild) {
|
||||
var exts = cls._yuibuild.exts,
|
||||
ll = exts.length,
|
||||
j;
|
||||
|
||||
for (j = 0; j < ll; j++) {
|
||||
if (exts[j] === extClass) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_getClass : function(main, cfg) {
|
||||
|
||||
var dynamic = (cfg && false === cfg.dynamic) ? false : true,
|
||||
builtClass = (dynamic) ? Base.build._template(main) : main;
|
||||
|
||||
builtClass._yuibuild = {
|
||||
id: null,
|
||||
exts : [],
|
||||
dynamic : dynamic
|
||||
};
|
||||
|
||||
return builtClass;
|
||||
},
|
||||
|
||||
_getAggregates : function(main, cfg) {
|
||||
var aggr = [],
|
||||
cfgAggr = (cfg && cfg.aggregates),
|
||||
c = main,
|
||||
classAggr;
|
||||
|
||||
while (c && c.prototype) {
|
||||
classAggr = c._buildCfg && c._buildCfg.aggregates;
|
||||
if (classAggr) {
|
||||
aggr = aggr.concat(classAggr);
|
||||
}
|
||||
c = c.superclass ? c.superclass.constructor : null;
|
||||
}
|
||||
|
||||
if (cfgAggr) {
|
||||
aggr = aggr.concat(cfgAggr);
|
||||
}
|
||||
|
||||
return aggr;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base-base']});
|
||||
|
||||
|
||||
YUI.add('base', function(Y){}, '3.0.0' ,{use:['base-base', 'base-pluginhost', 'base-build']});
|
||||
|
||||
8
jssource/src_files/include/javascript/yui3/build/classnamemanager/classnamemanager-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/classnamemanager/classnamemanager-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("classnamemanager",function(C){var B="classNamePrefix",D="classNameDelimiter",A=C.config;A[B]=A[B]||"yui";A[D]=A[D]||"-";C.ClassNameManager=function(){var E=A[B],F=A[D];return{getClassName:C.cached(function(I,G){var H=E+F+((G)?Array.prototype.join.call(arguments,F):I);return H.replace(/\s/g,"");})};}();},"3.0.0");
|
||||
87
jssource/src_files/include/javascript/yui3/build/classnamemanager/classnamemanager.js
vendored
Normal file
87
jssource/src_files/include/javascript/yui3/build/classnamemanager/classnamemanager.js
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('classnamemanager', function(Y) {
|
||||
|
||||
/**
|
||||
* Contains a singleton (ClassNameManager) that enables easy creation and caching of
|
||||
* prefixed class names.
|
||||
* @module classnamemanager
|
||||
*/
|
||||
|
||||
/**
|
||||
* A singleton class providing:
|
||||
*
|
||||
* <ul>
|
||||
* <li>Easy creation of prefixed class names</li>
|
||||
* <li>Caching of previously created class names for improved performance.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @class ClassNameManager
|
||||
* @static
|
||||
*/
|
||||
|
||||
// String constants
|
||||
var CLASS_NAME_PREFIX = 'classNamePrefix',
|
||||
CLASS_NAME_DELIMITER = 'classNameDelimiter',
|
||||
CONFIG = Y.config;
|
||||
|
||||
// Global config
|
||||
|
||||
/**
|
||||
* Configuration property indicating the prefix for all CSS class names in this YUI instance.
|
||||
*
|
||||
* @property Y.config.classNamePrefix
|
||||
* @type {String}
|
||||
* @default "yui"
|
||||
* @static
|
||||
*/
|
||||
CONFIG[CLASS_NAME_PREFIX] = CONFIG[CLASS_NAME_PREFIX] || 'yui';
|
||||
|
||||
/**
|
||||
* Configuration property indicating the delimiter used to compose all CSS class names in
|
||||
* this YUI instance.
|
||||
*
|
||||
* @property Y.config.classNameDelimiter
|
||||
* @type {String}
|
||||
* @default "-"
|
||||
* @static
|
||||
*/
|
||||
CONFIG[CLASS_NAME_DELIMITER] = CONFIG[CLASS_NAME_DELIMITER] || '-';
|
||||
|
||||
Y.ClassNameManager = function () {
|
||||
|
||||
var sPrefix = CONFIG[CLASS_NAME_PREFIX],
|
||||
sDelimiter = CONFIG[CLASS_NAME_DELIMITER];
|
||||
|
||||
return {
|
||||
|
||||
/**
|
||||
* Returns a class name prefixed with the the value of the
|
||||
* <code>Y.config.classNamePrefix</code> attribute + the provided strings.
|
||||
* Uses the <code>Y.config.classNameDelimiter</code> attribute to delimit the
|
||||
* provided strings. E.g. Y.ClassNameManager.getClassName('foo','bar'); // yui-foo-bar
|
||||
*
|
||||
* @method getClassName
|
||||
* @param {String}+ one or more classname bits to be joined and prefixed
|
||||
*/
|
||||
getClassName: Y.cached(function (c, x) {
|
||||
|
||||
var sClass = sPrefix + sDelimiter +
|
||||
// ((x) ? Y.Array(arguments, 0, true).join(sDelimiter) : c);
|
||||
((x) ? Array.prototype.join.call(arguments, sDelimiter) : c);
|
||||
|
||||
return sClass.replace(/\s/g, '');
|
||||
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
}();
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
8
jssource/src_files/include/javascript/yui3/build/collection/collection-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/collection/collection-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("collection",function(E){var C=E.Lang,D=Array.prototype,B=E.Array;B.lastIndexOf=(D.lastIndexOf)?function(A,F){return A.lastIndexOf(F);}:function(A,G){for(var F=A.length-1;F>=0;F=F-1){if(A[F]===G){break;}}return F;};B.unique=function(F,H){var A=F.slice(),G=0,J=-1,I=null;while(G<A.length){I=A[G];while((J=A.lastIndexOf(I))!==G){A.splice(J,1);}G+=1;}if(H){if(C.isNumber(A[0])){A.sort(B.numericSort);}else{A.sort();}}return A;};B.filter=(D.filter)?function(A,F,G){return D.filter.call(A,F,G);}:function(A,G,H){var F=[];B.each(A,function(K,J,I){if(G.call(H,K,J,I)){F.push(K);}});return F;};B.reject=function(A,F,G){return B.filter(A,function(J,I,H){return !F.call(G,J,I,H);});};B.every=(D.every)?function(A,F,G){return D.every.call(A,F,G);}:function(F,H,I){var A=F.length;for(var G=0;G<A;G=G+1){if(!H.call(I,F[G],G,F)){return false;}}return true;};B.map=(D.map)?function(A,F,G){return D.map.call(A,F,G);}:function(A,G,H){var F=[];B.each(A,function(K,J,I){F.push(G.call(H,K,J,I));});return F;};B.reduce=(D.reduce)?function(A,H,F,G){return D.reduce.call(A,function(L,K,J,I){return F.call(G,L,K,J,I);},H);}:function(A,I,G,H){var F=I;B.each(A,function(L,K,J){F=G.call(H,F,L,K,J);});return F;};B.find=function(F,H,I){var A=F.length;for(var G=0;G<A;G++){if(H.call(I,F[G],G,F)){return F[G];}}return null;};B.grep=function(A,F){return B.filter(A,function(H,G){return F.test(H);});};B.partition=function(A,G,H){var F={matches:[],rejects:[]};B.each(A,function(J,I){var K=G.call(H,J,I,A)?F.matches:F.rejects;K.push(J);});return F;};B.zip=function(F,A){var G=[];B.each(F,function(I,H){G.push([I,A[H]]);});return G;};},"3.0.0");
|
||||
294
jssource/src_files/include/javascript/yui3/build/collection/collection.js
vendored
Normal file
294
jssource/src_files/include/javascript/yui3/build/collection/collection.js
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('collection', function(Y) {
|
||||
|
||||
/**
|
||||
* Collection utilities beyond what is provided in the YUI core
|
||||
* @module collection
|
||||
*/
|
||||
|
||||
var L = Y.Lang, Native = Array.prototype, A = Y.Array;
|
||||
|
||||
/**
|
||||
* Adds the following array utilities to the YUI instance
|
||||
* (Y.Array). This is in addition to the methods provided
|
||||
* in the core.
|
||||
* @class YUI~array~extras
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns the index of the last item in the array
|
||||
* that contains the specified value, -1 if the
|
||||
* value isn't found.
|
||||
* method Array.lastIndexOf
|
||||
* @static
|
||||
* @param a {Array} the array to search
|
||||
* @param val the value to search for
|
||||
* @return {int} the index of hte item that contains the value or -1
|
||||
*/
|
||||
A.lastIndexOf = (Native.lastIndexOf) ?
|
||||
function(a ,val) {
|
||||
return a.lastIndexOf(val);
|
||||
} :
|
||||
function(a, val) {
|
||||
for (var i=a.length-1; i>=0; i=i-1) {
|
||||
if (a[i] === val) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return i;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a copy of the array with the duplicate entries removed
|
||||
* @method Array.unique
|
||||
* @static
|
||||
* @param a {Array} the array to find the subset of uniques for
|
||||
* @param sort {bool} flag to denote if the array is sorted or not. Defaults to false, the more general operation
|
||||
* @return {Array} a copy of the array with duplicate entries removed
|
||||
*/
|
||||
A.unique = function(a, sort) {
|
||||
var b = a.slice(), i = 0, n = -1, item = null;
|
||||
|
||||
while (i < b.length) {
|
||||
item = b[i];
|
||||
while ((n = b.lastIndexOf(item)) !== i) {
|
||||
b.splice(n, 1);
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
// Note: the sort option doesn't really belong here... I think it was added
|
||||
// because there was a way to fast path the two operations together. That
|
||||
// implementation was not working, so I replaced it with the following.
|
||||
// Leaving it in so that the API doesn't get broken.
|
||||
if (sort) {
|
||||
if (L.isNumber(b[0])) {
|
||||
b.sort(A.numericSort);
|
||||
} else {
|
||||
b.sort();
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned true for.
|
||||
* @method Array.filter
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned true. If no items matched an empty array is
|
||||
* returned.
|
||||
*/
|
||||
A.filter = (Native.filter) ?
|
||||
function(a, f, o) {
|
||||
return Native.filter.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
if (f.call(o, item, i, a)) {
|
||||
results.push(item);
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* The inverse of filter. Executes the supplied function on each item.
|
||||
* Returns a new array containing the items that the supplied
|
||||
* function returned *false* for.
|
||||
* @method Array.reject
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} The items on which the supplied function
|
||||
* returned false.
|
||||
*/
|
||||
A.reject = function(a, f, o) {
|
||||
return A.filter(a, function(item, i, a) {
|
||||
return !f.call(o, item, i, a);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.every
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {boolean} true if every item in the array returns true
|
||||
* from the supplied function.
|
||||
*/
|
||||
A.every = (Native.every) ?
|
||||
function(a, f, o) {
|
||||
return Native.every.call(a,f,o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var l = a.length;
|
||||
for (var i = 0; i < l; i=i+1) {
|
||||
if (!f.call(o, a[i], i, a)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* @method Array.map
|
||||
* @param a {Array} the array to iterate
|
||||
* @param f {Function} the function to execute on each item
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {Array} A new array containing the return value
|
||||
* of the supplied function for each item in the original
|
||||
* array.
|
||||
*/
|
||||
A.map = (Native.map) ?
|
||||
function(a, f, o) {
|
||||
return Native.map.call(a, f, o);
|
||||
} :
|
||||
function(a, f, o) {
|
||||
var results = [];
|
||||
A.each(a, function(item, i, a) {
|
||||
results.push(f.call(o, item, i, a));
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array.
|
||||
* Reduce "folds" the array into a single value.
|
||||
* @method Array.reduce
|
||||
* @param a {Array} the array to iterate
|
||||
* @param init The initial value to start from
|
||||
* @param f {Function} the function to execute on each item. It
|
||||
* is responsible for returning the updated value of the
|
||||
* computation.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return A value that results from iteratively applying the
|
||||
* supplied function to each element in the array.
|
||||
*/
|
||||
A.reduce = (Native.reduce) ?
|
||||
function(a, init, f, o) {
|
||||
//Firefox's Array.reduce does not allow inclusion of a
|
||||
// thisObject, so we need to implement it manually
|
||||
return Native.reduce.call(a, function(init, item, i, a) {
|
||||
return f.call(o, init, item, i, a);
|
||||
}, init);
|
||||
} :
|
||||
function(a, init, f, o) {
|
||||
var r = init;
|
||||
A.each(a, function (item, i, a) {
|
||||
r = f.call(o, r, item, i, a);
|
||||
});
|
||||
return r;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Executes the supplied function on each item in the array,
|
||||
* searching for the first item that matches the supplied
|
||||
* function.
|
||||
* @method Array.find
|
||||
* @param a {Array} the array to search
|
||||
* @param f {Function} the function to execute on each item.
|
||||
* Iteration is stopped as soon as this function returns true
|
||||
* on an item.
|
||||
* @param o Optional context object
|
||||
* @static
|
||||
* @return {object} the first item that the supplied function
|
||||
* returns true for, or null if it never returns true
|
||||
*/
|
||||
A.find = function(a, f, o) {
|
||||
var l = a.length;
|
||||
for(var i=0; i < l; i++) {
|
||||
if (f.call(o, a[i], i, a)) {
|
||||
return a[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
/**
|
||||
* Iterates over an array, returning a new array of all the elements
|
||||
* that match the supplied regular expression
|
||||
* @method Array.grep
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param pattern {RegExp} The regular expression to test against
|
||||
* each item
|
||||
* @static
|
||||
* @return {Array} All the items in the collection that
|
||||
* produce a match against the supplied regular expression.
|
||||
* If no items match, an empty array is returned.
|
||||
*/
|
||||
A.grep = function (a, pattern) {
|
||||
return A.filter(a, function (item, index) {
|
||||
return pattern.test(item);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Partitions an array into two new arrays, one with the items
|
||||
* that match the supplied function, and one with the items that
|
||||
* do not.
|
||||
* @method Array.partition
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @paran f {Function} a function that will receive each item
|
||||
* in the collection and its index.
|
||||
* @param o Optional execution context of f.
|
||||
* @static
|
||||
* @return An object with two members, 'matches' and 'rejects',
|
||||
* that are arrays containing the items that were selected or
|
||||
* rejected by the test function (or an empty array).
|
||||
*/
|
||||
A.partition = function (a, f, o) {
|
||||
var results = {matches: [], rejects: []};
|
||||
A.each(a, function (item, index) {
|
||||
var set = f.call(o, item, index, a) ? results.matches : results.rejects;
|
||||
set.push(item);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
/**
|
||||
* Creates an array of arrays by pairing the corresponding
|
||||
* elements of two arrays together into a new array.
|
||||
* @method Array.zip
|
||||
* @param a {Array} a collection to iterate over
|
||||
* @param a2 {Array} another collection whose members will be
|
||||
* paired with members of the first parameter
|
||||
* @static
|
||||
* @return An array of arrays formed by pairing each element
|
||||
* of the first collection with an item in the second collection
|
||||
* having the corresponding index.
|
||||
*/
|
||||
A.zip = function (a, a2) {
|
||||
var results = [];
|
||||
A.each(a, function (item, index) {
|
||||
results.push([item, a2[index]]);
|
||||
});
|
||||
return results;
|
||||
};
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
9
jssource/src_files/include/javascript/yui3/build/compat/compat-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/compat/compat-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
896
jssource/src_files/include/javascript/yui3/build/compat/compat.js
vendored
Normal file
896
jssource/src_files/include/javascript/yui3/build/compat/compat.js
vendored
Normal file
@@ -0,0 +1,896 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('compat', function(Y) {
|
||||
|
||||
|
||||
var COMPAT_ARG = '~yui|2|compat~';
|
||||
|
||||
|
||||
if (window.YAHOO != YUI) {
|
||||
|
||||
// get any existing YAHOO obj props
|
||||
var o = (window.YAHOO) ? YUI.merge(window.YAHOO) : null;
|
||||
|
||||
// Make the YUI global the YAHOO global
|
||||
window.YAHOO = YUI;
|
||||
|
||||
// augment old YAHOO props
|
||||
if (o) {
|
||||
Y.mix(Y, o);
|
||||
}
|
||||
}
|
||||
|
||||
// add old namespaces
|
||||
Y.namespace("util", "widget", "example");
|
||||
|
||||
// case/location change
|
||||
Y.env = (Y.env) ? Y.mix(Y.env, Y.Env) : Y.Env;
|
||||
Y.lang = (Y.lang) ? Y.mix(Y.lang, Y.Lang) : Y.Lang;
|
||||
Y.env.ua = Y.UA;
|
||||
|
||||
// support Y.register
|
||||
Y.mix(Y.env, {
|
||||
modules: [],
|
||||
listeners: [],
|
||||
getVersion: function(name) {
|
||||
return this.Env.modules[name] || null;
|
||||
}
|
||||
});
|
||||
|
||||
var L = Y.lang;
|
||||
|
||||
// add old lang properties
|
||||
Y.mix(L, {
|
||||
|
||||
augmentObject: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null;
|
||||
return Y.mix(r, s, (wl), wl);
|
||||
},
|
||||
|
||||
augmentProto: function(r, s) {
|
||||
var a = arguments, wl = (a.length > 2) ? Y.Array(a, 2, true) : null;
|
||||
return Y.mix(r, s, (wl), wl, 1);
|
||||
},
|
||||
|
||||
// extend: Y.bind(Y.extend, Y),
|
||||
extend: Y.extend,
|
||||
// merge: Y.bind(Y.merge, Y)
|
||||
merge: Y.merge
|
||||
}, true);
|
||||
|
||||
L.augment = L.augmentProto;
|
||||
|
||||
L.hasOwnProperty = function(o, k) {
|
||||
return (o.hasOwnProperty(k));
|
||||
};
|
||||
|
||||
Y.augmentProto = L.augmentProto;
|
||||
|
||||
// add register function
|
||||
Y.mix(Y, {
|
||||
register: function(name, mainClass, data) {
|
||||
var mods = Y.Env.modules;
|
||||
if (!mods[name]) {
|
||||
mods[name] = { versions:[], builds:[] };
|
||||
}
|
||||
var m=mods[name],v=data.version,b=data.build,ls=Y.Env.listeners;
|
||||
m.name = name;
|
||||
m.version = v;
|
||||
m.build = b;
|
||||
m.versions.push(v);
|
||||
m.builds.push(b);
|
||||
m.mainClass = mainClass;
|
||||
// fire the module load listeners
|
||||
for (var i=0;i<ls.length;i=i+1) {
|
||||
ls[i](m);
|
||||
}
|
||||
// label the main class
|
||||
if (mainClass) {
|
||||
mainClass.VERSION = v;
|
||||
mainClass.BUILD = b;
|
||||
} else {
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// add old load listeners
|
||||
if ("undefined" !== typeof YAHOO_config) {
|
||||
var l=YAHOO_config.listener,ls=Y.Env.listeners,unique=true,i;
|
||||
if (l) {
|
||||
// if YAHOO is loaded multiple times we need to check to see if
|
||||
// this is a new config object. If it is, add the new component
|
||||
// load listener to the stack
|
||||
for (i=0;i<ls.length;i=i+1) {
|
||||
if (ls[i]==l) {
|
||||
unique=false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (unique) {
|
||||
ls.push(l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// add old registration for yahoo
|
||||
Y.register("yahoo", Y, {version: "3.0.0", build: "1549"});
|
||||
|
||||
if (Y.Event) {
|
||||
|
||||
var o = {
|
||||
|
||||
/**
|
||||
* Safari detection
|
||||
* @property isSafari
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
isSafari: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* webkit version
|
||||
* @property webkit
|
||||
* @type string
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.webkit
|
||||
*/
|
||||
webkit: Y.UA.webkit,
|
||||
|
||||
/**
|
||||
* Normalized keycodes for webkit/safari
|
||||
* @property webkitKeymap
|
||||
* @type {int: int}
|
||||
* @private
|
||||
* @static
|
||||
* @final
|
||||
*/
|
||||
webkitKeymap: {
|
||||
63232: 38, // up
|
||||
63233: 40, // down
|
||||
63234: 37, // left
|
||||
63235: 39, // right
|
||||
63276: 33, // page up
|
||||
63277: 34, // page down
|
||||
25: 9 // SHIFT-TAB (Safari provides a different key code in
|
||||
// this case, even though the shiftKey modifier is set)
|
||||
},
|
||||
|
||||
/**
|
||||
* IE detection
|
||||
* @property isIE
|
||||
* @private
|
||||
* @static
|
||||
* @deprecated use Y.Env.UA.ie
|
||||
*/
|
||||
isIE: Y.UA.ie,
|
||||
|
||||
/**
|
||||
* Returns scrollLeft
|
||||
* @method _getScrollLeft
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollLeft: function() {
|
||||
return this._getScroll()[1];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns scrollTop
|
||||
* @method _getScrollTop
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScrollTop: function() {
|
||||
return this._getScroll()[0];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the scrollTop and scrollLeft. Used to calculate the
|
||||
* pageX and pageY in Internet Explorer
|
||||
* @method _getScroll
|
||||
* @static
|
||||
* @private
|
||||
*/
|
||||
_getScroll: function() {
|
||||
var d = Y.config.doc, dd = d.documentElement, db = d.body;
|
||||
if (dd && (dd.scrollTop || dd.scrollLeft)) {
|
||||
return [dd.scrollTop, dd.scrollLeft];
|
||||
} else if (db) {
|
||||
return [db.scrollTop, db.scrollLeft];
|
||||
} else {
|
||||
return [0, 0];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageX
|
||||
* @method getPageX
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageX
|
||||
* @static
|
||||
*/
|
||||
getPageX: function(ev) {
|
||||
var x = ev.pageX;
|
||||
if (!x && 0 !== x) {
|
||||
x = ev.clientX || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
x += this._getScrollLeft();
|
||||
}
|
||||
}
|
||||
|
||||
return x;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the charcode for an event
|
||||
* @method getCharCode
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's charCode
|
||||
* @static
|
||||
*/
|
||||
getCharCode: function(ev) {
|
||||
var code = ev.keyCode || ev.charCode || 0;
|
||||
|
||||
// webkit normalization
|
||||
if (Y.UA.webkit && (code in Y.Event.webkitKeymap)) {
|
||||
code = Y.Event.webkitKeymap[code];
|
||||
}
|
||||
return code;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's pageY
|
||||
* @method getPageY
|
||||
* @param {Event} ev the event
|
||||
* @return {int} the event's pageY
|
||||
* @static
|
||||
*/
|
||||
getPageY: function(ev) {
|
||||
var y = ev.pageY;
|
||||
if (!y && 0 !== y) {
|
||||
y = ev.clientY || 0;
|
||||
|
||||
if ( Y.UA.ie ) {
|
||||
y += this._getScrollTop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return y;
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the pageX and pageY properties as an indexed array.
|
||||
* @method getXY
|
||||
* @param {Event} ev the event
|
||||
* @return {[x, y]} the pageX and pageY properties of the event
|
||||
* @static
|
||||
*/
|
||||
getXY: function(ev) {
|
||||
return [this.getPageX(ev), this.getPageY(ev)];
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's related target
|
||||
* @method getRelatedTarget
|
||||
* @param {Event} ev the event
|
||||
* @return {HTMLElement} the event's relatedTarget
|
||||
* @static
|
||||
*/
|
||||
getRelatedTarget: function(ev) {
|
||||
var t = ev.relatedTarget;
|
||||
if (!t) {
|
||||
if (ev.type == "mouseout") {
|
||||
t = ev.toElement;
|
||||
} else if (ev.type == "mouseover") {
|
||||
t = ev.fromElement;
|
||||
}
|
||||
}
|
||||
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the time of the event. If the time is not included, the
|
||||
* event is modified using the current time.
|
||||
* @method getTime
|
||||
* @param {Event} ev the event
|
||||
* @return {Date} the time of the event
|
||||
* @static
|
||||
*/
|
||||
getTime: function(ev) {
|
||||
if (!ev.time) {
|
||||
var t = new Date().getTime();
|
||||
try {
|
||||
ev.time = t;
|
||||
} catch(ex) {
|
||||
this.lastError = ex;
|
||||
return t;
|
||||
}
|
||||
}
|
||||
|
||||
return ev.time;
|
||||
},
|
||||
|
||||
/**
|
||||
* Convenience method for stopPropagation + preventDefault
|
||||
* @method stopEvent
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopEvent: function(ev) {
|
||||
this.stopPropagation(ev);
|
||||
this.preventDefault(ev);
|
||||
},
|
||||
|
||||
/**
|
||||
* Stops event propagation
|
||||
* @method stopPropagation
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
stopPropagation: function(ev) {
|
||||
if (ev.stopPropagation) {
|
||||
ev.stopPropagation();
|
||||
} else {
|
||||
ev.cancelBubble = true;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Prevents the default behavior of the event
|
||||
* @method preventDefault
|
||||
* @param {Event} ev the event
|
||||
* @static
|
||||
*/
|
||||
preventDefault: function(ev) {
|
||||
if (ev.preventDefault) {
|
||||
ev.preventDefault();
|
||||
} else {
|
||||
ev.returnValue = false;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the event's target element. Safari sometimes provides
|
||||
* a text node, and this is automatically resolved to the text
|
||||
* node's parent so that it behaves like other browsers.
|
||||
* @method getTarget
|
||||
* @param {Event} ev the event
|
||||
* @param {boolean} resolveTextNode when set to true the target's
|
||||
* parent will be returned if the target is a
|
||||
* text node. @deprecated, the text node is
|
||||
* now resolved automatically
|
||||
* @return {HTMLElement} the event's target
|
||||
* @static
|
||||
*/
|
||||
getTarget: function(ev, resolveTextNode) {
|
||||
var t = ev.target || ev.srcElement;
|
||||
return this.resolveTextNode(t);
|
||||
},
|
||||
|
||||
/**
|
||||
* In some cases, some browsers will return a text node inside
|
||||
* the actual element that was targeted. This normalizes the
|
||||
* return value for getTarget and getRelatedTarget.
|
||||
* @method resolveTextNode
|
||||
* @param {HTMLElement} node node to resolve
|
||||
* @return {HTMLElement} the normized node
|
||||
* @static
|
||||
*/
|
||||
resolveTextNode: function(node) {
|
||||
if (node && 3 == node.nodeType) {
|
||||
return node.parentNode;
|
||||
} else {
|
||||
return node;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* We cache elements bound by id because when the unload event
|
||||
* fires, we can no longer use document.getElementById
|
||||
* @method getEl
|
||||
* @static
|
||||
* @private
|
||||
* @deprecated Elements are not cached any longer
|
||||
*/
|
||||
getEl: function(id) {
|
||||
return Y.get(id);
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.Event, o);
|
||||
|
||||
/**
|
||||
* Calls Y.Event.attach with the correct argument order
|
||||
* @method removeListener
|
||||
*/
|
||||
Y.Event.removeListener = function(el, type, fn, data, override) {
|
||||
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.detach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
/**
|
||||
* Calls Y.Event.detach with the correct argument order
|
||||
* @method addListener
|
||||
*/
|
||||
Y.Event.addListener = function(el, type, fn, data, override) {
|
||||
|
||||
|
||||
// var a = Y.Array(arguments, 0, true), el = a.shift();
|
||||
// a.splice(2, 0, el);
|
||||
// return Y.Event.attach.apply(Y.Event, a);
|
||||
var context, a=[type, fn, el];
|
||||
|
||||
if (data) {
|
||||
|
||||
if (override) {
|
||||
context = (override === true) ? data : override;
|
||||
}
|
||||
|
||||
a.push(context);
|
||||
a.push(data);
|
||||
}
|
||||
|
||||
a.push(COMPAT_ARG);
|
||||
|
||||
return Y.Event.attach.apply(Y.Event, a);
|
||||
};
|
||||
|
||||
Y.Event.on = Y.Event.addListener;
|
||||
|
||||
var newOnavail = Y.Event.onAvailable;
|
||||
|
||||
Y.Event.onAvailable = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, false, true);
|
||||
};
|
||||
|
||||
Y.Event.onContentReady = function(id, fn, p_obj, p_override) {
|
||||
return newOnavail(id, fn, p_obj, p_override, true, true);
|
||||
};
|
||||
|
||||
Y.Event.onDOMReady = function(fn) {
|
||||
var a = Y.Array(arguments, 0, true);
|
||||
a.unshift('event:ready');
|
||||
return Y.on.apply(Y, a);
|
||||
};
|
||||
|
||||
Y.util.Event = Y.Event;
|
||||
|
||||
var CE = function(type, oScope, silent, signature) {
|
||||
//debugger;
|
||||
|
||||
var o = {
|
||||
context: oScope,
|
||||
silent: silent || false
|
||||
// signature: signature || CE.LIST
|
||||
};
|
||||
|
||||
CE.superclass.constructor.call(this, type, o);
|
||||
|
||||
this.signature = signature || CE.LIST;
|
||||
};
|
||||
|
||||
Y.extend(CE, Y.CustomEvent, {
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The LIST type returns three
|
||||
* parameters: the event type, the array of args passed to fire, and
|
||||
* the optional custom object
|
||||
* @property YAHOO.util.CustomEvent.LIST
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.LIST = 0;
|
||||
|
||||
/**
|
||||
* Subscriber listener sigature constant. The FLAT type returns two
|
||||
* parameters: the first argument passed to fire and the optional
|
||||
* custom object
|
||||
* @property YAHOO.util.CustomEvent.FLAT
|
||||
* @static
|
||||
* @type int
|
||||
*/
|
||||
CE.FLAT = 1;
|
||||
|
||||
Y.util.CustomEvent = CE;
|
||||
|
||||
var EP = function() {
|
||||
//console.log('Compat CustomEvent constructor executed: ' + this._yuid);
|
||||
if (!this._yuievt) {
|
||||
var sub = this.subscribe;
|
||||
Y.EventTarget.apply(this, arguments);
|
||||
this.subscribe = sub;
|
||||
this.__yuiepinit = function() {};
|
||||
}
|
||||
};
|
||||
|
||||
Y.extend(EP, Y.EventTarget, {
|
||||
|
||||
createEvent: function(type, o) {
|
||||
o = o || {};
|
||||
o.signature = o.signature || CE.FLAT;
|
||||
return this.publish(type, o);
|
||||
},
|
||||
|
||||
subscribe: function(type, fn, obj, override) {
|
||||
var ce = this._yuievt.events[type] || this.createEvent(type),
|
||||
a = Y.Array(arguments);
|
||||
|
||||
if (override && true !== override) {
|
||||
// a[2] = override;
|
||||
// a[1] = obj;
|
||||
}
|
||||
|
||||
Y.EventTarget.prototype.subscribe.apply(this, a);
|
||||
},
|
||||
|
||||
fireEvent: function(type) {
|
||||
return this.fire.apply(this, arguments);
|
||||
},
|
||||
|
||||
hasEvent: function(type) {
|
||||
return this.getEvent(type);
|
||||
}
|
||||
});
|
||||
|
||||
Y.util.EventProvider = EP;
|
||||
|
||||
}
|
||||
|
||||
|
||||
Y.register("event", Y, {version: "3.0.0", build: "1549"});
|
||||
|
||||
|
||||
var propertyCache = {};
|
||||
var patterns = {
|
||||
HYPHEN: /(-[a-z])/i, // to normalize get/setStyle
|
||||
ROOT_TAG: /^body|html$/i, // body for quirks mode, html for standards,
|
||||
OP_SCROLL:/^(?:inline|table-row)$/i
|
||||
};
|
||||
|
||||
var hyphenToCamel = function(property) {
|
||||
if ( !patterns.HYPHEN.test(property) ) {
|
||||
return property; // no hyphens
|
||||
}
|
||||
|
||||
if (propertyCache[property]) { // already converted
|
||||
return propertyCache[property];
|
||||
}
|
||||
|
||||
var converted = property;
|
||||
|
||||
while( patterns.HYPHEN.exec(converted) ) {
|
||||
converted = converted.replace(RegExp.$1,
|
||||
RegExp.$1.substr(1).toUpperCase());
|
||||
}
|
||||
|
||||
propertyCache[property] = converted;
|
||||
return converted;
|
||||
//return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
|
||||
};
|
||||
|
||||
var Dom = {
|
||||
get: function(el) {
|
||||
if (el) {
|
||||
if (el.nodeType || el.item) { // Node, or NodeList
|
||||
return el;
|
||||
}
|
||||
|
||||
if (typeof el === 'string') { // id
|
||||
return document.getElementById(el);
|
||||
}
|
||||
|
||||
if ('length' in el) { // array-like
|
||||
var c = [];
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
c[c.length] = Dom.get(el[i]);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
return el; // some other object, just pass it back
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
|
||||
isAncestor: function(haystack, needle) {
|
||||
return YUI.DOM.contains(Dom.get(haystack), Dom.get(needle));
|
||||
},
|
||||
|
||||
inDocument: function(el) {
|
||||
return Dom.isAncestor(Y.config.doc.documentElement, el);
|
||||
},
|
||||
|
||||
batch: function(el, method, o, override, args) {
|
||||
el = (el && (el.tagName || el.item)) ? el : Dom.get(el); // skip get() when possible
|
||||
|
||||
if (!el || !method) {
|
||||
return false;
|
||||
}
|
||||
if (args) {
|
||||
args = Y.Array(args);
|
||||
}
|
||||
var scope = (override) ? o : window;
|
||||
|
||||
var apply = function(el) {
|
||||
if (args) {
|
||||
var tmp = slice.call(args);
|
||||
tmp.unshift(el);
|
||||
return method.apply(scope, tmp);
|
||||
} else {
|
||||
return method.call(scope, el, o);
|
||||
}
|
||||
};
|
||||
|
||||
if (el.tagName || el.length === undefined) { // element or not array-like
|
||||
return apply(el);
|
||||
}
|
||||
|
||||
var collection = [];
|
||||
|
||||
for (var i = 0, len = el.length; i < len; ++i) {
|
||||
collection[collection.length] = apply(el[i]);
|
||||
}
|
||||
|
||||
return collection;
|
||||
},
|
||||
|
||||
// 2.x returns false if already present
|
||||
_addClass: function(el, className) {
|
||||
if ( YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.addClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if not present
|
||||
_removeClass: function(el, className) {
|
||||
if ( !YUI.DOM.hasClass(el, className) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.removeClass(el, className);
|
||||
return true;
|
||||
},
|
||||
|
||||
// 2.x returns false if no newClass or same as oldClass
|
||||
_replaceClass: function(el, oldClass, newClass) {
|
||||
if (!newClass || oldClass === newClass) {
|
||||
return false;
|
||||
}
|
||||
|
||||
YUI.DOM.replaceClass(el, oldClass, newClass);
|
||||
return true;
|
||||
},
|
||||
|
||||
getElementsByClassName: function(className, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : Y.config.doc;
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = Y.Selector.query(tag + '.' + className, root);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getElementsBy: function(method, tag, root) {
|
||||
tag = tag || '*';
|
||||
root = (root) ? Dom.get(root) : null || document;
|
||||
|
||||
var nodes = [];
|
||||
if (root) {
|
||||
nodes = YUI.DOM.byTag(tag, root, method);
|
||||
}
|
||||
return nodes;
|
||||
},
|
||||
|
||||
getViewportWidth: YUI.DOM.winWidth,
|
||||
getViewportHeight: YUI.DOM.winHeight,
|
||||
getDocumentWidth: YUI.DOM.docWidth,
|
||||
getDocumentHeight: YUI.DOM.docHeight,
|
||||
getDocumentScrollTop: YUI.DOM.docScrollY,
|
||||
getDocumentScrollLeft: YUI.DOM.docScrollX,
|
||||
getDocumentHeight: YUI.DOM.docHeight,
|
||||
|
||||
_guid: function(el, prefix) {
|
||||
prefix = prefix || 'yui-gen';
|
||||
Dom._id_counter = Dom._id_counter || 0;
|
||||
|
||||
if (el && el.id) { // do not override existing ID
|
||||
return el.id;
|
||||
}
|
||||
|
||||
var id = prefix + Dom._id_counter++;
|
||||
|
||||
if (el) {
|
||||
el.id = id;
|
||||
}
|
||||
|
||||
return id;
|
||||
},
|
||||
|
||||
_region: function(el) {
|
||||
if ( (el.parentNode === null || el.offsetParent === null ||
|
||||
YUI.DOM.getStyle(el, 'display') == 'none') && el != el.ownerDocument.body) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return YUI.DOM.region(el);
|
||||
|
||||
},
|
||||
|
||||
_ancestorByClass: function(element, className) {
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return YUI.DOM.hasClass(el, className);
|
||||
});
|
||||
},
|
||||
|
||||
_ancestorByTag: function(element, tag) {
|
||||
tag = tag.toUpperCase();
|
||||
return YUI.DOM.ancestor(element, function(el) {
|
||||
return el.tagName.toUpperCase() === tag;
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var slice = [].slice;
|
||||
|
||||
var wrap = function(fn, name) {
|
||||
Dom[name] = function() {
|
||||
var args = slice.call(arguments);
|
||||
args[0] = Dom.get(args[0]);
|
||||
return fn.apply(Dom, args);
|
||||
};
|
||||
};
|
||||
|
||||
var wrapped = {
|
||||
getAncestorBy: YUI.DOM.ancestor,
|
||||
getAncestorByClassName: Dom._ancestorByClass,
|
||||
getAncestorByTagName: Dom._ancestorByTag,
|
||||
getPreviousSiblingBy: YUI.DOM.previous,
|
||||
getPreviousSibling: YUI.DOM.previous,
|
||||
getNextSiblingBy: YUI.DOM.next,
|
||||
getNextSibling: YUI.DOM.next,
|
||||
getFirstChildBy: YUI.DOM.firstChild,
|
||||
getFirstChild: YUI.DOM.firstChild,
|
||||
getLastChildBy: YUI.DOM.lastChild,
|
||||
getLastChild: YUI.DOM.lastChild,
|
||||
getChildrenBy: YUI.DOM.children,
|
||||
getChildren: YUI.DOM.children,
|
||||
insertBefore: function(newNode, refNode) {
|
||||
YUI.DOM.insertBefore(Dom.get(newNode), Dom.get(refNode));
|
||||
},
|
||||
insertAfter: function(newNode, refNode) {
|
||||
YUI.DOM.insertAfter(Dom.get(newNode), Dom.get(refNode));
|
||||
}
|
||||
};
|
||||
|
||||
Y.each(wrapped, wrap);
|
||||
|
||||
var batched = {
|
||||
getStyle: YUI.DOM.getStyle,
|
||||
setStyle: YUI.DOM.setStyle,
|
||||
getXY: YUI.DOM.getXY,
|
||||
setXY: YUI.DOM.setXY,
|
||||
getX: YUI.DOM.getX,
|
||||
getY: YUI.DOM.getY,
|
||||
setX: YUI.DOM.setX,
|
||||
setY: YUI.DOM.setY,
|
||||
getRegion: Dom._region,
|
||||
hasClass: YUI.DOM.hasClass,
|
||||
addClass: Dom._addClass,
|
||||
removeClass: Dom._removeClass,
|
||||
replaceClass: Dom._replaceClass,
|
||||
generateId: Dom._guid
|
||||
};
|
||||
|
||||
Y.each(batched, function(v, n) {
|
||||
Dom[n] = function(el) {
|
||||
var args = slice.call(arguments, 1);
|
||||
return Dom.batch(el, v, null, null, args);
|
||||
};
|
||||
});
|
||||
|
||||
Y.util.Dom = Dom;
|
||||
|
||||
YAHOO.util.Region = function(t, r, b, l) {
|
||||
this.top = t;
|
||||
this[1] = t;
|
||||
this.right = r;
|
||||
this.bottom = b;
|
||||
this.left = l;
|
||||
this[0] = l;
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.contains = function(region) {
|
||||
return ( region.left >= this.left &&
|
||||
region.right <= this.right &&
|
||||
region.top >= this.top &&
|
||||
region.bottom <= this.bottom );
|
||||
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.getArea = function() {
|
||||
return ( (this.bottom - this.top) * (this.right - this.left) );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.intersect = function(region) {
|
||||
var t = Math.max( this.top, region.top );
|
||||
var r = Math.min( this.right, region.right );
|
||||
var b = Math.min( this.bottom, region.bottom );
|
||||
var l = Math.max( this.left, region.left );
|
||||
|
||||
if (b >= t && r >= l) {
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.union = function(region) {
|
||||
var t = Math.min( this.top, region.top );
|
||||
var r = Math.max( this.right, region.right );
|
||||
var b = Math.max( this.bottom, region.bottom );
|
||||
var l = Math.min( this.left, region.left );
|
||||
|
||||
return new YAHOO.util.Region(t, r, b, l);
|
||||
};
|
||||
|
||||
YAHOO.util.Region.prototype.toString = function() {
|
||||
return ( "Region {" +
|
||||
"top: " + this.top +
|
||||
", right: " + this.right +
|
||||
", bottom: " + this.bottom +
|
||||
", left: " + this.left +
|
||||
"}" );
|
||||
};
|
||||
|
||||
YAHOO.util.Region.getRegion = function(el) {
|
||||
return YUI.DOM.region(el);
|
||||
};
|
||||
|
||||
YAHOO.util.Point = function(x, y) {
|
||||
if (YAHOO.lang.isArray(x)) { // accept input from Dom.getXY, Event.getXY, etc.
|
||||
y = x[1]; // dont blow away x yet
|
||||
x = x[0];
|
||||
}
|
||||
|
||||
this.x = this.right = this.left = this[0] = x;
|
||||
this.y = this.top = this.bottom = this[1] = y;
|
||||
};
|
||||
|
||||
YAHOO.util.Point.prototype = new YAHOO.util.Region();
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dom','event']});
|
||||
YUI._setup(); YUI.use('dom', 'event', 'compat');
|
||||
8
jssource/src_files/include/javascript/yui3/build/console/console-filters-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/console/console-filters-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
710
jssource/src_files/include/javascript/yui3/build/console/console-filters.js
vendored
Normal file
710
jssource/src_files/include/javascript/yui3/build/console/console-filters.js
vendored
Normal file
@@ -0,0 +1,710 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('console-filters', function(Y) {
|
||||
|
||||
/**
|
||||
* <p>Provides Plugin.ConsoleFilters plugin class.</p>
|
||||
*
|
||||
* <p>This plugin adds the ability to control which Console entries display by filtering on category and source. Two groups of checkboxes are added to the Console footer, one for categories and the other for sources. Only those messages that match a checked category or source are displayed.</p>
|
||||
*
|
||||
* @module console-filters
|
||||
* @namespace Plugin
|
||||
* @class ConsoleFilters
|
||||
*/
|
||||
|
||||
// Some common strings and functions
|
||||
var getCN = Y.ClassNameManager.getClassName,
|
||||
CONSOLE = 'console',
|
||||
FILTERS = 'filters',
|
||||
FILTER = 'filter',
|
||||
CATEGORY = 'category',
|
||||
SOURCE = 'source',
|
||||
CATEGORY_DOT = 'category.',
|
||||
SOURCE_DOT = 'source.',
|
||||
|
||||
HOST = 'host',
|
||||
PARENT_NODE = 'parentNode',
|
||||
CHECKED = 'checked',
|
||||
DEF_VISIBILITY = 'defaultVisibility',
|
||||
|
||||
DOT = '.',
|
||||
EMPTY = '',
|
||||
|
||||
C_BODY = DOT + Y.Console.CHROME_CLASSES.console_bd_class,
|
||||
C_FOOT = DOT + Y.Console.CHROME_CLASSES.console_ft_class,
|
||||
|
||||
SEL_CHECK = 'input[type=checkbox].',
|
||||
|
||||
isString = Y.Lang.isString;
|
||||
|
||||
function ConsoleFilters() {
|
||||
ConsoleFilters.superclass.constructor.apply(this,arguments);
|
||||
}
|
||||
|
||||
Y.mix(ConsoleFilters,{
|
||||
/**
|
||||
* Plugin name.
|
||||
*
|
||||
* @property ConsoleFilters.NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @default 'consoleFilters'
|
||||
*/
|
||||
NAME : 'consoleFilters',
|
||||
|
||||
/**
|
||||
* The namespace hung off the host object that this plugin will inhabit.
|
||||
*
|
||||
* @property ConsoleFilters.NS
|
||||
* @type String
|
||||
* @static
|
||||
* @default 'filter'
|
||||
*/
|
||||
NS : FILTER,
|
||||
|
||||
/**
|
||||
* Markup template used to create the container for the category filters.
|
||||
*
|
||||
* @property ConsoleFilters.CATEGORIES_TEMPLATE
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
CATEGORIES_TEMPLATE :
|
||||
'<div class="{categories}"></div>',
|
||||
|
||||
/**
|
||||
* Markup template used to create the container for the source filters.
|
||||
*
|
||||
* @property ConsoleFilters.SOURCES_TEMPLATE
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
SOURCES_TEMPLATE :
|
||||
'<div class="{sources}"></div>',
|
||||
|
||||
/**
|
||||
* Markup template used to create the category and source filter checkboxes.
|
||||
*
|
||||
* @property ConsoleFilters.FILTER_TEMPLATE
|
||||
* @type String
|
||||
* @static
|
||||
*/
|
||||
FILTER_TEMPLATE :
|
||||
// IE8 and FF3 don't permit breaking _between_ nowrap elements. IE8
|
||||
// doesn't understand (non spec) wbr tag, nor does it create text nodes
|
||||
// for spaces in innerHTML strings. The thin-space entity suffices to
|
||||
// create a breakable point.
|
||||
'<label class="{filter_label}">'+
|
||||
'<input type="checkbox" value="{filter_name}" '+
|
||||
'class="{filter} {filter_class}"> {filter_name}'+
|
||||
'</label> ',
|
||||
|
||||
/**
|
||||
* Classnames used by the templates when creating nodes.
|
||||
*
|
||||
* @property ConsoleFilters.CHROME_CLASSES
|
||||
* @type Object
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
CHROME_CLASSES : {
|
||||
categories : getCN(CONSOLE,FILTERS,'categories'),
|
||||
sources : getCN(CONSOLE,FILTERS,'sources'),
|
||||
category : getCN(CONSOLE,FILTER,CATEGORY),
|
||||
source : getCN(CONSOLE,FILTER,SOURCE),
|
||||
filter : getCN(CONSOLE,FILTER),
|
||||
filter_label : getCN(CONSOLE,FILTER,'label')
|
||||
},
|
||||
|
||||
ATTRS : {
|
||||
/**
|
||||
* Default visibility applied to new categories and sources.
|
||||
*
|
||||
* @attribute defaultVisibility
|
||||
* @type {Boolean}
|
||||
* @default true
|
||||
*/
|
||||
defaultVisibility : {
|
||||
value : true,
|
||||
validator : Y.Lang.isBoolean
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Map of entry categories to their visibility status. Update a
|
||||
* particular category's visibility by setting the subattribute to true
|
||||
* (visible) or false (hidden).</p>
|
||||
*
|
||||
* <p>For example, yconsole.filter.set('category.info', false) to hide
|
||||
* log entries with the category/logLevel of 'info'.</p>
|
||||
*
|
||||
* <p>Similarly, yconsole.filter.get('category.warn') will return a
|
||||
* boolean indicating whether that category is currently being included
|
||||
* in the UI.</p>
|
||||
*
|
||||
* <p>Unlike the YUI instance configuration's logInclude and logExclude
|
||||
* properties, filtered entries are only hidden from the UI, but
|
||||
* can be made visible again.</p>
|
||||
*
|
||||
* @attribute category
|
||||
* @type Object
|
||||
*/
|
||||
category : {
|
||||
value : {},
|
||||
validator : function (v,k) {
|
||||
return this._validateCategory(k,v);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* <p>Map of entry sources to their visibility status. Update a
|
||||
* particular sources's visibility by setting the subattribute to true
|
||||
* (visible) or false (hidden).</p>
|
||||
*
|
||||
* <p>For example, yconsole.filter.set('sources.slider', false) to hide
|
||||
* log entries originating from Y.Slider.</p>
|
||||
*
|
||||
* @attribute source
|
||||
* @type Object
|
||||
*/
|
||||
source : {
|
||||
value : {},
|
||||
validator : function (v,k) {
|
||||
return this._validateSource(k,v);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximum number of entries to store in the message cache. Use this to
|
||||
* limit the memory footprint in environments with heavy log usage.
|
||||
* By default, there is no limit (Number.POSITIVE_INFINITY).
|
||||
*
|
||||
* @attribute cacheLimit
|
||||
* @type {Number}
|
||||
* @default Number.POSITIVE_INFINITY
|
||||
*/
|
||||
cacheLimit : {
|
||||
value : Number.POSITIVE_INFINITY,
|
||||
setter : function (v) {
|
||||
if (Y.Lang.isNumber(v)) {
|
||||
this._cacheLimit = v;
|
||||
return v;
|
||||
} else {
|
||||
return Y.Attribute.INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(ConsoleFilters, Y.Plugin.Base, {
|
||||
|
||||
/**
|
||||
* Collection of all log messages passed through since the plugin's
|
||||
* instantiation. This holds all messages regardless of filter status.
|
||||
* Used as a single source of truth for repopulating the Console body when
|
||||
* filters are changed.
|
||||
*
|
||||
* @property _entries
|
||||
* @type Array
|
||||
* @protected
|
||||
*/
|
||||
_entries : null,
|
||||
|
||||
_cacheLimit : Number.POSITIVE_INFINITY,
|
||||
|
||||
/**
|
||||
* The container node created to house the category filters.
|
||||
*
|
||||
* @property _categories
|
||||
* @type Node
|
||||
* @protected
|
||||
*/
|
||||
_categories : null,
|
||||
|
||||
/**
|
||||
* The container node created to house the source filters.
|
||||
*
|
||||
* @property _sources
|
||||
* @type Node
|
||||
* @protected
|
||||
*/
|
||||
_sources : null,
|
||||
|
||||
/**
|
||||
* Initialize entries collection and attach listeners to host events and
|
||||
* methods.
|
||||
*
|
||||
* @method initializer
|
||||
* @protected
|
||||
*/
|
||||
initializer : function () {
|
||||
this._entries = [];
|
||||
|
||||
this.get(HOST).on("entry", this._onEntry, this);
|
||||
|
||||
this.doAfter("renderUI", this.renderUI);
|
||||
this.doAfter("syncUI", this.syncUI);
|
||||
this.doAfter("bindUI", this.bindUI);
|
||||
|
||||
this.doAfter("clearConsole", this._afterClearConsole);
|
||||
|
||||
if (this.get(HOST).get('rendered')) {
|
||||
this.renderUI();
|
||||
this.syncUI();
|
||||
this.bindUI();
|
||||
}
|
||||
|
||||
this.after("cacheLimitChange", this._afterCacheLimitChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes the plugin UI and unwires events.
|
||||
*
|
||||
* @method destructor
|
||||
* @protected
|
||||
*/
|
||||
destructor : function () {
|
||||
//TODO: grab last {consoleLimit} entries and update the console with
|
||||
//them (no filtering)
|
||||
this._entries = [];
|
||||
|
||||
if (this._categories) {
|
||||
this._categories.get(PARENT_NODE).removeChild(this._categories);
|
||||
}
|
||||
if (this._sources) {
|
||||
this._sources.get(PARENT_NODE).removeChild(this._sources);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds the category and source filter sections to the Console footer.
|
||||
*
|
||||
* @method renderUI
|
||||
* @protected
|
||||
*/
|
||||
renderUI : function () {
|
||||
var foot = this.get(HOST).get('contentBox').query(C_FOOT),
|
||||
html;
|
||||
|
||||
if (foot) {
|
||||
html = Y.substitute(
|
||||
ConsoleFilters.CATEGORIES_TEMPLATE,
|
||||
ConsoleFilters.CHROME_CLASSES);
|
||||
|
||||
this._categories = foot.appendChild(Y.Node.create(html));
|
||||
|
||||
html = Y.substitute(
|
||||
ConsoleFilters.SOURCES_TEMPLATE,
|
||||
ConsoleFilters.CHROME_CLASSES);
|
||||
|
||||
this._sources = foot.appendChild(Y.Node.create(html));
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Binds to checkbox click events and internal attribute change events to
|
||||
* maintain the UI state.
|
||||
*
|
||||
* @method bindUI
|
||||
* @protected
|
||||
*/
|
||||
bindUI : function () {
|
||||
this._categories.on('click', Y.bind(this._onCategoryCheckboxClick, this));
|
||||
|
||||
this._sources.on('click', Y.bind(this._onSourceCheckboxClick, this));
|
||||
|
||||
this.after('categoryChange',this._afterCategoryChange);
|
||||
this.after('sourceChange', this._afterSourceChange);
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the UI to be in accordance with the current state of the plugin.
|
||||
*
|
||||
* @method syncUI
|
||||
*/
|
||||
syncUI : function () {
|
||||
Y.each(this.get(CATEGORY), function (v, k) {
|
||||
this._uiSetCheckbox(CATEGORY, k, v);
|
||||
}, this);
|
||||
|
||||
Y.each(this.get(SOURCE), function (v, k) {
|
||||
this._uiSetCheckbox(SOURCE, k, v);
|
||||
}, this);
|
||||
|
||||
this.refreshConsole();
|
||||
},
|
||||
|
||||
/**
|
||||
* Ensures a filter is set up for any new categories or sources and
|
||||
* collects the messages in _entries. If the message is stamped with a
|
||||
* category or source that is currently being filtered out, the message
|
||||
* will not pass to the Console's print buffer.
|
||||
*
|
||||
* @method _onEntry
|
||||
* @param e {Event} the custom event object
|
||||
* @protected
|
||||
*/
|
||||
_onEntry : function (e) {
|
||||
this._entries.push(e.message);
|
||||
|
||||
var cat = CATEGORY_DOT + e.message.category,
|
||||
src = SOURCE_DOT + e.message.source,
|
||||
cat_filter = this.get(cat),
|
||||
src_filter = this.get(src),
|
||||
overLimit = this._entries.length - this._cacheLimit,
|
||||
visible;
|
||||
|
||||
if (overLimit > 0) {
|
||||
this._entries.splice(0, overLimit);
|
||||
}
|
||||
|
||||
if (cat_filter === undefined) {
|
||||
visible = this.get(DEF_VISIBILITY);
|
||||
this.set(cat, visible);
|
||||
cat_filter = visible;
|
||||
}
|
||||
|
||||
if (src_filter === undefined) {
|
||||
visible = this.get(DEF_VISIBILITY);
|
||||
this.set(src, visible);
|
||||
src_filter = visible;
|
||||
}
|
||||
|
||||
if (!cat_filter || !src_filter) {
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes the cached entries after a call to the Console's clearConsole().
|
||||
*
|
||||
* @method _afterClearConsole
|
||||
* @protected
|
||||
*/
|
||||
_afterClearConsole : function () {
|
||||
this._entries = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers the Console to update if a known category filter
|
||||
* changes value (e.g. visible => hidden). Updates the appropriate
|
||||
* checkbox's checked state if necessary.
|
||||
*
|
||||
* @method _afterCategoryChange
|
||||
* @param e {Event} the attribute change event object
|
||||
* @protected
|
||||
*/
|
||||
_afterCategoryChange : function (e) {
|
||||
var cat = e.subAttrName.replace(/category\./, EMPTY),
|
||||
before = e.prevVal,
|
||||
after = e.newVal;
|
||||
|
||||
// Don't update the console for new categories
|
||||
if (!cat || before[cat] !== undefined) {
|
||||
this.refreshConsole();
|
||||
|
||||
this._filterBuffer();
|
||||
}
|
||||
|
||||
if (cat && !e.fromUI) {
|
||||
this._uiSetCheckbox(CATEGORY, cat, after[cat]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Triggers the Console to update if a known source filter
|
||||
* changes value (e.g. visible => hidden). Updates the appropriate
|
||||
* checkbox's checked state if necessary.
|
||||
*
|
||||
* @method _afterSourceChange
|
||||
* @param e {Event} the attribute change event object
|
||||
* @protected
|
||||
*/
|
||||
_afterSourceChange : function (e) {
|
||||
var src = e.subAttrName.replace(/source\./, EMPTY),
|
||||
before = e.prevVal,
|
||||
after = e.newVal;
|
||||
|
||||
// Don't update the console for new sources
|
||||
if (!src || before[src] !== undefined) {
|
||||
this.refreshConsole();
|
||||
|
||||
this._filterBuffer();
|
||||
}
|
||||
|
||||
if (src && !e.fromUI) {
|
||||
this._uiSetCheckbox(SOURCE, src, after[src]);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Flushes the Console's print buffer of any entries that have a category
|
||||
* or source that is currently being excluded.
|
||||
*
|
||||
* @method _filterBuffer
|
||||
* @protected
|
||||
*/
|
||||
_filterBuffer : function () {
|
||||
var cats = this.get(CATEGORY),
|
||||
srcs = this.get(SOURCE),
|
||||
buffer = this.get(HOST).buffer,
|
||||
start = null,
|
||||
i;
|
||||
|
||||
for (i = buffer.length - 1; i >= 0; --i) {
|
||||
if (!cats[buffer[i].category] || !srcs[buffer[i].source]) {
|
||||
start = start || i;
|
||||
} else if (start) {
|
||||
buffer.splice(i,(start - i));
|
||||
start = null;
|
||||
}
|
||||
}
|
||||
if (start) {
|
||||
buffer.splice(0,start + 1);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Trims the cache of entries to the appropriate new length.
|
||||
*
|
||||
* @method _afterCacheLimitChange
|
||||
* @param e {Event} the attribute change event object
|
||||
* @protected
|
||||
*/
|
||||
_afterCacheLimitChange : function (e) {
|
||||
if (isFinite(e.newVal)) {
|
||||
var delta = this._entries.length - e.newVal;
|
||||
|
||||
if (delta > 0) {
|
||||
this._entries.splice(0,delta);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Repopulates the Console with entries appropriate to the current filter
|
||||
* settings.
|
||||
*
|
||||
* @method refreshConsole
|
||||
*/
|
||||
refreshConsole : function () {
|
||||
var entries = this._entries,
|
||||
host = this.get(HOST),
|
||||
body = host.get('contentBox').query(C_BODY),
|
||||
remaining = host.get('consoleLimit'),
|
||||
cats = this.get(CATEGORY),
|
||||
srcs = this.get(SOURCE),
|
||||
buffer = [],
|
||||
i,e;
|
||||
|
||||
if (body) {
|
||||
host._cancelPrintLoop();
|
||||
|
||||
// Evaluate all entries from latest to oldest
|
||||
for (i = entries.length - 1; i >= 0 && remaining >= 0; --i) {
|
||||
e = entries[i];
|
||||
if (cats[e.category] && srcs[e.source]) {
|
||||
buffer.unshift(e);
|
||||
--remaining;
|
||||
}
|
||||
}
|
||||
|
||||
body.set('innerHTML',EMPTY);
|
||||
host.buffer = buffer;
|
||||
host.printBuffer();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Updates the checked property of a filter checkbox of the specified type.
|
||||
* If no checkbox is found for the input params, one is created.
|
||||
*
|
||||
* @method _uiSetCheckbox
|
||||
* @param type {String} 'category' or 'source'
|
||||
* @param item {String} the name of the filter (e.g. 'info', 'event')
|
||||
* @param checked {Boolean} value to set the checkbox's checked property
|
||||
* @protected
|
||||
*/
|
||||
_uiSetCheckbox : function (type, item, checked) {
|
||||
if (type && item) {
|
||||
var container = type === CATEGORY ?
|
||||
this._categories :
|
||||
this._sources,
|
||||
sel = SEL_CHECK + getCN(CONSOLE,FILTER,item),
|
||||
checkbox = container.query(sel),
|
||||
host;
|
||||
|
||||
if (!checkbox) {
|
||||
host = this.get(HOST);
|
||||
|
||||
this._createCheckbox(container, item);
|
||||
|
||||
checkbox = container.query(sel);
|
||||
|
||||
host._uiSetHeight(host.get('height'));
|
||||
}
|
||||
|
||||
checkbox.set(CHECKED, checked);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Passes checkbox clicks on to the category attribute.
|
||||
*
|
||||
* @method _onCategoryCheckboxClick
|
||||
* @param e {Event} the DOM event
|
||||
* @protected
|
||||
*/
|
||||
_onCategoryCheckboxClick : function (e) {
|
||||
var t = e.target, cat;
|
||||
|
||||
if (t.hasClass(ConsoleFilters.CHROME_CLASSES.filter)) {
|
||||
cat = t.get('value');
|
||||
if (cat && cat in this.get(CATEGORY)) {
|
||||
this.set(CATEGORY_DOT + cat, t.get(CHECKED), { fromUI: true });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Passes checkbox clicks on to the source attribute.
|
||||
*
|
||||
* @method _onSourceCheckboxClick
|
||||
* @param e {Event} the DOM event
|
||||
* @protected
|
||||
*/
|
||||
_onSourceCheckboxClick : function (e) {
|
||||
var t = e.target, src;
|
||||
|
||||
if (t.hasClass(ConsoleFilters.CHROME_CLASSES.filter)) {
|
||||
src = t.get('value');
|
||||
if (src && src in this.get(SOURCE)) {
|
||||
this.set(SOURCE_DOT + src, t.get(CHECKED), { fromUI: true });
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides any number of categories from the UI. Convenience method for
|
||||
* myConsole.filter.set('category.foo', false); set('category.bar', false);
|
||||
* and so on.
|
||||
*
|
||||
* @method hideCategory
|
||||
* @param cat* {String} 1..n categories to filter out of the UI
|
||||
*/
|
||||
hideCategory : function (cat, multiple) {
|
||||
if (isString(multiple)) {
|
||||
Y.Array.each(arguments, arguments.callee, this);
|
||||
} else {
|
||||
this.set(CATEGORY_DOT + cat, false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows any number of categories in the UI. Convenience method for
|
||||
* myConsole.filter.set('category.foo', true); set('category.bar', true);
|
||||
* and so on.
|
||||
*
|
||||
* @method showCategory
|
||||
* @param cat* {String} 1..n categories to allow to display in the UI
|
||||
*/
|
||||
showCategory : function (cat, multiple) {
|
||||
if (isString(multiple)) {
|
||||
Y.Array.each(arguments, arguments.callee, this);
|
||||
} else {
|
||||
this.set(CATEGORY_DOT + cat, true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Hides any number of sources from the UI. Convenience method for
|
||||
* myConsole.filter.set('source.foo', false); set('source.bar', false);
|
||||
* and so on.
|
||||
*
|
||||
* @method hideSource
|
||||
* @param src* {String} 1..n sources to filter out of the UI
|
||||
*/
|
||||
hideSource : function (src, multiple) {
|
||||
if (isString(multiple)) {
|
||||
Y.Array.each(arguments, arguments.callee, this);
|
||||
} else {
|
||||
this.set(SOURCE_DOT + src, false);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Shows any number of sources in the UI. Convenience method for
|
||||
* myConsole.filter.set('source.foo', true); set('source.bar', true);
|
||||
* and so on.
|
||||
*
|
||||
* @method showSource
|
||||
* @param src* {String} 1..n sources to allow to display in the UI
|
||||
*/
|
||||
showSource : function (src, multiple) {
|
||||
if (isString(multiple)) {
|
||||
Y.Array.each(arguments, arguments.callee, this);
|
||||
} else {
|
||||
this.set(SOURCE_DOT + src, true);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Creates a checkbox and label from the ConsoleFilters.FILTER_TEMPLATE for
|
||||
* the provided type and name. The checkbox and label are appended to the
|
||||
* container node passes as the first arg.
|
||||
*
|
||||
* @method _createCheckbox
|
||||
* @param container {Node} the parentNode of the new checkbox and label
|
||||
* @param name {String} the identifier of the filter
|
||||
* @protected
|
||||
*/
|
||||
_createCheckbox : function (container, name) {
|
||||
var info = Y.merge(ConsoleFilters.CHROME_CLASSES, {
|
||||
filter_name : name,
|
||||
filter_class : getCN(CONSOLE, FILTER, name)
|
||||
}),
|
||||
node = Y.Node.create(
|
||||
Y.substitute(ConsoleFilters.FILTER_TEMPLATE, info));
|
||||
|
||||
container.appendChild(node);
|
||||
},
|
||||
|
||||
/**
|
||||
* Validates category updates are objects and the subattribute is not too
|
||||
* deep.
|
||||
*
|
||||
* @method _validateCategory
|
||||
* @param cat {String} the new category:visibility map
|
||||
* @param v {String} the subattribute path updated
|
||||
* @return Boolean
|
||||
* @protected
|
||||
*/
|
||||
_validateCategory : function (cat, v) {
|
||||
return Y.Lang.isObject(v,true) && cat.split(/\./).length < 3;
|
||||
},
|
||||
|
||||
/**
|
||||
* Validates source updates are objects and the subattribute is not too
|
||||
* deep.
|
||||
*
|
||||
* @method _validateSource
|
||||
* @param cat {String} the new source:visibility map
|
||||
* @param v {String} the subattribute path updated
|
||||
* @return Boolean
|
||||
* @protected
|
||||
*/
|
||||
_validateSource : function (src, v) {
|
||||
return Y.Lang.isObject(v,true) && src.split(/\./).length < 3;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').ConsoleFilters = ConsoleFilters;
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['console','plugin']});
|
||||
9
jssource/src_files/include/javascript/yui3/build/console/console-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/console/console-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1478
jssource/src_files/include/javascript/yui3/build/console/console.js
vendored
Normal file
1478
jssource/src_files/include/javascript/yui3/build/console/console.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
jssource/src_files/include/javascript/yui3/build/cookie/cookie-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/cookie/cookie-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("cookie",function(C){var K=C.Lang,I=C.Object,G=null,D=K.isString,P=K.isObject,F=K.isUndefined,E=K.isFunction,H=encodeURIComponent,B=decodeURIComponent,N=C.config.doc;function J(L){throw new TypeError(L);}function M(L){if(!D(L)||L===""){J("Cookie name must be a non-empty string.");}}function A(L){if(!D(L)||L===""){J("Subcookie name must be a non-empty string.");}}C.Cookie={_createCookieString:function(Q,T,R,O){O=O||{};var V=H(Q)+"="+(R?H(T):T),L=O.expires,U=O.path,S=O.domain;if(P(O)){if(L instanceof Date){V+="; expires="+L.toUTCString();}if(D(U)&&U!==""){V+="; path="+U;}if(D(S)&&S!==""){V+="; domain="+S;}if(O.secure===true){V+="; secure";}}return V;},_createCookieHashString:function(L){if(!P(L)){J("Cookie._createCookieHashString(): Argument must be an object.");}var O=[];I.each(L,function(R,Q){if(!E(R)&&!F(R)){O.push(H(Q)+"="+H(String(R)));}});return O.join("&");},_parseCookieHash:function(S){var R=S.split("&"),T=G,Q={};if(S.length){for(var O=0,L=R.length;O<L;O++){T=R[O].split("=");Q[B(T[0])]=B(T[1]);}}return Q;},_parseCookieString:function(W,Y){var X={};if(D(W)&&W.length>0){var L=(Y===false?function(Z){return Z;}:B),U=W.split(/;\s/g),V=G,O=G,R=G;for(var Q=0,S=U.length;Q<S;Q++){R=U[Q].match(/([^=]+)=/i);if(R instanceof Array){try{V=B(R[1]);O=L(U[Q].substring(R[1].length+1));}catch(T){}}else{V=B(U[Q]);O="";}X[V]=O;}}return X;},exists:function(L){M(L);var O=this._parseCookieString(N.cookie,true);return O.hasOwnProperty(L);},get:function(O,L){M(O);var S,Q,R;if(E(L)){R=L;L={};}else{if(P(L)){R=L.converter;}else{L={};}}S=this._parseCookieString(N.cookie,!L.raw);Q=S[O];if(F(Q)){return G;}if(!E(R)){return Q;}else{return R(Q);}},getSub:function(L,Q,O){var R=this.getSubs(L);if(R!==G){A(Q);if(F(R[Q])){return G;}if(!E(O)){return R[Q];}else{return O(R[Q]);}}else{return G;}},getSubs:function(L){M(L);var O=this._parseCookieString(N.cookie,false);if(D(O[L])){return this._parseCookieHash(O[L]);}return G;},remove:function(O,L){M(O);L=C.merge(L||{},{expires:new Date(0)});return this.set(O,"",L);},removeSub:function(O,S,L){M(O);A(S);L=L||{};var R=this.getSubs(O);if(P(R)&&R.hasOwnProperty(S)){delete R[S];if(!L.removeIfEmpty){return this.setSubs(O,R,L);}else{for(var Q in R){if(R.hasOwnProperty(Q)&&!E(R[Q])&&!F(R[Q])){return this.setSubs(O,R,L);}}return this.remove(O,L);}}else{return"";}},set:function(O,Q,L){M(O);if(F(Q)){J("Cookie.set(): Value cannot be undefined.");}L=L||{};var R=this._createCookieString(O,Q,!L.raw,L);N.cookie=R;return R;},setSub:function(O,R,Q,L){M(O);A(R);if(F(Q)){J("Cookie.setSub(): Subcookie value cannot be undefined.");}var S=this.getSubs(O);if(!P(S)){S={};}S[R]=Q;return this.setSubs(O,S,L);},setSubs:function(O,Q,L){M(O);if(!P(Q)){J("Cookie.setSubs(): Cookie value must be an object.");}var R=this._createCookieString(O,this._createCookieHashString(Q),false,L);N.cookie=R;return R;}};},"3.0.0",{requires:["yui-base"]});
|
||||
491
jssource/src_files/include/javascript/yui3/build/cookie/cookie.js
vendored
Normal file
491
jssource/src_files/include/javascript/yui3/build/cookie/cookie.js
vendored
Normal file
@@ -0,0 +1,491 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('cookie', function(Y) {
|
||||
|
||||
/**
|
||||
* Utilities for cookie management
|
||||
* @module cookie
|
||||
*/
|
||||
|
||||
//shortcuts
|
||||
var L = Y.Lang,
|
||||
O = Y.Object,
|
||||
NULL = null,
|
||||
|
||||
//shortcuts to functions
|
||||
isString = L.isString,
|
||||
isObject = L.isObject,
|
||||
isUndefined = L.isUndefined,
|
||||
isFunction = L.isFunction,
|
||||
encode = encodeURIComponent,
|
||||
decode = decodeURIComponent,
|
||||
|
||||
//shortcut to document
|
||||
doc = Y.config.doc;
|
||||
|
||||
/*
|
||||
* Throws an error message.
|
||||
*/
|
||||
function error(message){
|
||||
throw new TypeError(message);
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks the validity of a cookie name.
|
||||
*/
|
||||
function validateCookieName(name){
|
||||
if (!isString(name) || name === ""){
|
||||
error("Cookie name must be a non-empty string.");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Checks the validity of a subcookie name.
|
||||
*/
|
||||
function validateSubcookieName(subName){
|
||||
if (!isString(subName) || subName === ""){
|
||||
error("Subcookie name must be a non-empty string.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie utility.
|
||||
* @class Cookie
|
||||
* @static
|
||||
*/
|
||||
Y.Cookie = {
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Private Methods
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Creates a cookie string that can be assigned into document.cookie.
|
||||
* @param {String} name The name of the cookie.
|
||||
* @param {String} value The value of the cookie.
|
||||
* @param {Boolean} encodeValue True to encode the value, false to leave as-is.
|
||||
* @param {Object} options (Optional) Options for the cookie.
|
||||
* @return {String} The formatted cookie string.
|
||||
* @method _createCookieString
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
_createCookieString : function (name /*:String*/, value /*:Variant*/, encodeValue /*:Boolean*/, options /*:Object*/) /*:String*/ {
|
||||
|
||||
options = options || {};
|
||||
|
||||
var text /*:String*/ = encode(name) + "=" + (encodeValue ? encode(value) : value),
|
||||
expires = options.expires,
|
||||
path = options.path,
|
||||
domain = options.domain;
|
||||
|
||||
|
||||
if (isObject(options)){
|
||||
//expiration date
|
||||
if (expires instanceof Date){
|
||||
text += "; expires=" + expires.toUTCString();
|
||||
}
|
||||
|
||||
//path
|
||||
if (isString(path) && path !== ""){
|
||||
text += "; path=" + path;
|
||||
}
|
||||
|
||||
//domain
|
||||
if (isString(domain) && domain !== ""){
|
||||
text += "; domain=" + domain;
|
||||
}
|
||||
|
||||
//secure
|
||||
if (options.secure === true){
|
||||
text += "; secure";
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
},
|
||||
|
||||
/**
|
||||
* Formats a cookie value for an object containing multiple values.
|
||||
* @param {Object} hash An object of key-value pairs to create a string for.
|
||||
* @return {String} A string suitable for use as a cookie value.
|
||||
* @method _createCookieHashString
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
_createCookieHashString : function (hash /*:Object*/) /*:String*/ {
|
||||
if (!isObject(hash)){
|
||||
error("Cookie._createCookieHashString(): Argument must be an object.");
|
||||
}
|
||||
|
||||
var text /*:Array*/ = [];
|
||||
|
||||
O.each(hash, function(value, key){
|
||||
if (!isFunction(value) && !isUndefined(value)){
|
||||
text.push(encode(key) + "=" + encode(String(value)));
|
||||
}
|
||||
});
|
||||
|
||||
return text.join("&");
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a cookie hash string into an object.
|
||||
* @param {String} text The cookie hash string to parse (format: n1=v1&n2=v2).
|
||||
* @return {Object} An object containing entries for each cookie value.
|
||||
* @method _parseCookieHash
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
_parseCookieHash : function (text) {
|
||||
|
||||
var hashParts = text.split("&"),
|
||||
hashPart = NULL,
|
||||
hash = {};
|
||||
|
||||
if (text.length){
|
||||
for (var i=0, len=hashParts.length; i < len; i++){
|
||||
hashPart = hashParts[i].split("=");
|
||||
hash[decode(hashPart[0])] = decode(hashPart[1]);
|
||||
}
|
||||
}
|
||||
|
||||
return hash;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses a cookie string into an object representing all accessible cookies.
|
||||
* @param {String} text The cookie string to parse.
|
||||
* @param {Boolean} shouldDecode (Optional) Indicates if the cookie values should be decoded or not. Default is true.
|
||||
* @return {Object} An object containing entries for each accessible cookie.
|
||||
* @method _parseCookieString
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
_parseCookieString : function (text /*:String*/, shouldDecode /*:Boolean*/) /*:Object*/ {
|
||||
|
||||
var cookies /*:Object*/ = {};
|
||||
|
||||
if (isString(text) && text.length > 0) {
|
||||
|
||||
var decodeValue = (shouldDecode === false ? function(s){return s;} : decode),
|
||||
cookieParts = text.split(/;\s/g),
|
||||
cookieName = NULL,
|
||||
cookieValue = NULL,
|
||||
cookieNameValue = NULL;
|
||||
|
||||
for (var i=0, len=cookieParts.length; i < len; i++){
|
||||
|
||||
//check for normally-formatted cookie (name-value)
|
||||
cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
|
||||
if (cookieNameValue instanceof Array){
|
||||
try {
|
||||
cookieName = decode(cookieNameValue[1]);
|
||||
cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1));
|
||||
} catch (ex){
|
||||
//intentionally ignore the cookie - the encoding is wrong
|
||||
}
|
||||
} else {
|
||||
//means the cookie does not have an "=", so treat it as a boolean flag
|
||||
cookieName = decode(cookieParts[i]);
|
||||
cookieValue = "";
|
||||
}
|
||||
cookies[cookieName] = cookieValue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return cookies;
|
||||
},
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// Public Methods
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Determines if the cookie with the given name exists. This is useful for
|
||||
* Boolean cookies (those that do not follow the name=value convention).
|
||||
* @param {String} name The name of the cookie to check.
|
||||
* @return {Boolean} True if the cookie exists, false if not.
|
||||
* @method exists
|
||||
* @static
|
||||
*/
|
||||
exists: function(name) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
var cookies = this._parseCookieString(doc.cookie, true);
|
||||
|
||||
return cookies.hasOwnProperty(name);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the cookie value for the given name.
|
||||
* @param {String} name The name of the cookie to retrieve.
|
||||
* @param {Function|Object} options (Optional) An object containing one or more
|
||||
* cookie options: raw (true/false) and converter (a function).
|
||||
* The converter function is run on the value before returning it. The
|
||||
* function is not used if the cookie doesn't exist. The function can be
|
||||
* passed instead of the options object for backwards compatibility. When
|
||||
* raw is set to true, the cookie value is not URI decoded.
|
||||
* @return {Variant} If no converter is specified, returns a string or null if
|
||||
* the cookie doesn't exist. If the converter is specified, returns the value
|
||||
* returned from the converter or null if the cookie doesn't exist.
|
||||
* @method get
|
||||
* @static
|
||||
*/
|
||||
get : function (name, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
var cookies,
|
||||
cookie,
|
||||
converter;
|
||||
|
||||
//if options is a function, then it's the converter
|
||||
if (isFunction(options)) {
|
||||
converter = options;
|
||||
options = {};
|
||||
} else if (isObject(options)) {
|
||||
converter = options.converter;
|
||||
} else {
|
||||
options = {};
|
||||
}
|
||||
|
||||
cookies = this._parseCookieString(doc.cookie, !options.raw);
|
||||
cookie = cookies[name];
|
||||
|
||||
//should return null, not undefined if the cookie doesn't exist
|
||||
if (isUndefined(cookie)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!isFunction(converter)){
|
||||
return cookie;
|
||||
} else {
|
||||
return converter(cookie);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns the value of a subcookie.
|
||||
* @param {String} name The name of the cookie to retrieve.
|
||||
* @param {String} subName The name of the subcookie to retrieve.
|
||||
* @param {Function} converter (Optional) A function to run on the value before returning
|
||||
* it. The function is not used if the cookie doesn't exist.
|
||||
* @return {Variant} If the cookie doesn't exist, null is returned. If the subcookie
|
||||
* doesn't exist, null if also returned. If no converter is specified and the
|
||||
* subcookie exists, a string is returned. If a converter is specified and the
|
||||
* subcookie exists, the value returned from the converter is returned.
|
||||
* @method getSub
|
||||
* @static
|
||||
*/
|
||||
getSub : function (name /*:String*/, subName /*:String*/, converter /*:Function*/) /*:Variant*/ {
|
||||
|
||||
var hash /*:Variant*/ = this.getSubs(name);
|
||||
|
||||
if (hash !== NULL) {
|
||||
|
||||
validateSubcookieName(subName); //throws error
|
||||
|
||||
if (isUndefined(hash[subName])){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!isFunction(converter)){
|
||||
return hash[subName];
|
||||
} else {
|
||||
return converter(hash[subName]);
|
||||
}
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns an object containing name-value pairs stored in the cookie with the given name.
|
||||
* @param {String} name The name of the cookie to retrieve.
|
||||
* @return {Object} An object of name-value pairs if the cookie with the given name
|
||||
* exists, null if it does not.
|
||||
* @method getSubs
|
||||
* @static
|
||||
*/
|
||||
getSubs : function (name) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
var cookies = this._parseCookieString(doc.cookie, false);
|
||||
if (isString(cookies[name])){
|
||||
return this._parseCookieHash(cookies[name]);
|
||||
}
|
||||
return NULL;
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a cookie from the machine by setting its expiration date to
|
||||
* sometime in the past.
|
||||
* @param {String} name The name of the cookie to remove.
|
||||
* @param {Object} options (Optional) An object containing one or more
|
||||
* cookie options: path (a string), domain (a string),
|
||||
* and secure (true/false). The expires option will be overwritten
|
||||
* by the method.
|
||||
* @return {String} The created cookie string.
|
||||
* @method remove
|
||||
* @static
|
||||
*/
|
||||
remove : function (name, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
//set options
|
||||
options = Y.merge(options || {}, {
|
||||
expires: new Date(0)
|
||||
});
|
||||
|
||||
//set cookie
|
||||
return this.set(name, "", options);
|
||||
},
|
||||
|
||||
/**
|
||||
* Removes a sub cookie with a given name.
|
||||
* @param {String} name The name of the cookie in which the subcookie exists.
|
||||
* @param {String} subName The name of the subcookie to remove.
|
||||
* @param {Object} options (Optional) An object containing one or more
|
||||
* cookie options: path (a string), domain (a string), expires (a Date object),
|
||||
* removeIfEmpty (true/false), and secure (true/false). This must be the same
|
||||
* settings as the original subcookie.
|
||||
* @return {String} The created cookie string.
|
||||
* @method removeSub
|
||||
* @static
|
||||
*/
|
||||
removeSub : function(name, subName, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
validateSubcookieName(subName); //throws error
|
||||
|
||||
options = options || {};
|
||||
|
||||
//get all subcookies for this cookie
|
||||
var subs = this.getSubs(name);
|
||||
|
||||
//delete the indicated subcookie
|
||||
if (isObject(subs) && subs.hasOwnProperty(subName)){
|
||||
delete subs[subName];
|
||||
|
||||
if (!options.removeIfEmpty) {
|
||||
//reset the cookie
|
||||
|
||||
return this.setSubs(name, subs, options);
|
||||
} else {
|
||||
//reset the cookie if there are subcookies left, else remove
|
||||
for (var key in subs){
|
||||
if (subs.hasOwnProperty(key) && !isFunction(subs[key]) && !isUndefined(subs[key])){
|
||||
return this.setSubs(name, subs, options);
|
||||
}
|
||||
}
|
||||
|
||||
return this.remove(name, options);
|
||||
}
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a cookie with a given name and value.
|
||||
* @param {String} name The name of the cookie to set.
|
||||
* @param {Variant} value The value to set for the cookie.
|
||||
* @param {Object} options (Optional) An object containing one or more
|
||||
* cookie options: path (a string), domain (a string), expires (a Date object),
|
||||
* secure (true/false), and raw (true/false). Setting raw to true indicates
|
||||
* that the cookie should not be URI encoded before being set.
|
||||
* @return {String} The created cookie string.
|
||||
* @method set
|
||||
* @static
|
||||
*/
|
||||
set : function (name, value, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
if (isUndefined(value)){
|
||||
error("Cookie.set(): Value cannot be undefined.");
|
||||
}
|
||||
|
||||
options = options || {};
|
||||
|
||||
var text = this._createCookieString(name, value, !options.raw, options);
|
||||
doc.cookie = text;
|
||||
return text;
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a sub cookie with a given name to a particular value.
|
||||
* @param {String} name The name of the cookie to set.
|
||||
* @param {String} subName The name of the subcookie to set.
|
||||
* @param {Variant} value The value to set.
|
||||
* @param {Object} options (Optional) An object containing one or more
|
||||
* cookie options: path (a string), domain (a string), expires (a Date object),
|
||||
* and secure (true/false).
|
||||
* @return {String} The created cookie string.
|
||||
* @method setSub
|
||||
* @static
|
||||
*/
|
||||
setSub : function (name, subName, value, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
validateSubcookieName(subName); //throws error
|
||||
|
||||
if (isUndefined(value)){
|
||||
error("Cookie.setSub(): Subcookie value cannot be undefined.");
|
||||
}
|
||||
|
||||
var hash = this.getSubs(name);
|
||||
|
||||
if (!isObject(hash)){
|
||||
hash = {};
|
||||
}
|
||||
|
||||
hash[subName] = value;
|
||||
|
||||
return this.setSubs(name, hash, options);
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Sets a cookie with a given name to contain a hash of name-value pairs.
|
||||
* @param {String} name The name of the cookie to set.
|
||||
* @param {Object} value An object containing name-value pairs.
|
||||
* @param {Object} options (Optional) An object containing one or more
|
||||
* cookie options: path (a string), domain (a string), expires (a Date object),
|
||||
* and secure (true/false).
|
||||
* @return {String} The created cookie string.
|
||||
* @method setSubs
|
||||
* @static
|
||||
*/
|
||||
setSubs : function (name, value, options) {
|
||||
|
||||
validateCookieName(name); //throws error
|
||||
|
||||
if (!isObject(value)){
|
||||
error("Cookie.setSubs(): Cookie value must be an object.");
|
||||
}
|
||||
|
||||
var text /*:String*/ = this._createCookieString(name, this._createCookieHashString(value), false, options);
|
||||
doc.cookie = text;
|
||||
return text;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['yui-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-array-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-array-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dataschema-array",function(C){var A=C.Lang,B={apply:function(F,G){var D=G,E={results:[],meta:{}};if(A.isArray(D)){if(A.isArray(F.resultFields)){E=B._parseResults(F.resultFields,D,E);}else{E.results=D;}}else{E.error=new Error("Array schema parse failure");}return E;},_parseResults:function(H,K,D){var G=[],O,N,I,J,M,L,F,E;for(F=K.length-1;F>-1;F--){O={};N=K[F];I=(A.isObject(N)&&!A.isFunction(N))?2:(A.isArray(N))?1:(A.isString(N))?0:-1;if(I>0){for(E=H.length-1;E>-1;E--){J=H[E];M=(!A.isUndefined(J.key))?J.key:J;L=(!A.isUndefined(N[M]))?N[M]:N[E];O[M]=C.DataSchema.Base.parse(L,J);}}else{if(I===0){O=N;}else{O=null;}}G[F]=O;}D.results=G;return D;}};C.DataSchema.Array=C.mix(B,C.DataSchema.Base);},"3.0.0",{requires:["dataschema-base"]});
|
||||
107
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-array.js
vendored
Normal file
107
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-array.js
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults(schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse(value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-base-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-base-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dataschema-base",function(B){var A=B.Lang,C={apply:function(D,E){return E;},parse:function(D,E){if(E.parser){var F=(A.isFunction(E.parser))?E.parser:B.Parsers[E.parser+""];if(F){D=F.call(this,D);}else{}}return D;}};B.namespace("DataSchema").Base=C;B.namespace("Parsers");},"3.0.0",{requires:["base"]});
|
||||
73
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-base.js
vendored
Normal file
73
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-base.js
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataSchema utility provides a common configurable interface for widgets to
|
||||
* apply a given schema to a variety of data.
|
||||
*
|
||||
* @module dataschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base DataSchema implementation, which can be extended to
|
||||
* create DataSchemas for specific data formats, such XML, JSON, text and
|
||||
* arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-base
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
/**
|
||||
* Base class for the YUI DataSchema Utility.
|
||||
* @class DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaBase = {
|
||||
/**
|
||||
* Overridable method returns data as-is.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies field parser, if defined
|
||||
*
|
||||
* @method parse
|
||||
* @param value {Object} Original value.
|
||||
* @param field {Object} Field.
|
||||
* @return {Object} Type-converted value.
|
||||
*/
|
||||
parse: function(value, field) {
|
||||
if(field.parser) {
|
||||
var parser = (LANG.isFunction(field.parser)) ?
|
||||
field.parser : Y.Parsers[field.parser+''];
|
||||
if(parser) {
|
||||
value = parser.call(this, value);
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
Y.namespace("DataSchema").Base = SchemaBase;
|
||||
Y.namespace("Parsers");
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-json-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-json-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dataschema-json",function(C){var A=C.Lang,B={getPath:function(D){var G=null,F=[],E=0;if(D){D=D.replace(/\[(['"])(.*?)\1\]/g,function(I,H,J){F[E]=J;return".@"+(E++);}).replace(/\[(\d+)\]/g,function(I,H){F[E]=parseInt(H,10)|0;return".@"+(E++);}).replace(/^\./,"");if(!/[^\w\.\$@]/.test(D)){G=D.split(".");for(E=G.length-1;E>=0;--E){if(G[E].charAt(0)==="@"){G[E]=F[parseInt(G[E].substr(1),10)];}}}else{}}return G;},getLocationValue:function(G,F){var E=0,D=G.length;for(;E<D;E++){if(!A.isUndefined(F[G[E]])){F=F[G[E]];}else{F=undefined;break;}}return F;},apply:function(F,G){var D=G,E={results:[],meta:{}};if(!A.isObject(G)){try{D=C.JSON.parse(G);}catch(H){E.error=H;return E;}}if(A.isObject(D)&&F){if(!A.isUndefined(F.resultListLocator)){E=B._parseResults(F,D,E);}if(!A.isUndefined(F.metaFields)){E=B._parseMeta(F.metaFields,D,E);}}else{E.error=new Error("JSON schema parse failure");}return E;},_parseResults:function(H,D,G){var F=[],I,E;if(H.resultListLocator){I=B.getPath(H.resultListLocator);if(I){F=B.getLocationValue(I,D);if(F===undefined){G.results=[];E=new Error("JSON results retrieval failure");}else{if(A.isArray(H.resultFields)&&A.isArray(F)){G=B._getFieldValues(H.resultFields,F,G);}else{G.results=[];E=new Error("JSON Schema fields retrieval failure");}}}else{E=new Error("JSON Schema results locator failure");}if(E){G.error=E;}}return G;},_getFieldValues:function(K,P,E){var G=[],M=K.length,H,F,O,Q,S,D,J=[],N=[],L=[],R,I;for(H=0;H<M;H++){O=K[H];Q=O.key||O;S=B.getPath(Q);if(S){if(S.length===1){J[J.length]={key:Q,path:S[0]};}else{N[N.length]={key:Q,path:S};}}else{}D=(A.isFunction(O.parser))?O.parser:C.Parsers[O.parser+""];if(D){L[L.length]={key:Q,parser:D};}}for(H=P.length-1;H>=0;--H){I={};R=P[H];if(R){for(F=J.length-1;F>=0;--F){I[J[F].key]=C.DataSchema.Base.parse((A.isUndefined(R[J[F].path])?R[F]:R[J[F].path]),J[F]);}for(F=N.length-1;F>=0;--F){I[N[F].key]=C.DataSchema.Base.parse((B.getLocationValue(N[F].path,R)),N[F]);}for(F=L.length-1;F>=0;--F){Q=L[F].key;I[Q]=L[F].parser(I[Q]);if(A.isUndefined(I[Q])){I[Q]=null;}}G[H]=I;}}E.results=G;return E;},_parseMeta:function(G,D,F){if(A.isObject(G)){var E,H;for(E in G){if(G.hasOwnProperty(E)){H=B.getPath(G[E]);if(H&&D){F.meta[E]=B.getLocationValue(H,D);}}}}else{F.error=new Error("JSON meta data retrieval failure");}return F;}};C.DataSchema.JSON=C.mix(B,C.DataSchema.Base);},"3.0.0",{requires:["json","dataschema-base"]});
|
||||
294
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-json.js
vendored
Normal file
294
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-json.js
vendored
Normal file
@@ -0,0 +1,294 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(!LANG.isUndefined(data[path[i]])) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults(schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(schema.resultFields) && LANG.isArray(results)) {
|
||||
data_out = SchemaJSON._getFieldValues(schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse(
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse(
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser(record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['json', 'dataschema-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-text-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-text-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dataschema-text",function(C){var B=C.Lang,A={apply:function(F,G){var D=G,E={results:[],meta:{}};if(B.isString(D)&&B.isString(F.resultDelimiter)){E=A._parseResults(F,D,E);}else{E.error=new Error("Text schema parse failure");}return E;},_parseResults:function(D,K,E){var I=D.resultDelimiter,H=[],L,P,S,R,J,N,Q,O,G,F,M=K.length-I.length;if(K.substr(M)==I){K=K.substr(0,M);}L=K.split(D.resultDelimiter);for(G=L.length-1;G>-1;G--){S={};R=L[G];if(B.isString(D.fieldDelimiter)){P=R.split(D.fieldDelimiter);if(B.isArray(D.resultFields)){J=D.resultFields;for(F=J.length-1;F>-1;F--){N=J[F];Q=(!B.isUndefined(N.key))?N.key:N;O=(!B.isUndefined(P[Q]))?P[Q]:P[F];S[Q]=C.DataSchema.Base.parse(O,N);}}}else{S=R;}H[G]=S;}E.results=H;return E;}};C.DataSchema.Text=C.mix(A,C.DataSchema.Base);},"3.0.0",{requires:["dataschema-base"]});
|
||||
116
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-text.js
vendored
Normal file
116
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-text.js
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults(schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse(value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-xml-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-xml-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dataschema-xml",function(C){var B=C.Lang,A={apply:function(F,G){var D=G,E={results:[],meta:{}};if(D&&D.nodeType&&(D.nodeType===9||D.nodeType===1||D.nodeType===11)&&F){E=A._parseResults(F,D,E);E=A._parseMeta(F.metaFields,D,E);}else{E.error=new Error("XML schema parse failure");}return E;},_getLocationValue:function(K,H){var F=K.locator||K.key||K,E=H.ownerDocument||H,D,G,I=null;try{if(!B.isUndefined(E.evaluate)){D=E.evaluate(F,H,E.createNSResolver(!H.ownerDocument?H.documentElement:H.ownerDocument.documentElement),0,null);while(G=D.iterateNext()){I=G.textContent;}}else{E.setProperty("SelectionLanguage","XPath");D=H.selectNodes(F)[0];I=D.value||D.text||null;}return C.DataSchema.Base.parse(I,K);}catch(J){}},_parseMeta:function(H,G,F){if(B.isObject(H)){var E,D=G.ownerDocument||G;for(E in H){if(H.hasOwnProperty(E)){F.meta[E]=A._getLocationValue(H[E],D);}}}return F;},_parseResults:function(F,K,G){if(F.resultListLocator&&B.isArray(F.resultFields)){var E=K.getElementsByTagName(F.resultListLocator),L=F.resultFields,J=[],D,M,N,I,H;if(E.length){for(I=E.length-1;I>=0;I--){N={};D=E[I];for(H=L.length-1;H>=0;H--){M=L[H];N[M.key||M]=A._getLocationValue(M,D);}J[I]=N;}G.results=J;}else{G.error=new Error("XML schema result nodes retrieval failure");}}return G;}};C.DataSchema.XML=C.mix(A,C.DataSchema.Base);},"3.0.0",{requires:["dataschema-base"]});
|
||||
164
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-xml.js
vendored
Normal file
164
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema-xml.js
vendored
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (xmldoc.nodeType === 9 || xmldoc.nodeType === 1 || xmldoc.nodeType === 11) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults(schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta(schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
// Standards mode
|
||||
if(!LANG.isUndefined(xmldoc.evaluate)) {
|
||||
result = xmldoc.evaluate(locator, context, xmldoc.createNSResolver(!context.ownerDocument ? context.documentElement : context.ownerDocument.documentElement), 0, null);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent;
|
||||
}
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
result = context.selectNodes(locator)[0];
|
||||
value = result.value || result.text || null;
|
||||
}
|
||||
return Y.DataSchema.Base.parse(value, field);
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue(metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, xmldoc_in, data_out) {
|
||||
if(schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var nodeList = xmldoc_in.getElementsByTagName(schema.resultListLocator),
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, field, result, i, j;
|
||||
|
||||
if(nodeList.length) {
|
||||
// Loop through each result node
|
||||
for(i=nodeList.length-1; i>= 0; i--) {
|
||||
result = {};
|
||||
node = nodeList[i];
|
||||
|
||||
// Find each field value
|
||||
for(j=fields.length-1; j>= 0; j--) {
|
||||
field = fields[j];
|
||||
result[field.key || field] = SchemaXML._getLocationValue(field, node);
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
735
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema.js
vendored
Normal file
735
jssource/src_files/include/javascript/yui3/build/dataschema/dataschema.js
vendored
Normal file
@@ -0,0 +1,735 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dataschema-base', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataSchema utility provides a common configurable interface for widgets to
|
||||
* apply a given schema to a variety of data.
|
||||
*
|
||||
* @module dataschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base DataSchema implementation, which can be extended to
|
||||
* create DataSchemas for specific data formats, such XML, JSON, text and
|
||||
* arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-base
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
/**
|
||||
* Base class for the YUI DataSchema Utility.
|
||||
* @class DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaBase = {
|
||||
/**
|
||||
* Overridable method returns data as-is.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies field parser, if defined
|
||||
*
|
||||
* @method parse
|
||||
* @param value {Object} Original value.
|
||||
* @param field {Object} Field.
|
||||
* @return {Object} Type-converted value.
|
||||
*/
|
||||
parse: function(value, field) {
|
||||
if(field.parser) {
|
||||
var parser = (LANG.isFunction(field.parser)) ?
|
||||
field.parser : Y.Parsers[field.parser+''];
|
||||
if(parser) {
|
||||
value = parser.call(this, value);
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
Y.namespace("DataSchema").Base = SchemaBase;
|
||||
Y.namespace("Parsers");
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base']});
|
||||
|
||||
YUI.add('dataschema-json', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with JSON data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-json
|
||||
*/
|
||||
|
||||
/**
|
||||
* JSON subclass for the DataSchema Utility.
|
||||
* @class DataSchema.JSON
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaJSON = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.JSON static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Utility function converts JSON locator strings into walkable paths
|
||||
*
|
||||
* @method DataSchema.JSON.getPath
|
||||
* @param locator {String} JSON value locator.
|
||||
* @return {String[]} Walkable path to data value.
|
||||
* @static
|
||||
*/
|
||||
getPath: function(locator) {
|
||||
var path = null,
|
||||
keys = [],
|
||||
i = 0;
|
||||
|
||||
if (locator) {
|
||||
// Strip the ["string keys"] and [1] array indexes
|
||||
locator = locator.
|
||||
replace(/\[(['"])(.*?)\1\]/g,
|
||||
function (x,$1,$2) {keys[i]=$2;return '.@'+(i++);}).
|
||||
replace(/\[(\d+)\]/g,
|
||||
function (x,$1) {keys[i]=parseInt($1,10)|0;return '.@'+(i++);}).
|
||||
replace(/^\./,''); // remove leading dot
|
||||
|
||||
// Validate against problematic characters.
|
||||
if (!/[^\w\.\$@]/.test(locator)) {
|
||||
path = locator.split('.');
|
||||
for (i=path.length-1; i >= 0; --i) {
|
||||
if (path[i].charAt(0) === '@') {
|
||||
path[i] = keys[parseInt(path[i].substr(1),10)];
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
return path;
|
||||
},
|
||||
|
||||
/**
|
||||
* Utility function to walk a path and return the value located there.
|
||||
*
|
||||
* @method DataSchema.JSON.getLocationValue
|
||||
* @param path {String[]} Locator path.
|
||||
* @param data {String} Data to traverse.
|
||||
* @return {Object} Data value at location.
|
||||
* @static
|
||||
*/
|
||||
getLocationValue: function (path, data) {
|
||||
var i = 0,
|
||||
len = path.length;
|
||||
for (;i<len;i++) {
|
||||
if(!LANG.isUndefined(data[path[i]])) {
|
||||
data = data[path[i]];
|
||||
}
|
||||
else {
|
||||
data = undefined;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
|
||||
/**
|
||||
* Applies a given schema to given JSON data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} JSON data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
// Convert incoming JSON strings
|
||||
if(!LANG.isObject(data)) {
|
||||
try {
|
||||
data_in = Y.JSON.parse(data);
|
||||
}
|
||||
catch(e) {
|
||||
data_out.error = e;
|
||||
return data_out;
|
||||
}
|
||||
}
|
||||
|
||||
if(LANG.isObject(data_in) && schema) {
|
||||
// Parse results data
|
||||
if(!LANG.isUndefined(schema.resultListLocator)) {
|
||||
data_out = SchemaJSON._parseResults(schema, data_in, data_out);
|
||||
}
|
||||
|
||||
// Parse meta data
|
||||
if(!LANG.isUndefined(schema.metaFields)) {
|
||||
data_out = SchemaJSON._parseMeta(schema.metaFields, data_in, data_out);
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, json_in, data_out) {
|
||||
var results = [],
|
||||
path,
|
||||
error;
|
||||
|
||||
if(schema.resultListLocator) {
|
||||
path = SchemaJSON.getPath(schema.resultListLocator);
|
||||
if(path) {
|
||||
results = SchemaJSON.getLocationValue(path, json_in);
|
||||
if (results === undefined) {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON results retrieval failure");
|
||||
}
|
||||
else {
|
||||
if(LANG.isArray(schema.resultFields) && LANG.isArray(results)) {
|
||||
data_out = SchemaJSON._getFieldValues(schema.resultFields, results, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = [];
|
||||
error = new Error("JSON Schema fields retrieval failure");
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
error = new Error("JSON Schema results locator failure");
|
||||
}
|
||||
|
||||
if (error) {
|
||||
data_out.error = error;
|
||||
}
|
||||
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get field data values out of list of full results
|
||||
*
|
||||
* @method _getFieldValues
|
||||
* @param fields {Array} Fields to find.
|
||||
* @param array_in {Array} Results to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getFieldValues: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
len = fields.length,
|
||||
i, j,
|
||||
field, key, path, parser,
|
||||
simplePaths = [], complexPaths = [], fieldParsers = [],
|
||||
result, record;
|
||||
|
||||
// First collect hashes of simple paths, complex paths, and parsers
|
||||
for (i=0; i<len; i++) {
|
||||
field = fields[i]; // A field can be a simple string or a hash
|
||||
key = field.key || field; // Find the key
|
||||
|
||||
// Validate and store locators for later
|
||||
path = SchemaJSON.getPath(key);
|
||||
if (path) {
|
||||
if (path.length === 1) {
|
||||
simplePaths[simplePaths.length] = {key:key, path:path[0]};
|
||||
} else {
|
||||
complexPaths[complexPaths.length] = {key:key, path:path};
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
// Validate and store parsers for later
|
||||
//TODO: use Y.DataSchema.parse?
|
||||
parser = (LANG.isFunction(field.parser)) ? field.parser : Y.Parsers[field.parser+''];
|
||||
if (parser) {
|
||||
fieldParsers[fieldParsers.length] = {key:key, parser:parser};
|
||||
}
|
||||
}
|
||||
|
||||
// Traverse list of array_in, creating records of simple fields,
|
||||
// complex fields, and applying parsers as necessary
|
||||
for (i=array_in.length-1; i>=0; --i) {
|
||||
record = {};
|
||||
result = array_in[i];
|
||||
if(result) {
|
||||
// Cycle through simpleLocators
|
||||
for (j=simplePaths.length-1; j>=0; --j) {
|
||||
// Bug 1777850: The result might be an array instead of object
|
||||
record[simplePaths[j].key] = Y.DataSchema.Base.parse(
|
||||
(LANG.isUndefined(result[simplePaths[j].path]) ?
|
||||
result[j] : result[simplePaths[j].path]), simplePaths[j]);
|
||||
}
|
||||
|
||||
// Cycle through complexLocators
|
||||
for (j=complexPaths.length - 1; j>=0; --j) {
|
||||
record[complexPaths[j].key] = Y.DataSchema.Base.parse(
|
||||
(SchemaJSON.getLocationValue(complexPaths[j].path, result)), complexPaths[j] );
|
||||
}
|
||||
|
||||
// Cycle through fieldParsers
|
||||
for (j=fieldParsers.length-1; j>=0; --j) {
|
||||
key = fieldParsers[j].key;
|
||||
record[key] = fieldParsers[j].parser(record[key]);
|
||||
// Safety net
|
||||
if (LANG.isUndefined(record[key])) {
|
||||
record[key] = null;
|
||||
}
|
||||
}
|
||||
results[i] = record;
|
||||
}
|
||||
}
|
||||
data_out.results = results;
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param metaFields {Object} Metafields definitions.
|
||||
* @param json_in {Object} JSON to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Schema-parsed meta data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, json_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key, path;
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
path = SchemaJSON.getPath(metaFields[key]);
|
||||
if (path && json_in) {
|
||||
data_out.meta[key] = SchemaJSON.getLocationValue(path, json_in);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("JSON meta data retrieval failure");
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.JSON = Y.mix(SchemaJSON, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['json', 'dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-xml', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with XML data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-xml
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
/**
|
||||
* XML subclass for the DataSchema Utility.
|
||||
* @class DataSchema.XML
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
SchemaXML = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.XML static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given XML data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {XMLDoc} XML document.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var xmldoc = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(xmldoc && xmldoc.nodeType && (xmldoc.nodeType === 9 || xmldoc.nodeType === 1 || xmldoc.nodeType === 11) && schema) {
|
||||
// Parse results data
|
||||
data_out = SchemaXML._parseResults(schema, xmldoc, data_out);
|
||||
|
||||
// Parse meta data
|
||||
data_out = SchemaXML._parseMeta(schema.metaFields, xmldoc, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get an XPath-specified value for a given field from an XML node or document.
|
||||
*
|
||||
* @method _getLocationValue
|
||||
* @param field {String | Object} Field definition.
|
||||
* @param context {Object} XML node or document to search within.
|
||||
* @return {Object} Data value or null.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_getLocationValue: function(field, context) {
|
||||
var locator = field.locator || field.key || field,
|
||||
xmldoc = context.ownerDocument || context,
|
||||
result, res, value = null;
|
||||
|
||||
try {
|
||||
// Standards mode
|
||||
if(!LANG.isUndefined(xmldoc.evaluate)) {
|
||||
result = xmldoc.evaluate(locator, context, xmldoc.createNSResolver(!context.ownerDocument ? context.documentElement : context.ownerDocument.documentElement), 0, null);
|
||||
while(res = result.iterateNext()) {
|
||||
value = res.textContent;
|
||||
}
|
||||
}
|
||||
// IE mode
|
||||
else {
|
||||
xmldoc.setProperty("SelectionLanguage", "XPath");
|
||||
result = context.selectNodes(locator)[0];
|
||||
value = result.value || result.text || null;
|
||||
}
|
||||
return Y.DataSchema.Base.parse(value, field);
|
||||
|
||||
}
|
||||
catch(e) {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses results data according to schema
|
||||
*
|
||||
* @method _parseMeta
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseMeta: function(metaFields, xmldoc_in, data_out) {
|
||||
if(LANG.isObject(metaFields)) {
|
||||
var key,
|
||||
xmldoc = xmldoc_in.ownerDocument || xmldoc_in;
|
||||
|
||||
for(key in metaFields) {
|
||||
if (metaFields.hasOwnProperty(key)) {
|
||||
data_out.meta[key] = SchemaXML._getLocationValue(metaFields[key], xmldoc);
|
||||
}
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Object} Schema to parse against.
|
||||
* @param xmldoc_in {Object} XML document parse.
|
||||
* @param data_out {Object} In-progress schema-parsed data to update.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, xmldoc_in, data_out) {
|
||||
if(schema.resultListLocator && LANG.isArray(schema.resultFields)) {
|
||||
var nodeList = xmldoc_in.getElementsByTagName(schema.resultListLocator),
|
||||
fields = schema.resultFields,
|
||||
results = [],
|
||||
node, field, result, i, j;
|
||||
|
||||
if(nodeList.length) {
|
||||
// Loop through each result node
|
||||
for(i=nodeList.length-1; i>= 0; i--) {
|
||||
result = {};
|
||||
node = nodeList[i];
|
||||
|
||||
// Find each field value
|
||||
for(j=fields.length-1; j>= 0; j--) {
|
||||
field = fields[j];
|
||||
result[field.key || field] = SchemaXML._getLocationValue(field, node);
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
|
||||
data_out.results = results;
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("XML schema result nodes retrieval failure");
|
||||
}
|
||||
}
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.XML = Y.mix(SchemaXML, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-array', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with data stored in arrays.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-array
|
||||
*/
|
||||
|
||||
/**
|
||||
* Array subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Array
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaArray = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Array static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given Array data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Array data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isArray(data_in)) {
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
// Parse results data
|
||||
data_out = SchemaArray._parseResults(schema.resultFields, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.results = data_in;
|
||||
}
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Array schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param fields {Array} Schema to parse against.
|
||||
* @param array_in {Array} Array to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(fields, array_in, data_out) {
|
||||
var results = [],
|
||||
result, item, type, field, key, value, i, j;
|
||||
|
||||
for(i=array_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = array_in[i];
|
||||
type = (LANG.isObject(item) && !LANG.isFunction(item)) ? 2 : (LANG.isArray(item)) ? 1 : (LANG.isString(item)) ? 0 : -1;
|
||||
if(type > 0) {
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(item[key])) ? item[key] : item[j];
|
||||
result[key] = Y.DataSchema.Base.parse(value, field);
|
||||
}
|
||||
}
|
||||
else if(type === 0) {
|
||||
result = item;
|
||||
}
|
||||
else {
|
||||
//TODO: null or {}?
|
||||
result = null;
|
||||
}
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Array = Y.mix(SchemaArray, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
|
||||
YUI.add('dataschema-text', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSchema implementation which can be used to work with delimited text data.
|
||||
*
|
||||
* @module dataschema
|
||||
* @submodule dataschema-text
|
||||
*/
|
||||
|
||||
/**
|
||||
* Text subclass for the DataSchema Utility.
|
||||
* @class DataSchema.Text
|
||||
* @extends DataSchema.Base
|
||||
* @static
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang,
|
||||
|
||||
SchemaText = {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSchema.Text static methods
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
* Applies a given schema to given delimited text data.
|
||||
*
|
||||
* @method apply
|
||||
* @param schema {Object} Schema to apply.
|
||||
* @param data {Object} Text data.
|
||||
* @return {Object} Schema-parsed data.
|
||||
* @static
|
||||
*/
|
||||
apply: function(schema, data) {
|
||||
var data_in = data,
|
||||
data_out = {results:[],meta:{}};
|
||||
|
||||
if(LANG.isString(data_in) && LANG.isString(schema.resultDelimiter)) {
|
||||
// Parse results data
|
||||
data_out = SchemaText._parseResults(schema, data_in, data_out);
|
||||
}
|
||||
else {
|
||||
data_out.error = new Error("Text schema parse failure");
|
||||
}
|
||||
|
||||
return data_out;
|
||||
},
|
||||
|
||||
/**
|
||||
* Schema-parsed list of results from full data
|
||||
*
|
||||
* @method _parseResults
|
||||
* @param schema {Array} Schema to parse against.
|
||||
* @param text_in {String} Text to parse.
|
||||
* @param data_out {Object} In-progress parsed data to update.
|
||||
* @return {Object} Parsed data object.
|
||||
* @static
|
||||
* @protected
|
||||
*/
|
||||
_parseResults: function(schema, text_in, data_out) {
|
||||
var resultDelim = schema.resultDelimiter,
|
||||
results = [],
|
||||
results_in, fields_in, result, item, fields, field, key, value, i, j,
|
||||
|
||||
// Delete final delimiter at end of string if there
|
||||
tmpLength = text_in.length-resultDelim.length;
|
||||
if(text_in.substr(tmpLength) == resultDelim) {
|
||||
text_in = text_in.substr(0, tmpLength);
|
||||
}
|
||||
|
||||
// Split into results
|
||||
results_in = text_in.split(schema.resultDelimiter);
|
||||
|
||||
for(i=results_in.length-1; i>-1; i--) {
|
||||
result = {};
|
||||
item = results_in[i];
|
||||
|
||||
if(LANG.isString(schema.fieldDelimiter)) {
|
||||
fields_in = item.split(schema.fieldDelimiter);
|
||||
|
||||
if(LANG.isArray(schema.resultFields)) {
|
||||
fields = schema.resultFields;
|
||||
for(j=fields.length-1; j>-1; j--) {
|
||||
field = fields[j];
|
||||
key = (!LANG.isUndefined(field.key)) ? field.key : field;
|
||||
value = (!LANG.isUndefined(fields_in[key])) ? fields_in[key] : fields_in[j];
|
||||
result[key] = Y.DataSchema.Base.parse(value, field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
result = item;
|
||||
}
|
||||
|
||||
results[i] = result;
|
||||
}
|
||||
data_out.results = results;
|
||||
|
||||
return data_out;
|
||||
}
|
||||
};
|
||||
|
||||
Y.DataSchema.Text = Y.mix(SchemaText, Y.DataSchema.Base);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dataschema-base']});
|
||||
|
||||
|
||||
|
||||
YUI.add('dataschema', function(Y){}, '3.0.0' ,{use:['dataschema-base','dataschema-json','dataschema-xml','dataschema-array','dataschema-text']});
|
||||
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-arrayschema-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-arrayschema-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-arrayschema",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"schema",NAME:"dataSourceArraySchema",ATTRS:{schema:{}}});B.extend(A,B.Plugin.Base,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(E){var D=(B.DataSource.IO&&(this.get("host") instanceof B.DataSource.IO)&&B.Lang.isString(E.data.responseText))?E.data.responseText:E.data,C=B.DataSchema.Array.apply(this.get("schema"),D);if(!C){C={meta:{},results:D};}this.get("host").fire("response",B.mix({response:C},E));return new B.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");}});B.namespace("Plugin").DataSourceArraySchema=A;},"3.0.0",{requires:["plugin","datasource-local","dataschema-array"]});
|
||||
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-arrayschema.js
vendored
Normal file
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-arrayschema.js
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-arrayschema', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with schema-parsing on array data.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-arrayschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds schema-parsing to the DataSource Utility.
|
||||
* @class DataSourceArraySchema
|
||||
* @extends Plugin.Base
|
||||
*/
|
||||
var DataSourceArraySchema = function() {
|
||||
DataSourceArraySchema.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
Y.mix(DataSourceArraySchema, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "schema"
|
||||
*/
|
||||
NS: "schema",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceArraySchema"
|
||||
*/
|
||||
NAME: "dataSourceArraySchema",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSourceArraySchema Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
schema: {
|
||||
//value: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DataSourceArraySchema, Y.Plugin.Base, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this.doBefore("_defDataFn", this._beforeDefDataFn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses raw data into a normalized response.
|
||||
*
|
||||
* @method _beforeDefDataFn
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefDataFn: function(e) {
|
||||
var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
|
||||
response = Y.DataSchema.Array.apply(this.get("schema"), data);
|
||||
|
||||
// Default
|
||||
if(!response) {
|
||||
response = {
|
||||
meta: {},
|
||||
results: data
|
||||
};
|
||||
}
|
||||
|
||||
this.get("host").fire("response", Y.mix({response:response}, e));
|
||||
return new Y.Do.Halt("DataSourceArraySchema plugin halted _defDataFn");
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').DataSourceArraySchema = DataSourceArraySchema;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['plugin', 'datasource-local', 'dataschema-array']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-cache-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-cache-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-cache",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"cache",NAME:"dataSourceCache",ATTRS:{}});B.extend(A,B.Cache,{initializer:function(C){this.doBefore("_defRequestFn",this._beforeDefRequestFn);this.doBefore("_defResponseFn",this._beforeDefResponseFn);},_beforeDefRequestFn:function(D){var C=(this.retrieve(D.request))||null;if(C&&C.response){this.get("host").fire("response",B.mix({response:C.response},D));return new B.Do.Halt("DataSourceCache plugin halted _defRequestFn");}},_beforeDefResponseFn:function(C){if(C.response&&!C.response.cached){C.response.cached=true;this.add(C.request,C.response,(C.callback&&C.callback.argument));}}});B.namespace("Plugin").DataSourceCache=A;},"3.0.0",{requires:["datasource-local","cache"]});
|
||||
136
jssource/src_files/include/javascript/yui3/build/datasource/datasource-cache.js
vendored
Normal file
136
jssource/src_files/include/javascript/yui3/build/datasource/datasource-cache.js
vendored
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-cache', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with caching functionality.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-cache
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds cacheability to the DataSource Utility.
|
||||
* @class DataSourceCache
|
||||
* @extends Cache
|
||||
*/
|
||||
var DataSourceCache = function() {
|
||||
DataSourceCache.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
Y.mix(DataSourceCache, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "cache"
|
||||
*/
|
||||
NS: "cache",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceCache"
|
||||
*/
|
||||
NAME: "dataSourceCache",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSourceCache Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DataSourceCache, Y.Cache, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this.doBefore("_defRequestFn", this._beforeDefRequestFn);
|
||||
this.doBefore("_defResponseFn", this._beforeDefResponseFn);
|
||||
},
|
||||
|
||||
/**
|
||||
* First look for cached response, then send request to live data.
|
||||
*
|
||||
* @method _beforeDefRequestFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object.</dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefRequestFn: function(e) {
|
||||
// Is response already in the Cache?
|
||||
var entry = (this.retrieve(e.request)) || null;
|
||||
if(entry && entry.response) {
|
||||
this.get("host").fire("response", Y.mix({response: entry.response}, e));
|
||||
return new Y.Do.Halt("DataSourceCache plugin halted _defRequestFn");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Adds data to cache before returning data.
|
||||
*
|
||||
* @method _beforeDefResponseFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* <dt>response (Object)</dt> <dd>Normalized response object with the following properties:
|
||||
* <dl>
|
||||
* <dt>cached (Object)</dt> <dd>True when response is cached.</dd>
|
||||
* <dt>results (Object)</dt> <dd>Parsed results.</dd>
|
||||
* <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
|
||||
* <dt>error (Object)</dt> <dd>Error object.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefResponseFn: function(e) {
|
||||
// Add to Cache before returning
|
||||
if(e.response && !e.response.cached) {
|
||||
e.response.cached = true;
|
||||
this.add(e.request, e.response, (e.callback && e.callback.argument));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').DataSourceCache = DataSourceCache;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['datasource-local', 'cache']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-function-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-function-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-function",function(B){var A=B.Lang,C=function(){C.superclass.constructor.apply(this,arguments);};B.mix(C,{NAME:"dataSourceFunction",ATTRS:{source:{validator:A.isFunction}}});B.extend(C,B.DataSource.Local,{_defRequestFn:function(G){var F=this.get("source"),D;if(F){try{D=F(G.request,this,G);this.fire("data",B.mix({data:D},G));}catch(E){G.error=E;this.fire("error",G);}}else{G.error=new Error("Function data failure");this.fire("error",G);}return G.tId;}});B.DataSource.Function=C;},"3.0.0",{requires:["datasource-local"]});
|
||||
115
jssource/src_files/include/javascript/yui3/build/datasource/datasource-function.js
vendored
Normal file
115
jssource/src_files/include/javascript/yui3/build/datasource/datasource-function.js
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-function', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSource implementation which can be used to retrieve data from a custom function.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-function
|
||||
*/
|
||||
|
||||
/**
|
||||
* Function subclass for the DataSource Utility.
|
||||
* @class DataSource.Function
|
||||
* @extends DataSource.Local
|
||||
* @constructor
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
DSFn = function() {
|
||||
DSFn.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.Function static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(DSFn, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceFunction"
|
||||
*/
|
||||
NAME: "dataSourceFunction",
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.Function Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
/**
|
||||
* @attribute source
|
||||
* @description Pointer to live data.
|
||||
* @type MIXED
|
||||
* @default null
|
||||
*/
|
||||
source: {
|
||||
validator: LANG.isFunction
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DSFn, Y.DataSource.Local, {
|
||||
/**
|
||||
* Passes query string to IO. Fires <code>response</code> event when
|
||||
* response is received asynchronously.
|
||||
*
|
||||
* @method _defRequestFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defRequestFn: function(e) {
|
||||
var fn = this.get("source"),
|
||||
response;
|
||||
|
||||
if(fn) {
|
||||
try {
|
||||
response = fn(e.request, this, e);
|
||||
this.fire("data", Y.mix({data:response}, e));
|
||||
}
|
||||
catch(error) {
|
||||
e.error = error;
|
||||
this.fire("error", e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
e.error = new Error("Function data failure");
|
||||
this.fire("error", e);
|
||||
}
|
||||
|
||||
return e.tId;
|
||||
}
|
||||
});
|
||||
|
||||
Y.DataSource.Function = DSFn;
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['datasource-local']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-get-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-get-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-get",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NAME:"dataSourceGet",ATTRS:{get:{value:B.Get,cloneDefaultValue:false},asyncMode:{value:"allowAll"},scriptCallbackParam:{value:"callback"},generateRequestCallback:{value:function(C,D){return"&"+C.get("scriptCallbackParam")+"=YUI.Env.DataSource.callbacks["+D+"]";}}},callbacks:[],_tId:0});B.extend(A,B.DataSource.Local,{_defRequestFn:function(F){var E=this.get("source"),D=this.get("get"),G=A._tId++,C=this;YUI.Env.DataSource.callbacks[G]=B.rbind(function(H){if((C.get("asyncMode")!=="ignoreStaleResponses")||(G===A.callbacks.length-1)){C.fire("data",B.mix({data:H},F));}else{}delete A.callbacks[G];},this,G);E+=F.request+this.get("generateRequestCallback")(this,G);D.script(E,{autopurge:true,onFailure:B.bind(function(H){H.error=new Error("Script node data failure");this.fire("error",H);},this,F)});return F.tId;}});B.DataSource.Get=A;YUI.namespace("Env.DataSource.callbacks");},"3.0.0",{requires:["datasource-local","get"]});
|
||||
226
jssource/src_files/include/javascript/yui3/build/datasource/datasource-get.js
vendored
Normal file
226
jssource/src_files/include/javascript/yui3/build/datasource/datasource-get.js
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-get', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSource implementation which can be used to retrieve data via the Get Utility.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-get
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get Utility subclass for the DataSource Utility.
|
||||
* @class DataSource.Get
|
||||
* @extends DataSource.Local
|
||||
* @constructor
|
||||
*/
|
||||
var DSGet = function() {
|
||||
DSGet.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.Get static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(DSGet, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceGet"
|
||||
*/
|
||||
NAME: "dataSourceGet",
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.Get Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
/**
|
||||
* Pointer to Get Utility.
|
||||
*
|
||||
* @attribute get
|
||||
* @type Y.Get
|
||||
* @default Y.Get
|
||||
*/
|
||||
get: {
|
||||
value: Y.Get,
|
||||
cloneDefaultValue: false
|
||||
},
|
||||
|
||||
/**
|
||||
* Defines request/response management in the following manner:
|
||||
* <dl>
|
||||
* <!--<dt>queueRequests</dt>
|
||||
* <dd>If a request is already in progress, wait until response is returned before sending the next request.</dd>
|
||||
* <dt>cancelStaleRequests</dt>
|
||||
* <dd>If a request is already in progress, cancel it before sending the next request.</dd>-->
|
||||
* <dt>ignoreStaleResponses</dt>
|
||||
* <dd>Send all requests, but handle only the response for the most recently sent request.</dd>
|
||||
* <dt>allowAll</dt>
|
||||
* <dd>Send all requests and handle all responses.</dd>
|
||||
* </dl>
|
||||
*
|
||||
* @attribute asyncMode
|
||||
* @type String
|
||||
* @default "allowAll"
|
||||
*/
|
||||
asyncMode: {
|
||||
value: "allowAll"
|
||||
},
|
||||
|
||||
/**
|
||||
* Callback string parameter name sent to the remote script. By default,
|
||||
* requests are sent to
|
||||
* <URI>?<scriptCallbackParam>=callbackFunction
|
||||
*
|
||||
* @attribute scriptCallbackParam
|
||||
* @type String
|
||||
* @default "callback"
|
||||
*/
|
||||
scriptCallbackParam : {
|
||||
value: "callback"
|
||||
},
|
||||
|
||||
/**
|
||||
* Accepts the DataSource instance and a callback ID, and returns a callback
|
||||
* param/value string that gets appended to the script URI. Implementers
|
||||
* can customize this string to match their server's query syntax.
|
||||
*
|
||||
* @attribute generateRequestCallback
|
||||
* @type Function
|
||||
*/
|
||||
generateRequestCallback : {
|
||||
value: function(self, id) {
|
||||
return "&" + self.get("scriptCallbackParam") + "=YUI.Env.DataSource.callbacks["+id+"]" ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Global array of callback functions, one for each request sent.
|
||||
*
|
||||
* @property callbacks
|
||||
* @type Function[]
|
||||
* @static
|
||||
*/
|
||||
callbacks : [],
|
||||
|
||||
/**
|
||||
* Unique ID to track requests.
|
||||
*
|
||||
* @property _tId
|
||||
* @type Number
|
||||
* @private
|
||||
* @static
|
||||
*/
|
||||
_tId : 0
|
||||
});
|
||||
|
||||
Y.extend(DSGet, Y.DataSource.Local, {
|
||||
/**
|
||||
* Passes query string to Get Utility. Fires <code>response</code> event when
|
||||
* response is received asynchronously.
|
||||
*
|
||||
* @method _defRequestFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defRequestFn: function(e) {
|
||||
var uri = this.get("source"),
|
||||
get = this.get("get"),
|
||||
id = DSGet._tId++,
|
||||
self = this;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Dynamically add handler function with a closure to the callback stack
|
||||
YUI.Env.DataSource.callbacks[id] = Y.rbind(function(response) {
|
||||
if((self.get("asyncMode") !== "ignoreStaleResponses")||
|
||||
(id === DSGet.callbacks.length-1)) { // Must ignore stale responses
|
||||
|
||||
self.fire("data", Y.mix({data:response}, e));
|
||||
}
|
||||
else {
|
||||
}
|
||||
|
||||
delete DSGet.callbacks[id];
|
||||
}, this, id);
|
||||
|
||||
// We are now creating a request
|
||||
uri += e.request + this.get("generateRequestCallback")(this, id);
|
||||
//uri = this.doBefore(sUri);
|
||||
get.script(uri, {
|
||||
autopurge: true,
|
||||
// Works in Firefox only....
|
||||
onFailure: Y.bind(function(e) {
|
||||
e.error = new Error("Script node data failure");
|
||||
this.fire("error", e);
|
||||
}, this, e)
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return e.tId;
|
||||
}
|
||||
});
|
||||
|
||||
Y.DataSource.Get = DSGet;
|
||||
YUI.namespace("Env.DataSource.callbacks");
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['datasource-local', 'get']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-io-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-io-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-io",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NAME:"dataSourceIO",ATTRS:{io:{value:B.io,cloneDefaultValue:false}}});B.extend(A,B.DataSource.Local,{initializer:function(C){this._queue={interval:null,conn:null,requests:[]};},_queue:null,_defRequestFn:function(F){var E=this.get("source"),G=this.get("io"),D=F.request,C=B.mix(F.cfg,{on:{success:function(J,H,I){this.fire("data",B.mix({data:H},I));},failure:function(J,H,I){I.error=new Error("IO data failure");this.fire("error",B.mix({data:H},I));this.fire("data",B.mix({data:H},I));}},context:this,arguments:F});if(B.Lang.isString(D)){if(C.method&&(C.method.toUpperCase()==="POST")){C.data=C.data?C.data+D:D;}else{E+=D;}}G(E,C);return F.tId;}});B.DataSource.IO=A;},"3.0.0",{requires:["datasource-local","io"]});
|
||||
154
jssource/src_files/include/javascript/yui3/build/datasource/datasource-io.js
vendored
Normal file
154
jssource/src_files/include/javascript/yui3/build/datasource/datasource-io.js
vendored
Normal file
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-io', function(Y) {
|
||||
|
||||
/**
|
||||
* Provides a DataSource implementation which can be used to retrieve data via the IO Utility.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-io
|
||||
*/
|
||||
|
||||
/**
|
||||
* IO subclass for the DataSource Utility.
|
||||
* @class DataSource.IO
|
||||
* @extends DataSource.Local
|
||||
* @constructor
|
||||
*/
|
||||
var DSIO = function() {
|
||||
DSIO.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.IO static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(DSIO, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceIO"
|
||||
*/
|
||||
NAME: "dataSourceIO",
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource.IO Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
/**
|
||||
* Pointer to IO Utility.
|
||||
*
|
||||
* @attribute io
|
||||
* @type Y.io
|
||||
* @default Y.io
|
||||
*/
|
||||
io: {
|
||||
value: Y.io,
|
||||
cloneDefaultValue: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DSIO, Y.DataSource.Local, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this._queue = {interval:null, conn:null, requests:[]};
|
||||
},
|
||||
|
||||
/**
|
||||
* @property _queue
|
||||
* @description Object literal to manage asynchronous request/response
|
||||
* cycles enabled if queue needs to be managed (asyncMode/ioConnMode):
|
||||
* <dl>
|
||||
* <dt>interval {Number}</dt>
|
||||
* <dd>Interval ID of in-progress queue.</dd>
|
||||
* <dt>conn</dt>
|
||||
* <dd>In-progress connection identifier (if applicable).</dd>
|
||||
* <dt>requests {Object[]}</dt>
|
||||
* <dd>Array of queued request objects: {request:request, callback:callback}.</dd>
|
||||
* </dl>
|
||||
* @type Object
|
||||
* @default {interval:null, conn:null, requests:[]}
|
||||
* @private
|
||||
*/
|
||||
_queue: null,
|
||||
|
||||
/**
|
||||
* Passes query string to IO. Fires <code>response</code> event when
|
||||
* response is received asynchronously.
|
||||
*
|
||||
* @method _defRequestFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defRequestFn: function(e) {
|
||||
var uri = this.get("source"),
|
||||
io = this.get("io"),
|
||||
request = e.request,
|
||||
cfg = Y.mix(e.cfg, {
|
||||
on: {
|
||||
success: function (id, response, e) {
|
||||
this.fire("data", Y.mix({data:response}, e));
|
||||
},
|
||||
failure: function (id, response, e) {
|
||||
e.error = new Error("IO data failure");
|
||||
this.fire("error", Y.mix({data:response}, e));
|
||||
this.fire("data", Y.mix({data:response}, e));
|
||||
}
|
||||
},
|
||||
context: this,
|
||||
arguments: e
|
||||
});
|
||||
|
||||
// Support for POST transactions
|
||||
if(Y.Lang.isString(request)) {
|
||||
if(cfg.method && (cfg.method.toUpperCase() === "POST")) {
|
||||
cfg.data = cfg.data ? cfg.data+request : request;
|
||||
}
|
||||
else {
|
||||
uri += request;
|
||||
}
|
||||
}
|
||||
io(uri, cfg);
|
||||
return e.tId;
|
||||
}
|
||||
});
|
||||
|
||||
Y.DataSource.IO = DSIO;
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['datasource-local', 'io']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-jsonschema-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-jsonschema-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-jsonschema",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"schema",NAME:"dataSourceJSONSchema",ATTRS:{schema:{}}});B.extend(A,B.Plugin.Base,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(E){var D=(B.DataSource.IO&&(this.get("host") instanceof B.DataSource.IO)&&B.Lang.isString(E.data.responseText))?E.data.responseText:E.data,C=B.DataSchema.JSON.apply(this.get("schema"),D);if(!C){C={meta:{},results:D};}this.get("host").fire("response",B.mix({response:C},E));return new B.Do.Halt("DataSourceJSONSchema plugin halted _defDataFn");}});B.namespace("Plugin").DataSourceJSONSchema=A;},"3.0.0",{requires:["plugin","datasource-local","dataschema-json"]});
|
||||
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-jsonschema.js
vendored
Normal file
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-jsonschema.js
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-jsonschema', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with schema-parsing on JSON data.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-jsonschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds schema-parsing to the DataSource Utility.
|
||||
* @class DataSourceJSONSchema
|
||||
* @extends Plugin.Base
|
||||
*/
|
||||
var DataSourceJSONSchema = function() {
|
||||
DataSourceJSONSchema.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
Y.mix(DataSourceJSONSchema, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "schema"
|
||||
*/
|
||||
NS: "schema",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceJSONSchema"
|
||||
*/
|
||||
NAME: "dataSourceJSONSchema",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSourceJSONSchema Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
schema: {
|
||||
//value: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DataSourceJSONSchema, Y.Plugin.Base, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this.doBefore("_defDataFn", this._beforeDefDataFn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses raw data into a normalized response.
|
||||
*
|
||||
* @method _beforeDefDataFn
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefDataFn: function(e) {
|
||||
var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
|
||||
response = Y.DataSchema.JSON.apply(this.get("schema"), data);
|
||||
|
||||
// Default
|
||||
if(!response) {
|
||||
response = {
|
||||
meta: {},
|
||||
results: data
|
||||
};
|
||||
}
|
||||
|
||||
this.get("host").fire("response", Y.mix({response:response}, e));
|
||||
return new Y.Do.Halt("DataSourceJSONSchema plugin halted _defDataFn");
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').DataSourceJSONSchema = DataSourceJSONSchema;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['plugin', 'datasource-local', 'dataschema-json']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-local-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-local-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-local",function(C){var B=C.Lang,A=function(){A.superclass.constructor.apply(this,arguments);};C.mix(A,{NAME:"dataSourceLocal",ATTRS:{source:{value:null}},_tId:0,issueCallback:function(E){if(E.callback){var D=(E.error&&E.callback.failure)||E.callback.success;if(D){D(E);}}}});C.extend(A,C.Base,{initializer:function(D){this._initEvents();},_initEvents:function(){this.publish("request",{defaultFn:C.bind("_defRequestFn",this),queuable:true});this.publish("data",{defaultFn:C.bind("_defDataFn",this),queuable:true});this.publish("response",{defaultFn:C.bind("_defResponseFn",this),queuable:true});},_defRequestFn:function(E){var D=this.get("source");if(B.isUndefined(D)){E.error=new Error("Local source undefined");}if(E.error){this.fire("error",E);}this.fire("data",C.mix({data:D},E));},_defDataFn:function(G){var E=G.data,F=G.meta,D={results:(B.isArray(E))?E:[E],meta:(F)?F:{}};this.fire("response",C.mix({response:D},G));},_defResponseFn:function(D){A.issueCallback(D);},sendRequest:function(E,G,D){var F=A._tId++;this.fire("request",{tId:F,request:E,callback:G,cfg:D||{}});return F;}});C.namespace("DataSource").Local=A;},"3.0.0",{requires:["base"]});
|
||||
336
jssource/src_files/include/javascript/yui3/build/datasource/datasource-local.js
vendored
Normal file
336
jssource/src_files/include/javascript/yui3/build/datasource/datasource-local.js
vendored
Normal file
@@ -0,0 +1,336 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-local', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataSource utility provides a common configurable interface for widgets to
|
||||
* access a variety of data, from JavaScript arrays to online database servers.
|
||||
*
|
||||
* @module datasource
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides the base DataSource implementation, which can be extended to
|
||||
* create DataSources for specific data protocols, such as the IO Utility, the
|
||||
* Get Utility, or custom functions.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-local
|
||||
*/
|
||||
|
||||
/**
|
||||
* Base class for the DataSource Utility.
|
||||
* @class DataSource.Local
|
||||
* @extends Base
|
||||
* @constructor
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
DSLocal = function() {
|
||||
DSLocal.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource static properties
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
Y.mix(DSLocal, {
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceLocal"
|
||||
*/
|
||||
NAME: "dataSourceLocal",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSource Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
/**
|
||||
* @attribute source
|
||||
* @description Pointer to live data.
|
||||
* @type MIXED
|
||||
* @default null
|
||||
*/
|
||||
source: {
|
||||
value: null
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Global transaction counter.
|
||||
*
|
||||
* @property DataSource._tId
|
||||
* @type Number
|
||||
* @static
|
||||
* @private
|
||||
* @default 0
|
||||
*/
|
||||
_tId: 0,
|
||||
|
||||
/**
|
||||
* Executes a given callback. The third param determines whether to execute
|
||||
*
|
||||
* @method DataSource.issueCallback
|
||||
* @param callback {Object} The callback object.
|
||||
* @param params {Array} params to be passed to the callback method
|
||||
* @param error {Boolean} whether an error occurred
|
||||
* @static
|
||||
*/
|
||||
issueCallback: function (e) {
|
||||
if(e.callback) {
|
||||
var callbackFunc = (e.error && e.callback.failure) || e.callback.success;
|
||||
if (callbackFunc) {
|
||||
callbackFunc(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DSLocal, Y.Base, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this._initEvents();
|
||||
},
|
||||
|
||||
/**
|
||||
* This method creates all the events for this module.
|
||||
* @method _initEvents
|
||||
* @private
|
||||
*/
|
||||
_initEvents: function() {
|
||||
/**
|
||||
* Fired when a data request is received.
|
||||
*
|
||||
* @event request
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object.</dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @preventable _defRequestFn
|
||||
*/
|
||||
this.publish("request", {defaultFn: Y.bind("_defRequestFn", this), queuable:true});
|
||||
|
||||
/**
|
||||
* Fired when raw data is received.
|
||||
*
|
||||
* @event data
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @preventable _defDataFn
|
||||
*/
|
||||
this.publish("data", {defaultFn: Y.bind("_defDataFn", this), queuable:true});
|
||||
|
||||
/**
|
||||
* Fired when response is returned.
|
||||
*
|
||||
* @event response
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* <dt>response (Object)</dt> <dd>Normalized response object with the following properties:
|
||||
* <dl>
|
||||
* <dt>results (Object)</dt> <dd>Parsed results.</dd>
|
||||
* <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
|
||||
* <dt>error (Boolean)</dt> <dd>Error flag.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* </dl>
|
||||
* @preventable _defResponseFn
|
||||
*/
|
||||
this.publish("response", {defaultFn: Y.bind("_defResponseFn", this), queuable:true});
|
||||
|
||||
/**
|
||||
* Fired when an error is encountered.
|
||||
*
|
||||
* @event error
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* <dt>response (Object)</dt> <dd>Normalized response object with the following properties:
|
||||
* <dl>
|
||||
* <dt>results (Object)</dt> <dd>Parsed results.</dd>
|
||||
* <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
|
||||
* <dt>error (Object)</dt> <dd>Error object.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* </dl>
|
||||
*/
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* Manages request/response transaction. Must fire <code>response</code>
|
||||
* event when response is received. This method should be implemented by
|
||||
* subclasses to achieve more complex behavior such as accessing remote data.
|
||||
*
|
||||
* @method _defRequestFn
|
||||
* @param e {Event.Facade} Event Facadewith the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defRequestFn: function(e) {
|
||||
var data = this.get("source");
|
||||
|
||||
// Problematic data
|
||||
if(LANG.isUndefined(data)) {
|
||||
e.error = new Error("Local source undefined");
|
||||
}
|
||||
if(e.error) {
|
||||
this.fire("error", e);
|
||||
}
|
||||
|
||||
this.fire("data", Y.mix({data:data}, e));
|
||||
},
|
||||
|
||||
/**
|
||||
* Normalizes raw data into a response that includes results and meta properties.
|
||||
*
|
||||
* @method _defDataFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defDataFn: function(e) {
|
||||
var data = e.data,
|
||||
meta = e.meta,
|
||||
response = {
|
||||
results: (LANG.isArray(data)) ? data : [data],
|
||||
meta: (meta) ? meta : {}
|
||||
};
|
||||
|
||||
this.fire("response", Y.mix({response: response}, e));
|
||||
},
|
||||
|
||||
/**
|
||||
* Sends data as a normalized response to callback.
|
||||
*
|
||||
* @method _defResponseFn
|
||||
* @param e {Event.Facade} Event Facade with the following properties:
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>cfg (Object)</dt> <dd>Configuration object.</dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* <dt>response (Object)</dt> <dd>Normalized response object with the following properties:
|
||||
* <dl>
|
||||
* <dt>results (Object)</dt> <dd>Parsed results.</dd>
|
||||
* <dt>meta (Object)</dt> <dd>Parsed meta data.</dd>
|
||||
* <dt>error (Boolean)</dt> <dd>Error flag.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_defResponseFn: function(e) {
|
||||
// Send the response back to the callback
|
||||
DSLocal.issueCallback(e);
|
||||
},
|
||||
|
||||
/**
|
||||
* Generates a unique transaction ID and fires <code>request</code> event.
|
||||
*
|
||||
* @method sendRequest
|
||||
* @param request {Object} Request.
|
||||
* @param callback {Object} An object literal with the following properties:
|
||||
* <dl>
|
||||
* <dt><code>success</code></dt>
|
||||
* <dd>The function to call when the data is ready.</dd>
|
||||
* <dt><code>failure</code></dt>
|
||||
* <dd>The function to call upon a response failure condition.</dd>
|
||||
* <dt><code>argument</code></dt>
|
||||
* <dd>Arbitrary data payload that will be passed back to the success and failure handlers.</dd>
|
||||
* </dl>
|
||||
* @param cfg {Object} Configuration object
|
||||
* @return {Number} Transaction ID.
|
||||
*/
|
||||
sendRequest: function(request, callback, cfg) {
|
||||
var tId = DSLocal._tId++;
|
||||
this.fire("request", {tId:tId, request:request, callback:callback, cfg:cfg || {}});
|
||||
return tId;
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace("DataSource").Local = DSLocal;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['base']});
|
||||
9
jssource/src_files/include/javascript/yui3/build/datasource/datasource-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/datasource/datasource-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-polling-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-polling-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-polling",function(C){var A=C.Lang,B=function(){this._intervals={};};B.prototype={_intervals:null,setInterval:function(F,E,G){var D=C.later(F,this,this.sendRequest,[E,G],true);this._intervals[D.id]=D;return D.id;},clearInterval:function(E,D){E=D||E;if(this._intervals[E]){this._intervals[E].cancel();delete this._intervals[E];}},clearAllIntervals:function(){C.each(this._intervals,this.clearInterval,this);}};C.augment(C.DataSource.Local,B);},"3.0.0",{requires:["datasource-local"]});
|
||||
93
jssource/src_files/include/javascript/yui3/build/datasource/datasource-polling.js
vendored
Normal file
93
jssource/src_files/include/javascript/yui3/build/datasource/datasource-polling.js
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-polling', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with polling functionality.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-polling
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds polling to the DataSource Utility.
|
||||
* @class Pollable
|
||||
* @extends DataSource.Local
|
||||
*/
|
||||
var LANG = Y.Lang,
|
||||
|
||||
Pollable = function() {
|
||||
this._intervals = {};
|
||||
};
|
||||
|
||||
Pollable.prototype = {
|
||||
|
||||
/**
|
||||
* @property _intervals
|
||||
* @description Hash of polling interval IDs that have been enabled,
|
||||
* stored here to be able to clear all intervals.
|
||||
* @private
|
||||
*/
|
||||
_intervals: null,
|
||||
|
||||
/**
|
||||
* Sets up a polling mechanism to send requests at set intervals and forward
|
||||
* responses to given callback.
|
||||
*
|
||||
* @method setInterval
|
||||
* @param msec {Number} Length of interval in milliseconds.
|
||||
* @param request {Object} Request object.
|
||||
* @param callback {Object} An object literal with the following properties:
|
||||
* <dl>
|
||||
* <dt><code>success</code></dt>
|
||||
* <dd>The function to call when the data is ready.</dd>
|
||||
* <dt><code>failure</code></dt>
|
||||
* <dd>The function to call upon a response failure condition.</dd>
|
||||
* <dt><code>argument</code></dt>
|
||||
* <dd>Arbitrary data that will be passed back to the success and failure handlers.</dd>
|
||||
* </dl>
|
||||
* @return {Number} Interval ID.
|
||||
*/
|
||||
setInterval: function(msec, request, callback) {
|
||||
var x = Y.later(msec, this, this.sendRequest, [request, callback], true);
|
||||
this._intervals[x.id] = x;
|
||||
return x.id;
|
||||
},
|
||||
|
||||
/**
|
||||
* Disables polling mechanism associated with the given interval ID.
|
||||
*
|
||||
* @method clearInterval
|
||||
* @param id {Number} Interval ID.
|
||||
*/
|
||||
clearInterval: function(id, key) {
|
||||
// In case of being called by clearAllIntervals()
|
||||
id = key || id;
|
||||
if(this._intervals[id]) {
|
||||
// Clear the interval
|
||||
this._intervals[id].cancel();
|
||||
// Clear from tracker
|
||||
delete this._intervals[id];
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Clears all intervals.
|
||||
*
|
||||
* @method clearAllIntervals
|
||||
*/
|
||||
clearAllIntervals: function() {
|
||||
Y.each(this._intervals, this.clearInterval, this);
|
||||
}
|
||||
};
|
||||
|
||||
Y.augment(Y.DataSource.Local, Pollable);
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['datasource-local']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-textschema-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-textschema-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-textschema",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"schema",NAME:"dataSourceTextSchema",ATTRS:{schema:{}}});B.extend(A,B.Plugin.Base,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(E){var D=(B.DataSource.IO&&(this.get("host") instanceof B.DataSource.IO)&&B.Lang.isString(E.data.responseText))?E.data.responseText:E.data,C=B.DataSchema.Text.apply(this.get("schema"),D);if(!C){C={meta:{},results:D};}this.get("host").fire("response",B.mix({response:C},E));return new B.Do.Halt("DataSourceTextSchema plugin halted _defDataFn");}});B.namespace("Plugin").DataSourceTextSchema=A;},"3.0.0",{requires:["plugin","datasource-local","dataschema-text"]});
|
||||
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-textschema.js
vendored
Normal file
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-textschema.js
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-textschema', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with schema-parsing on text data.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-textschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds schema-parsing to the DataSource Utility.
|
||||
* @class DataSourceTextSchema
|
||||
* @extends Plugin.Base
|
||||
*/
|
||||
var DataSourceTextSchema = function() {
|
||||
DataSourceTextSchema.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
Y.mix(DataSourceTextSchema, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "schema"
|
||||
*/
|
||||
NS: "schema",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceTextSchema"
|
||||
*/
|
||||
NAME: "dataSourceTextSchema",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSourceTextSchema Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
schema: {
|
||||
//value: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DataSourceTextSchema, Y.Plugin.Base, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this.doBefore("_defDataFn", this._beforeDefDataFn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses raw data into a normalized response.
|
||||
*
|
||||
* @method _beforeDefDataFn
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefDataFn: function(e) {
|
||||
var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && Y.Lang.isString(e.data.responseText)) ? e.data.responseText : e.data,
|
||||
response = Y.DataSchema.Text.apply(this.get("schema"), data);
|
||||
|
||||
// Default
|
||||
if(!response) {
|
||||
response = {
|
||||
meta: {},
|
||||
results: data
|
||||
};
|
||||
}
|
||||
|
||||
this.get("host").fire("response", Y.mix({response:response}, e));
|
||||
return new Y.Do.Halt("DataSourceTextSchema plugin halted _defDataFn");
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').DataSourceTextSchema = DataSourceTextSchema;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['plugin', 'datasource-local', 'dataschema-text']});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-xmlschema-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datasource/datasource-xmlschema-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datasource-xmlschema",function(B){var A=function(){A.superclass.constructor.apply(this,arguments);};B.mix(A,{NS:"schema",NAME:"dataSourceXMLSchema",ATTRS:{schema:{}}});B.extend(A,B.Plugin.Base,{initializer:function(C){this.doBefore("_defDataFn",this._beforeDefDataFn);},_beforeDefDataFn:function(E){var D=(B.DataSource.IO&&(this.get("host") instanceof B.DataSource.IO)&&E.data.responseXML&&(E.data.responseXML.nodeType===9))?E.data.responseXML:E.data,C=B.DataSchema.XML.apply(this.get("schema"),D);if(!C){C={meta:{},results:D};}this.get("host").fire("response",B.mix({response:C},E));return new B.Do.Halt("DataSourceXMLSchema plugin halted _defDataFn");}});B.namespace("Plugin").DataSourceXMLSchema=A;},"3.0.0",{requires:["plugin","datasource-local","dataschema-xml"]});
|
||||
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-xmlschema.js
vendored
Normal file
113
jssource/src_files/include/javascript/yui3/build/datasource/datasource-xmlschema.js
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datasource-xmlschema', function(Y) {
|
||||
|
||||
/**
|
||||
* Extends DataSource with schema-parsing on XML data.
|
||||
*
|
||||
* @module datasource
|
||||
* @submodule datasource-xmlschema
|
||||
*/
|
||||
|
||||
/**
|
||||
* Adds schema-parsing to the DataSource Utility.
|
||||
* @class DataSourceXMLSchema
|
||||
* @extends Plugin.Base
|
||||
*/
|
||||
var DataSourceXMLSchema = function() {
|
||||
DataSourceXMLSchema.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
Y.mix(DataSourceXMLSchema, {
|
||||
/**
|
||||
* The namespace for the plugin. This will be the property on the host which
|
||||
* references the plugin instance.
|
||||
*
|
||||
* @property NS
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "schema"
|
||||
*/
|
||||
NS: "schema",
|
||||
|
||||
/**
|
||||
* Class name.
|
||||
*
|
||||
* @property NAME
|
||||
* @type String
|
||||
* @static
|
||||
* @final
|
||||
* @value "dataSourceXMLSchema"
|
||||
*/
|
||||
NAME: "dataSourceXMLSchema",
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DataSourceXMLSchema Attributes
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
ATTRS: {
|
||||
schema: {
|
||||
//value: {}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Y.extend(DataSourceXMLSchema, Y.Plugin.Base, {
|
||||
/**
|
||||
* Internal init() handler.
|
||||
*
|
||||
* @method initializer
|
||||
* @param config {Object} Config object.
|
||||
* @private
|
||||
*/
|
||||
initializer: function(config) {
|
||||
this.doBefore("_defDataFn", this._beforeDefDataFn);
|
||||
},
|
||||
|
||||
/**
|
||||
* Parses raw data into a normalized response.
|
||||
*
|
||||
* @method _beforeDefDataFn
|
||||
* <dl>
|
||||
* <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
|
||||
* <dt>request (Object)</dt> <dd>The request.</dd>
|
||||
* <dt>callback (Object)</dt> <dd>The callback object with the following properties:
|
||||
* <dl>
|
||||
* <dt>success (Function)</dt> <dd>Success handler.</dd>
|
||||
* <dt>failure (Function)</dt> <dd>Failure handler.</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>data (Object)</dt> <dd>Raw data.</dd>
|
||||
* </dl>
|
||||
* @protected
|
||||
*/
|
||||
_beforeDefDataFn: function(e) {
|
||||
var data = (Y.DataSource.IO && (this.get("host") instanceof Y.DataSource.IO) && e.data.responseXML && (e.data.responseXML.nodeType === 9)) ? e.data.responseXML : e.data,
|
||||
response = Y.DataSchema.XML.apply(this.get("schema"), data);
|
||||
|
||||
// Default
|
||||
if(!response) {
|
||||
response = {
|
||||
meta: {},
|
||||
results: data
|
||||
};
|
||||
}
|
||||
|
||||
this.get("host").fire("response", Y.mix({response:response}, e));
|
||||
return new Y.Do.Halt("DataSourceXMLSchema plugin halted _defDataFn");
|
||||
}
|
||||
});
|
||||
|
||||
Y.namespace('Plugin').DataSourceXMLSchema = DataSourceXMLSchema;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['plugin', 'datasource-local', 'dataschema-xml']});
|
||||
1463
jssource/src_files/include/javascript/yui3/build/datasource/datasource.js
vendored
Normal file
1463
jssource/src_files/include/javascript/yui3/build/datasource/datasource.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-format-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-format-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-date-format",function(D){var A=function(E,G,F){if(typeof F==="undefined"){F=10;}G=G.toString();for(;parseInt(E,10)<F&&F>1;F/=10){E=G+E;}return E.toString();};D.config.dateFormat=D.config.dateFormat||"%Y-%m-%d";D.config.locale=D.config.locale||"en";var C={formats:{a:function(F,E){return E.a[F.getDay()];},A:function(F,E){return E.A[F.getDay()];},b:function(F,E){return E.b[F.getMonth()];},B:function(F,E){return E.B[F.getMonth()];},C:function(E){return A(parseInt(E.getFullYear()/100,10),0);},d:["getDate","0"],e:["getDate"," "],g:function(E){return A(parseInt(C.formats.G(E)%100,10),0);},G:function(G){var H=G.getFullYear();var F=parseInt(C.formats.V(G),10);var E=parseInt(C.formats.W(G),10);if(E>F){H++;}else{if(E===0&&F>=52){H--;}}return H;},H:["getHours","0"],I:function(F){var E=F.getHours()%12;return A(E===0?12:E,0);},j:function(I){var H=new Date(""+I.getFullYear()+"/1/1 GMT");var F=new Date(""+I.getFullYear()+"/"+(I.getMonth()+1)+"/"+I.getDate()+" GMT");var E=F-H;var G=parseInt(E/60000/60/24,10)+1;return A(G,0,100);},k:["getHours"," "],l:function(F){var E=F.getHours()%12;return A(E===0?12:E," ");},m:function(E){return A(E.getMonth()+1,0);},M:["getMinutes","0"],p:function(F,E){return E.p[F.getHours()>=12?1:0];},P:function(F,E){return E.P[F.getHours()>=12?1:0];},s:function(F,E){return parseInt(F.getTime()/1000,10);},S:["getSeconds","0"],u:function(E){var F=E.getDay();return F===0?7:F;},U:function(H){var E=parseInt(C.formats.j(H),10);var G=6-H.getDay();var F=parseInt((E+G)/7,10);return A(F,0);},V:function(H){var G=parseInt(C.formats.W(H),10);var E=(new Date(""+H.getFullYear()+"/1/1")).getDay();var F=G+(E>4||E<=1?0:1);if(F===53&&(new Date(""+H.getFullYear()+"/12/31")).getDay()<4){F=1;}else{if(F===0){F=C.formats.V(new Date(""+(H.getFullYear()-1)+"/12/31"));}}return A(F,0);},w:"getDay",W:function(H){var E=parseInt(C.formats.j(H),10);var G=7-C.formats.u(H);var F=parseInt((E+G)/7,10);return A(F,0,10);},y:function(E){return A(E.getFullYear()%100,0);},Y:"getFullYear",z:function(G){var F=G.getTimezoneOffset();var E=A(parseInt(Math.abs(F/60),10),0);var I=A(Math.abs(F%60),0);return(F>0?"-":"+")+E+I;},Z:function(E){var F=E.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/,"$2").replace(/[a-z ]/g,"");if(F.length>4){F=C.formats.z(E);}return F;},"%":function(E){return"%";}},aggregates:{c:"locale",D:"%m/%d/%y",F:"%Y-%m-%d",h:"%b",n:"\n",r:"locale",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"},format:function(N,H){H=H||{};if(!D.Lang.isDate(N)){return D.Lang.isValue(N)?N:"";}var M=H.format||D.config.dateFormat,F=H.locale||D.config.locale,L=D.DataType.Date.Locale;F=F.replace(/_/g,"-");if(!L[F]){var G=F.replace(/-[a-zA-Z]+$/,"");if(G in L){F=G;}else{if(D.config.locale in L){F=D.config.locale;}else{F="en";}}}var J=L[F];var I=function(P,O){var Q=C.aggregates[O];return(Q==="locale"?J[O]:Q);};var E=function(P,O){var Q=C.formats[O];switch(D.Lang.type(Q)){case"string":return N[Q]();case"function":return Q.call(N,N,J);case"array":if(D.Lang.type(Q[0])==="string"){return A(N[Q[0]](),Q[1]);}default:return O;}};while(M.match(/%[cDFhnrRtTxX]/)){M=M.replace(/%([cDFhnrRtTxX])/g,I);}var K=M.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g,E);I=E=undefined;return K;}};D.mix(D.namespace("DataType.Date"),C);var B={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],r:"%I:%M:%S %p",x:"%d/%m/%y",X:"%T"};D.namespace("DataType.Date.Locale");D.DataType.Date.Locale["en"]=B;D.DataType.Date.Locale["en-US"]=D.merge(B,{c:"%a %d %b %Y %I:%M:%S %p %Z",x:"%m/%d/%Y",X:"%I:%M:%S %p"});D.DataType.Date.Locale["en-GB"]=D.merge(B,{r:"%l:%M:%S %P %Z"});D.DataType.Date.Locale["en-AU"]=D.merge(B);},"3.0.0");
|
||||
443
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-format.js
vendored
Normal file
443
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-format.js
vendored
Normal file
@@ -0,0 +1,443 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-date-format', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataType Utility provides type-conversion and string-formatting
|
||||
* convenience methods for various JavaScript object types.
|
||||
*
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format date submodule implements strftime formatters for javascript based on the
|
||||
* Open Group specification defined at
|
||||
* http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
|
||||
* This implementation does not include modified conversion specifiers (i.e., Ex and Ox)
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Date provides a set of utility functions to operate against Date objects.
|
||||
*
|
||||
* @class DataType.Date
|
||||
* @static
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pad a number with leading spaces, zeroes or something else
|
||||
* @method xPad
|
||||
* @param x {Number} The number to be padded
|
||||
* @param pad {String} The character to pad the number with
|
||||
* @param r {Number} (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits.
|
||||
* @private
|
||||
*/
|
||||
var xPad=function (x, pad, r)
|
||||
{
|
||||
if(typeof r === "undefined")
|
||||
{
|
||||
r=10;
|
||||
}
|
||||
pad = pad.toString();
|
||||
for( ; parseInt(x, 10)<r && r>1; r/=10) {
|
||||
x = pad + x;
|
||||
}
|
||||
return x.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Default date format.
|
||||
*
|
||||
* @for config
|
||||
* @property dateFormat
|
||||
* @type String
|
||||
* @value "%Y-%m-%d"
|
||||
*/
|
||||
Y.config.dateFormat = Y.config.dateFormat || "%Y-%m-%d";
|
||||
|
||||
/**
|
||||
* Default locale for the YUI instance.
|
||||
*
|
||||
* @property locale
|
||||
* @type String
|
||||
* @value "en"
|
||||
*/
|
||||
Y.config.locale = Y.config.locale || "en";
|
||||
|
||||
var Dt = {
|
||||
formats: {
|
||||
a: function (d, l) { return l.a[d.getDay()]; },
|
||||
A: function (d, l) { return l.A[d.getDay()]; },
|
||||
b: function (d, l) { return l.b[d.getMonth()]; },
|
||||
B: function (d, l) { return l.B[d.getMonth()]; },
|
||||
C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },
|
||||
d: ["getDate", "0"],
|
||||
e: ["getDate", " "],
|
||||
g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },
|
||||
G: function (d) {
|
||||
var y = d.getFullYear();
|
||||
var V = parseInt(Dt.formats.V(d), 10);
|
||||
var W = parseInt(Dt.formats.W(d), 10);
|
||||
|
||||
if(W > V) {
|
||||
y++;
|
||||
} else if(W===0 && V>=52) {
|
||||
y--;
|
||||
}
|
||||
|
||||
return y;
|
||||
},
|
||||
H: ["getHours", "0"],
|
||||
I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },
|
||||
j: function (d) {
|
||||
var gmd_1 = new Date("" + d.getFullYear() + "/1/1 GMT");
|
||||
var gmdate = new Date("" + d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate() + " GMT");
|
||||
var ms = gmdate - gmd_1;
|
||||
var doy = parseInt(ms/60000/60/24, 10)+1;
|
||||
return xPad(doy, 0, 100);
|
||||
},
|
||||
k: ["getHours", " "],
|
||||
l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, " "); },
|
||||
m: function (d) { return xPad(d.getMonth()+1, 0); },
|
||||
M: ["getMinutes", "0"],
|
||||
p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
s: function (d, l) { return parseInt(d.getTime()/1000, 10); },
|
||||
S: ["getSeconds", "0"],
|
||||
u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },
|
||||
U: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 6-d.getDay();
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0);
|
||||
},
|
||||
V: function (d) {
|
||||
var woy = parseInt(Dt.formats.W(d), 10);
|
||||
var dow1_1 = (new Date("" + d.getFullYear() + "/1/1")).getDay();
|
||||
// First week is 01 and not 00 as in the case of %U and %W,
|
||||
// so we add 1 to the final result except if day 1 of the year
|
||||
// is a Monday (then %W returns 01).
|
||||
// We also need to subtract 1 if the day 1 of the year is
|
||||
// Friday-Sunday, so the resulting equation becomes:
|
||||
var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);
|
||||
if(idow === 53 && (new Date("" + d.getFullYear() + "/12/31")).getDay() < 4)
|
||||
{
|
||||
idow = 1;
|
||||
}
|
||||
else if(idow === 0)
|
||||
{
|
||||
idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
|
||||
}
|
||||
|
||||
return xPad(idow, 0);
|
||||
},
|
||||
w: "getDay",
|
||||
W: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 7-Dt.formats.u(d);
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0, 10);
|
||||
},
|
||||
y: function (d) { return xPad(d.getFullYear()%100, 0); },
|
||||
Y: "getFullYear",
|
||||
z: function (d) {
|
||||
var o = d.getTimezoneOffset();
|
||||
var H = xPad(parseInt(Math.abs(o/60), 10), 0);
|
||||
var M = xPad(Math.abs(o%60), 0);
|
||||
return (o>0?"-":"+") + H + M;
|
||||
},
|
||||
Z: function (d) {
|
||||
var tz = d.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
|
||||
if(tz.length > 4) {
|
||||
tz = Dt.formats.z(d);
|
||||
}
|
||||
return tz;
|
||||
},
|
||||
"%": function (d) { return "%"; }
|
||||
},
|
||||
|
||||
aggregates: {
|
||||
c: "locale",
|
||||
D: "%m/%d/%y",
|
||||
F: "%Y-%m-%d",
|
||||
h: "%b",
|
||||
n: "\n",
|
||||
r: "locale",
|
||||
R: "%H:%M",
|
||||
t: "\t",
|
||||
T: "%H:%M:%S",
|
||||
x: "locale",
|
||||
X: "locale"
|
||||
//"+": "%a %b %e %T %Z %Y"
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes a native JavaScript Date and formats it as a string for display to user.
|
||||
*
|
||||
* @for DataType.Date
|
||||
* @method format
|
||||
* @param oDate {Date} Date.
|
||||
* @param oConfig {Object} (Optional) Object literal of configuration values:
|
||||
* <dl>
|
||||
* <dt>format {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* <p>
|
||||
* Any strftime string is supported, such as "%I:%M:%S %p". strftime has several format specifiers defined by the Open group at
|
||||
* <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>
|
||||
* PHP added a few of its own, defined at <a href="http://www.php.net/strftime">http://www.php.net/strftime</a>
|
||||
* </p>
|
||||
* <p>
|
||||
* This javascript implementation supports all the PHP specifiers and a few more. The full list is below.
|
||||
* </p>
|
||||
* <p>
|
||||
* If not specified, it defaults to the ISO8601 standard date format: %Y-%m-%d. This may be overridden by changing Y.config.dateFormat
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>
|
||||
* <dt>%A</dt> <dd>full weekday name according to the current locale</dd>
|
||||
* <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>
|
||||
* <dt>%B</dt> <dd>full month name according to the current locale</dd>
|
||||
* <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>
|
||||
* <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>
|
||||
* <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>
|
||||
* <dt>%D</dt> <dd>same as %m/%d/%y</dd>
|
||||
* <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range " 1" to "31")</dd>
|
||||
* <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>
|
||||
* <dt>%g</dt> <dd>like %G, but without the century</dd>
|
||||
* <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>
|
||||
* <dt>%h</dt> <dd>same as %b</dd>
|
||||
* <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>
|
||||
* <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>
|
||||
* <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>
|
||||
* <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>
|
||||
* <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>
|
||||
* <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>
|
||||
* <dt>%M</dt> <dd>minute as a decimal number</dd>
|
||||
* <dt>%n</dt> <dd>newline character</dd>
|
||||
* <dt>%p</dt> <dd>either "AM" or "PM" according to the given time value, or the corresponding strings for the current locale</dd>
|
||||
* <dt>%P</dt> <dd>like %p, but lower case</dd>
|
||||
* <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>
|
||||
* <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>
|
||||
* <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>
|
||||
* <dt>%S</dt> <dd>second as a decimal number</dd>
|
||||
* <dt>%t</dt> <dd>tab character</dd>
|
||||
* <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>
|
||||
* <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>
|
||||
* <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Sunday as the first day of the first week</dd>
|
||||
* <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,
|
||||
* range 01 to 53, where week 1 is the first week that has at least 4 days
|
||||
* in the current year, and with Monday as the first day of the week.</dd>
|
||||
* <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>
|
||||
* <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Monday as the first day of the first week</dd>
|
||||
* <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>
|
||||
* <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>
|
||||
* <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>
|
||||
* <dt>%Y</dt> <dd>year as a decimal number including the century</dd>
|
||||
* <dt>%z</dt> <dd>numerical time zone representation</dd>
|
||||
* <dt>%Z</dt> <dd>time zone name or abbreviation</dd>
|
||||
* <dt>%%</dt> <dd>a literal "%" character</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>locale {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* The locale to use when displaying days of week, months of the year, and other locale specific
|
||||
* strings. If not specified, this defaults to "en" (though this may be overridden by changing Y.config.locale).
|
||||
* The following locales are built in:
|
||||
* <dl>
|
||||
* <dt>en</dt>
|
||||
* <dd>English</dd>
|
||||
* <dt>en-US</dt>
|
||||
* <dd>US English</dd>
|
||||
* <dt>en-GB</dt>
|
||||
* <dd>British English</dd>
|
||||
* <dt>en-AU</dt>
|
||||
* <dd>Australian English (identical to British English)</dd>
|
||||
* </dl>
|
||||
* More locales may be added by subclassing of Y.DataType.Date.Locale["en"].
|
||||
* See Y.DataType.Date.Locale for more information.
|
||||
* </dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted date for display.
|
||||
*/
|
||||
format : function (oDate, oConfig) {
|
||||
oConfig = oConfig || {};
|
||||
|
||||
if(!Y.Lang.isDate(oDate)) {
|
||||
return Y.Lang.isValue(oDate) ? oDate : "";
|
||||
}
|
||||
|
||||
var format = oConfig.format || Y.config.dateFormat,
|
||||
sLocale = oConfig.locale || Y.config.locale,
|
||||
LOCALE = Y.DataType.Date.Locale;
|
||||
|
||||
sLocale = sLocale.replace(/_/g, "-");
|
||||
|
||||
// Make sure we have a definition for the requested locale, or default to en.
|
||||
if(!LOCALE[sLocale]) {
|
||||
var tmpLocale = sLocale.replace(/-[a-zA-Z]+$/, "");
|
||||
if(tmpLocale in LOCALE) {
|
||||
sLocale = tmpLocale;
|
||||
} else if(Y.config.locale in LOCALE) {
|
||||
sLocale = Y.config.locale;
|
||||
} else {
|
||||
sLocale = "en";
|
||||
}
|
||||
}
|
||||
|
||||
var aLocale = LOCALE[sLocale];
|
||||
|
||||
var replace_aggs = function (m0, m1) {
|
||||
var f = Dt.aggregates[m1];
|
||||
return (f === "locale" ? aLocale[m1] : f);
|
||||
};
|
||||
|
||||
var replace_formats = function (m0, m1) {
|
||||
var f = Dt.formats[m1];
|
||||
switch(Y.Lang.type(f)) {
|
||||
case "string": // string => built in date function
|
||||
return oDate[f]();
|
||||
case "function": // function => our own function
|
||||
return f.call(oDate, oDate, aLocale);
|
||||
case "array": // built in function with padding
|
||||
if(Y.Lang.type(f[0]) === "string") {
|
||||
return xPad(oDate[f[0]](), f[1]);
|
||||
} // no break; (fall through to default:)
|
||||
default:
|
||||
return m1;
|
||||
}
|
||||
};
|
||||
|
||||
// First replace aggregates (run in a loop because an agg may be made up of other aggs)
|
||||
while(format.match(/%[cDFhnrRtTxX]/)) {
|
||||
format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);
|
||||
}
|
||||
|
||||
// Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)
|
||||
var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);
|
||||
|
||||
replace_aggs = replace_formats = undefined;
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), Dt);
|
||||
|
||||
/**
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Date.Locale class is a container for all localised date strings
|
||||
* used by Y.DataType.Date. It is used internally, but may be extended
|
||||
* to provide new date localisations.
|
||||
*
|
||||
* To create your own Locale, follow these steps:
|
||||
* <ol>
|
||||
* <li>Find an existing locale that matches closely with your needs</li>
|
||||
* <li>Use this as your base class. Use Y.DataType.Date.Locale["en"] if nothing
|
||||
* matches.</li>
|
||||
* <li>Create your own class as an extension of the base class using
|
||||
* Y.merge, and add your own localisations where needed.</li>
|
||||
* </ol>
|
||||
* See the Y.DataType.Date.Locale["en-US"] and Y.DataType.Date.Locale["en-GB"]
|
||||
* classes which extend Y.DataType.Date.Locale["en"].
|
||||
*
|
||||
* For example, to implement locales for French french and Canadian french,
|
||||
* we would do the following:
|
||||
* <ol>
|
||||
* <li>For French french, we have no existing similar locale, so use
|
||||
* Y.DataType.Date.Locale["en"] as the base, and extend it:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr"] = Y.merge(Y.DataType.Date.Locale, {
|
||||
* a: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"],
|
||||
* A: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
|
||||
* b: ["jan", "fév", "mar", "avr", "mai", "jun", "jui", "aoû", "sep", "oct", "nov", "déc"],
|
||||
* B: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
|
||||
* c: "%a %d %b %Y %T %Z",
|
||||
* p: ["", ""],
|
||||
* P: ["", ""],
|
||||
* x: "%d.%m.%Y",
|
||||
* X: "%T"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* <li>For Canadian french, we start with French french and change the meaning of \%x:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr-CA"] = Y.merge(Y.DataType.Date.Locale["fr"], {
|
||||
* x: "%Y-%m-%d"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* With that, you can use your new locales:
|
||||
* <pre>
|
||||
* var d = new Date("2008/04/22");
|
||||
* Y.DataType.Date.format(d, { format: "%A, %d %B == %x", locale: "fr" });
|
||||
* </pre>
|
||||
* will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 22.04.2008
|
||||
* </pre>
|
||||
* And
|
||||
* <pre>
|
||||
* Y.DataType.Date.format(d, {format: "%A, %d %B == %x", locale: "fr-CA" });
|
||||
* </pre>
|
||||
* Will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 2008-04-22
|
||||
* </pre>
|
||||
* @requires oop
|
||||
* @class DataType.Date.Locale
|
||||
* @static
|
||||
*/
|
||||
var YDateEn = {
|
||||
a: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
A: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
b: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
B: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
c: "%a %d %b %Y %T %Z",
|
||||
p: ["AM", "PM"],
|
||||
P: ["am", "pm"],
|
||||
r: "%I:%M:%S %p",
|
||||
x: "%d/%m/%y",
|
||||
X: "%T"
|
||||
};
|
||||
|
||||
Y.namespace("DataType.Date.Locale");
|
||||
|
||||
Y.DataType.Date.Locale["en"] = YDateEn;
|
||||
|
||||
Y.DataType.Date.Locale["en-US"] = Y.merge(YDateEn, {
|
||||
c: "%a %d %b %Y %I:%M:%S %p %Z",
|
||||
x: "%m/%d/%Y",
|
||||
X: "%I:%M:%S %p"
|
||||
});
|
||||
|
||||
Y.DataType.Date.Locale["en-GB"] = Y.merge(YDateEn, {
|
||||
r: "%l:%M:%S %P %Z"
|
||||
});
|
||||
Y.DataType.Date.Locale["en-AU"] = Y.merge(YDateEn);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-date-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Date"),{parse:function(D){var C=null;if(!(A.isDate(D))){C=new Date(D);}else{return C;}if(A.isDate(C)&&(C!="Invalid Date")&&!isNaN(C)){return C;}else{return null;}}});B.namespace("Parsers").date=B.DataType.Date.parse;},"3.0.0");YUI.add("datatype-date-format",function(D){var A=function(E,G,F){if(typeof F==="undefined"){F=10;}G=G.toString();for(;parseInt(E,10)<F&&F>1;F/=10){E=G+E;}return E.toString();};D.config.dateFormat=D.config.dateFormat||"%Y-%m-%d";D.config.locale=D.config.locale||"en";var C={formats:{a:function(F,E){return E.a[F.getDay()];},A:function(F,E){return E.A[F.getDay()];},b:function(F,E){return E.b[F.getMonth()];},B:function(F,E){return E.B[F.getMonth()];},C:function(E){return A(parseInt(E.getFullYear()/100,10),0);},d:["getDate","0"],e:["getDate"," "],g:function(E){return A(parseInt(C.formats.G(E)%100,10),0);},G:function(G){var H=G.getFullYear();var F=parseInt(C.formats.V(G),10);var E=parseInt(C.formats.W(G),10);if(E>F){H++;}else{if(E===0&&F>=52){H--;}}return H;},H:["getHours","0"],I:function(F){var E=F.getHours()%12;return A(E===0?12:E,0);},j:function(I){var H=new Date(""+I.getFullYear()+"/1/1 GMT");var F=new Date(""+I.getFullYear()+"/"+(I.getMonth()+1)+"/"+I.getDate()+" GMT");var E=F-H;var G=parseInt(E/60000/60/24,10)+1;return A(G,0,100);},k:["getHours"," "],l:function(F){var E=F.getHours()%12;return A(E===0?12:E," ");},m:function(E){return A(E.getMonth()+1,0);},M:["getMinutes","0"],p:function(F,E){return E.p[F.getHours()>=12?1:0];},P:function(F,E){return E.P[F.getHours()>=12?1:0];},s:function(F,E){return parseInt(F.getTime()/1000,10);},S:["getSeconds","0"],u:function(E){var F=E.getDay();return F===0?7:F;},U:function(H){var E=parseInt(C.formats.j(H),10);var G=6-H.getDay();var F=parseInt((E+G)/7,10);return A(F,0);},V:function(H){var G=parseInt(C.formats.W(H),10);var E=(new Date(""+H.getFullYear()+"/1/1")).getDay();var F=G+(E>4||E<=1?0:1);if(F===53&&(new Date(""+H.getFullYear()+"/12/31")).getDay()<4){F=1;}else{if(F===0){F=C.formats.V(new Date(""+(H.getFullYear()-1)+"/12/31"));}}return A(F,0);},w:"getDay",W:function(H){var E=parseInt(C.formats.j(H),10);var G=7-C.formats.u(H);var F=parseInt((E+G)/7,10);return A(F,0,10);},y:function(E){return A(E.getFullYear()%100,0);},Y:"getFullYear",z:function(G){var F=G.getTimezoneOffset();var E=A(parseInt(Math.abs(F/60),10),0);var I=A(Math.abs(F%60),0);return(F>0?"-":"+")+E+I;},Z:function(E){var F=E.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/,"$2").replace(/[a-z ]/g,"");if(F.length>4){F=C.formats.z(E);}return F;},"%":function(E){return"%";}},aggregates:{c:"locale",D:"%m/%d/%y",F:"%Y-%m-%d",h:"%b",n:"\n",r:"locale",R:"%H:%M",t:"\t",T:"%H:%M:%S",x:"locale",X:"locale"},format:function(N,H){H=H||{};if(!D.Lang.isDate(N)){return D.Lang.isValue(N)?N:"";}var M=H.format||D.config.dateFormat,F=H.locale||D.config.locale,L=D.DataType.Date.Locale;F=F.replace(/_/g,"-");if(!L[F]){var G=F.replace(/-[a-zA-Z]+$/,"");if(G in L){F=G;}else{if(D.config.locale in L){F=D.config.locale;}else{F="en";}}}var J=L[F];var I=function(P,O){var Q=C.aggregates[O];return(Q==="locale"?J[O]:Q);};var E=function(P,O){var Q=C.formats[O];switch(D.Lang.type(Q)){case"string":return N[Q]();case"function":return Q.call(N,N,J);case"array":if(D.Lang.type(Q[0])==="string"){return A(N[Q[0]](),Q[1]);}default:return O;}};while(M.match(/%[cDFhnrRtTxX]/)){M=M.replace(/%([cDFhnrRtTxX])/g,I);}var K=M.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g,E);I=E=undefined;return K;}};D.mix(D.namespace("DataType.Date"),C);var B={a:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],A:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],b:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],B:["January","February","March","April","May","June","July","August","September","October","November","December"],c:"%a %d %b %Y %T %Z",p:["AM","PM"],P:["am","pm"],r:"%I:%M:%S %p",x:"%d/%m/%y",X:"%T"};D.namespace("DataType.Date.Locale");D.DataType.Date.Locale["en"]=B;D.DataType.Date.Locale["en-US"]=D.merge(B,{c:"%a %d %b %Y %I:%M:%S %p %Z",x:"%m/%d/%Y",X:"%I:%M:%S %p"});D.DataType.Date.Locale["en-GB"]=D.merge(B,{r:"%l:%M:%S %P %Z"});D.DataType.Date.Locale["en-AU"]=D.merge(B);},"3.0.0");YUI.add("datatype-date",function(A){},"3.0.0",{use:["datatype-date-parse","datatype-date-format"]});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-parse-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-parse-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-date-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Date"),{parse:function(D){var C=null;if(!(A.isDate(D))){C=new Date(D);}else{return C;}if(A.isDate(C)&&(C!="Invalid Date")&&!isNaN(C)){return C;}else{return null;}}});B.namespace("Parsers").date=B.DataType.Date.parse;},"3.0.0");
|
||||
53
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-parse.js
vendored
Normal file
53
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date-parse.js
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-date-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-parse
|
||||
* @for DataType.Date
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), {
|
||||
/**
|
||||
* Converts data to type Date.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
|
||||
* @return {Date} A Date, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var date = null;
|
||||
|
||||
//Convert to date
|
||||
if(!(LANG.isDate(data))) {
|
||||
date = new Date(data);
|
||||
}
|
||||
else {
|
||||
return date;
|
||||
}
|
||||
|
||||
// Validate
|
||||
if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
|
||||
return date;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").date = Y.DataType.Date.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
495
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date.js
vendored
Normal file
495
jssource/src_files/include/javascript/yui3/build/datatype/datatype-date.js
vendored
Normal file
@@ -0,0 +1,495 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-date-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-parse
|
||||
* @for DataType.Date
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), {
|
||||
/**
|
||||
* Converts data to type Date.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
|
||||
* @return {Date} A Date, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var date = null;
|
||||
|
||||
//Convert to date
|
||||
if(!(LANG.isDate(data))) {
|
||||
date = new Date(data);
|
||||
}
|
||||
else {
|
||||
return date;
|
||||
}
|
||||
|
||||
// Validate
|
||||
if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
|
||||
return date;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").date = Y.DataType.Date.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-date-format', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataType Utility provides type-conversion and string-formatting
|
||||
* convenience methods for various JavaScript object types.
|
||||
*
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format date submodule implements strftime formatters for javascript based on the
|
||||
* Open Group specification defined at
|
||||
* http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
|
||||
* This implementation does not include modified conversion specifiers (i.e., Ex and Ox)
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Date provides a set of utility functions to operate against Date objects.
|
||||
*
|
||||
* @class DataType.Date
|
||||
* @static
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pad a number with leading spaces, zeroes or something else
|
||||
* @method xPad
|
||||
* @param x {Number} The number to be padded
|
||||
* @param pad {String} The character to pad the number with
|
||||
* @param r {Number} (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits.
|
||||
* @private
|
||||
*/
|
||||
var xPad=function (x, pad, r)
|
||||
{
|
||||
if(typeof r === "undefined")
|
||||
{
|
||||
r=10;
|
||||
}
|
||||
pad = pad.toString();
|
||||
for( ; parseInt(x, 10)<r && r>1; r/=10) {
|
||||
x = pad + x;
|
||||
}
|
||||
return x.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Default date format.
|
||||
*
|
||||
* @for config
|
||||
* @property dateFormat
|
||||
* @type String
|
||||
* @value "%Y-%m-%d"
|
||||
*/
|
||||
Y.config.dateFormat = Y.config.dateFormat || "%Y-%m-%d";
|
||||
|
||||
/**
|
||||
* Default locale for the YUI instance.
|
||||
*
|
||||
* @property locale
|
||||
* @type String
|
||||
* @value "en"
|
||||
*/
|
||||
Y.config.locale = Y.config.locale || "en";
|
||||
|
||||
var Dt = {
|
||||
formats: {
|
||||
a: function (d, l) { return l.a[d.getDay()]; },
|
||||
A: function (d, l) { return l.A[d.getDay()]; },
|
||||
b: function (d, l) { return l.b[d.getMonth()]; },
|
||||
B: function (d, l) { return l.B[d.getMonth()]; },
|
||||
C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },
|
||||
d: ["getDate", "0"],
|
||||
e: ["getDate", " "],
|
||||
g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },
|
||||
G: function (d) {
|
||||
var y = d.getFullYear();
|
||||
var V = parseInt(Dt.formats.V(d), 10);
|
||||
var W = parseInt(Dt.formats.W(d), 10);
|
||||
|
||||
if(W > V) {
|
||||
y++;
|
||||
} else if(W===0 && V>=52) {
|
||||
y--;
|
||||
}
|
||||
|
||||
return y;
|
||||
},
|
||||
H: ["getHours", "0"],
|
||||
I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },
|
||||
j: function (d) {
|
||||
var gmd_1 = new Date("" + d.getFullYear() + "/1/1 GMT");
|
||||
var gmdate = new Date("" + d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate() + " GMT");
|
||||
var ms = gmdate - gmd_1;
|
||||
var doy = parseInt(ms/60000/60/24, 10)+1;
|
||||
return xPad(doy, 0, 100);
|
||||
},
|
||||
k: ["getHours", " "],
|
||||
l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, " "); },
|
||||
m: function (d) { return xPad(d.getMonth()+1, 0); },
|
||||
M: ["getMinutes", "0"],
|
||||
p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
s: function (d, l) { return parseInt(d.getTime()/1000, 10); },
|
||||
S: ["getSeconds", "0"],
|
||||
u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },
|
||||
U: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 6-d.getDay();
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0);
|
||||
},
|
||||
V: function (d) {
|
||||
var woy = parseInt(Dt.formats.W(d), 10);
|
||||
var dow1_1 = (new Date("" + d.getFullYear() + "/1/1")).getDay();
|
||||
// First week is 01 and not 00 as in the case of %U and %W,
|
||||
// so we add 1 to the final result except if day 1 of the year
|
||||
// is a Monday (then %W returns 01).
|
||||
// We also need to subtract 1 if the day 1 of the year is
|
||||
// Friday-Sunday, so the resulting equation becomes:
|
||||
var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);
|
||||
if(idow === 53 && (new Date("" + d.getFullYear() + "/12/31")).getDay() < 4)
|
||||
{
|
||||
idow = 1;
|
||||
}
|
||||
else if(idow === 0)
|
||||
{
|
||||
idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
|
||||
}
|
||||
|
||||
return xPad(idow, 0);
|
||||
},
|
||||
w: "getDay",
|
||||
W: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 7-Dt.formats.u(d);
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0, 10);
|
||||
},
|
||||
y: function (d) { return xPad(d.getFullYear()%100, 0); },
|
||||
Y: "getFullYear",
|
||||
z: function (d) {
|
||||
var o = d.getTimezoneOffset();
|
||||
var H = xPad(parseInt(Math.abs(o/60), 10), 0);
|
||||
var M = xPad(Math.abs(o%60), 0);
|
||||
return (o>0?"-":"+") + H + M;
|
||||
},
|
||||
Z: function (d) {
|
||||
var tz = d.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
|
||||
if(tz.length > 4) {
|
||||
tz = Dt.formats.z(d);
|
||||
}
|
||||
return tz;
|
||||
},
|
||||
"%": function (d) { return "%"; }
|
||||
},
|
||||
|
||||
aggregates: {
|
||||
c: "locale",
|
||||
D: "%m/%d/%y",
|
||||
F: "%Y-%m-%d",
|
||||
h: "%b",
|
||||
n: "\n",
|
||||
r: "locale",
|
||||
R: "%H:%M",
|
||||
t: "\t",
|
||||
T: "%H:%M:%S",
|
||||
x: "locale",
|
||||
X: "locale"
|
||||
//"+": "%a %b %e %T %Z %Y"
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes a native JavaScript Date and formats it as a string for display to user.
|
||||
*
|
||||
* @for DataType.Date
|
||||
* @method format
|
||||
* @param oDate {Date} Date.
|
||||
* @param oConfig {Object} (Optional) Object literal of configuration values:
|
||||
* <dl>
|
||||
* <dt>format {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* <p>
|
||||
* Any strftime string is supported, such as "%I:%M:%S %p". strftime has several format specifiers defined by the Open group at
|
||||
* <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>
|
||||
* PHP added a few of its own, defined at <a href="http://www.php.net/strftime">http://www.php.net/strftime</a>
|
||||
* </p>
|
||||
* <p>
|
||||
* This javascript implementation supports all the PHP specifiers and a few more. The full list is below.
|
||||
* </p>
|
||||
* <p>
|
||||
* If not specified, it defaults to the ISO8601 standard date format: %Y-%m-%d. This may be overridden by changing Y.config.dateFormat
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>
|
||||
* <dt>%A</dt> <dd>full weekday name according to the current locale</dd>
|
||||
* <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>
|
||||
* <dt>%B</dt> <dd>full month name according to the current locale</dd>
|
||||
* <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>
|
||||
* <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>
|
||||
* <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>
|
||||
* <dt>%D</dt> <dd>same as %m/%d/%y</dd>
|
||||
* <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range " 1" to "31")</dd>
|
||||
* <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>
|
||||
* <dt>%g</dt> <dd>like %G, but without the century</dd>
|
||||
* <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>
|
||||
* <dt>%h</dt> <dd>same as %b</dd>
|
||||
* <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>
|
||||
* <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>
|
||||
* <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>
|
||||
* <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>
|
||||
* <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>
|
||||
* <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>
|
||||
* <dt>%M</dt> <dd>minute as a decimal number</dd>
|
||||
* <dt>%n</dt> <dd>newline character</dd>
|
||||
* <dt>%p</dt> <dd>either "AM" or "PM" according to the given time value, or the corresponding strings for the current locale</dd>
|
||||
* <dt>%P</dt> <dd>like %p, but lower case</dd>
|
||||
* <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>
|
||||
* <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>
|
||||
* <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>
|
||||
* <dt>%S</dt> <dd>second as a decimal number</dd>
|
||||
* <dt>%t</dt> <dd>tab character</dd>
|
||||
* <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>
|
||||
* <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>
|
||||
* <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Sunday as the first day of the first week</dd>
|
||||
* <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,
|
||||
* range 01 to 53, where week 1 is the first week that has at least 4 days
|
||||
* in the current year, and with Monday as the first day of the week.</dd>
|
||||
* <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>
|
||||
* <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Monday as the first day of the first week</dd>
|
||||
* <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>
|
||||
* <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>
|
||||
* <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>
|
||||
* <dt>%Y</dt> <dd>year as a decimal number including the century</dd>
|
||||
* <dt>%z</dt> <dd>numerical time zone representation</dd>
|
||||
* <dt>%Z</dt> <dd>time zone name or abbreviation</dd>
|
||||
* <dt>%%</dt> <dd>a literal "%" character</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>locale {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* The locale to use when displaying days of week, months of the year, and other locale specific
|
||||
* strings. If not specified, this defaults to "en" (though this may be overridden by changing Y.config.locale).
|
||||
* The following locales are built in:
|
||||
* <dl>
|
||||
* <dt>en</dt>
|
||||
* <dd>English</dd>
|
||||
* <dt>en-US</dt>
|
||||
* <dd>US English</dd>
|
||||
* <dt>en-GB</dt>
|
||||
* <dd>British English</dd>
|
||||
* <dt>en-AU</dt>
|
||||
* <dd>Australian English (identical to British English)</dd>
|
||||
* </dl>
|
||||
* More locales may be added by subclassing of Y.DataType.Date.Locale["en"].
|
||||
* See Y.DataType.Date.Locale for more information.
|
||||
* </dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted date for display.
|
||||
*/
|
||||
format : function (oDate, oConfig) {
|
||||
oConfig = oConfig || {};
|
||||
|
||||
if(!Y.Lang.isDate(oDate)) {
|
||||
return Y.Lang.isValue(oDate) ? oDate : "";
|
||||
}
|
||||
|
||||
var format = oConfig.format || Y.config.dateFormat,
|
||||
sLocale = oConfig.locale || Y.config.locale,
|
||||
LOCALE = Y.DataType.Date.Locale;
|
||||
|
||||
sLocale = sLocale.replace(/_/g, "-");
|
||||
|
||||
// Make sure we have a definition for the requested locale, or default to en.
|
||||
if(!LOCALE[sLocale]) {
|
||||
var tmpLocale = sLocale.replace(/-[a-zA-Z]+$/, "");
|
||||
if(tmpLocale in LOCALE) {
|
||||
sLocale = tmpLocale;
|
||||
} else if(Y.config.locale in LOCALE) {
|
||||
sLocale = Y.config.locale;
|
||||
} else {
|
||||
sLocale = "en";
|
||||
}
|
||||
}
|
||||
|
||||
var aLocale = LOCALE[sLocale];
|
||||
|
||||
var replace_aggs = function (m0, m1) {
|
||||
var f = Dt.aggregates[m1];
|
||||
return (f === "locale" ? aLocale[m1] : f);
|
||||
};
|
||||
|
||||
var replace_formats = function (m0, m1) {
|
||||
var f = Dt.formats[m1];
|
||||
switch(Y.Lang.type(f)) {
|
||||
case "string": // string => built in date function
|
||||
return oDate[f]();
|
||||
case "function": // function => our own function
|
||||
return f.call(oDate, oDate, aLocale);
|
||||
case "array": // built in function with padding
|
||||
if(Y.Lang.type(f[0]) === "string") {
|
||||
return xPad(oDate[f[0]](), f[1]);
|
||||
} // no break; (fall through to default:)
|
||||
default:
|
||||
return m1;
|
||||
}
|
||||
};
|
||||
|
||||
// First replace aggregates (run in a loop because an agg may be made up of other aggs)
|
||||
while(format.match(/%[cDFhnrRtTxX]/)) {
|
||||
format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);
|
||||
}
|
||||
|
||||
// Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)
|
||||
var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);
|
||||
|
||||
replace_aggs = replace_formats = undefined;
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), Dt);
|
||||
|
||||
/**
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Date.Locale class is a container for all localised date strings
|
||||
* used by Y.DataType.Date. It is used internally, but may be extended
|
||||
* to provide new date localisations.
|
||||
*
|
||||
* To create your own Locale, follow these steps:
|
||||
* <ol>
|
||||
* <li>Find an existing locale that matches closely with your needs</li>
|
||||
* <li>Use this as your base class. Use Y.DataType.Date.Locale["en"] if nothing
|
||||
* matches.</li>
|
||||
* <li>Create your own class as an extension of the base class using
|
||||
* Y.merge, and add your own localisations where needed.</li>
|
||||
* </ol>
|
||||
* See the Y.DataType.Date.Locale["en-US"] and Y.DataType.Date.Locale["en-GB"]
|
||||
* classes which extend Y.DataType.Date.Locale["en"].
|
||||
*
|
||||
* For example, to implement locales for French french and Canadian french,
|
||||
* we would do the following:
|
||||
* <ol>
|
||||
* <li>For French french, we have no existing similar locale, so use
|
||||
* Y.DataType.Date.Locale["en"] as the base, and extend it:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr"] = Y.merge(Y.DataType.Date.Locale, {
|
||||
* a: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"],
|
||||
* A: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
|
||||
* b: ["jan", "fév", "mar", "avr", "mai", "jun", "jui", "aoû", "sep", "oct", "nov", "déc"],
|
||||
* B: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
|
||||
* c: "%a %d %b %Y %T %Z",
|
||||
* p: ["", ""],
|
||||
* P: ["", ""],
|
||||
* x: "%d.%m.%Y",
|
||||
* X: "%T"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* <li>For Canadian french, we start with French french and change the meaning of \%x:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr-CA"] = Y.merge(Y.DataType.Date.Locale["fr"], {
|
||||
* x: "%Y-%m-%d"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* With that, you can use your new locales:
|
||||
* <pre>
|
||||
* var d = new Date("2008/04/22");
|
||||
* Y.DataType.Date.format(d, { format: "%A, %d %B == %x", locale: "fr" });
|
||||
* </pre>
|
||||
* will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 22.04.2008
|
||||
* </pre>
|
||||
* And
|
||||
* <pre>
|
||||
* Y.DataType.Date.format(d, {format: "%A, %d %B == %x", locale: "fr-CA" });
|
||||
* </pre>
|
||||
* Will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 2008-04-22
|
||||
* </pre>
|
||||
* @requires oop
|
||||
* @class DataType.Date.Locale
|
||||
* @static
|
||||
*/
|
||||
var YDateEn = {
|
||||
a: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
A: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
b: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
B: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
c: "%a %d %b %Y %T %Z",
|
||||
p: ["AM", "PM"],
|
||||
P: ["am", "pm"],
|
||||
r: "%I:%M:%S %p",
|
||||
x: "%d/%m/%y",
|
||||
X: "%T"
|
||||
};
|
||||
|
||||
Y.namespace("DataType.Date.Locale");
|
||||
|
||||
Y.DataType.Date.Locale["en"] = YDateEn;
|
||||
|
||||
Y.DataType.Date.Locale["en-US"] = Y.merge(YDateEn, {
|
||||
c: "%a %d %b %Y %I:%M:%S %p %Z",
|
||||
x: "%m/%d/%Y",
|
||||
X: "%I:%M:%S %p"
|
||||
});
|
||||
|
||||
Y.DataType.Date.Locale["en-GB"] = Y.merge(YDateEn, {
|
||||
r: "%l:%M:%S %P %Z"
|
||||
});
|
||||
Y.DataType.Date.Locale["en-AU"] = Y.merge(YDateEn);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-date', function(Y){}, '3.0.0' ,{use:['datatype-date-parse', 'datatype-date-format']});
|
||||
|
||||
9
jssource/src_files/include/javascript/yui3/build/datatype/datatype-min.js
vendored
Normal file
9
jssource/src_files/include/javascript/yui3/build/datatype/datatype-min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-format-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-format-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-number-format",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Number"),{format:function(I,E){if(A.isNumber(I)){E=E||{};var D=(I<0),F=I+"",M=E.decimalPlaces,C=E.decimalSeparator||".",L=E.thousandsSeparator,K,G,J,H;if(A.isNumber(M)&&(M>=0)&&(M<=20)){F=I.toFixed(M);}if(C!=="."){F=F.replace(".",C);}if(L){K=F.lastIndexOf(C);K=(K>-1)?K:F.length;G=F.substring(K);for(J=0,H=K;H>0;H--){if((J%3===0)&&(H!==K)&&(!D||(H>1))){G=L+G;}G=F.charAt(H-1)+G;J++;}F=G;}F=(E.prefix)?E.prefix+F:F;F=(E.suffix)?F+E.suffix:F;return F;}else{return(A.isValue(I)&&I.toString)?I.toString():"";}}});},"3.0.0");
|
||||
112
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-format.js
vendored
Normal file
112
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-format.js
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-number-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Number provides a set of utility functions to operate against Number objects.
|
||||
*
|
||||
* @class DataType.Number
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Takes a Number and formats to string for display to user.
|
||||
*
|
||||
* @method format
|
||||
* @param data {Number} Number.
|
||||
* @param config {Object} (Optional) Optional configuration values:
|
||||
* <dl>
|
||||
* <dt>prefix {String}</dd>
|
||||
* <dd>String prepended before each number, like a currency designator "$"</dd>
|
||||
* <dt>decimalPlaces {Number}</dd>
|
||||
* <dd>Number of decimal places to round. Must be a number 0 to 20.</dd>
|
||||
* <dt>decimalSeparator {String}</dd>
|
||||
* <dd>Decimal separator</dd>
|
||||
* <dt>thousandsSeparator {String}</dd>
|
||||
* <dd>Thousands separator</dd>
|
||||
* <dt>suffix {String}</dd>
|
||||
* <dd>String appended after each number, like " items" (note the space)</dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted number for display. Note, the following values
|
||||
* return as "": null, undefined, NaN, "".
|
||||
*/
|
||||
format: function(data, config) {
|
||||
if(LANG.isNumber(data)) {
|
||||
config = config || {};
|
||||
|
||||
var isNeg = (data < 0),
|
||||
output = data + "",
|
||||
decPlaces = config.decimalPlaces,
|
||||
decSep = config.decimalSeparator || ".",
|
||||
thouSep = config.thousandsSeparator,
|
||||
decIndex,
|
||||
newOutput, count, i;
|
||||
|
||||
// Decimal precision
|
||||
if(LANG.isNumber(decPlaces) && (decPlaces >= 0) && (decPlaces <= 20)) {
|
||||
// Round to the correct decimal place
|
||||
output = data.toFixed(decPlaces);
|
||||
}
|
||||
|
||||
// Decimal separator
|
||||
if(decSep !== "."){
|
||||
output = output.replace(".", decSep);
|
||||
}
|
||||
|
||||
// Add the thousands separator
|
||||
if(thouSep) {
|
||||
// Find the dot or where it would be
|
||||
decIndex = output.lastIndexOf(decSep);
|
||||
decIndex = (decIndex > -1) ? decIndex : output.length;
|
||||
// Start with the dot and everything to the right
|
||||
newOutput = output.substring(decIndex);
|
||||
// Working left, every third time add a separator, every time add a digit
|
||||
for (count = 0, i=decIndex; i>0; i--) {
|
||||
if ((count%3 === 0) && (i !== decIndex) && (!isNeg || (i > 1))) {
|
||||
newOutput = thouSep + newOutput;
|
||||
}
|
||||
newOutput = output.charAt(i-1) + newOutput;
|
||||
count++;
|
||||
}
|
||||
output = newOutput;
|
||||
}
|
||||
|
||||
// Prepend prefix
|
||||
output = (config.prefix) ? config.prefix + output : output;
|
||||
|
||||
// Append suffix
|
||||
output = (config.suffix) ? output + config.suffix : output;
|
||||
|
||||
return output;
|
||||
}
|
||||
// Not a Number, just return as string
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-number-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Number"),{parse:function(D){var C=(D===null)?D:+D;if(A.isNumber(C)){return C;}else{return null;}}});B.namespace("Parsers").number=B.DataType.Number.parse;},"3.0.0");YUI.add("datatype-number-format",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Number"),{format:function(I,E){if(A.isNumber(I)){E=E||{};var D=(I<0),F=I+"",M=E.decimalPlaces,C=E.decimalSeparator||".",L=E.thousandsSeparator,K,G,J,H;if(A.isNumber(M)&&(M>=0)&&(M<=20)){F=I.toFixed(M);}if(C!=="."){F=F.replace(".",C);}if(L){K=F.lastIndexOf(C);K=(K>-1)?K:F.length;G=F.substring(K);for(J=0,H=K;H>0;H--){if((J%3===0)&&(H!==K)&&(!D||(H>1))){G=L+G;}G=F.charAt(H-1)+G;J++;}F=G;}F=(E.prefix)?E.prefix+F:F;F=(E.suffix)?F+E.suffix:F;return F;}else{return(A.isValue(I)&&I.toString)?I.toString():"";}}});},"3.0.0");YUI.add("datatype-number",function(A){},"3.0.0",{use:["datatype-number-parse","datatype-number-format"]});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-parse-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-parse-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-number-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.Number"),{parse:function(D){var C=(D===null)?D:+D;if(A.isNumber(C)){return C;}else{return null;}}});B.namespace("Parsers").number=B.DataType.Number.parse;},"3.0.0");
|
||||
45
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-parse.js
vendored
Normal file
45
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number-parse.js
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-number-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-parse
|
||||
* @for DataType.Number
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Converts data to type Number.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number | Boolean} Data to convert. The following
|
||||
* values return as null: null, undefined, NaN, "".
|
||||
* @return {Number} A number, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var number = (data === null) ? data : +data;
|
||||
if(LANG.isNumber(number)) {
|
||||
return number;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").number = Y.DataType.Number.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
156
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number.js
vendored
Normal file
156
jssource/src_files/include/javascript/yui3/build/datatype/datatype-number.js
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-number-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-parse
|
||||
* @for DataType.Number
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Converts data to type Number.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number | Boolean} Data to convert. The following
|
||||
* values return as null: null, undefined, NaN, "".
|
||||
* @return {Number} A number, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var number = (data === null) ? data : +data;
|
||||
if(LANG.isNumber(number)) {
|
||||
return number;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").number = Y.DataType.Number.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-number-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Number provides a set of utility functions to operate against Number objects.
|
||||
*
|
||||
* @class DataType.Number
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Takes a Number and formats to string for display to user.
|
||||
*
|
||||
* @method format
|
||||
* @param data {Number} Number.
|
||||
* @param config {Object} (Optional) Optional configuration values:
|
||||
* <dl>
|
||||
* <dt>prefix {String}</dd>
|
||||
* <dd>String prepended before each number, like a currency designator "$"</dd>
|
||||
* <dt>decimalPlaces {Number}</dd>
|
||||
* <dd>Number of decimal places to round. Must be a number 0 to 20.</dd>
|
||||
* <dt>decimalSeparator {String}</dd>
|
||||
* <dd>Decimal separator</dd>
|
||||
* <dt>thousandsSeparator {String}</dd>
|
||||
* <dd>Thousands separator</dd>
|
||||
* <dt>suffix {String}</dd>
|
||||
* <dd>String appended after each number, like " items" (note the space)</dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted number for display. Note, the following values
|
||||
* return as "": null, undefined, NaN, "".
|
||||
*/
|
||||
format: function(data, config) {
|
||||
if(LANG.isNumber(data)) {
|
||||
config = config || {};
|
||||
|
||||
var isNeg = (data < 0),
|
||||
output = data + "",
|
||||
decPlaces = config.decimalPlaces,
|
||||
decSep = config.decimalSeparator || ".",
|
||||
thouSep = config.thousandsSeparator,
|
||||
decIndex,
|
||||
newOutput, count, i;
|
||||
|
||||
// Decimal precision
|
||||
if(LANG.isNumber(decPlaces) && (decPlaces >= 0) && (decPlaces <= 20)) {
|
||||
// Round to the correct decimal place
|
||||
output = data.toFixed(decPlaces);
|
||||
}
|
||||
|
||||
// Decimal separator
|
||||
if(decSep !== "."){
|
||||
output = output.replace(".", decSep);
|
||||
}
|
||||
|
||||
// Add the thousands separator
|
||||
if(thouSep) {
|
||||
// Find the dot or where it would be
|
||||
decIndex = output.lastIndexOf(decSep);
|
||||
decIndex = (decIndex > -1) ? decIndex : output.length;
|
||||
// Start with the dot and everything to the right
|
||||
newOutput = output.substring(decIndex);
|
||||
// Working left, every third time add a separator, every time add a digit
|
||||
for (count = 0, i=decIndex; i>0; i--) {
|
||||
if ((count%3 === 0) && (i !== decIndex) && (!isNeg || (i > 1))) {
|
||||
newOutput = thouSep + newOutput;
|
||||
}
|
||||
newOutput = output.charAt(i-1) + newOutput;
|
||||
count++;
|
||||
}
|
||||
output = newOutput;
|
||||
}
|
||||
|
||||
// Prepend prefix
|
||||
output = (config.prefix) ? config.prefix + output : output;
|
||||
|
||||
// Append suffix
|
||||
output = (config.suffix) ? output + config.suffix : output;
|
||||
|
||||
return output;
|
||||
}
|
||||
// Not a Number, just return as string
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-number', function(Y){}, '3.0.0' ,{use:['datatype-number-parse', 'datatype-number-format']});
|
||||
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-format-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-format-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-xml-format",function(B){var A=B.Lang;B.mix(B.namespace("DataType.XML"),{format:function(C){try{if(!A.isUndefined(XMLSerializer)){return(new XMLSerializer()).serializeToString(C);}}catch(D){if(C&&C.xml){return C.xml;}else{return(A.isValue(C)&&C.toString)?C.toString():"";}}}});},"3.0.0");
|
||||
60
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-format.js
vendored
Normal file
60
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-format.js
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-xml-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Format XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.XML provides a set of utility functions to operate against XML documents.
|
||||
*
|
||||
* @class DataType.XML
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method format
|
||||
* @param data {XMLDoc} Data to convert.
|
||||
* @return {String} String.
|
||||
*/
|
||||
format: function(data) {
|
||||
try {
|
||||
if(!LANG.isUndefined(XMLSerializer)) {
|
||||
return (new XMLSerializer()).serializeToString(data);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
if(data && data.xml) {
|
||||
return data.xml;
|
||||
}
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-xml-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.XML"),{parse:function(E){var D=null;if(A.isString(E)){try{if(!A.isUndefined(DOMParser)){D=new DOMParser().parseFromString(E,"text/xml");}}catch(F){try{if(!A.isUndefined(ActiveXObject)){D=new ActiveXObject("Microsoft.XMLDOM");D.async=false;D.loadXML(E);}}catch(C){}}}if((A.isNull(D))||(A.isNull(D.documentElement))||(D.documentElement.nodeName==="parsererror")){}return D;}});B.namespace("Parsers").xml=B.DataType.XML.parse;},"3.0.0");YUI.add("datatype-xml-format",function(B){var A=B.Lang;B.mix(B.namespace("DataType.XML"),{format:function(C){try{if(!A.isUndefined(XMLSerializer)){return(new XMLSerializer()).serializeToString(C);}}catch(D){if(C&&C.xml){return C.xml;}else{return(A.isValue(C)&&C.toString)?C.toString():"";}}}});},"3.0.0");YUI.add("datatype-xml",function(A){},"3.0.0",{use:["datatype-xml-parse","datatype-xml-format"]});
|
||||
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-parse-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-parse-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("datatype-xml-parse",function(B){var A=B.Lang;B.mix(B.namespace("DataType.XML"),{parse:function(E){var D=null;if(A.isString(E)){try{if(!A.isUndefined(DOMParser)){D=new DOMParser().parseFromString(E,"text/xml");}}catch(F){try{if(!A.isUndefined(ActiveXObject)){D=new ActiveXObject("Microsoft.XMLDOM");D.async=false;D.loadXML(E);}}catch(C){}}}if((A.isNull(D))||(A.isNull(D.documentElement))||(D.documentElement.nodeName==="parsererror")){}return D;}});B.namespace("Parsers").xml=B.DataType.XML.parse;},"3.0.0");
|
||||
62
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-parse.js
vendored
Normal file
62
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml-parse.js
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-xml-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-parse
|
||||
* @for DataType.XML
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String} Data to convert.
|
||||
* @return {XMLDoc} XML Document.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var xmlDoc = null;
|
||||
if(LANG.isString(data)) {
|
||||
try {
|
||||
if(!LANG.isUndefined(DOMParser)) {
|
||||
xmlDoc = new DOMParser().parseFromString(data, "text/xml");
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
try {
|
||||
if(!LANG.isUndefined(ActiveXObject)) {
|
||||
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
xmlDoc.async = false;
|
||||
xmlDoc.loadXML(data);
|
||||
}
|
||||
}
|
||||
catch(ee) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
|
||||
}
|
||||
|
||||
return xmlDoc;
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").xml = Y.DataType.XML.parse;
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
121
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml.js
vendored
Normal file
121
jssource/src_files/include/javascript/yui3/build/datatype/datatype-xml.js
vendored
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-xml-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-parse
|
||||
* @for DataType.XML
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String} Data to convert.
|
||||
* @return {XMLDoc} XML Document.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var xmlDoc = null;
|
||||
if(LANG.isString(data)) {
|
||||
try {
|
||||
if(!LANG.isUndefined(DOMParser)) {
|
||||
xmlDoc = new DOMParser().parseFromString(data, "text/xml");
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
try {
|
||||
if(!LANG.isUndefined(ActiveXObject)) {
|
||||
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
xmlDoc.async = false;
|
||||
xmlDoc.loadXML(data);
|
||||
}
|
||||
}
|
||||
catch(ee) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
|
||||
}
|
||||
|
||||
return xmlDoc;
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").xml = Y.DataType.XML.parse;
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-xml-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Format XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.XML provides a set of utility functions to operate against XML documents.
|
||||
*
|
||||
* @class DataType.XML
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method format
|
||||
* @param data {XMLDoc} Data to convert.
|
||||
* @return {String} String.
|
||||
*/
|
||||
format: function(data) {
|
||||
try {
|
||||
if(!LANG.isUndefined(XMLSerializer)) {
|
||||
return (new XMLSerializer()).serializeToString(data);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
if(data && data.xml) {
|
||||
return data.xml;
|
||||
}
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-xml', function(Y){}, '3.0.0' ,{use:['datatype-xml-parse', 'datatype-xml-format']});
|
||||
|
||||
765
jssource/src_files/include/javascript/yui3/build/datatype/datatype.js
vendored
Normal file
765
jssource/src_files/include/javascript/yui3/build/datatype/datatype.js
vendored
Normal file
@@ -0,0 +1,765 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('datatype-number-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-parse
|
||||
* @for DataType.Number
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Converts data to type Number.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number | Boolean} Data to convert. The following
|
||||
* values return as null: null, undefined, NaN, "".
|
||||
* @return {Number} A number, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var number = (data === null) ? data : +data;
|
||||
if(LANG.isNumber(number)) {
|
||||
return number;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").number = Y.DataType.Number.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-number-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-number-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Number provides a set of utility functions to operate against Number objects.
|
||||
*
|
||||
* @class DataType.Number
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Number"), {
|
||||
/**
|
||||
* Takes a Number and formats to string for display to user.
|
||||
*
|
||||
* @method format
|
||||
* @param data {Number} Number.
|
||||
* @param config {Object} (Optional) Optional configuration values:
|
||||
* <dl>
|
||||
* <dt>prefix {String}</dd>
|
||||
* <dd>String prepended before each number, like a currency designator "$"</dd>
|
||||
* <dt>decimalPlaces {Number}</dd>
|
||||
* <dd>Number of decimal places to round. Must be a number 0 to 20.</dd>
|
||||
* <dt>decimalSeparator {String}</dd>
|
||||
* <dd>Decimal separator</dd>
|
||||
* <dt>thousandsSeparator {String}</dd>
|
||||
* <dd>Thousands separator</dd>
|
||||
* <dt>suffix {String}</dd>
|
||||
* <dd>String appended after each number, like " items" (note the space)</dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted number for display. Note, the following values
|
||||
* return as "": null, undefined, NaN, "".
|
||||
*/
|
||||
format: function(data, config) {
|
||||
if(LANG.isNumber(data)) {
|
||||
config = config || {};
|
||||
|
||||
var isNeg = (data < 0),
|
||||
output = data + "",
|
||||
decPlaces = config.decimalPlaces,
|
||||
decSep = config.decimalSeparator || ".",
|
||||
thouSep = config.thousandsSeparator,
|
||||
decIndex,
|
||||
newOutput, count, i;
|
||||
|
||||
// Decimal precision
|
||||
if(LANG.isNumber(decPlaces) && (decPlaces >= 0) && (decPlaces <= 20)) {
|
||||
// Round to the correct decimal place
|
||||
output = data.toFixed(decPlaces);
|
||||
}
|
||||
|
||||
// Decimal separator
|
||||
if(decSep !== "."){
|
||||
output = output.replace(".", decSep);
|
||||
}
|
||||
|
||||
// Add the thousands separator
|
||||
if(thouSep) {
|
||||
// Find the dot or where it would be
|
||||
decIndex = output.lastIndexOf(decSep);
|
||||
decIndex = (decIndex > -1) ? decIndex : output.length;
|
||||
// Start with the dot and everything to the right
|
||||
newOutput = output.substring(decIndex);
|
||||
// Working left, every third time add a separator, every time add a digit
|
||||
for (count = 0, i=decIndex; i>0; i--) {
|
||||
if ((count%3 === 0) && (i !== decIndex) && (!isNeg || (i > 1))) {
|
||||
newOutput = thouSep + newOutput;
|
||||
}
|
||||
newOutput = output.charAt(i-1) + newOutput;
|
||||
count++;
|
||||
}
|
||||
output = newOutput;
|
||||
}
|
||||
|
||||
// Prepend prefix
|
||||
output = (config.prefix) ? config.prefix + output : output;
|
||||
|
||||
// Append suffix
|
||||
output = (config.suffix) ? output + config.suffix : output;
|
||||
|
||||
return output;
|
||||
}
|
||||
// Not a Number, just return as string
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-number', function(Y){}, '3.0.0' ,{use:['datatype-number-parse', 'datatype-number-format']});
|
||||
|
||||
|
||||
YUI.add('datatype-date-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse number submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-parse
|
||||
* @for DataType.Date
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), {
|
||||
/**
|
||||
* Converts data to type Date.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String | Number} Data to convert. Values supported by the Date constructor are supported.
|
||||
* @return {Date} A Date, or null.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var date = null;
|
||||
|
||||
//Convert to date
|
||||
if(!(LANG.isDate(data))) {
|
||||
date = new Date(data);
|
||||
}
|
||||
else {
|
||||
return date;
|
||||
}
|
||||
|
||||
// Validate
|
||||
if(LANG.isDate(date) && (date != "Invalid Date") && !isNaN(date)) { // Workaround for bug 2527965
|
||||
return date;
|
||||
}
|
||||
else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").date = Y.DataType.Date.parse;
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-date-format', function(Y) {
|
||||
|
||||
/**
|
||||
* The DataType Utility provides type-conversion and string-formatting
|
||||
* convenience methods for various JavaScript object types.
|
||||
*
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* Date submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date
|
||||
*/
|
||||
|
||||
/**
|
||||
* Format date submodule implements strftime formatters for javascript based on the
|
||||
* Open Group specification defined at
|
||||
* http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html
|
||||
* This implementation does not include modified conversion specifiers (i.e., Ex and Ox)
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-date-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.Date provides a set of utility functions to operate against Date objects.
|
||||
*
|
||||
* @class DataType.Date
|
||||
* @static
|
||||
*/
|
||||
|
||||
/**
|
||||
* Pad a number with leading spaces, zeroes or something else
|
||||
* @method xPad
|
||||
* @param x {Number} The number to be padded
|
||||
* @param pad {String} The character to pad the number with
|
||||
* @param r {Number} (optional) The base of the pad, eg, 10 implies to two digits, 100 implies to 3 digits.
|
||||
* @private
|
||||
*/
|
||||
var xPad=function (x, pad, r)
|
||||
{
|
||||
if(typeof r === "undefined")
|
||||
{
|
||||
r=10;
|
||||
}
|
||||
pad = pad.toString();
|
||||
for( ; parseInt(x, 10)<r && r>1; r/=10) {
|
||||
x = pad + x;
|
||||
}
|
||||
return x.toString();
|
||||
};
|
||||
|
||||
/**
|
||||
* Default date format.
|
||||
*
|
||||
* @for config
|
||||
* @property dateFormat
|
||||
* @type String
|
||||
* @value "%Y-%m-%d"
|
||||
*/
|
||||
Y.config.dateFormat = Y.config.dateFormat || "%Y-%m-%d";
|
||||
|
||||
/**
|
||||
* Default locale for the YUI instance.
|
||||
*
|
||||
* @property locale
|
||||
* @type String
|
||||
* @value "en"
|
||||
*/
|
||||
Y.config.locale = Y.config.locale || "en";
|
||||
|
||||
var Dt = {
|
||||
formats: {
|
||||
a: function (d, l) { return l.a[d.getDay()]; },
|
||||
A: function (d, l) { return l.A[d.getDay()]; },
|
||||
b: function (d, l) { return l.b[d.getMonth()]; },
|
||||
B: function (d, l) { return l.B[d.getMonth()]; },
|
||||
C: function (d) { return xPad(parseInt(d.getFullYear()/100, 10), 0); },
|
||||
d: ["getDate", "0"],
|
||||
e: ["getDate", " "],
|
||||
g: function (d) { return xPad(parseInt(Dt.formats.G(d)%100, 10), 0); },
|
||||
G: function (d) {
|
||||
var y = d.getFullYear();
|
||||
var V = parseInt(Dt.formats.V(d), 10);
|
||||
var W = parseInt(Dt.formats.W(d), 10);
|
||||
|
||||
if(W > V) {
|
||||
y++;
|
||||
} else if(W===0 && V>=52) {
|
||||
y--;
|
||||
}
|
||||
|
||||
return y;
|
||||
},
|
||||
H: ["getHours", "0"],
|
||||
I: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, 0); },
|
||||
j: function (d) {
|
||||
var gmd_1 = new Date("" + d.getFullYear() + "/1/1 GMT");
|
||||
var gmdate = new Date("" + d.getFullYear() + "/" + (d.getMonth()+1) + "/" + d.getDate() + " GMT");
|
||||
var ms = gmdate - gmd_1;
|
||||
var doy = parseInt(ms/60000/60/24, 10)+1;
|
||||
return xPad(doy, 0, 100);
|
||||
},
|
||||
k: ["getHours", " "],
|
||||
l: function (d) { var I=d.getHours()%12; return xPad(I===0?12:I, " "); },
|
||||
m: function (d) { return xPad(d.getMonth()+1, 0); },
|
||||
M: ["getMinutes", "0"],
|
||||
p: function (d, l) { return l.p[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
P: function (d, l) { return l.P[d.getHours() >= 12 ? 1 : 0 ]; },
|
||||
s: function (d, l) { return parseInt(d.getTime()/1000, 10); },
|
||||
S: ["getSeconds", "0"],
|
||||
u: function (d) { var dow = d.getDay(); return dow===0?7:dow; },
|
||||
U: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 6-d.getDay();
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0);
|
||||
},
|
||||
V: function (d) {
|
||||
var woy = parseInt(Dt.formats.W(d), 10);
|
||||
var dow1_1 = (new Date("" + d.getFullYear() + "/1/1")).getDay();
|
||||
// First week is 01 and not 00 as in the case of %U and %W,
|
||||
// so we add 1 to the final result except if day 1 of the year
|
||||
// is a Monday (then %W returns 01).
|
||||
// We also need to subtract 1 if the day 1 of the year is
|
||||
// Friday-Sunday, so the resulting equation becomes:
|
||||
var idow = woy + (dow1_1 > 4 || dow1_1 <= 1 ? 0 : 1);
|
||||
if(idow === 53 && (new Date("" + d.getFullYear() + "/12/31")).getDay() < 4)
|
||||
{
|
||||
idow = 1;
|
||||
}
|
||||
else if(idow === 0)
|
||||
{
|
||||
idow = Dt.formats.V(new Date("" + (d.getFullYear()-1) + "/12/31"));
|
||||
}
|
||||
|
||||
return xPad(idow, 0);
|
||||
},
|
||||
w: "getDay",
|
||||
W: function (d) {
|
||||
var doy = parseInt(Dt.formats.j(d), 10);
|
||||
var rdow = 7-Dt.formats.u(d);
|
||||
var woy = parseInt((doy+rdow)/7, 10);
|
||||
return xPad(woy, 0, 10);
|
||||
},
|
||||
y: function (d) { return xPad(d.getFullYear()%100, 0); },
|
||||
Y: "getFullYear",
|
||||
z: function (d) {
|
||||
var o = d.getTimezoneOffset();
|
||||
var H = xPad(parseInt(Math.abs(o/60), 10), 0);
|
||||
var M = xPad(Math.abs(o%60), 0);
|
||||
return (o>0?"-":"+") + H + M;
|
||||
},
|
||||
Z: function (d) {
|
||||
var tz = d.toString().replace(/^.*:\d\d( GMT[+-]\d+)? \(?([A-Za-z ]+)\)?\d*$/, "$2").replace(/[a-z ]/g, "");
|
||||
if(tz.length > 4) {
|
||||
tz = Dt.formats.z(d);
|
||||
}
|
||||
return tz;
|
||||
},
|
||||
"%": function (d) { return "%"; }
|
||||
},
|
||||
|
||||
aggregates: {
|
||||
c: "locale",
|
||||
D: "%m/%d/%y",
|
||||
F: "%Y-%m-%d",
|
||||
h: "%b",
|
||||
n: "\n",
|
||||
r: "locale",
|
||||
R: "%H:%M",
|
||||
t: "\t",
|
||||
T: "%H:%M:%S",
|
||||
x: "locale",
|
||||
X: "locale"
|
||||
//"+": "%a %b %e %T %Z %Y"
|
||||
},
|
||||
|
||||
/**
|
||||
* Takes a native JavaScript Date and formats it as a string for display to user.
|
||||
*
|
||||
* @for DataType.Date
|
||||
* @method format
|
||||
* @param oDate {Date} Date.
|
||||
* @param oConfig {Object} (Optional) Object literal of configuration values:
|
||||
* <dl>
|
||||
* <dt>format {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* <p>
|
||||
* Any strftime string is supported, such as "%I:%M:%S %p". strftime has several format specifiers defined by the Open group at
|
||||
* <a href="http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html">http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html</a>
|
||||
* PHP added a few of its own, defined at <a href="http://www.php.net/strftime">http://www.php.net/strftime</a>
|
||||
* </p>
|
||||
* <p>
|
||||
* This javascript implementation supports all the PHP specifiers and a few more. The full list is below.
|
||||
* </p>
|
||||
* <p>
|
||||
* If not specified, it defaults to the ISO8601 standard date format: %Y-%m-%d. This may be overridden by changing Y.config.dateFormat
|
||||
* </p>
|
||||
* <dl>
|
||||
* <dt>%a</dt> <dd>abbreviated weekday name according to the current locale</dd>
|
||||
* <dt>%A</dt> <dd>full weekday name according to the current locale</dd>
|
||||
* <dt>%b</dt> <dd>abbreviated month name according to the current locale</dd>
|
||||
* <dt>%B</dt> <dd>full month name according to the current locale</dd>
|
||||
* <dt>%c</dt> <dd>preferred date and time representation for the current locale</dd>
|
||||
* <dt>%C</dt> <dd>century number (the year divided by 100 and truncated to an integer, range 00 to 99)</dd>
|
||||
* <dt>%d</dt> <dd>day of the month as a decimal number (range 01 to 31)</dd>
|
||||
* <dt>%D</dt> <dd>same as %m/%d/%y</dd>
|
||||
* <dt>%e</dt> <dd>day of the month as a decimal number, a single digit is preceded by a space (range " 1" to "31")</dd>
|
||||
* <dt>%F</dt> <dd>same as %Y-%m-%d (ISO 8601 date format)</dd>
|
||||
* <dt>%g</dt> <dd>like %G, but without the century</dd>
|
||||
* <dt>%G</dt> <dd>The 4-digit year corresponding to the ISO week number</dd>
|
||||
* <dt>%h</dt> <dd>same as %b</dd>
|
||||
* <dt>%H</dt> <dd>hour as a decimal number using a 24-hour clock (range 00 to 23)</dd>
|
||||
* <dt>%I</dt> <dd>hour as a decimal number using a 12-hour clock (range 01 to 12)</dd>
|
||||
* <dt>%j</dt> <dd>day of the year as a decimal number (range 001 to 366)</dd>
|
||||
* <dt>%k</dt> <dd>hour as a decimal number using a 24-hour clock (range 0 to 23); single digits are preceded by a blank. (See also %H.)</dd>
|
||||
* <dt>%l</dt> <dd>hour as a decimal number using a 12-hour clock (range 1 to 12); single digits are preceded by a blank. (See also %I.) </dd>
|
||||
* <dt>%m</dt> <dd>month as a decimal number (range 01 to 12)</dd>
|
||||
* <dt>%M</dt> <dd>minute as a decimal number</dd>
|
||||
* <dt>%n</dt> <dd>newline character</dd>
|
||||
* <dt>%p</dt> <dd>either "AM" or "PM" according to the given time value, or the corresponding strings for the current locale</dd>
|
||||
* <dt>%P</dt> <dd>like %p, but lower case</dd>
|
||||
* <dt>%r</dt> <dd>time in a.m. and p.m. notation equal to %I:%M:%S %p</dd>
|
||||
* <dt>%R</dt> <dd>time in 24 hour notation equal to %H:%M</dd>
|
||||
* <dt>%s</dt> <dd>number of seconds since the Epoch, ie, since 1970-01-01 00:00:00 UTC</dd>
|
||||
* <dt>%S</dt> <dd>second as a decimal number</dd>
|
||||
* <dt>%t</dt> <dd>tab character</dd>
|
||||
* <dt>%T</dt> <dd>current time, equal to %H:%M:%S</dd>
|
||||
* <dt>%u</dt> <dd>weekday as a decimal number [1,7], with 1 representing Monday</dd>
|
||||
* <dt>%U</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Sunday as the first day of the first week</dd>
|
||||
* <dt>%V</dt> <dd>The ISO 8601:1988 week number of the current year as a decimal number,
|
||||
* range 01 to 53, where week 1 is the first week that has at least 4 days
|
||||
* in the current year, and with Monday as the first day of the week.</dd>
|
||||
* <dt>%w</dt> <dd>day of the week as a decimal, Sunday being 0</dd>
|
||||
* <dt>%W</dt> <dd>week number of the current year as a decimal number, starting with the
|
||||
* first Monday as the first day of the first week</dd>
|
||||
* <dt>%x</dt> <dd>preferred date representation for the current locale without the time</dd>
|
||||
* <dt>%X</dt> <dd>preferred time representation for the current locale without the date</dd>
|
||||
* <dt>%y</dt> <dd>year as a decimal number without a century (range 00 to 99)</dd>
|
||||
* <dt>%Y</dt> <dd>year as a decimal number including the century</dd>
|
||||
* <dt>%z</dt> <dd>numerical time zone representation</dd>
|
||||
* <dt>%Z</dt> <dd>time zone name or abbreviation</dd>
|
||||
* <dt>%%</dt> <dd>a literal "%" character</dd>
|
||||
* </dl>
|
||||
* </dd>
|
||||
* <dt>locale {String} (Optional)</dt>
|
||||
* <dd>
|
||||
* The locale to use when displaying days of week, months of the year, and other locale specific
|
||||
* strings. If not specified, this defaults to "en" (though this may be overridden by changing Y.config.locale).
|
||||
* The following locales are built in:
|
||||
* <dl>
|
||||
* <dt>en</dt>
|
||||
* <dd>English</dd>
|
||||
* <dt>en-US</dt>
|
||||
* <dd>US English</dd>
|
||||
* <dt>en-GB</dt>
|
||||
* <dd>British English</dd>
|
||||
* <dt>en-AU</dt>
|
||||
* <dd>Australian English (identical to British English)</dd>
|
||||
* </dl>
|
||||
* More locales may be added by subclassing of Y.DataType.Date.Locale["en"].
|
||||
* See Y.DataType.Date.Locale for more information.
|
||||
* </dd>
|
||||
* </dl>
|
||||
* @return {String} Formatted date for display.
|
||||
*/
|
||||
format : function (oDate, oConfig) {
|
||||
oConfig = oConfig || {};
|
||||
|
||||
if(!Y.Lang.isDate(oDate)) {
|
||||
return Y.Lang.isValue(oDate) ? oDate : "";
|
||||
}
|
||||
|
||||
var format = oConfig.format || Y.config.dateFormat,
|
||||
sLocale = oConfig.locale || Y.config.locale,
|
||||
LOCALE = Y.DataType.Date.Locale;
|
||||
|
||||
sLocale = sLocale.replace(/_/g, "-");
|
||||
|
||||
// Make sure we have a definition for the requested locale, or default to en.
|
||||
if(!LOCALE[sLocale]) {
|
||||
var tmpLocale = sLocale.replace(/-[a-zA-Z]+$/, "");
|
||||
if(tmpLocale in LOCALE) {
|
||||
sLocale = tmpLocale;
|
||||
} else if(Y.config.locale in LOCALE) {
|
||||
sLocale = Y.config.locale;
|
||||
} else {
|
||||
sLocale = "en";
|
||||
}
|
||||
}
|
||||
|
||||
var aLocale = LOCALE[sLocale];
|
||||
|
||||
var replace_aggs = function (m0, m1) {
|
||||
var f = Dt.aggregates[m1];
|
||||
return (f === "locale" ? aLocale[m1] : f);
|
||||
};
|
||||
|
||||
var replace_formats = function (m0, m1) {
|
||||
var f = Dt.formats[m1];
|
||||
switch(Y.Lang.type(f)) {
|
||||
case "string": // string => built in date function
|
||||
return oDate[f]();
|
||||
case "function": // function => our own function
|
||||
return f.call(oDate, oDate, aLocale);
|
||||
case "array": // built in function with padding
|
||||
if(Y.Lang.type(f[0]) === "string") {
|
||||
return xPad(oDate[f[0]](), f[1]);
|
||||
} // no break; (fall through to default:)
|
||||
default:
|
||||
return m1;
|
||||
}
|
||||
};
|
||||
|
||||
// First replace aggregates (run in a loop because an agg may be made up of other aggs)
|
||||
while(format.match(/%[cDFhnrRtTxX]/)) {
|
||||
format = format.replace(/%([cDFhnrRtTxX])/g, replace_aggs);
|
||||
}
|
||||
|
||||
// Now replace formats (do not run in a loop otherwise %%a will be replace with the value of %a)
|
||||
var str = format.replace(/%([aAbBCdegGHIjklmMpPsSuUVwWyYzZ%])/g, replace_formats);
|
||||
|
||||
replace_aggs = replace_formats = undefined;
|
||||
|
||||
return str;
|
||||
}
|
||||
};
|
||||
|
||||
Y.mix(Y.namespace("DataType.Date"), Dt);
|
||||
|
||||
/**
|
||||
* @module datatype
|
||||
*/
|
||||
|
||||
/**
|
||||
* The Date.Locale class is a container for all localised date strings
|
||||
* used by Y.DataType.Date. It is used internally, but may be extended
|
||||
* to provide new date localisations.
|
||||
*
|
||||
* To create your own Locale, follow these steps:
|
||||
* <ol>
|
||||
* <li>Find an existing locale that matches closely with your needs</li>
|
||||
* <li>Use this as your base class. Use Y.DataType.Date.Locale["en"] if nothing
|
||||
* matches.</li>
|
||||
* <li>Create your own class as an extension of the base class using
|
||||
* Y.merge, and add your own localisations where needed.</li>
|
||||
* </ol>
|
||||
* See the Y.DataType.Date.Locale["en-US"] and Y.DataType.Date.Locale["en-GB"]
|
||||
* classes which extend Y.DataType.Date.Locale["en"].
|
||||
*
|
||||
* For example, to implement locales for French french and Canadian french,
|
||||
* we would do the following:
|
||||
* <ol>
|
||||
* <li>For French french, we have no existing similar locale, so use
|
||||
* Y.DataType.Date.Locale["en"] as the base, and extend it:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr"] = Y.merge(Y.DataType.Date.Locale, {
|
||||
* a: ["dim", "lun", "mar", "mer", "jeu", "ven", "sam"],
|
||||
* A: ["dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi"],
|
||||
* b: ["jan", "fév", "mar", "avr", "mai", "jun", "jui", "aoû", "sep", "oct", "nov", "déc"],
|
||||
* B: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"],
|
||||
* c: "%a %d %b %Y %T %Z",
|
||||
* p: ["", ""],
|
||||
* P: ["", ""],
|
||||
* x: "%d.%m.%Y",
|
||||
* X: "%T"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* <li>For Canadian french, we start with French french and change the meaning of \%x:
|
||||
* <pre>
|
||||
* Y.DataType.Date.Locale["fr-CA"] = Y.merge(Y.DataType.Date.Locale["fr"], {
|
||||
* x: "%Y-%m-%d"
|
||||
* });
|
||||
* </pre>
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* With that, you can use your new locales:
|
||||
* <pre>
|
||||
* var d = new Date("2008/04/22");
|
||||
* Y.DataType.Date.format(d, { format: "%A, %d %B == %x", locale: "fr" });
|
||||
* </pre>
|
||||
* will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 22.04.2008
|
||||
* </pre>
|
||||
* And
|
||||
* <pre>
|
||||
* Y.DataType.Date.format(d, {format: "%A, %d %B == %x", locale: "fr-CA" });
|
||||
* </pre>
|
||||
* Will return:
|
||||
* <pre>
|
||||
* mardi, 22 avril == 2008-04-22
|
||||
* </pre>
|
||||
* @requires oop
|
||||
* @class DataType.Date.Locale
|
||||
* @static
|
||||
*/
|
||||
var YDateEn = {
|
||||
a: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
|
||||
A: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
|
||||
b: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
|
||||
B: ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
|
||||
c: "%a %d %b %Y %T %Z",
|
||||
p: ["AM", "PM"],
|
||||
P: ["am", "pm"],
|
||||
r: "%I:%M:%S %p",
|
||||
x: "%d/%m/%y",
|
||||
X: "%T"
|
||||
};
|
||||
|
||||
Y.namespace("DataType.Date.Locale");
|
||||
|
||||
Y.DataType.Date.Locale["en"] = YDateEn;
|
||||
|
||||
Y.DataType.Date.Locale["en-US"] = Y.merge(YDateEn, {
|
||||
c: "%a %d %b %Y %I:%M:%S %p %Z",
|
||||
x: "%m/%d/%Y",
|
||||
X: "%I:%M:%S %p"
|
||||
});
|
||||
|
||||
Y.DataType.Date.Locale["en-GB"] = Y.merge(YDateEn, {
|
||||
r: "%l:%M:%S %P %Z"
|
||||
});
|
||||
Y.DataType.Date.Locale["en-AU"] = Y.merge(YDateEn);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-date', function(Y){}, '3.0.0' ,{use:['datatype-date-parse', 'datatype-date-format']});
|
||||
|
||||
|
||||
YUI.add('datatype-xml-parse', function(Y) {
|
||||
|
||||
/**
|
||||
* Parse XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-parse
|
||||
* @for DataType.XML
|
||||
*/
|
||||
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method parse
|
||||
* @param data {String} Data to convert.
|
||||
* @return {XMLDoc} XML Document.
|
||||
*/
|
||||
parse: function(data) {
|
||||
var xmlDoc = null;
|
||||
if(LANG.isString(data)) {
|
||||
try {
|
||||
if(!LANG.isUndefined(DOMParser)) {
|
||||
xmlDoc = new DOMParser().parseFromString(data, "text/xml");
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
try {
|
||||
if(!LANG.isUndefined(ActiveXObject)) {
|
||||
xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
|
||||
xmlDoc.async = false;
|
||||
xmlDoc.loadXML(data);
|
||||
}
|
||||
}
|
||||
catch(ee) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( (LANG.isNull(xmlDoc)) || (LANG.isNull(xmlDoc.documentElement)) || (xmlDoc.documentElement.nodeName === "parsererror") ) {
|
||||
}
|
||||
|
||||
return xmlDoc;
|
||||
}
|
||||
});
|
||||
|
||||
// Add Parsers shortcut
|
||||
Y.namespace("Parsers").xml = Y.DataType.XML.parse;
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
YUI.add('datatype-xml-format', function(Y) {
|
||||
|
||||
/**
|
||||
* Format XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml-format
|
||||
*/
|
||||
|
||||
/**
|
||||
* XML submodule.
|
||||
*
|
||||
* @module datatype
|
||||
* @submodule datatype-xml
|
||||
*/
|
||||
|
||||
/**
|
||||
* DataType.XML provides a set of utility functions to operate against XML documents.
|
||||
*
|
||||
* @class DataType.XML
|
||||
* @static
|
||||
*/
|
||||
var LANG = Y.Lang;
|
||||
|
||||
Y.mix(Y.namespace("DataType.XML"), {
|
||||
/**
|
||||
* Converts data to type XMLDocument.
|
||||
*
|
||||
* @method format
|
||||
* @param data {XMLDoc} Data to convert.
|
||||
* @return {String} String.
|
||||
*/
|
||||
format: function(data) {
|
||||
try {
|
||||
if(!LANG.isUndefined(XMLSerializer)) {
|
||||
return (new XMLSerializer()).serializeToString(data);
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
if(data && data.xml) {
|
||||
return data.xml;
|
||||
}
|
||||
else {
|
||||
return (LANG.isValue(data) && data.toString) ? data.toString() : "";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' );
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype-xml', function(Y){}, '3.0.0' ,{use:['datatype-xml-parse', 'datatype-xml-format']});
|
||||
|
||||
|
||||
|
||||
|
||||
YUI.add('datatype', function(Y){}, '3.0.0' ,{use:['datatype-number', 'datatype-date', 'datatype-xml']});
|
||||
|
||||
8
jssource/src_files/include/javascript/yui3/build/dd/dd-constrain-min.js
vendored
Normal file
8
jssource/src_files/include/javascript/yui3/build/dd/dd-constrain-min.js
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add("dd-constrain",function(B){var K="dragNode",M="offsetHeight",F="offsetWidth",Q="host",P="constrain2region",H="constrain2node",G="tickXArray",O="tickYArray",N=B.DD.DDM,E="top",J="right",L="bottom",D="left",I=null;var A=function(C){A.superclass.constructor.apply(this,arguments);};A.NAME="DragConstrained";A.NS="con";A.ATTRS={host:{},stickX:{value:false},stickY:{value:false},tickX:{value:false},tickY:{value:false},tickXArray:{value:false},tickYArray:{value:false},constrain2region:{value:false,getter:function(C){if(B.Lang.isObject(C)){var R={};B.mix(R,C);return R;}else{return false;}},setter:function(C){if(B.Lang.isObject(C)){if(B.Lang.isNumber(C[E])&&B.Lang.isNumber(C[J])&&B.Lang.isNumber(C[D])&&B.Lang.isNumber(C[L])){var R={};B.mix(R,C);return R;}else{return false;}}else{if(C!==false){return false;}}return C;}},gutter:{value:"0",setter:function(C){return B.DD.DDM.cssSizestoObject(C);}},constrain2node:{value:false,setter:function(R){if(!this.get(P)){var C=B.Node.get(R);if(C){return C;}}else{if(this.get(P)!==false){}}return false;}},constrain2view:{value:false}};I={initializer:function(){this.get(Q).on("drag:start",B.bind(this._handleStart,this));this.get(Q).after("drag:align",B.bind(this.align,this));},_handleStart:function(){this._regionCache=null;},_regionCache:null,_cacheRegion:function(){this._regionCache=this.get(H).get("region");},getRegion:function(V){var T={},U=null,C=null,S=this.get("gutter"),R=this.get(Q);if(this.get(H)){if(!this._regionCache){B.on("resize",B.bind(this._cacheRegion,this),window);this._cacheRegion();}T=B.clone(this._regionCache);}else{if(this.get(P)){T=this.get(P);}else{if(this.get("constrain2view")){T=R.get(K).get("viewportRegion");}else{return false;}}}B.each(S,function(W,X){if((X==J)||(X==L)){T[X]-=W;}else{T[X]+=W;}});if(V){U=R.get(K).get(M);C=R.get(K).get(F);T[J]=T[J]-C;T[L]=T[L]-U;}return T;},_checkRegion:function(C){var S=C,U=this.getRegion(),T=this.get(Q),V=T.get(K).get(M),R=T.get(K).get(F);if(S[1]>(U[L]-V)){C[1]=(U[L]-V);}if(U[E]>S[1]){C[1]=U[E];}if(S[0]>(U[J]-R)){C[0]=(U[J]-R);}if(U[D]>S[0]){C[0]=U[D];}return C;},inRegion:function(S){S=S||this.get(Q).get(K).getXY();var R=this._checkRegion([S[0],S[1]]),C=false;if((S[0]===R[0])&&(S[1]===R[1])){C=true;}return C;},align:function(){var S=this.get(Q),C=S.actXY,R=this.getRegion(true);if(this.get("stickX")){C[1]=(S.startXY[1]-S.deltaXY[1]);}if(this.get("stickY")){C[0]=(S.startXY[0]-S.deltaXY[0]);}if(R){C=this._checkRegion(C);}C=this._checkTicks(C,R);S.actXY=C;},_checkTicks:function(W,U){var T=this.get(Q),V=(T.startXY[0]-T.deltaXY[0]),S=(T.startXY[1]-T.deltaXY[1]),C=this.get("tickX"),R=this.get("tickY");if(C&&!this.get(G)){W[0]=N._calcTicks(W[0],V,C,U[D],U[J]);}if(R&&!this.get(O)){W[1]=N._calcTicks(W[1],S,R,U[E],U[L]);}if(this.get(G)){W[0]=N._calcTickArray(W[0],this.get(G),U[D],U[J]);}if(this.get(O)){W[1]=N._calcTickArray(W[1],this.get(O),U[E],U[L]);}return W;}};B.namespace("Plugin");B.extend(A,B.Base,I);B.Plugin.DDConstrained=A;B.mix(N,{_calcTicks:function(X,W,T,V,U){var R=((X-W)/T),S=Math.floor(R),C=Math.ceil(R);if((S!==0)||(C!==0)){if((R>=S)&&(R<=C)){X=(W+(T*S));if(V&&U){if(X<V){X=(W+(T*(S+1)));}if(X>U){X=(W+(T*(S-1)));}}}}return X;},_calcTickArray:function(Y,Z,X,U){var R=0,V=Z.length,T=0,S,C,W;if(!Z||(Z.length===0)){return Y;}else{if(Z[0]>=Y){return Z[0];}else{for(R=0;R<V;R++){T=(R+1);if(Z[T]&&Z[T]>=Y){S=Y-Z[R];C=Z[T]-Y;W=(C>S)?Z[R]:Z[T];if(X&&U){if(W>U){if(Z[R]){W=Z[R];}else{W=Z[V-1];}}}return W;}}return Z[Z.length-1];}}}});},"3.0.0",{requires:["dd-drag"],skinnable:false});
|
||||
425
jssource/src_files/include/javascript/yui3/build/dd/dd-constrain.js
vendored
Normal file
425
jssource/src_files/include/javascript/yui3/build/dd/dd-constrain.js
vendored
Normal file
@@ -0,0 +1,425 @@
|
||||
/*
|
||||
Copyright (c) 2009, Yahoo! Inc. All rights reserved.
|
||||
Code licensed under the BSD License:
|
||||
http://developer.yahoo.net/yui/license.txt
|
||||
version: 3.0.0
|
||||
build: 1549
|
||||
*/
|
||||
YUI.add('dd-constrain', function(Y) {
|
||||
|
||||
|
||||
/**
|
||||
* The Drag & Drop Utility allows you to create a draggable interface efficiently, buffering you from browser-level abnormalities and enabling you to focus on the interesting logic surrounding your particular implementation. This component enables you to create a variety of standard draggable objects with just a few lines of code and then, using its extensive API, add your own specific implementation logic.
|
||||
* @module dd
|
||||
* @submodule dd-constrain
|
||||
*/
|
||||
/**
|
||||
* This is a plugin for the dd-drag module to add the constraining methods to it. It supports constraining to a renodenode or viewport. It anode* supports tick based moves and XY axis constraints.
|
||||
* @class DragConstrained
|
||||
* @extends Base
|
||||
* @constructor
|
||||
* @namespace Plugin
|
||||
*/
|
||||
|
||||
var DRAG_NODE = 'dragNode',
|
||||
OFFSET_HEIGHT = 'offsetHeight',
|
||||
OFFSET_WIDTH = 'offsetWidth',
|
||||
HOST = 'host',
|
||||
CON_2_REGION = 'constrain2region',
|
||||
CON_2_NODE = 'constrain2node',
|
||||
TICK_X_ARRAY = 'tickXArray',
|
||||
TICK_Y_ARRAY = 'tickYArray',
|
||||
DDM = Y.DD.DDM,
|
||||
TOP = 'top',
|
||||
RIGHT = 'right',
|
||||
BOTTOM = 'bottom',
|
||||
LEFT = 'left',
|
||||
proto = null;
|
||||
|
||||
var C = function(config) {
|
||||
C.superclass.constructor.apply(this, arguments);
|
||||
};
|
||||
|
||||
C.NAME = 'DragConstrained';
|
||||
/**
|
||||
* @property con
|
||||
* @description The Constrained instance will be placed on the Drag instance under the con namespace.
|
||||
* @type {String}
|
||||
*/
|
||||
C.NS = 'con';
|
||||
|
||||
C.ATTRS = {
|
||||
host: {
|
||||
},
|
||||
/**
|
||||
* @attribute stickX
|
||||
* @description Stick the drag movement to the X-Axis. Default: false
|
||||
* @type Boolean
|
||||
*/
|
||||
stickX: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute stickY
|
||||
* @description Stick the drag movement to the Y-Axis
|
||||
* @type Boolean
|
||||
*/
|
||||
stickY: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute tickX
|
||||
* @description The X tick offset the drag node should snap to on each drag move. False for no ticks. Default: false
|
||||
* @type Number/false
|
||||
*/
|
||||
tickX: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute tickY
|
||||
* @description The Y tick offset the drag node should snap to on each drag move. False for no ticks. Default: false
|
||||
* @type Number/false
|
||||
*/
|
||||
tickY: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute tickXArray
|
||||
* @description An array of page coordinates to use as X ticks for drag movement.
|
||||
* @type Array
|
||||
*/
|
||||
tickXArray: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute tickYArray
|
||||
* @description An array of page coordinates to use as Y ticks for drag movement.
|
||||
* @type Array
|
||||
*/
|
||||
tickYArray: {
|
||||
value: false
|
||||
},
|
||||
/**
|
||||
* @attribute constrain2region
|
||||
* @description An Object Literal containing a valid region (top, right, bottom, left) of page positions to constrain the drag node to.
|
||||
* @type Object
|
||||
*/
|
||||
constrain2region: {
|
||||
value: false,
|
||||
getter: function(r) {
|
||||
if (Y.Lang.isObject(r)) {
|
||||
var o = {};
|
||||
Y.mix(o, r);
|
||||
return o;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
setter: function (r) {
|
||||
if (Y.Lang.isObject(r)) {
|
||||
if (Y.Lang.isNumber(r[TOP]) && Y.Lang.isNumber(r[RIGHT]) && Y.Lang.isNumber(r[LEFT]) && Y.Lang.isNumber(r[BOTTOM])) {
|
||||
var o = {};
|
||||
Y.mix(o, r);
|
||||
return o;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else if (r !== false) {
|
||||
return false;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @attribute gutter
|
||||
* @description CSS style string for the gutter of a region (supports negative values): '5 0' (sets top and bottom to 5px, left and right to 0px), '1 2 3 4' (top 1px, right 2px, bottom 3px, left 4px)
|
||||
* @type String
|
||||
*/
|
||||
gutter: {
|
||||
value: '0',
|
||||
setter: function(gutter) {
|
||||
return Y.DD.DDM.cssSizestoObject(gutter);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @attribute constrain2node
|
||||
* @description Will attempt to constrain the drag node to the boundaries of this node.
|
||||
* @type Object
|
||||
*/
|
||||
constrain2node: {
|
||||
value: false,
|
||||
setter: function(n) {
|
||||
if (!this.get(CON_2_REGION)) {
|
||||
var node = Y.Node.get(n);
|
||||
if (node) {
|
||||
return node;
|
||||
}
|
||||
} else if (this.get(CON_2_REGION) !== false) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
},
|
||||
/**
|
||||
* @attribute constrain2view
|
||||
* @description Will attempt to constrain the drag node to the boundaries of the viewport region.
|
||||
* @type Object
|
||||
*/
|
||||
constrain2view: {
|
||||
value: false
|
||||
}
|
||||
};
|
||||
|
||||
proto = {
|
||||
initializer: function() {
|
||||
this.get(HOST).on('drag:start', Y.bind(this._handleStart, this));
|
||||
this.get(HOST).after('drag:align', Y.bind(this.align, this));
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @method _handleStart
|
||||
* @description Fires on drag:start and clears the _regionCache
|
||||
*/
|
||||
_handleStart: function() {
|
||||
this._regionCache = null;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @property _regionCache
|
||||
* @description Store a cache of the region that we are constraining to
|
||||
* @type Object
|
||||
*/
|
||||
_regionCache: null,
|
||||
/**
|
||||
* @private
|
||||
* @method _cacheRegion
|
||||
* @description Get's the region and caches it, called from window.resize and when the cache is null
|
||||
*/
|
||||
_cacheRegion: function() {
|
||||
this._regionCache = this.get(CON_2_NODE).get('region');
|
||||
},
|
||||
/**
|
||||
* @method getRegion
|
||||
* @description Get the active region: viewport, node, custom region
|
||||
* @param {Boolean} inc Include the node's height and width
|
||||
* @return {Object}
|
||||
*/
|
||||
getRegion: function(inc) {
|
||||
var r = {}, oh = null, ow = null,
|
||||
g = this.get('gutter'),
|
||||
host = this.get(HOST);
|
||||
|
||||
if (this.get(CON_2_NODE)) {
|
||||
if (!this._regionCache) {
|
||||
Y.on('resize', Y.bind(this._cacheRegion, this), window);
|
||||
this._cacheRegion();
|
||||
}
|
||||
r = Y.clone(this._regionCache);
|
||||
} else if (this.get(CON_2_REGION)) {
|
||||
r = this.get(CON_2_REGION);
|
||||
} else if (this.get('constrain2view')) {
|
||||
r = host.get(DRAG_NODE).get('viewportRegion');
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Y.each(g, function(i, n) {
|
||||
if ((n == RIGHT) || (n == BOTTOM)) {
|
||||
r[n] -= i;
|
||||
} else {
|
||||
r[n] += i;
|
||||
}
|
||||
});
|
||||
if (inc) {
|
||||
oh = host.get(DRAG_NODE).get(OFFSET_HEIGHT);
|
||||
ow = host.get(DRAG_NODE).get(OFFSET_WIDTH);
|
||||
r[RIGHT] = r[RIGHT] - ow;
|
||||
r[BOTTOM] = r[BOTTOM] - oh;
|
||||
}
|
||||
return r;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @method _checkRegion
|
||||
* @description Check if xy is inside a given region, if not change to it be inside.
|
||||
* @param {Array} _xy The XY to check if it's in the current region, if it isn't inside the region, it will reset the xy array to be inside the region.
|
||||
* @return {Array} The new XY that is inside the region
|
||||
*/
|
||||
_checkRegion: function(_xy) {
|
||||
var oxy = _xy,
|
||||
r = this.getRegion(),
|
||||
host = this.get(HOST),
|
||||
oh = host.get(DRAG_NODE).get(OFFSET_HEIGHT),
|
||||
ow = host.get(DRAG_NODE).get(OFFSET_WIDTH);
|
||||
|
||||
if (oxy[1] > (r[BOTTOM] - oh)) {
|
||||
_xy[1] = (r[BOTTOM] - oh);
|
||||
}
|
||||
if (r[TOP] > oxy[1]) {
|
||||
_xy[1] = r[TOP];
|
||||
|
||||
}
|
||||
if (oxy[0] > (r[RIGHT] - ow)) {
|
||||
_xy[0] = (r[RIGHT] - ow);
|
||||
}
|
||||
if (r[LEFT] > oxy[0]) {
|
||||
_xy[0] = r[LEFT];
|
||||
}
|
||||
|
||||
return _xy;
|
||||
},
|
||||
/**
|
||||
* @method inRegion
|
||||
* @description Checks if the XY passed or the dragNode is inside the active region.
|
||||
* @param {Array} xy Optional XY to check, if not supplied this.get('dragNode').getXY() is used.
|
||||
* @return {Boolean} True if the XY is inside the region, false otherwise.
|
||||
*/
|
||||
inRegion: function(xy) {
|
||||
xy = xy || this.get(HOST).get(DRAG_NODE).getXY();
|
||||
|
||||
var _xy = this._checkRegion([xy[0], xy[1]]),
|
||||
inside = false;
|
||||
if ((xy[0] === _xy[0]) && (xy[1] === _xy[1])) {
|
||||
inside = true;
|
||||
}
|
||||
return inside;
|
||||
},
|
||||
/**
|
||||
* @method align
|
||||
* @description Modifies the Drag.actXY method from the after drag:align event. This is where the constraining happens.
|
||||
*/
|
||||
align: function() {
|
||||
var host = this.get(HOST),
|
||||
_xy = host.actXY,
|
||||
r = this.getRegion(true);
|
||||
|
||||
if (this.get('stickX')) {
|
||||
_xy[1] = (host.startXY[1] - host.deltaXY[1]);
|
||||
}
|
||||
if (this.get('stickY')) {
|
||||
_xy[0] = (host.startXY[0] - host.deltaXY[0]);
|
||||
}
|
||||
|
||||
if (r) {
|
||||
_xy = this._checkRegion(_xy);
|
||||
}
|
||||
|
||||
_xy = this._checkTicks(_xy, r);
|
||||
host.actXY = _xy;
|
||||
},
|
||||
/**
|
||||
* @private
|
||||
* @method _checkTicks
|
||||
* @description This method delegates the proper helper method for tick calculations
|
||||
* @param {Array} xy The XY coords for the Drag
|
||||
* @param {Object} r The optional region that we are bound to.
|
||||
* @return {Array} The calced XY coords
|
||||
*/
|
||||
_checkTicks: function(xy, r) {
|
||||
var host = this.get(HOST),
|
||||
lx = (host.startXY[0] - host.deltaXY[0]),
|
||||
ly = (host.startXY[1] - host.deltaXY[1]),
|
||||
xt = this.get('tickX'),
|
||||
yt = this.get('tickY');
|
||||
if (xt && !this.get(TICK_X_ARRAY)) {
|
||||
xy[0] = DDM._calcTicks(xy[0], lx, xt, r[LEFT], r[RIGHT]);
|
||||
}
|
||||
if (yt && !this.get(TICK_Y_ARRAY)) {
|
||||
xy[1] = DDM._calcTicks(xy[1], ly, yt, r[TOP], r[BOTTOM]);
|
||||
}
|
||||
if (this.get(TICK_X_ARRAY)) {
|
||||
xy[0] = DDM._calcTickArray(xy[0], this.get(TICK_X_ARRAY), r[LEFT], r[RIGHT]);
|
||||
}
|
||||
if (this.get(TICK_Y_ARRAY)) {
|
||||
xy[1] = DDM._calcTickArray(xy[1], this.get(TICK_Y_ARRAY), r[TOP], r[BOTTOM]);
|
||||
}
|
||||
|
||||
return xy;
|
||||
}
|
||||
};
|
||||
|
||||
Y.namespace('Plugin');
|
||||
Y.extend(C, Y.Base, proto);
|
||||
Y.Plugin.DDConstrained = C;
|
||||
|
||||
Y.mix(DDM, {
|
||||
/**
|
||||
* @for DDM
|
||||
* @namespace DD
|
||||
* @private
|
||||
* @method _calcTicks
|
||||
* @description Helper method to calculate the tick offsets for a given position
|
||||
* @param {Number} pos The current X or Y position
|
||||
* @param {Number} start The start X or Y position
|
||||
* @param {Number} tick The X or Y tick increment
|
||||
* @param {Number} off1 The min offset that we can't pass (region)
|
||||
* @param {Number} off2 The max offset that we can't pass (region)
|
||||
* @return {Number} The new position based on the tick calculation
|
||||
*/
|
||||
_calcTicks: function(pos, start, tick, off1, off2) {
|
||||
var ix = ((pos - start) / tick),
|
||||
min = Math.floor(ix),
|
||||
max = Math.ceil(ix);
|
||||
if ((min !== 0) || (max !== 0)) {
|
||||
if ((ix >= min) && (ix <= max)) {
|
||||
pos = (start + (tick * min));
|
||||
if (off1 && off2) {
|
||||
if (pos < off1) {
|
||||
pos = (start + (tick * (min + 1)));
|
||||
}
|
||||
if (pos > off2) {
|
||||
pos = (start + (tick * (min - 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return pos;
|
||||
},
|
||||
/**
|
||||
* @for DDM
|
||||
* @namespace DD
|
||||
* @private
|
||||
* @method _calcTickArray
|
||||
* @description This method is used with the tickXArray and tickYArray config options
|
||||
* @param {Number} pos The current X or Y position
|
||||
* @param {Number} ticks The array containing our custom tick positions.
|
||||
* @param {Number} off1 The min offset that we can't pass (region)
|
||||
* @param {Number} off2 The max offset that we can't pass (region)
|
||||
* @return The tick position
|
||||
*/
|
||||
_calcTickArray: function(pos, ticks, off1, off2) {
|
||||
var i = 0, len = ticks.length, next = 0,
|
||||
diff1, diff2, ret;
|
||||
|
||||
if (!ticks || (ticks.length === 0)) {
|
||||
return pos;
|
||||
} else if (ticks[0] >= pos) {
|
||||
return ticks[0];
|
||||
} else {
|
||||
for (i = 0; i < len; i++) {
|
||||
next = (i + 1);
|
||||
if (ticks[next] && ticks[next] >= pos) {
|
||||
diff1 = pos - ticks[i];
|
||||
diff2 = ticks[next] - pos;
|
||||
ret = (diff2 > diff1) ? ticks[i] : ticks[next];
|
||||
if (off1 && off2) {
|
||||
if (ret > off2) {
|
||||
if (ticks[i]) {
|
||||
ret = ticks[i];
|
||||
} else {
|
||||
ret = ticks[len - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
}
|
||||
return ticks[ticks.length - 1];
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
}, '3.0.0' ,{requires:['dd-drag'], skinnable:false});
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user