footer.js.tpl 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <script>
  2. /* Makes row highlighting possible */
  3. $(document).ready( function() {
  4. // Date time settings.
  5. moment.locale('{{ locale }}');
  6. $.datepicker.setDefaults($.datepicker.regional["{{ locale }}"]);
  7. $.datepicker.regional["local"] = $.datepicker.regional["{{ locale }}"];
  8. // Chosen select
  9. $(".chzn-select").chosen({
  10. disable_search_threshold: 10,
  11. no_results_text: '{{ 'SearchNoResultsFound' | get_lang | escape('js')}}',
  12. placeholder_text_multiple: '{{ 'SelectSomeOptions' | get_lang | escape('js')}}',
  13. placeholder_text_single: '{{ 'SelectAnOption' | get_lang | escape('js')}}',
  14. width: "100%"
  15. });
  16. // Bootstrap tabs.
  17. $('.tab-wrapper a').click(function (e) {
  18. e.preventDefault();
  19. $(this).tab('show');
  20. //$('#tabs a:first').tab('show') // Select first tab
  21. });
  22. // Fixes bug when loading links inside a tab.
  23. $('.tab-wrapper .tab-pane a').unbind();
  24. /**
  25. * Advanced options
  26. * Usage
  27. * <a id="link" href="url">Advanced</a>
  28. * <div id="link_options">
  29. * hidden content :)
  30. * </div>
  31. * */
  32. $(".advanced_options").on("click", function (event) {
  33. event.preventDefault();
  34. var id = $(this).attr('id') + '_options';
  35. var button = $(this);
  36. button.toggleClass('active');
  37. $("#" + id).toggle();
  38. });
  39. /**
  40. * <a class="advanced_options_open" href="http://" rel="div_id">Open</a>
  41. * <a class="advanced_options_close" href="http://" rel="div_id">Close</a>
  42. * <div id="div_id">Div content</div>
  43. * */
  44. $(".advanced_options_open").on("click", function (event) {
  45. event.preventDefault();
  46. var id = $(this).attr('rel');
  47. $("#" + id).show();
  48. });
  49. $(".advanced_options_close").on("click", function (event) {
  50. event.preventDefault();
  51. var id = $(this).attr('rel');
  52. $("#" + id).hide();
  53. });
  54. // Adv multi-select search input.
  55. $('.select_class_filter').on('focus', function () {
  56. var inputId = $(this).attr('id');
  57. inputId = inputId.replace('-filter', '');
  58. $("#" + inputId).filterByText($("#" + inputId + "-filter"));
  59. });
  60. $(".jp-jplayer audio").addClass('skip');
  61. // Mediaelement
  62. if ( {{ show_media_element }} == 1) {
  63. jQuery('video:not(.skip), audio:not(.skip)').mediaelementplayer(/* Options */);
  64. }
  65. // Table highlight.
  66. $("form .data_table input:checkbox").click(function () {
  67. if ($(this).is(":checked")) {
  68. $(this).parentsUntil("tr").parent().addClass("row_selected");
  69. } else {
  70. $(this).parentsUntil("tr").parent().removeClass("row_selected");
  71. }
  72. });
  73. /* For non HTML5 browsers */
  74. if ($("#formLogin".length > 1)) {
  75. $("input[name=login]").focus();
  76. }
  77. // Tool tip (in exercises)
  78. var tip_options = {
  79. placement: 'right'
  80. };
  81. $('.boot-tooltip').tooltip(tip_options);
  82. });
  83. </script>