Skip to content

Commit

Permalink
r1.2.3 - packaged for bower and npm
Browse files Browse the repository at this point in the history
  • Loading branch information
Wayne Weibel committed Feb 25, 2016
1 parent 5bde094 commit 164333d
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
bower_components
jquery.ezstorage.min.js
16 changes: 10 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ jQuery EZStorage is a plugin that simplifies access to HTML5 storages & cookies.

CHANGELOG
-------------------------
###1.2.2
###1.2.3
packaged for bower and npm
removed auto-inclusion of jquery.cookie and JSON libraries

###1.2.2
damn typos and some more commenting

###1.2.1
###1.2.1
numeric options.expires value now being set correctly when decimal
values passed, eg. .25 or 20.662; also clarified some commenting

###1.2.0
###1.2.0
added settings property to global object, and options parameter to functions; automatic Date parsing for expiration values.

###1.1.0
###1.1.0
added shorthand version of functions

###1.0.0
Initial version
###1.0.0
Initial version
27 changes: 27 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n'
},
build: {
src: 'jquery.ezstorage.js',
dest: 'jquery.ezstorage.min.js'
}
},
clean: {
uglify: [
'jquery.ezstorage.min.js'
]
}
});

// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean')

// Default task(s).
grunt.registerTask('default', ['uglify']);
};
6 changes: 3 additions & 3 deletions LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Simple HTML5 Storage wrapper to save data on the browser side
Defaults to cookies (if enabled) if HTML Storage is not supported.

Version: 1.2.2
Version: 1.2.3

Licensed under MIT-style license:<br>
[http://www.opensource.org/licenses/mit-license.php][1]
[1]: http://www.opensource.org/licenses/mit-license.php

<br>

Copyright (c) 2013 Wayne Weibel
Copyright (c) 2013-2016 Wayne Weibel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -26,4 +26,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Functionalities:

- Store data easily, encode/decode it with JSON automatically.
- Automatcially handles conversion of Number and String to Date for expiration values.
- Attempts to dynamically load [jquery.cookie][1] and [JSON][2] libraries if necessary. These should be included directly to avoid complications with browsers and data transfer.
- [jquery.cookie][1] and [JSON][2] should be included directly to avoid complications with browsers and data transfer.
[1]: https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js
[2]: http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js

Expand All @@ -17,16 +17,16 @@ Usage
-------------------------

$.ezstorage(action, key, value, options)

overloaded function to manage 'storage'

- checks if local/session Storage is implemented in the browser
- checks if cookies are enabled
- get/set key:value pairs (in Storage or as a cookie)
- removes key:value pairs (in Storage or as a cookie)

@param String __action__

- the action to perform:
- 'enabled' = verify that a storage option is possible
- 'get' = get a value from storage; returns null, Scalar, Object
Expand All @@ -52,15 +52,15 @@ Usage
- persist: Boolean; whether to place value in localStorage despite expires being set
- path: String; only used if cookie,
- full: Boolean; whether to return the full object stored by ezstorage or just value

@return Mixed

- 'enabled' = Boolean
- 'get' = null or stored value; will be Object if Scalar set with an expires
- 'set' = stored value;
- 'set' = stored value;
- 'remove' = always True, if not a javascript error occured.
<br />

<br />
Shorthand Functions
-------------------------
### `enabled()`
Expand All @@ -75,7 +75,7 @@ Get an item from a storage. Searches localStorage, sessionStorage, and cookies.
$.ezstorage.get('foo', {full:true}); // return {ezstorage:true …} not just 'value'

### `set(key, value, options = {})`
Set an item in a storage. If options.expire or options.persist are set value is stored in localStorage, else sessionStorage/cookie.
Set an item in a storage. If options.expire or options.persist are set value is stored in localStorage, else sessionStorage/cookie.
- __value__ is stored as an object: `{ezstorage:true, <options>, value:<value>}`


Expand All @@ -87,14 +87,14 @@ Set an item in a storage. If options.expire or options.persist are set value is
Delete an item from all storages (local, session, and cookie). Options only used if being stored as a cookie.

storage.remove('foo');

<br />
Global Object
-------------------------

$.ezstorage.defaultSettings(); // return settings to {ezstorage: true, path:'/'};
$.ezstorage.settings = {<your settings>}; // no longer need to pass in function

<br />
Compatibility
-------------
Expand Down
28 changes: 28 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "jquery-ezstorage",
"description": "plugin for simple interaction with HTML5 Storage, local and session, and/or cookies",
"main": "jquery.ezstorage.js",
"authors": [
"Wayne Weibel"
],
"license": "MIT",
"keywords": [
"storage",
"html5",
"localStorage",
"sessionStorage",
"cookie"
],
"homepage": "https://github.com/wayne-weibel/jquery-ezstorage",
"moduleType": [],
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery.cookie": "jquery-cookie#1.4.1"
}
}
22 changes: 4 additions & 18 deletions jquery.ezstorage.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,20 +40,6 @@ $('document').ready(function () {
window.JSON && (window.JSON.stringify || window.JSON.encode) ||
$.toJSON
};

// ensure that JSON.parse and JSON.strinigify are available
if(!('parse' in JSON) || !('stringify' in JSON)){
$.getScript('http://cdnjs.cloudflare.com/ajax/libs/json2/20110223/json2.js', function() {
console.log('EZStorage: loaded JSON library dynamically');
});
}

// include jquery.cookie ($.cookie) library
if ( typeof(jQuery.cookie) === 'undefined' ) {
$.getScript('https://raw.github.com/carhartl/jquery-cookie/master/jquery.cookie.js', function() {
console.log('EZStorage: loaded jQuery.cookie library dynamically');
});
}
});

/**
Expand Down Expand Up @@ -90,7 +76,7 @@ $('document').ready(function () {
*/
var ezs = $.ezstorage =
function EZStorage(action, key, value, options) {

// establish options - set expires to date object if necessary
options = $.extend({}, ezs.settings, options);
if ( options.expires ) {
Expand Down Expand Up @@ -139,7 +125,7 @@ $('document').ready(function () {
}
}
}

// check for a cookie version if not found in storage
return $.cookie(key);
break;
Expand Down Expand Up @@ -186,5 +172,5 @@ $('document').ready(function () {
defaultSettings : function() { this.settings = {ezstorage: true, path:'/'}; },
settings : {ezstorage: true, path: '/'}
});
})(jQuery);

})(jQuery);
32 changes: 32 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "jquery-ezstorage",
"version": "1.2.3",
"description": "plugin for simple interaction with HTML5 Storage, local and session, and/or cookies",
"main": "jquery.ezstorage.js",
"scripts": {},
"repository": {
"type": "git",
"url": "git+https://github.com/wayne-weibel/jquery-ezstorage.git"
},
"keywords": [
"storage",
"html5",
"localStorage",
"sessionStorage",
"cookie"
],
"author": "Wayne Weibel",
"license": "MIT",
"bugs": {
"url": "https://github.com/wayne-weibel/jquery-ezstorage/issues"
},
"homepage": "https://github.com/wayne-weibel/jquery-ezstorage#readme",
"dependencies": {
"jquery.cookie": "1.4.1"
},
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-uglify": "^0.11.0"
}
}

0 comments on commit 164333d

Please sign in to comment.