Projet

Général

Profil

Révision 599a39cd

Ajouté par Assos Assos il y a environ 3 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/date/date_admin.js
1
/**
2
 * @file
3
 */
1 4
(function ($) {
2 5

  
3
Drupal.behaviors.dateAdmin = {};
6
  Drupal.behaviors.dateAdmin = {};
4 7

  
5
Drupal.behaviors.dateAdmin.attach = function (context, settings) {
6
  // Remove timezone handling options for fields without hours granularity.
7
  var $hour = $('#edit-field-settings-granularity-hour').once('date-admin');
8
  if ($hour.length) {
9
    new Drupal.dateAdmin.TimezoneHandler($hour);
10
  }
11
};
8
  Drupal.behaviors.dateAdmin.attach = function (context, settings) {
9
    // Remove timezone handling options for fields without hours granularity.
10
    var $hour = $('#edit-field-settings-granularity-hour').once('date-admin');
11
    if ($hour.length) {
12
      new Drupal.dateAdmin.TimezoneHandler($hour);
13
    }
14
  };
12 15

  
16
  Drupal.dateAdmin = {};
13 17

  
14
Drupal.dateAdmin = {};
15

  
16
/**
18
  /**
17 19
 * Constructor for the TimezoneHandler object.
18 20
 *
19 21
 * This object is responsible for showing the timezone handling options dropdown
20 22
 * when the user has chosen to collect hours as part of the date field, and
21 23
 * hiding it otherwise.
22 24
 */
23
Drupal.dateAdmin.TimezoneHandler = function ($checkbox) {
24
  this.$checkbox = $checkbox;
25
  this.$dropdown = $('#edit-field-settings-tz-handling');
26
  this.$timezoneDiv = $('.form-item-field-settings-tz-handling');
27
  // Store the initial value of the timezone handling dropdown.
28
  this.storeTimezoneHandling();
29
  // Toggle the timezone handling section when the user clicks the "Hour"
30
  // checkbox.
31
  this.$checkbox.bind('click', $.proxy(this.clickHandler, this));
32
  // Trigger the click handler so that if the checkbox is unchecked on initial
33
  // page load, the timezone handling section will be hidden.
34
  this.clickHandler();
35
};
25
  Drupal.dateAdmin.TimezoneHandler = function ($checkbox) {
26
    this.$checkbox = $checkbox;
27
    this.$dropdown = $('#edit-field-settings-tz-handling');
28
    this.$timezoneDiv = $('.form-item-field-settings-tz-handling');
29
    // Store the initial value of the timezone handling dropdown.
30
    this.storeTimezoneHandling();
31
    // Toggle the timezone handling section when the user clicks the "Hour"
32
    // checkbox.
33
    this.$checkbox.bind('click', $.proxy(this.clickHandler, this));
34
    // Trigger the click handler so that if the checkbox is unchecked on initial
35
    // page load, the timezone handling section will be hidden.
36
    this.clickHandler();
37
  };
36 38

  
37
/**
38
 * Event handler triggered when the user clicks the "Hour" checkbox.
39
 */
40
Drupal.dateAdmin.TimezoneHandler.prototype.clickHandler = function () {
41
  if (this.$checkbox.is(':checked')) {
42
    this.restoreTimezoneHandlingOptions();
43
  }
44
  else {
45
    this.hideTimezoneHandlingOptions();
46
  }
47
};
39
  /**
40
   * Event handler triggered when the user clicks the "Hour" checkbox.
41
   */
42
  Drupal.dateAdmin.TimezoneHandler.prototype.clickHandler = function () {
43
    if (this.$checkbox.is(':checked')) {
44
      this.restoreTimezoneHandlingOptions();
45
    }
46
    else {
47
      this.hideTimezoneHandlingOptions();
48
    }
49
  };
48 50

  
49
/**
50
 * Hide the timezone handling options section of the form.
51
 */
52
Drupal.dateAdmin.TimezoneHandler.prototype.hideTimezoneHandlingOptions = function () {
53
  this.storeTimezoneHandling();
54
  this.$dropdown.val('none');
55
  this.$timezoneDiv.hide();
56
};
51
  /**
52
   * Hide the timezone handling options section of the form.
53
   */
54
  Drupal.dateAdmin.TimezoneHandler.prototype.hideTimezoneHandlingOptions = function () {
55
    this.storeTimezoneHandling();
56
    this.$dropdown.val('none');
57
    this.$timezoneDiv.hide();
58
  };
57 59

  
58
/**
59
 * Show the timezone handling options section of the form.
60
 */
61
Drupal.dateAdmin.TimezoneHandler.prototype.restoreTimezoneHandlingOptions = function () {
62
  var val = this.getTimezoneHandling();
63
  this.$dropdown.val(val);
64
  this.$timezoneDiv.show();
65
};
60
  /**
61
   * Show the timezone handling options section of the form.
62
   */
63
  Drupal.dateAdmin.TimezoneHandler.prototype.restoreTimezoneHandlingOptions = function () {
64
    var val = this.getTimezoneHandling();
65
    this.$dropdown.val(val);
66
    this.$timezoneDiv.show();
67
  };
66 68

  
67
/**
68
 * Store the current value of the timezone handling dropdown.
69
 */
70
Drupal.dateAdmin.TimezoneHandler.prototype.storeTimezoneHandling = function () {
71
  this._timezoneHandling = this.$dropdown.val();
72
};
69
  /**
70
   * Store the current value of the timezone handling dropdown.
71
   */
72
  Drupal.dateAdmin.TimezoneHandler.prototype.storeTimezoneHandling = function () {
73
    this._timezoneHandling = this.$dropdown.val();
74
  };
73 75

  
74
/**
75
 * Return the stored value of the timezone handling dropdown.
76
 */
77
Drupal.dateAdmin.TimezoneHandler.prototype.getTimezoneHandling = function () {
78
  return this._timezoneHandling;
79
};
76
  /**
77
   * Return the stored value of the timezone handling dropdown.
78
   */
79
  Drupal.dateAdmin.TimezoneHandler.prototype.getTimezoneHandling = function () {
80
    return this._timezoneHandling;
81
  };
80 82

  
81 83
})(jQuery);

Formats disponibles : Unified diff