(container, progress, color)
| 7604 | * @param {Object} color 可选,指定颜色样式(目前暂未提供实际样式,可暂时不暴露此参数) |
| 7605 | */ |
| 7606 | var showProgressbar = function(container, progress, color) { |
| 7607 | if (typeof container === 'number') { |
| 7608 | color = progress; |
| 7609 | progress = container; |
| 7610 | container = 'body'; |
| 7611 | } |
| 7612 | container = $(container || 'body'); |
| 7613 | if (container.length === 0) return; |
| 7614 | container = container[0]; |
| 7615 | var progressbar; |
| 7616 | if (container.classList.contains(CLASS_PROGRESSBAR)) { |
| 7617 | progressbar = container; |
| 7618 | } else { |
| 7619 | var progressbars = container.querySelectorAll(SELECTOR_PROGRESSBAR + ':not(.' + CLASS_PROGRESSBAR_OUT + ')'); |
| 7620 | if (progressbars) { |
| 7621 | for (var i = 0, len = progressbars.length; i < len; i++) { |
| 7622 | var _progressbar = progressbars[i]; |
| 7623 | if (_progressbar.parentNode === container) { |
| 7624 | progressbar = _progressbar; |
| 7625 | break; |
| 7626 | } |
| 7627 | } |
| 7628 | } |
| 7629 | if (!progressbar) { |
| 7630 | progressbar = document.createElement('span'); |
| 7631 | progressbar.className = CLASS_PROGRESSBAR + ' ' + CLASS_PROGRESSBAR_IN + (typeof progress !== 'undefined' ? '' : (' ' + CLASS_PROGRESSBAR_INFINITE)) + (color ? (' ' + CLASS_PROGRESSBAR + '-' + color) : ''); |
| 7632 | if (typeof progress !== 'undefined') { |
| 7633 | progressbar.innerHTML = '<span></span>'; |
| 7634 | } |
| 7635 | container.appendChild(progressbar); |
| 7636 | } else { |
| 7637 | progressbar.classList.add(CLASS_PROGRESSBAR_IN); |
| 7638 | } |
| 7639 | } |
| 7640 | if (progress) setProgressbar(container, progress); |
| 7641 | return progressbar; |
| 7642 | }; |
| 7643 | /** |
| 7644 | * 关闭进度条 |
| 7645 | * @param {Object} container 可选,默认body,支持selector,DOM Node,mui wrapper |
no test coverage detected