webamp/js/context.js
Jordan Eldredge 624292e457 Fix loading skins from context menu
I had forgotten to include MyFile in context.js. Additionally, for some reason
`self` was out of scope in the callback.
2015-04-11 11:03:50 -07:00

43 lines
1.3 KiB
JavaScript

define(['file'], function(MyFile) {
return {
init: function(winamp) {
this.winamp = winamp;
// The Option button
this.option = document.getElementById('option');
var self = this;
document.onclick = function() {
self.option.classList.remove('selected');
};
this.option.onclick = function(event) {
self.option.classList.toggle('selected');
event.stopPropagation();
};
var skinSelectNodes = document.getElementsByClassName('skin-select');
for(var i = 0; i < skinSelectNodes.length; i++) {
skinSelectNodes[i].onclick = this._loadSkin.bind(this);
}
document.getElementById('context-play-file').onclick = function(event) {
self.option.classList.remove('selected');
self.winamp.openFileDialog();
};
document.getElementById('context-load-skin').onclick = function(event) {
self.option.classList.remove('selected');
self.winamp.openFileDialog();
};
document.getElementById('context-exit').onclick = function() {
self.winamp.close();
};
},
_loadSkin: function(event) {
var skinFile = new MyFile();
skinFile.setUrl(event.target.dataset.skinUrl);
this.winamp.setSkin(skinFile);
}
};
});