Example #1
0
sp.createInt = function(id, title, def, min, max, step, unit,
                        callback, persistent) {
  var group = this;

  var item = createSetting(group, 'integer', id, title);

  var initial = group.getvalue(id, def, 'int', persistent);
  item.model.value = initial;

  prop.setClipRange(item.model.value, min, max);

  item.model.min  = min;
  item.model.max  = max;
  item.model.step = step;
  item.model.unit = unit;

  prop.subscribeValue(item.model.value, function(newval) {
    if(group.zombie)
      return;

    newval = parseInt(newval);
    group.setvalue(id, newval, persistent);
    callback(newval);
  }, {
    noInitialUpdate: true,
    ignoreVoid: true,
    autoDestroy: true
  });

  callback(initial);
  return item;
}
Example #2
0
sp.createBool = function(id, title, def, callback, persistent) {
  var group = this;
  var item = createSetting(group, 'bool', id, title);

  var initial = group.getvalue(id, def, 'bool', persistent);
  item.model.value = initial;

  prop.subscribeValue(item.model.value, function(newval) {
    if(group.zombie)
      return;

    group.setvalue(id, newval, persistent);
    callback(newval);
  }, {
    noInitialUpdate: true,
    ignoreVoid: true,
    autoDestroy: true
  });
  callback(initial);
  return item;
}