Giter Club home page Giter Club logo

zepto-cookie's Introduction

Zepto Cookie Plugin

A simple plugin to read, set, and delete cookies. This plugin extends Zepto.js with a $.cookie method.

It is a modification of the jQuery-Cookie plugin made to work with Zepto.

Loading

Simply include the script in your site's template after zepto.min.js:

<script type="text/javascript" src="zepto.min.js"></script>
<script type="text/javascript" src="zepto.cookie.min.js"></script>

Alternatively, you can build the plugin directly into the Zepto library itself. To do so, copy zepto.cookie.js into the zepto/src/ folder of the Zepto project. Then build Zepto as you normally would using the rake concat command:

rake concat[zepto.cookie] dist

This will result in a build the default Zepto library, with the inclusion of Zepto Cookie. Grab the regular or minified version of zepto.js from the zepto/dist/ folder and include the library as you normally would.

<script type="text/javascript" src="zepto.min.js"></script>

You can then use Zepto Cookie as you normally would.

Usage

Use as such: $.fn.cookie(key, value, options);

key (string), The name of the cookie you want to read/ set.

value (string), The value of the cookie you're setting.

options (object), Additional cookie parameters such as expires, path, or domain.

Examples

$.fn.cookie('foo', 'bar');

Sets a cookie with the name of foo to the value of bar.

$.fn.cookie('foo');

Reads the value of a cookie. If ran after the first example, would return bar.

$.fn.cookie('foo', null);

Deletes (expires) the cookie with the name of foo.

$.fn.cookie('foo', 'bar', { expires: 7 });

Sets the cookie foo with value bar, set to expire in 7 days.

Options

The options argument is an object which supports the following properties:

{ expires : 7 }

The lifespan of the cookie in days. Takes an integer. Defaults to being a session cookie.

{ path: '/foo' }

The path for which the cookie is valid. If not specified, the cookie defaults to the path on which the cookie was set.

{ domain: 'example.com' }

The domain for which the cookie is valid. If not specified, the cookie defaults to the domain on which the cookie was set.

{ secure: true }

Whether the cookie requries a secure connection (https). Defaults to false.

{ raw: true }

Whether or not to URI encode the cookie value. Defaults to false.

zepto-cookie's People

Contributors

dcompute avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

zepto-cookie's Issues

Use "Zepto.extend" instead of "$.extend" (to work 'noConflict' like)

Hi,

I'd like to use your plugin for a project, but I've got one problem with it: Zepto only uses $ if it isn't used before.

See this fragment from the Zepto js code:

'$' in window || (window.$ = Zepto);

Could you please use

Zepto.extend(...

... instead of $.extend, so nothing breaks even if some other framework uses '$'

Thanks,
Dennis

[enhancement] Add missing bower.json.

Hey, maintainer(s) of dcompute/Zepto-Cookie!

We at VersionEye are working hard to keep up the quality of the bower's registry.

We just finished our initial analysis of the quality of the Bower.io registry:

7530 - registered packages, 224 of them doesnt exists anymore;

We analysed 7306 existing packages and 1070 of them don't have bower.json on the master branch ( that's where a Bower client pulls a data ).

Sadly, your library dcompute/Zepto-Cookie is one of them.

Can you spare 15 minutes to help us to make Bower better?

Just add a new file bower.json and change attributes.

{
  "name": "dcompute/Zepto-Cookie",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "description": "please add it",
  "license": "Eclipse",
  "ignore": [
    ".jshintrc",
    "**/*.txt"
  ],
  "dependencies": {
    "<dependency_name>": "<semantic_version>",
    "<dependency_name>": "<Local_folder>",
    "<dependency_name>": "<package>"
  },
  "devDependencies": {
    "<test-framework-name>": "<version>"
  }
}

Read more about bower.json on the official spefication and nodejs semver library has great examples of proper versioning.

NB! Please validate your bower.json with jsonlint before commiting your updates.

Thank you!

Timo,
twitter: @versioneye
email: [email protected]
VersionEye - no more legacy software!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.