Alien-Web-ExtJS-V3
view release on metacpan or search on metacpan
share/adapter/ext/ext-base-debug.js view on Meta::CPAN
Ext.applyIf(String, {
/**
* Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
* token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
* <pre><code>
var cls = 'my-class', text = 'Some text';
var s = String.format('<div class="{0}">{1}</div>', cls, text);
// s now contains the string: '<div class="my-class">Some text</div>'
* </code></pre>
* @param {String} string The tokenized string to be formatted
* @param {String} value1 The value to replace token {0}
* @param {String} value2 Etc...
* @return {String} The formatted string
* @static
*/
format : function(format){
var args = Ext.toArray(arguments, 1);
return format.replace(/\{(\d+)\}/g, function(m, i){
return args[i];
});
}
});
/**
* @class Array
*/
Ext.applyIf(Array.prototype, {
/**
* Checks whether or not the specified object exists in the array.
* @param {Object} o The object to check for
* @param {Number} from (Optional) The index at which to begin the search
* @return {Number} The index of o in the array (or -1 if it is not found)
*/
indexOf : function(o, from){
var len = this.length;
from = from || 0;
from += (from < 0) ? len : 0;
for (; from < len; ++from){
if(this[from] === o){
return from;
}
}
return -1;
},
/**
* Removes the specified object from the array. If the object is not found nothing happens.
* @param {Object} o The object to remove
* @return {Array} this array
*/
remove : function(o){
var index = this.indexOf(o);
if(index != -1){
this.splice(index, 1);
}
return this;
}
});
/**
* @class Ext.util.TaskRunner
* Provides the ability to execute one or more arbitrary tasks in a multithreaded
* manner. Generally, you can use the singleton {@link Ext.TaskMgr} instead, but
* if needed, you can create separate instances of TaskRunner. Any number of
* separate tasks can be started at any time and will run independently of each
* other. Example usage:
* <pre><code>
// Start a simple clock task that updates a div once per second
var updateClock = function(){
Ext.fly('clock').update(new Date().format('g:i:s A'));
}
var task = {
run: updateClock,
interval: 1000 //1 second
}
var runner = new Ext.util.TaskRunner();
runner.start(task);
// equivalent using TaskMgr
Ext.TaskMgr.start({
run: updateClock,
interval: 1000
});
* </code></pre>
* <p>See the {@link #start} method for details about how to configure a task object.</p>
* Also see {@link Ext.util.DelayedTask}.
*
* @constructor
* @param {Number} interval (optional) The minimum precision in milliseconds supported by this TaskRunner instance
* (defaults to 10)
*/
Ext.util.TaskRunner = function(interval){
interval = interval || 10;
var tasks = [],
removeQueue = [],
id = 0,
running = false,
// private
stopThread = function(){
running = false;
clearInterval(id);
id = 0;
},
// private
startThread = function(){
if(!running){
running = true;
id = setInterval(runTasks, interval);
}
},
// private
removeTask = function(t){
removeQueue.push(t);
if(t.onStop){
t.onStop.apply(t.scope || t);
}
},
share/adapter/ext/ext-base-debug.js view on Meta::CPAN
});
var onStart = function(){
var me = this,
attr;
me.onStart.fire();
me.runAttrs = {};
for(attr in this.attributes){
this.setRunAttr(attr);
}
me.isAnimated = true;
me.startTime = now();
actualFrames = 0;
};
var onTween = function(){
var me = this;
me.onTween.fire({
duration: now() - me.startTime,
curFrame: me.curFrame
});
var ra = me.runAttrs;
for (var attr in ra) {
this.setAttr(attr, me.doMethod(attr, ra[attr].start, ra[attr].end), ra[attr].unit);
}
++actualFrames;
};
var onComplete = function() {
var me = this,
actual = (now() - me.startTime) / 1000,
data = {
duration: actual,
frames: actualFrames,
fps: actualFrames / actual
};
me.isAnimated = false;
actualFrames = 0;
me.onComplete.fire(data);
};
me.onStart = new Ext.util.Event(me);
me.onTween = new Ext.util.Event(me);
me.onComplete = new Ext.util.Event(me);
(me._onStart = new Ext.util.Event(me)).addListener(onStart);
(me._onTween = new Ext.util.Event(me)).addListener(onTween);
(me._onComplete = new Ext.util.Event(me)).addListener(onComplete);
}
};
Ext.lib.AnimMgr = new function() {
var me = this,
thread = null,
queue = [],
tweenCount = 0;
Ext.apply(me, {
fps: 1000,
delay: 1,
registerElement: function(tween){
queue.push(tween);
++tweenCount;
tween._onStart.fire();
me.start();
},
unRegister: function(tween, index){
tween._onComplete.fire();
index = index || getIndex(tween);
if (index != -1) {
queue.splice(index, 1);
}
if (--tweenCount <= 0) {
me.stop();
}
},
start: function(){
if(thread === null){
thread = setInterval(me.run, me.delay);
}
},
stop: function(tween){
if(!tween){
clearInterval(thread);
for(var i = 0, len = queue.length; i < len; ++i){
if(queue[0].isAnimated){
me.unRegister(queue[0], 0);
}
}
queue = [];
thread = null;
tweenCount = 0;
}else{
me.unRegister(tween);
}
},
run: function(){
var tf, i, len, tween;
for(i = 0, len = queue.length; i<len; i++) {
tween = queue[i];
if(tween && tween.isAnimated){
tf = tween.totalFrames;
if(tween.curFrame < tf || tf === null){
++tween.curFrame;
if(tween.useSec){
correctFrame(tween);
}
tween._onTween.fire();
}else{
me.stop(tween);
}
}
}
}
});
var getIndex = function(anim) {
var i, len;
for(i = 0, len = queue.length; i<len; i++) {
if(queue[i] === anim) {
return i;
}
}
return -1;
};
var correctFrame = function(tween) {
var frames = tween.totalFrames,
frame = tween.curFrame,
duration = tween.duration,
expected = (frame * duration * 1000 / frames),
elapsed = (now() - tween.startTime),
tweak = 0;
if(elapsed < duration * 1000){
tweak = Math.round((elapsed / expected - 1) * frame);
}else{
tweak = frames - (frame + 1);
}
if(tweak > 0 && isFinite(tweak)){
if(tween.curFrame + tweak >= frames){
tweak = frames - (frame + 1);
}
tween.curFrame += tweak;
}
};
};
EXTLIB.Bezier = new function() {
( run in 1.004 second using v1.01-cache-2.11-cpan-02777c243ea )