Bug fix for group create radios
authorOlga Brani <olgabrani@grnet.gr>
Fri, 9 Nov 2012 10:06:56 +0000 (12:06 +0200)
committerOlga Brani <olgabrani@grnet.gr>
Fri, 9 Nov 2012 10:06:56 +0000 (12:06 +0200)
snf-astakos-app/astakos/im/static/im/js/forms.js
snf-astakos-app/astakos/im/static/im/js/quotas.js
snf-astakos-app/astakos/im/templates/im/astakosgroup_form_demo.html
snf-astakos-app/astakos/im/templates/im/astakosgroup_list.html

index b5e39c1..ee5f153 100644 (file)
@@ -8,9 +8,11 @@
       var el = $('<a class="checkbox-widget" href="javascript:void(0)"/>');
       var form = $this.closest(".form-row");
          var className = $this.attr('class');
+         var isRadio = $this.hasClass('radio');
 
       // add class to identify form rows which contain a checkbox
       form.addClass("with-checkbox");
+
       
       if ($this.prev().length > 0) {
         var lbl = $this.prev()[0];
@@ -18,6 +20,7 @@
             $(lbl).addClass("checkbox-label");
 
             $(lbl).click(function(e){
+               if (isRadio && $this.attr('checked')){ return; }
                 var src = e.srcElement.nodeName;
                 if (src == "LABEL" || src == "label") {
                     el.toggleClass("checked"); 
@@ -38,7 +41,7 @@
          el.addClass(className);       
                
       el.click(function() {
-
+               if (isRadio && $this.attr('checked')){ return; }
         el.toggleClass("checked");
         $this.attr('checked', el.hasClass("checked"));
         $this.trigger('changed');
@@ -47,6 +50,7 @@
       el.keypress(function(e){
        
        if (e.keyCode == 0 || e.keyCode == 32){
+               if (isRadio && $this.attr('checked')){ return; }
                e.preventDefault();
                el.toggleClass("checked");
                $this.attr('checked', el.hasClass("checked"));
index e5e7709..729449f 100644 (file)
@@ -26,7 +26,7 @@ $(document).ready(function() {
                $(this).siblings('fieldset').find('.checkbox-widget.limited').removeClass('checked');
                $(this).siblings('fieldset').find('input[type="checkbox"].limited').removeAttr('checked');  
                $(this).siblings('fieldset').find('input[type="checkbox"].unlimited').attr('checked','checked');  
-               $(this).siblings('fieldset').find('.double-checks input[type="text"]').removeClass('hideshow');
+               $(this).siblings('fieldset').find('.double-checks input[type="text"]').hide();
                $(this).parents('.group').hide('slow', function() {
                    $(this).appendTo('.not-foo');       
                });
@@ -43,11 +43,15 @@ $(document).ready(function() {
         
                
        $('.quotas-form input.limited').bind("changed", function(e){
-               $(this).siblings('input[type="text"]').toggle();
-               $(this).siblings('input[type="text"]').focus();
-               parentdiv = $(this).parents('.form-row').prev('.form-row');
-               parentdiv.find('input[type="checkbox"].unlimited').removeAttr('checked');  
-               parentdiv.find('.checkbox-widget').removeClass('checked');
+               console.log($(this).attr('checked'));
+               if ($(this).attr('checked')){
+                       $(this).siblings('input[type="text"]').toggle();
+                       $(this).siblings('input[type="text"]').focus();
+                       parentdiv = $(this).parents('.form-row').prev('.form-row');
+                       parentdiv.find('input[type="checkbox"].unlimited').removeAttr('checked');  
+                       parentdiv.find('.checkbox-widget').removeClass('checked');
+               }
+               
                 
        });
        
index 679e431..e06a35e 100644 (file)
                                <div class="form-row">
                                        <p class="clearfix">
                                                <label for="{{r|add:'_unlimited'}}">Unlimited</label>
-                                               <input type="checkbox" id="{{'id_'|add:r|add:'_unlimited'}}" name="{{r|add:'_unlimited'}}" class="unlimited" checked="checked">
+                                               <input type="checkbox" id="{{'id_'|add:r|add:'_unlimited'}}" name="{{r|add:'_unlimited'}}" class="unlimited radio" checked="checked">
                                        </p>
                                </div>
                                <div class="form-row">
                                        <p class="clearfix">
                                                <label for="{{r|add:'_limited'}}">Limited</label>
-                                               <input type="checkbox" id="id_storage_per_user_limited" name="{{r|add:'_limited'}}" class="limited">
+                                               <input type="checkbox" id="id_storage_per_user_limited" name="{{r|add:'_limited'}}" class="radio limited">
                                                <input type="text" id="{{'id_'|add:r|add:'_uplimit'}}" name="{{r|add:'_uplimit'}}"/> 
                                        </p>
                                </div>
index 17b51e5..44f6aaf 100644 (file)
@@ -31,7 +31,7 @@
                                        <div>
                                                <div class="wrap">
                                                        <h2>WELCOME!</h2>
-                                                       <p  ><img alt="THINK ABOUT IT" src="/static/im/images/create.png"></p>
+                                                       <p><a href="{% url group_add 'course' %}"><img alt="THINK ABOUT IT" src="/static/im/images/create.png"></a></p>
                                                        <p class="txt">Connect with a world of people who share your passions.<br>With millions of groups at your fingertips, it's easy to find the group that's best for you -- no matter your interest.</p>
                                                        <p><a href="{% url group_add 'course' %}">create a group ></a></p>
                                                        <!--<p class="btn"><a href="{% url group_create_list %}" class="submit">CREATE</a></p>-->
@@ -42,7 +42,7 @@
                                        <div>
                                                <div class="wrap">
                                                        <h2>ALREADY AWARE?</h2>
-                                                       <p  ><img alt="THINK ABOUT IT" src="/static/im/images/join.png"></p>
+                                                       <p><a href="{% url group_add 'course' %}"><img alt="THINK ABOUT IT" src="/static/im/images/join.png"></a></p>
                                                        <p class="txt">Well, this is the place to start!<br>sdofuisd ofuaofi usdiof uiofu osifuaoi ufisdfiousf oiusd<br></p>
                                                        
                                                        <p><a href="{% url group_search %}">join a group ></a></p>