Skip to content

Commit

Permalink
more customized rules
Browse files Browse the repository at this point in the history
  • Loading branch information
ericawright committed May 12, 2016
1 parent 0c31be8 commit 88124c8
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 56 deletions.
22 changes: 3 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,40 +25,24 @@
"curly": 2,
"default-case": 0,
"eqeqeq": [2, "smart"],
"func-names": 0,
"func-style": 0,
"generator-star-spacing": [2, {"before": false, "after": false}],
"global-require": 0,
"id-blacklist": 0,
"id-length": 0,
"id-match": 0,
"indent": [2, 2],
"init-declarations": 0,
"max-len": 0,
"max-params": 0,
"newline-after-var": 0,
"no-bitwise": 0,
"no-bitwise": 1,
"no-console": 1,
"no-empty-function": 0,
"no-inline-comments": 0,
"no-invalid-this": 0,
"no-magic-numbers": 0,
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-negated-condition": 0,
"no-shadow": 0,
"no-trailing-spaces": [2, {"skipBlankLines": false}],
"no-underscore-dangle": 0,
"no-unused-vars": [2, {"vars": "local", "args": "none"}],
"no-warning-comments": 0,
"object-curly-spacing": [2, "never"],
"no-var": 2,
"prefer-const": 0,
"prefer-reflect": 0,
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"space-before-function-paren": [2, {"anonymous": "never", "named": "never"}],
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"space-infix-ops": 2,
"space-unary-ops": 2,
"strict": 0
"space-unary-ops": 2
}
}
4 changes: 2 additions & 2 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ function startup(data, reason) {
let resource = Services.io.getProtocolHandler('resource')
.QueryInterface(Ci.nsIResProtocolHandler);
resource.setSubstitution(RESOURCE_HOST, data.resourceURI);
unload(function() {
unload(function () {
resource.setSubstitution(RESOURCE_HOST, null);
});

// Initialize VerticalTabs object for each window.
Cu.import('resource://tabcenter/verticaltabs.jsm');
unload(vtInit());
watchWindows(function(window) {
watchWindows(function (window) {
let vt = new VerticalTabs(window, {newPayload, addPingStats});
unload(vt.unload.bind(vt), window);
}, 'navigator:browser');
Expand Down
22 changes: 11 additions & 11 deletions tabdatastore.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const EXPORTED_SYMBOLS = ['VTTabDataStore', 'VTTabIDs'];
Components.utils.import('resource://gre/modules/XPCOMUtils.jsm');

let VTTabDataStore = {
getTabValue: function(aTab, aKey) {
getTabValue: function (aTab, aKey) {
let value = null;
try {
value = this.sessionStore.getTabValue(aTab, aKey);
Expand All @@ -59,7 +59,7 @@ let VTTabDataStore = {
return value;
},

setTabValue: function(aTab, aKey, aValue) {
setTabValue: function (aTab, aKey, aValue) {
if (!aValue) {
this.deleteTabValue(aTab, aKey);
}
Expand All @@ -73,7 +73,7 @@ let VTTabDataStore = {
}
},

deleteTabValue: function(aTab, aKey) {
deleteTabValue: function (aTab, aKey) {
aTab.removeAttribute(aKey);
try {
this.checkCachedSessionDataExpiration(aTab);
Expand All @@ -85,7 +85,7 @@ let VTTabDataStore = {
},

// workaround for http://piro.sakura.ne.jp/latest/blosxom/mozilla/extension/treestyletab/2009-09-29_debug.htm
checkCachedSessionDataExpiration: function(aTab) {
checkCachedSessionDataExpiration: function (aTab) {
let data = aTab.linkedBrowser.__SS_data;
if (data &&
data._tabStillLoading &&
Expand All @@ -110,7 +110,7 @@ function VTTabIDs(tabs) {
}
VTTabIDs.prototype = {

init: function() {
init: function () {
const tabs = this.tabs;
tabs.VTTabIDs = this;
tabs.addEventListener('TabOpen', this, true);
Expand All @@ -129,18 +129,18 @@ VTTabIDs.prototype = {

kId: 'verticaltabs-id',

id: function(aTab) {
id: function (aTab) {
return aTab.getAttribute(this.kId);
},

get: function(aID) {
get: function (aID) {
let elements = this.tabs.getElementsByAttribute(this.kId, aID);
return elements.length ? elements[0] : undefined;
},

/*** Event handlers ***/

handleEvent: function(aEvent) {
handleEvent: function (aEvent) {
switch (aEvent.type) {
case 'TabOpen':
this.initTab(aEvent.originalTarget);
Expand All @@ -151,11 +151,11 @@ VTTabIDs.prototype = {
}
},

makeNewId: function() {
makeNewId: function () {
return this.uuidGen.generateUUID().toString();
},

initTab: function(aTab) {
initTab: function (aTab) {
if (aTab.hasAttribute(this.kId)) {
return;
}
Expand All @@ -164,7 +164,7 @@ VTTabIDs.prototype = {
VTTabDataStore.setTabValue(aTab, this.kId, id);
},

restoreTab: function(aTab) {
restoreTab: function (aTab) {
// Restore the original ID
let newId = VTTabDataStore.getTabValue(aTab, this.kId);
if (newId) {
Expand Down
6 changes: 3 additions & 3 deletions utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function unload(callback, container) {
}
// Calling with no arguments runs all the unloader callbacks
if (callback == null) {
unloaders.slice().forEach(function(unloader) { unloader(); });
unloaders.slice().forEach(function (unloader) { unloader(); });
unloaders.length = 0;
return;
}
Expand All @@ -74,7 +74,7 @@ function unload(callback, container) {

// Wrap the callback to additionally remove the unload listener
let origCallback = callback;
callback = function() {
callback = function () {
container.removeEventListener('unload', removeUnloader, false);
origCallback();
};
Expand Down Expand Up @@ -153,7 +153,7 @@ function watchWindows(callback) {
Services.ww.registerNotification(windowWatcher);

// Make sure to stop watching for windows if we're unloading
unload(function() { Services.ww.unregisterNotification(windowWatcher); });
unload(function () { Services.ww.unregisterNotification(windowWatcher); });
}

const PAYLOAD_KEYS = [
Expand Down
42 changes: 21 additions & 21 deletions verticaltabs.jsm
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ function vtInit() {
let ios = Components.classes['@mozilla.org/network/io-service;1']
.getService(Components.interfaces.nsIIOService);

let installStylesheet = function(uri) {
let installStylesheet = function (uri) {
uri = ios.newURI(uri, null, null);
sss.loadAndRegisterSheet(uri, sss.USER_SHEET);
};

let removeStylesheet = function(uri) {
let removeStylesheet = function (uri) {
uri = ios.newURI(uri, null, null);
sss.unregisterSheet(uri, sss.USER_SHEET);
};
Expand Down Expand Up @@ -101,9 +101,9 @@ function VerticalTabs(window, {newPayload, addPingStats}) {
}
VerticalTabs.prototype = {

init: function() {
init: function () {
this.window.VerticalTabs = this;
this.unloaders.push(function() {
this.unloaders.push(function () {
delete this.window.VerticalTabs;
});
this.window.onunload = () => {
Expand Down Expand Up @@ -155,13 +155,13 @@ VerticalTabs.prototype = {
this.tabObserver.observe(results, {attributes: true});
}

this.unloaders.push(function() {
this.unloaders.push(function () {
this.tabIDs.unload();
this.tabObserver.disconnect();
});
},

createElement: function(label, attrs) {
createElement: function (label, attrs) {
let rv = this.document.createElementNS(NS_XUL, label);
if (attrs) {
for (let attr in attrs) {
Expand All @@ -171,7 +171,7 @@ VerticalTabs.prototype = {
return rv;
},

rearrangeXUL: function() {
rearrangeXUL: function () {
const window = this.window;
const document = this.document;

Expand Down Expand Up @@ -278,7 +278,7 @@ VerticalTabs.prototype = {
}
}, 150);

this.unloaders.push(function() {
this.unloaders.push(function () {
// Move the tabs toolbar back to where it was
toolbar._toolbox = null; // reset value set by constructor
toolbar.removeAttribute('toolboxid');
Expand Down Expand Up @@ -326,7 +326,7 @@ VerticalTabs.prototype = {
});
},

initContextMenu: function() {
initContextMenu: function () {
const document = this.document;
const tabs = document.getElementById('tabbrowser-tabs');

Expand All @@ -343,31 +343,31 @@ VerticalTabs.prototype = {

tabs.contextMenu.addEventListener('popupshowing', this, false);

this.unloaders.push(function() {
this.unloaders.push(function () {
if (closeMultiple) {
tabs.contextMenu.removeChild(closeMultiple);
}
tabs.contextMenu.removeEventListener('popupshowing', this, false);
});
},

initTab: function(aTab) {
initTab: function (aTab) {
if (this.document.getElementById('main-window').getAttribute('tabspinned') !== 'true') {
aTab.removeAttribute('crop');
} else {
aTab.setAttribute('crop', 'end');
}
},

unload: function() {
this.unloaders.forEach(function(func) {
unload: function () {
this.unloaders.forEach(function (func) {
func.call(this);
}, this);
},

/*** Event handlers ***/

handleEvent: function(aEvent) {
handleEvent: function (aEvent) {
switch (aEvent.type) {
case 'DOMContentLoaded':
this.init();
Expand Down Expand Up @@ -396,30 +396,30 @@ VerticalTabs.prototype = {
}
},

onTabSelect: function(aEvent) {
onTabSelect: function (aEvent) {
let tab = aEvent.target;
tab.scrollIntoView();
},

onTabOpen: function(aEvent) {
onTabOpen: function (aEvent) {
let tab = aEvent.target;
this.stats.tabs_created++;
this.initTab(tab);
},

onTabClose: function(aEvent) {
onTabClose: function (aEvent) {
this.stats.tabs_destroyed++;
},

onTabPinned: function(aEvent) {
onTabPinned: function (aEvent) {
this.stats.tabs_pinned++;
},

onTabUnpinned: function(aEvent) {
onTabUnpinned: function (aEvent) {
this.stats.tabs_unpinned++;
},

onPopupShowing: function(aEvent) {
onPopupShowing: function (aEvent) {
if (!this.multiSelect) {
return;
}
Expand All @@ -433,7 +433,7 @@ VerticalTabs.prototype = {
}
},

sendStats: function(payload) {
sendStats: function (payload) {
this.addPingStats(this.stats);
this.stats = this.newPayload();
}
Expand Down

0 comments on commit 88124c8

Please sign in to comment.