| 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 |
); |
| 94 |
|