PageSourceSearch

https://libreriamedievale.com/sites/all/modules/ubercart/uc_roles/uc_roles.js?Z

js libreriamedievale.com collected 2026-09-25 00:53:45 UTC 6,145 bytes, 154 lines download raw bytes

1
2/**
3 * @file
4 * Enables and disables expiration fields to prevent invalid configurations.
5 */
6
7/**
8 * Disables duration amount when its type is "never".
9 */
10function _uc_role_expiration_disable_check(granularity, quantity) {
11  // 'never' means there's no point in setting a duration.
12  if ($(granularity).val() == 'never') {
13    $(quantity).attr('disabled', 'disabled').val('');
14  }
15  // Anything besides 'never' should enable setting a duration.
16  else {
17    $(quantity).removeAttr('disabled');
18  }
19}
20
21/**
22 * Switch between relative and absolute expiration durations.
23 */
24function expiration_switcher() {
25  if ($('#edit-expiration').val() == 'abs') {
26    $("#edit-uc-roles-expire-relative-duration-wrapper").hide();
27    $("#edit-uc-roles-expire-relative-granularity-wrapper").hide();
28    $("#edit-uc-roles-by-quantity-wrapper").hide();
29    $("#edit-uc-roles-expire-absolute-wrapper").show();
30  }
31  else {
32    $("#edit-uc-roles-expire-absolute-wrapper").hide();
33    $("#edit-uc-roles-expire-relative-duration-wrapper").show();
34    $("#edit-uc-roles-expire-relative-granularity-wrapper").show();
35    $("#edit-uc-roles-by-quantity-wrapper").show();
36  }
37}
38
39/**
40 * Set the default state for expiration duration.
41 */
42function expiration_switcher_default() {
43  if ($('#edit-uc-roles-default-end-expiration').val() == 'abs') {
44    $("#edit-uc-roles-default-length-wrapper").attr('style', 'display:none;');
45    $("#edit-uc-roles-default-granularity-wrapper").attr('style', 'display:none;');
46    $("#edit-uc-roles-default-by-quantity-wrapper").attr('style', 'display:none;');
47    $("#edit-uc-roles-default-end-time-wrapper").removeAttr('style');
48  }
49  else {
50    $("#edit-uc-roles-default-length-wrapper").removeAttr('style');
51    $("#edit-uc-roles-default-granularity-wrapper").removeAttr('style');
52    $("#edit-uc-roles-default-by-quantity-wrapper").removeAttr('style');
53    $("#edit-uc-roles-default-end-time-wrapper").attr('style', 'display:none;');
54  }
55}
56
57/**
58 * Override the expiration duration default state.
59 */
60function uc_roles_expiration_default_override() {
61  if ($('#edit-end-override').length == 0) {
62    return;
63  }
64
65  if ($('#edit-end-override').attr('checked')) {
66    $('#edit-expiration-wrapper').removeAttr('style');
67    $('#edit-uc-roles-expire-absolute-wrapper').removeAttr('style');
68    $('#edit-uc-roles-expire-relative-duration-wrapper').removeAttr('style');
69    $('#edit-uc-roles-expire-relative-granularity-wrapper').removeAttr('style');
70    $('#edit-uc-roles-by-quantity-wrapper').removeAttr('style');
71    expiration_switcher();
72  }
73  else {
74    $('#edit-expiration-wrapper').attr('style', 'display:none;');
75    $('#edit-uc-roles-expire-relative-duration-wrapper').attr('style', 'display:none;');
76    $('#edit-uc-roles-expire-relative-granularity-wrapper').attr('style', 'display:none;');
77    $('#edit-uc-roles-by-quantity-wrapper').attr('style', 'display:none;');
78    $('#edit-uc-roles-expire-absolute-wrapper').attr('style', 'display:none;');
79  }
80}
81
82$(document).ready(
83  function() {
84    _uc_role_expiration_disable_check('#edit-uc-roles-expire-relative-granularity', '#edit-uc-roles-expire-relative-duration');
85    _uc_role_expiration_disable_check('#edit-uc-roles-default-granularity', '#edit-uc-roles-default-length');
86    _uc_role_expiration_disable_check('#edit-uc-roles-reminder-granularity', '#edit-uc-roles-reminder-length');
87    uc_roles_expiration_default_override();
88    expiration_switcher_default();
89  }
90);
91
92// When you change the role expiration time select.
93Drupal.behaviors.ucRoleExpirationTime = function(context) {
94  $("#edit-expiration:not(.ucRoleExpirationTime-processed)", context).addClass('ucRoleExpirationTime-processed').change(
95    function() {
96      expiration_switcher();
97    }
98  );
99}
100
101// When you change the default role expiration time select.
102Drupal.behaviors.ucRoleDefaultExpirationTimeDefault = function(context) {
103  $("#edit-uc-roles-default-end-expiration:not(.ucRoleDefaultExpirationTimeDefault-processed)", context).addClass('ucRoleDefaultExpirationTimeDefault-processed').change(
104    function() {
105      expiration_switcher_default();
106    }
107  );
108}
109
110// When you change the role expiration time select.
111Drupal.behaviors.ucRoleExpirationTimeDefault = function(context) {
112  $("#edit-uc-roles-end-expiration:not(.ucRoleExpirationTimeDefault-processed)", context).addClass('ucRoleExpirationTimeDefault-processed').change(
113    function() {
114      expiration_switcher_default();
115    }
116  );
117}
118
119// When you change the role expiration granularity select.
120Drupal.behaviors.ucRoleExpirationGranularity = function(context) {
121  $('#edit-uc-roles-expire-relative-granularity:not(.ucRoleExpirationGranularity-processed)', context).addClass('ucRoleExpirationGranularity-processed').change(
122    function() {
123      _uc_role_expiration_disable_check('#edit-uc-roles-expire-relative-granularity', '#edit-uc-roles-expire-relative-duration');
124    }
125  );
126}
127
128// When you change the default role expiration granularity select.
129Drupal.behaviors.ucRoleDefaultExpirationGranularity = function(context) {
130  $('#edit-uc-roles-default-granularity:not(.ucRoleDefaultExpirationGranularity-processed)', context).addClass('ucRoleDefaultExpirationGranularity-processed').change(
131    function() {
132      _uc_role_expiration_disable_check('#edit-uc-roles-default-granularity', '#edit-uc-roles-default-length');
133    }
134  );
135}
136
137// When you change the default role expiration granularity select.
138Drupal.behaviors.ucRoleReminderExpirationGranularity = function(context) {
139  $('#edit-uc-roles-reminder-granularity:not(.ucRoleReminderExpirationGranularity-processed)', context).addClass('ucRoleReminderExpirationGranularity-processed').change(
140    function() {
141      _uc_role_expiration_disable_check('#edit-uc-roles-reminder-granularity', '#edit-uc-roles-reminder-length');
142    }
143  );
144}
145
146// When you change the default role expiration granularity select.
147Drupal.behaviors.ucRoleExpirationEndOverride = function(context) {
148  $('#edit-end-override:not(.ucRoleExpirationEndOverride-processed)', context).addClass('ucRoleExpirationEndOverride-processed').click(
149    function() {
150      uc_roles_expiration_default_override();
151    }
152  );
153}
154

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.