Remove extra spaces inside () and add spacing for before { bracket

This commit is contained in:
Raymond Lee 2010-07-30 17:54:30 +08:00
Родитель 22208a8ff8
Коммит f9cb556c01
11 изменённых файлов: 202 добавлений и 203 удалений

Просмотреть файл

@ -77,9 +77,9 @@ var Drag = function(item, event, isResizing, isFauxDrag) {
this.item.setZ(999999);
if (this.item.isATabItem && !isResizing)
this.safeWindowBounds = Items.getSafeWindowBounds( true );
this.safeWindowBounds = Items.getSafeWindowBounds(true);
else
this.safeWindowBounds = Items.getSafeWindowBounds( );
this.safeWindowBounds = Items.getSafeWindowBounds();
Trenches.activateOthersTrenches(this.el);
@ -124,10 +124,10 @@ Drag.prototype = {
// OH SNAP!
if ( // if we aren't holding down the meta key...
!Keys.meta
&& ( !checkItemStatus // don't check the item status...
&& (!checkItemStatus // don't check the item status...
// OR we aren't a tab on top of something else, and there's no drop site...
|| ( !( this.item.isATabItem && this.item.overlapsWithOtherItems() )
&& !iQ(".acceptsDrop").length ) )
|| (!(this.item.isATabItem && this.item.overlapsWithOtherItems())
&& !iQ(".acceptsDrop").length))
) {
newRect = Trenches.snap(bounds,stationaryCorner,assumeConstantSize,keepProportional);
if (newRect) { // might be false if no changes were made
@ -202,7 +202,7 @@ Drag.prototype = {
var updateY = false;
var snappedTrenches = {};
var snapRadius = ( Keys.meta ? 0 : Trenches.defaultRadius );
var snapRadius = (Keys.meta ? 0 : Trenches.defaultRadius);
if (rect.left < swb.left + snapRadius ) {
if (stationaryCorner.indexOf('right') > -1)
rect.width = rect.right - swb.left;

Просмотреть файл

@ -41,25 +41,25 @@
// **********
// Title: groups.js
(function(){
(function() {
// ----------
// Function: numCmp
// Numeric compare for sorting.
// Private to this file.
var numCmp = function(a,b){ return a-b; }
var numCmp = function(a,b) { return a-b; }
// ----------
// Function: min
// Given a list of numbers, returns the smallest.
// Private to this file.
function min(list){ return list.slice().sort(numCmp)[0]; }
function min(list) { return list.slice().sort(numCmp)[0]; }
// ----------
// Function: max
// Given a list of numbers, returns the largest.
// Private to this file.
function max(list){ return list.slice().sort(numCmp).reverse()[0]; }
function max(list) { return list.slice().sort(numCmp).reverse()[0]; }
// ##########
// Class: Group
@ -125,7 +125,7 @@ window.Group = function Group(listOfEls, options) {
if (!rectToBe) {
rectToBe = Groups.getBoundingBox(listOfEls);
rectToBe.inset( -30, -30 );
rectToBe.inset(-30, -30);
}
var $container = options.container;
@ -135,7 +135,7 @@ window.Group = function Group(listOfEls, options) {
.css({position: 'absolute'})
.css(rectToBe);
if ( this.isNewTabsGroup() ) $container.addClass("newTabGroup");
if (this.isNewTabsGroup()) $container.addClass("newTabGroup");
}
this.bounds = $container.bounds();
@ -152,13 +152,13 @@ window.Group = function Group(listOfEls, options) {
this.$ntb
.addClass(this.isNewTabsGroup() ? 'newTabButtonAlt' : 'newTabButton')
.click(function(){
.click(function() {
self.newTab();
});
(this.$ntb)[0].title = 'New tab';
if ( this.isNewTabsGroup() ) this.$ntb.html("<span>+</span>");
if (this.isNewTabsGroup()) this.$ntb.html("<span>+</span>");
// ___ Resizer
this.$resizer = iQ("<div>")
@ -217,12 +217,12 @@ window.Group = function Group(listOfEls, options) {
}
};
var handleKeyPress = function(e){
if ( e.which == 13 ) { // return
var handleKeyPress = function(e) {
if (e.which == 13) { // return
(self.$title)[0].blur();
self.$title
.addClass("transparentBorder")
.one("mouseout", function(){
.one("mouseout", function() {
self.$title.removeClass("transparentBorder");
});
} else
@ -316,7 +316,7 @@ window.Group = function Group(listOfEls, options) {
this._inited = true;
this.save();
} catch(e){
} catch(e) {
Utils.log("Error in Group(): " + e);
}
};
@ -331,7 +331,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// -----------
// Function: setActiveTab
// Sets the active <TabItem> for this group
setActiveTab: function(tab){
setActiveTab: function(tab) {
Utils.assert('tab must be a TabItem', tab && tab.isATabItem);
this._activeTab = tab;
},
@ -339,7 +339,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// -----------
// Function: getActiveTab
// Gets the active <TabItem> for this group
getActiveTab: function(){
getActiveTab: function() {
return this._activeTab;
},
@ -453,8 +453,8 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
if (!options)
options = {};
rect.width = Math.max( 110, rect.width );
rect.height = Math.max( 125, rect.height);
rect.width = Math.max(110, rect.width);
rect.height = Math.max(125, rect.height);
var titleHeight = this.$titlebar.height();
@ -627,7 +627,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// TODO: You should be allowed to drop in the white space at the bottom and have it go to the end
// (right now it can match the thumbnail above it and go there)
function findInsertionPoint(dropPos){
function findInsertionPoint(dropPos) {
if (self.shouldStack(self._children.length + 1))
return 0;
@ -639,21 +639,21 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
if (box.bottom < dropPos.top || box.top > dropPos.top)
return;
var dist = Math.sqrt( Math.pow((box.top+box.height/2)-dropPos.top,2)
+ Math.pow((box.left+box.width/2)-dropPos.left,2) );
var dist = Math.sqrt(Math.pow((box.top+box.height/2)-dropPos.top,2)
+ Math.pow((box.left+box.width/2)-dropPos.left,2));
if ( dist <= best.dist ){
if (dist <= best.dist) {
best.item = child;
best.dist = dist;
best.index = index;
}
});
if ( self._children.length ){
if (self._children.length) {
if (best.item) {
box = best.item.getBounds();
var insertLeft = dropPos.left <= box.left + box.width/2;
if ( !insertLeft )
if (!insertLeft)
return best.index+1;
return best.index;
}
@ -665,11 +665,11 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// Insert the tab into the right position.
var index = findInsertionPoint(dropPos);
this._children.splice( index, 0, item );
this._children.splice(index, 0, item);
item.setZ(this.getZ() + 1);
$el.addClass("tabInGroup");
if ( this.isNewTabsGroup() ) $el.addClass("inNewTabGroup")
if (this.isNewTabsGroup()) $el.addClass("inNewTabGroup")
if (!wasAlreadyInThisGroup) {
item.droppable(false);
@ -693,7 +693,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
}
UI.setReorderTabsOnHide(this);
if ( this._nextNewTabCallback ){
if (this._nextNewTabCallback) {
this._nextNewTabCallback.apply(this, [item])
this._nextNewTabCallback = null;
}
@ -744,7 +744,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
if (typeof(item.setResizable) == 'function')
item.setResizable(true);
if (!this._children.length && !this.locked.close && !this.getTitle() && !options.dontClose){
if (!this._children.length && !this.locked.close && !this.getTitle() && !options.dontClose) {
this.close();
} else if (!options.dontArrange) {
this.arrange();
@ -781,14 +781,14 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: hideExpandControl
// Hide the control which expands a stacked group into a quick-look view.
hideExpandControl: function(){
hideExpandControl: function() {
this.$expander.hide();
},
// ----------
// Function: showExpandControl
// Show the control which expands a stacked group into a quick-look view.
showExpandControl: function(){
showExpandControl: function() {
var childBB = this.getChild(0).getBounds();
var dT = childBB.top - this.getBounds().top;
var dL = childBB.left - this.getBounds().left;
@ -819,7 +819,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
};
var rects = Items.arrange(null, bb, options);
return (rects[0].width < TabItems.minTabWidth * 1.35 );
return (rects[0].width < TabItems.minTabWidth * 1.35);
},
// ----------
@ -847,7 +847,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
if (typeof(options) == 'undefined')
options = {};
this._children.forEach(function(child){
this._children.forEach(function(child) {
child.removeClass("stacked")
});
@ -908,7 +908,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
this._stackArrange(bb, options);
}
if ( this._isStacked && !this.expanded) this.showExpandControl();
if (this._isStacked && !this.expanded) this.showExpandControl();
else this.hideExpandControl();
},
@ -1004,14 +1004,14 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: _randRotate
// Random rotation generator for <_stackArrange>
_randRotate: function(spread, index){
if ( index >= this._stackAngles.length ){
var randAngle = 5*index + parseInt( (Math.random()-.5)*1 );
_randRotate: function(spread, index) {
if (index >= this._stackAngles.length) {
var randAngle = 5*index + parseInt((Math.random()-.5)*1);
this._stackAngles.push(randAngle);
return randAngle;
}
if ( index > 5 ) index = 5;
if (index > 5) index = 5;
return this._stackAngles[index];
},
@ -1049,7 +1049,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
return {};*/
},
expand: function(){
expand: function() {
var self = this;
// ___ we're stacked, and command is held down so expand
Groups.setActiveGroup(self);
@ -1077,10 +1077,10 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
pos.left -= overlayWidth/3;
pos.top -= overlayHeight/3;
if ( pos.top < 0 ) pos.top = 20;
if ( pos.left < 0 ) pos.left = 20;
if ( pos.top+overlayHeight > window.innerHeight ) pos.top = window.innerHeight-overlayHeight-20;
if ( pos.left+overlayWidth > window.innerWidth ) pos.left = window.innerWidth-overlayWidth-20;
if (pos.top < 0) pos.top = 20;
if (pos.left < 0) pos.left = 20;
if (pos.top+overlayHeight > window.innerHeight) pos.top = window.innerHeight-overlayHeight-20;
if (pos.left+overlayWidth > window.innerWidth) pos.left = window.innerWidth-overlayWidth-20;
$tray
.animate({
@ -1094,7 +1094,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
})
.addClass("overlay");
this._children.forEach(function(child){
this._children.forEach(function(child) {
child.addClass("stack-trayed");
});
@ -1117,7 +1117,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// it will collapse, which we don't want. Thus,
// we wait a little bit before adding this event
// handler.
setTimeout(function(){
setTimeout(function() {
$shield.mouseover(function() {
self.collapse();
});
@ -1160,7 +1160,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
this.expanded.$shield.remove();
this.expanded = null;
this._children.forEach(function(child){
this._children.forEach(function(child) {
child.removeClass("stack-trayed");
});
@ -1174,26 +1174,26 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
_addHandlers: function(container) {
var self = this;
this.dropOptions.over = function(){
if ( !this.isNewTabsGroup() )
this.dropOptions.over = function() {
if (!this.isNewTabsGroup())
iQ(this.container).addClass("acceptsDrop");
};
this.dropOptions.drop = function(event){
this.dropOptions.drop = function(event) {
iQ(this.container).removeClass("acceptsDrop");
this.add( drag.info.$el, {left:event.pageX, top:event.pageY} );
this.add(drag.info.$el, {left:event.pageX, top:event.pageY});
};
if (!this.locked.bounds)
this.draggable();
iQ(container)
.mousedown(function(e){
.mousedown(function(e) {
self._mouseDown = {
location: new Point(e.clientX, e.clientY),
className: e.target.className
};
})
.mouseup(function(e){
.mouseup(function(e) {
if (!self._mouseDown || !self._mouseDown.location || !self._mouseDown.className)
return;
@ -1203,7 +1203,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
|| className.indexOf('name') != -1
|| className.indexOf('close') != -1
|| className.indexOf('newTabButton') != -1
|| className.indexOf('stackExpander') != -1 ) {
|| className.indexOf('stackExpander') != -1) {
return;
}
@ -1213,14 +1213,14 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
return;
// Don't zoom in to the last tab for the new tab group.
if ( self.isNewTabsGroup() )
if (self.isNewTabsGroup())
return;
// Zoom into the last-active tab when the group
// is clicked, but only for non-stacked groups.
var activeTab = self.getActiveTab();
if( !self._isStacked ){
if ( activeTab )
if (!self._isStacked) {
if (activeTab)
activeTab.zoomIn();
else if (self.getChild(0))
self.getChild(0).zoomIn();
@ -1231,7 +1231,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
this.droppable(true);
this.$expander.click(function(){
this.$expander.click(function() {
self.expand();
});
},
@ -1239,7 +1239,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: setResizable
// Sets whether the group is resizable and updates the UI accordingly.
setResizable: function(value){
setResizable: function(value) {
this.resizeOptions.minWidth = 90;
this.resizeOptions.minHeight = 90;
@ -1264,12 +1264,12 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// we have to marshal it. A value of 0 wait time doesn't seem
// to work. Instead, we use a value of 1 which seems to be the
// minimum amount of time required.
Utils.timeout(function(){
Utils.timeout(function() {
UI.showTabView()
}, 1);
var self = this;
var doNextTab = function(tab){
var doNextTab = function(tab) {
var group = Groups.getActiveGroup();
iQ(tab.container).css({opacity: 0});
@ -1296,7 +1296,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
height: window.innerHeight
}, {
duration: 270,
complete: function(){
complete: function() {
iQ(tab.container).css({opacity: 1});
gBrowser.selectedTab = newTab;
UI.hideTabView()
@ -1369,7 +1369,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: setTopChild
// Sets the <Item> that should be displayed on top when in stack mode.
setTopChild: function(topChild){
setTopChild: function(topChild) {
this.topChild = topChild;
this.arrange({animate: false});
@ -1383,10 +1383,10 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// Parameters:
// index - the index of the child tab to return, use negative
// numbers to index from the end (-1 is the last child)
getChild: function(index){
if ( index < 0 )
getChild: function(index) {
if (index < 0)
index = this._children.length + index;
if ( index >= this._children.length || index < 0 )
if (index >= this._children.length || index < 0)
return null;
return this._children[index];
},
@ -1394,7 +1394,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: getChildren
// Returns all children.
getChildren: function(){
getChildren: function() {
return this._children;
},
@ -1407,7 +1407,7 @@ window.Group.prototype = Utils.extend(new Item(), new Subscribable(), {
// callback - the one-time callback that is fired when the next
// time a tab is added to a group; it gets passed the
// new tab
onNextNewTab: function(callback){
onNextNewTab: function(callback) {
this._nextNewTabCallback = callback;
}
});
@ -1468,10 +1468,10 @@ window.Groups = {
getBoundingBox: function Groups_getBoundingBox(els) {
var el, b;
var bounds = [iQ(el).bounds() for each (el in els)];
var left = min( [ b.left for each (b in bounds) ] );
var top = min( [ b.top for each (b in bounds) ] );
var right = max( [ b.right for each (b in bounds) ] );
var bottom = max( [ b.bottom for each (b in bounds) ] );
var left = min([ b.left for each (b in bounds) ]);
var top = min([ b.top for each (b in bounds) ]);
var right = max([ b.right for each (b in bounds) ]);
var bottom = max([ b.bottom for each (b in bounds) ]);
return new Rect(left, top, right-left, bottom-top);
},
@ -1525,7 +1525,7 @@ window.Groups = {
this._inited = true;
this.save(); // for nextID
}catch(e){
} catch(e) {
Utils.log("error in recons: "+e);
}
},
@ -1682,7 +1682,7 @@ window.Groups = {
// Given a <TabItem>, files it in the appropriate group.
newTab: function(tabItem) {
var group = this.getActiveGroup();
if ( group == null )
if (group == null)
group = this.getNewTabGroup();
if (group) group.add(tabItem);
},
@ -1725,9 +1725,9 @@ window.Groups = {
// ----------
// Function: getOrphanedTabs
// Returns an array of all tabs that aren't in a group.
getOrphanedTabs: function(){
getOrphanedTabs: function() {
var tabs = TabItems.getItems();
tabs = tabs.filter(function(tab){
tabs = tabs.filter(function(tab) {
return tab.parent == null;
});
return tabs;
@ -1738,7 +1738,7 @@ window.Groups = {
// Paramaters:
// reverse - the boolean indicates the direction to look for the next group.
// Returns the <tabItem>. If nothing is found, return null.
getNextGroupTab: function(reverse){
getNextGroupTab: function(reverse) {
var groups = Groups.groups.map(function(group) group);
var activeGroup = Groups.getActiveGroup();
var tabItem = null;

Просмотреть файл

@ -40,7 +40,7 @@
// **********
// Title: infoitems.js
(function(){
(function() {
// ##########
// Class: InfoItem
@ -114,7 +114,7 @@ window.InfoItem = function(bounds, options) {
this._inited = true;
this.save();
} catch(e){
} catch(e) {
Utils.log(e);
}
};

Просмотреть файл

@ -551,9 +551,9 @@ iQClass.prototype = {
// set css properties. So for each element to be animated, go through
// and explicitly define 'em.
let rupper = /([A-Z])/g;
this.each(function(elem){
this.each(function(elem) {
let cStyle = window.getComputedStyle(elem, null);
for (let prop in css){
for (let prop in css) {
prop = prop.replace(rupper, "-$1").toLowerCase();
iQ(elem).css(prop, cStyle.getPropertyValue(prop));
}

Просмотреть файл

@ -145,10 +145,10 @@ window.Item.prototype = {
// Parameters:
// container - the outermost DOM element that describes this item onscreen.
_init: function(container) {
Utils.assert( 'Subclass must implement the Subscribable interface',
Utils.assert('Subclass must implement the Subscribable interface',
typeof(this.addSubscriber) == 'function' &&
typeof(this.removeSubscriber) == 'function' &&
typeof(this._sendToSubscribers) == 'function' );
typeof(this._sendToSubscribers) == 'function');
Utils.assert('container must be a DOM element', Utils.isDOMElement(container));
Utils.assert('Subclass must provide setBounds', typeof(this.setBounds) == 'function');
Utils.assert('Subclass must provide setZ', typeof(this.setZ) == 'function');
@ -189,8 +189,8 @@ window.Item.prototype = {
// ___ drop
this.dropOptions = {
over: function(){},
out: function(){
over: function() {},
out: function() {
var group = drag.info.item.parent;
if (group) {
group.remove(drag.info.$el, {dontClose: true});
@ -198,7 +198,7 @@ window.Item.prototype = {
iQ(this.container).removeClass("acceptsDrop");
},
drop: function(event){
drop: function(event) {
iQ(this.container).removeClass("acceptsDrop");
},
// Function: dropAcceptFunction
@ -216,14 +216,14 @@ window.Item.prototype = {
aspectRatio: self.keepProportional,
minWidth: 90,
minHeight: 90,
start: function(e,ui){
start: function(e,ui) {
resizeInfo = new Drag(this, e, true); // true = isResizing
},
resize: function(e,ui){
resize: function(e,ui) {
// TODO: maybe the stationaryCorner should be topright for rtl langs?
resizeInfo.snap('topleft', false, self.keepProportional);
},
stop: function(){
stop: function() {
self.setUserSize();
self.pushAway();
resizeInfo.stop();
@ -320,7 +320,7 @@ window.Item.prototype = {
// Function: pushAway
// Pushes all other items away so none overlap this Item.
pushAway: function() {
var buffer = Math.floor( Items.defaultGutter / 2 );
var buffer = Math.floor(Items.defaultGutter / 2);
var items = Items.getTopLevelItems();
// setup each Item's pushAwayData attribute:
@ -439,7 +439,7 @@ window.Item.prototype = {
var pusher = data.pusher;
if (pusher) {
var newPosStep = new Point( posStep.x + posStep2.x, posStep.y + posStep2.y );
var newPosStep = new Point(posStep.x + posStep2.x, posStep.y + posStep2.y);
apply(pusher, newPosStep, posStep2, sizeStep);
}
}
@ -854,7 +854,7 @@ window.Items = {
// ----------
// Function: getPageBounds
// Returns a <Rect> defining the area of the page <Item>s should stay within.
getPageBounds: function( dontCountNewTabGroup ) {
getPageBounds: function(dontCountNewTabGroup) {
var bottom = dontCountNewTabGroup ? 0 : TabItems.tabHeight + Items.defaultGutter;
var width = Math.max(100, window.innerWidth);
var height = Math.max(100, window.innerHeight - bottom);
@ -864,7 +864,7 @@ window.Items = {
// ----------
// Function: getSafeWindowBounds
// Returns the bounds within which it is safe to place all non-stationary <Item>s.
getSafeWindowBounds: function( dontCountNewTabGroup ) {
getSafeWindowBounds: function(dontCountNewTabGroup) {
// the safe bounds that would keep it "in the window"
var gutter = Items.defaultGutter;
var newTabGroupBounds = Groups.getBoundsForNewTabGroup();
@ -873,10 +873,10 @@ window.Items = {
// TODO: set top gutter separately, elsewhere.
var topGutter = 5;
if (dontCountNewTabGroup)
return new Rect( gutter, topGutter,
window.innerWidth - 2 * gutter, window.innerHeight - gutter - topGutter );
return new Rect( gutter, topGutter,
window.innerWidth - 2 * gutter, newTabGroupBounds.top - gutter - topGutter );
return new Rect(gutter, topGutter,
window.innerWidth - 2 * gutter, window.innerHeight - gutter - topGutter);
return new Rect(gutter, topGutter,
window.innerWidth - 2 * gutter, newTabGroupBounds.top - gutter - topGutter);
},

Просмотреть файл

@ -162,7 +162,7 @@ Rect.prototype = {
//
// Paramaters
// - A <Rect>
contains: function(rect){
contains: function(rect) {
return(rect.left > this.left
&& rect.right < this.right
&& rect.top > this.top
@ -245,7 +245,7 @@ Rect.prototype = {
// ----------
// Function: union
// Returns a new <Rect> with the union of this rectangle and the given <Rect>.
union: function(a){
union: function(a) {
var newLeft = Math.min(a.left, this.left);
var newTop = Math.min(a.top, this.top);
var newWidth = Math.max(a.right, this.right) - newLeft;
@ -344,7 +344,7 @@ Range.prototype = {
// little graph. It goes from near 0 at x=0 to near 1 at x=1
// smoothly and beautifully.
// http://www.wolframalpha.com/input/?i=.5+%2B+.5+*+tanh%28%284+*+x%29+-+2%29
function tanh(x){
function tanh(x) {
var e = Math.exp(x);
return (e - 1/e) / (e + 1/e);
}

Просмотреть файл

@ -37,7 +37,7 @@
// **********
// Title: profile.js
(function(){
(function() {
// ##########
// Class: Profile
// A simple profiling helper.
@ -70,7 +70,7 @@ window.Profile = {
return val.apply(obj, arguments);
} finally {
let diff = Date.now() - start;
if(diff >= self.cutoff && !self.silent)
if (diff >= self.cutoff && !self.silent)
Utils.log("profile: " + name + "." + key + " = " + diff + "ms");
}
};
@ -83,7 +83,7 @@ window.Profile = {
checkpoint: function(label) {
var now = Date.now();
if(label && !this.silent)
if (label && !this.silent)
Utils.log("profile checkpoint: " + label + " = " + (now - this._time) + "ms");
this._time = now;

Просмотреть файл

@ -101,22 +101,22 @@ window.TabItem = function(tab) {
// ___ drag/drop
// override dropOptions with custom tabitem methods
// This is mostly to support the phantom groups.
this.dropOptions.drop = function(e){
this.dropOptions.drop = function(e) {
var $target = iQ(this.container);
this.isDropTarget = false;
var phantom = $target.data("phantomGroup");
var group = drag.info.item.parent;
if ( group ) {
group.add( drag.info.$el );
if (group) {
group.add(drag.info.$el);
} else {
phantom.removeClass("phantom acceptsDrop");
new Group([$target, drag.info.$el], {container:phantom, bounds:phantom.bounds()});
}
};
this.dropOptions.over = function(e){
this.dropOptions.over = function(e) {
var $target = iQ(this.container);
this.isDropTarget = true;
@ -125,7 +125,7 @@ window.TabItem = function(tab) {
var phantomMargin = 40;
var groupBounds = this.getBoundsWithTitle();
groupBounds.inset( -phantomMargin, -phantomMargin );
groupBounds.inset(-phantomMargin, -phantomMargin);
iQ(".phantom").remove();
var phantom = iQ("<div>")
@ -154,11 +154,11 @@ window.TabItem = function(tab) {
$target.data("phantomGroup", phantom);
};
this.dropOptions.out = function(e){
this.dropOptions.out = function(e) {
this.isDropTarget = false;
var phantom = iQ(this.container).data("phantomGroup");
if (phantom) {
phantom.fadeOut(function(){
phantom.fadeOut(function() {
iQ(this).remove();
});
}
@ -302,7 +302,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
var data = this.getStorageData(saveImageData);
if (TabItems.storageSanity(data))
Storage.saveTab(this.tab, data);
}catch(e){
} catch(e) {
Utils.log("Error in saving tab value: "+e);
}
},
@ -365,7 +365,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// If this is a brand new tab don't animate it in from
// a random location (i.e., from [0,0]). Instead, just
// have it appear where it should be.
if (immediately || (!this._hasBeenDrawn) ) {
if (immediately || (!this._hasBeenDrawn)) {
/* $container.stop(true, true); */
$container.css(css);
} else {
@ -381,7 +381,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
}
if (css.fontSize && !this.inStack()) {
if (css.fontSize < fontSizeRange.min )
if (css.fontSize < fontSizeRange.min)
$title.fadeOut();//.dequeue();
else
$title.fadeIn();//.dequeue();
@ -400,7 +400,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
widthRange = new Range(60, 70);
proportion = widthRange.proportion(css.width); // between 0 and 1
$close.show().css({opacity:proportion});
if ( proportion <= .1 )
if (proportion <= .1)
$close.hide()
}
@ -437,13 +437,13 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
var b = this.getBounds();
var $container = iQ(this.container);
var $title = iQ('.tab-title', $container);
return new Rect( b.left, b.top, b.width, b.height + $title.height() );
return new Rect(b.left, b.top, b.width, b.height + $title.height());
},
// ----------
// Function: inStack
// Returns true if this item is in a stacked group.
inStack: function(){
inStack: function() {
return iQ(this.container).hasClass("stacked");
},
@ -484,7 +484,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Function: setResizable
// If value is true, makes this item resizable, otherwise non-resizable.
// Shows/hides a visible resize handle as appropriate.
setResizable: function(value){
setResizable: function(value) {
var $resizer = iQ('.expander', this.container);
this.resizeOptions.minWidth = TabItems.minTabWidth;
@ -502,7 +502,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: makeActive
// Updates this item to visually indicate that it's active.
makeActive: function(){
makeActive: function() {
iQ(this.container).find("canvas").addClass("focus");
iQ(this.container).find("img.cached-thumb").addClass("focus");
@ -511,7 +511,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// ----------
// Function: makeDeactive
// Updates this item to visually indicate that it's not active.
makeDeactive: function(){
makeDeactive: function() {
iQ(this.container).find("canvas").removeClass("focus");
iQ(this.container).find("img.cached-thumb").removeClass("focus");
},
@ -539,7 +539,7 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
var tab = this.tab;
function onZoomDone(){
function onZoomDone() {
TabItems.resumePainting();
// If it's not focused, the onFocus lsitener would handle it.
if (gBrowser.selectedTab == tab) {
@ -559,14 +559,14 @@ window.TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// If the tab is in a group set then set the active
// group to the tab's parent.
if ( self.parent ){
if (self.parent) {
var gID = self.parent.id;
var group = Groups.group(gID);
Groups.setActiveGroup( group );
group.setActiveTab( self );
Groups.setActiveGroup(group);
group.setActiveTab(self);
}
else
Groups.setActiveGroup( null );
Groups.setActiveGroup(null);
if (childHitResult.callback)
childHitResult.callback();
@ -716,7 +716,7 @@ window.TabItems = {
});
// When a tab is closed, unlink.
Tabs.onClose( function(){
Tabs.onClose(function() {
if (this.ownerDocument.defaultView != gWindow)
return;
@ -727,7 +727,7 @@ window.TabItems = {
});
// For each tab, create the link.
Tabs.allTabs.forEach(function(tab){
Tabs.allTabs.forEach(function(tab) {
if (tab.ownerDocument.defaultView != gWindow)
return;
@ -741,7 +741,7 @@ window.TabItems = {
// ----------
// Function: update
// Takes in a xul:tab.
update: function(tab){
update: function(tab) {
try {
Utils.assertThrow("must already be linked", tab.tabItem);
@ -804,7 +804,7 @@ window.TabItems = {
// ----------
// Function: unlink
// Takes in a xul:tab.
unlink: function(tab){
unlink: function(tab) {
try {
Utils.assertThrow("should already be linked", tab.tabItem);
@ -949,7 +949,7 @@ window.TabItems = {
item.reconnected = item.tab.linkedBrowser.currentURI.spec != 'about:blank';
item.save();
}catch(e){
} catch(e) {
Utils.log(e);
}
@ -961,14 +961,14 @@ window.TabItems = {
// Class: TabCanvas
// Takes care of the actual canvas for the tab thumbnail
// Does not need to be accessed from outside of tabitems.js
var TabCanvas = function(tab, canvas){
var TabCanvas = function(tab, canvas) {
this.init(tab, canvas);
};
TabCanvas.prototype = {
// ----------
// Function: init
init: function(tab, canvas){
init: function(tab, canvas) {
this.tab = tab;
this.canvas = canvas;
@ -981,7 +981,7 @@ TabCanvas.prototype = {
// ----------
// Function: paint
paint: function(evt){
paint: function(evt) {
var ctx = this.canvas.getContext("2d");
var w = this.canvas.width;
@ -1002,8 +1002,8 @@ TabCanvas.prototype = {
ctx.save();
ctx.scale(scaler, scaler);
try{
ctx.drawWindow( fromWin, fromWin.scrollX, fromWin.scrollY, w/scaler, h/scaler, "#fff" );
} catch(e){
ctx.drawWindow(fromWin, fromWin.scrollX, fromWin.scrollY, w/scaler, h/scaler, "#fff");
} catch(e) {
Utils.error('paint', e);
}

Просмотреть файл

@ -148,10 +148,10 @@ Trench.prototype = {
this.minRange = minRange;
// set the appropriate bounds as a rect.
if ( this.xory == "x" ) // vertical
this.rect = new Rect ( this.position - this.radius, this.range.min, 2 * this.radius, this.range.extent );
if (this.xory == "x") // vertical
this.rect = new Rect(this.position - this.radius, this.range.min, 2 * this.radius, this.range.extent);
else // horizontal
this.rect = new Rect ( this.range.min, this.position - this.radius, this.range.extent, 2 * this.radius );
this.rect = new Rect(this.range.min, this.position - this.radius, this.range.extent, 2 * this.radius);
this.show(); // DEBUG
},
@ -166,12 +166,12 @@ Trench.prototype = {
if (!Utils.isRange(activeRange))
return false;
this.activeRange = activeRange;
if ( this.xory == "x" ) { // horizontal
this.activeRect = new Rect( this.position - this.radius, this.activeRange.min, 2 * this.radius, this.activeRange.extent );
this.guideRect = new Rect( this.position, this.activeRange.min, 0, this.activeRange.extent );
if (this.xory == "x") { // horizontal
this.activeRect = new Rect(this.position - this.radius, this.activeRange.min, 2 * this.radius, this.activeRange.extent);
this.guideRect = new Rect(this.position, this.activeRange.min, 0, this.activeRange.extent);
} else { // vertical
this.activeRect = new Rect( this.activeRange.min, this.position - this.radius, this.activeRange.extent, 2 * this.radius );
this.guideRect = new Rect( this.activeRange.min, this.position, this.activeRange.extent, 0 );
this.activeRect = new Rect(this.activeRange.min, this.position - this.radius, this.activeRange.extent, 2 * this.radius);
this.guideRect = new Rect(this.activeRange.min, this.position, this.activeRange.extent, 0);
}
},
@ -227,7 +227,6 @@ Trench.prototype = {
// opacity. If <active> is false, the entire trench will be
// very translucent.
show: function Trench_show() { // DEBUG
if (this.active && this.showGuide) {
if (!this.dom.guideTrench)
this.dom.guideTrench = iQ("<div/>").addClass('guideTrench').css({id: 'guideTrench'+this.id});
@ -242,7 +241,7 @@ Trench.prototype = {
}
if (!Trenches.showDebug) {
this.hide( true ); // true for dontHideGuides
this.hide(true); // true for dontHideGuides
return;
}
@ -274,7 +273,7 @@ Trench.prototype = {
//----------
// Function: hide
// Hide the trench.
hide: function Trench_hide( dontHideGuides ) {
hide: function Trench_hide(dontHideGuides) {
if (this.dom.visibleTrench)
this.dom.visibleTrench.remove();
if (this.dom.activeVisibleTrench)
@ -429,7 +428,7 @@ Trench.prototype = {
var groups = Groups.groups;
var trench = this;
groups.forEach(function( group ) {
groups.forEach(function(group) {
if (group.isDragging) // floating groups don't block trenches
return;
if (group.isNewTabsGroup())
@ -540,7 +539,7 @@ var Trenches = {
if (!Array.isArray(ids))
ids = [ids];
var self = this;
ids.forEach(function(id){
ids.forEach(function(id) {
self.trenches[id].hide();
delete self.trenches[id];
});
@ -661,7 +660,7 @@ var Trenches = {
// Function: show
// <Trench.show> all <Trench>es.
show: function Trenches_show() {
this.trenches.forEach(function(t){
this.trenches.forEach(function(t) {
t.show();
});
},

Просмотреть файл

@ -149,8 +149,8 @@ var UIManager = {
// When you click on the background/empty part of TabView,
// we create a new group.
iQ(gTabViewFrame.contentDocument).mousedown(function(e){
if ( e.originalTarget.id == "content" )
iQ(gTabViewFrame.contentDocument).mousedown(function(e) {
if (e.originalTarget.id == "content")
self._createGroupOnDrag(e)
});
@ -396,7 +396,7 @@ var UIManager = {
_addTabActionHandlers: function() {
var self = this;
Tabs.onClose(function(){
Tabs.onClose(function() {
if (this.ownerDocument.defaultView != gWindow)
return;
@ -588,7 +588,7 @@ var UIManager = {
// ----------
// Function: _setTabViewFrameKeyHandlers
// Sets up the key handlers for navigating between tabs within the TabView UI.
_setTabViewFrameKeyHandlers: function(){
_setTabViewFrameKeyHandlers: function() {
var self = this;
iQ(window).keyup(function(event) {
@ -608,7 +608,7 @@ var UIManager = {
return;
}
function getClosestTabBy(norm){
function getClosestTabBy(norm) {
var centers =
[[item.bounds.center(), item] for each(item in TabItems.getItems())];
var myCenter = self.getActiveTab().bounds.center();
@ -617,7 +617,7 @@ var UIManager = {
.sort(function(a,b){
return myCenter.distance(a[0]) - myCenter.distance(b[0]);
});
if ( matches.length > 0 )
if (matches.length > 0)
return matches[0][1];
return null;
}
@ -703,7 +703,7 @@ var UIManager = {
// Function: _createGroupOnDrag
// Called in response to a mousedown in empty space in the TabView UI;
// creates a new group based on the user's drag.
_createGroupOnDrag: function(e){
_createGroupOnDrag: function(e) {
const minSize = 60;
const minMinSize = 15;
@ -731,7 +731,7 @@ var UIManager = {
setZ: function FauxItem_setZ(z) {
this.container.css("z-index", z);
},
setOpacity: function FauxItem_setOpacity( opacity ) {
setOpacity: function FauxItem_setOpacity(opacity) {
this.container.css("opacity", opacity);
},
// we don't need to pushAway the phantom item at the end, because
@ -742,7 +742,7 @@ var UIManager = {
var dragOutInfo = new Drag(item, e, true); // true = isResizing
function updateSize(e){
function updateSize(e) {
var box = new Rect();
box.left = Math.min(startPos.x, e.clientX);
box.right = Math.max(startPos.x, e.clientX);
@ -866,8 +866,8 @@ var UIManager = {
var wScale;
var hScale;
if ( Math.abs(newPageBounds.width - this._pageBounds.width)
> Math.abs(newPageBounds.height - this._pageBounds.height) ) {
if (Math.abs(newPageBounds.width - this._pageBounds.width)
> Math.abs(newPageBounds.height - this._pageBounds.height)) {
wScale = newPageBounds.width / this._pageBounds.width;
hScale = newPageBounds.height / itemBounds.height;
} else {
@ -968,10 +968,10 @@ var UIManager = {
var count = commands.length;
var a;
for (a = 0; a < count; a++) {
commands[a].element = ( iQ("<option>")
commands[a].element = (iQ("<option>")
.val(a)
.html(commands[a].name)
.appendTo($select) )[0];
.appendTo($select))[0];
}
} catch(e) {
Utils.log(e);
@ -1073,7 +1073,7 @@ var UIManager = {
leftovers.push(set[0]);
}
if(leftovers.length)
if (leftovers.length)
putInGroup(leftovers, "mixed");
Groups.arrange();