aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Ugnich Anton2012-10-23 01:44:58 +0700
committerGravatar Ugnich Anton2012-10-23 01:44:58 +0700
commit9b94011a09685dec1b1b38fef8294c6ffa578079 (patch)
treeab6808f9f10a29628d9bb93905b1fcd3c2887b43
parentadfc38138808eede6bcc29a706c9191e7d2d84fe (diff)
JS/CSS optimization
-rw-r--r--build.xml23
-rw-r--r--nbproject/project.properties1
-rw-r--r--src/java/com/juick/http/www/PageTemplates.java14
-rw-r--r--src/java/com/juick/http/www/UserThread.java26
-rw-r--r--web/scripts3.js64
-rw-r--r--web/style3.css4
6 files changed, 71 insertions, 61 deletions
diff --git a/build.xml b/build.xml
index 94203053..b66246a0 100644
--- a/build.xml
+++ b/build.xml
@@ -10,6 +10,29 @@
<project name="com.juick.http.www" default="default" basedir=".">
<description>Builds, tests, and runs the project com.juick.http.www.</description>
<import file="nbproject/build-impl.xml"/>
+
+ <target name="-pre-dist">
+ <echo level="info" message="Compressing JavaScript and CSS files...." />
+ <path id="yuicompressor.classpath">
+ <fileset dir="${ant.home}/lib">
+ <include name="yuiant.jar"/>
+ <include name="yuicompressor-2.4.7.jar"/>
+ </fileset>
+ </path>
+ <taskdef name="yuicompress" classname="com.yahoo.platform.yui.compressor.YUICompressTask">
+ <classpath>
+ <path refid="yuicompressor.classpath"/>
+ </classpath>
+ </taskdef>
+ <yuicompress linebreak="8000" warn="false" munge="yes" preserveallsemicolons="true" outputfolder="${basedir}/${build.web.dir}">
+ <fileset dir="${basedir}/web">
+ <include name="**/*.js" />
+ <include name="**/*.css" />
+ </fileset>
+ </yuicompress>
+ <echo level="info" message="Compression Complete" />
+ </target>
+
<!--
There exist several targets which are by default empty and which can be
diff --git a/nbproject/project.properties b/nbproject/project.properties
index 1b4e5382..e4bb4d38 100644
--- a/nbproject/project.properties
+++ b/nbproject/project.properties
@@ -1,6 +1,5 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=true
-annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
build.classes.dir=${build.web.dir}/WEB-INF/classes
diff --git a/src/java/com/juick/http/www/PageTemplates.java b/src/java/com/juick/http/www/PageTemplates.java
index a38b90f8..567bc639 100644
--- a/src/java/com/juick/http/www/PageTemplates.java
+++ b/src/java/com/juick/http/www/PageTemplates.java
@@ -54,12 +54,11 @@ public class PageTemplates {
out.println("<head>");
out.println(" <meta charset=\"utf-8\"/>");
out.println(" <title>" + title + "</title>");
- out.println(" <link rel=\"stylesheet\" href=\"http://static.juick.com/style3.css?2012030601\"/>");
+ out.println(" <link rel=\"stylesheet\" href=\"http://static.juick.com/style3.2012102203.css\"/>");
out.println(" <link rel=\"icon\" type=\"image/png\" href=\"http://static.juick.com/favicon.png\"/>");
- out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\"></script>");
- out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\"></script>");
- out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/scripts3.js?20120306\"></script>");
- out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/js/jquery.autoresize.js\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js\" defer=\"defer\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"https://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js\" defer=\"defer\" async=\"async\"></script>");
+ out.println(" <script type=\"text/javascript\" src=\"http://static.juick.com/scripts3.2012102203.js\" defer=\"defer\"></script>");
if (headers != null) {
out.println(headers);
}
@@ -332,10 +331,7 @@ public class PageTemplates {
if (rs.getString(12).equals("jpg")) {
out.println(" <div class=\"msg-media\"><a href=\"http://i.juick.com/photos-1024/" + mid + ".jpg\"><img src=\"http://i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></a></div>");
} else {
- out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + mid + ".mp4\">Video</a></b></div></div>");
- out.println(" <script type=\"text/javascript\">");
- out.println(" inlinevideo(" + mid + ");");
- out.println(" </script>");
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><a href=\"http://i.juick.com/video/" + mid + ".mp4\" onclick=\"inlinevideo(" + mid + "); return false\"><img src=\"http://i.juick.com/thumbs/" + mid + ".jpg\" alt=\"\"/></a></div></div>");
}
}
diff --git a/src/java/com/juick/http/www/UserThread.java b/src/java/com/juick/http/www/UserThread.java
index 320c62ba..c335fcb9 100644
--- a/src/java/com/juick/http/www/UserThread.java
+++ b/src/java/com/juick/http/www/UserThread.java
@@ -83,11 +83,6 @@ public class UserThread {
out.println("</div>");
out.println("</div>"); // topwrapper
- out.println("<script type=\"text/javascript\">");
- out.println("$(document).ready(unfoldReply);");
- out.println("$(window).bind('hashchange',unfoldReply);");
- out.println("</script>");
-
PageTemplates.pageFooter(request, out, locale, visitor);
} finally {
out.close();
@@ -150,16 +145,13 @@ public class UserThread {
if (rs.getString(11).equals("jpg")) {
out.println(" <div class=\"msg-media\"><a href=\"http://i.juick.com/p/" + mid + ".jpg\"><img src=\"http://i.juick.com/photos-512/" + mid + ".jpg\" alt=\"\"/></a></div>");
} else {
- out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + mid + ".mp4\">Video</a></b></div></div>");
- out.println(" <script type=\"text/javascript\">");
- out.println(" inlinevideo(" + mid + ");");
- out.println(" </script>");
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + mid + "\"><a href=\"http://i.juick.com/video/" + mid + ".mp4\" onclick=\"inlinevideo(" + mid + "); return false\"><img src=\"http://i.juick.com/thumbs/" + mid + ".jpg\" alt=\"\"/></a></div></div>");
}
}
if (cancomment) {
out.println(" <form action=\"/post\" method=\"POST\" enctype=\"multipart/form-data\"><input type=\"hidden\" name=\"mid\" value=\"" + mid + "\"/>");
- out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\""+rb.getString("Add a comment")+"\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
+ out.println(" <div class=\"msg-comment\"><textarea name=\"body\" rows=\"1\" class=\"reply\" placeholder=\"" + rb.getString("Add a comment") + "\" onkeypress=\"postformListener(this.form,event)\"></textarea></div>");
out.println(" </form>");
}
@@ -238,10 +230,10 @@ public class UserThread {
if (listview) {
out.print("<a href=\"?view=tree\">" + rbuser.getString("View as tree") + "</a>");
} else {
- out.print("<a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); return false\">" + rbuser.getString("Expand all") + "</a> &#183; <a href=\"?view=list\">" + rbuser.getString("View as list") + "</a>");
+ out.print("<span id=\"unfoldall\"><a href=\"#\" onclick=\"$('#replies>li').show(); $('#replies .msg-comments').hide(); $('#unfoldall').hide(); return false\">" + rbuser.getString("Expand all") + "</a> &#183; </span><a href=\"?view=list\">" + rbuser.getString("View as list") + "</a>");
}
out.print("</div>");
- out.println(" <h2>"+rbuser.getString("Replies")+" (" + replies.size() + ")</h2>");
+ out.println(" <h2>" + rbuser.getString("Replies") + " (" + replies.size() + ")</h2>");
out.println("</div>");
out.println("<ul id=\"replies\">");
@@ -282,10 +274,7 @@ public class UserThread {
if (msg.AttachmentType.equals("jpg")) {
out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></div>");
} else {
- out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\">Video</a></b></div></div>");
- out.println(" <script type=\"text/javascript\">");
- out.println(" inlinevideo('" + msg.MID + "-" + msg.RID + "');");
- out.println(" </script>");
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\" onclick=\"inlinevideo(" + msg.MID + "-" + msg.RID + "); return false\"><img src=\"http://i.juick.com/thumbs/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></a></div></div>");
}
}
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"http://i.juick.com/a/" + msg.User.UID + ".png\" alt=\"" + msg.User.UName + "\"/></a></div>");
@@ -318,10 +307,7 @@ public class UserThread {
if (msg.AttachmentType.equals("jpg")) {
out.println(" <div class=\"msg-media\"><img src=\"http://i.juick.com/photos-512/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></div>");
} else {
- out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><b>Attachment: <a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\">Video</a></b></div></div>");
- out.println(" <script type=\"text/javascript\">");
- out.println(" inlinevideo('" + msg.MID + "-" + msg.RID + "');");
- out.println(" </script>");
+ out.println(" <div class=\"msg-media\"><div id=\"video-" + msg.MID + "-" + msg.RID + "\"><a href=\"http://i.juick.com/video/" + msg.MID + "-" + msg.RID + ".mp4\" onclick=\"inlinevideo(" + msg.MID + "-" + msg.RID + "); return false\"><img src=\"http://i.juick.com/thumbs/" + msg.MID + "-" + msg.RID + ".jpg\" alt=\"\"/></a></div></div>");
}
}
out.println(" <div class=\"msg-avatar\"><a href=\"/" + msg.User.UName + "/\"><img src=\"http://i.juick.com/a/" + msg.User.UID + ".png\"></a></div>");
diff --git a/web/scripts3.js b/web/scripts3.js
index 13686067..853734ed 100644
--- a/web/scripts3.js
+++ b/web/scripts3.js
@@ -2,12 +2,13 @@ function inlinevideo(mid) {
var flashvars={
file:'http://i.juick.com/video/'+mid+'.mp4',
image:'http://i.juick.com/thumbs/'+mid+'.jpg',
- skin:'http://static.juick.com/glow.zip'
+ skin:'http://static.juick.com/glow.zip',
+ autostart:'true'
};
var params={
allowfullscreen:'true'
};
- swfobject.embedSWF('http://static.juick.com/player.swf','video-'+mid,'640','390','9.0.115','false',flashvars,params,null);
+ swfobject.embedSWF('http://static.juick.com/player.swf','video-'+mid,'512','384','9.0.115','false',flashvars,params,null);
}
function postformListener(formEl,ev) {
@@ -62,33 +63,6 @@ function unfoldReply() {
}
}
-$(document).ready(function() {
- var tareply=$('textarea.reply');
- tareply.autoResize({
- extraSpace: 0,
- minHeight: 1
- });
- tareply.click(function () {
- $(this).addClass("narrow");
- $(this).after('<input type="submit" value="OK"/>');
- $(this).off('click');
- });
-
- if(!!$('.stickya').offset()) {
- var stickyTop = $('.stickya').offset().top;
- $(window).scroll(function() {
- var windowTop = $(window).scrollTop();
- if (stickyTop < windowTop) {
- $('.stickya').css({
- position:'fixed'
- });
- } else {
- $('.stickya').css('position','absolute');
- }
- });
- }
-});
-
/*
* jQuery.fn.autoResize 1.14
*/
@@ -364,3 +338,35 @@ $(document).ready(function() {
};
})(jQuery);
+
+/******************************************************************************/
+
+$(document).ready(function() {
+ var tareply=$('textarea.reply');
+ tareply.autoResize({
+ extraSpace: 0,
+ minHeight: 1
+ });
+ tareply.click(function () {
+ $(this).addClass("narrow");
+ $(this).after('<input type="submit" value="OK"/>');
+ $(this).off('click');
+ });
+
+ if(!!$('.stickya').offset()) {
+ var stickyTop = $('.stickya').offset().top;
+ $(window).scroll(function() {
+ var windowTop = $(window).scrollTop();
+ if (stickyTop < windowTop) {
+ $('.stickya').css({
+ position:'fixed'
+ });
+ } else {
+ $('.stickya').css('position','absolute');
+ }
+ });
+ }
+
+ unfoldReply();
+ $(window).bind('hashchange',unfoldReply);
+});
diff --git a/web/style3.css b/web/style3.css
index ea2fca98..e528454f 100644
--- a/web/style3.css
+++ b/web/style3.css
@@ -1,5 +1,5 @@
html,body,h1,h2,ul,li,form,input,textarea { margin: 0; padding: 0; }
-html { font-family: sans-serif; font-size: 16px; }
+html,input { font-family: sans-serif; font-size: 12pt; }
h1,h2 { font-weight: normal; }
ul { list-style-type: none; }
a { text-decoration: none; }
@@ -63,7 +63,7 @@ img { border: none; }
#content .msg-links { font-size: small; margin: 8px 0 0 68px; }
#content .msg-comments { margin: 10px 0 0 58px; padding: 5px 0 0 10px; overflow: hidden; font-size: small; border-top: 1px solid; }
#content .msg-comment { margin: 8px 0 0 58px; }
-#content .msg-comment textarea { border: 1px solid; width: 505px; padding: 2px; resize: vertical; vertical-align: top; }
+#content .msg-comment textarea { border: 1px solid; width: 505px; padding: 2px; resize: vertical; vertical-align: top; min-height: 12pt; height: 12pt; }
#content .msg-comment textarea.narrow { width: 450px; }
#content .msg-comment input { border: 1px solid; width: 50px; margin-left: 6px; vertical-align: top; }
#content .msg-recomms { margin: 10px 0 0 68px; padding: 0; overflow: hidden; font-size: small; }