drg_cms 0.6.0.3 → 0.6.0.6
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 +259 -102
- data/app/assets/javascripts/drg_cms_cms.js +1 -1
- data/app/assets/stylesheets/drg_cms/drg_cms.css +314 -142
- data/app/assets/stylesheets/drg_cms/select-multiple.css +11 -2
- data/app/controllers/cmsedit_controller.rb +313 -236
- data/app/controllers/dc_application_controller.rb +29 -4
- data/app/controllers/dc_common_controller.rb +19 -16
- 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/{controllers → controls}/design_element_settings_control.rb +0 -0
- data/app/forms/all_options.yml +11 -3
- data/app/forms/cms_menu.yml +22 -18
- data/app/forms/dc_design.yml +6 -3
- data/app/forms/dc_filter.yml +3 -6
- data/app/forms/dc_poll_result.yml +74 -0
- data/app/forms/dc_poll_result_export.yml +35 -0
- data/app/helpers/cmsedit_edit_helper.rb +471 -0
- data/app/helpers/cmsedit_helper.rb +151 -821
- data/app/helpers/cmsedit_index_helper.rb +567 -0
- data/app/helpers/dc_application_helper.rb +48 -31
- data/app/models/{dc_dummy.rb → __dc_dummy.rb} +0 -0
- data/app/models/dc_filter.rb +12 -5
- data/app/models/dc_memory.rb +8 -1
- data/app/models/dc_poll.rb +38 -19
- data/app/models/dc_poll_result.rb +44 -0
- data/app/models/dc_temp.rb +137 -0
- 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 +7 -6
- data/app/models/drgcms_form_fields/date_select.rb +1 -1
- data/app/models/drgcms_form_fields/datetime_picker.rb +8 -7
- data/app/models/drgcms_form_fields/datetime_select.rb +1 -1
- data/app/models/drgcms_form_fields/drgcms_field.rb +39 -7
- data/app/models/drgcms_form_fields/embedded.rb +7 -2
- data/app/models/drgcms_form_fields/file_field.rb +52 -0
- data/app/models/drgcms_form_fields/html_field.rb +1 -1
- data/app/models/drgcms_form_fields/multitext_autocomplete.rb +7 -4
- data/app/models/drgcms_form_fields/number_field.rb +15 -6
- data/app/models/drgcms_form_fields/radio.rb +91 -0
- data/app/models/drgcms_form_fields/readonly.rb +1 -1
- data/app/models/drgcms_form_fields/select.rb +14 -2
- data/app/models/drgcms_form_fields/text_area.rb +1 -1
- data/app/models/drgcms_form_fields/text_autocomplete.rb +1 -1
- 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 +11 -3
- data/app/renderers/dc_poll_renderer.rb +29 -11
- 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 +2 -4
- 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 +7 -0
- data/config/locales/drgcms_sl.yml +8 -1
- data/config/locales/models_en.yml +13 -4
- data/config/locales/models_sl.yml +13 -2
- data/drg_cms.gemspec +1 -1
- data/lib/drg_cms.rb +1 -0
- data/lib/drg_cms/version.rb +1 -1
- data/lib/generators/new_drg_form/new_drg_form_generator.rb +7 -2
- metadata +20 -13
- data/app/assets/stylesheets/drg_cms/__jquery-ui.css +0 -339
- 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: ce40eeb1428b5e11a14613978b213af29ad3a26c4f68a0addc2987135df60ece
|
4
|
+
data.tar.gz: 880a2bca2c8dac8e5e5cb5723e6acca268a9f0f4f439a4befe6a34b7b4a1dbd3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 389d89408cd1e628ac26b0ec08de34c55851f84094e4258f9e98b7c036f48c992a84dd5c61385bd9ebb0592cb2df3e8dd0cc2c61808820b9e3c43bbb5dc5f7aa
|
7
|
+
data.tar.gz: 5c30cabb9b66750e0a6cc9783510dd15cb3ed866f9fca39d06c1037baa8c2c41db5798121f49b4b0e847163396eae77a68d99e8d8c548db55c57ea08f4d17dfd
|
@@ -43,36 +43,54 @@ dumpAttributes = function(obj) {
|
|
43
43
|
};
|
44
44
|
|
45
45
|
/*******************************************************************
|
46
|
-
*
|
46
|
+
* Function checks if there are delay loaded embedded elements on
|
47
|
+
* selected tab and triggers iframe reload.
|
47
48
|
*******************************************************************/
|
48
|
-
|
49
|
-
var
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
49
|
+
update_embedded_on_first_display = function(div_name) {
|
50
|
+
var iframes = $(div_name).find("iframe");
|
51
|
+
$.each(iframes, function(index, iframe) {
|
52
|
+
var src_delay = iframe.getAttribute('data-src-delay');
|
53
|
+
if (src_delay != null && src_delay != '') {
|
54
|
+
iframe.setAttribute('data-src-delay', '');
|
55
|
+
iframe.setAttribute('src', src_delay);
|
56
|
+
}
|
57
|
+
});
|
58
|
+
};
|
59
|
+
|
60
|
+
/*******************************************************************
|
61
|
+
* Return false when confirmation is not required
|
62
|
+
*******************************************************************/
|
63
|
+
confirmation_is_cancled = function(object) {
|
64
|
+
var confirmation = object.getAttribute("data-confirm");
|
65
|
+
// if confirmation required
|
66
|
+
if (confirmation !== null) {
|
67
|
+
if (!confirm(confirmation)) {return true;}
|
68
|
+
}
|
69
|
+
return false;
|
54
70
|
};
|
55
71
|
|
56
72
|
/*******************************************************************
|
57
|
-
* Will update select field on the form which select options are dependend
|
73
|
+
* Will update select field on the form which select options are dependend
|
74
|
+
* on other field value. It calls /dc_common/autocomplete and passes
|
75
|
+
* methodname and depend field value to obtain new values for select field.
|
58
76
|
*******************************************************************/
|
59
77
|
update_select_depend = function(select_name, depend_name, method) {
|
60
78
|
var select_field = $('#'+select_name);
|
61
79
|
var depend_field = $('#'+depend_name);
|
62
|
-
|
80
|
+
|
63
81
|
$.ajax({
|
64
82
|
url: "/dc_common/autocomplete",
|
65
83
|
type: "POST",
|
66
84
|
dataType: "json",
|
67
|
-
data: { input:
|
85
|
+
data: { input: depend_field.val(), search: method},
|
68
86
|
success: function(data) {
|
69
|
-
|
70
|
-
|
71
|
-
|
87
|
+
|
88
|
+
select_field.empty();
|
89
|
+
$.each(data, function(index, element) {
|
90
|
+
select_field.append( new Option(element['label'], element['id']) );
|
91
|
+
});
|
72
92
|
}
|
73
93
|
});
|
74
|
-
*/
|
75
|
-
|
76
94
|
};
|
77
95
|
|
78
96
|
/*******************************************************************
|
@@ -160,72 +178,107 @@ $(function() {
|
|
160
178
|
*******************************************************************/
|
161
179
|
|
162
180
|
process_json_result = function(json) {
|
163
|
-
var i,operation,
|
164
|
-
$.each(json, function(key,
|
181
|
+
var i,w,operation,selector, msg_div, field;
|
182
|
+
$.each(json, function(key, value) {
|
165
183
|
i = key.search('_');
|
166
184
|
if (i > 1) {
|
167
185
|
operation = key.substring(0,i);
|
168
|
-
|
186
|
+
selector = key.substring(i+1,100);
|
169
187
|
} else {
|
170
188
|
operation = key;
|
171
|
-
|
189
|
+
selector = '';
|
172
190
|
}
|
173
191
|
//
|
174
192
|
switch (operation) {
|
175
|
-
|
193
|
+
|
194
|
+
/**** update fields on form ****/
|
176
195
|
case 'record':
|
177
|
-
$('#'+key)
|
196
|
+
field = $('#'+key);
|
197
|
+
// checkbox field
|
198
|
+
if (field.is(':checkbox')) {
|
199
|
+
field.prop('checked', value);
|
200
|
+
// select field
|
201
|
+
} else if (field.is('select')) {
|
202
|
+
// options for select field
|
203
|
+
if (value && value.isArray) {
|
204
|
+
field.empty();
|
205
|
+
$.each(value, function(index, v) {
|
206
|
+
field.append( new Option(v[0], v[1]) );
|
207
|
+
});
|
208
|
+
// select field value
|
209
|
+
} else {
|
210
|
+
field.val(value);
|
211
|
+
}
|
212
|
+
// other input fields
|
213
|
+
} else {
|
214
|
+
field.val(value);
|
215
|
+
}
|
178
216
|
break;
|
179
|
-
|
217
|
+
|
218
|
+
/**** display message ****/
|
180
219
|
case 'msg':
|
181
|
-
|
182
|
-
if ( $('.'+
|
183
|
-
|
184
|
-
$('.dc-title').after(
|
220
|
+
msg_div = 'dc-form-' + selector;
|
221
|
+
if ( $('.'+msg_div).length == 0 ) {
|
222
|
+
value = '<div class="' + msg_div + '">' + value + '</div>';
|
223
|
+
$('.dc-title').after(value);
|
185
224
|
} else {
|
186
|
-
$('.'+
|
225
|
+
$('.'+msg_div).html(value);
|
187
226
|
}
|
188
227
|
break;
|
189
|
-
|
228
|
+
|
229
|
+
/**** display popup message ****/
|
190
230
|
case 'popup':
|
191
|
-
$('#popup').html(
|
231
|
+
$('#popup').html(value);
|
192
232
|
$('#popup').bPopup({ speed: 650, transition: 'slideDown' });
|
193
233
|
|
194
|
-
|
234
|
+
/**** update div ****/
|
195
235
|
case '#div+':
|
196
|
-
$('#'+
|
236
|
+
$('#'+selector).append(value);
|
197
237
|
break;
|
198
238
|
case '#+div':
|
199
|
-
$('#'+
|
239
|
+
$('#'+selector).prepend(value);
|
200
240
|
break;
|
201
241
|
case '#div':
|
202
|
-
$('#'+
|
242
|
+
$('#'+selector).html(value);
|
203
243
|
break;
|
204
244
|
case '.div+':
|
205
|
-
$('.'+
|
245
|
+
$('.'+selector).append(value);
|
206
246
|
break;
|
207
247
|
case '.+div':
|
208
|
-
$('.'+
|
248
|
+
$('.'+selector).prepend(value);
|
209
249
|
break;
|
210
250
|
case '.div':
|
211
|
-
$('.'+
|
251
|
+
$('.'+selector).html(value);
|
212
252
|
break;
|
213
|
-
|
253
|
+
|
254
|
+
/**** goto url ****/
|
214
255
|
case 'url':
|
215
|
-
window.location.href =
|
256
|
+
window.location.href = value;
|
216
257
|
break;
|
217
258
|
case 'alert':
|
218
|
-
alert(
|
259
|
+
alert(value);
|
219
260
|
break;
|
220
261
|
case 'window':
|
221
|
-
|
262
|
+
if (value == 'close') { window.close();
|
263
|
+
} else if (value == 'reload') { location.reload();
|
264
|
+
} else {
|
265
|
+
w = window.open(value, selector);
|
266
|
+
w.focus();
|
267
|
+
}
|
268
|
+
break;
|
269
|
+
case 'newwindow':
|
270
|
+
w = window.open(value, selector,"location=no,scrollbars=yes,resizable=yes");
|
222
271
|
w.focus();
|
223
272
|
break;
|
224
273
|
case 'eval':
|
225
|
-
eval (
|
274
|
+
eval (value);
|
226
275
|
break;
|
227
276
|
case 'reload':
|
228
|
-
|
277
|
+
if (value == 'parent') {
|
278
|
+
parent.location.reload();
|
279
|
+
} else {
|
280
|
+
location.reload();
|
281
|
+
}
|
229
282
|
break;
|
230
283
|
default:
|
231
284
|
console.log("DRGCMS: Invalid ajax result operation: " + operation);
|
@@ -265,6 +318,21 @@ $.fn.dc_scroll_view = function () {
|
|
265
318
|
});
|
266
319
|
};
|
267
320
|
|
321
|
+
/*******************************************************************
|
322
|
+
* Updates single field on parent iframe form of embedded form.
|
323
|
+
*******************************************************************/
|
324
|
+
process_parent_form_updates = function(element) {
|
325
|
+
var field = element.getAttribute("data-field");
|
326
|
+
var value = element.getAttribute("data-value");
|
327
|
+
if ( window.parent.$('#'+field).length > 0 ) {
|
328
|
+
if (field.substring(0,3) === 'td_') { // readonly field
|
329
|
+
window.parent.$('#'+field+' > div').html(value);
|
330
|
+
} else { // input field
|
331
|
+
window.parent.$('#'+field).val(value);
|
332
|
+
}
|
333
|
+
}
|
334
|
+
};
|
335
|
+
|
268
336
|
/*******************************************************************
|
269
337
|
*
|
270
338
|
*******************************************************************/
|
@@ -285,6 +353,20 @@ $(document).ready( function() {
|
|
285
353
|
window.scrollTo(0, $.getUrlParam('return_to_ypos'));
|
286
354
|
}
|
287
355
|
|
356
|
+
/*******************************************************************
|
357
|
+
* The idea is to update fields on parent iframe form, when embedded document
|
358
|
+
* is updated in its iframe. Update fields are listed in .dc-form-updates div
|
359
|
+
* and are set by flash[:update] Hash object.
|
360
|
+
*
|
361
|
+
* eg. flash[:update] = {'td_record_radonly' => 'New value for read_only field',
|
362
|
+
* 'record_name' => 'New name'}
|
363
|
+
*******************************************************************/
|
364
|
+
if ( $('.dc-form-updates').length > 0 ) {
|
365
|
+
$('.dc-form-updates').children().each( function( index, element ) {
|
366
|
+
process_parent_form_updates(element);
|
367
|
+
});
|
368
|
+
}
|
369
|
+
|
288
370
|
/*******************************************************************
|
289
371
|
* Register ad clicks
|
290
372
|
*******************************************************************/
|
@@ -337,11 +419,11 @@ $(document).ready( function() {
|
|
337
419
|
* Tab clicked on form. Hide old and show selected div.
|
338
420
|
*******************************************************************/
|
339
421
|
$('.dc-form-li').on('click', function(e) {
|
340
|
-
// find li with dc-form-li-selected class. This is our old tab
|
422
|
+
// find li with dc-form-li-selected class. This is our old tab
|
341
423
|
var old_tab_id = null;
|
342
424
|
$(e.target).parents('ul').find('li').each( function() {
|
343
425
|
if ($(this).hasClass('dc-form-li-selected')) {
|
344
|
-
// when not already selected toggle dc-form-li-selected class and save old tab
|
426
|
+
// when not already selected toggle dc-form-li-selected class and save old tab
|
345
427
|
if ($(this) !== $(e.target)) {
|
346
428
|
$(this).toggleClass('dc-form-li-selected');
|
347
429
|
$(e.target).toggleClass('dc-form-li-selected');
|
@@ -354,11 +436,15 @@ $(document).ready( function() {
|
|
354
436
|
if (old_tab_id !== null) {
|
355
437
|
$('#data_' + old_tab_id).toggleClass('div-hidden');
|
356
438
|
$('#data_' + e.target.getAttribute("data-div")).toggleClass('div-hidden');
|
357
|
-
|
358
|
-
|
359
|
-
|
439
|
+
|
440
|
+
// resize parent iframe to fit selected tab size
|
441
|
+
// var div_height = document.getElementById('data_' + e.target.getAttribute("data-div")).clientHeight + 130;
|
442
|
+
// var div_height = document.getElementById('cmsform').clientHeight + 50;
|
443
|
+
var div_height = document.body.scrollHeight;
|
444
|
+
window.frameElement.style.height = div_height.toString() + 'px';
|
360
445
|
// it would be too easy $('#cmsform :input:enabled:visible:first').focus();
|
361
446
|
select_first_input_field('#data_' + e.target.getAttribute("data-div"));
|
447
|
+
update_embedded_on_first_display('#data_' + e.target.getAttribute("data-div"));
|
362
448
|
}
|
363
449
|
});
|
364
450
|
|
@@ -367,7 +453,6 @@ $(document).ready( function() {
|
|
367
453
|
* unless on initial display.
|
368
454
|
*******************************************************************/
|
369
455
|
$('#iframe_cms').on('load', function() {
|
370
|
-
// alert('bla 1');
|
371
456
|
new_height = this.contentWindow.document.body.offsetHeight + 50;
|
372
457
|
if (new_height < 500 && new_height > 60) new_height = 500;
|
373
458
|
this.style.height = new_height + 'px';
|
@@ -392,48 +477,70 @@ $(document).ready( function() {
|
|
392
477
|
* Process Ajax call on cmsedit form actions
|
393
478
|
*******************************************************************/
|
394
479
|
$('.dc-link-ajax').on('click', function(e) {
|
395
|
-
//
|
480
|
+
// confirmation if required
|
481
|
+
if (confirmation_is_cancled(this)) {return false;}
|
482
|
+
|
483
|
+
// check HTML5 validations
|
396
484
|
if ($("form")[0] && !$("form")[0].checkValidity() ) {
|
397
485
|
$("form")[0].reportValidity();
|
398
486
|
return false;
|
399
487
|
}
|
400
|
-
var
|
401
|
-
|
402
|
-
// Get values from elements on the page:
|
488
|
+
var req = this.getAttribute("data-request");
|
489
|
+
// Get values from elements on the page:
|
403
490
|
if (req == "script") {
|
404
|
-
eval (
|
491
|
+
eval (this.getAttribute("data-script"));
|
405
492
|
return false;
|
406
493
|
}
|
407
494
|
else if (req == "post") {
|
408
495
|
data = $('form').serialize();
|
409
|
-
// alert(data);
|
410
496
|
}
|
411
497
|
else {
|
412
498
|
data = {};
|
413
499
|
req = 'get'; // by default
|
414
500
|
}
|
415
501
|
|
416
|
-
$('.dc-spinner').
|
502
|
+
$('.dc-spinner').show();
|
417
503
|
$.ajax({
|
418
|
-
url:
|
504
|
+
url: this.getAttribute("data-url"),
|
419
505
|
type: req,
|
420
506
|
dataType: "json",
|
421
507
|
data: data,
|
422
|
-
// success: function(files,data,xhr) {
|
423
|
-
// document.getElementById('if_priponkas').contentDocument.location.reload(true);
|
424
|
-
// }
|
425
508
|
success: function(data) {
|
426
509
|
process_json_result(data);
|
427
|
-
$('.dc-spinner').
|
510
|
+
$('.dc-spinner').hide();
|
428
511
|
}
|
429
512
|
|
430
513
|
});
|
431
|
-
});
|
514
|
+
});
|
515
|
+
|
516
|
+
/*******************************************************************
|
517
|
+
* Process action submit button click.
|
518
|
+
*******************************************************************/
|
519
|
+
$('.dc-action-submit').on('click', function(e) {
|
520
|
+
// confirmation if required
|
521
|
+
if (confirmation_is_cancled(this)) {return false;}
|
522
|
+
|
523
|
+
// check HTML5 validations
|
524
|
+
var form = $("form")[0];
|
525
|
+
if (form && !form.checkValidity() ) {
|
526
|
+
form.reportValidity();
|
527
|
+
return false;
|
528
|
+
}
|
529
|
+
var url = this.getAttribute("data-url");
|
530
|
+
if (url == null) {return false;}
|
531
|
+
|
532
|
+
form.setAttribute('action', url);
|
533
|
+
form.setAttribute('method', "post");
|
534
|
+
form.submit();
|
535
|
+
});
|
432
536
|
|
433
537
|
/*******************************************************************
|
434
538
|
will open a new window with URL specified.
|
435
539
|
********************************************************************/
|
436
540
|
$('.dc-window-open').on('click', function(e) {
|
541
|
+
// confirmation if required
|
542
|
+
if (confirmation_is_cancled(this)) {return false;}
|
543
|
+
|
437
544
|
var url = this.getAttribute("data-url");
|
438
545
|
var title = this.getAttribute("title");
|
439
546
|
var w = 1000;
|
@@ -442,7 +549,6 @@ $(document).ready( function() {
|
|
442
549
|
var top = (screen.height/2)-(h/2);
|
443
550
|
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);
|
444
551
|
win.focus();
|
445
|
-
// $('#bpopup').bPopup({ loadUrl: url, speed: 650, transition: 'slideDown' });
|
446
552
|
});
|
447
553
|
|
448
554
|
/*******************************************************************
|
@@ -494,11 +600,11 @@ $(document).ready( function() {
|
|
494
600
|
* Display spinner on link with spinner, submit link
|
495
601
|
*******************************************************************/
|
496
602
|
$('.dc-link-spinner').on('click', function(e) {
|
497
|
-
$('.dc-spinner').
|
603
|
+
$('.dc-spinner').show();
|
498
604
|
});
|
499
605
|
|
500
606
|
$('.dc-link-submit').on('click', function(e) {
|
501
|
-
$('.dc-spinner').
|
607
|
+
$('.dc-spinner').show();
|
502
608
|
});
|
503
609
|
|
504
610
|
/*******************************************************************
|
@@ -722,8 +828,9 @@ element = $(this).find(':first').attr('id');
|
|
722
828
|
});
|
723
829
|
|
724
830
|
/*******************************************************************
|
725
|
-
* Resize result table columns
|
831
|
+
* Resize result table columns. For now an idea.
|
726
832
|
*******************************************************************/
|
833
|
+
/*
|
727
834
|
$( ".dc-result-header .spacer" )
|
728
835
|
.mouseenter(function() {
|
729
836
|
console.log("enter");
|
@@ -731,7 +838,7 @@ element = $(this).find(':first').attr('id');
|
|
731
838
|
.mouseleave(function() {
|
732
839
|
console.log("leave");
|
733
840
|
});
|
734
|
-
|
841
|
+
*/
|
735
842
|
/*******************************************************************
|
736
843
|
* number_field type entered
|
737
844
|
*******************************************************************/
|
@@ -746,44 +853,47 @@ element = $(this).find(':first').attr('id');
|
|
746
853
|
/*******************************************************************
|
747
854
|
* number_field type leaved
|
748
855
|
*******************************************************************/
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
856
|
+
$('.dc-number').on('focusout', function(e) {
|
857
|
+
var decimals = $(this).attr("data-decimal") || 2;
|
858
|
+
var delimiter = $(this).attr("data-delimiter") || '.';
|
859
|
+
var separator = $(this).attr("data-separator") || ',';
|
860
|
+
var currency = $(this).attr("data-currency") || '';
|
861
|
+
var val = this.value;
|
862
|
+
// clear delimiters and replace separator with .
|
863
|
+
val = val.replace(delimiter,'');
|
864
|
+
val = val.replace(separator,'.');
|
865
|
+
val = parseFloat(val).toFixed(decimals);
|
866
|
+
var whole, dec, sign;
|
867
|
+
// [whole,dec] = val.split('.');
|
868
|
+
whole = val.split('.')[0];
|
869
|
+
dec = val.split('.')[1];
|
761
870
|
// remove negative sign and add at the end
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
871
|
+
var sign = whole.substr(0,1);
|
872
|
+
if (sign == '-') {
|
873
|
+
whole = whole.substr(1,20);
|
874
|
+
} else {
|
875
|
+
sign = '';
|
876
|
+
}
|
877
|
+
// save value to hidden field which holds return value
|
878
|
+
var field = '#' + $(this).attr("id").slice(0,-1);
|
879
|
+
$(field).val(val);
|
768
880
|
|
769
|
-
$(field).val( parseFloat(value).toFixed(decimals) );
|
770
|
-
|
771
881
|
// decimal part
|
772
|
-
|
773
|
-
|
774
|
-
|
882
|
+
if (decimals == 0) separator = '';
|
883
|
+
if (dec == null) dec = '';
|
884
|
+
while (dec.length < decimals) dec = dec + '0';
|
775
885
|
// whole part
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
886
|
+
if (whole == null || whole == '') whole = '0';
|
887
|
+
var ar = [];
|
888
|
+
while (whole.length > 0) {
|
889
|
+
var pos1 = whole.length - 3
|
890
|
+
if (pos1 < 0) pos1 = 0;
|
891
|
+
ar.unshift(whole.substr(pos1,3));
|
892
|
+
whole = whole.slice(0, -3);
|
783
893
|
};
|
784
894
|
|
785
|
-
|
786
|
-
|
895
|
+
if (delimiter !== '') whole = ar.join(delimiter);
|
896
|
+
$(this).val(sign + whole + separator + dec + currency);
|
787
897
|
});
|
788
898
|
|
789
899
|
/*******************************************************************
|
@@ -809,6 +919,55 @@ element = $(this).find(':first').attr('id');
|
|
809
919
|
$(field).val( parseFloat(value).toFixed(decimals) );
|
810
920
|
}
|
811
921
|
});
|
922
|
+
|
923
|
+
/*******************************************************************
|
924
|
+
* Result header sort icon is hoverd. Change background icon to filter.
|
925
|
+
*******************************************************************/
|
926
|
+
$('.dc-result-header .th i').hover( function() {
|
927
|
+
old_sort_icon = '';
|
928
|
+
// save old sort icon and replace it with filter icon
|
929
|
+
$.each( $(this).attr("class").split(/\s+/),
|
930
|
+
function(index, item) { if (item.match('sort')) { old_sort_icon = item}; }
|
931
|
+
);
|
932
|
+
$(this).removeClass(old_sort_icon).addClass('fa-filter');
|
933
|
+
// bring back old sort icon
|
934
|
+
}, function(){
|
935
|
+
$(this).removeClass('fa-filter').addClass(old_sort_icon);
|
936
|
+
});
|
937
|
+
|
938
|
+
/*******************************************************************
|
939
|
+
* Result header sort icon is clicked. Display filter menu for the field.
|
940
|
+
*******************************************************************/
|
941
|
+
$('.dc-result-header .th i').click( function(e) {
|
942
|
+
e.preventDefault();
|
943
|
+
// additional click will close dialog when visible
|
944
|
+
if ($('.filter-popup').is(':visible')) {
|
945
|
+
$('.filter-popup').hide();
|
946
|
+
return;
|
947
|
+
}
|
948
|
+
// retrieve name of current field and set it in popup
|
949
|
+
var header = $(this).closest('.th');
|
950
|
+
var field_name = header.attr("data-name");
|
951
|
+
$('.filter-popup').attr('data-name', field_name);
|
952
|
+
// change popup position and show
|
953
|
+
$('.filter-popup').css({'top':e.pageY+5,'left':e.pageX, 'position':'absolute'});
|
954
|
+
$('.filter-popup').show();
|
955
|
+
});
|
956
|
+
|
957
|
+
/*******************************************************************
|
958
|
+
* Filter operation is clicked on filter popup. Retrieve data and call
|
959
|
+
* filter on action.
|
960
|
+
*******************************************************************/
|
961
|
+
$('.filter-popup li').click( function(e) {
|
962
|
+
var url = $(this).data('url')
|
963
|
+
var operator = $(this).data('operator');
|
964
|
+
var parent = $(this).closest('.filter-popup')
|
965
|
+
var field_name = parent.data("name");
|
966
|
+
|
967
|
+
url = url + '&filter_field=' + field_name + '&filter_oper=' + operator;
|
968
|
+
window.location.href = url;
|
969
|
+
});
|
970
|
+
|
812
971
|
});
|
813
972
|
|
814
973
|
/*******************************************************************
|
@@ -827,9 +986,7 @@ $(document).keydown( function(e) {
|
|
827
986
|
});
|
828
987
|
|
829
988
|
/*******************************************************************
|
830
|
-
|
831
|
-
* almost every minute. That was a lesson learned years ago when I lost
|
832
|
-
* few hours of work on computer lockup ;-(
|
989
|
+
|
833
990
|
*******************************************************************
|
834
991
|
$(document).onmousedown( function(e) {
|
835
992
|
mouseDown = true;
|
@@ -841,4 +998,4 @@ $(document).onmouseup( function(e) {
|
|
841
998
|
console.log("mouse up");
|
842
999
|
});
|
843
1000
|
|
844
|
-
**/
|
1001
|
+
**/
|