/* Construct a state `toggler`: a function which inverses
`property` in context based on its current value.
The by `toggler` returned function restores that value.
328912
function factory(key, state, ctx) {
  return enter

  function enter() {
    var context = ctx || this
    var current = context[key]

    context[key] = !state

    return exit

    function exit() {
      context[key] = current
    }
  }
}
1182498
async def toggle(self):
        """"""

        self.logger.debug("toggle command")

        if not self.state == 'ready':
            return

        if self.streamer is None:
            return

        try:
            if self.streamer.is_playing():
                await self.pause()
            else:
                await self.resume()
        except Exception as e:
            logger.error(e)
            pass
385800
function UndoManager(callback, panels) {

        var undoObj = this;
        var undoStack = []; // A stack of undo states
        var stackPtr = 0; // The index of the current state
        var mode = "none";
        var lastState; // The last state
        var timer; // The setTimeout handle for cancelling the timer
        var inputStateObj;

        // Set the mode for later logic steps.
        var setMode = function (newMode, noSave) {
            if (mode != newMode) {
                mode = newMode;
                if (!noSave) {
                    saveState();
                }
            }

            if (!uaSniffed.isIE || mode != "moving") {
                timer = setTimeout(refreshState, 1);
            }
            else {
                inputStateObj = null;
            }
        };

        var refreshState = function (isInitialState) {
            inputStateObj = new TextareaState(panels, isInitialState);
            timer = undefined;
        };

        this.setCommandMode = function () {
            mode = "command";
            saveState();
            timer = setTimeout(refreshState, 0);
        };

        this.canUndo = function () {
            return stackPtr > 1;
        };

        this.canRedo = function () {
            if (undoStack[stackPtr + 1]) {
                return true;
            }
            return false;
        };

        // Removes the last state and restores it.
        this.undo = function () {

            if (undoObj.canUndo()) {
                if (lastState) {
                    // What about setting state -1 to null or checking for undefined?
                    lastState.restore();
                    lastState = null;
                }
                else {
                    undoStack[stackPtr] = new TextareaState(panels);
                    undoStack[--stackPtr].restore();

                    if (callback) {
                        callback();
                    }
                }
            }

            mode = "none";
            panels.input.focus();
            refreshState();
        };

        // Redo an action.
        this.redo = function () {

            if (undoObj.canRedo()) {

                undoStack[++stackPtr].restore();

                if (callback) {
                    callback();
                }
            }

            mode = "none";
            panels.input.focus();
            refreshState();
        };

        // Push the input area state to the stack.
        var saveState = function () {
            var currState = inputStateObj || new TextareaState(panels);

            if (!currState) {
                return false;
            }
            if (mode == "moving") {
                if (!lastState) {
                    lastState = currState;
                }
                return;
            }
            if (lastState) {
                if (undoStack[stackPtr - 1].text != lastState.text) {
                    undoStack[stackPtr++] = lastState;
                }
                lastState = null;
            }
            undoStack[stackPtr++] = currState;
            undoStack[stackPtr + 1] = null;
            if (callback) {
                callback();
            }
        };

        var handleCtrlYZ = function (event) {

            var handled = false;

            if (event.ctrlKey || event.metaKey) {

                // IE and Opera do not support charCode.
                var keyCode = event.charCode || event.keyCode;
                var keyCodeChar = String.fromCharCode(keyCode);

                switch (keyCodeChar) {

                    case "y":
                        undoObj.redo();
                        handled = true;
                        break;

                    case "z":
                        if (!event.shiftKey) {
                            undoObj.undo();
                        }
                        else {
                            undoObj.redo();
                        }
                        handled = true;
                        break;
                }
            }

            if (handled) {
                if (event.preventDefault) {
                    event.preventDefault();
                }
                if (window.event) {
                    window.event.returnValue = false;
                }
                return;
            }
        };

        // Set the mode depending on what is going on in the input area.
        var handleModeChange = function (event) {

            if (!event.ctrlKey && !event.metaKey) {

                var keyCode = event.keyCode;

                if ((keyCode >= 33 && keyCode <= 40) || (keyCode >= 63232 && keyCode <= 63235)) {
                    // 33 - 40: page up/dn and arrow keys
                    // 63232 - 63235: page up/dn and arrow keys on safari
                    setMode("moving");
                }
                else if (keyCode == 8 || keyCode == 46 || keyCode == 127) {
                    // 8: backspace
                    // 46: delete
                    // 127: delete
                    setMode("deleting");
                }
                else if (keyCode == 13) {
                    // 13: Enter
                    setMode("newlines");
                }
                else if (keyCode == 27) {
                    // 27: escape
                    setMode("escape");
                }
                else if ((keyCode < 16 || keyCode > 20) && keyCode != 91) {
                    // 16-20 are shift, etc. 
                    // 91: left window key
                    // I think this might be a little messed up since there are
                    // a lot of nonprinting keys above 20.
                    setMode("typing");
                }
            }
        };

        var setEventHandlers = function () {
            util.addEvent(panels.input, "keypress", function (event) {
                // keyCode 89: y
                // keyCode 90: z
                if ((event.ctrlKey || event.metaKey) && (event.keyCode == 89 || event.keyCode == 90)) {
                    event.preventDefault();
                }
            });

            var handlePaste = function () {
                if (uaSniffed.isIE || (inputStateObj && inputStateObj.text != panels.input.value)) {
                    if (timer == undefined) {
                        mode = "paste";
                        saveState();
                        refreshState();
                    }
                }
            };

            util.addEvent(panels.input, "keydown", handleCtrlYZ);
            util.addEvent(panels.input, "keydown", handleModeChange);
            util.addEvent(panels.input, "mousedown", function () {
                setMode("moving");
            });

            panels.input.onpaste = handlePaste;
            panels.input.ondrop = handlePaste;
        };

        var init = function () {
            setEventHandlers();
            refreshState(true);
            saveState();
        };

        init();
    }
1121518
def toggle_save
      return if !verify_logged_in

      resp = Caboose::StdClass.new
      if SavedProperty.where(:user_id => logged_in_user.id, :mls => params[:mls]).exists?
        SavedProperty.where(:user_id => logged_in_user.id, :mls => params[:mls]).destroy_all
        resp.saved = false
      else
        p = SavedProperty.new
        p.user_id = logged_in_user.id
        p.mls = params[:mls]
        p.save
        resp.saved = true
      end

      render :json => resp
    end
1019154
function ToggleComponentController($scope, $element, $attrs, $q, $mdComponentRegistry) {
    var self = this;

    // Use Default internal method until overridden by directive postLink

    self.toggleOpen = function () {
      return $q.when($scope.isOpen);
    };

    self.isOpen = function () {
      return !!$scope.isOpen;
    };

    self.open = function () {
      return self.$toggleOpen(true);
    };

    self.close = function () {
      return self.$toggleOpen(false);
    };

    self.toggle = function () {
      return self.$toggleOpen(!$scope.isOpen);
    };

    self.destroy = $mdComponentRegistry.register(self, $attrs.mdComponentId);
  }
119899
def _determine_toggles(payload, toggles):
    '''
    
    '''

    for toggle, definition in six.iteritems(toggles):
        #did the user specify anything?
        if definition['value'] is not None:
            #test for yes_no toggle
            if (definition['value'] is True or definition['value'] == 'yes') and definition['type'] == 'yes_no':
                payload[toggle] = 'yes'
            elif (definition['value'] is False or definition['value'] == 'no') and definition['type'] == 'yes_no':
                payload[toggle] = 'no'

            #test for true_false toggle
            if (definition['value'] is True or definition['value'] == 'yes') and definition['type'] == 'true_false':
                payload[toggle] = True
            elif (definition['value'] is False or definition['value'] == 'no') and definition['type'] == 'true_false':
                payload[toggle] = False

    return payload
149578
function (ele, state) {
            if (typeof state === 'boolean') {
                return state ? this.show() : this.hide();
            }

            if (isHidden(ele)) {
                showHide(ele, true);
            } else {
                showHide(ele);
            }
            return this;
        }
295790
function(attr, options) {
    options = options ? _.clone(options) : {};
    var val = this.get(attr);
    if(!_.isBoolean(val)) console.error('Tried to toggle non-boolean value ' + attr +'!', this);
    return this.set(attr, !val, options);
  }
974596
function aboutSessionRestore_toggleRestoreState(element) {
    var state = this.getRestoreState(element);

    widgets.clickTreeCell(this._controller, this.tabList, element.listIndex, 0, {});
    this._controller.sleep(0);

    this._controller.assertJS("subject.newState != subject.oldState",
                              {newState : this.getRestoreState(element), oldState : state});
  }
1204282
function setState(promise, state) {
  utils.defineProperty(promise, 'state', {
    enumerable: false,
    // According to the spec: If the state is UNFULFILLED (0), the state can be changed;
    // If the state is FULFILLED (1) or FAILED (2), the state cannot be changed, and therefore we
    // lock the property
    configurable: (! state),
    writable: false,
    value: state
  });
}
582566
public static function switcher($toggler='tabs')
	{
		if (isset(self::$loaded[__METHOD__]))
		{
			return;
		}

		self::framework(true);

		Asset::script('assets/switcher.js', false, true);

		App::get('document')->addScriptDeclaration(
			"jQuery(document).ready(function($){
				$('#" . $toggler . "').switcher();
			});"
		);

		self::$loaded[__METHOD__] = true;
	}
1144090
function stateUpdateParamsSurrogate(state, toParams) {
            var oldOnEnter = state.self.onEnter;
            state.self.onEnter = function () {
              _StickyState.stateEntering(state, toParams, oldOnEnter, true);
            };
            restore.addRestoreFunction(function () {
              state.self.onEnter = oldOnEnter;
            });

            return state;
          }
1204532
function toggleTopWindowClass(toggleSwitch) {
        var modalWindow;

        if (openedWindows.length() > 0) {
          modalWindow = openedWindows.top().value;
          modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch);
        }
      }
933847
function Toggle({ children, ...props }) {
  const { getLabelProps, ...fieldCtx } = useFieldContext();
  const { getFocusProps, keyboardFocused } = useKeyboardFocus();

  /**
   * Due to us applying keyboard-only focus events to 2 separate elements (the input and label)
   * we must apply the original `onMouseDown` event to the `onMouseUp` event of the label.
   *
   * By passing the original props within `getFocusProps` we are able to allow
   * `event.preventDefault()` to still prevent chained events as expected.
   */
  const { onMouseDown: onFocusMouseDown, ...keyboardFocusedProps } = getFocusProps(props);

  const modifiedFieldCtx = {
    getLabelProps: ({ onMouseUp, ...other }) =>
      getLabelProps({ onMouseUp: composeEventHandlers(onMouseUp, onFocusMouseDown), ...other }),
    ...fieldCtx
  };

  return (
    <FieldContext.Provider value={modifiedFieldCtx}>
      <ToggleContext.Provider value={{ isFocused: keyboardFocused }}>
        <StyledToggle>
          <StyledToggleInput
            {...modifiedFieldCtx.getInputProps({
              'data-garden-id': 'forms.toggle',
              'data-garden-version': PACKAGE_VERSION,
              ...keyboardFocusedProps
            })}
          />
          {children}
        </StyledToggle>
      </ToggleContext.Provider>
    </FieldContext.Provider>
  );
}
1050925
@Setup(Level.Iteration)
    public void toggleEnabledState() {
        enabled = !enabled;
        manager.setFeatureState(new FeatureState(OverheadFeature.FEATURE, enabled));
    }
215194
function( state ) {
      if ( this.flipped === state ) {
        return this;
      }

      this.flipped = state;
      if(this.viewer.navigator){
        this.viewer.navigator.setFlip(this.getFlip());
      }
      this.viewer.forceRedraw();

      /**
       * Raised when flip state has been changed.
       *
       * @event flip
       * @memberof OpenSeadragon.Viewer
       * @type {object}
       * @property {OpenSeadragon.Viewer} eventSource - A reference to the Viewer which raised the event.
       * @property {Number} flipped - The flip state after this change.
       * @property {?Object} userData - Arbitrary subscriber-defined object.
       */
      this.viewer.raiseEvent('flip', {"flipped": state});
      return this;
    }
30179
function() {
            var self            = this,
                delineator      = self.config.controls.toggleLogic === 'or' ? ', ' : '',
                toggleSelector  = '';

            self.callActions('beforeGetToggleSelector', arguments);

            self.toggleArray = h.clean(self.toggleArray);

            toggleSelector = self.toggleArray.join(delineator);

            if (toggleSelector === '') {
                toggleSelector = self.config.controls.toggleDefault;
            }

            return self.callFilters('selectorGetToggleSelector', toggleSelector, arguments);
        }