Merge branch 'master' into devel

master
Gina Häußge 2013-06-09 18:18:57 +02:00
commit edff311351
1 changed files with 26 additions and 21 deletions

View File

@ -1753,43 +1753,48 @@ function ItemListHelper(listType, supportedSorting, supportedFilters, defaultSor
//~~ local storage //~~ local storage
self._saveCurrentSortingToLocalStorage = function() { self._saveCurrentSortingToLocalStorage = function() {
self._initializeLocalStorage(); if ( self._initializeLocalStorage() ) {
var currentSorting = self.currentSorting();
var currentSorting = self.currentSorting(); if (currentSorting !== undefined)
if (currentSorting !== undefined) localStorage[self.listType + "." + "currentSorting"] = currentSorting;
localStorage[self.listType + "." + "currentSorting"] = currentSorting; else
else localStorage[self.listType + "." + "currentSorting"] = undefined;
localStorage[self.listType + "." + "currentSorting"] = undefined; }
} }
self._loadCurrentSortingFromLocalStorage = function() { self._loadCurrentSortingFromLocalStorage = function() {
self._initializeLocalStorage(); if ( self._initializeLocalStorage() ) {
if (_.contains(_.keys(supportedSorting), localStorage[self.listType + "." + "currentSorting"]))
if (_.contains(_.keys(supportedSorting), localStorage[self.listType + "." + "currentSorting"])) self.currentSorting(localStorage[self.listType + "." + "currentSorting"]);
self.currentSorting(localStorage[self.listType + "." + "currentSorting"]); else
else self.currentSorting(defaultSorting);
self.currentSorting(defaultSorting); }
} }
self._saveCurrentFiltersToLocalStorage = function() { self._saveCurrentFiltersToLocalStorage = function() {
self._initializeLocalStorage(); if ( self._initializeLocalStorage() ) {
var filters = _.intersection(_.keys(self.supportedFilters), self.currentFilters());
var filters = _.intersection(_.keys(self.supportedFilters), self.currentFilters()); localStorage[self.listType + "." + "currentFilters"] = JSON.stringify(filters);
localStorage[self.listType + "." + "currentFilters"] = JSON.stringify(filters); }
} }
self._loadCurrentFiltersFromLocalStorage = function() { self._loadCurrentFiltersFromLocalStorage = function() {
self._initializeLocalStorage(); if ( self._initializeLocalStorage() ) {
self.currentFilters(_.intersection(_.keys(self.supportedFilters), JSON.parse(localStorage[self.listType + "." + "currentFilters"])));
self.currentFilters(_.intersection(_.keys(self.supportedFilters), JSON.parse(localStorage[self.listType + "." + "currentFilters"]))); }
} }
self._initializeLocalStorage = function() { self._initializeLocalStorage = function() {
if (!Modernizr.localstorage)
return false;
if (localStorage[self.listType + "." + "currentSorting"] !== undefined && localStorage[self.listType + "." + "currentFilters"] !== undefined && JSON.parse(localStorage[self.listType + "." + "currentFilters"]) instanceof Array) if (localStorage[self.listType + "." + "currentSorting"] !== undefined && localStorage[self.listType + "." + "currentFilters"] !== undefined && JSON.parse(localStorage[self.listType + "." + "currentFilters"]) instanceof Array)
return; return true;
localStorage[self.listType + "." + "currentSorting"] = self.defaultSorting; localStorage[self.listType + "." + "currentSorting"] = self.defaultSorting;
localStorage[self.listType + "." + "currentFilters"] = JSON.stringify(self.defaultFilters); localStorage[self.listType + "." + "currentFilters"] = JSON.stringify(self.defaultFilters);
return true;
} }
self._loadCurrentFiltersFromLocalStorage(); self._loadCurrentFiltersFromLocalStorage();