settings.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. 'use strict';
  2. var Vue = require('vue'),
  3. Core = require('./core.js').Core;
  4. var vueSettings = new Vue({
  5. el: '#settings',
  6. data: {
  7. settings: Core.settings.data,
  8. open: false
  9. },
  10. methods: {
  11. show: function () {
  12. this.open = true;
  13. $('.backdrop').removeClass('hide');
  14. $('.settings').addClass('open');
  15. },
  16. hide: function () {
  17. this.open = false;
  18. // wait for animation to finish
  19. setTimeout(function () {
  20. $('.backdrop').addClass('hide');
  21. $('.settings').removeClass('open');
  22. }, 500);
  23. },
  24. toggleSettings: function () {
  25. if (this.open) this.hide();
  26. else this.show();
  27. },
  28. saveSettings: function () {
  29. Core.settings.set(this.settings);
  30. Core.settings.save(function (error) {
  31. if (error) return console.error(error);
  32. vueSettings.hide();
  33. });
  34. },
  35. exportThings: function () {
  36. Core.things.export();
  37. vueSettings.hide();
  38. },
  39. logout: function () {
  40. window.location.href = '/auth/logout';
  41. }
  42. }
  43. });
  44. module.exports = vueSettings;