Upgrade to ExtJS 3.2.0 - Released 03/30/2010
[extjs.git] / docs / source / Cookies.html
index 284f9d6..f829248 100644 (file)
-<html>\r
-<head>\r
-  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    \r
-  <title>The source code</title>\r
-    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />\r
-    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>\r
-</head>\r
-<body  onload="prettyPrint();">\r
-    <pre class="prettyprint lang-js"><div id="cls-Ext.util.Cookies"></div>/**\r
- * @class Ext.util.Cookies\r
- * Utility class for managing and interacting with cookies.\r
- * @singleton\r
- */\r
-Ext.util.Cookies = {\r
-    <div id="method-Ext.util.Cookies-set"></div>/**\r
-     * Create a cookie with the specified name and value. Additional settings\r
-     * for the cookie may be optionally specified (for example: expiration,\r
-     * access restriction, SSL).\r
-     * @param {String} name The name of the cookie to set. \r
-     * @param {Mixed} value The value to set for the cookie.\r
-     * @param {Object} expires (Optional) Specify an expiration date the\r
-     * cookie is to persist until.  Note that the specified Date object will\r
-     * be converted to Greenwich Mean Time (GMT). \r
-     * @param {String} path (Optional) Setting a path on the cookie restricts\r
-     * access to pages that match that path. Defaults to all pages (<tt>'/'</tt>). \r
-     * @param {String} domain (Optional) Setting a domain restricts access to\r
-     * pages on a given domain (typically used to allow cookie access across\r
-     * subdomains). For example, "extjs.com" will create a cookie that can be\r
-     * accessed from any subdomain of extjs.com, including www.extjs.com,\r
-     * support.extjs.com, etc.\r
-     * @param {Boolean} secure (Optional) Specify true to indicate that the cookie\r
-     * should only be accessible via SSL on a page using the HTTPS protocol.\r
-     * Defaults to <tt>false</tt>. Note that this will only work if the page\r
-     * calling this code uses the HTTPS protocol, otherwise the cookie will be\r
-     * created with default options.\r
-     */\r
-    set : function(name, value){\r
-        var argv = arguments;\r
-        var argc = arguments.length;\r
-        var expires = (argc > 2) ? argv[2] : null;\r
-        var path = (argc > 3) ? argv[3] : '/';\r
-        var domain = (argc > 4) ? argv[4] : null;\r
-        var secure = (argc > 5) ? argv[5] : false;\r
-        document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");\r
-    },\r
-\r
-    <div id="method-Ext.util.Cookies-get"></div>/**\r
-     * Retrieves cookies that are accessible by the current page. If a cookie\r
-     * does not exist, <code>get()</code> returns <tt>null</tt>.  The following\r
-     * example retrieves the cookie called "valid" and stores the String value\r
-     * in the variable <tt>validStatus</tt>.\r
-     * <pre><code>\r
-     * var validStatus = Ext.util.Cookies.get("valid");\r
-     * </code></pre>\r
-     * @param {String} name The name of the cookie to get\r
-     * @return {Mixed} Returns the cookie value for the specified name;\r
-     * null if the cookie name does not exist.\r
-     */\r
-    get : function(name){\r
-        var arg = name + "=";\r
-        var alen = arg.length;\r
-        var clen = document.cookie.length;\r
-        var i = 0;\r
-        var j = 0;\r
-        while(i < clen){\r
-            j = i + alen;\r
-            if(document.cookie.substring(i, j) == arg){\r
-                return Ext.util.Cookies.getCookieVal(j);\r
-            }\r
-            i = document.cookie.indexOf(" ", i) + 1;\r
-            if(i === 0){\r
-                break;\r
-            }\r
-        }\r
-        return null;\r
-    },\r
-\r
-    <div id="method-Ext.util.Cookies-clear"></div>/**\r
-     * Removes a cookie with the provided name from the browser\r
-     * if found by setting its expiration date to sometime in the past. \r
-     * @param {String} name The name of the cookie to remove\r
-     */\r
-    clear : function(name){\r
-        if(Ext.util.Cookies.get(name)){\r
-            document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";\r
-        }\r
-    },\r
-    /**\r
-     * @private\r
-     */\r
-    getCookieVal : function(offset){\r
-        var endstr = document.cookie.indexOf(";", offset);\r
-        if(endstr == -1){\r
-            endstr = document.cookie.length;\r
-        }\r
-        return unescape(document.cookie.substring(offset, endstr));\r
-    }\r
-};</pre>    \r
-</body>\r
+<html>
+<head>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
+  <title>The source code</title>
+    <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
+    <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
+</head>
+<body  onload="prettyPrint();">
+    <pre class="prettyprint lang-js">/*!
+ * Ext JS Library 3.2.0
+ * Copyright(c) 2006-2010 Ext JS, Inc.
+ * licensing@extjs.com
+ * http://www.extjs.com/license
+ */
+<div id="cls-Ext.util.Cookies"></div>/**
+ * @class Ext.util.Cookies
+ * Utility class for managing and interacting with cookies.
+ * @singleton
+ */
+Ext.util.Cookies = {
+    <div id="method-Ext.util.Cookies-set"></div>/**
+     * Create a cookie with the specified name and value. Additional settings
+     * for the cookie may be optionally specified (for example: expiration,
+     * access restriction, SSL).
+     * @param {String} name The name of the cookie to set. 
+     * @param {Mixed} value The value to set for the cookie.
+     * @param {Object} expires (Optional) Specify an expiration date the
+     * cookie is to persist until.  Note that the specified Date object will
+     * be converted to Greenwich Mean Time (GMT). 
+     * @param {String} path (Optional) Setting a path on the cookie restricts
+     * access to pages that match that path. Defaults to all pages (<tt>'/'</tt>). 
+     * @param {String} domain (Optional) Setting a domain restricts access to
+     * pages on a given domain (typically used to allow cookie access across
+     * subdomains). For example, "extjs.com" will create a cookie that can be
+     * accessed from any subdomain of extjs.com, including www.extjs.com,
+     * support.extjs.com, etc.
+     * @param {Boolean} secure (Optional) Specify true to indicate that the cookie
+     * should only be accessible via SSL on a page using the HTTPS protocol.
+     * Defaults to <tt>false</tt>. Note that this will only work if the page
+     * calling this code uses the HTTPS protocol, otherwise the cookie will be
+     * created with default options.
+     */
+    set : function(name, value){
+        var argv = arguments;
+        var argc = arguments.length;
+        var expires = (argc > 2) ? argv[2] : null;
+        var path = (argc > 3) ? argv[3] : '/';
+        var domain = (argc > 4) ? argv[4] : null;
+        var secure = (argc > 5) ? argv[5] : false;
+        document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toGMTString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
+    },
+
+    <div id="method-Ext.util.Cookies-get"></div>/**
+     * Retrieves cookies that are accessible by the current page. If a cookie
+     * does not exist, <code>get()</code> returns <tt>null</tt>.  The following
+     * example retrieves the cookie called "valid" and stores the String value
+     * in the variable <tt>validStatus</tt>.
+     * <pre><code>
+     * var validStatus = Ext.util.Cookies.get("valid");
+     * </code></pre>
+     * @param {String} name The name of the cookie to get
+     * @return {Mixed} Returns the cookie value for the specified name;
+     * null if the cookie name does not exist.
+     */
+    get : function(name){
+        var arg = name + "=";
+        var alen = arg.length;
+        var clen = document.cookie.length;
+        var i = 0;
+        var j = 0;
+        while(i < clen){
+            j = i + alen;
+            if(document.cookie.substring(i, j) == arg){
+                return Ext.util.Cookies.getCookieVal(j);
+            }
+            i = document.cookie.indexOf(" ", i) + 1;
+            if(i === 0){
+                break;
+            }
+        }
+        return null;
+    },
+
+    <div id="method-Ext.util.Cookies-clear"></div>/**
+     * Removes a cookie with the provided name from the browser
+     * if found by setting its expiration date to sometime in the past. 
+     * @param {String} name The name of the cookie to remove
+     */
+    clear : function(name){
+        if(Ext.util.Cookies.get(name)){
+            document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
+        }
+    },
+    /**
+     * @private
+     */
+    getCookieVal : function(offset){
+        var endstr = document.cookie.indexOf(";", offset);
+        if(endstr == -1){
+            endstr = document.cookie.length;
+        }
+        return unescape(document.cookie.substring(offset, endstr));
+    }
+};</pre>    
+</body>
 </html>
\ No newline at end of file