diff --git a/src/brackets.js b/src/brackets.js index b88df63c2c5..54327ee8cba 100644 --- a/src/brackets.js +++ b/src/brackets.js @@ -37,7 +37,7 @@ */ define(function (require, exports, module) { "use strict"; - + // Load dependent non-module scripts require("widgets/bootstrap-dropdown"); require("widgets/bootstrap-modal"); @@ -57,7 +57,7 @@ define(function (require, exports, module) { require("thirdparty/CodeMirror2/addon/mode/overlay"); require("thirdparty/CodeMirror2/addon/search/searchcursor"); require("thirdparty/CodeMirror2/keymap/sublime"); - + // Load dependent modules var Global = require("utils/Global"), AppInit = require("utils/AppInit"), diff --git a/src/main.js b/src/main.js index ba37386f009..4e1b40bdce9 100644 --- a/src/main.js +++ b/src/main.js @@ -50,9 +50,12 @@ require.config({ locale: window.localStorage.getItem("locale") || (typeof (brackets) !== "undefined" ? brackets.app.language : navigator.language) }); -define(function (require, exports, module) { +define(function (require) { "use strict"; - - // Load the brackets module. This is a self-running module that loads and runs the entire application. - require("brackets"); + + // Load compatibility shims--these need to load early, be careful moving this + require(["utils/Compatibility"], function () { + // Load the brackets module. This is a self-running module that loads and runs the entire application. + require(["brackets"]); + }); }); diff --git a/src/utils/Compatibility.js b/src/utils/Compatibility.js new file mode 100644 index 00000000000..0de7af58092 --- /dev/null +++ b/src/utils/Compatibility.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2014 Adobe Systems Incorporated. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + * + */ + + +/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */ +/*global define */ + +/** + * Compatibility shims for running Brackets in various environments, browsers. + */ +define(function () { + "use strict"; + + // [IE10] String.prototype missing trimRight() and trimLeft() + if (!String.prototype.trimRight) { + String.prototype.trimRight = function () { return this.replace(/\s+$/, ""); }; + } + if (!String.prototype.trimLeft) { + String.prototype.trimLeft = function () { return this.replace(/^\s+/, ""); }; + } + +});