3 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
\r
4 <title>The source code</title>
\r
5 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
6 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
8 <body onload="prettyPrint();">
\r
9 <pre class="prettyprint lang-js">
\r
10 <div id="cls-Ext.state.CookieProvider"></div>/**
\r
11 * @class Ext.state.CookieProvider
\r
12 * @extends Ext.state.Provider
\r
13 * The default Provider implementation which saves state via cookies.
\r
16 var cp = new Ext.state.CookieProvider({
\r
18 expires: new Date(new Date().getTime()+(1000*60*60*24*30)), //30 days
\r
21 Ext.state.Manager.setProvider(cp);
\r
23 * @cfg {String} path The path for which the cookie is active (defaults to root '/' which makes it active for all pages in the site)
\r
24 * @cfg {Date} expires The cookie expiration date (defaults to 7 days from now)
\r
25 * @cfg {String} domain The domain to save the cookie for. Note that you cannot specify a different domain than
\r
26 * your page is on, but you can specify a sub-domain, or simply the domain itself like 'extjs.com' to include
\r
27 * all sub-domains if you need to access cookies across different sub-domains (defaults to null which uses the same
\r
28 * domain the page is running on including the 'www' like 'www.extjs.com')
\r
29 * @cfg {Boolean} secure True if the site is using SSL (defaults to false)
\r
31 * Create a new CookieProvider
\r
32 * @param {Object} config The configuration object
\r
34 Ext.state.CookieProvider = function(config){
\r
35 Ext.state.CookieProvider.superclass.constructor.call(this);
\r
37 this.expires = new Date(new Date().getTime()+(1000*60*60*24*7)); //7 days
\r
39 this.secure = false;
\r
40 Ext.apply(this, config);
\r
41 this.state = this.readCookies();
\r
44 Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
\r
46 set : function(name, value){
\r
47 if(typeof value == "undefined" || value === null){
\r
51 this.setCookie(name, value);
\r
52 Ext.state.CookieProvider.superclass.set.call(this, name, value);
\r
56 clear : function(name){
\r
57 this.clearCookie(name);
\r
58 Ext.state.CookieProvider.superclass.clear.call(this, name);
\r
62 readCookies : function(){
\r
64 c = document.cookie + ";",
\r
65 re = /\s?(.*?)=(.*?);/g,
\r
69 while((matches = re.exec(c)) != null){
\r
72 if(name && name.substring(0,3) == "ys-"){
\r
73 cookies[name.substr(3)] = this.decodeValue(value);
\r
80 setCookie : function(name, value){
\r
81 document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
\r
82 ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
\r
83 ((this.path == null) ? "" : ("; path=" + this.path)) +
\r
84 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
\r
85 ((this.secure == true) ? "; secure" : "");
\r
89 clearCookie : function(name){
\r
90 document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
\r
91 ((this.path == null) ? "" : ("; path=" + this.path)) +
\r
92 ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
\r
93 ((this.secure == true) ? "; secure" : "");
\r