You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.8 KiB

9 years ago
9 years ago
9 years ago
  1. var csrf;
  2. function initInstall() {
  3. if ($('.install').length == 0) {
  4. return;
  5. }
  6. // Database type change detection.
  7. $("#db_type").change(function () {
  8. var db_type = $('#db_type').val();
  9. if (db_type === "SQLite3") {
  10. $('#sql_settings').hide();
  11. $('#pgsql_settings').hide();
  12. $('#sqlite_settings').show();
  13. return;
  14. }
  15. var mysql_default = '127.0.0.1:3306';
  16. var postgres_default = '127.0.0.1:5432';
  17. $('#sqlite_settings').hide();
  18. $('#sql_settings').show();
  19. if (db_type === "PostgreSQL") {
  20. $('#pgsql_settings').show();
  21. if ($('#db_host').val() == mysql_default) {
  22. $('#db_host').val(postgres_default);
  23. }
  24. } else {
  25. $('#pgsql_settings').hide();
  26. if ($('#db_host').val() == postgres_default) {
  27. $('#db_host').val(mysql_default);
  28. }
  29. }
  30. });
  31. };
  32. function initRepository() {
  33. if ($('.repository').length == 0) {
  34. return;
  35. }
  36. // Labels
  37. if ($('.repository.labels').length == 0) {
  38. return;
  39. }
  40. $('.color-picker').each(function () {
  41. $(this).minicolors();
  42. });
  43. $('.precolors .color').click(function () {
  44. var color_hex = $(this).data('color-hex')
  45. $('.color-picker').val(color_hex);
  46. $('.minicolors-swatch-color').css("background-color", color_hex);
  47. });
  48. $('.delete-label-button').click(function () {
  49. var $this = $(this);
  50. $('.delete-label.modal').modal({
  51. closable: false,
  52. onApprove: function () {
  53. $.post($this.data('url'), {
  54. "_csrf": csrf,
  55. "id": $this.data("id")
  56. }).done(function (data) {
  57. window.location.href = data.redirect;
  58. });
  59. }
  60. }).modal('show');
  61. return false;
  62. });
  63. $('.edit-label-button').click(function () {
  64. $('#label-modal-id').val($(this).data('id'));
  65. $('#label-modal-title').val($(this).data('title'));
  66. $('#label-modal-color').val($(this).data('color'))
  67. $('.minicolors-swatch-color').css("background-color", $(this).data('color'));
  68. $('.edit-label.modal').modal({
  69. onApprove: function () {
  70. $('.edit-label.form').submit();
  71. }
  72. }).modal('show');
  73. return false;
  74. });
  75. };
  76. $(document).ready(function () {
  77. csrf = $('meta[name=_csrf]').attr("content");
  78. // Semantic UI modules.
  79. $('.dropdown').dropdown();
  80. $('.jump.dropdown').dropdown({
  81. action: 'hide'
  82. });
  83. $('.slide.up.dropdown').dropdown({
  84. transition: 'slide up'
  85. });
  86. $('.ui.accordion').accordion();
  87. $('.ui.checkbox').checkbox();
  88. $('.poping.up').popup();
  89. initInstall();
  90. initRepository();
  91. });