Browse files

JavaScript refactoring.

Load minified json2.js in prod.
Ignore new minified file.
Bump version.
Pull SortMyBox js files into own file.
  • Loading branch information...
1 parent 8117a71 commit 728a757f1e9432a673ca8fd9c77e369b689bf2a0 @mustpax committed Sep 11, 2012
Showing with 38 additions and 37 deletions.
  1. +1 −0 .jshintignore
  2. +0 −28 app/views/js-templates.html
  3. +1 −7 app/views/main.html
  4. +1 −1 makefile
  5. +34 −0 public/js/sortbox.js
  6. +1 −1 war/WEB-INF/appengine-web-template.xml
View
1 .jshintignore
@@ -4,6 +4,7 @@ public/js/bootstrap.min.js
public/js/jquery-1.7.2.js
public/js/jquery-1.7.2.min.js
public/js/json2.js
+public/js/json2.min.js
public/js/underscore-min.js
public/js/underscore.js
public/js/jquery-ui-1.8.20.custom.min.js
View
28 app/views/js-templates.html
@@ -86,31 +86,3 @@
</div>
</div>
</script>
-
-<script>
- _.templateSettings.escape = /\{\{(.+?)\}\}/g;
- !function($) {
- var templateCache = {};
-
- /**
- * Render the template with the given name into a jQuery
- * wrapped unattached DOM element.
- */
- function template(name, context) {
- var t = templateCache[name];
- if (! t) {
- var e = $('#' + name);
- if (! e.length) {
- throw 'Cannot find template with name: ' + name;
- }
-
- t = _.template(e.html());
- templateCache[name] = t;
- }
-
- return $(t(context));
- };
-
- sortbox.template = template;
- }(window.jQuery);
-</script>
View
8 app/views/main.html
@@ -77,20 +77,14 @@
<script src="#{static-path '/public/js/jquery-1.7.2.js'/}"></script>
<script src="#{static-path '/public/js/bootstrap.js'/}"></script>
<script src="#{static-path '/public/js/jquery-ui-1.8.20.custom.js'/}"></script>
+ <script src="#{static-path '/public/js/sortbox.js'/}"></script>
#{/if}
#{else}
<script src="#{static-path '/public/js/all.js'/}"></script>
#{/else}
<script>
window.csrfToken = '${session.getAuthenticityToken().escapeJavaScript()}';
- window.sortbox = {};
- $(function() {
- $('.dropdown-toggle').dropdown();
- $('.easter').live('click', function() {
- $(this).append('<i class="icon-refresh spin"></i>');
- });
- });
</script>
#{include 'js-templates.html' /}
View
2 makefile
@@ -1,5 +1,5 @@
alljs = public/js/all.js
-jsfiles = public/js/json2.js public/js/jquery-1.7.2.min.js public/js/bootstrap.min.js public/js/underscore-min.js public/js/jquery-ui-1.8.20.custom.min.js
+jsfiles = public/js/json2.min.js public/js/jquery-1.7.2.min.js public/js/bootstrap.min.js public/js/underscore-min.js public/js/jquery-ui-1.8.20.custom.min.js public/js/sortbox.js
playgae = submodules/play-gae/lib/play-gae.jar
play = submodules/play/framework/play-local.jar
View
34 public/js/sortbox.js
@@ -0,0 +1,34 @@
+(function($) {
+ 'use strict';
+
+ var templateCache = {},
+ sortbox = {};
+
+ window.sortbox = sortbox;
+ _.templateSettings.escape = /\{\{(.+?)\}\}/g;
+
+ /**
+ * Render the template with the given name into a jQuery
+ * wrapped unattached DOM element.
+ */
+ function template(name, context) {
+ var t = templateCache[name];
+ if (! t) {
+ var e = $('#' + name);
+ if (! e.length) {
+ throw 'Cannot find template with name: ' + name;
+ }
+
+ t = _.template(e.html());
+ templateCache[name] = t;
+ }
+
+ return $(t(context));
+ }
+ sortbox.template = template;
+
+ $('.dropdown-toggle').dropdown();
+ $('.easter').live('click', function() {
+ $(this).append('<i class="icon-refresh spin"></i>');
+ });
+})(window.jQuery);
View
2 war/WEB-INF/appengine-web-template.xml
@@ -1,6 +1,6 @@
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
<application>sortmybox-hrd</application>
- <version>11-6-{suffix}</version>
+ <version>11-7-{suffix}</version>
<threadsafe>true</threadsafe>
<system-properties>
<property name="app.id" value="prod" />

0 comments on commit 728a757

Please sign in to comment.