application.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //= require ./jquery
  2. //= require ./jquery_ujs
  3. //= require ./stupidtable
  4. //= require ./jquery.stickytableheaders
  5. //= require ./selectize
  6. //= require ./highlight.pack
  7. //= require ./moment
  8. //= require ./moment-timezone
  9. //= require ./daterangepicker
  10. //= require ./Chart.js
  11. //= require ./chartkick
  12. //= require ./ace
  13. //= require ./Sortable
  14. //= require ./bootstrap
  15. //= require ./vue
  16. //= require ./routes
  17. //= require ./queries
  18. //= require ./fuzzysearch
  19. Vue.config.devtools = false
  20. $(document).on('mouseenter', '.dropdown-toggle', function () {
  21. $(this).parent().addClass('open')
  22. })
  23. $(document).on("change", "#bind input, #bind select", function () {
  24. submitIfCompleted($(this).closest("form"))
  25. })
  26. $(document).on("click", "#code", function () {
  27. $(this).addClass("expanded")
  28. })
  29. function submitIfCompleted($form) {
  30. var completed = true
  31. $form.find("input[name], select").each( function () {
  32. if ($(this).val() == "") {
  33. completed = false
  34. }
  35. })
  36. if (completed) {
  37. $form.submit()
  38. }
  39. }
  40. // Prevent backspace from navigating backwards.
  41. // Adapted from Biff MaGriff: http://stackoverflow.com/a/7895814/1196499
  42. function preventBackspaceNav() {
  43. $(document).keydown(function (e) {
  44. var preventKeyPress
  45. if (e.keyCode == 8) {
  46. var d = e.srcElement || e.target
  47. switch (d.tagName.toUpperCase()) {
  48. case 'TEXTAREA':
  49. preventKeyPress = d.readOnly || d.disabled
  50. break
  51. case 'INPUT':
  52. preventKeyPress = d.readOnly || d.disabled || (d.attributes["type"] && $.inArray(d.attributes["type"].value.toLowerCase(), ["radio", "reset", "checkbox", "submit", "button"]) >= 0)
  53. break
  54. case 'DIV':
  55. preventKeyPress = d.readOnly || d.disabled || !(d.attributes["contentEditable"] && d.attributes["contentEditable"].value == "true")
  56. break
  57. default:
  58. preventKeyPress = true
  59. break
  60. }
  61. }
  62. else {
  63. preventKeyPress = false
  64. }
  65. if (preventKeyPress) {
  66. e.preventDefault()
  67. }
  68. })
  69. }
  70. preventBackspaceNav()