此项目的demo网站http://wijmo.com/Wijmo-Open/samples/
/*
* wijprogressbar Widget. V1.0
*
* Copyright (c) Componentone Inc.
*
* Depends:
* Jquery-1.4.2.js
* jquery.ui.core.js
* jquery.ui.widget.js
*
*Optional dependence for effect settings:
* jquery.effects.core.js
* jquery.effects.blind.js
* jquery.effects.bounce.js
* jquery.effects.clip.js
* jquery.effects.drop.js
* jquery.effects.explode.js
* jquery.effects.fold.js
* jquery.effects.hightlight.js
* jquery.effects.pulsate.js
* jquery.effects.scale.js
* jquery.effects.shake.js
* jquery.effects.slide.js
* jquery.effects.transfer.js
* HTML:
*
*/
(function ($) {
$.widget("ui.wijprogressbar", $.ui.progressbar, {
options: {
///
///The label's alignment on the progress bar. The value should be "east", "west", "center", "north", "south" or "running".
///Default:"center".
///Type:String.
///Code sample:$('.selector').wijprogressbar('option','labelAlign','center').
///
labelAlign: "center",
///
///The value of the progress bar,the type should be numeric.
///Default:0.
///Type:Number.
///Code sample:$('.selector').wijprogressbar('option','value',60).
///
maxValue: 100,
///
///The minimum value of the progress bar,the type should be numeric.
///Default:0.
///Type:Number.
///Code sample:$('.selector').wijprogressbar('option','minValue',0).
///
minValue: 0,
///
///The fill direction of the progress bar.the value should be "east", "west", "north" or "south".
///Default:"east".
///Type:String.
///Code sample:$('.selector').wijprogressbar('option','fillDirection','east').
///
fillDirection: "east",
///
///The progressbar's orientation.the value should be 'horizontal' or 'vertical'.
///Default:"horizontal".
///Type:String.
///Code sample:$('selector').wijprogressbar('option','orientation','horizontal').
///
///orientation: "horizontal",
///
///Sets the format of the label text.The available formats are as follows:
///{0} or {ProgressValue} express the current progress Value.
///{1} or {PercentProgress} express the current percent of the progress bar.
///{2} or {RemainingProgress} express the remaining progress of the progress bar.
///{3} or {PercentageRemaining} express the remaining percent of the progress bar.
///{4} or {Min} express the min Vlaue of the progress bar.
///{5} or {Max} express the max Value of the progress bar.
///Default:"{1}%".
///Type:String.
///Code sample:$('.selector').wijprogressbar('option','labelFormatString','{0}%').
///
labelFormatString: "{1}%",
///
///Set the format of the ToolTip of the progress bar,the expression of the format like the labelFormatString.
///Default:"{1}%".
///Type:String.
///Code sample:$('.selector').wijprogressbar('option','toolTipFormatString','{1}%').
///
toolTipFormatString: "{1}%",
///
///The increment of the progress bar's indicator.
///Default:1.
///Type:Number.
///
///Code sample:$('.selector').wijprogressbar('option','indicatorIncrement',10).
indicatorIncrement: 1,
///
///The Image's url of the indicator.
///Default:"".
///Type:String.
///Code sample:$('.selector').wijprogressbar('option','indicatorImage','images/abc.png').
///
indicatorImage: "",
///
///The delay of the progressbar's animation.
///Default:0.
///Type:Number.
///Code sample:$('.selector').wijprogressbar('option',
///
animationDelay: 0,
///
///The options parameter of the jQuery's animation.
///Default:"{animated:'progress',duration:500}".
///Type:Options.
///Code sample:$('.selector').wijprogressbar('option','animationOptions',{animated:'progress',duration:600}).
///
animationOptions: {
animated: 'progress',
duration: 500
}
},
//when set the options, trigger this method.
_setOption: function (key, value) {
var val, self = this;
switch (key) {
case "value":
val = parseInt(value);
self.options[key] = val;
self._refreshValue(val);
break;
case "maxValue":
case "minValue":
val = parseInt(value);
self.options[key] = val;
self[key === "maxValue" ? "max" : "min"] = val;
self._refreshValue();
break;
case "labelFormatString":
case "toolTipFormatString":
self.options[key] = value;
self._refreshValue();
//$.Widget.prototype._setOption.apply(this, arguments);
break;
case "orientation":
case "fillDirection":
case "labelAlign":
case "indicatorImage":
self.options[key] = value;
self._initElements();
self._refreshValue();
//$.Widget.prototype._setOption.apply(this, arguments);
break;
case "indicatorIncrement":
value = (value == 0 ? 1 : value);
self.options[key] = value;
self._initElements();
self._refreshValue();
break;
default: break;
}
$.Widget.prototype._setOption.apply(self, arguments);
},
///create the widget
_create: function () {
var self = this;
self.min = self.options.minValue;
self.max = self.options.maxValue;
self.element.addClass("ui-wijprogressbar");
$.ui.progressbar.prototype._create.apply(self, arguments);
self.label = $("").addClass("ui-progressbar-label ui-corner-left").appendTo(self.valueDiv);
self._initElements();
self._isInit = true;
self._refreshValue();
},
///Trigger the pressbar event.
_triggerEvent: function (eventName, oldValue, newValue, cancel) {
var ea = $.Event(eventName);
ea.data = {
oldValue: oldValue,
newValue: newValue,
cancel: cancel
};
this._trigger(eventName, ea);
return ea.data.cancel;
},
//refresh the progress value.
_refreshValue: function () {
var self = this;
if (!self._isInit) {
return;
}
var value = self.value();
var percent = (value - self.min) / (self.max - self.min) * 100;
var o = self.options;
var cancel = self._triggerEvent("beforeProgressChanging", self.element.attr("aria-valuenow"), value, false);
if (cancel) {
return;
}
self.valueDiv.css({
width: "",
height: ""
});
// If have animation.
if (o.animationOptions.animated && o.animationOptions.duration > 0) {
setTimeout($.proxy(function () {
var o = self.options.animationOptions;
var animateOptions = {
content: self.valueDiv,
complete: $.proxy(function () {
self._triggerEvent("progressChanged", self.element.attr("aria-valuenow"), value, false);
}, self),
step: $.proxy(function (ovalue) {
self._performAnimating(ovalue);
}, self),
processValue: percent
}
var animations = $.ui.wijprogressbar.animations;
var duration = o.duration;
var easing = o.animated;
if (easing && !animations[easing]) {
easing = "progress";
}
if (!animations[easing]) {
animations[easing] = function (options) {
this.progress(options, {
easing: easing,
duration: duration || 1000
});
}
}
animations[easing](animateOptions, self.options.animationOptions);
}, self), o.animationDelay);
}
else {
//trigger the progressChanged event.
var oldValue = self.element.attr("aria-valuenow");
self._refreshProgress(percent);
self._triggerEvent("progressChanged", oldValue, value, false);
}
},
///Set the label's position of the progress bar.
_setLabelSide: function () {
var self = this;
var fillDirection = self.options.fillDirection;
var labelAlign = self.options.labelAlign;
if (self._isHorizontal()) {
if (labelAlign === "west" || labelAlign === "east" || labelAlign === "center") {
self.label.css("width", self.element.width() + 'px');
}
else
if (labelAlign === "running") {
self.label.css("width", "auto");
}
else {
self.element.css("line-height", "normal");
self.valueDiv.css("line-height", "normal");
self.label.css("height", labelAlign === "north" ? self.element.height() + 'px' : "auto");
}
}
else {
if (labelAlign === "west" || labelAlign === "east" || labelAlign === "center") {
self.label.css({ "line-height": self.element.height() + 'px', "width": self.element.width() + 'px' });
}
else
if (labelAlign === "running") {
self.label.css({ "height": "auto", "width": self.element.width() + 'px' });
}
else {
self.element.css("line-height", "normal");
self.valueDiv.css("line-height", "normal");
self.label.css("height", labelAlign === "north" ? self.element.height() + 'px' : "auto");
}
}
},
///get the progress bar's progress orientation.
_isHorizontal: function () {
return this.options.fillDirection === "west" || this.options.fillDirection === "east";
},
///start the progress
startTask: function () {
///
if ($(":animated", this.element).length == 0) {
var value = this.value();
this._refreshValue(value);
}
},
///stop the progress
stopTask: function () {
///
this.valueDiv.stop();
},
//init the progress bar
_initElements: function () {
var self = this;
var o = self.options;
self.element.removeClass("ui-wijprogressbar-west ui-wijprogressbar-east ui-wijprogressbar-north ui-wijprogressbar-south").addClass("ui-wijprogressbar-" + o.fillDirection);
var height = self.element.height();
self.valueDiv.css("line-height", "");
self.label.removeClass("lb_west lb_east lb_south lb_north lb_center lb_running").addClass("lb_" + o.labelAlign)
.css("line-height", "").css({
left: "",
right: "",
top: "",
bottom: ""
});
if (self._isHorizontal()) {
self.valueDiv.height(height)
.css("line-height", height + "px");
}
else {
self.valueDiv.width(self.element.width());
}
self._setLabelSide();
if (self.options.indicatorImage !== "") {
self.valueDiv.css("background", "transparent url(" + self.options.indicatorImage + ") repeat fixed");
}
},
///refresh the progress
_refreshProgress: function (value) {
var self = this;
var ea = new $.Event('progressChanging');
var nowValue = value * (self.max - self.min) / 100 + self.min;
var o = self.options;
var cancel = self._triggerEvent("progressChanging", self.element.attr("aria-valuenow"), nowValue, false);
if (cancel) {
return;
}
if (self._isHorizontal()) {
self.valueDiv.toggleClass(o.fillDirection === "east" ? "ui-corner-right" : "ui-corner-left", value === self.max).width(value + "%");
}
else {
self.valueDiv.toggleClass(o.fillDirection === "south" ? "ui-corner-bottom" : "ui-corner-top", value === self.max).height(value + "%");
}
self.element.attr("aria-valuenow", nowValue);
var txt = self._getFormatString(o.labelFormatString, value);
self._setLabelsText(txt);
var _tooTip = self._getFormatString(o.toolTipFormatString, value);
self.element.attr("title", _tooTip);
},
///play progress animation.
_performAnimating: function (obj) {
var self = this;
var len = Math.floor(obj / self.options.indicatorIncrement);
obj = len * self.options.indicatorIncrement;
var o = self.options;
self._refreshProgress(obj);
if (o.labelAlign === "running") {
if (self._isHorizontal()) {
var eleWidth = self.element.width();
var labelWidth = self.label.outerWidth();
var progressWidth = self.valueDiv.outerWidth();
var left = eleWidth === progressWidth ? eleWidth - labelWidth : obj * eleWidth / 100 - labelWidth + labelWidth * (eleWidth - progressWidth) / eleWidth;
self.label.css(o.fillDirection === "east" ? "left" : "right", left);
}
else {
var eleHeight = self.element.height();
var labelHeight = self.label.outerHeight();
var progressHeight = self.valueDiv.outerHeight();
var top = eleHeight === progressHeight ? eleHeight - labelHeight : obj * eleHeight / 100 - labelHeight + labelHeight * (eleHeight - progressHeight) / eleHeight;
self.label.css(o.fillDirection === "south" ? "top" : "bottom", top);
}
}
},
//set the label'text
_setLabelsText: function (text) {
if (!this._isHorizontal() && this.options.labelAlign === "rightOrBottom") {
this.label.html('' + text + '');
return;
}
this.label.html(text);
},
//format the text
_getFormatString: function (format, val) {
var self = this;
var processValue = parseInt(self.element.attr("aria-valuenow"));
var remainingProcess = self.max - processValue
var percentProgress = val;
var percentageRemaining = 100 - val;
var r = /\{0\}/g;
format = format.replace(r, processValue.toString());
r = /\{ProgressValue\}/g;
format = format.replace(r, processValue.toString());
r = /\{1\}/g;
format = format.replace(r, percentProgress.toString());
r = /\{PercentProgress\}/g;
format = format.replace(r, percentProgress.toString());
r = /\{2\}/g;
format = format.replace(r, remainingProcess.toString());
r = /\{RemainingProgress\}/g;
format = format.replace(r, remainingProcess.toString());
r = /\{3\}/g;
format = format.replace(r, percentageRemaining.toString());
r = /\{PercentageRemaining\}/g;
format = format.replace(r, percentageRemaining.toString());
r = /\{4\}/g;
format = format.replace(r, self.min);
r = /\{Min\}/g;
format = format.replace(r, self.min);
r = /\{5\}/g;
format = format.replace(r, self.max);
r = /\{Max\}/g;
format = format.replace(r, self.max);
return format;
},
///destroy the widget.
destroy: function () {
this.element.empty();
this.element.removeClass("ui-wijprogressbar ui-widget ui-widget-content ui-corner-all ui-wijprogressbar-h").removeAttr("title");
$.Widget.prototype.destroy.apply(this, arguments);
}
});
///progress bar animation. If user want to write custom animation,can override the animations option.And set the animated to the options key.
$.extend($.ui.wijprogressbar, {
animations: {
progress: function (options, additions) {
options = $.extend({
easing: "swing",
duration: 1000
}, options, additions);
options.content.stop(true, true).animate({
widthvalue: options.processValue
}, options);
}
}
});
})(jQuery);
widget主要是处理ui层面的,实用与否只有用了才知道,widget可以利用jQuery已经存在的css framework。利用themeRoller,可以很轻松的换肤。至于说功能,可以在用户反馈后再慢慢完善。
这个progressbar本身是继承自jQuery ui progressbar的。因为开源,如果自己有好的想法,自己也可以去增加自己需要的功能。

JavaScript字符串替换方法详解及常见问题解答 本文将探讨两种在JavaScript中替换字符串字符的方法:在JavaScript代码内部替换和在网页HTML内部替换。 在JavaScript代码内部替换字符串 最直接的方法是使用replace()方法: str = str.replace("find","replace"); 该方法仅替换第一个匹配项。要替换所有匹配项,需使用正则表达式并添加全局标志g: str = str.replace(/fi

因此,在这里,您准备好了解所有称为Ajax的东西。但是,到底是什么? AJAX一词是指用于创建动态,交互式Web内容的一系列宽松的技术。 Ajax一词,最初由Jesse J创造

本文讨论了在浏览器中优化JavaScript性能的策略,重点是减少执行时间并最大程度地减少对页面负载速度的影响。

本文讨论了使用浏览器开发人员工具的有效JavaScript调试,专注于设置断点,使用控制台和分析性能。

将矩阵电影特效带入你的网页!这是一个基于著名电影《黑客帝国》的酷炫jQuery插件。该插件模拟了电影中经典的绿色字符特效,只需选择一张图片,插件就会将其转换为充满数字字符的矩阵风格画面。快来试试吧,非常有趣! 工作原理 插件将图片加载到画布上,读取像素和颜色值: data = ctx.getImageData(x, y, settings.grainSize, settings.grainSize).data 插件巧妙地读取图片的矩形区域,并利用jQuery计算每个区域的平均颜色。然后,使用

本文将引导您使用jQuery库创建一个简单的图片轮播。我们将使用bxSlider库,它基于jQuery构建,并提供许多配置选项来设置轮播。 如今,图片轮播已成为网站必备功能——一图胜千言! 决定使用图片轮播后,下一个问题是如何创建它。首先,您需要收集高质量、高分辨率的图片。 接下来,您需要使用HTML和一些JavaScript代码来创建图片轮播。网络上有很多库可以帮助您以不同的方式创建轮播。我们将使用开源的bxSlider库。 bxSlider库支持响应式设计,因此使用此库构建的轮播可以适应任何

数据集对于构建API模型和各种业务流程至关重要。这就是为什么导入和导出CSV是经常需要的功能。在本教程中,您将学习如何在Angular中下载和导入CSV文件


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Dreamweaver CS6
视觉化网页开发工具

PhpStorm Mac 版本
最新(2018.2.1 )专业的PHP集成开发工具

MinGW - 适用于 Windows 的极简 GNU
这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。