Skip to content

Commit

Permalink
Make MediumEditor global + Fix remaining Selection + Util refs
Browse files Browse the repository at this point in the history
  • Loading branch information
nmielnik committed Aug 14, 2015
1 parent 9814f99 commit 266261f
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 76 deletions.
2 changes: 1 addition & 1 deletion Gruntfile.js
Expand Up @@ -13,6 +13,7 @@ module.exports = function (grunt) {
globalConfig: globalConfig
},
srcFiles = [
'src/js/globals.js',
'src/js/util.js',
'src/js/defaults/buttons.js',
'src/js/defaults/options.js',
Expand All @@ -31,7 +32,6 @@ module.exports = function (grunt) {
'src/js/extensions/placeholder.js',
'src/js/extensions/toolbar.js',
'src/js/extensions/deprecated/image-dragging.js',
'src/js/defaults/options.js',
'src/js/defaults/extensions.js',
'src/js/core.js',
'src/js/version.js'
Expand Down
6 changes: 2 additions & 4 deletions spec/selection.spec.js
@@ -1,10 +1,9 @@
/*global describe, it, expect, spyOn,
afterEach, beforeEach, fireEvent,
jasmine, selectElementContents, setupTestHelpers,
selectElementContentsAndFire, Selection,
placeCursorInsideElement */
selectElementContentsAndFire, placeCursorInsideElement */

describe('Selection TestCase', function () {
describe('MediumEditor.selection TestCase', function () {
'use strict';

beforeEach(function () {
Expand All @@ -19,7 +18,6 @@ describe('Selection TestCase', function () {
describe('Exposure', function () {
it('is exposed on the MediumEditor ctor', function () {
expect(MediumEditor.selection).toBeTruthy();
expect(MediumEditor.selection).toEqual(Selection);
});
});

Expand Down
5 changes: 2 additions & 3 deletions spec/util.spec.js
@@ -1,7 +1,7 @@
/*global Util, describe, it, expect, spyOn,
/*global describe, it, expect, spyOn,
afterEach, beforeEach, setupTestHelpers, selectElementContents */

describe('Util', function () {
describe('MediumEditor.util', function () {
'use strict';

beforeEach(function () {
Expand All @@ -15,7 +15,6 @@ describe('Util', function () {
describe('Exposure', function () {
it('is exposed on the MediumEditor ctor', function () {
expect(MediumEditor.util).toBeTruthy();
expect(MediumEditor.util).toEqual(Util);
});

});
Expand Down
98 changes: 45 additions & 53 deletions src/js/core.js

Large diffs are not rendered by default.

4 changes: 1 addition & 3 deletions src/js/events.js
@@ -1,5 +1,3 @@
/*global Util */

var Events;

(function () {
Expand All @@ -15,7 +13,7 @@ var Events;
};

Events.prototype = {
InputEventOnContenteditableSupported: !Util.isIE,
InputEventOnContenteditableSupported: !MediumEditor.util.isIE,

// Helpers for event handling

Expand Down
8 changes: 3 additions & 5 deletions src/js/extension.js
@@ -1,11 +1,9 @@
/* global Util */

var Extension;
(function () {
'use strict';

Extension = function (options) {
Util.extend(this, options);
MediumEditor.util.extend(this, options);
};

Extension.extend = function (protoProps) {
Expand Down Expand Up @@ -49,7 +47,7 @@ var Extension;
}

// das statics (.extend comes over, so your subclass can have subclasses too)
Util.extend(child, parent);
MediumEditor.util.extend(child, parent);

// Set the prototype chain to inherit from `parent`, without calling
// `parent`'s constructor function.
Expand All @@ -60,7 +58,7 @@ var Extension;
child.prototype = new Surrogate();

if (protoProps) {
Util.extend(child.prototype, protoProps);
MediumEditor.util.extend(child.prototype, protoProps);
}

// todo: $super?
Expand Down
2 changes: 1 addition & 1 deletion src/js/extensions/form.js
Expand Up @@ -6,7 +6,7 @@ var FormExtension;

var noop = function () {};

/* Base functionality for an extension whcih will display
/* Base functionality for an extension which will display
* a 'form' inside the toolbar
*/
FormExtension = Button.extend({
Expand Down
6 changes: 6 additions & 0 deletions src/js/globals.js
@@ -0,0 +1,6 @@
/*jshint unused: false */
function MediumEditor(elements, options) {
'use strict';
return this.init(elements, options);
}
/*jshint unused: true */
6 changes: 3 additions & 3 deletions src/js/selection.js
@@ -1,5 +1,3 @@
var Selection;

(function () {
'use strict';

Expand All @@ -11,7 +9,7 @@ var Selection;
}
}

Selection = {
var Selection = {
findMatchingSelectionParent: function (testElementFunction, contentWindow) {
var selection = contentWindow.getSelection(),
range,
Expand Down Expand Up @@ -422,4 +420,6 @@ var Selection;
return startNode;
}
};

MediumEditor.selection = Selection;
}());
6 changes: 3 additions & 3 deletions src/js/util.js
@@ -1,7 +1,5 @@
/*global NodeFilter*/

var Util;

(function (window) {
'use strict';

Expand All @@ -24,7 +22,7 @@ var Util;
return dest;
}

Util = {
var Util = {

// http://stackoverflow.com/questions/17907445/how-to-detect-ie11#comment30165888_17907562
// by rg89
Expand Down Expand Up @@ -864,4 +862,6 @@ var Util;
}
}
};

MediumEditor.util = Util;
}(window));

0 comments on commit 266261f

Please sign in to comment.