settings.js 548 B

12345678910111213141516171819
  1. define('utils/settings', function () {
  2. Vue.directive('setting', {
  3. bind: function () {
  4. var _this = this;
  5. _this.onChange = function () {
  6. _.options.set(_this.value, _this.el.checked);
  7. };
  8. _this.el.addEventListener('change', _this.onChange, false);
  9. },
  10. update: function (value) {
  11. var _this = this;
  12. _this.el.checked = _.options.get(_this.value = value);
  13. },
  14. unbind: function () {
  15. var _this = this;
  16. _this.el.removeEventListener('change', _this.onChange, false);
  17. },
  18. });
  19. });