Sha256: b3c99d328c2b5fd2356df120f652a30de15f63e418350a7fc98c93f4d99636a0

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 Bytes

Contents

/*
---
 
script: Toggle.js
 
description: Changes the checkedness state of a checkbox
 
license: Public domain (http://unlicense.org).

authors: Yaroslaff Fedin
 
requires:
  - LSD.Action
 
provides:
  - LSD.Action.Toggle
  - LSD.Action.Check
  - LSD.Action.Uncheck
 
...
*/


LSD.Action.Toggle = LSD.Action.build({
  enable: function(target) {
    if (!target || target == this.invoker || target.element == this.invoker) return;
    if (!target.checked) (target.check || target.click).apply(target, Array.prototype.slice.call(arguments, 1));
  },
  
  disable: function(target) {
    if (!target || target == this.invoker || target.element == this.invoker) return;
    if (target.checked) (target.uncheck || target.click).apply(target, Array.prototype.slice.call(arguments, 1));
  },
  
  getState: function(target, name, state) {
    return (state !== true && state !== false) ? this.invoker.checked : !state;
  },

  enabler: 'check',
  disabler: 'uncheck'
});

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lsd_rails-0.1.2 Packages/lsd/Source/Action/Toggle.js
lsd_rails-0.1.1 Packages/lsd/Source/Action/Toggle.js
lsd_rails-0.1 Packages/lsd/Source/Action/Toggle.js