Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: grevory/angular-local-storage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.2.7
Choose a base ref
...
head repository: grevory/angular-local-storage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.5.0
Choose a head ref

Commits on Mar 16, 2016

  1. Sync up NPM with Git repo

    grevory committed Mar 16, 2016
    Copy the full SHA
    36b5dc0 View commit details

Commits on Mar 30, 2016

  1. Update number of ways

    jlast committed Mar 30, 2016
    Copy the full SHA
    38b159d View commit details
  2. Merge pull request #302 from jlast/patch-1

    Update number of ways
    grevory committed Mar 30, 2016
    Copy the full SHA
    2c85ff2 View commit details

Commits on Apr 4, 2016

  1. Update README.md

    Updated docs to indicate that cookie expiration = 0 => session cookie and not non-expiring cookie.
    robinj committed Apr 4, 2016
    Copy the full SHA
    2db6972 View commit details
  2. Merge pull request #306 from robinj/patch-1

    Update README.md for setStorageCookie
    grevory committed Apr 4, 2016
    Copy the full SHA
    c18dc4f View commit details

Commits on Apr 29, 2016

  1. Wrapped the code in a closure

    Wrapped the code in a closure to avoid cluttering the global variable space.
    Snede committed Apr 29, 2016
    Copy the full SHA
    f47a703 View commit details
  2. Added broadcast for localstorage changed

    Added broadcast for localstorage changed, so changes from other windows/tabs can be detected an applied.
    Snede committed Apr 29, 2016
    Copy the full SHA
    6f5798a View commit details
  3. Added $timeout

    Snede committed Apr 29, 2016
    Copy the full SHA
    7bbc4e5 View commit details
  4. Copy the full SHA
    531341f View commit details
  5. Added comment

    Snede committed Apr 29, 2016
    Copy the full SHA
    fce07dc View commit details
  6. Fixed issue with undefined key in callback

    Fixed issue with calling isKeyPrefixOurs before key was defined.
    Snede committed Apr 29, 2016
    Copy the full SHA
    f2515cd View commit details
  7. Copy the full SHA
    e4e83bc View commit details

Commits on May 2, 2016

  1. Copy the full SHA
    729794a View commit details
  2. Added tests for enabling defaultToCookie and tested wether you could …

    …disable the configuration
    Snede committed May 2, 2016
    Copy the full SHA
    67d8075 View commit details
  3. Removed closure.

    Snede committed May 2, 2016
    Copy the full SHA
    77a3f5f View commit details
  4. Added tests to confirm defaultToCookie functionality. And added tests…

    … for localStorageChanged event
    Snede committed May 2, 2016
    Copy the full SHA
    61ccc05 View commit details
  5. Copy the full SHA
    dacab66 View commit details
  6. Added underivedkey test

    Snede committed May 2, 2016
    Copy the full SHA
    0b28d48 View commit details
  7. Copy the full SHA
    517cc4d View commit details
  8. 1.2.7

    Snede committed May 2, 2016
    Copy the full SHA
    3066957 View commit details
  9. 0.2.8

    Snede committed May 2, 2016
    Copy the full SHA
    cd35cf1 View commit details
  10. Deployment script

    Snede committed May 2, 2016
    Copy the full SHA
    dfd67aa View commit details

Commits on May 6, 2016

  1. Copy the full SHA
    8041d62 View commit details

Commits on May 15, 2016

  1. Update README.md

    Clarify documentation about setNotify
    dirkpostma committed May 15, 2016
    Copy the full SHA
    9fe433a View commit details

Commits on May 18, 2016

  1. Merge pull request #313 from Snede/master

    Added features, "Changed" broadcast, disabling defaultToCookies, added closure
    grevory committed May 18, 2016
    Copy the full SHA
    09b27d6 View commit details
  2. Merge pull request #314 from jkjustjoshing/patch-1

    Point to correct file for webpack require.
    grevory committed May 18, 2016
    Copy the full SHA
    d0c6f1b View commit details
  3. Merge pull request #317 from dirkpostma/patch-1

    Update README.md
    grevory committed May 18, 2016
    Copy the full SHA
    14ba833 View commit details

Commits on Jul 13, 2016

  1. Add files via upload

    zpgu authored Jul 13, 2016
    Copy the full SHA
    0acda9f View commit details
  2. Merge pull request #1 from zpgu/zpgu-patch-1

     switch/select type dynamically
    zpgu authored Jul 13, 2016
    Copy the full SHA
    662dd06 View commit details
  3. switch/select type dynamically

    1) added setStorageType(type)
    2) added type to relevant calls except removeFromLocalStorage(...), as it's a vararg variety, but easy to do if needed.
    
    This is a non-intrusive patch, as it preserves original functionality with minimal changes, but adds storage type selectability when needed.
    
    Typical use case:
    your existing code picked one type as default, but in a couple of places you need to use the other type, then try this:
    
    setStorageType(non-default-type); // switch to new type
    ...do your storage calls
    setStorageType(default-type); // restore default
    
    Or you can specify a type to each call directly (without type specified, will use whatever the last type active).
    zpgu authored Jul 13, 2016
    Copy the full SHA
    8a1528d View commit details

Commits on Jul 14, 2016

  1. removeFromLocalStorage() to take type param

    removeFromLocalStorage() supports selecting storage type as the last parameter.
    
    not as optimized as I'd like for the patches, but they're non-invasive, and easy to reason for correctness.
    This completes the type selection patch (TODO: need to add tests).
    zpgu authored Jul 14, 2016
    Copy the full SHA
    575716b View commit details
  2. Merge pull request #2 from zpgu/zpgu-patch-2

    removeFromLocalStorage() to take type param
    zpgu authored Jul 14, 2016
    Copy the full SHA
    a4d41a9 View commit details
  3. try git commit

    zpg committed Jul 14, 2016
    Copy the full SHA
    1767e6a View commit details
  4. switch type only when different

    zpg committed Jul 14, 2016
    Copy the full SHA
    fad1093 View commit details
  5. minor refactoring

    zpg committed Jul 14, 2016
    Copy the full SHA
    52972f2 View commit details
  6. minor refactoring

    zpg committed Jul 14, 2016
    Copy the full SHA
    106eb41 View commit details

Commits on Jul 29, 2016

  1. Merge pull request #320 from zpgu/master

     switch/select type dynamically
    grevory authored Jul 29, 2016
    Copy the full SHA
    482c6c1 View commit details
  2. 0.3.0

    grevory committed Jul 29, 2016
    Copy the full SHA
    1437b63 View commit details
  3. Updated release to 0.3.0

    grevory committed Jul 29, 2016
    Copy the full SHA
    459456e View commit details
  4. Copy the full SHA
    d1a77a5 View commit details

Commits on Aug 10, 2016

  1. Add 'secure' argument to setStorageCookie method

    Add a 3rd argument named 'secure' to the setStorageCookie method to allow users to opt-in to only use the cookie on a secure origin.
    ry8806 authored and jonkoops committed Aug 10, 2016
    Copy the full SHA
    6deab95 View commit details

Commits on Aug 18, 2016

  1. Merge pull request #283 from ry8806/master

    added function parameter for secure cookies, added test, added api ex…
    grevory authored Aug 18, 2016
    Copy the full SHA
    1a9ff2a View commit details
  2. 0.4.0

    grevory committed Aug 18, 2016
    Copy the full SHA
    ad8841b View commit details
  3. Deploying secure cookies

    grevory committed Aug 18, 2016
    Copy the full SHA
    5f5846f View commit details

Commits on Aug 26, 2016

  1. Copy the full SHA
    44e52a9 View commit details
  2. Merge pull request #324 from loftyduck/master

    prevent memory leak by removing listeners on the window
    grevory authored Aug 26, 2016
    Copy the full SHA
    4640501 View commit details

Commits on Aug 29, 2016

  1. 0.5.0

    grevory committed Aug 29, 2016
    Copy the full SHA
    a2baadb View commit details
Showing with 1,009 additions and 654 deletions.
  1. +35 −16 README.md
  2. +126 −26 dist/angular-local-storage.js
  3. +2 −2 dist/angular-local-storage.min.js
  4. +1 −1 dist/angular-local-storage.min.js.map
  5. +1 −1 index.js
  6. +1 −1 package.json
  7. +125 −25 src/angular-local-storage.js
  8. +1 −0 test/.jshintrc
  9. +717 −582 test/spec/localStorageSpec.js
51 changes: 35 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ An Angular module that gives you access to the browsers local storage
- [Configuration](#configuration)
- [setPrefix](#setprefix)
- [setStorageType](#setstoragetype)
- [setDefaultToCookie](#setdefaulttocookie)
- [setStorageCookie](#setstoragecookie)
- [setStorageCookieDomain](#setstoragecookiedomain)
- [setNotify](#setnotify)
@@ -40,7 +41,7 @@ An Angular module that gives you access to the browsers local storage
- [clearAll](#cookieclearall)

##Get Started
**(1)** You can install angular-local-storage using 2 different ways:<br/>
**(1)** You can install angular-local-storage using 3 different ways:<br/>
**Git:**
clone & build [this](https://github.com/grevory/angular-local-storage.git) repository<br/>
**Bower:**
@@ -95,14 +96,24 @@ myApp.config(function (localStorageServiceProvider) {
.setStorageType('sessionStorage');
});
```
###setDefaultToCookie
If localStorage is not supported, the library will default to cookies instead. This behavior can be disabled.<br/>
**Default:** `true`
```js
myApp.config(function (localStorageServiceProvider) {
localStorageServiceProvider
.setDefaultToCookie(false);
});
```
###setStorageCookie
Set cookie options (usually in case of fallback)<br/>
**expiry:** number of days before cookies expire (0 = does not expire). **default:** `30`<br/>
**path:** the web path the cookie represents. **default:** `'/'`
**expiry:** number of days before cookies expire (0 = session cookie). **default:** `30`<br/>
**path:** the web path the cookie represents. **default:** `'/'`<br/>
**secure:** whether to store cookies as secure. **default:** `false`
```js
myApp.config(function (localStorageServiceProvider) {
localStorageServiceProvider
.setStorageCookie(45, '<path>');
.setStorageCookie(45, '<path>', false);
});
```
###setStorageCookieDomain
@@ -118,9 +129,10 @@ myApp.config(function (localStorageServiceProvider) {
For local testing (when you are testing on localhost) set the domain to an empty string ''. Setting the domain to 'localhost' will not work on all browsers (eg. Chrome) since some browsers only allow you to set domain cookies for registry controlled domains, i.e. something ending in .com or so, but not IPs **or intranet hostnames** like localhost. </br>

###setNotify
Send signals for each of the following actions:<br/>
**setItem** , default: `true`<br/>
**removeItem** , default: `false`

Configure whether events should be broadcasted on $rootScope for each of the following actions:<br/>
**setItem** , default: `true`, event "LocalStorageModule.notification.setitem"<br/>
**removeItem** , default: `false`, event "LocalStorageModule.notification.removeitem"
```js
myApp.config(function (localStorageServiceProvider) {
localStorageServiceProvider
@@ -139,7 +151,7 @@ myApp.config(function (localStorageServiceProvider) {
```
##API Documentation
##isSupported
Checks if the browser support the current storage type(e.g: `localStorage`, `sessionStorage`).
Checks if the browser support the current storage type(e.g: `localStorage`, `sessionStorage`).
**Returns:** `Boolean`
```js
myApp.controller('MainCtrl', function($scope, localStorageService) {
@@ -159,6 +171,7 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
//...
});
```
You can also dynamically change storage type by passing the storage type as the last parameter for any of the API calls. For example: `localStorageService.set(key, val, "sessionStorage");`
###set
Directly adds a value to local storage.<br/>
If local storage is not supported, use cookies instead.<br/>
@@ -229,9 +242,9 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
});
```
###bind
Bind $scope key to localStorageService.
**Usage:** `localStorageService.bind(scope, property, value[optional], key[optional])`
***key:*** The corresponding key used in local storage
Bind $scope key to localStorageService.
**Usage:** `localStorageService.bind(scope, property, value[optional], key[optional])`
***key:*** The corresponding key used in local storage
**Returns:** deregistration function for this listener.
```js
myApp.controller('MainCtrl', function($scope, localStorageService) {
@@ -259,7 +272,7 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
```

###deriveKey
Return the derive key
Return the derive key
**Returns** `String`
```js
myApp.controller('MainCtrl', function($scope, localStorageService) {
@@ -271,7 +284,7 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
});
```
###length
Return localStorageService.length, ignore keys that not owned.
Return localStorageService.length, ignore keys that not owned.
**Returns** `Number`
```js
myApp.controller('MainCtrl', function($scope, localStorageService) {
@@ -283,7 +296,7 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
##Cookie
Deal with browser's cookies directly.
##cookie.isSupported
Checks if cookies are enabled in the browser.
Checks if cookies are enabled in the browser.
**Returns:** `Boolean`
```js
myApp.controller('MainCtrl', function($scope, localStorageService) {
@@ -312,6 +325,11 @@ myApp.controller('MainCtrl', function($scope, localStorageService) {
localStorageService.cookie.set(key,val,10)
```
sets a cookie that expires in 10 days.
**Secure Cookie** Pass a fourth argument to set the cookie as secure [W3C](https://www.w3.org/TR/csp-cookies/#grammardef-secure)
```js
localStorageService.cookie.set(key,val,null,false)
```
sets a cookie that is secure.
###cookie.get
Directly get a value from a cookie.<br/>
**Returns:** `value from local storage`
@@ -352,7 +370,7 @@ Check out the full demo at http://gregpike.net/demos/angular-local-storage/demo.

##Development:
* Don't forget about tests.
* If you planning add some feature please create issue before.
* If you're planning to add some feature please create an issue before.

Clone the project:
```sh
@@ -367,8 +385,9 @@ $ grunt test
**Deploy:**<br/>
Run the build task, update version before(bower,package)
```sh
$ npm version patch|minor|major
$ grunt dist
$ git tag 0.*.*
$ git commit [message]
$ git push origin master --tags
```

Loading