| 1 |
tinyMCEPopup.requireLangPack(); |
| 2 |
|
| 3 |
var TimedContentDialog = { |
| 4 |
init : function() { |
| 5 |
jQuery('#do_client_show').click( |
| 6 |
function() { |
| 7 |
if (jQuery(this).is(':checked')) { |
| 8 |
jQuery('#client_show_minutes').removeAttr('disabled'); |
| 9 |
jQuery('#client_show_seconds').removeAttr('disabled'); |
| 10 |
jQuery('#client_show_fade').removeAttr('disabled'); |
| 11 |
} else { |
| 12 |
jQuery('#client_show_minutes').attr('disabled', 'disabled'); |
| 13 |
jQuery('#client_show_seconds').attr('disabled', 'disabled'); |
| 14 |
jQuery('#client_show_fade').attr('disabled', 'disabled'); |
| 15 |
} |
| 16 |
} |
| 17 |
); |
| 18 |
|
| 19 |
jQuery('#do_client_hide').click( |
| 20 |
function() { |
| 21 |
if (jQuery(this).attr('checked')) { |
| 22 |
jQuery('#client_hide_minutes').removeAttr('disabled'); |
| 23 |
jQuery('#client_hide_seconds').removeAttr('disabled'); |
| 24 |
jQuery('#client_hide_fade').removeAttr('disabled'); |
| 25 |
} else { |
| 26 |
jQuery('#client_hide_minutes').attr('disabled', 'disabled'); |
| 27 |
jQuery('#client_hide_seconds').attr('disabled', 'disabled'); |
| 28 |
jQuery('#client_hide_fade').attr('disabled', 'disabled'); |
| 29 |
} |
| 30 |
} |
| 31 |
); |
| 32 |
|
| 33 |
var today = new Date(); |
| 34 |
|
| 35 |
jQuery('#do_server_show').click( |
| 36 |
function() { |
| 37 |
if (jQuery(this).is(':checked')) { |
| 38 |
jQuery('#server_show_dt').removeAttr('disabled'); |
| 39 |
jQuery('#server_show_dt').AnyTime_picker( |
| 40 |
{ |
| 41 |
earliest: today, |
| 42 |
baseYear: today.getUTCFullYear(), |
| 43 |
format: "%Y-%b-%d %T %+", |
| 44 |
formatUtcOffset: "%+ (%@)" |
| 45 |
} |
| 46 |
); |
| 47 |
} else { |
| 48 |
jQuery('#server_show_dt').AnyTime_noPicker(); |
| 49 |
jQuery('#server_show_dt').attr('disabled', 'disabled'); |
| 50 |
} |
| 51 |
} |
| 52 |
); |
| 53 |
|
| 54 |
jQuery('#do_server_hide').click( |
| 55 |
function() { |
| 56 |
if (jQuery(this).attr('checked')) { |
| 57 |
jQuery('#server_hide_dt').removeAttr('disabled'); |
| 58 |
jQuery('#server_hide_dt').AnyTime_picker( |
| 59 |
{ |
| 60 |
earliest: today, |
| 61 |
baseYear: today.getUTCFullYear(), |
| 62 |
format: "%Y-%b-%d %T %+", |
| 63 |
formatUtcOffset: "%+ (%@)" |
| 64 |
} |
| 65 |
); |
| 66 |
} else { |
| 67 |
jQuery('#server_hide_dt').AnyTime_noPicker(); |
| 68 |
jQuery('#server_hide_dt').attr('disabled', 'disabled'); |
| 69 |
} |
| 70 |
} |
| 71 |
); |
| 72 |
|
| 73 |
}, |
| 74 |
|
| 75 |
client_action : function() { |
| 76 |
// Get settings from the dialog and build the arguments for the shortcode |
| 77 |
var show_args = ""; |
| 78 |
var hide_args = ""; |
| 79 |
|
| 80 |
var sm = Math.abs(parseInt(jQuery('#client_show_minutes').val())); |
| 81 |
var ss = Math.abs(parseInt(jQuery('#client_show_seconds').val())); |
| 82 |
var sf = Math.abs(parseInt(jQuery('#client_show_fade').val())); |
| 83 |
if (isNaN(sm)) sm = 0; if (isNaN(ss)) ss = 0; if (isNaN(sf)) sf = 0; |
| 84 |
|
| 85 |
var hm = Math.abs(parseInt(jQuery('#client_hide_minutes').val())); |
| 86 |
var hs = Math.abs(parseInt(jQuery('#client_hide_seconds').val())); |
| 87 |
var hf = Math.abs(parseInt(jQuery('#client_hide_fade').val())); |
| 88 |
if (isNaN(hm)) hm = 0; if (isNaN(hs)) hs = 0; if (isNaN(hf)) hf = 0; |
| 89 |
|
| 90 |
st = (sm * 60) + ss; ht = (hm * 60) + hs; |
| 91 |
|
| 92 |
if (jQuery('#do_client_show').attr('checked')) { |
| 93 |
if (st > 0) |
| 94 |
show_args = " show=\"" + sm + ":" + ss + ":" + sf + "\""; |
| 95 |
else { |
| 96 |
tinyMCEPopup.alert('When using the Show action, the Show time must be at least 1 second.'); |
| 97 |
return; |
| 98 |
} |
| 99 |
} |
| 100 |
if (jQuery('#do_client_hide').attr('checked')) { |
| 101 |
if (ht > 0) |
| 102 |
hide_args = " hide=\"" + hm + ":" + hs + ":" + hf + "\""; |
| 103 |
else { |
| 104 |
tinyMCEPopup.alert('When using the Hide action, the Hide time must be at least 1 second.'); |
| 105 |
return; |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
if (jQuery('#do_client_show').attr('checked') && jQuery('#do_client_hide').attr('checked') && (st >= ht)) { |
| 110 |
tinyMCEPopup.alert('When using both Show and Hide actions, the Hide time must be later than the Show time.'); |
| 111 |
return; |
| 112 |
} |
| 113 |
|
| 114 |
if (!(jQuery('#do_client_show').attr('checked') || jQuery('#do_client_hide').attr('checked'))) { |
| 115 |
tinyMCEPopup.alert('Please select an action to perform.'); |
| 116 |
return; |
| 117 |
} |
| 118 |
// Insert the contents from the input into the document |
| 119 |
tinyMCEPopup.editor.execCommand('mceReplaceContent', false, '[timed-content-client' + show_args + hide_args + ']{$selection}[/timed-content-client]'); |
| 120 |
tinyMCEPopup.close(); |
| 121 |
}, |
| 122 |
|
| 123 |
server_action : function() { |
| 124 |
// Get settings from the dialog and build the arguments for the shortcode |
| 125 |
var show_args = ""; |
| 126 |
var hide_args = ""; |
| 127 |
var debug_args = ""; |
| 128 |
|
| 129 |
var sdt = jQuery('#server_show_dt').val(); |
| 130 |
var hdt = jQuery('#server_hide_dt').val(); |
| 131 |
var s_Date = new Date(sdt); |
| 132 |
var h_Date = new Date(hdt); |
| 133 |
|
| 134 |
if (jQuery('#do_server_show').attr('checked')) { |
| 135 |
show_args = " show=\"" + sdt + "\""; |
| 136 |
} |
| 137 |
if (jQuery('#do_server_hide').attr('checked')) { |
| 138 |
hide_args = " hide=\"" + hdt + "\""; |
| 139 |
} |
| 140 |
if (jQuery('#server_debug').attr('checked')) { |
| 141 |
debug_args = " debug=\"true\""; |
| 142 |
} |
| 143 |
|
| 144 |
if (jQuery('#do_server_show').attr('checked') && jQuery('#do_server_hide').attr('checked') && (s_Date >= h_Date)) { |
| 145 |
tinyMCEPopup.alert('When using both Show and Hide actions, the Hide time must be later than the Show time.'); |
| 146 |
return; |
| 147 |
} |
| 148 |
|
| 149 |
if (!(jQuery('#do_server_show').attr('checked') || jQuery('#do_server_hide').attr('checked'))) { |
| 150 |
tinyMCEPopup.alert('Please select an action to perform.'); |
| 151 |
return; |
| 152 |
} |
| 153 |
// Insert the contents from the input into the document |
| 154 |
tinyMCEPopup.editor.execCommand('mceReplaceContent', false, '[timed-content-server' + show_args + hide_args + debug_args + ']{$selection}[/timed-content-server]'); |
| 155 |
tinyMCEPopup.close(); |
| 156 |
} |
| 157 |
}; |
| 158 |
|
| 159 |
tinyMCEPopup.onInit.add(TimedContentDialog.init, TimedContentDialog); |
| 160 |
|