uppy
Version:
Almost as cute as a Puppy :dog:
65 lines (45 loc) • 3.19 kB
JavaScript
;
var _appendChild = require('yo-yoify/lib/appendChild');
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Plugin = require('./Plugin');
/**
* Progress bar
*
*/
module.exports = function (_Plugin) {
_inherits(ProgressBar, _Plugin);
function ProgressBar(core, opts) {
_classCallCheck(this, ProgressBar);
var _this = _possibleConstructorReturn(this, _Plugin.call(this, core, opts));
_this.id = 'ProgressBar';
_this.title = 'Progress Bar';
_this.type = 'progressindicator';
// set default options
var defaultOptions = {
target: 'body',
replaceTargetContent: false,
fixed: false
// merge default options with the ones set by user
};_this.opts = _extends({}, defaultOptions, opts);
_this.render = _this.render.bind(_this);
return _this;
}
ProgressBar.prototype.render = function render(state) {
var _uppyProgressBarInner, _uppyProgressBarPercentage, _uppyProgressBar;
var progress = state.totalProgress || 0;
return _uppyProgressBar = document.createElement('div'), _uppyProgressBar.setAttribute('style', '' + String(this.opts.fixed ? 'position: fixed' : 'null') + ''), _uppyProgressBar.setAttribute('class', 'UppyProgressBar'), _appendChild(_uppyProgressBar, [' ', (_uppyProgressBarInner = document.createElement('div'), _uppyProgressBarInner.setAttribute('style', 'width: ' + String(progress) + '%'), _uppyProgressBarInner.setAttribute('class', 'UppyProgressBar-inner'), _uppyProgressBarInner), ' ', (_uppyProgressBarPercentage = document.createElement('div'), _uppyProgressBarPercentage.setAttribute('class', 'UppyProgressBar-percentage'), _appendChild(_uppyProgressBarPercentage, [progress]), _uppyProgressBarPercentage), ' ']), _uppyProgressBar;
};
ProgressBar.prototype.install = function install() {
var target = this.opts.target;
var plugin = this;
this.target = this.mount(target, plugin);
};
ProgressBar.prototype.uninstall = function uninstall() {
this.unmount();
};
return ProgressBar;
}(Plugin);
//# sourceMappingURL=ProgressBar.js.map