radio/lorgar/views/songProgress.js

71 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

"use strict";
(function() {
var moduleName = "views/songProgress";
var deps = [];
2019-01-30 20:36:33 +00:00
deps.push("views/slider");
define(moduleName, deps, function() {
2019-01-30 20:36:33 +00:00
var Slider = require("views/slider");
2019-01-30 20:36:33 +00:00
var SongProgress = Slider.inherit({
className: "SongProgress",
constructor: function(controller, options) {
var base = {
minHeight: 10,
maxHeight: 10
};
W.extend(base, options)
2019-01-30 20:36:33 +00:00
Slider.fn.constructor.call(this, controller, base);
2019-01-26 18:54:22 +00:00
this._f.on("load", this._onLoad, this);
2019-01-26 18:54:22 +00:00
2019-01-30 20:36:33 +00:00
this._e.insertBefore(this._loadProgress, this._value);
},
destructor: function() {
this._f.off("load", this._onLoad, this);
2019-01-30 20:36:33 +00:00
Slider.fn.destructor.call(this);
},
_createBars: function() {
2019-01-30 20:36:33 +00:00
Slider.fn._createBars.call(this);
this._loadProgress = document.createElement("div");
2019-01-30 20:36:33 +00:00
this._loadProgress.style.backgroundColor = Slider.theme.secondaryColor || "#ffff00";
this._loadProgress.style.height = "100%";
this._loadProgress.style.width = "0";
this._loadProgress.style.position = "absolute";
this._loadProgress.style.top = "0";
this._loadProgress.style.left = "0";
2019-01-26 18:54:22 +00:00
},
_onData: function() {
2019-01-30 20:36:33 +00:00
Slider.fn._onData.call(this);
this._onLoad(this._f.load);
},
_onLoad: function(load) {
this._loadProgress.style.width = load * 100 + "%";
},
2019-01-26 18:54:22 +00:00
_onMouseDown: function(e) {
if (e.which === 1) {
this._f.trigger("seekingStart");
}
2019-01-30 20:36:33 +00:00
Slider.fn._onMouseDown.call(this, e);
2019-01-26 18:54:22 +00:00
},
2019-01-30 20:36:33 +00:00
_onMouseUp: function(e) {
Slider.fn._onMouseUp.call(this, e);
this._f.trigger("seekingEnd", this._f.value);
},
_resetTheme: function() {
2019-01-30 20:36:33 +00:00
Slider.fn._resetTheme.call(this);
2019-01-30 20:36:33 +00:00
this._loadProgress.style.backgroundColor = Slider.theme.secondaryColor || "#ffff00"
}
});
return SongProgress;
})
})();