diff --git a/lib/ace/editor.js b/lib/ace/editor.js
index a442c38f..2fd404b7 100644
--- a/lib/ace/editor.js
+++ b/lib/ace/editor.js
@@ -426,7 +426,7 @@ var Editor =function(renderer, doc) {
this.bgTokenizer.getState(cursor.row, function (lineState) {
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
var line = _self.doc.getLine(cursor.row),
- lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
+ lineIndent = _self.mode.getNextLineIndent(lineState, line.slice(0, cursor.column), _self.doc.getTabString());
var end = _self.doc.insert(cursor, text);
/* TODO: This shortcut is somehow broken
diff --git a/lib/ace/keybinding.js b/lib/ace/keybinding.js
index fecf2463..db54ac00 100644
--- a/lib/ace/keybinding.js
+++ b/lib/ace/keybinding.js
@@ -37,7 +37,7 @@
define(function(require, exports, module) {
-var core = require("pilot/core");
+var useragent = require("pilot/useragent");
var event = require("pilot/event");
var default_mac = require("ace/conf/keybindings/default_mac").bindings;
var default_win = require("ace/conf/keybindings/default_win").bindings;
@@ -50,7 +50,7 @@ var KeyBinding = function(element, editor, config) {
var _self = this;
event.addKeyListener(element, function(e) {
// opera on mac swaps ctrl and meta keys
- if (core.isOpera && core.isMac)
+ if (useragent.isOpera && useragent.isMac)
var hashId = 0 | (e.metaKey ? 1 : 0) | (e.altKey ? 2 : 0)
| (e.shiftKey ? 4 : 0) | (e.ctrlKey ? 8 : 0);
else
@@ -145,7 +145,7 @@ var KeyBinding = function(element, editor, config) {
}
this.setConfig = function(config) {
- this.config = config || (core.isMac
+ this.config = config || (useragent.isMac
? default_mac
: default_win);
if (typeof this.config.reverse == "undefined")
diff --git a/lib/ace/test/text_edit_test.js b/lib/ace/test/text_edit_test.js
index 61658cca..d917b363 100644
--- a/lib/ace/test/text_edit_test.js
+++ b/lib/ace/test/text_edit_test.js
@@ -133,6 +133,15 @@ var Test = {
editor.indent();
assert.equal(["a12345", " b12345", "c12345"].join("\n"), doc.toString());
},
+
+ "test: no auto indent if cursor is before the {" : function() {
+ var doc = new Document("{", new JavaScriptMode());
+ var editor = new Editor(new MockRenderer(), doc);
+
+ editor.moveCursorTo(0, 0);
+ editor.onTextInput("\n");
+ assert.equal(["", "{"].join("\n"), doc.toString());
+ },
"test: outdent block" : function() {
var doc = new Document([" a12345", " b12345", " c12345"].join("\n"));
diff --git a/plugins/cockpit/cli.js b/plugins/cockpit/cli.js
index bb8428c7..df183782 100644
--- a/plugins/cockpit/cli.js
+++ b/plugins/cockpit/cli.js
@@ -39,7 +39,7 @@ define(function(require, exports, module) {
var console = require('pilot/console');
-var util = require('pilot/util');
+var lang = require('pilot/lang');
var oop = require('pilot/oop');
var EventEmitter = require('pilot/event_emitter').EventEmitter;
@@ -1048,7 +1048,7 @@ oop.inherits(CliRequisition, Requisition);
}
}
- util.arrayRemove(names, assignment.name);
+ lang.arrayRemove(names, assignment.name);
args.splice(i, 1);
// We don't need to i++ if we splice
}
diff --git a/plugins/cockpit/ui/requestView.js b/plugins/cockpit/ui/requestView.js
index 24458a46..8e21d3ca 100644
--- a/plugins/cockpit/ui/requestView.js
+++ b/plugins/cockpit/ui/requestView.js
@@ -37,16 +37,14 @@
define(function(require, exports, module) {
-
-var util = require('pilot/util');
-
-var requestViewCss = require("text!cockpit/ui/requestView.css");
var dom = require("pilot/dom");
-dom.importCssString(requestViewCss);
-
+var event = require("pilot/event");
var requestViewHtml = require("text!cockpit/ui/requestView.html");
var Templater = require("pilot/domtemplate").Templater;
+var requestViewCss = require("text!cockpit/ui/requestView.css");
+dom.importCssString(requestViewCss);
+
/**
* Pull the HTML into the DOM, but don't add it to the document
*/
@@ -102,24 +100,24 @@ RequestView.prototype = {
hideOutput: function(ev) {
this.output.style.display = 'none';
- util.addClass(this.hide, 'cmd_hidden');
- util.removeClass(this.show, 'cmd_hidden');
+ dom.addCssClass(this.hide, 'cmd_hidden');
+ dom.removeCssClass(this.show, 'cmd_hidden');
- ev.stopPropagation();
+ event.stopPropagation(ev);
},
showOutput: function(ev) {
this.output.style.display = 'block';
- util.removeClass(this.hide, 'cmd_hidden');
- util.addClass(this.show, 'cmd_hidden');
+ dom.removeCssClass(this.hide, 'cmd_hidden');
+ dom.addCssClass(this.show, 'cmd_hidden');
- ev.stopPropagation();
+ event.stopPropagation(ev);
},
remove: function(ev) {
this.cliView.output.removeChild(this.rowin);
this.cliView.output.removeChild(this.rowout);
- ev.stopPropagation();
+ event.stopPropagation(ev);
},
onRequestChange: function(ev) {
@@ -140,7 +138,7 @@ RequestView.prototype = {
}, this);
this.cliView.scrollOutputToBottom();
- util.setClass(this.output, 'cmd_error', this.request.error);
+ dom.setCssClass(this.output, 'cmd_error', this.request.error);
this.throb.style.display = this.request.completed ? 'none' : 'block';
}
diff --git a/plugins/pilot/canon.js b/plugins/pilot/canon.js
index e0037cf0..3a4165a0 100644
--- a/plugins/pilot/canon.js
+++ b/plugins/pilot/canon.js
@@ -44,7 +44,7 @@ var EventEmitter = require('pilot/event_emitter').EventEmitter;
var catalog = require('pilot/catalog');
var Status = require('pilot/types').Status;
var types = require('pilot/types');
-var util = require('pilot/util');
+var lang = require('pilot/lang');
/*
// TODO: this doesn't belong here - or maybe anywhere?
@@ -153,7 +153,7 @@ function upgradeType(param) {
function removeCommand(command) {
var name = (typeof command === 'string' ? command : command.name);
delete commands[name];
- util.arrayRemove(commandNames, name);
+ lang.arrayRemove(commandNames, name);
};
function getCommand(name) {
diff --git a/plugins/pilot/commands/basic.js b/plugins/pilot/commands/basic.js
index ae16a47e..68b34fa8 100644
--- a/plugins/pilot/commands/basic.js
+++ b/plugins/pilot/commands/basic.js
@@ -37,8 +37,7 @@
define(function(require, exports, module) {
-
-var util = require('pilot/util');
+var checks = require("pilot/typecheck");
var canon = require('pilot/canon');
/**
@@ -165,11 +164,11 @@ var evalCommandSpec = {
var type = '';
var x;
- if (util.isFunction(result)) {
+ if (checks.isFunction(result)) {
// converts the function to a well formated string
msg = (result + '').replace(/\n/g, '
').replace(/ /g, ' ');
type = 'function';
- } else if (util.isObject(result)) {
+ } else if (checks.isObject(result)) {
if (Array.isArray(result)) {
type = 'array';
} else {
@@ -181,9 +180,9 @@ var evalCommandSpec = {
for (x in result) {
if (result.hasOwnProperty(x)) {
- if (util.isFunction(result[x])) {
+ if (checks.isFunction(result[x])) {
value = '[function]';
- } else if (util.isObject(result[x])) {
+ } else if (checks.isObject(result[x])) {
value = '[object]';
} else {
value = result[x];
diff --git a/plugins/pilot/dom.js b/plugins/pilot/dom.js
index 99d51636..585ec820 100644
--- a/plugins/pilot/dom.js
+++ b/plugins/pilot/dom.js
@@ -51,12 +51,30 @@ exports.hasCssClass = function(el, name) {
return classes.indexOf(name) !== -1;
};
+/**
+* Add a CSS class to the list of classes on the given node
+*/
exports.addCssClass = function(el, name) {
if (!exports.hasCssClass(el, name)) {
el.className += " " + name;
}
};
+/**
+ * Add or remove a CSS class from the list of classes on the given node
+ * depending on the value of include
+ */
+exports.setCssClass = function(node, className, include) {
+ if (include) {
+ exports.addCssClass(node, className);
+ } else {
+ exports.removeCssClass(node, className);
+ }
+};
+
+/**
+* Remove a CSS class from the list of classes on the given node
+*/
exports.removeCssClass = function(el, name) {
var classes = el.className.split(/\s+/g);
while (true) {
diff --git a/plugins/pilot/event.js b/plugins/pilot/event.js
index 2beaff41..34621fe6 100644
--- a/plugins/pilot/event.js
+++ b/plugins/pilot/event.js
@@ -37,7 +37,7 @@
define(function(require, exports, module) {
-var core = require("pilot/core");
+var useragent = require("pilot/useragent");
exports.addListener = function(elem, type, callback) {
if (elem.addEventListener) {
@@ -61,6 +61,9 @@ exports.removeListener = function(elem, type, callback) {
}
};
+/**
+* Prevents propagation and clobbers the default action of the passed event
+*/
exports.stopEvent = function(e) {
exports.stopPropagation(e);
exports.preventDefault(e);
@@ -212,7 +215,7 @@ exports.addMultiMouseDownListener = function(el, button, count, timeout, callbac
};
exports.addListener(el, "mousedown", listener);
- core.isIE && exports.addListener(el, "dblclick", listener);
+ useragent.isIE && exports.addListener(el, "dblclick", listener);
};
exports.addKeyListener = function(el, callback) {
@@ -224,7 +227,7 @@ exports.addKeyListener = function(el, callback) {
});
// repeated keys are fired as keypress and not keydown events
- if (core.isMac && (core.isGecko || core.isOpera)) {
+ if (useragent.isMac && (useragent.isGecko || useragent.isOpera)) {
exports.addListener(el, "keypress", function(e) {
var keyId = e.keyIdentifier || e.keyCode;
if (lastDown !== keyId) {
diff --git a/plugins/pilot/keyboard/keyutil.js b/plugins/pilot/keyboard/keyutil.js
index bbc0ac5a..12bc3a99 100644
--- a/plugins/pilot/keyboard/keyutil.js
+++ b/plugins/pilot/keyboard/keyutil.js
@@ -33,8 +33,8 @@ For more information about SproutCore, visit http://www.sproutcore.com
define(function(require, exports, module) {
-var util = require('pilot/util');
-
+var event = require('pilot/event');
+var useragent = require('pilot/useragent');
/**
* Helper functions and hashes for key handling.
@@ -215,13 +215,13 @@ exports.addKeyDownListener = function(element, boundFunction) {
var handled = boundFunction(ev);
// If the boundFunction returned true, then stop the event.
if (handled) {
- util.stopEvent(ev);
+ event.stopEvent(ev);
}
return handled;
};
element.addEventListener('keydown', function(ev) {
- if (util.isMozilla) {
+ if (useragent.isGecko) {
// Check for function keys (like DELETE, TAB, LEFT, RIGHT...)
if (exports.KeyHelper.FUNCTION_KEYS[ev.keyCode]) {
return true;
@@ -240,7 +240,7 @@ exports.addKeyDownListener = function(element, boundFunction) {
}, false);
element.addEventListener('keypress', function(ev) {
- if (util.isMozilla) {
+ if (useragent.isGecko) {
// If this is a function key, we have to use the keyCode.
if (exports.KeyHelper.FUNCTION_KEYS[ev.keyCode]) {
return handleBoundFunction(ev);
diff --git a/plugins/pilot/lang.js b/plugins/pilot/lang.js
index 5170a261..b8b946e1 100644
--- a/plugins/pilot/lang.js
+++ b/plugins/pilot/lang.js
@@ -62,6 +62,17 @@ exports.arrayToMap = function(arr) {
};
+/**
+ * splice out of 'array' anything that === 'value'
+ */
+exports.arrayRemove = function(array, value) {
+ for (var i = 0; i <= array.length; i++) {
+ if (value === array[i]) {
+ array.splice(i, 1);
+ }
+ }
+};
+
exports.escapeRegExp = function(str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
};
diff --git a/plugins/pilot/stacktrace.js b/plugins/pilot/stacktrace.js
index 961d88cc..b5094e73 100644
--- a/plugins/pilot/stacktrace.js
+++ b/plugins/pilot/stacktrace.js
@@ -1,6 +1,6 @@
define(function(require, exports, module) {
-var util = require("pilot/util");
+var ua = require("pilot/useragent");
var console = require('pilot/console');
// Changed to suit the specific needs of running within Skywriter
@@ -65,11 +65,11 @@ var mode = (function() {
// functionality provided by Firebug. Firebug tries to do the right
// thing here and break, but it happens every time you load the page.
// bug 554105
- if (util.isMozilla) {
+ if (ua.isGecko) {
return 'firefox';
- } else if (util.isOpera) {
+ } else if (ua.isOpera) {
return 'opera';
- } else if (util.isSafari) {
+ } else {
return 'other';
}
diff --git a/plugins/pilot/typecheck.js b/plugins/pilot/typecheck.js
new file mode 100644
index 00000000..40ea1630
--- /dev/null
+++ b/plugins/pilot/typecheck.js
@@ -0,0 +1,80 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Skywriter.
+ *
+ * The Initial Developer of the Original Code is
+ * Mozilla.
+ * Portions created by the Initial Developer are Copyright (C) 2009
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ * Joe Walker (jwalker@mozilla.com)
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+define(function(require, exports, module) {
+
+var objectToString = Object.prototype.toString;
+
+/**
+ * Return true if it is a String
+ */
+exports.isString = function(it) {
+ return it && objectToString.call(it) === "[object String]";
+};
+
+/**
+ * Returns true if it is a Boolean.
+ */
+exports.isBoolean = function(it) {
+ return it && objectToString.call(it) === "[object Boolean]";
+};
+
+/**
+ * Returns true if it is a Number.
+ */
+exports.isNumber = function(it) {
+ return it && objectToString.call(it) === "[object Number]" && isFinite(it);
+};
+
+/**
+ * Hack copied from dojo.
+ */
+exports.isObject = function(it) {
+ return it !== undefined &&
+ (it === null || typeof it == "object" ||
+ Array.isArray(it) || exports.isFunction(it));
+};
+
+/**
+ * Is the passed object a function?
+ * From dojo.isFunction()
+ */
+exports.isFunction = function(it) {
+ return it && objectToString.call(it) === "[object Function]";
+};
+
+});
\ No newline at end of file
diff --git a/plugins/pilot/core.js b/plugins/pilot/useragent.js
similarity index 63%
rename from plugins/pilot/core.js
rename to plugins/pilot/useragent.js
index 40991657..06c9432e 100644
--- a/plugins/pilot/core.js
+++ b/plugins/pilot/useragent.js
@@ -38,23 +38,54 @@
define(function(require, exports, module) {
var os = (navigator.platform.match(/mac|win|linux/i) || ["other"])[0].toLowerCase();
+var ua = navigator.userAgent;
+var av = navigator.appVersion;
+/** Is the user using a browser that identifies itself as Windows */
exports.isWin = (os == "win");
+
+/** Is the user using a browser that identifies itself as Mac OS */
exports.isMac = (os == "mac");
+
+/** Is the user using a browser that identifies itself as Linux */
exports.isLinux = (os == "linux");
+
exports.isIE = ! + "\v1";
-exports.isGecko = window.controllers && window.navigator.product === "Gecko";
+
+/** Is this Firefox or related? */
+exports.isGecko = exports.isMozilla = window.controllers && window.navigator.product === "Gecko";
+
+/** Is this Opera */
exports.isOpera = window.opera && Object.prototype.toString.call(window.opera) == "[object Opera]";
-exports.provide = function(namespace) {
- var parts = namespace.split(".");
- var obj = window;
- for (var i=0; i= 0;
+
+/**
+ * I hate doing this, but we need some way to determine if the user is on a Mac
+ * The reason is that users have different expectations of their key combinations.
+ *
+ * Take copy as an example, Mac people expect to use CMD or APPLE + C
+ * Windows folks expect to use CTRL + C
+ */
+exports.OS = {
+ LINUX: 'LINUX',
+ MAC: 'MAC',
+ WINDOWS: 'WINDOWS'
+};
+
+/**
+ * Return an exports.OS constant
+ */
+exports.getOS = function() {
+ if (exports.isMac) {
+ return exports.OS['MAC'];
+ } else if (exports.isLinux) {
+ return exports.OS['LINUX'];
+ } else {
+ return exports.OS['WINDOWS'];
}
};
diff --git a/plugins/pilot/util.js b/plugins/pilot/util.js
index 7fed5068..9a80e472 100644
--- a/plugins/pilot/util.js
+++ b/plugins/pilot/util.js
@@ -37,6 +37,9 @@
define(function(require, exports, module) {
+throw new Error("pilot/util is deprecated. If you need one of the functions from this\
+module please copy the code to the appropriate placein pilot/(lang|dom|event)");
+
/**
* Create an object representing a de-serialized query section of a URL.
* Query keys with multiple values are returned in an array.
@@ -140,57 +143,6 @@ exports.rateLimit = function(maxRate, scope, func) {
}
};
-/**
- * Return true if it is a String
- */
-exports.isString = function(it) {
- return (typeof it == "string" || it instanceof String);
-};
-
-/**
- * Returns true if it is a Boolean.
- */
-exports.isBoolean = function(it) {
- return (typeof it == 'boolean');
-};
-
-/**
- * Returns true if it is a Number.
- */
-exports.isNumber = function(it) {
- return (typeof it == 'number' && isFinite(it));
-};
-
-/**
- * Hack copied from dojo.
- */
-exports.isObject = function(it) {
- return it !== undefined &&
- (it === null || typeof it == "object" ||
- Array.isArray(it) || exports.isFunction(it));
-};
-
-/**
- * Is the passed object a function?
- * From dojo.isFunction()
- */
-exports.isFunction = (function() {
- var _isFunction = function(it) {
- var t = typeof it; // must evaluate separately due to bizarre Opera bug. See #8937
- //Firefox thinks object HTML element is a function, so test for nodeType.
- return it && (t == "function" || it instanceof Function) && !it.nodeType; // Boolean
- };
-
- return exports.isSafari ?
- // only slow this down w/ gratuitious casting in Safari (not WebKit)
- function(/*anything*/ it) {
- if (typeof it == "function" && it == "[object NodeList]") {
- return false;
- }
- return _isFunction(it); // Boolean
- } : _isFunction;
-})();
-
/**
* A la Prototype endsWith(). Takes a regex excluding the '$' end marker
*/
@@ -228,9 +180,8 @@ exports.indexOfProperty = function(array, propertyName, item) {
* A la Prototype last().
*/
exports.last = function(array) {
- if (Array.isArray(array)) {
- return array[array.length - 1];
- }
+
+return array[array.length - 1];
};
/**
@@ -271,21 +222,6 @@ exports.makeArray = function(number, character) {
return newArray;
};
-/**
- * Repeat a string a given number of times.
- * @param string String to repeat
- * @param repeat Number of times to repeat
- */
-exports.repeatString = function(string, repeat) {
- var newstring = '';
-
- for (var i = 0; i < repeat; i++) {
- newstring += string;
- }
-
- return newstring;
-};
-
/**
* Given a row, find the number of leading spaces.
* E.g. an array with the string " aposjd" would return 2
@@ -347,77 +283,6 @@ exports.englishFromCamel = function(camel) {
}).trim();
};
-/**
- * I hate doing this, but we need some way to determine if the user is on a Mac
- * The reason is that users have different expectations of their key combinations.
- *
- * Take copy as an example, Mac people expect to use CMD or APPLE + C
- * Windows folks expect to use CTRL + C
- */
-exports.OS = {
- LINUX: 'LINUX',
- MAC: 'MAC',
- WINDOWS: 'WINDOWS'
-};
-
-var ua = navigator.userAgent;
-var av = navigator.appVersion;
-
-/** Is the user using a browser that identifies itself as Linux */
-exports.isLinux = av.indexOf("Linux") >= 0;
-
-/** Is the user using a browser that identifies itself as Windows */
-exports.isWindows = av.indexOf("Win") >= 0;
-
-/** Is the user using a browser that identifies itself as WebKit */
-exports.isWebKit = parseFloat(ua.split("WebKit/")[1]) || undefined;
-
-/** Is the user using a browser that identifies itself as Chrome */
-exports.isChrome = parseFloat(ua.split("Chrome/")[1]) || undefined;
-
-/** Is the user using a browser that identifies itself as Mac OS */
-exports.isMac = av.indexOf("Macintosh") >= 0;
-
-/* Is this Firefox or related? */
-exports.isMozilla = av.indexOf('Gecko/') >= 0;
-
-if (ua.indexOf("AdobeAIR") >= 0) {
- exports.isAIR = 1;
-}
-
-/**
- * Is the user using a browser that identifies itself as Safari
- * See also:
- * - http://developer.apple.com/internet/safari/faq.html#anchor2
- * - http://developer.apple.com/internet/safari/uamatrix.html
- */
-var index = Math.max(av.indexOf("WebKit"), av.indexOf("Safari"), 0);
-if (index && !exports.isChrome) {
- // try to grab the explicit Safari version first. If we don't get
- // one, look for less than 419.3 as the indication that we're on something
- // "Safari 2-ish".
- exports.isSafari = parseFloat(av.split("Version/")[1]);
- if (!exports.isSafari || parseFloat(av.substr(index + 7)) <= 419.3) {
- exports.isSafari = 2;
- }
-}
-
-if (ua.indexOf("Gecko") >= 0 && !exports.isWebKit) {
- exports.isMozilla = parseFloat(av);
-}
-
-/**
- * Return a exports.OS constant
- */
-exports.getOS = function() {
- if (exports.isMac) {
- return exports.OS['MAC'];
- } else if (exports.isLinux) {
- return exports.OS['LINUX'];
- } else {
- return exports.OS['WINDOWS'];
- }
-};
/** Returns true if the DOM element "b" is inside the element "a". */
if (typeof(document) !== 'undefined' && document.compareDocumentPosition) {
@@ -430,14 +295,6 @@ if (typeof(document) !== 'undefined' && document.compareDocumentPosition) {
};
}
-/**
- * Prevents propagation and clobbers the default action of the passed event
- */
-exports.stopEvent = function(ev) {
- ev.preventDefault();
- ev.stopPropagation();
-};
-
/**
* Create a random password of the given length (default 16 chars)
*/
@@ -491,53 +348,6 @@ exports.formatDate = function (date) {
*/
exports.formatDate.shortMonths = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ];
-/**
- * Add a CSS class to the list of classes on the given node
- */
-exports.addClass = function(node, className) {
- var parts = className.split(/\s+/);
- var cls = " " + node.className + " ";
- for (var i = 0, len = parts.length, c; i < len; ++i) {
- c = parts[i];
- if (c && cls.indexOf(" " + c + " ") < 0) {
- cls += c + " ";
- }
- }
- node.className = cls.trim();
-};
-
-/**
- * Remove a CSS class from the list of classes on the given node
- */
-exports.removeClass = function(node, className) {
- var cls;
- if (className !== undefined) {
- var parts = className.split(/\s+/);
- cls = " " + node.className + " ";
- for (var i = 0, len = parts.length; i < len; ++i) {
- cls = cls.replace(" " + parts[i] + " ", " ");
- }
- cls = cls.trim();
- } else {
- cls = "";
- }
- if (node.className != cls) {
- node.className = cls;
- }
-};
-
-/**
- * Add or remove a CSS class from the list of classes on the given node
- * depending on the value of include
- */
-exports.setClass = function(node, className, include) {
- if (include) {
- exports.addClass(node, className);
- } else {
- exports.removeClass(node, className);
- }
-};
-
/**
* Is the passed object either null or undefined (using ===)
*/
@@ -629,16 +439,4 @@ exports.rectsEqual = function(r1, r2, delta) {
return true;
};
-/**
- * splice out of 'array' anything that === 'value'
- */
-exports.arrayRemove = function(array, value) {
- for (var i = 0; i <= array.length; i++) {
- if (value === array[i]) {
- array.splice(i, 1);
- }
- }
-};
-
-
});