ui/twig/dashboards/default/scripts.html.twig line 240

Open in your IDE?
  1. {{ embed_script(assett('html5shiv::/dist/html5shiv.js'), null, null, 'ie') }}
  2. {{ embed_script(assett('respond::/dest/respond.js'), null, null, 'ie') }}
  3. {{ embed_script(assett('sugar::/release/sugar.min.js'), null, null, 'head') }}
  4. {{ embed_script(assett('headjs::/dist/1.0.0/head.min.js'), null, null, 'head') }}
  5. {{ embed_script(assett('jquery2::/dist/jquery.min.js'), null, null, 'head') }}
  6. {{ embed_script(assett('jquery-migrate::/dist/jquery-migrate.min.js'), null, null, 'head') }}
  7. {{ embed_script(assett('jquery-ui::/jquery-ui.min.js'), null, null, 'head') }}
  8. {{ embed_script(assett('bootstrap::/dist/js/bootstrap.min.js'), null, null, 'head') }}
  9. {{ embed_script(assett('jquery-cookie', 'jquery.cookie.min.js'), null, null, 'bottom') }}
  10. {{ embed_script(assett('breakpoints::/breakpoints.js'), null, null, 'bottom') }}
  11. {{ embed_script(assett('jquery-scrollbar::/jquery.scrollbar.min.js'), null, null, 'bottom') }}
  12. {{ embed_script(assett('jquery-slimscroll::/jquery.slimscroll.min.js'), null, null, 'bottom') }}
  13. {{ embed_script(assett('bootstrap-colorpicker::/dist/js/bootstrap-colorpicker.min.js'), null, null, 'bottom') }}
  14. {{ embed_script(assett('moment::/min/moment.min.js'), null, null, 'bottom') }}
  15. {{ embed_script(assett('bootstrap-slider::/dist/bootstrap-slider.min.js'), null, null, 'bottom') }}
  16. {{ embed_script(assett('chosen::/chosen.jquery.min.js'), null, null, 'bottom') }}
  17. {{ embed_script(assett('jquery-maskedinput::/dist/jquery.maskedinput.min.js'), null, null, 'bottom') }}
  18. {{ embed_script(assett('jquery-tageditor::/jquery.tag-editor.min.js'), null, null, 'bottom') }}
  19. {{ embed_script(assett('mixitup::/build/jquery.mixitup.min.js'), null, null, 'bottom') }}
  20. {{ embed_script(assett('knockout::/dist/knockout.js'), null, null, 'bottom') }}
  21. {{ embed_script(assett('chart-js::/dist/chart.min.js'), null, null, 'bottom') }}
  22. {{ embed_script(assett('palette-js::/palette.js'), null, null, 'bottom') }}
  23. {{ embed_script(assett('jquery-boilerplate::/dist/jquery.boilerplate.min.js'), null, null, 'bottom') }}
  24. {{ embed_script(assett('ace::/src-min-noconflict/ace.js'), null, null, 'bottom') }}
  25. {{ embed_script(assett('js-yaml::/dist/js-yaml.min.js'), null, null, 'bottom') }}
  26. {{ embed_script(assett('jquery-infinitescroll::/dist/infinite-scroll.pkgd.min.js'), null, null, 'bottom') }}
  27. {{ embed_script(assett('ckeditor::/ckeditor.js'), null, null, 'bottom') }}
  28. {{ embed_script(assett('uri-js::/src/URI.min.js'), null, null, 'bottom') }}
  29. {{ embed_script('/bundles/cmscore/plugins/modal.js', null, null, 'bottom') }}
  30. {{ embed_script(assett('match-height::/dist/jquery.matchHeight-min.js'), null, null, 'bottom') }}
  31. {{ embed_script(assett('clipboardjs::/dist/clipboard.js'), null, null, 'bottom') }}
  32. {{ embed_script(assett('anchorme::/dist-browser/anchorme.min.js'), null, null, 'bottom') }}
  33. {{ embed_script('/bundles/cmscore/searches.js', null, null, 'bottom') }}
  34. {{ embed_script('/bundles/cmscore/dashboard/bulk.js', null, null, 'bottom') }}
  35. {# HACK: cropper #}
  36. {{ embed_script(assett('cropper::/dist/cropper.min.js')) }}
  37. {{ embed_style(assett('cropper::/dist/cropper.min.css')) }}
  38. {{ embed_script('/bundles/cmsfile/cropper.js', null, null, 'bottom') }}
  39. {# HACK: toastr #}
  40. {{ embed_script(assett('toastr::/toastr.min.js'), null, null, 'bottom') }}
  41. {{ embed_style(assett('toastr::/toastr.min.css')) }}
  42. {% inline_script %}
  43.     <script>
  44.         (function (window, document, $, undefined) {
  45.             $(function () {
  46.                 toastr.options = {
  47.                     closeButton: false,
  48.                     debug: false,
  49.                     newestOnTop: true,
  50.                     progressBar: false,
  51.                     positionClass: 'toast-top-right',
  52.                     preventDuplicates: false,
  53.                     onclick: null,
  54.                     showDuration: '250',
  55.                     hideDuration: '250',
  56.                     timeOut: '1500',
  57.                     extendedTimeOut: '500',
  58.                     showEasing: 'swing',
  59.                     hideEasing: 'linear',
  60.                     showMethod: 'fadeIn',
  61.                     hideMethod: 'fadeOut'
  62.                 };
  63.             });
  64.         })(window, document, jQuery);
  65.     </script>
  66. {% endinline %}
  67. {# pulled from page editor stuff #}
  68. {% inline_script %}
  69.     <script>
  70.         function htmlEscape(str) {
  71.             return String(str)
  72.                 .replace(/&/g, '&amp;')
  73.                 .replace(/"/g, '&quot;')
  74.                 .replace(/'/g, '&#39;')
  75.                 .replace(/</g, '&lt;')
  76.                 .replace(/>/g, '&gt;');
  77.         }
  78.         $.fn.serializeObject = function() {
  79.             var o = {}, a = this.serializeArray();
  80.             $.each(a, function() {
  81.                 if (o[this.name] !== undefined) {
  82.                     if (!o[this.name].push) {
  83.                         o[this.name] = [o[this.name]];
  84.                     }
  85.                     o[this.name].push(this.value || '');
  86.                 } else {
  87.                     o[this.name] = this.value || '';
  88.                 }
  89.             });
  90.             return o;
  91.         };
  92.     </script>
  93. {% endinline %}
  94. {% inline_script %}
  95.     <script>
  96.         (function (window, document, $, undefined) {
  97.             // hide modal content when hidden
  98.             $('body').on('hidden.bs.modal', '[data-campussuite-modal-autoempty]', function (e) {
  99.                 var $target = $(e.target),
  100.                     $content = $target.find('div.modal-content').first();
  101.                 $content.empty();
  102.             });
  103.             // image loader plugin
  104.             window.csimgloader = function(elem, count) {
  105.                 // init count
  106.                 if (count === undefined) {
  107.                     count = 1;
  108.                 }
  109.                 // should be an img element
  110.                 var $elem = $(elem);
  111.                 // grab the src of the image
  112.                 var src = $elem.attr('src');
  113.                 // set new html for loading purposes
  114.                 var $parent = $elem.parent();
  115.                 $parent.html('<img alt="" src="/bundles/cmscore/loading.gif" />');
  116.                 // set a callback that runs in a few seconds to try and reload the image
  117.                 setTimeout((function(parent, src, count) {
  118.                     return function() {
  119.                         if (count > 12) {
  120.                             return;
  121.                         }
  122.                         count++;
  123.                         var $parent = $(parent);
  124.                         if ($.contains(document.documentElement, $parent[0])) {
  125.                             $parent.html('<img alt="" src="' + src + '" onerror="(function(elem){jQuery(function() {window.csimgloader(elem, ' + count + ');});})(this);" />');
  126.                         }
  127.                     };
  128.                 })($parent[0], src, count), 5000);
  129.             }
  130.         })(window, document, jQuery);
  131.     </script>
  132. {% endinline %}
  133. {% inline_script %}
  134.     <script>
  135.         CKEDITOR.dtd.$removeEmpty['em'] = false;
  136.         CKEDITOR.on('dialogDefinition', function(e) {
  137.             var dialog = e.data;
  138.             var dialogName = dialog.name;
  139.             var dialogDefinition = dialog.definition;
  140.             if (dialogName === 'link') {
  141.                 var infoTab = dialogDefinition.getContents('info');
  142.                 var urlOptions = infoTab.get('urlOptions');
  143.                 urlOptions.children.push({
  144.                     type: 'button',
  145.                     id: 'browseSite',
  146.                     label: 'Browse Files',
  147.                     title: 'Browse Files',
  148.                     onClick: function() {
  149.                         var urlField = this.getDialog().getContentElement('info', 'url'),
  150.                             cs = window.top.CAMPUSSUITE;
  151.                         CampussuiteModals.open({
  152.                             url: '/_dashboard/files/modal',
  153.                             params: {
  154.                                 mode: (typeof CKEDITOR_MODAL_OVERRIDE !== 'undefined') ? CKEDITOR_MODAL_OVERRIDE : 'url',
  155.                                 container: cs.container,
  156.                                 value: urlField.getValue()
  157.                             },
  158.                             callback: function(selection) {
  159.                                 urlField.setValue(selection);
  160.                             },
  161.                             styles: 'modal-dialog--media'
  162.                         });
  163.                     }
  164.                 });
  165.                 urlOptions.children.push({
  166.                     type: 'button',
  167.                     id: 'browseContent',
  168.                     label: 'Browse Content',
  169.                     title: 'Browse Content',
  170.                     onClick: function() {
  171.                         var urlField = this.getDialog().getContentElement('info', 'url'),
  172.                             cs = window.top.CAMPUSSUITE;
  173.                         CampussuiteModals.open({
  174.                             url: '/_dashboard/modules/modal',
  175.                             params: {
  176.                                 containerId: cs.container
  177.                             },
  178.                             callback: function(selection) {
  179.                                 urlField.setValue(selection);
  180.                             },
  181.                             styles: 'modal-dialog--media'
  182.                         });
  183.                     }
  184.                 });
  185.             }
  186.             if (dialogName === 'image') {
  187.                 var tb = dialogDefinition.getContents('info');
  188.                 var thing = tb.elements[0].children[0];
  189.                 thing.children.push({
  190.                     type: 'button',
  191.                     id: 'browseSite',
  192.                     label: 'Browse Files',
  193.                     title: 'Browse Files',
  194.                     onClick: function() {
  195.                         var urlField = this.getDialog().getContentElement('info', 'txtUrl'),
  196.                             cs = window.top.CAMPUSSUITE;
  197.                         CampussuiteModals.open({
  198.                             url: '/_dashboard/files/modal',
  199.                             params: {
  200.                                 mode: (typeof CKEDITOR_MODAL_OVERRIDE !== 'undefined') ? CKEDITOR_MODAL_OVERRIDE : 'url',
  201.                                 container: cs.container,
  202.                                 value: urlField.getValue()
  203.                             },
  204.                             callback: function(selection) {
  205.                                 urlField.setValue(selection);
  206.                             },
  207.                             styles: 'modal-dialog--media'
  208.                         });
  209.                     }
  210.                 });
  211.             }
  212.         });
  213.     </script>
  214. {% endinline %}
  215. {{ embed_script('/bundles/cmscore/AjaxSelect.js', null, null, 'bottom') }}
  216. <script type="text/javascript">
  217.     window.CAMPUSSUITE = {
  218.         environment: '{{ cms.environment }}',
  219.         tenant: {
  220.             id: {{ cms.tenant.id }},
  221.             uid: '{{ cms.tenant.uid.toString() }}',
  222.             slug: '{{ cms.tenant.slug }}'
  223.         },
  224.         container: {{ (cms.department is not empty) ? cms.department.id : 'null' }}
  225.     };
  226. </script>
  227. {% inline_script %}
  228.     <script>
  229.         // Break point entry
  230.         $(function() {
  231.             var $window = $(window),
  232.                 $console = $('#cs-console');
  233.             $window
  234.                 .bind('enterBreakpoint321', function () {
  235.                     if ($console.hasClass('sb-disable-autoload')) {
  236.                         return;
  237.                     }
  238.                     $console
  239.                         .removeClass('cs-console-md')
  240.                         .removeClass('cs-console-lg sb-expand')
  241.                         .addClass('cs-console-sm sb-collapse');
  242.                 })
  243.                 .bind('enterBreakpoint481', function () {
  244.                     if ($console.hasClass('sb-disable-autoload')) {
  245.                         return;
  246.                     }
  247.                     $console
  248.                         .removeClass('cs-console-md')
  249.                         .removeClass('cs-console-lg sb-expand')
  250.                         .addClass('cs-console-sm sb-collapse');
  251.                 })
  252.                 .bind('enterBreakpoint821', function () {
  253.                     if ($console.hasClass('sb-disable-autoload')) {
  254.                         return;
  255.                     }
  256.                     $console
  257.                         .removeClass('cs-console-sm')
  258.                         .removeClass('cs-console-lg sb-expand')
  259.                         .addClass('cs-console-md sb-collapse');
  260.                 })
  261.                 .bind('enterBreakpoint1065', function () {
  262.                     if ($console.hasClass('sb-disable-autoload')) {
  263.                         return;
  264.                     }
  265.                     $console
  266.                         .removeClass('cs-console-sm sb-collapse')
  267.                         .removeClass('cs-console-md sb-collapse')
  268.                         .addClass('cs-console-lg sb-expand');
  269.                 });
  270.             $window.setBreakpoints({
  271.                 distinct: true,
  272.                 breakpoints: [
  273.                     // needing to set breakpoints at one pixel above where they should
  274.                     // this better matches current css media queries
  275.                     // these events need triggered once the viewport extends beyond the designated "real" sizes, hence the extra pixel
  276.                     321,// 320
  277.                     481,// 480
  278.                     821,// 820
  279.                     1065// 1064
  280.                 ]
  281.             });
  282.         });
  283.         // Console Sidebar Toggle
  284.         $(function() {
  285.             var $toggle = $('.cs-console-sb-toggle'),
  286.                 $console = $('#cs-console');
  287.             $toggle.click(function () {
  288.                 if ($console.hasClass('sb-collapse')) {
  289.                     $console
  290.                         .removeClass('sb-collapse')
  291.                         .addClass('sb-expand');
  292.                 } else {
  293.                     $console
  294.                         .removeClass('sb-expand')
  295.                         .addClass('sb-collapse');
  296.                 }
  297.             });
  298.         });
  299.         // Console Sidebar Hover
  300.         $(function() {
  301.             var $sidebar = $('#cs-console-sidebar'),
  302.                 $console = $('#cs-console');
  303.             $sidebar.hover(
  304.                 function () {
  305.                     //if ( ! $console.hasClass('cs-console-sm')) {
  306.                     if ($console.hasClass('cs-console-md')) {
  307.                         $console
  308.                             .addClass('sb-expand')
  309.                             .removeClass('sb-collapse');
  310.                     }
  311.                 },
  312.                 function () {
  313.                     if ($console.hasClass('cs-console-md')) {
  314.                         $console
  315.                             .addClass('sb-collapse')
  316.                             .removeClass('sb-expand');
  317.                     }
  318.                 }
  319.             );
  320.         });
  321.         // Console Sidebar Nav Toggle
  322.         $(function() {
  323.             $('ul.editor__side-nav').on('click', 'a', function(e) {
  324.                 var $link = $(e.currentTarget),
  325.                     $topmenu = $link.closest('ul'),
  326.                     $topitem = $link.closest('li');
  327.                 // remove the active state from all current items
  328.                 // skip the currently selected item to prevent odd behavior
  329.                 $topmenu
  330.                     .find('li')
  331.                     .not($topitem)
  332.                     .removeClass('active');
  333.                 // activate the current items
  334.                 $topitem.addClass('active');
  335.             });
  336.             $('ul.cs-console-sb-menu').on('click', 'a', function(e) {
  337.                 var $link = $(e.currentTarget),
  338.                     $topmenu = $link.closest('ul'),
  339.                     $submenu = null,
  340.                     $topitem = null,
  341.                     $subitem = null;
  342.                 // fix the menus
  343.                 if ($topmenu.hasClass('cs-sub-menu')) {
  344.                     $submenu = $topmenu;
  345.                     $topmenu = $submenu.closest('ul');
  346.                 }
  347.                 // if there is a submenu above, then there are two items to consider
  348.                 if ($submenu !== null) {
  349.                     $subitem = $link.closest('li');
  350.                     $topitem = $subitem.closest('li');
  351.                 } else {
  352.                     $topitem = $link.closest('li');
  353.                 }
  354.                 // now, there might be a submenu related that we need to show
  355.                 // if nothing returns, clear out the variable
  356.                 $submenu = $topitem.children('ul.cs-sub-menu');
  357.                 if ($submenu.length === 0) {
  358.                     $submenu = null;
  359.                 }
  360.                 // remove the active state from all current items
  361.                 // skip the currently selected item to prevent odd behavior
  362.                 $topmenu
  363.                     .find('li')
  364.                     .not($topitem)
  365.                     .not($subitem)
  366.                     .removeClass('active');
  367.                 // slide up all open submenus
  368.                 // skip the currently selected item to prevent odd behavior
  369.                 $topmenu
  370.                     .find('ul.cs-sub-menu')
  371.                     .not($submenu)
  372.                     .slideUp(200);
  373.                 // activate the current items
  374.                 $topitem.addClass('active');
  375.                 if ($subitem !== null) {
  376.                     $subitem.addClass('active');
  377.                 }
  378.                 // if we have a submenu, open it
  379.                 // items with submenus should not have other actions, prevent default then
  380.                 if ($submenu !== null) {
  381.                     $submenu.slideDown(200);
  382.                     e.preventDefault();
  383.                 }
  384.             });
  385.         });
  386.         // Console Sidebar Slimscroll
  387.         $(function() {
  388.             var resizeListener;
  389.             var pause = 500;
  390.             $('.sb-scroll').slimScroll({
  391.                 height: 'auto',
  392.                 size: '10px'
  393.             });
  394.             $(window).resize(function(){
  395.                 clearTimeout(resizeListener);
  396.                 resizeListener = setTimeout(
  397.                     function() {
  398.                         $('.sb-scroll').slimScroll({
  399.                             height: 'auto'
  400.                         });
  401.                     },
  402.                     pause
  403.                 );
  404.             });
  405.         });
  406.     </script>
  407. {% endinline %}
  408. {% inline_script %}
  409.     <script>
  410.         $('[data-topbar="popover-bottom"]').popover({
  411.             html: true,
  412.             placement: 'bottom',
  413.             sanitize: false,
  414.             content: function () {
  415.                 return $(this).siblings('.dropdown-content').html();
  416.             }
  417.         });
  418.         // Close popovers
  419.         $('body').on('click', function (e) {
  420.             $('[data-topbar="popover-bottom"]').each(function () {
  421.                 if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
  422.                     $(this).popover('hide');
  423.                 }
  424.             });
  425.         });
  426.         // tooltips: https://getbootstrap.com/docs/3.3/javascript/#tooltips-examples
  427.         $(function () {
  428.             const elements = $('[data-toggle="tooltip"]');
  429.             for (let i=0; i < elements.length; i++) {
  430.                 const element = $(elements[i]);
  431.                 const isTriggeredByClick = ('click' === element.data('trigger'));
  432.                 element.tooltip({
  433.                     container: 'body',
  434.                     placement: element.data('placement') ?? 'right',
  435.                     trigger: isTriggeredByClick ? 'manual' : 'hover',
  436.                     html: true,
  437.                     template: '<div class="tooltip tooltip-custom" role="tooltip"><div class="tooltip-arrow tooltip-arrow-custom"></div><div class="tooltip-inner tooltip-inner-custom"></div></div>',
  438.                 });
  439.                 if (isTriggeredByClick) {
  440.                     element.on('click', function (event) {
  441.                         event.preventDefault();
  442.                         event.stopPropagation();
  443.                         $(this).tooltip('show');
  444.                     });
  445.                 }
  446.                 element.on('show.bs.tooltip', function () {
  447.                     const displayedTitle = $(this).data('originalTitle');
  448.                     const tooltipElements = $('[data-toggle="tooltip"]');
  449.                     for (let i=0; i < tooltipElements.length; i++) {
  450.                         if (displayedTitle !== $(tooltipElements[i]).data('originalTitle')) {
  451.                             $(tooltipElements[i]).tooltip('hide');
  452.                         }
  453.                     }
  454.                 });
  455.             }
  456.             $('body').on('click', function () {
  457.                 $('[data-toggle="tooltip"]').tooltip('hide');
  458.             });
  459.         });
  460.     </script>
  461. {% endinline %}
  462. {% include '@ui/dashboards/default/scripts/google-analytics.html.twig' %}
  463. {% include '@ui/dashboards/default/scripts/zendesk.html.twig' %}
  464. {% include '@ui/dashboards/default/scripts/churnzero.html.twig' %}