Save the states that are still valid and needed in order to support page refresh and external navigation.
Called on window unload.
@private
510728
function () {
                this._removeOldStates();
                ariaUtilsEvent.removeListener(window, "unload", this._saveStateCB);
                this._storage.setItem(this._STORAGE_KEY, stateMemory);
                this._storage.$dispose();
                this._storage = null;
            }
523051
function updateNavButtonsState() {
            // Item navigation
            if (itemNav) {
                var isFirst = rel.activeItem === 0,
                    isLast  = rel.activeItem >= items.length - 1,
                    itemsButtonState = isFirst ? 'first' : isLast ? 'last' : 'middle';

                if (last.itemsButtonState !== itemsButtonState) {
                    last.itemsButtonState = itemsButtonState;

                    if ($prevButton.is('button,input')) {
                        $prevButton.prop('disabled', isFirst);
                    }

                    if ($nextButton.is('button,input')) {
                        $nextButton.prop('disabled', isLast);
                    }

                    $prevButton[isFirst ? 'removeClass' : 'addClass'](o.disabledClass);
                    $nextButton[isLast ? 'removeClass' : 'addClass'](o.disabledClass);
                }
            }

            // Page navigation
            if ($pages[0]) {
                var isStart = pos.dest <= pos.start,
                    isEnd = pos.dest >= pos.end,
                    pagesButtonState = isStart ? 'first' : isEnd ? 'last' : 'middle';

                // Update paging buttons only if there has been a change in their state
                if (last.pagesButtonState !== pagesButtonState) {
                    last.pagesButtonState = pagesButtonState;

                    if ($prevPageButton.is('button,input')) {
                        $prevPageButton.prop('disabled', isStart);
                    }

                    if ($nextPageButton.is('button,input')) {
                        $nextPageButton.prop('disabled', isEnd);
                    }

                    $prevPageButton[isStart ? 'removeClass' : 'addClass'](o.disabledClass);
                    $nextPageButton[isEnd ? 'removeClass' : 'addClass'](o.disabledClass);
                }
            }
        }
240679
function () {
        if (this.state == 'zombie') {
            this.expireController();  // Toss anything that might have happened

            RemoteObjectTemplate.enableSendMessage(true, this.sendMessage); // Re-enable sending

            this.state = 'live';
            this.rootId = null;  // Cancel forcing our controller on server
            this.refreshSession();

            console.log('Getting live again - fetching state from server');
        }

        this.setCookie('session' + this.app, this.session, 0);
    }
1079684
function saveState( $pageEnd = 0 )
    {
        if ( $pageEnd )
        {
            // this will be called at a new page to return the state to what it was on the
            // end of the previous page, before the stack was closed down
            // This is to get around not being able to have open 'q' across pages
            $opt = $this->stateStack[$pageEnd]; // ok to use this as stack starts numbering at 1
            $this->setColor($opt['col'],1);
            $this->setStrokeColor($opt['str'],1);
            $this->objects[$this->currentContents]['c'].="\n".$opt['lin'];
            //$this->currentLineStyle = $opt['lin'];
        }
        else
        {
            $this->nStateStack++;
            $this->stateStack[$this->nStateStack]=array( 'col' => $this->currentColour,
                                                         'str' => $this->currentStrokeColour,
                                                         'lin' => $this->currentLineStyle );
        }
        $this->objects[$this->currentContents]['c'] .= "\nq";
    }
252469
def save_state(self):
        
        settings = QtCore.QSettings()
        settings.setValue(
            'inasafe/useDefaultTemplates',
            self.default_template_radio.isChecked())
        settings.setValue(
            'inasafe/lastTemplate',
            self.template_combo.itemData(self.template_combo.currentIndex()))
        settings.setValue(
            'inasafe/lastCustomTemplate', self.template_path.text())
44073
void save() {

        saveAndDeleteEntities(false, new I_CmsSimpleCallback<Boolean>() {

            public void execute(Boolean hasChangedSettings) {

                setSaved();
                setUnchanged();
                m_hasChangedSettings = m_hasChangedSettings || hasChangedSettings.booleanValue();
            }
        });
    }
493781
def save(self, page, language, data, change, extra_data=None):
        """"""
        # if this placeholder is untranslated, we save everything
        # in the default language
        if self.untranslated:
            language = settings.PAGE_DEFAULT_LANGUAGE

        # the page is being changed
        if change:
            # we need create a new content if revision is enabled
            if(settings.PAGE_CONTENT_REVISION and self.name
                not in settings.PAGE_CONTENT_REVISION_EXCLUDE_LIST):
                Content.objects.create_content_if_changed(
                    page,
                    language,
                    self.name,
                    data
                )
            else:
                Content.objects.set_or_create_content(
                    page,
                    language,
                    self.name,
                    data
                )
        # the page is being added
        else:
            Content.objects.set_or_create_content(
                page,
                language,
                self.name,
                data
            )
831356
function () {
                stateMemory.discarded = [];
                if (this._isIE7OrLess) {
                    stateMemory.states = [stateMemory.states[this._currentPos]];
                    return;
                }
                var states = stateMemory.states;
                var expirationTime = ((new Date()).getTime() - this.EXPIRATION_TIME * 1000) + "";
                for (var i = 0; i < states.length; i++) {
                    if (states[i].id > expirationTime) {
                        break;
                    }
                }
                states.splice(0, i);
            }
69049
def _set_save_states(self):
        """"""

        wx.BeginBusyCursor()
        self.saving = True
        self.grid.Disable()
1202760
def save_state(internal_request, state):
        
        state_data = {"hash_type": internal_request.user_id_hash_type}
        state[UserIdHasher.STATE_KEY] = state_data
612784
function() {
      Backbone.$(window).off('popstate', this.checkUrl).off('hashchange', this.checkUrl);
      if (this._checkUrlInterval) clearInterval(this._checkUrlInterval);
      History.started = false;
    }
956950
function() {

			var self = this;

			self.__refreshActive = false;
			if (self.__refreshDeactivate) {
				self.__refreshDeactivate();
			}

			self.scrollTo(self.__scrollLeft, self.__scrollTop, true);

		}
13173
def _save_state(self):
        
        ns_prefixes_floating_in = copy.copy(self._ns_prefixes_floating_in)
        ns_prefixes_floating_out = copy.copy(self._ns_prefixes_floating_out)
        ns_decls_floating_in = copy.copy(self._ns_decls_floating_in)
        curr_ns_map = copy.copy(self._curr_ns_map)
        ns_map_stack = copy.copy(self._ns_map_stack)
        pending_start_element = self._pending_start_element
        ns_counter = self._ns_counter
        # XXX: I have been unable to find a test justifying copying this :/
        # for completeness, I’m still doing it
        ns_auto_prefixes_floating_in = \
            copy.copy(self._ns_auto_prefixes_floating_in)
        try:
            yield
        except:  # NOQA: E722
            self._ns_prefixes_floating_in = ns_prefixes_floating_in
            self._ns_prefixes_floating_out = ns_prefixes_floating_out
            self._ns_decls_floating_in = ns_decls_floating_in
            self._pending_start_element = pending_start_element
            self._curr_ns_map = curr_ns_map
            self._ns_map_stack = ns_map_stack
            self._ns_counter = ns_counter
            self._ns_auto_prefixes_floating_in = ns_auto_prefixes_floating_in
            raise
519134
function clear() {
        var that = this;
        var state = getInternalState(that);
        var data = state.index;
        var entry = state.first;
        while (entry) {
          entry.removed = true;
          if (entry.previous) entry.previous = entry.previous.next = undefined;
          delete data[entry.index];
          entry = entry.next;
        }
        state.first = state.last = undefined;
        if (DESCRIPTORS) state.size = 0;
        else that.size = 0;
      }
865766
private void resetValidationState() {
		// if User Model exists it will be returned, othewise Shared Model is returned
		final FileWidgetModel componentModel = getComponentModel();
		// If Shared Model is returned then both fileType and fileSize are always valid
		// If User Model is returned check if any if any is false
		if (!componentModel.validFileSize || !componentModel.validFileType) {
		    final FileWidgetModel userModel = getOrCreateComponentModel();
		    userModel.validFileType = true;
		    userModel.validFileSize = true;

		}
	}
472236
function save() {
      var value, data = '';

      // localStorage can be disabled on WebKit/Gecko so make a dummy storage
      if (!hasOldIEDataSupport) {
        return;
      }

      for (var key in items) {
        value = items[key];
        data += (data ? ',' : '') + key.length.toString(32) + ',' + key + ',' + value.length.toString(32) + ',' + value;
      }

      storageElm.setAttribute(userDataKey, data);

      try {
        storageElm.save(userDataKey);
      } catch (ex) {
        // Ignore disk full
      }

      updateKeys();
    }
713581
def save_state(state, output_dir, keep=False):
  """"""
  params_file = os.path.join(output_dir, "model.pkl")
  with gfile.GFile(params_file, "wb") as f:
    pickle.dump((state.params, state.step, state.history), f)
  if keep:
    params_file = os.path.join(output_dir, "model_{}.pkl".format(state.step))
    with gfile.GFile(params_file, "wb") as f:
      pickle.dump((state.params, state.step, state.history), f)
  log("Model saved to %s" % params_file, stdout=False)