Skip to content
Snippets Groups Projects
Commit 2c0a63e8 authored by Owen Bush's avatar Owen Bush
Browse files

JS coding standards cleanup

parent 23c3144e
No related branches found
No related tags found
No related merge requests found
/**
* @file
* Javascript functionality for the recurring events create form.
*/
(function ($) { (function ($) {
'use strict'; 'use strict';
...@@ -5,7 +10,7 @@ ...@@ -5,7 +10,7 @@
* Add weekday selection based on date range. * Add weekday selection based on date range.
*/ */
Drupal.behaviors.recurring_events_weekday_selection = { Drupal.behaviors.recurring_events_weekday_selection = {
attach: function(context, settings) { attach: function (context, settings) {
var weekdays = new Array(7); var weekdays = new Array(7);
weekdays[0] = "sunday"; weekdays[0] = "sunday";
weekdays[1] = "monday"; weekdays[1] = "monday";
...@@ -16,7 +21,7 @@ ...@@ -16,7 +21,7 @@
weekdays[6] = "saturday"; weekdays[6] = "saturday";
// When the weekly occurrence start date is changed. // When the weekly occurrence start date is changed.
$('#edit-weekly-recurring-date-0-value-date').on('change', function(event) { $('#edit-weekly-recurring-date-0-value-date').on('change', function (event) {
var value = $(this).val(); var value = $(this).val();
var date_parts = value.split('-'); var date_parts = value.split('-');
if (date_parts.length > 0) { if (date_parts.length > 0) {
...@@ -24,7 +29,7 @@ ...@@ -24,7 +29,7 @@
var weekday = weekdays[date.getDay()]; var weekday = weekdays[date.getDay()];
// Remove all the weekday recurrence options. // Remove all the weekday recurrence options.
$('#edit-weekly-recurring-date-0-days').find('input').each(function(key, item) { $('#edit-weekly-recurring-date-0-days').find('input').each(function (key, item) {
$(item).prop('checked', false); $(item).prop('checked', false);
}); });
...@@ -35,7 +40,7 @@ ...@@ -35,7 +40,7 @@
}); });
// When the monthly occurrence start date is changed. // When the monthly occurrence start date is changed.
$('#edit-monthly-recurring-date-0-value-date').on('change', function(event) { $('#edit-monthly-recurring-date-0-value-date').on('change', function (event) {
var value = $(this).val(); var value = $(this).val();
var date_parts = value.split('-'); var date_parts = value.split('-');
if (date_parts.length > 0) { if (date_parts.length > 0) {
...@@ -43,7 +48,7 @@ ...@@ -43,7 +48,7 @@
var weekday = weekdays[date.getDay()]; var weekday = weekdays[date.getDay()];
// Remove all the monthly recurrence options. // Remove all the monthly recurrence options.
$('#edit-monthly-recurring-date-0-days').find('input').each(function(key, item) { $('#edit-monthly-recurring-date-0-days').find('input').each(function (key, item) {
$(item).prop('checked', false); $(item).prop('checked', false);
}); });
...@@ -59,12 +64,12 @@ ...@@ -59,12 +64,12 @@
* Set end date for excluded and included dates to be the same as the start. * Set end date for excluded and included dates to be the same as the start.
*/ */
Drupal.behaviors.recurring_events_excluded_included_dates = { Drupal.behaviors.recurring_events_excluded_included_dates = {
attach: function(context, settings) { attach: function (context, settings) {
$('#edit-excluded-dates-wrapper, #edit-included-dates-wrapper').find('input.form-date').once().on('change', function(e) { $('#edit-excluded-dates-wrapper, #edit-included-dates-wrapper').find('input.form-date').once().on('change', function (e) {
if ($(this).attr('name').includes('[value][date]')) { if ($(this).attr('name').includes('[value][date]')) {
var start_date = this; var start_date = this;
var parent = $(this).closest('.form-wrapper'); var parent = $(this).closest('.form-wrapper');
$(parent).find('input.form-date').each(function(index, item) { $(parent).find('input.form-date').each(function (index, item) {
if (index == 1) { if (index == 1) {
if ($(item).val() == '') { if ($(item).val() == '') {
$(item).val($(start_date).val()); $(item).val($(start_date).val());
......
/**
* @file
* Javascript functionality for the included/excluded date forms.
*/
(function ($) { (function ($) {
'use strict'; 'use strict';
...@@ -5,9 +10,9 @@ ...@@ -5,9 +10,9 @@
* Set end date for excluded and included dates to be the same as the start. * Set end date for excluded and included dates to be the same as the start.
*/ */
Drupal.behaviors.recurring_events_excluded_included_config_dates = { Drupal.behaviors.recurring_events_excluded_included_config_dates = {
attach: function(context, settings) { attach: function (context, settings) {
$('#edit-start').once().on('change', function(e) { $('#edit-start').once().on('change', function (e) {
if ($('#edit-end').val() == '') { if ($('#edit-end').val() == '') {
$('#edit-end').val($(this).val()); $('#edit-end').val($(this).val());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment