Skip to content

Commit

Permalink
Merge pull request #669 from yabwe/cleanup-v5
Browse files Browse the repository at this point in the history
Remove Unused Methods
  • Loading branch information
j0k3r committed Jun 5, 2015
2 parents 98c48f3 + b8d5506 commit 15ae3b3
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 138 deletions.
23 changes: 0 additions & 23 deletions spec/extension.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,29 +26,6 @@ describe('Extensions TestCase', function () {
expect(editor.options.extensions).toBe(extensions);
});

it('should call methods on all extensions with callExtensions is used', function () {
var Extension = function () {},
ext1 = new Extension(),
ext2 = new Extension(),
editor = this.newMediumEditor('.editor', {
extensions: {
'one': ext1,
'two': ext2
}
});

Extension.prototype.aMethod = function () {
// just a stub function
};

spyOn(ext1, 'aMethod');
spyOn(ext2, 'aMethod');

editor.callExtensions('aMethod', 'theParam');
expect(ext1.aMethod).toHaveBeenCalledWith('theParam');
expect(ext2.aMethod).toHaveBeenCalledWith('theParam');
});

it('should set the base property to an instance of MediumEditor', function () {
var extOne = new MediumEditor.Extension(),
editor = this.newMediumEditor('.editor', {
Expand Down
36 changes: 0 additions & 36 deletions spec/util.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,42 +79,6 @@ describe('Util', function () {
});
});

describe('getobject', function () {
it('should get nested objects', function () {
var obj = { a: { b: { c: { d: 10 } } } };
expect(Util.getObject('a.b.c.d', false, obj)).toBe(10);
expect(Util.getObject('a.b.c.d', false, false)).toBe(undefined);
expect(Util.getObject(false, false, obj)).toBe(obj);
expect(Util.getObject('a.b.c', false, obj)).toEqual({ d: 10 });
expect(Util.getObject('a', false, obj)).toEqual({ b: { c: { d: 10 } } });
});

it('should create a path if told to', function () {
var obj = {};
expect(Util.getObject('a.b.c.d', true, obj)).toEqual({});
expect(obj.a.b.c.d).toBeTruthy();
});

it('should NOT create a path', function () {
var obj = {};
expect(Util.getObject('a.b.c.d.e.f.g', false, obj)).toBe(undefined);
expect(obj.a).toBe(undefined);
});
});

describe('setobject', function () {
it('sets returns the value', function () {
var obj = {};
expect(Util.setObject('a.b.c', 10, obj)).toBe(10);
expect(obj.a.b.c).toBe(10);
});

it('sets returns undefined because of empty string', function () {
var obj = {};
expect(Util.setObject('', 10, obj)).toBe(undefined);
});
});

describe('settargetblank', function () {
it('sets target blank on a A element from a A element', function () {
var el = this.createElement('a', '', 'lorem ipsum');
Expand Down
28 changes: 0 additions & 28 deletions src/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -648,34 +648,6 @@ function MediumEditor(elements, options) {
return extension;
},

/**
* NOT DOCUMENTED - exposed for backwards compatability
* Helper function to call a method with a number of parameters on all registered extensions.
* The function assures that the function exists before calling.
*
* @param {string} funcName name of the function to call
* @param [args] arguments passed into funcName
*/
callExtensions: function (funcName) {
if (arguments.length < 1) {
return;
}

var args = Array.prototype.slice.call(arguments, 1),
ext,
name;

for (name in this.options.extensions) {
if (this.options.extensions.hasOwnProperty(name)) {
ext = this.options.extensions[name];
if (ext[funcName] !== undefined) {
ext[funcName].apply(ext, args);
}
}
}
return this;
},

stopSelectionUpdates: function () {
this.preventSelectionUpdates = true;
},
Expand Down
51 changes: 0 additions & 51 deletions src/js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,6 @@ var Util;
(function (window) {
'use strict';

// Params: Array, Boolean, Object
function getProp(parts, create, context) {
if (!context) {
context = window;
}

try {
for (var i = 0; i < parts.length; i++) {
var p = parts[i];
if (!(p in context)) {
if (create) {
context[p] = {};
} else {
return;
}
}
context = context[p];
}
return context;
} catch (e) {
// 'p in context' throws an exception when context is a number, boolean, etc. rather than an object,
// so in that corner case just return undefined (by having no return statement)
}
}

function copyInto(overwrite, dest) {
var prop,
sources = Array.prototype.slice.call(arguments, 2);
Expand Down Expand Up @@ -125,16 +100,6 @@ var Util;
return copyInto.apply(this, args);
},

derives: function derives(base, derived) {
var origPrototype = derived.prototype;
function Proto() { }
Proto.prototype = base.prototype;
derived.prototype = new Proto();
derived.prototype.constructor = base;
derived.prototype = copyInto(false, derived.prototype, origPrototype);
return derived;
},

// Find the next node in the DOM tree that represents any text that is being
// displayed directly next to the targetNode (passed as an argument)
// Text that appears directly next to the current node can be:
Expand Down Expand Up @@ -698,22 +663,6 @@ var Util;
} else {
el.parentNode.removeChild(el);
}
},

setObject: function (name, value, context) {
// summary:
// Set a property from a dot-separated string, such as 'A.B.C'
var parts = name.split('.'),
p = parts.pop(),
obj = getProp(parts, true, context);
return obj && p ? (obj[p] = value) : undefined; // Object
},

getObject: function (name, create, context) {
// summary:
// Get a property from a dot-separated string, such as 'A.B.C'
return getProp(name ? name.split('.') : [], create, context); // Object
}

};
}(window));

0 comments on commit 15ae3b3

Please sign in to comment.