Last active
August 29, 2015 14:00
-
-
Save darkowlzz/171eff600135ebdab2fe to your computer and use it in GitHub Desktop.
Snippet of viewPanel.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ViewPanel class | |
function ViewPanel(content, script) { | |
this.panel = Panel({ | |
width: sp.prefs['width'], | |
height: sp.prefs['height'], | |
contentURL: data.url(content), | |
contentScriptFile: data.url(script) | |
}); | |
// Using arrow functions to resolve scope issues | |
let onWidthChange = () => { | |
this.panel.width = sp.prefs['width']; | |
} | |
let onHeightChange = () => { | |
this.panel.height = sp.prefs['height']; | |
} | |
// listeners on the prefs change | |
sp.on('width', onWidthChange); | |
sp.on('height', onHeightChange); | |
} | |
ViewPanel.prototype.getWidth = function getWidth() { | |
return this.panel.width; | |
}; | |
ViewPanel.prototype.getHeight = function getHeight() { | |
return this.panel.height; | |
}; | |
ViewPanel.prototype.setWidth = function setWidth(width) { | |
this.panel.width = width; | |
}; | |
ViewPanel.prototype.setHeight = function setHeight(height) { | |
this.panel.height = height; | |
}; | |
ViewPanel.prototype.getPanel = function getPanel() { | |
return this.panel; | |
}; | |
exports.ViewPanel = ViewPanel; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment