PHP Classes

File: js/1mix.progress.js

Recommend this page to a friend!
  Classes of Alex Lau   Mix2ool   js/1mix.progress.js   Download  
File: js/1mix.progress.js
Role: Auxiliary data
Content type: text/plain
Description: The progress component
Class: Mix2ool
Web development framework integrated with jQuery
Author: By
Last change:
Date: 14 years ago
Size: 2,569 bytes
 

Contents

Class file image Download
mixElements.append("progress"); document.createElement("progress"); mix.progress = function (elements){ var progress; if (type(elements) == "undefined"){ progress = $(document.createElement("progress")); }else{ progress = $(elements).filter(function (){ var el = this.parentNode; while (el.nodeType == 1 && el.nodeName.toLowerCase() != "html" && el.nodeName.toLowerCase() != "template") el = el.parentNode; return (("" + this.nodeName).toLowerCase() == "progress" && this._mixInit !== true && el.nodeName.toLowerCase() != "template"); //node name is progress and has not been initialized }); } progress.each(function (){ $(this).append("progressbar".$create()); }).bind("attrChange", function (){ mix.progress.redraw(this); }).each(function (){ this._mixInit = true; }).redraw(); $(window).resize(function (){ progress.redraw(); }); return progress; }; mix.progress.redraw = function (el){ if ($(el).attr("position") == "-1"){ if (type(el._indeterminateFunc) == "undefined"){ el._indeterminateFunc = function (){ var elWidth = $(el).width(); var barWidth = $(el).find("progressbar").width(); var newWidth = (barWidth / elWidth + 0.01) * elWidth; if (newWidth > elWidth) newWidth = 0; if (newWidth <= barWidth + 1) newWidth++; $(el).find("progressbar").css("width", newWidth +"px"); } } el._indeterminateFunc.stopTimer().startTimer(50); }else{ if (type(el._indeterminateFunc) != "undefined"){ el._indeterminateFunc.stopTimer(); } var v = ("" + $(el).attr("value")).toFloat(); var m = ("" + $(el).attr("max")).toFloat(); if (isNaN(v)) v = 0; else if (isNaN(m)) m = 1; if (m <= 0) m = 1; if (v < 0) v = 0; if (v > m) v = m; $(el).find("progressbar").css("width", (v/m * $(el).width()) + "px"); } }; mix.progress.attr = function (el, name, value){ if (type(value) == "undefined"){ //getter switch (name){ case "value": case "max": return el.getAttribute(name); break; case "position": var v = ("" + $(el).attr("value")).toFloat(); var m = ("" + $(el).attr("max")).toFloat(); if (isNaN(v) && isNaN(m)){ return "-1"; } return "" + (v/m); break; } return; } if (name == "value" || name == "max"){ el.setAttribute(name, value); $(el).trigger("attrChange", [name, value]); mix.progress.redraw(el); } return value; }; mix.progress.customAttrList = "value,max,position".split(",");