| @@ -1,61 +1,93 @@ | ||
| 1 | -jQuery( document ).ready( function() { | |
| 2 | - jQuery( "select#timed_content_rule_frequency" ).change( function() { | |
| 3 | - jQuery( "select#timed_content_rule_frequency option:selected" ).each( function() { | |
| 4 | - if ( jQuery( this ).val() == '0' ) | |
| 5 | - jQuery( "#timed_content_rule_hourly_num_of_hours_div" ).css( "display", "block" ); | |
| 6 | - else | |
| 7 | - jQuery( "#timed_content_rule_hourly_num_of_hours_div" ).css( "display", "none" ); | |
| 8 | - if ( jQuery( this ).val() == '1' ) | |
| 9 | - jQuery( "#timed_content_rule_daily_num_of_days_div" ).css( "display", "block" ); | |
| 10 | - else | |
| 11 | - jQuery( "#timed_content_rule_daily_num_of_days_div" ).css( "display", "none" ); | |
| 12 | - if ( jQuery( this ).val() == '2' ) { | |
| 13 | - jQuery( "#timed_content_rule_weekly_num_of_weeks_div" ).css( "display", "block" ); | |
| 14 | - jQuery( "#timed_content_rule_weekly_days_of_week_to_repeat_div" ).css( "display", "block" ); | |
| 15 | - } else { | |
| 16 | - jQuery( "#timed_content_rule_weekly_num_of_weeks_div" ).css( "display", "none" ); | |
| 17 | - jQuery( "#timed_content_rule_weekly_days_of_week_to_repeat_div" ).css( "display", "none" ); | |
| 18 | - } | |
| 19 | - if ( jQuery( this ).val() == '3' ) { | |
| 20 | - jQuery( "#timed_content_rule_monthly_num_of_months_div" ).css( "display", "block" ); | |
| 21 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_div" ).css( "display", "block" ); | |
| 22 | - // Check the 'timed_content_rule_monthly_nth_weekday_of_month' checkbox when first displayed... | |
| 23 | - if ( jQuery( "#timed_content_rule_monthly_nth_weekday_of_month" ).prop( "checked" ) ) { | |
| 24 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "block" ); | |
| 25 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "block" ); | |
| 26 | - } else { | |
| 27 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 28 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 29 | - } | |
| 30 | - // ...then watch it for changes. | |
| 31 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month" ).change( function() { | |
| 32 | - if ( jQuery( this ).prop( "checked" ) ) { | |
| 33 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "block" ); | |
| 34 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "block" ); | |
| 35 | - } else { | |
| 36 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 37 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 38 | - } | |
| 39 | - }); | |
| 40 | - } else { | |
| 41 | - jQuery( "#timed_content_rule_monthly_num_of_months_div" ).css( "display", "none" ); | |
| 42 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_div" ).css( "display", "none" ); | |
| 43 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 44 | - jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 45 | - } | |
| 46 | - if ( jQuery( this ).val() == '4' ) | |
| 47 | - jQuery( "#timed_content_rule_yearly_num_of_years_div" ).css( "display", "block" ); | |
| 48 | - else | |
| 49 | - jQuery( "#timed_content_rule_yearly_num_of_years_div" ).css( "display", "none" ); | |
| 50 | - }) | |
| 51 | - }).trigger( "change" ); | |
| 52 | - jQuery( "input[name=timed_content_rule_recurrence_duration]" ).change( function() { | |
| 53 | - if ( jQuery( "input[name=timed_content_rule_recurrence_duration]:checked" ).val() == "recurrence_duration_end_date" ) { | |
| 54 | - jQuery( "#timed_content_rule_recurrence_duration_end_date_div" ).css( "display", "block" ); | |
| 55 | - jQuery( "#timed_content_rule_recurrence_duration_num_repeat_div" ).css( "display", "none" ); | |
| 56 | - } else { | |
| 57 | - jQuery( "#timed_content_rule_recurrence_duration_end_date_div" ).css( "display", "none" ); | |
| 58 | - jQuery( "#timed_content_rule_recurrence_duration_num_repeat_div" ).css( "display", "block" ); | |
| 59 | - } | |
| 60 | - }).trigger( "change" ); | |
| 61 | -}); | |
| 1 | +jQuery( document ).ready( | |
| 2 | + function () { | |
| 3 | + jQuery( "select#timed_content_rule_frequency" ).change( | |
| 4 | + function () { | |
| 5 | + jQuery( "select#timed_content_rule_frequency option:selected" ).each( | |
| 6 | + function () { | |
| 7 | + if (jQuery( this ).val() == '0') { | |
| 8 | + jQuery( "#timed_content_rule_hourly_num_of_hours_div" ).css( "display", "block" ); | |
| 9 | + } else { | |
| 10 | + jQuery( "#timed_content_rule_hourly_num_of_hours_div" ).css( "display", "none" ); | |
| 11 | + } | |
| 12 | + if (jQuery( this ).val() == '1') { | |
| 13 | + jQuery( "#timed_content_rule_daily_num_of_days_div" ).css( "display", "block" ); | |
| 14 | + } else { | |
| 15 | + jQuery( "#timed_content_rule_daily_num_of_days_div" ).css( "display", "none" ); | |
| 16 | + } | |
| 17 | + if (jQuery( this ).val() == '2') { | |
| 18 | + jQuery( "#timed_content_rule_weekly_num_of_weeks_div" ).css( "display", "block" ); | |
| 19 | + jQuery( "#timed_content_rule_weekly_days_of_week_to_repeat_div" ).css( "display", "block" ); | |
| 20 | + } else { | |
| 21 | + jQuery( "#timed_content_rule_weekly_num_of_weeks_div" ).css( "display", "none" ); | |
| 22 | + jQuery( "#timed_content_rule_weekly_days_of_week_to_repeat_div" ).css( "display", "none" ); | |
| 23 | + } | |
| 24 | + if (jQuery( this ).val() == '3') { | |
| 25 | + jQuery( "#timed_content_rule_monthly_num_of_months_div" ).css( "display", "block" ); | |
| 26 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_div" ).css( "display", "block" ); | |
| 27 | + // Check the 'timed_content_rule_monthly_nth_weekday_of_month' checkbox when first displayed... | |
| 28 | + if (jQuery( "#timed_content_rule_monthly_nth_weekday_of_month" ).prop( "checked" )) { | |
| 29 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "block" ); | |
| 30 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "block" ); | |
| 31 | + } else { | |
| 32 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 33 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 34 | + } | |
| 35 | + // ...then watch it for changes. | |
| 36 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month" ).change( | |
| 37 | + function () { | |
| 38 | + if (jQuery( this ).prop( "checked" )) { | |
| 39 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "block" ); | |
| 40 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "block" ); | |
| 41 | + } else { | |
| 42 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 43 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 44 | + } | |
| 45 | + } | |
| 46 | + ); | |
| 47 | + } else { | |
| 48 | + jQuery( "#timed_content_rule_monthly_num_of_months_div" ).css( "display", "none" ); | |
| 49 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_div" ).css( "display", "none" ); | |
| 50 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_nth_div" ).css( "display", "none" ); | |
| 51 | + jQuery( "#timed_content_rule_monthly_nth_weekday_of_month_weekday_div" ).css( "display", "none" ); | |
| 52 | + } | |
| 53 | + if (jQuery( this ).val() == '4') { | |
| 54 | + jQuery( "#timed_content_rule_yearly_num_of_years_div" ).css( "display", "block" ); | |
| 55 | + } else { | |
| 56 | + jQuery( "#timed_content_rule_yearly_num_of_years_div" ).css( "display", "none" ); | |
| 57 | + } | |
| 58 | + } | |
| 59 | + ) | |
| 60 | + } | |
| 61 | + ).trigger( "change" ); | |
| 62 | + jQuery( "input[name=timed_content_rule_recurrence_duration]" ).change( | |
| 63 | + function () { | |
| 64 | + if (jQuery( "input[name=timed_content_rule_recurrence_duration]:checked" ).val() == "recurrence_duration_end_date") { | |
| 65 | + jQuery( "#timed_content_rule_recurrence_duration_end_date_div" ).css( "display", "block" ); | |
| 66 | + jQuery( "#timed_content_rule_recurrence_duration_num_repeat_div" ).css( "display", "none" ); | |
| 67 | + } else { | |
| 68 | + jQuery( "#timed_content_rule_recurrence_duration_end_date_div" ).css( "display", "none" ); | |
| 69 | + jQuery( "#timed_content_rule_recurrence_duration_num_repeat_div" ).css( "display", "block" ); | |
| 70 | + } | |
| 71 | + } | |
| 72 | + ).trigger( "change" ); | |
| 73 | + jQuery( "#timed_content_rule_exceptions_dates" ).on( | |
| 74 | + "dblclick", | |
| 75 | + "option", | |
| 76 | + function(){ | |
| 77 | + jQuery( this ).remove(); | |
| 78 | + if (jQuery( "#timed_content_rule_exceptions_dates option" ).length == 0 ) { | |
| 79 | + jQuery( "#timed_content_rule_exceptions_dates" ).append( '<option value="0">' + timedContentRuleAdmin.no_exceptions_label + '</option>' ); | |
| 80 | + } | |
| 81 | + jQuery( "#timed_content_rule_exceptions_dates_picker" ).trigger( "change" ); | |
| 82 | + | |
| 83 | + } | |
| 84 | + ); | |
| 85 | + jQuery( "#publish" ).on( | |
| 86 | + "click", | |
| 87 | + function() { | |
| 88 | + jQuery( "#timed_content_rule_exceptions_dates option[value='0']" ).remove(); | |
| 89 | + jQuery( "#timed_content_rule_exceptions_dates option" ).attr( "selected", "selected" ); | |
| 90 | + } | |
| 91 | + ); | |
| 92 | + } | |
| 93 | +); | |