2019-01-24 19:54:16 +00:00
|
|
|
"use strict";
|
|
|
|
(function() {
|
|
|
|
var moduleName = "views/songProgress";
|
|
|
|
|
|
|
|
var deps = [];
|
2019-01-30 20:36:33 +00:00
|
|
|
deps.push("views/slider");
|
2019-01-24 19:54:16 +00:00
|
|
|
|
|
|
|
define(moduleName, deps, function() {
|
2019-01-30 20:36:33 +00:00
|
|
|
var Slider = require("views/slider");
|
2019-01-24 19:54:16 +00:00
|
|
|
|
2019-01-30 20:36:33 +00:00
|
|
|
var SongProgress = Slider.inherit({
|
2019-01-24 19:54:16 +00:00
|
|
|
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
|
|
|
|
2019-01-24 19:54:16 +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);
|
2019-01-24 19:54:16 +00:00
|
|
|
},
|
|
|
|
destructor: function() {
|
|
|
|
this._f.off("load", this._onLoad, this);
|
|
|
|
|
2019-01-30 20:36:33 +00:00
|
|
|
Slider.fn.destructor.call(this);
|
2019-01-24 19:54:16 +00:00
|
|
|
},
|
|
|
|
_createBars: function() {
|
2019-01-30 20:36:33 +00:00
|
|
|
Slider.fn._createBars.call(this);
|
2019-01-24 19:54:16 +00:00
|
|
|
|
|
|
|
this._loadProgress = document.createElement("div");
|
|
|
|
|
2019-01-30 20:36:33 +00:00
|
|
|
this._loadProgress.style.backgroundColor = Slider.theme.secondaryColor || "#ffff00";
|
2019-01-24 19:54:16 +00:00
|
|
|
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
|
|
|
},
|
2019-01-24 19:54:16 +00:00
|
|
|
_onData: function() {
|
2019-01-30 20:36:33 +00:00
|
|
|
Slider.fn._onData.call(this);
|
2019-01-24 19:54:16 +00:00
|
|
|
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);
|
2019-01-24 19:54:16 +00:00
|
|
|
},
|
|
|
|
_resetTheme: function() {
|
2019-01-30 20:36:33 +00:00
|
|
|
Slider.fn._resetTheme.call(this);
|
2019-01-24 19:54:16 +00:00
|
|
|
|
2019-01-30 20:36:33 +00:00
|
|
|
this._loadProgress.style.backgroundColor = Slider.theme.secondaryColor || "#ffff00"
|
2019-01-24 19:54:16 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
return SongProgress;
|
|
|
|
})
|
|
|
|
})();
|
|
|
|
|