Skip to content

Commit c07d977

Browse files
committed
Harmonize spaces after keywords
Always use a space after a keyword preceding a ( or {, except for anonymous functions.
1 parent 5270e89 commit c07d977

File tree

8 files changed

+46
-46
lines changed

8 files changed

+46
-46
lines changed

Gruntfile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ var folderMount = function folderMount(connect, point) {
77
return connect.static(path.resolve(point));
88
};
99

10-
module.exports = function (grunt) {
10+
module.exports = function(grunt) {
1111

1212
// load all grunt tasks
1313
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
@@ -50,7 +50,7 @@ module.exports = function (grunt) {
5050
options: {
5151
port: 9001,
5252
hostname: '0.0.0.0',
53-
middleware: function (connect, options) {
53+
middleware: function(connect, options) {
5454
return [
5555
folderMount(connect, options.base)
5656
];

src/behavior.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ var behavior = (function() {
5555
var br = document.createElement('br');
5656
cursor.insertBefore(br);
5757

58-
if(atEnd) {
58+
if (atEnd) {
5959
log('at the end');
6060

6161
var noWidthSpace = document.createTextNode('\u200B');
@@ -76,9 +76,9 @@ var behavior = (function() {
7676
log('Default insert ' + direction + ' behavior');
7777
var parent = element.parentNode;
7878
var newElement = element.cloneNode(false);
79-
if(newElement.id) newElement.removeAttribute('id');
79+
if (newElement.id) newElement.removeAttribute('id');
8080

81-
switch(direction) {
81+
switch (direction) {
8282
case 'before':
8383
parent.insertBefore(newElement, element);
8484
element.focus();
@@ -104,7 +104,7 @@ var behavior = (function() {
104104
log('Default merge ' + direction + ' behavior');
105105
var container, merger, fragment, chunks, i, newChild, range;
106106

107-
switch(direction) {
107+
switch (direction) {
108108
case 'before':
109109
container = block.previous(element);
110110
merger = element;
@@ -115,18 +115,18 @@ var behavior = (function() {
115115
break;
116116
}
117117

118-
if(!(container && merger))
118+
if (!(container && merger))
119119
return;
120120

121-
if(container.childNodes.length > 0)
121+
if (container.childNodes.length > 0)
122122
cursor.moveAtTextEnd(container);
123123
else
124124
cursor.moveAtBeginning(container);
125125
cursor.setSelection();
126126

127127
fragment = document.createDocumentFragment();
128128
chunks = merger.childNodes;
129-
for(i = 0; i < chunks.length; i++) {
129+
for (i = 0; i < chunks.length; i++) {
130130
fragment.appendChild(chunks[i].cloneNode(true));
131131
}
132132
newChild = container.appendChild(fragment);
@@ -149,7 +149,7 @@ var behavior = (function() {
149149

150150
var next, previous;
151151

152-
switch(direction) {
152+
switch (direction) {
153153
case 'before':
154154
previous = block.previous(element);
155155
if (previous) {
@@ -175,11 +175,11 @@ var behavior = (function() {
175175
log('Default clipboard behavior');
176176
var pasteHolder, sel;
177177

178-
if(action !== 'paste') return;
178+
if (action !== 'paste') return;
179179

180180
element.setAttribute(config.pastingAttribute, true);
181181

182-
if(cursor.isSelection) {
182+
if (cursor.isSelection) {
183183
cursor = cursor.deleteContent();
184184
}
185185

src/block.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ var block = (function() {
22
return {
33
next: function(element) {
44
var next = element.nextElementSibling;
5-
if(next && next.getAttribute('contenteditable')) return next;
5+
if (next && next.getAttribute('contenteditable')) return next;
66
return null;
77
},
88

99
previous: function(element) {
1010
var previous = element.previousElementSibling;
11-
if(previous && previous.getAttribute('contenteditable')) return previous;
11+
if (previous && previous.getAttribute('contenteditable')) return previous;
1212
return null;
1313
}
1414
};

src/content.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ var content = (function() {
2121

2222
for (i = 0; i < element.childNodes.length; i++) {
2323
node = element.childNodes[i];
24-
if(!node) continue;
24+
if (!node) continue;
2525

2626
// skip empty tags, so they'll get removed
27-
if(node.nodeName !== 'BR' && !node.textContent) continue;
27+
if (node.nodeName !== 'BR' && !node.textContent) continue;
2828

29-
if(node.nodeType === 1 && node.nodeName !== 'BR') {
29+
if (node.nodeType === 1 && node.nodeName !== 'BR') {
3030
sibling = node;
31-
while((sibling = sibling.nextSibling) !== null) {
32-
if(!parser.isSameNode(sibling, node))
31+
while ((sibling = sibling.nextSibling) !== null) {
32+
if (!parser.isSameNode(sibling, node))
3333
break;
3434

35-
for(j = 0; j < sibling.childNodes.length; j++) {
35+
for (j = 0; j < sibling.childNodes.length; j++) {
3636
node.appendChild(sibling.childNodes[j].cloneNode(true));
3737
}
3838

@@ -71,9 +71,9 @@ var content = (function() {
7171
normalizeSpaces: function(element) {
7272
var nonBreakingSpace = '\u00A0';
7373

74-
if(!element) return;
74+
if (!element) return;
7575

76-
if(element.nodeType === 3) {
76+
if (element.nodeType === 3) {
7777
element.nodeValue = element.nodeValue.replace(/^(\s)/, nonBreakingSpace).replace(/(\s)$/, nonBreakingSpace);
7878
}
7979
else {
@@ -207,7 +207,7 @@ var content = (function() {
207207
$(elem)[0] :
208208
elem;
209209

210-
if(this.isWrappable(range)) {
210+
if (this.isWrappable(range)) {
211211
var a = range.surroundContents(elem);
212212
} else {
213213
console.log('content.wrap(): can not surround range');
@@ -285,7 +285,7 @@ var content = (function() {
285285
return node.nodeValue.search(charRegexp) >= 0;
286286
});
287287

288-
for(var i = 0; i < textNodes.length; i++) {
288+
for (var i = 0; i < textNodes.length; i++) {
289289
var node = textNodes[i];
290290
node.nodeValue = node.nodeValue.replace(charRegexp, '');
291291
}

src/cursor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,13 +174,13 @@ var Cursor = (function() {
174174
},
175175

176176
equals: function(cursor) {
177-
if(!cursor) return false;
177+
if (!cursor) return false;
178178

179-
if(!cursor.host) return false;
180-
if(!cursor.host.isEqualNode(this.host)) return false;
179+
if (!cursor.host) return false;
180+
if (!cursor.host.isEqualNode(this.host)) return false;
181181

182-
if(!cursor.range) return false;
183-
if(!cursor.range.equals(this.range)) return false;
182+
if (!cursor.range) return false;
183+
if (!cursor.range.equals(this.range)) return false;
184184

185185
return true;
186186
}

src/dispatcher.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ var dispatcher = (function() {
2424
*/
2525
var setupElementEvents = function($document, notifier) {
2626
$document.on('focus.editable', editableSelector, function(event) {
27-
if(this.getAttribute(config.pastingAttribute)) return;
27+
if (this.getAttribute(config.pastingAttribute)) return;
2828
notifier('focus', this);
2929
}).on('blur.editable', editableSelector, function(event) {
30-
if(this.getAttribute(config.pastingAttribute)) return;
30+
if (this.getAttribute(config.pastingAttribute)) return;
3131
notifier('blur', this);
3232
}).on('copy.editable', editableSelector, function(event) {
3333
log('Copy');
@@ -111,7 +111,7 @@ var dispatcher = (function() {
111111
var range = selectionWatcher.getFreshRange();
112112
if (range.isCursor) {
113113
var cursor = range.getCursor();
114-
if(cursor.isAtTextEnd()) {
114+
if (cursor.isAtTextEnd()) {
115115
event.preventDefault();
116116
event.stopPropagation();
117117
notifier('merge', this, 'after', cursor);
@@ -127,7 +127,7 @@ var dispatcher = (function() {
127127

128128
if (cursor.isAtTextEnd()) {
129129
notifier('insert', this, 'after', cursor);
130-
} else if(cursor.isAtBeginning()) {
130+
} else if (cursor.isAtBeginning()) {
131131
notifier('insert', this, 'before', cursor);
132132
} else {
133133
notifier('split', this, cursor.before(), cursor.after(), cursor);
@@ -241,7 +241,7 @@ var dispatcher = (function() {
241241
if (eventListeners === undefined) return;
242242

243243
for (var i=0, len=eventListeners.length; i < len; i++) {
244-
if(eventListeners[i].apply(
244+
if (eventListeners[i].apply(
245245
Editable,
246246
Array.prototype.slice.call(arguments).splice(1)
247247
) === false)
@@ -263,7 +263,7 @@ var dispatcher = (function() {
263263
listeners = {};
264264
// TODO check the config.event object to prevent
265265
// registering invalid handlers
266-
for(eventType in config.event) {
266+
for (eventType in config.event) {
267267
this.addListener(eventType, config.event[eventType]);
268268
}
269269

src/keyboard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var keyboard = (function() {
3232
if (eventListeners === undefined) return;
3333

3434
for (var i=0, len=eventListeners.length; i < len; i++) {
35-
if(eventListeners[i].apply(
35+
if (eventListeners[i].apply(
3636
context,
3737
Array.prototype.slice.call(arguments).splice(2)
3838
) === false)

src/parser.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -169,22 +169,22 @@ var parser = (function() {
169169
}
170170
},
171171

172-
isStartOffset: function (container, offset) {
172+
isStartOffset: function(container, offset) {
173173
if (container.nodeType === 3) {
174174
return offset === 0;
175175
} else {
176-
if(container.childNodes.length === 0)
176+
if (container.childNodes.length === 0)
177177
return true;
178178
else
179179
return container.childNodes[offset] === container.firstChild;
180180
}
181181
},
182182

183-
isEndOffset: function (container, offset) {
183+
isEndOffset: function(container, offset) {
184184
if (container.nodeType === 3) {
185185
return offset === container.length;
186186
} else {
187-
if(container.childNodes.length === 0)
187+
if (container.childNodes.length === 0)
188188
return true;
189189
else if (offset > 0)
190190
return container.childNodes[offset - 1] === container.lastChild;
@@ -210,7 +210,7 @@ var parser = (function() {
210210
}
211211
},
212212

213-
isTextEndOffset: function (container, offset) {
213+
isTextEndOffset: function(container, offset) {
214214
if (container.nodeType === 3) {
215215
var text = string.trimRight(container.nodeValue);
216216
return offset >= text.length;
@@ -225,15 +225,15 @@ var parser = (function() {
225225
isSameNode: function(target, source) {
226226
var i, len, attr;
227227

228-
if(target.nodeType !== source.nodeType)
228+
if (target.nodeType !== source.nodeType)
229229
return false;
230230

231-
if(target.nodeName !== source.nodeName)
231+
if (target.nodeName !== source.nodeName)
232232
return false;
233233

234-
for(i = 0, len = target.attributes.length; i < len; i++) {
234+
for (i = 0, len = target.attributes.length; i < len; i++) {
235235
attr = target.attributes[i];
236-
if(source.getAttribute(attr.name) !== attr.value)
236+
if (source.getAttribute(attr.name) !== attr.value)
237237
return false;
238238
}
239239

@@ -248,7 +248,7 @@ var parser = (function() {
248248
* @return {HTMLElement} THe deepest last child in the container.
249249
*/
250250
latestChild: function(container) {
251-
if(container.lastChild)
251+
if (container.lastChild)
252252
return this.latestChild(container.lastChild);
253253
else
254254
return container;

0 commit comments

Comments
 (0)