drg_cms 0.6.0.1 → 0.6.1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/drg_cms/drg_cms.js +454 -145
- data/app/assets/javascripts/drg_cms_application.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +635 -244
- data/app/assets/stylesheets/drg_cms/select-multiple.css +18 -12
- data/app/assets/stylesheets/drg_cms_cms.css +1 -1
- data/app/controllers/cmsedit_controller.rb +515 -335
- data/app/controllers/dc_application_controller.rb +378 -111
- data/app/controllers/dc_common_controller.rb +105 -14
- data/app/{controllers → controls}/browse_models_control.rb +0 -0
- data/app/controls/dc_help_control.rb +126 -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 +223 -0
- data/app/{controllers → controls}/design_element_settings_control.rb +0 -0
- data/app/forms/all_options.yml +44 -9
- data/app/forms/cms_menu.yml +28 -18
- 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_category.yml +2 -1
- data/app/forms/dc_design.yml +20 -16
- data/app/forms/dc_filter.yml +3 -6
- data/app/forms/dc_help_1.yml +109 -0
- data/app/forms/dc_journal.yml +3 -1
- data/app/forms/dc_json_ld.yml +59 -0
- data/app/forms/dc_key_value.yml +32 -0
- data/app/forms/dc_link.yml +1 -1
- data/app/forms/dc_menu.yml +2 -0
- data/app/forms/dc_menu_item.yml +2 -0
- data/app/forms/dc_page.yml +3 -5
- data/app/forms/dc_part.yml +1 -0
- data/app/forms/dc_piece.yml +1 -0
- data/app/forms/dc_poll.yml +15 -5
- 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_seo.yml +33 -0
- data/app/forms/dc_simple_menu.yml +2 -0
- data/app/forms/dc_site.yml +4 -12
- data/app/forms/dc_user.yml +27 -11
- data/app/forms/dc_user_role.yml +3 -0
- data/app/forms/json_ld_schema.yml +168 -0
- data/app/helpers/cms_common_helper.rb +375 -0
- data/app/helpers/cms_edit_helper.rb +506 -0
- data/app/helpers/cms_helper.rb +268 -0
- data/app/helpers/cms_index_helper.rb +580 -0
- data/app/helpers/dc_application_helper.rb +218 -306
- data/app/models/concerns/dc_page_concern.rb +40 -6
- data/app/models/concerns/dc_policy_rule_concern.rb +20 -8
- data/app/models/concerns/dc_seo_concern.rb +66 -0
- data/app/models/concerns/dc_site_concern.rb +67 -44
- data/app/models/concerns/dc_user_concern.rb +57 -18
- data/app/models/dc_design.rb +30 -18
- data/app/models/dc_filter.rb +22 -13
- data/app/models/dc_json_ld.rb +152 -0
- data/app/models/dc_key_value.rb +48 -0
- data/app/models/dc_key_value_store.rb +1 -0
- data/app/models/dc_memory.rb +8 -1
- data/app/models/dc_page.rb +0 -1
- data/app/models/dc_permission.rb +49 -9
- data/app/models/dc_policy.rb +25 -14
- data/app/models/dc_policy_role.rb +22 -11
- data/app/models/dc_poll.rb +39 -19
- data/app/models/dc_poll_result.rb +46 -0
- data/app/models/dc_temp.rb +140 -0
- data/app/models/dc_user_role.rb +2 -2
- data/app/models/drgcms_form_fields.rb +12 -1
- data/app/models/drgcms_form_fields/action.rb +61 -0
- data/app/models/drgcms_form_fields/comment.rb +8 -4
- data/app/models/drgcms_form_fields/date_picker.rb +11 -9
- data/app/models/drgcms_form_fields/date_select.rb +1 -1
- data/app/models/drgcms_form_fields/datetime_picker.rb +12 -10
- data/app/models/drgcms_form_fields/datetime_select.rb +1 -1
- data/app/models/drgcms_form_fields/drgcms_field.rb +55 -9
- data/app/models/drgcms_form_fields/embedded.rb +26 -16
- data/app/models/drgcms_form_fields/file_field.rb +52 -0
- data/app/models/drgcms_form_fields/file_select.rb +2 -2
- data/app/models/drgcms_form_fields/hash_field.rb +90 -0
- data/app/models/drgcms_form_fields/hidden_field.rb +1 -1
- data/app/models/drgcms_form_fields/html_field.rb +1 -1
- data/app/models/drgcms_form_fields/link_to.rb +2 -2
- data/app/models/drgcms_form_fields/method.rb +66 -0
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +23 -14
- data/app/models/drgcms_form_fields/number_field.rb +15 -6
- data/app/models/drgcms_form_fields/radio.rb +96 -0
- data/app/models/drgcms_form_fields/readonly.rb +2 -2
- data/app/models/drgcms_form_fields/select.rb +92 -29
- data/app/models/drgcms_form_fields/text_area.rb +1 -1
- data/app/models/drgcms_form_fields/text_autocomplete.rb +31 -17
- data/app/models/drgcms_form_fields/text_field.rb +1 -1
- data/app/models/drgcms_form_fields/text_with_select.rb +6 -3
- data/app/models/drgcms_form_fields/tree_select.rb +15 -4
- 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/{helpers → renderers}/dc_gallery_renderer.rb +1 -0
- data/app/{helpers → renderers}/dc_menu_renderer.rb +11 -4
- data/app/{helpers → renderers}/dc_page_renderer.rb +1 -0
- 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 +91 -64
- 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 +4 -1
- data/app/views/cmsedit/index.html.erb +7 -1
- data/app/views/cmsedit/new.html.erb +3 -1
- data/app/views/dc_common/_help.html.erb +17 -0
- data/app/views/layouts/models.html.erb +2 -1
- data/config/locales/drgcms_en.yml +27 -3
- data/config/locales/drgcms_sl.yml +32 -5
- data/config/locales/models_en.yml +65 -17
- data/config/locales/models_sl.yml +69 -18
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms.rb +61 -1
- data/lib/drg_cms/version.rb +1 -1
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +9 -2
- data/lib/tasks/database.rake +6 -56
- metadata +73 -54
- 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 -888
- data/app/models/dc_dummy.rb +0 -102
- data/test/fixtures/drg_cms_test_data.rb +0 -87
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a424c5a9f1d427b775dfb3a6a7bfa8ea0624c47fb2f4381c0fd19120a2c8c678
|
|
4
|
+
data.tar.gz: 6f0918c0365fbed1ff81e31bcd55be432ae8c02520f3811b18087941913957f5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 149a134733c8190f6b29003493f664e16fa2efad6608fb04a8bb607b9e00cd11a1752ec3b860d57af76789868667de12597b2023391879ad683ace066f71c1ec
|
|
7
|
+
data.tar.gz: 104ba8f48a7ad665da2f8ea99d833e04c94db4dc89a6d6ccecfe313ee5a082d7800691a31b805fb5cd35450e7350750ed68c073ef3e2bbafc971cfc8ff1180f2
|
|
@@ -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
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
update_embedded_on_tab_select = function(div_name) {
|
|
50
|
+
let iframes = $(div_name).find("iframe");
|
|
51
|
+
$.each(iframes, function(index, iframe) {
|
|
52
|
+
// delayed load
|
|
53
|
+
let 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
|
+
let 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,133 @@ $(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
|
-
|
|
202
|
+
let name = key.replace('record_','record[') + ']';
|
|
203
|
+
field = $('[name="' + name + '"]');
|
|
204
|
+
// checkbox field
|
|
205
|
+
if (field.is(':checkbox')) {
|
|
206
|
+
field.prop('checked', value);
|
|
207
|
+
// select field
|
|
208
|
+
} else if (field.is('select')) {
|
|
209
|
+
// options for select field
|
|
210
|
+
if (value && value.isArray) {
|
|
211
|
+
field.empty();
|
|
212
|
+
$.each(value, function(index, v) {
|
|
213
|
+
field.append( new Option(v[0], v[1]) );
|
|
214
|
+
});
|
|
215
|
+
// select field value
|
|
216
|
+
} else {
|
|
217
|
+
field.val(value).change();
|
|
218
|
+
}
|
|
219
|
+
// radio field
|
|
220
|
+
} else if (field.attr('type') == 'radio') {
|
|
221
|
+
field.val([value])
|
|
222
|
+
|
|
223
|
+
// other input fields
|
|
224
|
+
} else {
|
|
225
|
+
field.val(value);
|
|
226
|
+
}
|
|
152
227
|
break;
|
|
153
|
-
|
|
228
|
+
|
|
229
|
+
/**** display message ****/
|
|
154
230
|
case 'msg':
|
|
155
|
-
|
|
156
|
-
if ( $('.'+
|
|
157
|
-
|
|
158
|
-
$('.dc-title').after(
|
|
231
|
+
let msg_div = 'dc-form-' + selector;
|
|
232
|
+
if ( $('.' + msg_div).length == 0 ) {
|
|
233
|
+
value = '<div class="' + msg_div + '">' + value + '</div>';
|
|
234
|
+
$('.dc-title').after(value);
|
|
159
235
|
} else {
|
|
160
|
-
$('.'+
|
|
236
|
+
$('.' + msg_div).html(value);
|
|
237
|
+
$('.' + msg_div).show();
|
|
161
238
|
}
|
|
162
239
|
break;
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
$('#popup').
|
|
240
|
+
|
|
241
|
+
/**** display popup message ****/
|
|
242
|
+
case 'popup':
|
|
243
|
+
$('#popup').html(value);
|
|
244
|
+
$('#popup').bPopup({ speed: 650, transition: 'slideUp'});
|
|
245
|
+
break;
|
|
167
246
|
|
|
168
|
-
|
|
247
|
+
/**** update div ****/
|
|
169
248
|
case '#div+':
|
|
170
|
-
$('#'+
|
|
249
|
+
$('#'+selector).append(value);
|
|
171
250
|
break;
|
|
172
251
|
case '#+div':
|
|
173
|
-
$('#'+
|
|
252
|
+
$('#'+selector).prepend(value);
|
|
174
253
|
break;
|
|
175
254
|
case '#div':
|
|
176
|
-
$('#'+
|
|
255
|
+
$('#'+selector).html(value);
|
|
177
256
|
break;
|
|
178
257
|
case '.div+':
|
|
179
|
-
$('.'+
|
|
258
|
+
$('.'+selector).append(value);
|
|
180
259
|
break;
|
|
181
260
|
case '.+div':
|
|
182
|
-
$('.'+
|
|
261
|
+
$('.'+selector).prepend(value);
|
|
183
262
|
break;
|
|
184
263
|
case '.div':
|
|
185
|
-
$('.'+
|
|
264
|
+
$('.'+selector).html(value);
|
|
186
265
|
break;
|
|
187
|
-
|
|
266
|
+
|
|
267
|
+
/**** goto url ****/
|
|
188
268
|
case 'url':
|
|
189
|
-
window.location.href =
|
|
269
|
+
window.location.href = value;
|
|
190
270
|
break;
|
|
191
271
|
case 'alert':
|
|
192
|
-
alert(
|
|
272
|
+
alert(value);
|
|
193
273
|
break;
|
|
194
274
|
case 'window':
|
|
195
|
-
|
|
275
|
+
if (value == 'close') { window.close();
|
|
276
|
+
} else if (value == 'reload') {
|
|
277
|
+
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
|
+
value = value.toString();
|
|
296
|
+
if (value == 'parent') {
|
|
297
|
+
parent.location.reload();
|
|
298
|
+
/*** this would be current window (reload: true) ****/
|
|
299
|
+
} else if (value.length < 5) {
|
|
300
|
+
location.reload();
|
|
301
|
+
/*** reload iframe ****/
|
|
302
|
+
} else {
|
|
303
|
+
$( '#' + value ).attr('src', $( '#' + value ).attr('src'));
|
|
304
|
+
}
|
|
200
305
|
break;
|
|
201
306
|
default:
|
|
202
307
|
console.log("DRGCMS: Invalid ajax result operation: " + operation);
|
|
@@ -236,6 +341,42 @@ $.fn.dc_scroll_view = function () {
|
|
|
236
341
|
});
|
|
237
342
|
};
|
|
238
343
|
|
|
344
|
+
/*******************************************************************
|
|
345
|
+
* Updates single field on parent iframe form of embedded form.
|
|
346
|
+
*******************************************************************/
|
|
347
|
+
process_parent_form_updates = function(element) {
|
|
348
|
+
let field = element.getAttribute("data-field");
|
|
349
|
+
let value = element.getAttribute("data-value");
|
|
350
|
+
let selector = '#' + field;
|
|
351
|
+
|
|
352
|
+
// update record
|
|
353
|
+
if (field.match(/record/)) {
|
|
354
|
+
if (window.parent.$(selector).length > 0) {
|
|
355
|
+
if (field.substring(0, 3) === 'td_') { // readonly field
|
|
356
|
+
window.parent.$(selector + ' > div').html(value);
|
|
357
|
+
} else { // input field
|
|
358
|
+
window.parent.$(selector).val(value);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
// any div
|
|
362
|
+
} else {
|
|
363
|
+
if (window.parent.$(selector).length > 0) {
|
|
364
|
+
window.parent.$(selector).html(value);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
/*****************************************************************
|
|
370
|
+
* Toggle show and hide div
|
|
371
|
+
******************************************************************/
|
|
372
|
+
dc_toggle_div = function(div) {
|
|
373
|
+
if ($(div).is(":visible")) {
|
|
374
|
+
$(div).slideUp();
|
|
375
|
+
} else {
|
|
376
|
+
$(div).slideDown();
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
239
380
|
/*******************************************************************
|
|
240
381
|
*
|
|
241
382
|
*******************************************************************/
|
|
@@ -248,6 +389,27 @@ $(document).ready( function() {
|
|
|
248
389
|
// select_first_input_field('.dc-form');
|
|
249
390
|
}
|
|
250
391
|
*/
|
|
392
|
+
/*******************************************************************
|
|
393
|
+
* It will scroll display to ypos if return_to_ypos parameter is present
|
|
394
|
+
*******************************************************************/
|
|
395
|
+
if (window.location.href.match(/return_to_ypos=/))
|
|
396
|
+
{
|
|
397
|
+
window.scrollTo(0, $.getUrlParam('return_to_ypos'));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/*******************************************************************
|
|
401
|
+
* The idea is to update fields on parent iframe form, when embedded document
|
|
402
|
+
* is updated in its iframe. Update fields are listed in .dc-form-updates div
|
|
403
|
+
* and are set by flash[:update] Hash object.
|
|
404
|
+
*
|
|
405
|
+
* eg. flash[:update] = {'td_record_radonly' => 'New value for read_only field',
|
|
406
|
+
* 'record_name' => 'New name'}
|
|
407
|
+
*******************************************************************/
|
|
408
|
+
if ( $('.dc-form-updates').length > 0 ) {
|
|
409
|
+
$('.dc-form-updates').children().each( function( index, element ) {
|
|
410
|
+
process_parent_form_updates(element);
|
|
411
|
+
});
|
|
412
|
+
}
|
|
251
413
|
|
|
252
414
|
/*******************************************************************
|
|
253
415
|
* Register ad clicks
|
|
@@ -257,6 +419,17 @@ $(document).ready( function() {
|
|
|
257
419
|
return true;
|
|
258
420
|
});
|
|
259
421
|
|
|
422
|
+
/*****************************************************************
|
|
423
|
+
* Toggle CMS mode. When clicked on left 30 pixels, window will be scrolled approximately
|
|
424
|
+
* to the position wher toggle was clicked. When clicked from pixel 31 and on it will
|
|
425
|
+
* stay on the top of window.
|
|
426
|
+
******************************************************************/
|
|
427
|
+
$('.cms-toggle').bind('click', function(e) {
|
|
428
|
+
var url = '/dc_common/toggle_edit_mode?return_to=' + window.location.href;
|
|
429
|
+
if (e.pageX < 30) url = url + '&return_to_ypos=' + e.pageY ;
|
|
430
|
+
window.location.href = url;
|
|
431
|
+
});
|
|
432
|
+
|
|
260
433
|
/*******************************************************************
|
|
261
434
|
* Popup or close CMS edit menu on icon click
|
|
262
435
|
*******************************************************************/
|
|
@@ -280,21 +453,22 @@ $(document).ready( function() {
|
|
|
280
453
|
* Sort action clicked on cmsedit
|
|
281
454
|
*******************************************************************/
|
|
282
455
|
$('.drgcms_sort').change( function(e) {
|
|
283
|
-
table = e.target.getAttribute("data-table");
|
|
284
|
-
|
|
456
|
+
var table = e.target.getAttribute("data-table");
|
|
457
|
+
var form = e.target.getAttribute("data-form");
|
|
458
|
+
var sort = e.target.value;
|
|
285
459
|
e.target.value = null;
|
|
286
|
-
window.location.href = "/cmsedit?sort=" + sort + "&table=" + table;
|
|
460
|
+
window.location.href = "/cmsedit?sort=" + sort + "&table=" + table + "&form_name=" + form;
|
|
287
461
|
});
|
|
288
462
|
|
|
289
463
|
/*******************************************************************
|
|
290
464
|
* Tab clicked on form. Hide old and show selected div.
|
|
291
465
|
*******************************************************************/
|
|
292
466
|
$('.dc-form-li').on('click', function(e) {
|
|
293
|
-
// find li with dc-form-li-selected class. This is our old tab
|
|
294
|
-
|
|
467
|
+
// find li with dc-form-li-selected class. This is our old tab
|
|
468
|
+
let old_tab_id = null;
|
|
295
469
|
$(e.target).parents('ul').find('li').each( function() {
|
|
296
470
|
if ($(this).hasClass('dc-form-li-selected')) {
|
|
297
|
-
// when not already selected toggle dc-form-li-selected class and save old tab
|
|
471
|
+
// when not already selected toggle dc-form-li-selected class and save old tab
|
|
298
472
|
if ($(this) !== $(e.target)) {
|
|
299
473
|
$(this).toggleClass('dc-form-li-selected');
|
|
300
474
|
$(e.target).toggleClass('dc-form-li-selected');
|
|
@@ -307,11 +481,15 @@ $(document).ready( function() {
|
|
|
307
481
|
if (old_tab_id !== null) {
|
|
308
482
|
$('#data_' + old_tab_id).toggleClass('div-hidden');
|
|
309
483
|
$('#data_' + e.target.getAttribute("data-div")).toggleClass('div-hidden');
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
484
|
+
|
|
485
|
+
// resize parent iframe to fit selected tab size
|
|
486
|
+
let div_height = document.body.scrollHeight;
|
|
487
|
+
let frame = window.frameElement
|
|
488
|
+
if (frame === null) frame = document.body;
|
|
489
|
+
frame.style.height = div_height.toString() + 'px';
|
|
490
|
+
|
|
314
491
|
select_first_input_field('#data_' + e.target.getAttribute("data-div"));
|
|
492
|
+
update_embedded_on_tab_select('#data_' + e.target.getAttribute("data-div"));
|
|
315
493
|
}
|
|
316
494
|
});
|
|
317
495
|
|
|
@@ -319,12 +497,11 @@ $(document).ready( function() {
|
|
|
319
497
|
* Resize iframe_cms to the size of its contents. Make at least 500 px high
|
|
320
498
|
* unless on initial display.
|
|
321
499
|
*******************************************************************/
|
|
322
|
-
$('#iframe_cms').load
|
|
323
|
-
|
|
324
|
-
new_height = this.contentWindow.document.body.offsetHeight + 50;
|
|
500
|
+
$('#iframe_cms').on('load', function() {
|
|
501
|
+
let new_height = this.contentWindow.document.body.offsetHeight + 50;
|
|
325
502
|
if (new_height < 500 && new_height > 60) new_height = 500;
|
|
326
503
|
this.style.height = new_height + 'px';
|
|
327
|
-
// scroll to top
|
|
504
|
+
// scroll to top
|
|
328
505
|
$('#iframe_cms').dc_scroll_view();
|
|
329
506
|
});
|
|
330
507
|
|
|
@@ -332,61 +509,99 @@ $(document).ready( function() {
|
|
|
332
509
|
* Same goes for editiframe. Resize it + 30px
|
|
333
510
|
* unless on initial display with no data
|
|
334
511
|
*******************************************************************/
|
|
335
|
-
$('#iframe_edit').load
|
|
336
|
-
// console.log(this.contentWindow.document.body.offsetHeight);
|
|
512
|
+
$('#iframe_edit').on('load', function() {
|
|
337
513
|
if (this.contentWindow.document.body.offsetHeight > 10) {
|
|
338
514
|
this.style.height = (this.contentWindow.document.body.offsetHeight + 30) + 'px';
|
|
339
|
-
|
|
515
|
+
|
|
340
516
|
$('#iframe_edit').dc_scroll_view();
|
|
341
517
|
}
|
|
342
518
|
});
|
|
343
|
-
|
|
519
|
+
|
|
520
|
+
/*******************************************************************
|
|
521
|
+
* Same goes for iframe_embedded. Resize it + 30px
|
|
522
|
+
*******************************************************************/
|
|
523
|
+
$('.iframe_embedded').on('load', function() {
|
|
524
|
+
let embedded_height = this.contentWindow.document.body.offsetHeight;
|
|
525
|
+
// workaround. It gets tricky when embedded field is on tab
|
|
526
|
+
if (embedded_height == 0) embedded_height = 500;
|
|
527
|
+
this.style.height = (embedded_height + 30) + 'px';
|
|
528
|
+
// resize parent iframe window too
|
|
529
|
+
let parentWindow = this.contentWindow.parent;
|
|
530
|
+
let parent_height = (parentWindow.document.body.offsetHeight + 30) + 'px';
|
|
531
|
+
//parentWindow.frameElement.setAttribute('style', 'height:' + parent_height);
|
|
532
|
+
parentWindow.frameElement.style.height = parent_height;
|
|
533
|
+
});
|
|
534
|
+
|
|
344
535
|
/*******************************************************************
|
|
345
536
|
* Process Ajax call on cmsedit form actions
|
|
346
537
|
*******************************************************************/
|
|
347
538
|
$('.dc-link-ajax').on('click', function(e) {
|
|
348
|
-
//
|
|
539
|
+
// confirmation if required
|
|
540
|
+
if (confirmation_is_cancled(this)) {return false;}
|
|
541
|
+
|
|
542
|
+
// check HTML5 validations
|
|
349
543
|
if ($("form")[0] && !$("form")[0].checkValidity() ) {
|
|
350
544
|
$("form")[0].reportValidity();
|
|
351
545
|
return false;
|
|
352
546
|
}
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
// Get values from elements on the page:
|
|
547
|
+
let req = this.getAttribute("data-request");
|
|
548
|
+
// Get values from elements on the page:
|
|
356
549
|
if (req == "script") {
|
|
357
|
-
eval (
|
|
550
|
+
eval (this.getAttribute("data-script"));
|
|
358
551
|
return false;
|
|
359
552
|
}
|
|
360
553
|
else if (req == "post") {
|
|
361
554
|
data = $('form').serialize();
|
|
362
|
-
// alert(data);
|
|
363
555
|
}
|
|
364
556
|
else {
|
|
365
557
|
data = {};
|
|
366
558
|
req = 'get'; // by default
|
|
367
559
|
}
|
|
368
|
-
|
|
369
|
-
|
|
560
|
+
|
|
561
|
+
let url = this.getAttribute("data-url");
|
|
562
|
+
if (url.length < 5) return false;
|
|
563
|
+
|
|
564
|
+
$('.dc-spinner').show();
|
|
370
565
|
$.ajax({
|
|
371
|
-
url:
|
|
566
|
+
url: url,
|
|
372
567
|
type: req,
|
|
373
568
|
dataType: "json",
|
|
374
569
|
data: data,
|
|
375
|
-
// success: function(files,data,xhr) {
|
|
376
|
-
// document.getElementById('if_priponkas').contentDocument.location.reload(true);
|
|
377
|
-
// }
|
|
378
570
|
success: function(data) {
|
|
379
571
|
process_json_result(data);
|
|
380
|
-
$('.dc-spinner').
|
|
572
|
+
$('.dc-spinner').hide();
|
|
381
573
|
}
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
574
|
+
});
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
/*******************************************************************
|
|
578
|
+
* Process action submit button click.
|
|
579
|
+
*******************************************************************/
|
|
580
|
+
$('.dc-action-submit').on('click', function(e) {
|
|
581
|
+
// confirmation if required
|
|
582
|
+
if (confirmation_is_cancled(this)) {return false;}
|
|
583
|
+
|
|
584
|
+
// check HTML5 validations
|
|
585
|
+
var form = $("form")[0];
|
|
586
|
+
if (form && !form.checkValidity() ) {
|
|
587
|
+
form.reportValidity();
|
|
588
|
+
return false;
|
|
589
|
+
}
|
|
590
|
+
var url = this.getAttribute("data-url");
|
|
591
|
+
if (url == null) {return false;}
|
|
592
|
+
|
|
593
|
+
form.setAttribute('action', url);
|
|
594
|
+
form.setAttribute('method', "post");
|
|
595
|
+
form.submit();
|
|
596
|
+
});
|
|
385
597
|
|
|
386
598
|
/*******************************************************************
|
|
387
599
|
will open a new window with URL specified.
|
|
388
600
|
********************************************************************/
|
|
389
601
|
$('.dc-window-open').on('click', function(e) {
|
|
602
|
+
// confirmation if required
|
|
603
|
+
if (confirmation_is_cancled(this)) {return false;}
|
|
604
|
+
|
|
390
605
|
var url = this.getAttribute("data-url");
|
|
391
606
|
var title = this.getAttribute("title");
|
|
392
607
|
var w = 1000;
|
|
@@ -395,7 +610,6 @@ $(document).ready( function() {
|
|
|
395
610
|
var top = (screen.height/2)-(h/2);
|
|
396
611
|
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);
|
|
397
612
|
win.focus();
|
|
398
|
-
// $('#bpopup').bPopup({ loadUrl: url, speed: 650, transition: 'slideDown' });
|
|
399
613
|
});
|
|
400
614
|
|
|
401
615
|
/*******************************************************************
|
|
@@ -447,11 +661,11 @@ $(document).ready( function() {
|
|
|
447
661
|
* Display spinner on link with spinner, submit link
|
|
448
662
|
*******************************************************************/
|
|
449
663
|
$('.dc-link-spinner').on('click', function(e) {
|
|
450
|
-
$('.dc-spinner').
|
|
664
|
+
$('.dc-spinner').show();
|
|
451
665
|
});
|
|
452
666
|
|
|
453
667
|
$('.dc-link-submit').on('click', function(e) {
|
|
454
|
-
$('.dc-spinner').
|
|
668
|
+
$('.dc-spinner').show();
|
|
455
669
|
});
|
|
456
670
|
|
|
457
671
|
/*******************************************************************
|
|
@@ -460,8 +674,8 @@ $(document).ready( function() {
|
|
|
460
674
|
* data from with text_autocomplete and data doesn't exist in belongs_to table.
|
|
461
675
|
*******************************************************************/
|
|
462
676
|
$('.in-edit-add').on('click', function(e) {
|
|
463
|
-
url = '/cmsedit/new?table=' + this.getAttribute("data-table");
|
|
464
|
-
|
|
677
|
+
let url = '/cmsedit/new?table=' + this.getAttribute("data-table");
|
|
678
|
+
// I know. It doesn't work as expected. But it will do for now.
|
|
465
679
|
w = window.open(url, '', 'chrome=yes,width=800,height=600,resizable,scrollbars=yes,status=1,centerscreen=yes,modal=yes');
|
|
466
680
|
w.focus();
|
|
467
681
|
});
|
|
@@ -472,13 +686,9 @@ $(document).ready( function() {
|
|
|
472
686
|
**********************************************************************/
|
|
473
687
|
$('#filter_field').on('change', function() {
|
|
474
688
|
if (this.value.length > 0) {
|
|
475
|
-
name = 'filter_' + this.value;
|
|
689
|
+
let name = 'filter_' + this.value;
|
|
476
690
|
$(this).parents('form').find('span').each( function() {
|
|
477
|
-
|
|
478
|
-
element = $(this).find(':first').attr('id');
|
|
479
|
-
sometimes it is the second element
|
|
480
|
-
if (element == nil) { element = $(this).find(':first').next().attr('id');}
|
|
481
|
-
*/
|
|
691
|
+
|
|
482
692
|
if ($(this).attr('id') == name) {
|
|
483
693
|
if ( $(this).hasClass('div-hidden') ) { $(this).toggleClass('div-hidden'); }
|
|
484
694
|
} else {
|
|
@@ -534,7 +744,7 @@ element = $(this).find(':first').attr('id');
|
|
|
534
744
|
/*******************************************************************
|
|
535
745
|
* Experimental. Force reload of parent page if this div appears.
|
|
536
746
|
*******************************************************************/
|
|
537
|
-
$('#div-reload-parent').load
|
|
747
|
+
$('#div-reload-parent').on('load', function() {
|
|
538
748
|
// alert('div-reload-parent 1');
|
|
539
749
|
parent.location.href = parent.location.href;
|
|
540
750
|
});
|
|
@@ -544,7 +754,7 @@ element = $(this).find(':first').attr('id');
|
|
|
544
754
|
*
|
|
545
755
|
* Just an Idea. Not needed yet.
|
|
546
756
|
*******************************************************************/
|
|
547
|
-
$('#div-reload').load
|
|
757
|
+
$('#div-reload').on('load', function() {
|
|
548
758
|
alert('div-reload 1');
|
|
549
759
|
// location.href = location.href;
|
|
550
760
|
});
|
|
@@ -560,8 +770,8 @@ element = $(this).find(':first').attr('id');
|
|
|
560
770
|
* Fire action (by default show document) when doubleclicked on result row
|
|
561
771
|
*******************************************************************/
|
|
562
772
|
$('.dc-result tr').on('dblclick', function(e) {
|
|
563
|
-
url = String( this.getAttribute("data-dblclick") );
|
|
564
|
-
// prevent when data-dblclick not set
|
|
773
|
+
let url = String( this.getAttribute("data-dblclick") );
|
|
774
|
+
// prevent when data-dblclick not set
|
|
565
775
|
if (url.length > 5) {
|
|
566
776
|
e.preventDefault();
|
|
567
777
|
location.href = url;
|
|
@@ -572,8 +782,8 @@ element = $(this).find(':first').attr('id');
|
|
|
572
782
|
* Fire action (by default show document) when doubleclicked on result row
|
|
573
783
|
*******************************************************************/
|
|
574
784
|
$('.dc-result-data').on('dblclick', function(e) {
|
|
575
|
-
url = String( this.getAttribute("data-dblclick") );
|
|
576
|
-
// prevent when data-dblclick not set
|
|
785
|
+
let url = String( this.getAttribute("data-dblclick") );
|
|
786
|
+
// prevent when data-dblclick not set
|
|
577
787
|
if (url.length > 5) {
|
|
578
788
|
e.preventDefault();
|
|
579
789
|
location.href = url;
|
|
@@ -605,12 +815,12 @@ element = $(this).find(':first').attr('id');
|
|
|
605
815
|
});
|
|
606
816
|
|
|
607
817
|
/*******************************************************************
|
|
608
|
-
* This will fire cmsedit index action and pass value
|
|
818
|
+
* This will fire cmsedit index action and pass value entered into
|
|
609
819
|
* filter field and thus refresh browsed result set.
|
|
610
820
|
*******************************************************************/
|
|
611
821
|
$('#_record__filter_field').keydown( function(e) {
|
|
612
822
|
if (e.which == '13' || e.which == '9') {
|
|
613
|
-
url = $(this).parents('span').attr("data-url");
|
|
823
|
+
var url = $(this).parents('span').attr("data-url");
|
|
614
824
|
url = url + "&filter_value=" + this.value;
|
|
615
825
|
location.href = url;
|
|
616
826
|
return false;
|
|
@@ -622,9 +832,16 @@ element = $(this).find(':first').attr('id');
|
|
|
622
832
|
* work on all field types.
|
|
623
833
|
*******************************************************************/
|
|
624
834
|
$('.record_filter_field_icon').on('click', function(e) {
|
|
625
|
-
field = $('#_record__filter_field');
|
|
626
|
-
url = $(this).parents('span').attr("data-url");
|
|
627
|
-
|
|
835
|
+
let field = $('#_record__filter_field');
|
|
836
|
+
let url = $(this).parents('span').attr("data-url");
|
|
837
|
+
let value = null;
|
|
838
|
+
|
|
839
|
+
if (field.is(':checkbox')) {
|
|
840
|
+
value = field.is(':checked'); }
|
|
841
|
+
else {
|
|
842
|
+
value = field.val();
|
|
843
|
+
}
|
|
844
|
+
url = url + "&filter_value=" + value;
|
|
628
845
|
location.href = url;
|
|
629
846
|
});
|
|
630
847
|
|
|
@@ -675,8 +892,9 @@ element = $(this).find(':first').attr('id');
|
|
|
675
892
|
});
|
|
676
893
|
|
|
677
894
|
/*******************************************************************
|
|
678
|
-
* Resize result table columns
|
|
895
|
+
* Resize result table columns. For now an idea.
|
|
679
896
|
*******************************************************************/
|
|
897
|
+
/*
|
|
680
898
|
$( ".dc-result-header .spacer" )
|
|
681
899
|
.mouseenter(function() {
|
|
682
900
|
console.log("enter");
|
|
@@ -684,7 +902,7 @@ element = $(this).find(':first').attr('id');
|
|
|
684
902
|
.mouseleave(function() {
|
|
685
903
|
console.log("leave");
|
|
686
904
|
});
|
|
687
|
-
|
|
905
|
+
*/
|
|
688
906
|
/*******************************************************************
|
|
689
907
|
* number_field type entered
|
|
690
908
|
*******************************************************************/
|
|
@@ -699,51 +917,57 @@ element = $(this).find(':first').attr('id');
|
|
|
699
917
|
/*******************************************************************
|
|
700
918
|
* number_field type leaved
|
|
701
919
|
*******************************************************************/
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
920
|
+
$('.dc-number').on('focusout', function(e) {
|
|
921
|
+
var decimals = $(this).attr("data-decimal") || 2;
|
|
922
|
+
var delimiter = $(this).attr("data-delimiter") || '.';
|
|
923
|
+
var separator = $(this).attr("data-separator") || ',';
|
|
924
|
+
var currency = $(this).attr("data-currency") || '';
|
|
925
|
+
var val = this.value;
|
|
926
|
+
// clear delimiters and replace separator with .
|
|
927
|
+
val = val.replace(delimiter,'');
|
|
928
|
+
val = val.replace(separator,'.');
|
|
929
|
+
val = parseFloat(val).toFixed(decimals);
|
|
930
|
+
var whole, dec, sign;
|
|
931
|
+
// [whole,dec] = val.split('.');
|
|
932
|
+
whole = val.split('.')[0];
|
|
933
|
+
dec = val.split('.')[1];
|
|
714
934
|
// remove negative sign and add at the end
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
935
|
+
var sign = whole.substr(0,1);
|
|
936
|
+
if (sign == '-') {
|
|
937
|
+
whole = whole.substr(1,20);
|
|
938
|
+
} else {
|
|
939
|
+
sign = '';
|
|
940
|
+
}
|
|
941
|
+
// save value to hidden field which holds return value
|
|
942
|
+
var field = '#' + $(this).attr("id").slice(0,-1);
|
|
943
|
+
$(field).val(val);
|
|
721
944
|
|
|
722
|
-
$(field).val( parseFloat(value).toFixed(decimals) );
|
|
723
|
-
|
|
724
945
|
// decimal part
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
946
|
+
if (decimals == 0) separator = '';
|
|
947
|
+
if (dec == null) dec = '';
|
|
948
|
+
while (dec.length < decimals) dec = dec + '0';
|
|
728
949
|
// whole part
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
950
|
+
if (whole == null || whole == '') whole = '0';
|
|
951
|
+
var ar = [];
|
|
952
|
+
while (whole.length > 0) {
|
|
953
|
+
var pos1 = whole.length - 3
|
|
954
|
+
if (pos1 < 0) pos1 = 0;
|
|
955
|
+
ar.unshift(whole.substr(pos1,3));
|
|
956
|
+
whole = whole.slice(0, -3);
|
|
736
957
|
};
|
|
737
958
|
|
|
738
|
-
|
|
739
|
-
|
|
959
|
+
if (delimiter !== '') whole = ar.join(delimiter);
|
|
960
|
+
$(this).val(sign + whole + separator + dec + currency);
|
|
740
961
|
});
|
|
741
962
|
|
|
742
963
|
/*******************************************************************
|
|
743
|
-
*
|
|
964
|
+
* Key pressed in number_field.
|
|
965
|
+
* - put minus sign in front of input field
|
|
966
|
+
* - replace dot and comma separators when required. Not all numeric pads are created equal.
|
|
967
|
+
* - when enter is pressed, save value to field before form is proccessed
|
|
744
968
|
*******************************************************************/
|
|
745
969
|
$('.dc-number').on('keydown', function(e) {
|
|
746
|
-
// Minus sign. Put it on first place
|
|
970
|
+
// Minus sign. Put it on first place
|
|
747
971
|
if (e.which == 109) {
|
|
748
972
|
if($(this).val().substr(0,1) == '-') {
|
|
749
973
|
$(this).val( $(this).val().substr(1,20));
|
|
@@ -752,16 +976,103 @@ element = $(this).find(':first').attr('id');
|
|
|
752
976
|
}
|
|
753
977
|
e.preventDefault();
|
|
754
978
|
}
|
|
755
|
-
//
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
979
|
+
// replace , with . if . is separator.
|
|
980
|
+
var separator = $(this).attr("data-separator") || '.';
|
|
981
|
+
var inp = this;
|
|
982
|
+
if (e.which == 188) {
|
|
983
|
+
if (separator == '.') {
|
|
984
|
+
setTimeout(function() {
|
|
985
|
+
inp.value = inp.value.replace(/,/g, '.');
|
|
986
|
+
}, 0);
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
// replace . with , if , is separator
|
|
990
|
+
if (e.which == 190) {
|
|
991
|
+
if (separator == ',') {
|
|
992
|
+
setTimeout(function() {
|
|
993
|
+
inp.value = inp.value.replace(/\./g, ',');
|
|
994
|
+
}, 0);
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
// Enter means process form. Save the value before form is processed
|
|
999
|
+
if (e.which == 13) {
|
|
1000
|
+
var decimals = $(this).attr("data-decimal") || 2;
|
|
1001
|
+
var value = $(this).val().replace(separator,'.');
|
|
1002
|
+
var field = '#' + $(this).attr("id").slice(0,-1);
|
|
761
1003
|
|
|
762
|
-
|
|
763
|
-
|
|
1004
|
+
$(field).val( parseFloat(value).toFixed(decimals) );
|
|
1005
|
+
}
|
|
764
1006
|
});
|
|
1007
|
+
|
|
1008
|
+
/*******************************************************************
|
|
1009
|
+
* Slovenian keyboard has comma key instead of dot in numeric pad.
|
|
1010
|
+
* This will catch if comma has been pressed and will replace it with dot.
|
|
1011
|
+
*******************************************************************/
|
|
1012
|
+
$('.date-picker').keypress( function(e) {
|
|
1013
|
+
if (e.keyCode !== 44) return;
|
|
1014
|
+
var inp = this;
|
|
1015
|
+
setTimeout(function() {
|
|
1016
|
+
inp.value = inp.value.replace(/,/g, '.');
|
|
1017
|
+
}, 0);
|
|
1018
|
+
});
|
|
1019
|
+
|
|
1020
|
+
/*******************************************************************
|
|
1021
|
+
* Result header sort icon is hoverd. Change background icon to filter.
|
|
1022
|
+
*******************************************************************/
|
|
1023
|
+
$('.dc-result-header .th i').hover( function() {
|
|
1024
|
+
old_sort_icon = '';
|
|
1025
|
+
// save old sort icon and replace it with filter icon
|
|
1026
|
+
$.each( $(this).attr("class").split(/\s+/),
|
|
1027
|
+
function(index, item) { if (item.match('sort')) { old_sort_icon = item}; }
|
|
1028
|
+
);
|
|
1029
|
+
$(this).removeClass(old_sort_icon).addClass('fa-filter');
|
|
1030
|
+
// bring back old sort icon
|
|
1031
|
+
}, function(){
|
|
1032
|
+
$(this).removeClass('fa-filter').addClass(old_sort_icon);
|
|
1033
|
+
});
|
|
1034
|
+
|
|
1035
|
+
/*******************************************************************
|
|
1036
|
+
* Result header sort icon is clicked. Display filter menu for the field.
|
|
1037
|
+
*******************************************************************/
|
|
1038
|
+
$('.dc-result-header .th i').click( function(e) {
|
|
1039
|
+
e.preventDefault();
|
|
1040
|
+
// additional click will close dialog when visible
|
|
1041
|
+
if ($('.filter-popup').is(':visible')) {
|
|
1042
|
+
$('.filter-popup').hide();
|
|
1043
|
+
return;
|
|
1044
|
+
}
|
|
1045
|
+
// retrieve name of current field and set it in popup
|
|
1046
|
+
let header = $(this).closest('.th');
|
|
1047
|
+
let field_name = header.attr("data-name");
|
|
1048
|
+
$('.filter-popup').attr('data-name', field_name);
|
|
1049
|
+
// change popup position and show
|
|
1050
|
+
$('.filter-popup').css({'top':e.pageY+5,'left':e.pageX, 'position':'absolute'});
|
|
1051
|
+
$('.filter-popup').show();
|
|
1052
|
+
});
|
|
1053
|
+
|
|
1054
|
+
/*******************************************************************
|
|
1055
|
+
* Filter operation is clicked on filter popup. Retrieve data and call
|
|
1056
|
+
* filter on action.
|
|
1057
|
+
*******************************************************************/
|
|
1058
|
+
$('.filter-popup li').click( function(e) {
|
|
1059
|
+
let url = $(this).data('url');
|
|
1060
|
+
let operator = $(this).data('operator');
|
|
1061
|
+
let parent = $(this).closest('.filter-popup');
|
|
1062
|
+
let field_name = parent.data("name");
|
|
1063
|
+
|
|
1064
|
+
url = url + '&filter_field=' + field_name + '&filter_oper=' + operator;
|
|
1065
|
+
window.location.href = url;
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
/*****************************************************************
|
|
1069
|
+
* Toggle div
|
|
1070
|
+
******************************************************************/
|
|
1071
|
+
$(".dc-handle").click(function() {
|
|
1072
|
+
let div = this.getAttribute("data-div");
|
|
1073
|
+
dc_toggle_div(div);
|
|
1074
|
+
});
|
|
1075
|
+
|
|
765
1076
|
});
|
|
766
1077
|
|
|
767
1078
|
/*******************************************************************
|
|
@@ -780,9 +1091,7 @@ $(document).keydown( function(e) {
|
|
|
780
1091
|
});
|
|
781
1092
|
|
|
782
1093
|
/*******************************************************************
|
|
783
|
-
|
|
784
|
-
* almost every minute. That was a lesson learned years ago when I lost
|
|
785
|
-
* few hours of work on computer lockup ;-(
|
|
1094
|
+
|
|
786
1095
|
*******************************************************************
|
|
787
1096
|
$(document).onmousedown( function(e) {
|
|
788
1097
|
mouseDown = true;
|
|
@@ -794,4 +1103,4 @@ $(document).onmouseup( function(e) {
|
|
|
794
1103
|
console.log("mouse up");
|
|
795
1104
|
});
|
|
796
1105
|
|
|
797
|
-
**/
|
|
1106
|
+
**/
|