Skip to content

Commit

Permalink
Bring back jslint space validation
Browse files Browse the repository at this point in the history
  • Loading branch information
daviferreira committed Jan 31, 2015
1 parent 91548b2 commit 5099b96
Show file tree
Hide file tree
Showing 11 changed files with 328 additions and 346 deletions.
7 changes: 3 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ module.exports = function (grunt) {
browser: true,
unparam: true,
todo: true,
debug: true,
white: true
debug: true
}
}
};
Expand Down Expand Up @@ -98,7 +97,7 @@ module.exports = function (grunt) {
gruntConfig.cssmin = {
main: {
options: {
noAdvanced: true
noAdvanced: true
},

expand: true,
Expand All @@ -109,7 +108,7 @@ module.exports = function (grunt) {
},
themes: {
options: {
noAdvanced: true
noAdvanced: true
},

expand: true,
Expand Down
295 changes: 143 additions & 152 deletions dist/js/medium-editor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion spec/activate.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Activate/Deactivate TestCase', function () {
var editor, triggerEvents;

editor = new MediumEditor('.editor', {delay: 5});
triggerEvents = function() {
triggerEvents = function () {
fireEvent(window, 'resize', null, false);
fireEvent(document.body, 'click', null, false, document.body);
fireEvent(document.body, 'blur', null, false);
Expand Down
2 changes: 1 addition & 1 deletion spec/delay.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('Delay TestCase', function () {
tearDown(this.el);
});

it('should call function after delay', function() {
it('should call function after delay', function () {
var editor, spy;

editor = new MediumEditor('.editor', {delay: 100});
Expand Down
10 changes: 5 additions & 5 deletions spec/events.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ describe('Events TestCase', function () {
tearDown(this.el);
});

describe('On', function() {
it('should bind listener', function() {
describe('On', function () {
it('should bind listener', function () {
var el, editor, spy;
el = document.createElement('div');
spy = jasmine.createSpy('handler');
Expand All @@ -31,8 +31,8 @@ describe('Events TestCase', function () {
});
});

describe('Off', function() {
it('should unbind listener', function() {
describe('Off', function () {
it('should unbind listener', function () {
var el, editor, spy;
el = document.createElement('div');
spy = jasmine.createSpy('handler');
Expand All @@ -44,4 +44,4 @@ describe('Events TestCase', function () {
expect(spy).not.toHaveBeenCalled();
});
});
});
});
8 changes: 4 additions & 4 deletions spec/exploits.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ describe('Exploits', function () {
// mock event with clipboardData API
// test requires creating a function, so can't loop or jslint balks
evt = {
preventDefault: function() {
preventDefault: function () {
return;
},
clipboardData: {
getData: function(type) {
getData: function (type) {
// do we need to return different results for the different types? text/plain, text/html
return test.paste;
}
Expand Down Expand Up @@ -77,11 +77,11 @@ describe('Exploits', function () {
// mock event with clipboardData API
// test requires creating a function, so can't loop or jslint balks
evt = {
preventDefault: function() {
preventDefault: function () {
return;
},
clipboardData: {
getData: function(type) {
getData: function (type) {
// do we need to return different results for the different types? text/plain, text/html
return test.paste;
}
Expand Down
25 changes: 13 additions & 12 deletions spec/header-tags.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ describe('Protect Header Tags TestCase', function () {

// place cursor at begining of header
var editor = new MediumEditor('.editor'),
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();

range.setStart(el, 0);
range.collapse(true);
sel.removeAllRanges();
Expand All @@ -47,9 +48,9 @@ describe('Protect Header Tags TestCase', function () {

// place cursor at begining of header
var editor = new MediumEditor('.editor'),
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();
range.setStart(el, 0);
range.collapse(true);
sel.removeAllRanges();
Expand All @@ -68,24 +69,24 @@ describe('Protect Header Tags TestCase', function () {

// place cursor at begining of header
var editor = new MediumEditor('.editor'),
original_html = document.getElementById("editor").innerHTML,
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();
originalHTML = document.getElementById("editor").innerHTML,
el = document.getElementById("header"),
range = document.createRange(),
sel = window.getSelection();
range.setStart(el, 0);
range.collapse(true);
sel.removeAllRanges();
sel.addRange(range);

// hit backspace
editor.onBlockModifier( { which: 8, preventDefault: function(){ } });
editor.onBlockModifier({ which: 8, preventDefault: function () { } });

el = document.getElementById("header");
expect(el).toBeDefined();
expect(el.tagName).toBe('H2');

el = document.getElementById("editor");
expect(el.innerHTML).not.toBe(original_html);
expect(el.innerHTML).not.toBe(originalHTML);

});

Expand Down
2 changes: 1 addition & 1 deletion spec/init.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Initialization TestCase', function () {
expect(editor.elements).toEqual([element]);
});

it('should always initalize elements as an Array', function() {
it('should always initalize elements as an Array', function () {
var nodeList = document.querySelectorAll('span'),
node = document.querySelector('span'),
editor = new MediumEditor(nodeList);
Expand Down
14 changes: 7 additions & 7 deletions spec/selection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ describe('Selection TestCase', function () {
});

it('should update button states when updateOnEmptySelection is true and the selection is empty', function () {
spyOn(MediumEditor.prototype, 'setToolbarButtonStates').and.callThrough();
spyOn(MediumEditor.prototype, 'setToolbarButtonStates').and.callThrough();

var editor = new MediumEditor('.editor', {
updateOnEmptySelection: true
});
var editor = new MediumEditor('.editor', {
updateOnEmptySelection: true
});

selectElementContents(this.el, { collapse: 'toStart' });
editor.checkSelection();
selectElementContents(this.el, { collapse: 'toStart' });
editor.checkSelection();

expect(editor.setToolbarButtonStates).toHaveBeenCalled();
expect(editor.setToolbarButtonStates).toHaveBeenCalled();
});
});
});
Expand Down
14 changes: 7 additions & 7 deletions spec/toolbar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe('Toolbar TestCase', function () {
it('should call the onShowToolbar callback if set', function () {
this.el.innerHTML = 'specOnShowToolbarTest';
var editor = new MediumEditor('.editor');
editor.onShowToolbar = function() {};
editor.onShowToolbar = function () {};
spyOn(editor, 'onShowToolbar').and.callThrough();
jasmine.clock().install();
try {
Expand All @@ -54,15 +54,15 @@ describe('Toolbar TestCase', function () {
}
});

it('should not create an anchor form element if disableAnchorForm is set to true', function() {
it('should not create an anchor form element if disableAnchorForm is set to true', function () {
expect(document.querySelectorAll('.medium-editor-toolbar-form-anchor').length).toBe(0);
var editor = new MediumEditor('.editor', {
disableAnchorForm: true
});
expect(editor.toolbar.querySelectorAll('.medium-editor-toolbar-form-anchor').length).toBe(0);
});

it('should not call MediumEditor\'s toolbarFormAnchor method if disableAnchorForm is set to true', function() {
it('should not call MediumEditor\'s toolbarFormAnchor method if disableAnchorForm is set to true', function () {
spyOn(MediumEditor.prototype, 'toolbarFormAnchor').and.callThrough();
var editor = new MediumEditor('.editor', {
disableAnchorForm: true
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Toolbar TestCase', function () {
expect(editor.toolbar.classList.contains('medium-editor-toolbar-active')).toBe(false);
});

it('should enable bold button in toolbar when bold text is selected', function() {
it('should enable bold button in toolbar when bold text is selected', function () {
var editor = null;

this.el.innerHTML = 'lorem ipsum <b><div id="cef_el">dolor</div></b>';
Expand All @@ -158,7 +158,7 @@ describe('Toolbar TestCase', function () {
expect(editor.toolbar.querySelector('button[data-action="bold"]').classList.contains('medium-editor-button-active')).toBe(true);
});

it('should not activate buttons in toolbar when stopSelectionUpdates has been called, but should activate buttons after startSelectionUpdates is called', function() {
it('should not activate buttons in toolbar when stopSelectionUpdates has been called, but should activate buttons after startSelectionUpdates is called', function () {
var editor = null;

this.el.innerHTML = 'lorem ipsum <b><div id="cef_el">dolor</div></b>';
Expand All @@ -182,7 +182,7 @@ describe('Toolbar TestCase', function () {
it('should call onHideToolbar when toolbar is hidden', function () {
var editor = new MediumEditor('.editor');
editor.toolbar.classList.add('medium-editor-toolbar-active');
editor.onHideToolbar = function() {};
editor.onHideToolbar = function () {};

spyOn(editor, 'onHideToolbar').and.callThrough();

Expand All @@ -192,7 +192,7 @@ describe('Toolbar TestCase', function () {
expect(editor.onHideToolbar).toHaveBeenCalled();
});

it('should hide the toolbar for one medium-editor instance when another medium-editor instance shows its toolbar', function() {
it('should hide the toolbar for one medium-editor instance when another medium-editor instance shows its toolbar', function () {
var editorOne,
editorTwo;

Expand Down
Loading

0 comments on commit 5099b96

Please sign in to comment.