drg_cms 0.5.52.12 → 0.6.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/app/assets/javascripts/drg_cms/drg_cms.js +395 -120
- data/app/assets/javascripts/drg_cms/jstree.min.js +6 -6
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +476 -215
- data/app/assets/stylesheets/drg_cms/jstree.css +6 -12
- data/app/assets/stylesheets/drg_cms/select-multiple.css +19 -13
- data/app/assets/stylesheets/drg_cms_cms.css +1 -1
- data/app/controllers/cmsedit_controller.rb +474 -233
- data/app/controllers/dc_application_controller.rb +264 -41
- data/app/controllers/dc_common_controller.rb +75 -63
- data/app/{controllers → controls}/browse_models_control.rb +0 -0
- data/app/{controllers → controls}/dc_page_control.rb +24 -8
- data/app/controls/dc_poll_result_control.rb +88 -0
- data/app/controls/dc_report.rb +227 -0
- data/app/{controllers → controls}/design_element_settings_control.rb +0 -0
- data/app/forms/all_options.yml +70 -12
- data/app/forms/cms_menu.yml +26 -17
- data/app/forms/dc_ad.yml +11 -22
- data/app/forms/dc_big_table.yml +1 -0
- data/app/forms/dc_big_table_value.yml +1 -0
- data/app/forms/dc_design.yml +19 -16
- data/app/forms/dc_filter.yml +3 -6
- data/app/forms/dc_gallery.yml +53 -0
- data/app/forms/dc_json_ld.yml +59 -0
- data/app/forms/dc_key_value.yml +32 -0
- data/app/forms/dc_link.yml +16 -10
- data/app/forms/dc_menu_item.yml +6 -0
- data/app/forms/dc_page.yml +2 -7
- data/app/forms/dc_poll.yml +16 -9
- data/app/forms/dc_poll_item.yml +2 -1
- data/app/forms/dc_poll_result.yml +83 -0
- data/app/forms/dc_poll_result_export.yml +35 -0
- data/app/forms/dc_removed_url.yml +42 -0
- data/app/forms/dc_seo.yml +33 -0
- data/app/forms/dc_site.yml +2 -6
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/cms_common_helper.rb +311 -0
- data/app/helpers/cms_edit_helper.rb +498 -0
- data/app/helpers/cms_helper.rb +230 -0
- data/app/helpers/cms_index_helper.rb +564 -0
- data/app/helpers/dc_application_helper.rb +195 -268
- data/app/models/{dc_dummy.rb → __dc_dummy.rb} +0 -0
- data/app/models/concerns/dc_page_concern.rb +31 -6
- data/app/models/concerns/dc_seo_concern.rb +66 -0
- data/app/models/concerns/dc_site_concern.rb +12 -1
- data/app/models/concerns/dc_user_concern.rb +5 -3
- data/app/models/dc_design.rb +2 -0
- data/app/models/dc_filter.rb +37 -20
- data/app/models/dc_gallery.rb +64 -0
- data/app/models/dc_json_ld.rb +152 -0
- data/app/models/dc_key_value.rb +48 -0
- data/app/models/dc_link.rb +1 -0
- data/app/models/dc_memory.rb +26 -4
- data/app/models/dc_page.rb +1 -2
- data/app/models/dc_permission.rb +30 -0
- data/app/models/dc_poll.rb +39 -19
- data/app/models/dc_poll_result.rb +46 -0
- data/app/models/dc_removed_url.rb +54 -0
- data/app/models/dc_temp.rb +140 -0
- data/app/models/drgcms_form_fields.rb +6 -1642
- data/app/models/drgcms_form_fields/action.rb +61 -0
- data/app/models/drgcms_form_fields/check_box.rb +72 -0
- data/app/models/drgcms_form_fields/comment.rb +53 -0
- data/app/models/drgcms_form_fields/date_picker.rb +104 -0
- data/app/models/drgcms_form_fields/date_select.rb +68 -0
- data/app/models/drgcms_form_fields/datetime_picker.rb +89 -0
- data/app/models/drgcms_form_fields/datetime_select.rb +73 -0
- data/app/models/drgcms_form_fields/drgcms_field.rb +287 -0
- data/app/models/drgcms_form_fields/embedded.rb +97 -0
- data/app/models/drgcms_form_fields/file_field.rb +52 -0
- data/app/models/drgcms_form_fields/file_select.rb +70 -0
- data/app/models/drgcms_form_fields/hash_field.rb +86 -0
- data/app/models/drgcms_form_fields/hidden_field.rb +52 -0
- data/app/models/drgcms_form_fields/html_field.rb +70 -0
- data/app/models/drgcms_form_fields/journal_diff.rb +60 -0
- data/app/models/drgcms_form_fields/link_to.rb +69 -0
- data/app/models/drgcms_form_fields/method.rb +65 -0
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +204 -0
- data/app/models/drgcms_form_fields/number_field.rb +92 -0
- data/app/models/drgcms_form_fields/password_field.rb +62 -0
- data/app/models/drgcms_form_fields/radio.rb +96 -0
- data/app/models/drgcms_form_fields/readonly.rb +79 -0
- data/app/models/drgcms_form_fields/select.rb +226 -0
- data/app/models/drgcms_form_fields/submit_tag.rb +58 -0
- data/app/models/drgcms_form_fields/text_area.rb +68 -0
- data/app/models/drgcms_form_fields/text_autocomplete.rb +155 -0
- data/app/models/drgcms_form_fields/text_field.rb +56 -0
- data/app/models/drgcms_form_fields/text_with_select.rb +95 -0
- data/app/models/drgcms_form_fields/tree_select.rb +169 -0
- data/app/{helpers → renderers}/dc_ad_renderer.rb +0 -0
- data/app/{helpers → renderers}/dc_big_menu_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_captcha_renderer.rb +0 -0
- data/app/{helpers → renderers}/dc_common_renderer.rb +0 -0
- data/app/renderers/dc_gallery_renderer.rb +95 -0
- data/app/{helpers → renderers}/dc_menu_renderer.rb +11 -4
- data/app/{helpers → renderers}/dc_page_renderer.rb +21 -3
- data/app/{helpers → renderers}/dc_part_renderer.rb +5 -4
- data/app/{helpers → renderers}/dc_piece_renderer.rb +1 -1
- data/app/{helpers → renderers}/dc_poll_renderer.rb +86 -51
- data/app/{helpers → renderers}/dc_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_simple_menu_renderer.rb +1 -0
- data/app/views/cmsedit/{remove_edit_stuff.js.erb → __remove_edit_stuff.js.erb} +0 -0
- data/app/views/cmsedit/{show.html.erb → __show.html.erb} +0 -0
- data/app/views/cmsedit/_edit_stuff.html.erb +4 -25
- data/app/views/cmsedit/_form.html.erb +4 -3
- data/app/views/cmsedit/_result.html.erb +2 -3
- data/app/views/cmsedit/edit.html.erb +2 -1
- data/app/views/cmsedit/index.html.erb +6 -1
- data/app/views/cmsedit/new.html.erb +1 -1
- data/config/locales/drgcms_en.yml +15 -3
- data/config/locales/drgcms_sl.yml +18 -6
- data/config/locales/models_en.yml +103 -19
- data/config/locales/models_sl.yml +102 -17
- data/drg_cms.gemspec +3 -3
- data/lib/drg_cms.rb +6 -2
- data/lib/drg_cms/version.rb +2 -2
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +9 -2
- data/lib/tasks/database.rake +6 -56
- data/lib/tasks/dc_cleanup.rake +1 -1
- metadata +106 -61
- data/app/assets/stylesheets/drg_cms/__jquery-ui.css +0 -339
- data/app/helpers/application_helper.rb +0 -2
- data/app/helpers/cmsedit_helper.rb +0 -844
- data/test/fixtures/drg_cms_test_data.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ef26a547c0b8b4274cf351a0d479541cd2bfb10ebf1ba6405dcba87fa816d08d
|
4
|
+
data.tar.gz: 9e7c29e2d144e3b758972056359940a94baffb869cc18ee7f4483947f36be850
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '0918c545df0e262b8ca70f4a59451df888283374b0084f9fe14e554ed9a461fdadf749c89a02240d1898fde8c616dd272eec8fda39e1d8b255007859c71dbfa1'
|
7
|
+
data.tar.gz: 81f13601bafc13609e8c8f620d2511d9cc329bb82c0024eaaf6460639ea2102aaaf70f59860dfb33f75a647039440a30b9e388bc5094d433ec6c4fde25b0910a
|
@@ -28,6 +28,7 @@
|
|
28
28
|
*******************************************************************/
|
29
29
|
$.getUrlParam = function(name) {
|
30
30
|
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
|
31
|
+
if (results == null) return null;
|
31
32
|
return results[1] || 0;
|
32
33
|
};
|
33
34
|
|
@@ -42,16 +43,65 @@ dumpAttributes = function(obj) {
|
|
42
43
|
};
|
43
44
|
|
44
45
|
/*******************************************************************
|
45
|
-
*
|
46
|
+
* Function checks if there are delay loaded embedded elements on
|
47
|
+
* selected tab and triggers iframe reload.
|
46
48
|
*******************************************************************/
|
47
|
-
|
48
|
-
var
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
49
|
+
update_embedded_on_tab_select = function(div_name) {
|
50
|
+
var iframes = $(div_name).find("iframe");
|
51
|
+
$.each(iframes, function(index, iframe) {
|
52
|
+
// delayed load
|
53
|
+
var src_delay = iframe.getAttribute('data-src-delay');
|
54
|
+
if (src_delay != null && src_delay != '') {
|
55
|
+
iframe.setAttribute('data-src-delay', '');
|
56
|
+
iframe.setAttribute('src', src_delay);
|
57
|
+
}
|
58
|
+
// always load on tab select
|
59
|
+
var src_always = iframe.getAttribute('data-src-always');
|
60
|
+
if (src_always != null) {
|
61
|
+
iframe.setAttribute('src', src_always);
|
62
|
+
}
|
63
|
+
});
|
64
|
+
};
|
65
|
+
|
66
|
+
/*******************************************************************
|
67
|
+
* Return false when confirmation is not required
|
68
|
+
*******************************************************************/
|
69
|
+
confirmation_is_cancled = function(object) {
|
70
|
+
var confirmation = object.getAttribute("data-confirm");
|
71
|
+
// if confirmation required
|
72
|
+
if (confirmation !== null) {
|
73
|
+
if (!confirm(confirmation)) {return true;}
|
74
|
+
}
|
75
|
+
return false;
|
76
|
+
};
|
77
|
+
|
78
|
+
/*******************************************************************
|
79
|
+
* Will update select field on the form which select options are dependend
|
80
|
+
* on other field value. It calls /dc_common/autocomplete and passes
|
81
|
+
* methodname and depend field value to obtain new values for select field.
|
82
|
+
*******************************************************************/
|
83
|
+
update_select_depend = function(select_name, depend_name, method) {
|
84
|
+
var select_field = $('#'+select_name);
|
85
|
+
var depend_field = $('#'+depend_name);
|
86
|
+
|
87
|
+
$.ajax({
|
88
|
+
url: "/dc_common/autocomplete",
|
89
|
+
type: "POST",
|
90
|
+
dataType: "json",
|
91
|
+
data: { input: depend_field.val(), search: method},
|
92
|
+
success: function(data) {
|
93
|
+
|
94
|
+
select_field.empty();
|
95
|
+
$.each(data, function(index, element) {
|
96
|
+
select_field.append( new Option(element['label'], element['id']) );
|
97
|
+
});
|
98
|
+
}
|
99
|
+
});
|
53
100
|
};
|
54
101
|
|
102
|
+
/*******************************************************************
|
103
|
+
* Format number input field according to data
|
104
|
+
*******************************************************************/
|
55
105
|
format_number_field = function(e) {
|
56
106
|
var decimals = e.attr("data-decimal") || 2;
|
57
107
|
var delimiter = e.attr("data-delimiter") || '.';
|
@@ -99,10 +149,10 @@ $(function() {
|
|
99
149
|
*
|
100
150
|
* Protocol consists of operation and value which are returned as json by
|
101
151
|
* called controller. Controller will return an ajax call usually like this:
|
102
|
-
* render json: {operation: value}
|
152
|
+
* render json: {operation: value}
|
103
153
|
*
|
104
154
|
* Operation is further divided into source and determinator which are divided by underline char.
|
105
|
-
* render json: {#div_status: 'OK!'}
|
155
|
+
* render json: {#div_status: 'OK!'}
|
106
156
|
* will replace html in div="status" with value 'OK!'. Source is '#div' determinator is 'status'.
|
107
157
|
*
|
108
158
|
* Possible operators are:
|
@@ -125,78 +175,132 @@ $(function() {
|
|
125
175
|
* window_: Will force loading of url supplied in value into new window
|
126
176
|
* reload_: Will reload current window
|
127
177
|
*
|
128
|
-
* Operations can be chained and are executed
|
129
|
-
* render json: {'window_' => "/
|
130
|
-
* will open /
|
178
|
+
* Operations can be chained and are executed sequential.
|
179
|
+
* render json: {'window_' => "/document.pdf", 'reload_' => 1}.to_json
|
180
|
+
* will open /document.pdf in new window and reload current window.
|
131
181
|
*
|
132
182
|
* render json: {'record_name' => "Damjan", 'record_surname' => 'Rems'}.to_json
|
133
183
|
* will replace values of two fields on the form.
|
134
184
|
*******************************************************************/
|
135
185
|
|
136
186
|
process_json_result = function(json) {
|
137
|
-
var i,operation,
|
138
|
-
$.each(json, function(key,
|
187
|
+
var i,w,operation,selector, msg_div, field;
|
188
|
+
$.each(json, function(key, value) {
|
139
189
|
i = key.search('_');
|
140
190
|
if (i > 1) {
|
141
191
|
operation = key.substring(0,i);
|
142
|
-
|
192
|
+
selector = key.substring(i+1,100);
|
143
193
|
} else {
|
144
194
|
operation = key;
|
145
|
-
|
195
|
+
selector = '';
|
146
196
|
}
|
147
|
-
//
|
197
|
+
//
|
148
198
|
switch (operation) {
|
149
|
-
|
199
|
+
|
200
|
+
/**** update fields on form ****/
|
150
201
|
case 'record':
|
151
|
-
$('#'+key)
|
202
|
+
// field = $('#'+key);
|
203
|
+
var name = key.replace('record_','record[') + ']';
|
204
|
+
field = $('[name="' + name + '"]');
|
205
|
+
console.log(field.attr('type'));
|
206
|
+
console.log(field.is('select'));
|
207
|
+
// checkbox field
|
208
|
+
if (field.is(':checkbox')) {
|
209
|
+
field.prop('checked', value);
|
210
|
+
// select field
|
211
|
+
} else if (field.is('select')) {
|
212
|
+
// options for select field
|
213
|
+
if (value && value.isArray) {
|
214
|
+
field.empty();
|
215
|
+
$.each(value, function(index, v) {
|
216
|
+
field.append( new Option(v[0], v[1]) );
|
217
|
+
});
|
218
|
+
// select field value
|
219
|
+
} else {
|
220
|
+
field.val(value).change();
|
221
|
+
}
|
222
|
+
// radio field
|
223
|
+
} else if (field.attr('type') == 'radio') {
|
224
|
+
field.val([value])
|
225
|
+
|
226
|
+
// other input fields
|
227
|
+
} else {
|
228
|
+
field.val(value);
|
229
|
+
}
|
152
230
|
break;
|
153
|
-
|
231
|
+
|
232
|
+
/**** display message ****/
|
154
233
|
case 'msg':
|
155
|
-
|
156
|
-
if ( $('.'+
|
157
|
-
|
158
|
-
$('.dc-title').after(
|
234
|
+
msg_div = 'dc-form-' + selector;
|
235
|
+
if ( $('.'+msg_div).length == 0 ) {
|
236
|
+
value = '<div class="' + msg_div + '">' + value + '</div>';
|
237
|
+
$('.dc-title').after(value);
|
159
238
|
} else {
|
160
|
-
$('.'+
|
239
|
+
$('.'+msg_div).html(value);
|
161
240
|
}
|
162
241
|
break;
|
163
|
-
|
242
|
+
|
243
|
+
/**** display popup message ****/
|
164
244
|
case 'popup':
|
165
|
-
$('#popup').html(
|
245
|
+
$('#popup').html(value);
|
166
246
|
$('#popup').bPopup({ speed: 650, transition: 'slideDown' });
|
167
247
|
|
168
|
-
|
248
|
+
/**** update div ****/
|
169
249
|
case '#div+':
|
170
|
-
$('#'+
|
250
|
+
$('#'+selector).append(value);
|
171
251
|
break;
|
172
252
|
case '#+div':
|
173
|
-
$('#'+
|
253
|
+
$('#'+selector).prepend(value);
|
174
254
|
break;
|
175
255
|
case '#div':
|
176
|
-
$('#'+
|
256
|
+
$('#'+selector).html(value);
|
177
257
|
break;
|
178
258
|
case '.div+':
|
179
|
-
$('.'+
|
259
|
+
$('.'+selector).append(value);
|
180
260
|
break;
|
181
261
|
case '.+div':
|
182
|
-
$('.'+
|
262
|
+
$('.'+selector).prepend(value);
|
183
263
|
break;
|
184
264
|
case '.div':
|
185
|
-
$('.'+
|
265
|
+
$('.'+selector).html(value);
|
186
266
|
break;
|
187
|
-
|
267
|
+
|
268
|
+
/**** goto url ****/
|
188
269
|
case 'url':
|
189
|
-
window.location.href =
|
270
|
+
window.location.href = value;
|
190
271
|
break;
|
191
272
|
case 'alert':
|
192
|
-
alert(
|
273
|
+
alert(value);
|
193
274
|
break;
|
194
275
|
case 'window':
|
195
|
-
|
276
|
+
if (value == 'close') { window.close();
|
277
|
+
} else if (value == 'reload') { location.reload();
|
278
|
+
} else {
|
279
|
+
w = window.open(value, selector);
|
280
|
+
w.focus();
|
281
|
+
}
|
282
|
+
break;
|
283
|
+
case 'newwindow':
|
284
|
+
w = window.open(value, selector,"location=no,scrollbars=yes,resizable=yes");
|
196
285
|
w.focus();
|
197
286
|
break;
|
287
|
+
case 'eval':
|
288
|
+
console.log('from process_json_result: Eval option will be deprecated. Use script instead.')
|
289
|
+
eval (value);
|
290
|
+
break;
|
291
|
+
case 'script':
|
292
|
+
eval (value);
|
293
|
+
break;
|
198
294
|
case 'reload':
|
199
|
-
|
295
|
+
if (value == 'parent') {
|
296
|
+
parent.location.reload();
|
297
|
+
/*** this would be current window (reload: true) ****/
|
298
|
+
} else if (value.length < 5) {
|
299
|
+
window.location.href = window.location.href;
|
300
|
+
/*** reload iframe ****/
|
301
|
+
} else {
|
302
|
+
$( '#' + value ).attr('src', $( '#' + value ).attr('src'));
|
303
|
+
}
|
200
304
|
break;
|
201
305
|
default:
|
202
306
|
console.log("DRGCMS: Invalid ajax result operation: " + operation);
|
@@ -236,6 +340,21 @@ $.fn.dc_scroll_view = function () {
|
|
236
340
|
});
|
237
341
|
};
|
238
342
|
|
343
|
+
/*******************************************************************
|
344
|
+
* Updates single field on parent iframe form of embedded form.
|
345
|
+
*******************************************************************/
|
346
|
+
process_parent_form_updates = function(element) {
|
347
|
+
var field = element.getAttribute("data-field");
|
348
|
+
var value = element.getAttribute("data-value");
|
349
|
+
if ( window.parent.$('#'+field).length > 0 ) {
|
350
|
+
if (field.substring(0,3) === 'td_') { // readonly field
|
351
|
+
window.parent.$('#'+field+' > div').html(value);
|
352
|
+
} else { // input field
|
353
|
+
window.parent.$('#'+field).val(value);
|
354
|
+
}
|
355
|
+
}
|
356
|
+
};
|
357
|
+
|
239
358
|
/*******************************************************************
|
240
359
|
*
|
241
360
|
*******************************************************************/
|
@@ -248,6 +367,27 @@ $(document).ready( function() {
|
|
248
367
|
// select_first_input_field('.dc-form');
|
249
368
|
}
|
250
369
|
*/
|
370
|
+
/*******************************************************************
|
371
|
+
* It will scroll display to ypos if return_to_ypos parameter is present
|
372
|
+
*******************************************************************/
|
373
|
+
if (window.location.href.match(/return_to_ypos=/))
|
374
|
+
{
|
375
|
+
window.scrollTo(0, $.getUrlParam('return_to_ypos'));
|
376
|
+
}
|
377
|
+
|
378
|
+
/*******************************************************************
|
379
|
+
* The idea is to update fields on parent iframe form, when embedded document
|
380
|
+
* is updated in its iframe. Update fields are listed in .dc-form-updates div
|
381
|
+
* and are set by flash[:update] Hash object.
|
382
|
+
*
|
383
|
+
* eg. flash[:update] = {'td_record_radonly' => 'New value for read_only field',
|
384
|
+
* 'record_name' => 'New name'}
|
385
|
+
*******************************************************************/
|
386
|
+
if ( $('.dc-form-updates').length > 0 ) {
|
387
|
+
$('.dc-form-updates').children().each( function( index, element ) {
|
388
|
+
process_parent_form_updates(element);
|
389
|
+
});
|
390
|
+
}
|
251
391
|
|
252
392
|
/*******************************************************************
|
253
393
|
* Register ad clicks
|
@@ -257,6 +397,17 @@ $(document).ready( function() {
|
|
257
397
|
return true;
|
258
398
|
});
|
259
399
|
|
400
|
+
/*****************************************************************
|
401
|
+
* Toggle CMS mode. When clicked on left 30 pixels, window will be scrolled approximately
|
402
|
+
* to the position wher toggle was clicked. When clicked from pixel 31 and on it will
|
403
|
+
* stay on the top of window.
|
404
|
+
******************************************************************/
|
405
|
+
$('.cms-toggle').bind('click', function(e) {
|
406
|
+
var url = '/dc_common/toggle_edit_mode?return_to=' + window.location.href;
|
407
|
+
if (e.pageX < 30) url = url + '&return_to_ypos=' + e.pageY ;
|
408
|
+
window.location.href = url;
|
409
|
+
});
|
410
|
+
|
260
411
|
/*******************************************************************
|
261
412
|
* Popup or close CMS edit menu on icon click
|
262
413
|
*******************************************************************/
|
@@ -280,21 +431,22 @@ $(document).ready( function() {
|
|
280
431
|
* Sort action clicked on cmsedit
|
281
432
|
*******************************************************************/
|
282
433
|
$('.drgcms_sort').change( function(e) {
|
283
|
-
table = e.target.getAttribute("data-table");
|
284
|
-
|
434
|
+
var table = e.target.getAttribute("data-table");
|
435
|
+
var form = e.target.getAttribute("data-form");
|
436
|
+
var sort = e.target.value;
|
285
437
|
e.target.value = null;
|
286
|
-
window.location.href = "/cmsedit?sort=" + sort + "&table=" + table;
|
438
|
+
window.location.href = "/cmsedit?sort=" + sort + "&table=" + table + "&form_name=" + form;
|
287
439
|
});
|
288
440
|
|
289
441
|
/*******************************************************************
|
290
442
|
* Tab clicked on form. Hide old and show selected div.
|
291
443
|
*******************************************************************/
|
292
444
|
$('.dc-form-li').on('click', function(e) {
|
293
|
-
// find li with dc-form-li-selected class. This is our old tab
|
445
|
+
// find li with dc-form-li-selected class. This is our old tab
|
294
446
|
var old_tab_id = null;
|
295
447
|
$(e.target).parents('ul').find('li').each( function() {
|
296
448
|
if ($(this).hasClass('dc-form-li-selected')) {
|
297
|
-
// when not already selected toggle dc-form-li-selected class and save old tab
|
449
|
+
// when not already selected toggle dc-form-li-selected class and save old tab
|
298
450
|
if ($(this) !== $(e.target)) {
|
299
451
|
$(this).toggleClass('dc-form-li-selected');
|
300
452
|
$(e.target).toggleClass('dc-form-li-selected');
|
@@ -307,11 +459,15 @@ $(document).ready( function() {
|
|
307
459
|
if (old_tab_id !== null) {
|
308
460
|
$('#data_' + old_tab_id).toggleClass('div-hidden');
|
309
461
|
$('#data_' + e.target.getAttribute("data-div")).toggleClass('div-hidden');
|
310
|
-
|
311
|
-
|
312
|
-
|
462
|
+
|
463
|
+
// resize parent iframe to fit selected tab size
|
464
|
+
// var div_height = document.getElementById('data_' + e.target.getAttribute("data-div")).clientHeight + 130;
|
465
|
+
// var div_height = document.getElementById('cmsform').clientHeight + 50;
|
466
|
+
var div_height = document.body.scrollHeight;
|
467
|
+
window.frameElement.style.height = div_height.toString() + 'px';
|
313
468
|
// it would be too easy $('#cmsform :input:enabled:visible:first').focus();
|
314
469
|
select_first_input_field('#data_' + e.target.getAttribute("data-div"));
|
470
|
+
update_embedded_on_tab_select('#data_' + e.target.getAttribute("data-div"));
|
315
471
|
}
|
316
472
|
});
|
317
473
|
|
@@ -319,10 +475,9 @@ $(document).ready( function() {
|
|
319
475
|
* Resize iframe_cms to the size of its contents. Make at least 500 px high
|
320
476
|
* unless on initial display.
|
321
477
|
*******************************************************************/
|
322
|
-
$('#iframe_cms').load
|
323
|
-
// alert('bla 1');
|
478
|
+
$('#iframe_cms').on('load', function() {
|
324
479
|
new_height = this.contentWindow.document.body.offsetHeight + 50;
|
325
|
-
if (new_height < 500
|
480
|
+
if (new_height < 500 && new_height > 60) new_height = 500;
|
326
481
|
this.style.height = new_height + 'px';
|
327
482
|
// scroll to top
|
328
483
|
$('#iframe_cms').dc_scroll_view();
|
@@ -332,7 +487,7 @@ $(document).ready( function() {
|
|
332
487
|
* Same goes for editiframe. Resize it + 30px
|
333
488
|
* unless on initial display with no data
|
334
489
|
*******************************************************************/
|
335
|
-
$('#iframe_edit').load
|
490
|
+
$('#iframe_edit').on('load', function() {
|
336
491
|
// console.log(this.contentWindow.document.body.offsetHeight);
|
337
492
|
if (this.contentWindow.document.body.offsetHeight > 10) {
|
338
493
|
this.style.height = (this.contentWindow.document.body.offsetHeight + 30) + 'px';
|
@@ -345,42 +500,78 @@ $(document).ready( function() {
|
|
345
500
|
* Process Ajax call on cmsedit form actions
|
346
501
|
*******************************************************************/
|
347
502
|
$('.dc-link-ajax').on('click', function(e) {
|
348
|
-
//
|
349
|
-
if (
|
503
|
+
// confirmation if required
|
504
|
+
if (confirmation_is_cancled(this)) {return false;}
|
505
|
+
|
506
|
+
// check HTML5 validations
|
507
|
+
if ($("form")[0] && !$("form")[0].checkValidity() ) {
|
350
508
|
$("form")[0].reportValidity();
|
351
509
|
return false;
|
352
510
|
}
|
353
|
-
var
|
354
|
-
|
355
|
-
// Get values from elements on the page:
|
511
|
+
var req = this.getAttribute("data-request");
|
512
|
+
// Get values from elements on the page:
|
356
513
|
if (req == "script") {
|
357
|
-
eval (
|
514
|
+
eval (this.getAttribute("data-script"));
|
358
515
|
return false;
|
359
516
|
}
|
360
517
|
else if (req == "post") {
|
361
518
|
data = $('form').serialize();
|
362
|
-
// alert(data);
|
363
519
|
}
|
364
520
|
else {
|
365
521
|
data = {};
|
366
522
|
req = 'get'; // by default
|
367
523
|
}
|
368
524
|
|
369
|
-
$('.dc-spinner').
|
525
|
+
$('.dc-spinner').show();
|
370
526
|
$.ajax({
|
371
|
-
url:
|
527
|
+
url: this.getAttribute("data-url"),
|
372
528
|
type: req,
|
373
529
|
dataType: "json",
|
374
530
|
data: data,
|
375
|
-
// success: function(files,data,xhr) {
|
376
|
-
// document.getElementById('if_priponkas').contentDocument.location.reload(true);
|
377
|
-
// }
|
378
531
|
success: function(data) {
|
379
532
|
process_json_result(data);
|
380
|
-
$('.dc-spinner').
|
533
|
+
$('.dc-spinner').hide();
|
381
534
|
}
|
382
535
|
|
383
536
|
});
|
537
|
+
});
|
538
|
+
|
539
|
+
/*******************************************************************
|
540
|
+
* Process action submit button click.
|
541
|
+
*******************************************************************/
|
542
|
+
$('.dc-action-submit').on('click', function(e) {
|
543
|
+
// confirmation if required
|
544
|
+
if (confirmation_is_cancled(this)) {return false;}
|
545
|
+
|
546
|
+
// check HTML5 validations
|
547
|
+
var form = $("form")[0];
|
548
|
+
if (form && !form.checkValidity() ) {
|
549
|
+
form.reportValidity();
|
550
|
+
return false;
|
551
|
+
}
|
552
|
+
var url = this.getAttribute("data-url");
|
553
|
+
if (url == null) {return false;}
|
554
|
+
|
555
|
+
form.setAttribute('action', url);
|
556
|
+
form.setAttribute('method', "post");
|
557
|
+
form.submit();
|
558
|
+
});
|
559
|
+
|
560
|
+
/*******************************************************************
|
561
|
+
will open a new window with URL specified.
|
562
|
+
********************************************************************/
|
563
|
+
$('.dc-window-open').on('click', function(e) {
|
564
|
+
// confirmation if required
|
565
|
+
if (confirmation_is_cancled(this)) {return false;}
|
566
|
+
|
567
|
+
var url = this.getAttribute("data-url");
|
568
|
+
var title = this.getAttribute("title");
|
569
|
+
var w = 1000;
|
570
|
+
var h = 800;
|
571
|
+
var left = (screen.width/2)-(w/2);
|
572
|
+
var top = (screen.height/2)-(h/2);
|
573
|
+
var win = window.open(url, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
|
574
|
+
win.focus();
|
384
575
|
});
|
385
576
|
|
386
577
|
/*******************************************************************
|
@@ -432,11 +623,11 @@ $(document).ready( function() {
|
|
432
623
|
* Display spinner on link with spinner, submit link
|
433
624
|
*******************************************************************/
|
434
625
|
$('.dc-link-spinner').on('click', function(e) {
|
435
|
-
$('.dc-spinner').
|
626
|
+
$('.dc-spinner').show();
|
436
627
|
});
|
437
628
|
|
438
629
|
$('.dc-link-submit').on('click', function(e) {
|
439
|
-
$('.dc-spinner').
|
630
|
+
$('.dc-spinner').show();
|
440
631
|
});
|
441
632
|
|
442
633
|
/*******************************************************************
|
@@ -519,7 +710,7 @@ element = $(this).find(':first').attr('id');
|
|
519
710
|
/*******************************************************************
|
520
711
|
* Experimental. Force reload of parent page if this div appears.
|
521
712
|
*******************************************************************/
|
522
|
-
$('#div-reload-parent').load
|
713
|
+
$('#div-reload-parent').on('load', function() {
|
523
714
|
// alert('div-reload-parent 1');
|
524
715
|
parent.location.href = parent.location.href;
|
525
716
|
});
|
@@ -529,7 +720,7 @@ element = $(this).find(':first').attr('id');
|
|
529
720
|
*
|
530
721
|
* Just an Idea. Not needed yet.
|
531
722
|
*******************************************************************/
|
532
|
-
$('#div-reload').load
|
723
|
+
$('#div-reload').on('load', function() {
|
533
724
|
alert('div-reload 1');
|
534
725
|
// location.href = location.href;
|
535
726
|
});
|
@@ -590,12 +781,12 @@ element = $(this).find(':first').attr('id');
|
|
590
781
|
});
|
591
782
|
|
592
783
|
/*******************************************************************
|
593
|
-
* This will fire cmsedit index action and pass value
|
784
|
+
* This will fire cmsedit index action and pass value entered into
|
594
785
|
* filter field and thus refresh browsed result set.
|
595
786
|
*******************************************************************/
|
596
787
|
$('#_record__filter_field').keydown( function(e) {
|
597
788
|
if (e.which == '13' || e.which == '9') {
|
598
|
-
url = $(this).parents('span').attr("data-url");
|
789
|
+
var url = $(this).parents('span').attr("data-url");
|
599
790
|
url = url + "&filter_value=" + this.value;
|
600
791
|
location.href = url;
|
601
792
|
return false;
|
@@ -607,8 +798,8 @@ element = $(this).find(':first').attr('id');
|
|
607
798
|
* work on all field types.
|
608
799
|
*******************************************************************/
|
609
800
|
$('.record_filter_field_icon').on('click', function(e) {
|
610
|
-
field = $('#_record__filter_field');
|
611
|
-
url = $(this).parents('span').attr("data-url");
|
801
|
+
var field = $('#_record__filter_field');
|
802
|
+
var url = $(this).parents('span').attr("data-url");
|
612
803
|
url = url + "&filter_value=" + field.val();
|
613
804
|
location.href = url;
|
614
805
|
});
|
@@ -660,8 +851,9 @@ element = $(this).find(':first').attr('id');
|
|
660
851
|
});
|
661
852
|
|
662
853
|
/*******************************************************************
|
663
|
-
* Resize result table columns
|
854
|
+
* Resize result table columns. For now an idea.
|
664
855
|
*******************************************************************/
|
856
|
+
/*
|
665
857
|
$( ".dc-result-header .spacer" )
|
666
858
|
.mouseenter(function() {
|
667
859
|
console.log("enter");
|
@@ -669,7 +861,7 @@ element = $(this).find(':first').attr('id');
|
|
669
861
|
.mouseleave(function() {
|
670
862
|
console.log("leave");
|
671
863
|
});
|
672
|
-
|
864
|
+
*/
|
673
865
|
/*******************************************************************
|
674
866
|
* number_field type entered
|
675
867
|
*******************************************************************/
|
@@ -684,51 +876,57 @@ element = $(this).find(':first').attr('id');
|
|
684
876
|
/*******************************************************************
|
685
877
|
* number_field type leaved
|
686
878
|
*******************************************************************/
|
687
|
-
|
688
|
-
|
689
|
-
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
879
|
+
$('.dc-number').on('focusout', function(e) {
|
880
|
+
var decimals = $(this).attr("data-decimal") || 2;
|
881
|
+
var delimiter = $(this).attr("data-delimiter") || '.';
|
882
|
+
var separator = $(this).attr("data-separator") || ',';
|
883
|
+
var currency = $(this).attr("data-currency") || '';
|
884
|
+
var val = this.value;
|
885
|
+
// clear delimiters and replace separator with .
|
886
|
+
val = val.replace(delimiter,'');
|
887
|
+
val = val.replace(separator,'.');
|
888
|
+
val = parseFloat(val).toFixed(decimals);
|
889
|
+
var whole, dec, sign;
|
890
|
+
// [whole,dec] = val.split('.');
|
891
|
+
whole = val.split('.')[0];
|
892
|
+
dec = val.split('.')[1];
|
699
893
|
// remove negative sign and add at the end
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
894
|
+
var sign = whole.substr(0,1);
|
895
|
+
if (sign == '-') {
|
896
|
+
whole = whole.substr(1,20);
|
897
|
+
} else {
|
898
|
+
sign = '';
|
899
|
+
}
|
900
|
+
// save value to hidden field which holds return value
|
901
|
+
var field = '#' + $(this).attr("id").slice(0,-1);
|
902
|
+
$(field).val(val);
|
706
903
|
|
707
|
-
$(field).val( parseFloat(value).toFixed(decimals) );
|
708
|
-
|
709
904
|
// decimal part
|
710
|
-
|
711
|
-
|
712
|
-
|
905
|
+
if (decimals == 0) separator = '';
|
906
|
+
if (dec == null) dec = '';
|
907
|
+
while (dec.length < decimals) dec = dec + '0';
|
713
908
|
// whole part
|
714
|
-
|
715
|
-
|
716
|
-
|
717
|
-
|
718
|
-
|
719
|
-
|
720
|
-
|
909
|
+
if (whole == null || whole == '') whole = '0';
|
910
|
+
var ar = [];
|
911
|
+
while (whole.length > 0) {
|
912
|
+
var pos1 = whole.length - 3
|
913
|
+
if (pos1 < 0) pos1 = 0;
|
914
|
+
ar.unshift(whole.substr(pos1,3));
|
915
|
+
whole = whole.slice(0, -3);
|
721
916
|
};
|
722
917
|
|
723
|
-
|
724
|
-
|
918
|
+
if (delimiter !== '') whole = ar.join(delimiter);
|
919
|
+
$(this).val(sign + whole + separator + dec + currency);
|
725
920
|
});
|
726
921
|
|
727
922
|
/*******************************************************************
|
728
|
-
*
|
923
|
+
* Key pressed in number_field.
|
924
|
+
* - put minus sign in front of input field
|
925
|
+
* - replace dot and comma separators when required. Not all numeric pads are created equal.
|
926
|
+
* - when enter is pressed, save value to field before form is proccessed
|
729
927
|
*******************************************************************/
|
730
928
|
$('.dc-number').on('keydown', function(e) {
|
731
|
-
// Minus sign. Put it on first place
|
929
|
+
// Minus sign. Put it on first place
|
732
930
|
if (e.which == 109) {
|
733
931
|
if($(this).val().substr(0,1) == '-') {
|
734
932
|
$(this).val( $(this).val().substr(1,20));
|
@@ -737,16 +935,95 @@ element = $(this).find(':first').attr('id');
|
|
737
935
|
}
|
738
936
|
e.preventDefault();
|
739
937
|
}
|
740
|
-
//
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
938
|
+
// replace , with . if . is separator.
|
939
|
+
var separator = $(this).attr("data-separator") || '.';
|
940
|
+
var inp = this;
|
941
|
+
if (e.which == 188) {
|
942
|
+
if (separator == '.') {
|
943
|
+
setTimeout(function() {
|
944
|
+
inp.value = inp.value.replace(/,/g, '.');
|
945
|
+
}, 0);
|
946
|
+
}
|
947
|
+
}
|
948
|
+
// replace . with , if , is separator
|
949
|
+
if (e.which == 190) {
|
950
|
+
if (separator == ',') {
|
951
|
+
setTimeout(function() {
|
952
|
+
inp.value = inp.value.replace(/\./g, ',');
|
953
|
+
}, 0);
|
954
|
+
}
|
955
|
+
}
|
956
|
+
|
957
|
+
// Enter means process form. Save the value before form is processed
|
958
|
+
if (e.which == 13) {
|
959
|
+
var decimals = $(this).attr("data-decimal") || 2;
|
960
|
+
var value = $(this).val().replace(separator,'.');
|
961
|
+
var field = '#' + $(this).attr("id").slice(0,-1);
|
746
962
|
|
747
|
-
|
748
|
-
|
963
|
+
$(field).val( parseFloat(value).toFixed(decimals) );
|
964
|
+
}
|
749
965
|
});
|
966
|
+
|
967
|
+
/*******************************************************************
|
968
|
+
* Slovenian keyboard has comma key instead of dot in numeric pad.
|
969
|
+
* This will catch if comma has been pressed and will replace it with dot.
|
970
|
+
*******************************************************************/
|
971
|
+
$('.date-picker').keypress( function(e) {
|
972
|
+
if (e.keyCode !== 44) return;
|
973
|
+
var inp = this;
|
974
|
+
setTimeout(function() {
|
975
|
+
inp.value = inp.value.replace(/,/g, '.');
|
976
|
+
}, 0);
|
977
|
+
});
|
978
|
+
|
979
|
+
/*******************************************************************
|
980
|
+
* Result header sort icon is hoverd. Change background icon to filter.
|
981
|
+
*******************************************************************/
|
982
|
+
$('.dc-result-header .th i').hover( function() {
|
983
|
+
old_sort_icon = '';
|
984
|
+
// save old sort icon and replace it with filter icon
|
985
|
+
$.each( $(this).attr("class").split(/\s+/),
|
986
|
+
function(index, item) { if (item.match('sort')) { old_sort_icon = item}; }
|
987
|
+
);
|
988
|
+
$(this).removeClass(old_sort_icon).addClass('fa-filter');
|
989
|
+
// bring back old sort icon
|
990
|
+
}, function(){
|
991
|
+
$(this).removeClass('fa-filter').addClass(old_sort_icon);
|
992
|
+
});
|
993
|
+
|
994
|
+
/*******************************************************************
|
995
|
+
* Result header sort icon is clicked. Display filter menu for the field.
|
996
|
+
*******************************************************************/
|
997
|
+
$('.dc-result-header .th i').click( function(e) {
|
998
|
+
e.preventDefault();
|
999
|
+
// additional click will close dialog when visible
|
1000
|
+
if ($('.filter-popup').is(':visible')) {
|
1001
|
+
$('.filter-popup').hide();
|
1002
|
+
return;
|
1003
|
+
}
|
1004
|
+
// retrieve name of current field and set it in popup
|
1005
|
+
var header = $(this).closest('.th');
|
1006
|
+
var field_name = header.attr("data-name");
|
1007
|
+
$('.filter-popup').attr('data-name', field_name);
|
1008
|
+
// change popup position and show
|
1009
|
+
$('.filter-popup').css({'top':e.pageY+5,'left':e.pageX, 'position':'absolute'});
|
1010
|
+
$('.filter-popup').show();
|
1011
|
+
});
|
1012
|
+
|
1013
|
+
/*******************************************************************
|
1014
|
+
* Filter operation is clicked on filter popup. Retrieve data and call
|
1015
|
+
* filter on action.
|
1016
|
+
*******************************************************************/
|
1017
|
+
$('.filter-popup li').click( function(e) {
|
1018
|
+
var url = $(this).data('url')
|
1019
|
+
var operator = $(this).data('operator');
|
1020
|
+
var parent = $(this).closest('.filter-popup')
|
1021
|
+
var field_name = parent.data("name");
|
1022
|
+
|
1023
|
+
url = url + '&filter_field=' + field_name + '&filter_oper=' + operator;
|
1024
|
+
window.location.href = url;
|
1025
|
+
});
|
1026
|
+
|
750
1027
|
});
|
751
1028
|
|
752
1029
|
/*******************************************************************
|
@@ -765,9 +1042,7 @@ $(document).keydown( function(e) {
|
|
765
1042
|
});
|
766
1043
|
|
767
1044
|
/*******************************************************************
|
768
|
-
|
769
|
-
* almost every minute. That was a lesson learned years ago when I lost
|
770
|
-
* few hours of work on computer lockup ;-(
|
1045
|
+
|
771
1046
|
*******************************************************************
|
772
1047
|
$(document).onmousedown( function(e) {
|
773
1048
|
mouseDown = true;
|
@@ -779,4 +1054,4 @@ $(document).onmouseup( function(e) {
|
|
779
1054
|
console.log("mouse up");
|
780
1055
|
});
|
781
1056
|
|
782
|
-
**/
|
1057
|
+
**/
|