PluginProbe
Timed Content / 2.3
Timed Content v2.3
2.99 trunk 1.0 1.1 1.2 2.0 2.1 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.10 2.11 2.12 2.15 2.2 2.3 2.3.1 2.4 2.5 2.5.1 2.50 2.51 2.52 All 67 releases
timed-content / tinymce_plugin / dialog.js

dialog.js in Timed Content 2.3, at tinymce_plugin/dialog.js

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