From 9a5a67dfafc75b4ff76cbf9b1e425f83a80b0512 Mon Sep 17 00:00:00 2001
From: Steve Clay
Date: Sat, 6 Sep 2008 22:35:22 +0000
Subject: [PATCH] builder app improvements and bookmarklet JSMin.php : + YUI
and IE conditional comment preserving
---
README | 21 +++---
min/builder/_index.js | 71 +++++++++++++++++--
min/builder/bm.js | 29 ++++++++
min/builder/index.php | 16 ++++-
min/lib/JSMin.php | 45 ++++++++----
min/lib/Minify/Javascript.php | 21 +-----
.../unit_tests/_test_files/js/before.js | 16 ++++-
.../unit_tests/_test_files/js/before.min.js | 8 ++-
.../_test_files/js/before_noComments.min.js | 3 -
.../_test_files/minify/lines_output.js | 15 ++++
.../unit_tests/test_Minify_Javascript.php | 14 ----
11 files changed, 189 insertions(+), 70 deletions(-)
create mode 100644 min/builder/bm.js
delete mode 100644 min_extras/unit_tests/_test_files/js/before_noComments.min.js
diff --git a/README b/README
index aabdd77..eb81447 100644
--- a/README
+++ b/README
@@ -16,16 +16,6 @@ directory: i.e. you will have: /home/user/www/public_html/min
you to the Minify URI Builder application, which will help you
quickly start using Minify to serve content on your site.
-UNIT TESTING:
-
-1. Place the /min_extras/ directory as a child of your DOCUMENT_ROOT
-directory: i.e. you will have: /home/user/www/public_html/min_extras
-
-2. To run unit tests, access: http://yourdomain/min_extras/unit_tests/test_all.php
-
-Other test_*.php files in that directory can be run to test individual
-components more verbosely.
-
FILE ENCODINGS
@@ -35,3 +25,14 @@ encodings like ISO 8859/Windows-1252. By default Minify appends
Leading UTF-8 BOMs are stripped from all sources to prevent
duplication in output files, and files are converted to Unix newlines.
+
+
+UNIT TESTING:
+
+1. Place the /min_extras/ directory as a child of your DOCUMENT_ROOT
+directory: i.e. you will have: /home/user/www/public_html/min_extras
+
+2. To run unit tests, access: http://yourdomain/min_extras/unit_tests/test_all.php
+
+Other test_*.php files in that directory can be run to test individual
+components more verbosely.
diff --git a/min/builder/_index.js b/min/builder/_index.js
index ba56d8b..e48064a 100644
--- a/min/builder/_index.js
+++ b/min/builder/_index.js
@@ -1,41 +1,50 @@
-// @todo update test links when reordering, app instructions
var MUB = {
_uid : 0
+ /**
+ * Get markup for new source LI element
+ */
,newLi : function () {
return '
http://' + location.host + '/'
+ ' '
+ '
';
}
+ /**
+ * Add new empty source LI and attach handlers to buttons
+ */
,addLi : function () {
$('#sources').append(MUB.newLi());
var li = $('#li' + MUB._uid)[0];
$('button[title=Remove]', li).click(function () {
+ $('#results').hide();
var hadValue = !!$('input', li)[0].value;
$(li).remove();
- hadValue && MUB.update();
});
$('button[title$=Earlier]', li).click(function () {
$(li).prev('li').find('input').each(function () {
+ $('#results').hide();
// this = previous li input
var tmp = this.value;
this.value = $('input', li).val();
$('input', li).val(tmp);
MUB.updateAllTestLinks();
- MUB.update();
});
});
$('button[title$=Later]', li).click(function () {
$(li).next('li').find('input').each(function () {
+ $('#results').hide();
// this = next li input
var tmp = this.value;
this.value = $('input', li).val();
$('input', li).val(tmp);
MUB.updateAllTestLinks();
- MUB.update();
});
});
++MUB._uid;
}
+ /**
+ * In the context of a source LI element, this will analyze the URI in
+ * the INPUT and check the URL on the site.
+ */
,liUpdateTestLink : function () { // call in context of li element
if (! $('input', this)[0].value)
return;
@@ -58,9 +67,19 @@ var MUB = {
,dataType : 'text'
});
}
+ /**
+ * Check all source URLs
+ */
,updateAllTestLinks : function () {
$('#sources li').each(MUB.liUpdateTestLink);
}
+ /**
+ * In a given array of strings, find the character they all have at
+ * a particular index
+ * @param Array arr array of strings
+ * @param Number pos index to check
+ * @return mixed a common char or '' if any do not match
+ */
,getCommonCharAtPos : function (arr, pos) {
var i
,l = arr.length
@@ -72,6 +91,10 @@ var MUB = {
return '';
return c;
}
+ /**
+ * Get the shortest URI to minify the set of source files
+ * @param Array sources URIs
+ */
,getBestUri : function (sources) {
var pos = 0
,base = ''
@@ -103,6 +126,9 @@ var MUB = {
}
return uri;
}
+ /**
+ * Create the Minify URI for the sources
+ */
,update : function () {
MUB.updateAllTestLinks();
var sources = []
@@ -139,21 +165,56 @@ var MUB = {
);
$('#results').show();
}
+ /**
+ * Handler for the "Add file +" button
+ */
,addButtonClick : function () {
+ $('#results').hide();
MUB.addLi();
MUB.updateAllTestLinks();
$('#update').show().click(MUB.update);
}
+ /**
+ * Runs on DOMready
+ */
,init : function () {
$('#sources').html('');
$('#add button').click(MUB.addButtonClick);
+ // make easier to copy text out of
$('#uriHtml, #groupConfig').click(function () {
this.select();
}).focus(function () {
this.select();
});
$('a.ext').attr({target:'_blank'});
- MUB.addButtonClick();
+ if (location.hash) {
+ // make links out of URIs from bookmarklet
+ $('#getBm').hide();
+ $('#bmUris').html('
return array(
... your existing groups here ...
-
+
);
Make sure to replace keyName with a unique key for this group.
+
+
Find URIs on a Page
+
You can use the bookmarklet below to fetch all CSS & Javascript URIs from a page
+on your site. When you active it, this page will open in a new window with a list of
+available URIs to add.