public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Slava Bacherikov" <slava@bacherikov.org.ua>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/templatetags/, gpackages/static/js/, ...
Date: Sat, 14 Jul 2012 20:15:35 +0000 (UTC)	[thread overview]
Message-ID: <1342296505.223727ad8d3d091bfc580750b3abf00727bf901e.bacher09@gentoo> (raw)

commit:     223727ad8d3d091bfc580750b3abf00727bf901e
Author:     Slava Bacherikov <slava <AT> bacher09 <DOT> org>
AuthorDate: Sat Jul 14 20:08:25 2012 +0000
Commit:     Slava Bacherikov <slava <AT> bacherikov <DOT> org <DOT> ua>
CommitDate: Sat Jul 14 20:08:25 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoo-packages.git;a=commit;h=223727ad

Add filtering modal

---
 gpackages/apps/packages/templatetags/packages.py |    7 +++-
 gpackages/static/js/modals.js                    |   53 ++++++++++++++++------
 gpackages/templates/base.html                    |    8 +++-
 gpackages/templates/filtering_modal.html         |   24 ++++++++++
 4 files changed, 75 insertions(+), 17 deletions(-)

diff --git a/gpackages/apps/packages/templatetags/packages.py b/gpackages/apps/packages/templatetags/packages.py
index ed70efe..62e067a 100644
--- a/gpackages/apps/packages/templatetags/packages.py
+++ b/gpackages/apps/packages/templatetags/packages.py
@@ -5,7 +5,7 @@ register = template.Library()
 
 from ..models import RepositoryModel, EbuildModel
 from ..views import arches
-from ..forms import ArchChoiceForm
+from ..forms import ArchChoiceForm, FilteringForm
 
 @register.inclusion_tag('last_updated.html')
 def last_updated():
@@ -46,3 +46,8 @@ def arch_choice_modal(context):
     arches_s = arches_s or arches
     return {'form': ArchChoiceForm(initial = {'arches': arches_s}),
             'arches': arches_s}
+
+@register.inclusion_tag('filtering_modal.html')
+def filtering_modal():
+    form = FilteringForm()
+    return {'form': form }

diff --git a/gpackages/static/js/modals.js b/gpackages/static/js/modals.js
index 93847ac..77c4813 100644
--- a/gpackages/static/js/modals.js
+++ b/gpackages/static/js/modals.js
@@ -1,7 +1,7 @@
-
+var ModalsShow  = function(link_id_l, modal_id_l){
     var old_link = window.location.pathname;
-    function show_modal(modal){
 
+    function show_modal(modal){
         modal.modal("show");
         modal.on('hide', function(){
             modal.off("hide");
@@ -14,23 +14,48 @@
         modal.off('hide');
         modal.modal('hide');
     }
+    function obj_cache(){
+        var list = []
+        for(var i=0; i<modal_id_l.length; i++){
+            list[i] = $('#' + modal_id_l[i]);
+        }
+        return list;
+    }
 
-    $('#archchoice').click(function(e){
-        e.preventDefault();
-        var modal = $('#ArchModal');
-        show_modal(modal);
-        var obj = $(this).first()[0];
-        var link = obj.href;
-        history.pushState({modal: 'arch'}, null, link);
-        return false;
-    });
+    var list_m = obj_cache();
+
+    function set_event(modal, link_selector, modal_id){
+        $(link_selector).click(function(e){
+            e.preventDefault();
+            show_modal(modal);
+            var obj = $(this)[0];
+            var link = obj.href;
+            history.pushState({modal: modal_id}, null, link);
+            return false;
+        });
+    }
+
+    function set_events(){
+       for(var i=0; i<link_id_l.length; i++){  
+            set_event(list_m[i], '#' + link_id_l[i], modal_id_l[i]);
+        }
+    }
+
+    set_events();
 
     $(window).on('popstate', function(){
         var current = history.state;
-        var modal = $('#ArchModal');
-        if(current && 'modal' in current && current.modal == 'arch'){
+        if(current && 'modal' in current && current.modal){
+            var modal = list_m[modal_id_l.indexOf(current.modal)];
             show_modal(modal);
         } else {
-            hide_modal(modal);
+            for(var i=0;i<list_m.length;i++){
+                hide_modal(list_m[i]);
+            }
         }
     });
+}
+
+$(function() {
+    ModalsShow(['archchoice', 'filterchoice'], ['ArchModal', 'FilterModal']);
+});

diff --git a/gpackages/templates/base.html b/gpackages/templates/base.html
index 748055f..3fb010f 100644
--- a/gpackages/templates/base.html
+++ b/gpackages/templates/base.html
@@ -116,7 +116,7 @@
                             {% active_link 'local_uses' 'Local Use Flags' %}
                             {% active_link 'archchoice' 'Select Arches' id='archchoice' %}
                             {% active_link 'licenses' 'Licenses' %}
-                            {% active_link 'filter' 'Filter' %}
+                            {% active_link 'filter' 'Filter' id='filterchoice' %}
                         </ul>
                        </div>
                        {% recent_ebuilds %}
@@ -144,7 +144,11 @@
         <script src="{{ STATIC_URL }}js/packages_details.js"></script>
         <script src="{{ STATIC_URL }}js/modals.js"></script>
     {% endblock scripts %}
-{% arch_choice_modal %}
+
+    {% block modals %}
+        {% arch_choice_modal %}
+        {% filtering_modal %}
+    {% endblock modals %}
 {% endblock body %}
   </body>
 </html>

diff --git a/gpackages/templates/filtering_modal.html b/gpackages/templates/filtering_modal.html
new file mode 100644
index 0000000..66719e7
--- /dev/null
+++ b/gpackages/templates/filtering_modal.html
@@ -0,0 +1,24 @@
+{% load url from future %}
+{% load static %}
+{% get_static_prefix as STATIC_URL %}
+<div class="modal hide fade" id="FilterModal">
+    <div class="modal-header">
+        <button type="button" class="close" data-dismiss="modal">×</button>
+        <h3>Filter</h3>
+    </div>
+    <form action="{% url 'filter' %}" method="post" enctype="multipart/form-data">
+        {% csrf_token %}
+        <div class="modal-body filter">
+            {{ form.as_ul }} 
+        </div>
+        <div class="modal-footer">
+            <a href="#" class="btn" data-dismiss="modal">Close</a>
+            <input type="submit" class="btn btn-primary" value="Submit" />
+        </div>
+    </form>
+</div>
+<link href="{{ STATIC_URL }}css/chosen.css" rel="stylesheet">
+<script src="{{ STATIC_URL }}js/chosen.jquery.js"></script>
+<script type="text/javascript" charset="utf-8">
+    $('select').chosen(); // :)
+</script>



             reply	other threads:[~2012-07-14 20:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-14 20:15 Slava Bacherikov [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-07-14 20:15 [gentoo-commits] proj/gentoo-packages:master commit in: gpackages/apps/packages/templatetags/, gpackages/static/js/, Slava Bacherikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342296505.223727ad8d3d091bfc580750b3abf00727bf901e.bacher09@gentoo \
    --to=slava@bacherikov.org.ua \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox