From 3a474c9bae8d8c5921896282fdb443b746c4df89 Mon Sep 17 00:00:00 2001 From: cloudhead Date: Sat, 27 Mar 2010 02:24:39 -0400 Subject: [PATCH] Created a compat.js file in build/, for browser compatiblity, moved trim() in there. LESS builds to dist/ now. --- Makefile | 12 ++++++------ build/compat.js | 5 +++++ lib/ext/string.js | 12 ------------ 3 files changed, 11 insertions(+), 18 deletions(-) create mode 100644 build/compat.js delete mode 100644 lib/ext/string.js diff --git a/Makefile b/Makefile index 1b78465..ea4a781 100644 --- a/Makefile +++ b/Makefile @@ -14,8 +14,8 @@ benchmark: # Build less.js # SRC = lib/less -BUILD = build/less.js -BUILD_MIN = build/less.min.js +DIST = dist/less.js +DIST_MIN = dist/less.min.js HEADER = build/header.js VERSION = `cat VERSION` @@ -25,13 +25,13 @@ less: ${SRC}/parser.js\ ${SRC}/functions.js\ ${SRC}/tree/*.js\ - ${SRC}/browser.js > ${BUILD} - @@echo ${BUILD} built. + ${SRC}/browser.js > ${DIST} + @@echo ${DIST} built. min: less @@echo Minifying... - @@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${BUILD_MIN} + @@cat ${HEADER} | sed s/@VERSION/${VERSION}/ > ${DIST_MIN} @@java -jar build/compiler.jar\ - --js ${BUILD} >> ${BUILD_MIN} + --js ${DIST} >> ${DIST_MIN} .PHONY: test benchmark diff --git a/build/compat.js b/build/compat.js new file mode 100644 index 0000000..a22e5fc --- /dev/null +++ b/build/compat.js @@ -0,0 +1,5 @@ +if (typeof(String.prototype.trim) !== "function") { + String.prototype.trim = function (str) { + return this.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); + }; +} diff --git a/lib/ext/string.js b/lib/ext/string.js deleted file mode 100644 index 8136f17..0000000 --- a/lib/ext/string.js +++ /dev/null @@ -1,12 +0,0 @@ -if (typeof(String.prototype.trim) === "undefined") { - String.prototype.trim = function (str) { - var str = this.replace(/^\s+/, ''); - for (var i = str.length - 1; i >= 0; i--) { - if (/\S/.test(str.charAt(i))) { - str = str.substring(0, i + 1); - break; - } - } - return str; - }; -}