Toggle a bdage given its kind
340534
def toggle_badge(self, kind):
        ''''''
        badge = self.get_badge(kind)
        if badge:
            return self.remove_badge(kind)
        else:
            return self.add_badge(kind)
669115
def switch_toggle(self, device):
        """"""
        state = self.get_state(device)
        if(state == '1'):
            return self.switch_off(device)

        elif(state == '0'):
            return self.switch_on(device)
        else:
            return state
344899
def toggle_wrap_mode(self, checked):
        """"""
        self.plain_text.editor.toggle_wrap_mode(checked)
        self.set_option('wrap', checked)
1195951
def toggleWidth(self, width):
        ''
        if self.width != width:
            self.width = width
        else:
            self.width = int(options.default_width)
810301
function setToggleState(ele, state) {
  const btn = "btn";
  const sel = "selected";

  if (ele.classList.contains(btn)) {
    if (state) {
      ele.classList.add(sel);
    } else {
      ele.classList.remove(sel);
    }
  }
}
253779
def toggle(self):
        """"""
        if self._open:
            self._open = False
            self.__checkbutton_var.set(False)
            self.interior.grid_forget()
            self._checkbutton.config(image=self._closed_image)
        else:
            self._open = True
            self.__checkbutton_var.set(True)
            self.interior.grid(row=1, column=0, sticky="nswe")
            self._checkbutton.config(image=self._open_image)
1237544
def OnSpellCheckToggle(self, event):
        """"""

        spelltoolid = self.main_window.main_toolbar.label2id["CheckSpelling"]
        self.main_window.main_toolbar.ToggleTool(spelltoolid,
                                                 not config["check_spelling"])

        config["check_spelling"] = repr(not config["check_spelling"])

        self.main_window.grid.grid_renderer.cell_cache.clear()
        self.main_window.grid.ForceRefresh()
1323034
def switch_showfilter_icon(self, toggled):
        
        at = QtCore.Qt.DownArrow if toggled else QtCore.Qt.RightArrow
        self.showfilter_tb.setArrowType(at)
981148
def toggle_minmax(self, state):
        """"""
        self.sig_option_changed.emit('minmax', state)
        self.model.minmax = state
652998
def toggle_buttons(self):
        """"""
        all_types = self.all_types.get_value()
        self.idx_evt_type.setEnabled(not all_types)
607692
function() {
    var togglers = $('img.toggler').click(function() {
      var src = $(this).attr('src');
      var idnum = $(this).attr('id').substr(7);
      $('tr.cg-' + idnum).toggle();
      if (src.substr(-9) == 'minus.png')
        $(this).attr('src', src.substr(0, src.length-9) + 'plus.png');
      else
        $(this).attr('src', src.substr(0, src.length-8) + 'minus.png');
    }).css('display', '');
    if (DOCUMENTATION_OPTIONS.COLLAPSE_INDEX) {
        togglers.click();
    }
  }
705073
function togglify(win, opts) {
	// extend options for toggle window
	opts = oassign({
		animation: 'hide'
	}, opts);

	win._toggleAction = new ToggleAnimation(win, opts.animation);

	// patch toggle function to window
	win.toggle = function () {
		if (this.isVisible() && this.isFocused()) {
			this._toggleAction.hide();
		} else if (this.isVisible() && !this.isFocused()) {
			this._toggleAction.focus();
		} else if (this.isMinimized() || !this.isVisible()) {
			this._toggleAction.restore();
		}
	};

	// bind event for default action
	win.on('blur', function () {
		if (win.isVisible()) {
			this._toggleAction.blur();
		}
	});

	return win;
}
1013191
def randomToggle(self, randomize):
        """"""
        if randomize:
            self._stim.setReorderFunc(order_function('random'), 'random')
        else:
            self._stim.reorder = None
553996
def toggle_eventtype(self):
        """""" 
        check = self.check_all_eventtype.isChecked()
        
        for btn in self.idx_eventtype_list:
            btn.setChecked(check)
43423
def keyPressEvent(self, event):
        """"""
        ctrl = event.modifiers() & Qt.ControlModifier
        shift = event.modifiers() & Qt.ShiftModifier
        if event.key() in (Qt.Key_Enter, Qt.Key_Return):
            self.find.emit()
        elif event.key() == Qt.Key_F and ctrl and shift:
            # Toggle find widgets
            self.parent().toggle_visibility.emit(not self.isVisible())
        else:
            QWidget.keyPressEvent(self, event)
885472
def on_item_toggled(self, index, state=None):
        """"""
        if not index.data(model.IsIdle):
            return self.info("Cannot toggle")

        if not index.data(model.IsOptional):
            return self.info("This item is mandatory")

        if state is None:
            state = not index.data(model.IsChecked)

        index.model().setData(index, state, model.IsChecked)

        # Withdraw option to publish if no instances are toggled
        play = self.findChild(QtWidgets.QWidget, "Play")
        validate = self.findChild(QtWidgets.QWidget, "Validate")
        any_instances = any(index.data(model.IsChecked)
                            for index in self.data["models"]["instances"])
        play.setEnabled(any_instances)
        validate.setEnabled(any_instances)

        # Emit signals
        if index.data(model.Type) == "instance":
            instance = self.data["models"]["instances"].items[index.row()]
            util.defer(
                100, lambda: self.controller.emit_(
                    signal="instanceToggled",
                    kwargs={"new_value": state,
                            "old_value": not state,
                            "instance": instance}))

        if index.data(model.Type) == "plugin":
            util.defer(
                100, lambda: self.controller.emit_(
                    signal="pluginToggled",
                    kwargs={"new_value": state,
                            "old_value": not state,
                            "plugin": index.data(model.Object)}))
616848
function toggle(element, animation, callbackFn) {
    var nowVisible = element.style.display != 'none' || element.offsetLeft > 0;

    // create clone for reference
    var clone = element.cloneNode(true);
    var cleanup = function() {
        element.removeAttribute('data-animated');
        element.setAttribute('style', clone.getAttribute('style'));
        element.style.display = nowVisible ? 'none' : '';
		if( callbackFn ) { callbackFn(); }
    };

    // store attribute so everyone knows we're animating this element
    element.setAttribute('data-animated', "true");

    // toggle element visiblity right away if we're making something visible
    if( ! nowVisible ) {
        element.style.display = '';
    }

    var hiddenStyles, visibleStyles;

    // animate properties
    if( animation === 'slide' ) {
        hiddenStyles = initObjectProperties(["height", "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"], 0);
        visibleStyles = {};

        if( ! nowVisible ) {
            var computedStyles = window.getComputedStyle(element);
            visibleStyles = copyObjectProperties(["height", "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"], computedStyles);

            // in some browsers, getComputedStyle returns "auto" value. this falls back to getBoundingClientRect() in those browsers since we need an actual height.
            if(!isFinite(visibleStyles.height)) {
              var clientRect = element.getBoundingClientRect();
              visibleStyles.height = clientRect.height;
            }
            css(element, hiddenStyles);
        }

        // don't show a scrollbar during animation
        element.style.overflowY = 'hidden';
        animate(element, nowVisible ? hiddenStyles : visibleStyles, cleanup);
    } else {
        hiddenStyles = { opacity: 0 };
        visibleStyles = { opacity: 1 };
        if( ! nowVisible ) {
            css(element, hiddenStyles);
        }

        animate(element, nowVisible ? hiddenStyles : visibleStyles, cleanup);
    }
}