first commit

This commit is contained in:
2026-01-16 14:13:44 +08:00
commit 903ff8d495
34603 changed files with 8585054 additions and 0 deletions

View File

@ -0,0 +1,125 @@
/*
* This file is part of the jquery plugin "asyncQueue".
*
* (c) Sebastien Roch <roch.sebastien@gmail.com>
* @author (parallel) Dmitry Farafonov
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
(function($){
$.AsyncQueue = function() {
var that = this,
queue = [],
completeFunc,
failureFunc,
paused = false,
lastCallbackData,
_run,
_complete,
inQueue = 0,
defaultTimeOut = 10;
_run = function() {
var f = queue.shift();
if (f) {
inQueue++;
setTimeout(function(){
f.fn.apply(that, [that]);
if (!f.isParallel)
if (paused === false) {
_run();
}
inQueue --;
if (inQueue == 0 && queue.length == 0)
_complete();
}, f.timeOut);
if (f.isParallel)
if (paused === false) {
_run();
}
}
};
_complete = function(){
if (completeFunc)
completeFunc.apply(that, [that]);
};
this.onComplete = function(func) {
completeFunc = func;
};
this.onFailure = function(func) {
failureFunc = func;
};
this.add = function(func) {
// TODO: add callback for queue[i] complete
var obj = arguments[0];
if (obj && Object.prototype.toString.call(obj) === "[object Array]") {
var fn = arguments[1];
var timeOut = (typeof(arguments[2]) != "undefined")? arguments[2] : defaultTimeOut;
if (typeof(fn) == "function") {
for(var i = 0; i < obj.length; i++) {
var f = function(objx){
queue.push({isParallel: true, fn: function(){fn.apply(that, [that, objx]);}, timeOut: timeOut});
}(obj[i])
}
}
} else {
var fn = arguments[0];
var timeOut = (typeof(arguments[1]) != "undefined")? arguments[2] : defaultTimeOut;
queue.push({isParallel: false, fn: func, timeOut: timeOut});
}
return this;
};
this.addParallel = function(func, timeOut) {
// TODO: add callback for queue[i] complete
queue.push({isParallel: true, fn: func, timeOut: timeOut});
return this;
};
this.storeData = function(dataObject) {
lastCallbackData = dataObject;
return this;
};
this.lastCallbackData = function () {
return lastCallbackData;
};
this.run = function() {
paused = false;
_run();
};
this.pause = function () {
paused = true;
return this;
};
this.failure = function() {
paused = true;
if (failureFunc) {
var args = [that];
for(i = 0; i < arguments.length; i++) {
args.push(arguments[i]);
}
failureFunc.apply(that, args);
}
};
this.size = function(){
return queue.length;
};
return this;
}
})(jQuery);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,131 @@
/*
* @ Dmitry Farafonov
*/
(function($){
$.ProgressBar = function(options) {
this.element = $(options.boundingBox);
if (options.on && options.on.complete){
this.onComplete = options.on.complete;
}
if (options.on && options.on.valueChange){
this.onValueChange = options.on.valueChange;
}
this._create();
if (options.label)
this.set("label", options.label);
if (options.value)
this.value(options.value);
if (options.max)
this.set("max", options.max);
};
$.ProgressBar.prototype = {
options: {
value: 0,
max: 100
},
min: 0,
_create: function() {
this.element
.addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
.attr({
role: "progressbar",
"aria-valuemin": this.min,
"aria-valuemax": this.options.max,
"aria-valuenow": this._value()
});
this.valueDiv = $( "<div class='ui-progressbar-label'></div>" )
.appendTo( this.element );
this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
.appendTo( this.element );
this.oldValue = this._value();
this._refreshValue();
},
_destroy: function() {
this.element
.removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
.removeAttr( "role" )
.removeAttr( "aria-valuemin" )
.removeAttr( "aria-valuemax" )
.removeAttr( "aria-valuenow" );
this.valueDiv.remove();
},
value: function( newValue ) {
if ( newValue === undefined ) {
return this._value();
}
this._setOption( "value", newValue );
return this;
},
_setOption: function( key, value ) {
if ( key === "value" ) {
//var oldVal = this.options.value;
this.options.value = value;
this._refreshValue();
if (this.onValueChange)
this.onValueChange.apply(this, [{oldVal: this.oldValue, newVal: value}]);
if ( this._value() === this.options.max ) {
//this._trigger( "complete" );
if (this.onComplete)
this.onComplete.apply(this);
}
} else if (key === "label") {
$(this.element).find(".ui-progressbar-label").html(value);
} else if (key === "max") {
this.options.max = value;
}
//this._super( key, value );
},
_value: function() {
var val = this.options.value;
// normalize invalid value
if ( typeof val !== "number" ) {
val = 0;
}
return Math.min( this.options.max, Math.max( this.min, val ) );
},
_percentage: function() {
return 100 * this._value() / this.options.max;
},
_refreshValue: function() {
var value = this.value(),
percentage = this._percentage();
if ( this.oldValue !== value ) {
this.oldValue = value;
//this._trigger( "change" );
}
this.valueDiv
.toggle( value > this.min )
.toggleClass( "ui-corner-right", value === this.options.max )
.width( percentage.toFixed(0) + "%" );
this.element.attr( "aria-valuenow", value );
//$(this.element).find(".ui-progressbar-label").html(value + "%");
},
set: function(key, value){
this._setOption(key, value);
}
};
})( jQuery );