Started fixing spacing

dev
Gregory Pike 11 years ago
parent f8ea0a90cd
commit 3dee44cac3

@ -1,60 +1,50 @@
(function() { (function() {
/* Start angularLocalStorage */ /* Start angularLocalStorage */
'use strict'; 'use strict';
var angularLocalStorage = angular.module('LocalStorageModule', []); var angularLocalStorage = angular.module('LocalStorageModule', []);
angularLocalStorage.provider('localStorageService', function(){ angularLocalStorage.provider('localStorageService', function(){
// You should set a prefix to avoid overwriting any local storage variables from the rest of your app // You should set a prefix to avoid overwriting any local storage variables from the rest of your app
// e.g. angularLocalStorage.constant('prefix', 'youAppName'); // e.g. angularLocalStorage.constant('prefix', 'youAppName');
this.prefix = 'ls'; this.prefix = 'ls';
// Cookie options (usually in case of fallback) // Cookie options (usually in case of fallback)
// expiry = Number of days before cookies expire // 0 = Does not expire // expiry = Number of days before cookies expire // 0 = Does not expire
// path = The web path the cookie represents // path = The web path the cookie represents
this.cookie = { this.cookie = {
expiry: 30, expiry: 30,
path: '/' path: '/'
}; };
this.notify = { this.notify = {
setItem: true, setItem: true,
removeItem: false removeItem: false
}; };
this.setPrefix = function(prefix){ this.setPrefix = function(prefix){
this.prefix = prefix; this.prefix = prefix;
}; };
this.setStorageCookie = function(exp, path){ this.setStorageCookie = function(exp, path){
this.cookie = { this.cookie = {
expiry: exp, expiry: exp,
path: path path: path
}; };
}; };
this.setNotify = function(itemSet, itemRemove){ this.setNotify = function(itemSet, itemRemove){
this.notify = { this.notify = {
setItem: itemSet, setItem: itemSet,
removeItem: itemRemove removeItem: itemRemove
}; };
}; };
this.$get = ['$rootScope',function($rootScope){ this.$get = ['$rootScope',function($rootScope){
var prefix = this.prefix;
// If there is a prefix set in the config lets use that with an appended period for readability
//var prefix = angularLocalStorage.constant;
if (prefix.substr(-1)!=='.') {
prefix = !!prefix ? prefix + '.' : '';
}
// Checks the browser to see if local storage is supported
var browserSupportsLocalStorage = function () {
try {
return ('localStorage' in window && window.localStorage !== null);
} catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return false;
}
};
// Checks the browser to see if local storage is supported var prefix = this.prefix;
var browserSupportsLocalStorage = function () { // If there is a prefix set in the config lets use that with an appended period for readability
try { if (prefix.substr(-1)!=='.') {
prefix = !!prefix ? prefix + '.' : '';
}
// Checks the browser to see if local storage is supported
var browserSupportsLocalStorage = function () {
try {
var supported = ('localStorage' in window && window['localStorage'] !== null); var supported = ('localStorage' in window && window['localStorage'] !== null);
// When Safari (OS X or iOS) is in private browsing mode, it appears as though localStorage // When Safari (OS X or iOS) is in private browsing mode, it appears as though localStorage
@ -64,16 +54,16 @@
// that exceeded the quota." // that exceeded the quota."
var key = prefix + '__' + Math.round(Math.random() * 1e7); var key = prefix + '__' + Math.round(Math.random() * 1e7);
if (supported) { if (supported) {
localStorage.setItem(key, ''); localStorage.setItem(key, '');
localStorage.removeItem(key); localStorage.removeItem(key);
} }
return true; return true;
} catch (e) { } catch (e) {
$rootScope.$broadcast('LocalStorageModule.notification.error',e.message); $rootScope.$broadcast('LocalStorageModule.notification.error',e.message);
return false; return false;
} }
}; };
// If this browser does not support local storage use cookies // If this browser does not support local storage use cookies
if (!browserSupportsLocalStorage()) { if (!browserSupportsLocalStorage()) {