Skip to content

Instantly share code, notes, and snippets.

@darkowlzz
Last active August 29, 2015 14:00
Show Gist options
  • Save darkowlzz/171eff600135ebdab2fe to your computer and use it in GitHub Desktop.
Save darkowlzz/171eff600135ebdab2fe to your computer and use it in GitHub Desktop.
Snippet of viewPanel.js
// 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