appBase.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. (function () {
  2. // selectAll-"feature"...its really crappy to wait for document change
  3. // but since the materialize modal initialization is a fucking callback hell,
  4. // this is pretty much the only option...will (hopefully) be refactored in
  5. // version 2.4.0 when the entire rendering is switched to vue's...
  6. $(document).on('change', 'input:checkbox.selectAll', function(){
  7. $('input:checkbox.trackCheckbox').prop('checked', $(this).prop('checked'))
  8. })
  9. if (typeof require !== "undefined"){
  10. //open links externally by default
  11. $(document).on('click', 'a[href^="http"]', function (event) {
  12. event.preventDefault()
  13. shell.openExternal(this.href)
  14. })
  15. // Open DevTools when F12 is pressed
  16. // Reload page when F5 is pressed
  17. if (remote.process.env.NODE_ENV == 'development'){
  18. document.addEventListener("keydown", function (e) {
  19. if (e.which === 123) {
  20. remote.getCurrentWindow().toggleDevTools()
  21. }
  22. if (e.which === 116) {
  23. remote.getCurrentWindow().reload()
  24. }
  25. });
  26. }
  27. }
  28. // Function to make title-bar work
  29. function initTitleBar() {
  30. let $mainEl = $('#title-bar')
  31. $mainEl.css('display','none')
  32. $('nav').css('top','0')
  33. $('nav').css('padding-top','0')
  34. $('#main_icon').css('margin-top','0')
  35. $('#login_email_btn').addClass('disabled')
  36. document.documentElement.style.setProperty('--appbar-height', "0px")
  37. }
  38. // Ready state of the page
  39. document.onreadystatechange = function () {
  40. if (document.readyState == "interactive") {
  41. initTitleBar()
  42. if(typeof require !== "undefined"){
  43. $("#login-form-client-mode").removeClass('hide')
  44. $('#modal_settings_input_downloadTracksLocation').on('click', function () {
  45. let originalValue = $(this).val()
  46. let newValue = dialog.showOpenDialog({
  47. properties: ['openDirectory']
  48. })
  49. if (typeof newValue !== 'undefined'){
  50. $(this).val(newValue)
  51. }
  52. })
  53. }else{
  54. $("#login-form-server-mode").removeClass('hide')
  55. $("#openDownloadsFolder").parent().hide()
  56. $("#cancelAllTable").parent().removeClass("m4").addClass("m6")
  57. $("#clearTracksTable").parent().removeClass("m4").addClass("m6")
  58. $("#modal_settings_cbox_minimizeToTray").parent().parent().hide()
  59. }
  60. }
  61. };
  62. })(jQuery)