| 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').prop('disabled', 'disabled'); |
| 13 |
jQuery('#client_show_seconds').prop('disabled', 'disabled'); |
| 14 |
jQuery('#client_show_fade').prop('disabled', 'disabled'); |
| 15 |
} |
| 16 |
} |
| 17 |
); |
| 18 |
|
| 19 |
jQuery('#do_client_hide').click( |
| 20 |
function() { |
| 21 |
if (jQuery(this).is(':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').prop('disabled', 'disabled'); |
| 27 |
jQuery('#client_hide_seconds').prop('disabled', 'disabled'); |
| 28 |
jQuery('#client_hide_fade').prop('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_date').removeAttr('disabled'); |
| 39 |
jQuery('#server_show_time').removeAttr('disabled'); |
| 40 |
jQuery('#server_show_date').datepicker( |
| 41 |
{ |
| 42 |
changeMonth: true, |
| 43 |
changeYear: true, |
| 44 |
dateFormat: datepickParam.dateFormat |
| 45 |
} |
| 46 |
); |
| 47 |
jQuery('#server_show_time').timepicker( |
| 48 |
{ |
| 49 |
defaultTime: 'now' |
| 50 |
} |
| 51 |
); |
| 52 |
} else { |
| 53 |
jQuery('#server_show_date').prop('disabled', 'disabled'); |
| 54 |
jQuery('#server_show_time').prop('disabled', 'disabled'); |
| 55 |
} |
| 56 |
} |
| 57 |
); |
| 58 |
|
| 59 |
jQuery('#do_server_hide').click( |
| 60 |
function() { |
| 61 |
if (jQuery(this).is(':checked')) { |
| 62 |
jQuery('#server_hide_date').removeAttr('disabled'); |
| 63 |
jQuery('#server_hide_time').removeAttr('disabled'); |
| 64 |
jQuery('#server_hide_date').datepicker( |
| 65 |
{ |
| 66 |
changeMonth: true, |
| 67 |
changeYear: true, |
| 68 |
dateFormat: datepickParam.dateFormat |
| 69 |
} |
| 70 |
); |
| 71 |
jQuery('#server_hide_time').timepicker( |
| 72 |
{ |
| 73 |
defaultTime: 'now' |
| 74 |
} |
| 75 |
); |
| 76 |
} else { |
| 77 |
jQuery('#server_hide_date').prop('disabled', 'disabled'); |
| 78 |
jQuery('#server_hide_time').prop('disabled', 'disabled'); |
| 79 |
} |
| 80 |
} |
| 81 |
); |
| 82 |
|
| 83 |
jQuery.each( rules, function( key, value ) { |
| 84 |
jQuery('select#rules_list').append( '<option value="' + value['ID'] + '">' + value['title'] + '</option>\n' ); |
| 85 |
}); |
| 86 |
jQuery( "select#rules_list" ).change( function() { |
| 87 |
jQuery( "select#rules_list option:selected" ).each( function() { |
| 88 |
var id = jQuery( this ).val(); |
| 89 |
jQuery.each( rules, function( key, value ) { |
| 90 |
if ( id == value['ID'] ) |
| 91 |
jQuery( "span#rules_desc" ).html(value['desc']); |
| 92 |
}); |
| 93 |
if ( id < 0 ) { |
| 94 |
jQuery('select#rules_list').prop('disabled', 'disabled'); |
| 95 |
jQuery('#TimedContentDialogRules #insert').prop('disabled', 'disabled'); |
| 96 |
} |
| 97 |
|
| 98 |
}); |
| 99 |
}).trigger( "change" ); |
| 100 |
|
| 101 |
}, |
| 102 |
|
| 103 |
client_action : function() { |
| 104 |
// Get settings from the dialog and build the arguments for the shortcode |
| 105 |
var show_args = ""; |
| 106 |
var hide_args = ""; |
| 107 |
var display_args = ""; |
| 108 |
|
| 109 |
var sm = Math.abs(parseInt(jQuery('#client_show_minutes').val())); |
| 110 |
var ss = Math.abs(parseInt(jQuery('#client_show_seconds').val())); |
| 111 |
var sf = Math.abs(parseInt(jQuery('#client_show_fade').val())); |
| 112 |
if (isNaN(sm)) sm = 0; if (isNaN(ss)) ss = 0; if (isNaN(sf)) sf = 0; |
| 113 |
|
| 114 |
var hm = Math.abs(parseInt(jQuery('#client_hide_minutes').val())); |
| 115 |
var hs = Math.abs(parseInt(jQuery('#client_hide_seconds').val())); |
| 116 |
var hf = Math.abs(parseInt(jQuery('#client_hide_fade').val())); |
| 117 |
if (isNaN(hm)) hm = 0; if (isNaN(hs)) hs = 0; if (isNaN(hf)) hf = 0; |
| 118 |
|
| 119 |
st = (sm * 60) + ss; ht = (hm * 60) + hs; |
| 120 |
|
| 121 |
if (jQuery('#client_display_tag_div').prop('checked')) |
| 122 |
display_args = " display=\"div\""; |
| 123 |
else |
| 124 |
display_args = " display=\"span\""; |
| 125 |
|
| 126 |
if (jQuery('#do_client_show').prop('checked')) { |
| 127 |
if (st > 0) |
| 128 |
show_args = " show=\"" + sm + ":" + ss + ":" + sf + "\""; |
| 129 |
else { |
| 130 |
tinyMCEPopup.alert(errorMessages.clientNoShow); |
| 131 |
return; |
| 132 |
} |
| 133 |
} |
| 134 |
if (jQuery('#do_client_hide').prop('checked')) { |
| 135 |
if (ht > 0) |
| 136 |
hide_args = " hide=\"" + hm + ":" + hs + ":" + hf + "\""; |
| 137 |
else { |
| 138 |
tinyMCEPopup.alert(errorMessages.clientNoHide); |
| 139 |
return; |
| 140 |
} |
| 141 |
} |
| 142 |
|
| 143 |
if (jQuery('#do_client_show').prop('checked') && jQuery('#do_client_hide').prop('checked') && (st >= ht)) { |
| 144 |
tinyMCEPopup.alert(errorMessages.clientHideBeforeShow); |
| 145 |
return; |
| 146 |
} |
| 147 |
|
| 148 |
if (!(jQuery('#do_client_show').prop('checked') || jQuery('#do_client_hide').prop('checked'))) { |
| 149 |
tinyMCEPopup.alert(errorMessages.clientNoAction); |
| 150 |
return; |
| 151 |
} |
| 152 |
// Insert the contents from the input into the document |
| 153 |
tinyMCEPopup.editor.execCommand('mceReplaceContent', false, '[' + tags.client + ' ' + show_args + hide_args + display_args + ']{$selection}[/' + tags.client + ']'); |
| 154 |
tinyMCEPopup.close(); |
| 155 |
}, |
| 156 |
|
| 157 |
server_action : function() { |
| 158 |
// Get settings from the dialog and build the arguments for the shortcode |
| 159 |
var show_args = ""; |
| 160 |
var hide_args = ""; |
| 161 |
var debug_args = ""; |
| 162 |
|
| 163 |
var sd = jQuery('#server_show_date').val(); |
| 164 |
var hd = jQuery('#server_hide_date').val(); |
| 165 |
var st = jQuery('#server_show_time').val(); |
| 166 |
var ht = jQuery('#server_hide_time').val(); |
| 167 |
var tz = jQuery('#server_tz option:selected').val(); |
| 168 |
var s_Date = new Date(sd + " " + st); |
| 169 |
var h_Date = new Date(hd + " " + ht); |
| 170 |
|
| 171 |
if (jQuery('#do_server_show').prop('checked')) { |
| 172 |
show_args = " show=\"" + sd + " " + st + " " + tz + "\""; |
| 173 |
} |
| 174 |
if (jQuery('#do_server_hide').prop('checked')) { |
| 175 |
hide_args = " hide=\"" + hd + " " + ht + " " + tz + "\""; |
| 176 |
} |
| 177 |
if (jQuery('#server_debug').prop('checked')) { |
| 178 |
debug_args = " debug=\"true\""; |
| 179 |
} |
| 180 |
|
| 181 |
if (jQuery('#do_server_show').prop('checked') && (sd.length == 0)) { |
| 182 |
tinyMCEPopup.alert(errorMessages.serverNoShowDate); |
| 183 |
return; |
| 184 |
} |
| 185 |
|
| 186 |
if (jQuery('#do_server_hide').prop('checked') && (hd.length == 0)) { |
| 187 |
tinyMCEPopup.alert(errorMessages.serverNoHideDate); |
| 188 |
return; |
| 189 |
} |
| 190 |
|
| 191 |
if (jQuery('#do_server_show').prop('checked') && (st.length == 0)) { |
| 192 |
tinyMCEPopup.alert(errorMessages.serverNoShowTime); |
| 193 |
return; |
| 194 |
} |
| 195 |
|
| 196 |
if (jQuery('#do_server_hide').prop('checked') && (ht.length == 0)) { |
| 197 |
tinyMCEPopup.alert(errorMessages.serverNoHideTime); |
| 198 |
return; |
| 199 |
} |
| 200 |
|
| 201 |
if (jQuery('#do_server_show').prop('checked') && jQuery('#do_server_hide').prop('checked') && (s_Date >= h_Date)) { |
| 202 |
tinyMCEPopup.alert(errorMessages.serverHideBeforeShow); |
| 203 |
return; |
| 204 |
} |
| 205 |
|
| 206 |
if (!(jQuery('#do_server_show').prop('checked') || jQuery('#do_server_hide').prop('checked'))) { |
| 207 |
tinyMCEPopup.alert(errorMessages.serverNoAction); |
| 208 |
return; |
| 209 |
} |
| 210 |
|
| 211 |
// Insert the contents from the input into the document |
| 212 |
tinyMCEPopup.editor.execCommand('mceReplaceContent', false, '[' + tags.server + ' ' + show_args + hide_args + debug_args + ']{$selection}[/' + tags.server + ']'); |
| 213 |
tinyMCEPopup.close(); |
| 214 |
}, |
| 215 |
|
| 216 |
rules_action : function() { |
| 217 |
// Get settings from the dialog and build the arguments for the shortcode |
| 218 |
var rule_args = " id=\"" + jQuery('select#rules_list option:selected').val() + "\""; |
| 219 |
|
| 220 |
// Insert the contents from the input into the document |
| 221 |
tinyMCEPopup.editor.execCommand('mceReplaceContent', false, '[' + tags.rule + ' ' + rule_args + ']{$selection}[/' + tags.rule + ']'); |
| 222 |
tinyMCEPopup.close(); |
| 223 |
} |
| 224 |
}; |
| 225 |
|
| 226 |
tinyMCEPopup.onInit.add(TimedContentDialog.init, TimedContentDialog); |
| 227 |
|