(container, progress, color)
| 30 | * @param {Object} color 可选,指定颜色样式(目前暂未提供实际样式,可暂时不暴露此参数) |
| 31 | */ |
| 32 | var showProgressbar = function(container, progress, color) { |
| 33 | if (typeof container === 'number') { |
| 34 | color = progress; |
| 35 | progress = container; |
| 36 | container = 'body'; |
| 37 | } |
| 38 | container = $(container || 'body'); |
| 39 | if (container.length === 0) return; |
| 40 | container = container[0]; |
| 41 | var progressbar; |
| 42 | if (container.classList.contains(CLASS_PROGRESSBAR)) { |
| 43 | progressbar = container; |
| 44 | } else { |
| 45 | var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR + ':not(.' + CLASS_PROGRESSBAR_OUT + ')'); |
| 46 | if (progressbars) { |
| 47 | for (var i = 0, len = progressbars.length; i < len; i++) { |
| 48 | var _progressbar = progressbars[i]; |
| 49 | if (_progressbar.parentNode === container) { |
| 50 | progressbar = _progressbar; |
| 51 | break; |
| 52 | } |
| 53 | } |
| 54 | } |
| 55 | if (!progressbar) { |
| 56 | progressbar = document.createElement('span'); |
| 57 | progressbar.className = CLASS_PROGRESSBAR + ' ' + CLASS_PROGRESSBAR_IN + (typeof progress !== 'undefined' ? '' : (' ' + CLASS_PROGRESSBAR_INFINITE)) + (color ? (' ' + CLASS_PROGRESSBAR + '-' + color) : ''); |
| 58 | if (typeof progress !== 'undefined') { |
| 59 | progressbar.innerHTML = '<span></span>'; |
| 60 | } |
| 61 | container.appendChild(progressbar); |
| 62 | } else { |
| 63 | progressbar.classList.add(CLASS_PROGRESSBAR_IN); |
| 64 | } |
| 65 | } |
| 66 | if (progress) setProgressbar(container, progress); |
| 67 | return progressbar; |
| 68 | }; |
| 69 | /** |
| 70 | * 关闭进度条 |
| 71 | * @param {Object} container 可选,默认body,支持selector,DOM Node,mui wrapper |
no test coverage detected