[extensions-web] Put review main in its own file, not embedded in the document-ready handler



commit 239fa6716c23c6293f446afb642b439d3e91359c
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Sun Nov 13 22:54:03 2011 -0500

    Put review main in its own file, not embedded in the document-ready handler
    
    We want to remove the document-ready handler stuff

 sweettooth/review/templates/review/review.html |   11 ++---------
 sweettooth/static/js/review-main.js            |   10 ++++++++++
 sweettooth/static/js/review.js                 |    3 ++-
 sweettooth/templates/base.html                 |    2 +-
 4 files changed, 15 insertions(+), 11 deletions(-)
---
diff --git a/sweettooth/review/templates/review/review.html b/sweettooth/review/templates/review/review.html
index 58ff297..12c0b79 100644
--- a/sweettooth/review/templates/review/review.html
+++ b/sweettooth/review/templates/review/review.html
@@ -28,7 +28,7 @@
 </div>
 
 <h2 class="expanded"> Files </h2>
-<div id="files">
+<div id="files" data-fileurl="{% url review-ajax-files pk=version.pk %}">
 </div>
 
 <h2 class="expanded"> Previous Versions </h2>
@@ -80,14 +80,7 @@
 
 {% endblock %}
 
-{% block document-ready %}
-  require(['review', 'switch'], function() {
-    $("#files").reviewify("{% url review-ajax-files pk=version.pk %}");
-  });
-  $("h2").click(function() {
-    $(this).toggleClass("expanded").next().slideToggle();
-  }).not(".expanded").next().hide();
-{% endblock %}
+{% block js-main %}review{% endblock %}
 
 {% block head %}
   {{ block.super }}
diff --git a/sweettooth/static/js/review-main.js b/sweettooth/static/js/review-main.js
new file mode 100644
index 0000000..3fd5033
--- /dev/null
+++ b/sweettooth/static/js/review-main.js
@@ -0,0 +1,10 @@
+"use strict";
+
+require(['jquery', 'main', 'review'], function($) {
+    $(document).ready(function() {
+        $("#files").reviewify();
+        $("h2").click(function() {
+            $(this).toggleClass("expanded").next().slideToggle();
+        }).not(".expanded").next().hide();
+    });
+});
diff --git a/sweettooth/static/js/review.js b/sweettooth/static/js/review.js
index e586168..35ea99a 100644
--- a/sweettooth/static/js/review.js
+++ b/sweettooth/static/js/review.js
@@ -32,9 +32,10 @@ define(['jquery'], function($) {
         return $table;
     }
 
-    $.fn.reviewify = function(fileurl) {
+    $.fn.reviewify = function() {
         var $elem = $(this);
         var $fileList = $('<ul>', {'class': 'filelist'}).appendTo($elem);
+        var fileurl = $elem.data('fileurl');
 
         // Hide the file list until we're done grabbing all the elements.
         $fileList.hide();
diff --git a/sweettooth/templates/base.html b/sweettooth/templates/base.html
index 268c5b9..0e59e12 100644
--- a/sweettooth/templates/base.html
+++ b/sweettooth/templates/base.html
@@ -12,7 +12,7 @@ window._SW = function() {
 };
     </script>
     <script src="/static/js/jquery.js"></script>
-    <script data-main="/static/js/main.js" src="/static/js/require.js"></script>
+    <script data-main="/static/js/{% block js-main %}main{% endblock %}.js" src="/static/js/require.js"></script>
   </head>
   <body>
     <div id="global_domain_bar">



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]