Commits

Justin Love committed 74497e3

change events for toastmaster timer

  • Participants
  • Parent commits e3e1433

Comments (0)

Files changed (2)

File script/DiskClock.js

   }
   return function (e) {
     if (!validate || validate(e.target.value)) {
+      changePreference(property, dcprefs[property], e.target.value);
       dcprefs[property] = e.target.value;
       commitPreference(property);
       app.disks.thatRequireSetting(property, function(d) {d.jump();});
   if (!property) {
     return;
   }
-  if (diskclock.settings[property].commit) {
-    diskclock.settings[property].commit(app);
+  var info = diskclock.settings[property];
+  if (info.commit) {
+    info.commit(app);
   } else {
-    commitPreference(diskclock.settings[property].part_of);
+    commitPreference(info.part_of);
+  }
+}
+
+function changePreference(property, oldvalue, newvalue) {
+  if (!property) {
+    return;
+  }
+  var info = diskclock.settings[property];
+  if (info.change) {
+    info.change(oldvalue, newvalue, app);
   }
 }
 

File script/plugins/Toastmaster.js

       parts: ['toastmaster_min', 'toastmaster_max']
     },
     toastmaster_min: {
+      change: function(older, newer, app) {
+        app.dcprefs.toastmaster_max
+          = app.plugins.Toastmaster.max
+          = maxForMin(parseFloat(newer));
+        app.refreshSettings();
+      },
       commit: function(app) {
-        var t = app.plugins.Toastmaster
-        t.min = parseFloat(app.dcprefs.toastmaster_min, 10);
-        app.dcprefs.toastmaster_max = t.max = maxForMin(t.min);
-        app.refreshSettings();
+        app.plugins.Toastmaster.min = parseFloat(app.dcprefs.toastmaster_min, 10);
       }
     },
     toastmaster_max: {