~spreadubuntu/spreadubuntu/devel-drupal6

« back to all changes in this revision

Viewing changes to modules/og/modules/og_access/og_access.js

  • Committer: ruben
  • Date: 2009-06-08 09:38:49 UTC
  • Revision ID: ruben@captive-20090608093849-s1qtsyctv2vwp1x1
SpreadUbuntu moving to Drupal6. Based on ubuntu-drupal theme and adding our modules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Node authoring form for group posts
 
2
Drupal.behaviors.og_access_group_post = function() {
 
3
  
 
4
  /* Node authoring form for group content -Disable the public checkbox if no groups are selected in in Audience */
 
5
    $('.og-audience').click(function() {
 
6
      // Audience can be checkboxes, a simple select, or have optgroup (optgroups busted ATM. help wanted)
 
7
      var cnt;
 
8
      if ( $('.og-audience .form-checkbox').size() > 0) {
 
9
        cnt = $('input.og-audience:checked').size();  
 
10
      }
 
11
      else {
 
12
        cnt = $('.og-audience option:selected').size();      
 
13
      }
 
14
      if (cnt > 0 && !$("#edit-og-directory:checked").val()) {
 
15
        $('#edit-og-public').removeAttr("disabled");
 
16
      }
 
17
      else {
 
18
        $('#edit-og-public').attr("disabled", "disabled");
 
19
      }
 
20
    });
 
21
 
 
22
    // Set initial value
 
23
    if ( $('.og-audience .form-checkbox').size() > 0 ) {
 
24
      // The checkbox way of showing audience.      
 
25
      if ( $('input.og-audience:checked').size() < 1) {
 
26
        $('#edit-og-public').attr("disabled", "disabled");
 
27
      }    
 
28
    }
 
29
    else {
 
30
      // The select way of showing audience.
 
31
      if ($('.og-audience option').size() > 0 && $('.og-audience option:selected').size() < 1) {
 
32
        $('#edit-og-public').attr("disabled", "disabled");
 
33
      }        
 
34
    }
 
35
}
 
36
 
 
37
 
 
38
// Node authoring form for group homepages
 
39
Drupal.behaviors.og_access_group_node = function() {
 
40
    /* Don't allow "private group" and "Open subscription" at the same time 
 
41
     * This is just for improved UI. You may change it if you need this combination.
 
42
     */
 
43
    $("#edit-og-private").click(function() { 
 
44
      if ($("#edit-og-private:checked").val()) {
 
45
        $("input[@Name='og_selective']:nth(0)").removeAttr('checked').attr('disabled','disabled');
 
46
      }
 
47
      else {
 
48
        $("input[@Name='og_selective']:nth(0)").removeAttr('disabled');
 
49
      }
 
50
    });
 
51
 
 
52
    $("input[@Name='og_selective']").click(function() {
 
53
        // If Open is selected.
 
54
        if ($("input[@Name='og_selective']:checked").val() == 0) {
 
55
          $("#edit-og-private").removeAttr("checked").attr('disabled','disabled');
 
56
        }
 
57
        else {
 
58
          $("#edit-og-private").removeAttr("disabled");
 
59
        }
 
60
    });
 
61
 
 
62
    if ($("#edit-og-private:checked").val()) {
 
63
        $("input[@Name='og_selective']:nth(0)").removeAttr('checked').attr('disabled','disabled');
 
64
    }
 
65
    
 
66
    $("#edit-og-private").click(function() { 
 
67
      if ($("#edit-og-private:checked").val()) {
 
68
        $("#edit-og-directory").removeAttr("checked").attr('disabled','disabled');
 
69
      }
 
70
      else {
 
71
        $("#edit-og-directory").removeAttr('disabled');
 
72
      }
 
73
    });
 
74
 
 
75
    /*
 
76
     * Don't allow "private group" and "list in groups directory" at the same time 
 
77
     * This is just for improved UI. You may change it if you need this combination.
 
78
     */
 
79
    $("#edit-og-directory").click(function() {
 
80
      if ($("#edit-og-directory:checked").val()) {
 
81
        $("#edit-og-private").attr('disabled','disabled');
 
82
      }
 
83
      else {
 
84
        $("#edit-og-private").removeAttr('disabled');
 
85
      }
 
86
    });
 
87
    
 
88
    if ($("#edit-og-directory:checked").val() && !$("#edit-og-private:checked").val()) {
 
89
        $("#edit-og-private").attr('disabled','disabled');
 
90
    }
 
91
    if ($("#edit-og-private:checked").val() && !$("#edit-og-directory:checked").val()) {
 
92
        $("#edit-og-directory").attr('disabled','disabled');
 
93
    }
 
94
}
 
95
  
 
96
    
 
97
  /* admin og settings form, "Node Authoring Form - Visibilty of Posts"
 
98
   * Disable "Visible within the targeted groups and on other pages" if private groups set to "always private"
 
99
   * Disable "Visible only within the targeted groups" if private groups set to "always public"
 
100
   */
 
101
Drupal.behaviors.og_access_admin_settings = function() {
 
102
  $("input[@Name='og_private_groups']").click(function() {
 
103
      if ( $("input[@Name='og_private_groups']:checked").val() == 1 ) {
 
104
        $("input[@name='og_visibility']:nth(0)").removeAttr('disabled');
 
105
        $("input[@name='og_visibility']:nth(1)").attr('disabled','disabled');
 
106
      }
 
107
      else if ( $("input[@Name='og_private_groups']:checked").val() == 0 ) {
 
108
        $("input[@name='og_visibility']:nth(0)").attr('disabled','disabled');
 
109
        $("input[@name='og_visibility']:nth(1)").removeAttr('disabled');  
 
110
      }
 
111
      else { 
 
112
        $("input[@name='og_visibility']:nth(0)").removeAttr('disabled');  
 
113
        $("input[@name='og_visibility']:nth(1)").removeAttr('disabled');  
 
114
      }
 
115
    }
 
116
  );
 
117
 
 
118
  // Set intial value.
 
119
  if ( $("input[@Name='og_private_groups']:checked").val() == 1 ) {
 
120
    $("input[@name='og_visibility']:nth(0)").removeAttr('disabled');
 
121
    $("input[@name='og_visibility']:nth(1)").attr('disabled','disabled');
 
122
  }
 
123
  else if ( $("input[@Name='og_private_groups']:checked").val() == 0 ) {
 
124
      $("input[@name='og_visibility']:nth(0)").attr('disabled','disabled');
 
125
      $("input[@name='og_visibility']:nth(1)").removeAttr('disabled');  
 
126
  }
 
127
  
 
128
    /* "Group details - Private Groups"
 
129
     * Disable "always public" if Node authoring visibility set to "Visible only within the targeted groups"
 
130
     * Disable "always private" if Node authoring visibility set to "Visible within the targeted groups and on other pages"
 
131
     */
 
132
    $("input[@Name='og_visibility']").click(function() {
 
133
      if ($("input[@Name='og_visibility']:checked").val() == 0) {
 
134
          $("input[@name='og_private_groups']:nth(0)").attr('disabled','disabled');
 
135
          $("input[@name='og_private_groups']:nth(1)").removeAttr('disabled');
 
136
        }
 
137
        else if ($("input[@Name='og_visibility']:checked").val() == 1) {
 
138
          $("input[@name='og_private_groups']:nth(0)").removeAttr('disabled');
 
139
          $("input[@name='og_private_groups']:nth(1)").attr('disabled','disabled');
 
140
        } 
 
141
        else {
 
142
          $("input[@name='og_private_groups']:nth(0)").removeAttr('disabled');
 
143
          $("input[@name='og_private_groups']:nth(1)").removeAttr('disabled');
 
144
        }
 
145
      }
 
146
    );
 
147
 
 
148
    // Set initial value.
 
149
    if ($("input[@Name='og_visibility']:checked").val() == 0) {
 
150
        $("input[@name='og_private_groups']:nth(0)").attr('disabled','disabled');
 
151
        $("input[@name='og_private_groups']:nth(1)").removeAttr('disabled');
 
152
    }
 
153
    else if ($("input[@Name='og_visibility']:checked").val() == 1) {
 
154
        $("input[@name='og_private_groups']:nth(0)").removeAttr('disabled');
 
155
        $("input[@name='og_private_groups']:nth(1)").attr('disabled','disabled');     
 
156
    }
 
157
};
 
 
b'\\ No newline at end of file'