drg_cms 0.6.1.5 → 0.6.1.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +203 -24
  3. data/app/assets/fonts/ibm-plex-sans-300.woff2 +0 -0
  4. data/app/assets/fonts/ibm-plex-sans-400.woff2 +0 -0
  5. data/app/assets/fonts/ibm-plex-sans-500.woff2 +0 -0
  6. data/app/assets/fonts/ibm-plex-sans-600.woff2 +0 -0
  7. data/app/assets/fonts/ibm-plex-sans-700.woff2 +0 -0
  8. data/app/assets/fonts/ibm-plex-sans-italic.woff2 +0 -0
  9. data/app/assets/javascripts/drg_cms/drg_cms.js +253 -106
  10. data/app/assets/stylesheets/drg_cms/drg_cms.css +670 -521
  11. data/app/assets/stylesheets/drg_cms_application.css +1 -1
  12. data/app/assets/stylesheets/drg_cms_cms.css +1 -4
  13. data/app/controllers/cmsedit_controller.rb +33 -211
  14. data/app/controllers/dc_application_controller.rb +98 -22
  15. data/app/controllers/dc_common_controller.rb +9 -22
  16. data/app/controls/browse_models_control.rb +18 -27
  17. data/app/controls/cmsedit_control.rb +129 -0
  18. data/app/controls/dc_help_control.rb +1 -1
  19. data/app/controls/dc_page_control.rb +0 -1
  20. data/app/controls/dc_poll_result_control.rb +1 -1
  21. data/app/controls/dc_report.rb +2 -2
  22. data/app/controls/design_element_settings_control.rb +1 -1
  23. data/app/forms/all_options.yml +25 -7
  24. data/app/forms/cms_menu.yml +24 -24
  25. data/app/forms/dc_browse_fields.yml +13 -9
  26. data/app/forms/dc_browse_models.yml +24 -2
  27. data/app/forms/dc_poll_result_export.yml +1 -1
  28. data/app/forms/dc_site.yml +2 -5
  29. data/app/forms/dc_steps_template.yml +51 -0
  30. data/app/helpers/cms_common_helper.rb +73 -6
  31. data/app/helpers/cms_edit_helper.rb +275 -159
  32. data/app/helpers/cms_helper.rb +152 -59
  33. data/app/helpers/cms_index_helper.rb +220 -172
  34. data/app/helpers/dc_application_helper.rb +40 -67
  35. data/app/models/concerns/dc_page_concern.rb +1 -1
  36. data/app/models/concerns/dc_site_concern.rb +9 -3
  37. data/app/models/dc_filter.rb +30 -22
  38. data/app/models/dc_journal.rb +2 -2
  39. data/app/models/dc_json_ld.rb +19 -42
  40. data/app/models/dc_part.rb +19 -9
  41. data/app/models/dc_site.rb +0 -1
  42. data/app/models/drgcms_form_fields/drgcms_field.rb +10 -4
  43. data/app/models/drgcms_form_fields/link_to.rb +1 -1
  44. data/app/models/drgcms_form_fields/multitext_autocomplete.rb +5 -5
  45. data/app/models/drgcms_form_fields/readonly.rb +4 -1
  46. data/app/models/drgcms_form_fields/select.rb +10 -9
  47. data/app/models/drgcms_form_fields/text_autocomplete.rb +20 -12
  48. data/app/models/drgcms_form_fields/text_with_select.rb +1 -0
  49. data/app/renderers/dc_common_renderer.rb +20 -3
  50. data/app/renderers/dc_part_renderer.rb +1 -1
  51. data/app/renderers/dc_poll_renderer.rb +1 -1
  52. data/app/views/cmsedit/_edit_stuff.html.erb +12 -12
  53. data/app/views/cmsedit/_form.html.erb +19 -12
  54. data/app/views/cmsedit/edit.html.erb +10 -6
  55. data/app/views/cmsedit/index.html.erb +5 -3
  56. data/app/views/cmsedit/login.html.erb +1 -1
  57. data/app/views/cmsedit/new.html.erb +9 -5
  58. data/app/views/dc_common/_help.html.erb +1 -0
  59. data/app/views/dc_common/paste_clipboard.html.erb +1 -1
  60. data/app/views/layouts/cms.html.erb +3 -5
  61. data/config/locales/drgcms_en.yml +7 -1
  62. data/config/locales/drgcms_sl.yml +7 -1
  63. data/config/locales/kaminari.yml +1 -1
  64. data/drg_cms.gemspec +2 -2
  65. data/lib/drg_cms/version.rb +1 -1
  66. data/lib/drg_cms.rb +4 -4
  67. metadata +16 -10
  68. data/app/views/cmsedit/__remove_edit_stuff.js.erb +0 -6
  69. data/app/views/cmsedit/__show.html.erb +0 -21
@@ -67,7 +67,7 @@ update_embedded_on_tab_select = function(div_name) {
67
67
  * Return false when confirmation is not required
68
68
  *******************************************************************/
69
69
  confirmation_is_cancled = function(object) {
70
- var confirmation = object.getAttribute("data-confirm");
70
+ let confirmation = object.getAttribute("data-confirm");
71
71
  // if confirmation required
72
72
  if (confirmation !== null) {
73
73
  if (!confirm(confirmation)) {return true;}
@@ -81,8 +81,8 @@ confirmation_is_cancled = function(object) {
81
81
  * methodname and depend field value to obtain new values for select field.
82
82
  *******************************************************************/
83
83
  update_select_depend = function(select_name, depend_name, method) {
84
- var select_field = $('#'+select_name);
85
- var depend_field = $('#'+depend_name);
84
+ let select_field = $('#' + select_name);
85
+ let depend_field = $('#' + depend_name);
86
86
 
87
87
  $.ajax({
88
88
  url: "/dc_common/autocomplete",
@@ -159,7 +159,7 @@ $(function() {
159
159
  * record_name: will replace value of record[name] field on a form with supplied value
160
160
  *
161
161
  * msg_error: will display error message.
162
- * msg_warn: will display warning message.
162
+ * msg_warning: will display warning message.
163
163
  * msg_info: will display informational message.
164
164
  *
165
165
  * popup: will display popup message
@@ -199,15 +199,17 @@ process_json_result = function(json) {
199
199
 
200
200
  /**** update fields on form ****/
201
201
  case 'record':
202
- let name = key.replace('record_','record[') + ']';
203
- field = $('[name="' + name + '"]');
202
+ //let name = key.replace('record_','record[') + ']';
203
+ //field = $('[name="' + name + '"]');
204
+ field = $('#' + key);
205
+ // console.log(field);
204
206
  // checkbox field
205
207
  if (field.is(':checkbox')) {
206
208
  field.prop('checked', value);
207
209
  // select field
208
210
  } else if (field.is('select')) {
209
211
  // options for select field
210
- if (value && value.isArray) {
212
+ if (Array.isArray(value)) {
211
213
  field.empty();
212
214
  $.each(value, function(index, v) {
213
215
  field.append( new Option(v[0], v[1]) );
@@ -246,11 +248,24 @@ process_json_result = function(json) {
246
248
  /**** display popup message ****/
247
249
  case 'popup':
248
250
  if (selector == 'url') {
249
- $('#popup').bPopup({ loadUrl: value });
251
+ $('#popup').bPopup({ loadUrl: value,
252
+ transition: 'slideDown', transitionClose: 'slideDown', speed: 300,
253
+ opacity: 0, position: ['auto', 20],
254
+ closeClass: 'dc-link' });
250
255
  }
251
256
  else {
252
257
  $('#popup').html(value);
253
- $('#popup').bPopup({speed: 650, transition: 'slideUp', position: ['auto',1]});
258
+ $('#popup').bPopup( {
259
+ transition: 'slideDown', transitionClose: 'slideDown', speed: 300,
260
+ opacity: 0, position: ['auto', 20],
261
+ closeClass: 'dc-link' });
262
+ }
263
+ // resize parent iframe if smaller then 500px to ensure popup some space
264
+ let document_height = document.body.scrollHeight;
265
+ if (document_height < 500) {
266
+ let frame = window.frameElement
267
+ if (frame === null) frame = document.body;
268
+ frame.style.height = '500px';
254
269
  }
255
270
  break;
256
271
 
@@ -334,10 +349,12 @@ function dc_reload_window() {
334
349
  /*******************************************************************
335
350
  * Will open popup window
336
351
  *******************************************************************/
337
- function popup_window(url, window_name, win, w, h) {
338
- let y = win.top.outerHeight / 2 + win.top.screenY - ( h / 2);
339
- let x = win.top.outerWidth / 2 + win.top.screenX - ( w / 2);
340
- return win.open(url, window_name, `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${y}, left=${x}`);
352
+ function popup_window(url, title, parent_win, w, h) {
353
+ let y = parent_win.top.outerHeight / 2 + parent_win.top.screenY - (h / 2);
354
+ let x = parent_win.top.outerWidth / 2 + parent_win.top.screenX - (w / 2);
355
+ let win = parent_win.open(url, 'dc_popup', `toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width=${w}, height=${h}, top=${y}, left=${x}`);
356
+ win.document.title = title;
357
+ return win;
341
358
  }
342
359
 
343
360
  /*******************************************************************
@@ -393,7 +410,7 @@ process_parent_form_updates = function(element) {
393
410
  /*****************************************************************
394
411
  * Toggle show and hide div
395
412
  ******************************************************************/
396
- dc_toggle_div = function(div) {
413
+ dc_div_toggle = function(div) {
397
414
  if ($(div).is(":visible")) {
398
415
  $(div).slideUp();
399
416
  } else {
@@ -401,8 +418,55 @@ dc_toggle_div = function(div) {
401
418
  }
402
419
  };
403
420
 
421
+ /*****************************************************************
422
+ * Process simple ajax call
423
+ ******************************************************************/
424
+ simple_ajax_call = function(url) {
425
+ $.ajax({
426
+ url: url,
427
+ success: function(data) { process_json_result(data); }
428
+ });
429
+ };
430
+
431
+ /*****************************************************************
432
+ * Return value of the input field on a form
433
+ ******************************************************************/
434
+ function dc_field_get_value(field_name) {
435
+ field_name = field_name.replace('record_', '');
436
+ let field = $('[name="record[' + field_name + ']"]');
437
+ return field.val();
438
+ }
439
+
440
+ /*****************************************************************
441
+ * Will process data-fields attribute and add field values as parameters to url
442
+ ******************************************************************/
443
+ function dc_url_add_params(form, url) {
444
+ // check if data-fields attribute present
445
+ let fields = form.getAttribute("data-fields");
446
+ if (fields === null) return url;
447
+ // url might already contain ?
448
+ let form_parms = '?';
449
+ if (url.match(/\?/)) form_parms = '';
450
+
451
+ fields.split(',').forEach( function(field) {
452
+ let value = dc_field_get_value(field);
453
+ if (value) form_parms += '&' + field + '=' + value;
454
+ });
455
+ return url + form_parms;
456
+ }
457
+
404
458
  /*******************************************************************
405
- *
459
+ * Copy div text to clipboard
460
+ *******************************************************************/
461
+ function dc_copy_to_clipboard(div) {
462
+ let copyText = document.getElementById(div).innerText;
463
+ console.log(copyText);
464
+ /* Copy the text inside the text field */
465
+ navigator.clipboard.writeText(copyText);
466
+ }
467
+
468
+ /*******************************************************************
469
+ * Events start here
406
470
  *******************************************************************/
407
471
  $(document).ready( function() {
408
472
  /* This could be the way to focus on first input field on document open
@@ -465,7 +529,7 @@ $(document).ready( function() {
465
529
  * Popup CMS edit menu option clicked
466
530
  *******************************************************************/
467
531
  $('.drgcms_popmenu_item').on('click',function(e) {
468
- url = e.target.getAttribute("data-url");
532
+ let url = e.target.getAttribute("data-url");
469
533
  $('#iframe_cms').attr('src', url);
470
534
  // $('#iframe_cms').width(1000).height(1000);
471
535
  // scroll to top of page and hide menu
@@ -476,13 +540,22 @@ $(document).ready( function() {
476
540
  /*******************************************************************
477
541
  * Sort action clicked on cmsedit
478
542
  *******************************************************************/
479
- $('.drgcms_sort').change( function(e) {
543
+ $('.dc-sort-select').change( function(e) {
480
544
  let table = e.target.getAttribute("data-table");
481
545
  let form = e.target.getAttribute("data-form");
482
546
  if (form === null) form = table;
483
547
  let sort = e.target.value;
484
- e.target.value = null;
485
- window.location.href = "/cmsedit?sort=" + sort + "&table=" + table + "&form_name=" + form;
548
+ // e.target.value = null;
549
+ let url = "/cmsedit/run?control=cmsedit.sort&sort=" + sort + "&table=" + table + "&form_name=" + form;
550
+ simple_ajax_call(url);
551
+ });
552
+
553
+ /*******************************************************************
554
+ * Click on field name in result header perform sort action
555
+ *******************************************************************/
556
+ $('.dc-result-header span').on('click',function(e) {
557
+ let url = e.target.getAttribute("data-url");
558
+ simple_ajax_call(url);
486
559
  });
487
560
 
488
561
  /*******************************************************************
@@ -490,20 +563,20 @@ $(document).ready( function() {
490
563
  *******************************************************************/
491
564
  $('.dc-check-all').on('click',function(e) {
492
565
  let checkboxes = $('.dc-check');
493
- if ($(this).hasClass('fa-check-square-o')) {
566
+ if ($(this).hasClass('mi-check_box')) {
494
567
  // check all checkboxes
495
568
  checkboxes.each( function() {
496
569
  $(this).prop('checked', true);
497
570
  $(this).parent().closest('div').addClass('dc-checked');
498
571
  });
499
- $(this).removeClass('fa-check-square-o').addClass('fa-square-o');
572
+ $(this).removeClass('mi-check_box').addClass('mi-check_square');
500
573
  } else {
501
574
  // uncheck all checkboxes
502
575
  checkboxes.each( function() {
503
576
  $(this).prop('checked', false);
504
577
  $(this).parent().closest('div').removeClass('dc-checked');
505
578
  });
506
- $(this).removeClass('fa-square-o').addClass('fa-check-square-o');
579
+ $(this).removeClass('mi-check_square').addClass('mi-check_box');
507
580
  }
508
581
  });
509
582
 
@@ -603,11 +676,22 @@ $(document).ready( function() {
603
676
  if (url.length < 5) return false;
604
677
 
605
678
  // check HTML5 validations
606
- if ($("form")[0] && !$("form")[0].checkValidity() ) {
607
- $("form")[0].reportValidity();
608
- return false;
679
+ let validate = this.getAttribute("data-validate");
680
+ if (validate == null || validate == true) {
681
+ if ($("form")[0] && !$("form")[0].checkValidity()) {
682
+ $("form")[0].reportValidity();
683
+ return false;
684
+ }
609
685
  }
610
686
 
687
+ // update html editor fields before data serialization
688
+ let cke_elements = document.querySelectorAll(`div[id^="cke_record"]`);
689
+ cke_elements.forEach(e => {
690
+ let field_id = e.id.replace('cke_', '');
691
+ let text = CKEDITOR.instances[field_id].getData();
692
+ $('#' + field_id).val(text);
693
+ });
694
+
611
695
  let data = {};
612
696
  let request = this.getAttribute("data-request");
613
697
  switch (request) {
@@ -628,7 +712,7 @@ $(document).ready( function() {
628
712
  if (checkboxes.length > 0) {
629
713
  let checked = [];
630
714
  checkboxes.each( function() {
631
- if ($(this).prop('checked')) checked.push($(this).attr("id"));
715
+ if ($(this).prop('checked')) checked.push($(this).attr("id").replace('check-', ''));
632
716
  })
633
717
  data['checked'] = checked;
634
718
  }
@@ -642,9 +726,21 @@ $(document).ready( function() {
642
726
  success: function(data) {
643
727
  process_json_result(data);
644
728
  $('.dc-spinner').hide();
729
+ },
730
+ error: function (request, status, error) {
731
+ $('.dc-spinner').css('color','red');
732
+ alert(request.responseText);
645
733
  }
646
734
  });
647
735
  });
736
+
737
+ /*******************************************************************
738
+ * Click on filter off
739
+ *******************************************************************/
740
+ $('.mi-filter_alt_off').on('click', function(e) {
741
+ let url = $(this).parents('.dc-filter').attr("data-url");
742
+ if (url.length > 5) simple_ajax_call(url);
743
+ });
648
744
 
649
745
  /*******************************************************************
650
746
  * Process action submit button click.
@@ -665,24 +761,44 @@ $(document).ready( function() {
665
761
  form.setAttribute('action', url);
666
762
  form.setAttribute('method', "post");
667
763
  form.submit();
668
- });
669
-
670
- /*******************************************************************
671
- will open a new window with URL specified.
672
- ********************************************************************/
673
- $('.dc-window-open').on('click', function(e) {
674
- // confirmation if required
675
- if (confirmation_is_cancled(this)) {return false;}
676
-
677
- var url = this.getAttribute("data-url");
678
- var title = this.getAttribute("title");
679
- var w = 1000;
680
- var h = 800;
681
- var left = (screen.width/2)-(w/2);
682
- var top = (screen.height/2)-(h/2);
683
- 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);
764
+ });
765
+
766
+ /*******************************************************************
767
+ Will open a new window with URL specified.
768
+ ********************************************************************/
769
+ $('.dc-window-open').on('click', function(e) {
770
+ // confirmation if required
771
+ if (confirmation_is_cancled(this)) return false;
772
+
773
+ let url = this.getAttribute("data-url");
774
+ let title = this.getAttribute("title");
775
+ let w = this.getAttribute("data-x") || 1000;
776
+ let h = this.getAttribute("data-y") || 800;
777
+
778
+ url = dc_url_add_params(this, url)
779
+ let win = popup_window(url, title, window, w, h);
684
780
  win.focus();
685
- });
781
+ });
782
+
783
+ /*******************************************************************
784
+ Will open a new popup with URL specified.
785
+ ********************************************************************/
786
+ $('.dc-popup-open').on('click', function(e) {
787
+ // confirmation if required
788
+ if (confirmation_is_cancled(this)) return false;
789
+
790
+ let url = this.getAttribute("data-url");
791
+ let title = this.getAttribute("title");
792
+ let w = this.getAttribute("data-x") || 1000;
793
+ let h = this.getAttribute("data-y") || 800;
794
+
795
+ url = dc_url_add_params(this, url)
796
+ $('#popup').bPopup({ loadUrl: url,
797
+ transition: 'slideDown', transitionClose: 'slideDown', speed: 300,
798
+ opacity: 0, position: ['auto', 20],
799
+ closeClass: 'dc-link'
800
+ });
801
+ });
686
802
 
687
803
  /*******************************************************************
688
804
  * Animate button on click
@@ -698,20 +814,7 @@ $(document).ready( function() {
698
814
  $(this).toggleClass('dc-animate-button');
699
815
  });
700
816
  */
701
- /*******************************************************************
702
- * Animate button on click
703
- *******************************************************************/
704
- $('.dc-animate').mousedown( function() {
705
- $(this).toggleClass('dc-animate-button');
706
- });
707
-
708
- /*******************************************************************
709
- * Animate button on click
710
- *******************************************************************/
711
- $('.dc-animate').mouseup( function() {
712
- $(this).toggleClass('dc-animate-button');
713
- });
714
-
817
+
715
818
  /*******************************************************************
716
819
  * App menu option clicked
717
820
  *******************************************************************/
@@ -732,28 +835,40 @@ $(document).ready( function() {
732
835
  /*******************************************************************
733
836
  * Display spinner on link with spinner, submit link
734
837
  *******************************************************************/
735
- $('.dc-link-spinner').on('click', function(e) {
838
+ $('.dc-link.spin').on('click', function(e) {
736
839
  $('.dc-spinner').show();
737
840
  });
738
841
 
739
842
  $('.dc-link-submit').on('click', function(e) {
740
843
  $('.dc-spinner').show();
741
- });
844
+ });
845
+
846
+ /*******************************************************************
847
+ * Hide spinner when validation error occured
848
+ *******************************************************************/
849
+ $(':input').on("invalid", function(event) {
850
+ $('.dc-spinner').hide();
851
+ });
742
852
 
743
853
  /*******************************************************************
744
854
  * Add button clicked while in edit. Create window dialog for adding new record
745
855
  * into required table. This is helper scenario, when user is selecting
746
856
  * data from with text_autocomplete and data doesn't exist in belongs_to table.
747
857
  *******************************************************************/
748
- $('.in-edit-add').on('click', function(e) {
749
- let url = '/cmsedit/new?window_close=0&table=' + this.getAttribute("data-table");
858
+ $('.in-edit-add').on('click', function(e) {
859
+ let id = this.getAttribute("data-id");
860
+ let table = this.getAttribute("data-table");
861
+ let url = '/cmsedit/new?window_close=0&table=' + table;
862
+ if (id) {
863
+ url = '/cmsedit/' + id + '/edit?window_close=0&table=' + table;
864
+ }
750
865
  let w = popup_window(url, '', window, 1000, 800);
751
866
  w.focus();
752
867
  });
753
868
 
754
869
  /**********************************************************************
755
870
  * When filter_field (field name) is selected on filter subform this routine finds
756
- * and displays apropriate span with input field.
871
+ * and displays appropriate span with input field.
757
872
  **********************************************************************/
758
873
  $('#filter_field').on('change', function() {
759
874
  if (this.value.length > 0) {
@@ -891,11 +1006,10 @@ $(document).ready( function() {
891
1006
  *******************************************************************/
892
1007
  $('#_record__filter_field').keydown( function(e) {
893
1008
  if (e.which == '13' || e.which == '9') {
894
- var url = $(this).parents('span').attr("data-url");
1009
+ let url = $(this).parents('span').attr("data-url");
895
1010
  url = url + "&filter_value=" + this.value;
896
- location.href = url;
897
- return false;
898
- }
1011
+ simple_ajax_call(url);
1012
+ };
899
1013
  });
900
1014
 
901
1015
  /*******************************************************************
@@ -913,7 +1027,7 @@ $(document).ready( function() {
913
1027
  value = field.val();
914
1028
  }
915
1029
  url = url + "&filter_value=" + value;
916
- location.href = url;
1030
+ simple_ajax_call(url);
917
1031
  });
918
1032
 
919
1033
  /*******************************************************************
@@ -921,47 +1035,77 @@ $(document).ready( function() {
921
1035
  *******************************************************************/
922
1036
  $('#open_drgcms_filter').on('click', function(e) {
923
1037
  $('#drgcms_filter').bPopup({
924
- speed: 650,
925
- transition: 'slideDown'
926
- });
1038
+ transition: 'slideDown', transitionClose: 'slideDown', speed: 300,
1039
+ opacity: 0, position: ['auto', 20],
1040
+ closeClass: 'dc-link' });
927
1041
  });
928
1042
 
929
1043
  /*******************************************************************
930
1044
  * Click on preview selected image
931
1045
  *******************************************************************/
932
1046
  $('.dc-image-preview').on('click', function(e) {
933
- // var img = $('.img1 img').attr('src');
934
- var img = $(this).children(":first").attr('src');
935
- $('#dc-image-preview').bPopup({
936
- content:'image', //'ajax', 'iframe' or 'image'
937
- contentContainer:'#dc-image-preview',
938
- loadUrl: img
939
- });
1047
+ let img = $(this).children(":first").attr('src');
1048
+ $('#dc-image-preview').bPopup({
1049
+ content: 'image', //'ajax', 'iframe' or 'image'
1050
+ contentContainer: '#dc-image-preview',
1051
+ loadUrl: img,
1052
+ opacity: 0
1053
+ });
940
1054
  });
941
1055
 
942
1056
  /*******************************************************************
943
- *
1057
+ * Set new filter
944
1058
  *******************************************************************/
945
- $('.drgcms_popup_submit').on('click', function(e) {
946
- //e.preventDefault();
947
- url = $(this).attr( 'data-url' );
948
- field = $('select#filter_field1').val();
949
- oper = $('select#filter_oper').val();
950
- location.href = url + '&filter_field=' + field + '&filter_oper=' + oper
951
- // Still opening in new window
952
- // iframe = parent.document.getElementsByTagName("iframe")[0].getAttribute("id");
953
- // loc = url + '&filter_field=' + field + '&filter_oper=' + oper
954
- // $('#'+iframe).attr('src', loc);
955
- // parent.document.getElementById(iframe).src = loc
1059
+ $('.dc-filter-set').on('click', function(e) {
1060
+ let url = $(this).attr( 'data-url' );
1061
+ let field = $('select#filter_field1').val();
1062
+ let operation = $('select#filter_oper').val();
1063
+ url = url + '&filter_field=' + field + '&filter_oper=' + operation
1064
+ simple_ajax_call(url);
956
1065
  });
957
-
958
- /*******************************************************************
959
- * Toggle one cmsedit menu level
960
- *******************************************************************/
961
- $('.cmsedit-top-level-menu').on('click', function(e) {
962
- $(e.target).find('ul').toggle('fast');
1066
+
1067
+ /*******************************************************************
1068
+ * Toggle one cmsedit menu level
1069
+ *******************************************************************/
1070
+ $('.cmsedit-top-level-menu div').on('click', function(e) {
1071
+ $(e.target).siblings('ul').toggle('fast');
1072
+ $(e.target).toggleClass('expanded');
1073
+ });
1074
+
1075
+ /*******************************************************************
1076
+ * Toggle result set record menu
1077
+ *
1078
+ * This and additional two event hadlers provide expected behavior of submenus popup and close.
1079
+ *******************************************************************/
1080
+ $('.dc-result-submenu .mi-more_vert').on('click', function(e) {
1081
+ let ul = $(e.target).siblings('ul');
1082
+ // hide last selected menu if not the same
1083
+ if (typeof dc_last_menu_selected !== 'undefined') { dc_last_menu_selected.hide(); }
1084
+ // if menu is past the bottom fix it to bottom
1085
+ let menu_bottom = ul.height() + ul.parent().position().top + 20;
1086
+ if (menu_bottom > $(document).height()) ul.css('bottom', 0);
1087
+ ul.show();
1088
+ dc_last_menu_selected = ul;
963
1089
  });
964
-
1090
+
1091
+ /*******************************************************************
1092
+ * Result record menu has lost focus. Hide menu.
1093
+ *******************************************************************/
1094
+ $('.dc-result-submenu ul').hover(function(e) {
1095
+ },
1096
+ function(e) {
1097
+ dc_last_menu_selected.hide();
1098
+ dc_last_menu_selected = undefined;
1099
+ });
1100
+
1101
+ /*******************************************************************
1102
+ * Result set record menu is left open if action is canceled. Ex. delete confirm. This will hide menu.
1103
+ *******************************************************************/
1104
+ $('.dc-result-submenu ul li').on('click', function(e) {
1105
+ console.log('ups');
1106
+ if (typeof dc_last_menu_selected !== 'undefined') dc_last_menu_selected.hide();
1107
+ });
1108
+
965
1109
  /*******************************************************************
966
1110
  * Resize result table columns. For now an idea.
967
1111
  *******************************************************************/
@@ -1009,9 +1153,10 @@ $(document).ready( function() {
1009
1153
  } else {
1010
1154
  sign = '';
1011
1155
  }
1012
- // save value to hidden field which holds return value
1156
+ // save value to field holding return value and trigger change event
1013
1157
  var field = '#' + $(this).attr("id").slice(0,-1);
1014
1158
  $(field).val(val);
1159
+ $(field).trigger("change")
1015
1160
 
1016
1161
  // decimal part
1017
1162
  if (decimals == 0) separator = '';
@@ -1093,14 +1238,14 @@ $(document).ready( function() {
1093
1238
  *******************************************************************/
1094
1239
  $('.dc-result-header .th i').hover( function() {
1095
1240
  old_sort_icon = '';
1096
- // save old sort icon and replace it with filter icon
1241
+ // save old sort icon and replace it with filter icon
1097
1242
  $.each( $(this).attr("class").split(/\s+/),
1098
1243
  function(index, item) { if (item.match('sort')) { old_sort_icon = item}; }
1099
1244
  );
1100
- $(this).removeClass(old_sort_icon).addClass('fa-filter');
1101
- // bring back old sort icon
1102
- }, function(){
1103
- $(this).removeClass('fa-filter').addClass(old_sort_icon);
1245
+ $(this).removeClass(old_sort_icon).addClass('mi-ads_click');
1246
+ // bring back old sort icon
1247
+ }, function() {
1248
+ $(this).removeClass('mi-ads_click').addClass(old_sort_icon);
1104
1249
  });
1105
1250
 
1106
1251
  /*******************************************************************
@@ -1108,6 +1253,8 @@ $(document).ready( function() {
1108
1253
  *******************************************************************/
1109
1254
  $('.dc-result-header .th i').click( function(e) {
1110
1255
  e.preventDefault();
1256
+ if ($(this).hasClass('no-filter')) return;
1257
+
1111
1258
  // additional click will close dialog when visible
1112
1259
  if ($('.filter-popup').is(':visible')) {
1113
1260
  $('.filter-popup').hide();
@@ -1118,7 +1265,7 @@ $(document).ready( function() {
1118
1265
  let field_name = header.attr("data-name");
1119
1266
  $('.filter-popup').attr('data-name', field_name);
1120
1267
  // change popup position and show
1121
- $('.filter-popup').css({'top':e.pageY+5,'left':e.pageX, 'position':'absolute'});
1268
+ $('.filter-popup').css({'top': e.pageY + 5, 'left': e.pageX, 'position': 'absolute'});
1122
1269
  $('.filter-popup').show();
1123
1270
  });
1124
1271
 
@@ -1133,7 +1280,7 @@ $(document).ready( function() {
1133
1280
  let field_name = parent.data("name");
1134
1281
 
1135
1282
  url = url + '&filter_field=' + field_name + '&filter_oper=' + operator;
1136
- window.location.href = url;
1283
+ simple_ajax_call(url);
1137
1284
  });
1138
1285
 
1139
1286
  /*****************************************************************
@@ -1141,14 +1288,14 @@ $(document).ready( function() {
1141
1288
  ******************************************************************/
1142
1289
  $(".dc-handle").click(function() {
1143
1290
  let div = this.getAttribute("data-div");
1144
- dc_toggle_div(div);
1291
+ dc_div_toggle(div);
1145
1292
  });
1146
1293
 
1147
1294
  /*******************************************************************
1148
1295
  * Show-Hide CMS menu on hamburger click
1149
1296
  *******************************************************************/
1150
1297
  $('#menu-hamburger').on('click', function(e) {
1151
- $('.cmsedit-container #menu').toggleClass('visible');
1298
+ $('.cmsedit-container #cms-menu').toggleClass('visible');
1152
1299
  });
1153
1300
 
1154
1301
  });