You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2012/12/17 14:24:11 UTC
svn commit: r1422921 - in /myfaces/tomahawk/trunk:
core/src/main/java/org/apache/myfaces/custom/tree2/
core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/
core20/src/main/java/org/apache/myfaces/custom/tree2/ core20/src/main/ja...
Author: werpu
Date: Mon Dec 17 13:24:09 2012
New Revision: 1422921
URL: http://svn.apache.org/viewvc?rev=1422921&view=rev
Log:
TOMAHAWK-1650
Modified:
myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/cookielib.js
myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/tree.js
myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/cookielib.js
myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/tree.js
Modified: myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/core/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java Mon Dec 17 13:24:09 2012
@@ -561,7 +561,7 @@ public class HtmlTreeRenderer extends Re
if (node.getChildCount() > 0)
{
String onClick = new StringBuffer()
- .append("treeNavClick('")
+ .append("org.apache.myfaces.Tree.treeNavClick('")
.append(spanId)
.append("', '")
.append(image.getClientId(context))
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/cookielib.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/cookielib.js?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/cookielib.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/cookielib.js Mon Dec 17 13:24:09 2012
@@ -2,123 +2,116 @@
// CookieLib Definition
// Contains general purpose javascript methods for managing html cookies
//=============================================================================
+window.org = window.org || {};
+org.apache = org.apache || {};
+org.apache.myfaces = org.apache.myfaces || {};
-function CookieLib(){}
+if (!org.apache.myfaces.CookieLib) {
-CookieLib.COOKIE_DELIM = ";";
-CookieLib.COOKIE_KEYVAL = "=";
-CookieLib.ATTRIB_DELIM = ";";
-CookieLib.ATTRIB_KEYVAL = "=";
-
-/**
- * Retrieves the specified cookie as a String of text
- * @param String name - name of cookie to retrieve
- * @return String cookie value or null if not found
- */
-function CookieLib_getRawCookie(name) {
- var search = name + CookieLib.COOKIE_KEYVAL;
- if (document.cookie)
- {
- if (document.cookie.length > 0)
- {
- offset = document.cookie.indexOf(search);
- if (offset != -1)
- {
- offset += search.length;
- end = document.cookie.indexOf(CookieLib.COOKIE_DELIM, offset);
- if (end == -1) end = document.cookie.length;
- return unescape(document.cookie.substring(offset, end));
+ org.apache.myfaces.CookieLib = function () {
+ }
+
+ org.apache.myfaces.CookieLib.COOKIE_DELIM = ";";
+ org.apache.myfaces.CookieLib.COOKIE_KEYVAL = "=";
+ org.apache.myfaces.CookieLib.ATTRIB_DELIM = ";";
+ org.apache.myfaces.CookieLib.ATTRIB_KEYVAL = "=";
+
+ /**
+ * Retrieves the specified cookie as a String of text
+ * @param {String} name - name of cookie to retrieve
+ * @return {String} cookie value or null if not found
+ */
+ org.apache.myfaces.CookieLib.getRawCookie = function (name) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var search = name + CookieLib.COOKIE_KEYVAL;
+ if (document.cookie) {
+ if (document.cookie.length > 0) {
+ var offset = document.cookie.indexOf(search);
+ if (offset != -1) {
+ offset += search.length;
+ var end = document.cookie.indexOf(CookieLib.COOKIE_DELIM, offset);
+ if (end == -1) end = document.cookie.length;
+ return unescape(document.cookie.substring(offset, end));
+ }
}
}
- }
- return null;
-}
-CookieLib.getRawCookie = CookieLib_getRawCookie;
-
-/**
- * Cookies can hold multiple pieces of information. This methods saves a key/value pair to
- * the specified cookie. Each key/value pair is separated by a special character
- * defined by the ATTRIB_DELIM constant. Setting an attribute's value to null or empty string
- * will remove it from the cookie.
- * @param cookieName String - name of cookie that will hold the key/value pair
- * @param attribName String - attribute key
- * @param attribValue String - attribute value
- */
-function CookieLib_setCookieAttrib(cookieName, attribName, attribValue)
-{
- var attribMap = CookieLib.getCookie(cookieName);
- attribMap[attribName] = attribValue;
- CookieLib.setCookie(cookieName,attribMap);
-}
-CookieLib.setCookieAttrib = CookieLib_setCookieAttrib;
-
-/**
- * Cookies can hold multiple pieces of information. This methods retrieves a value from the
- * specified cookie using the specified key (attribName). Each key/value pair is separated by a
- * special character defined by the ATTRIB_DELIM constant.
- * @param cookieName String - name of cookie that that holds the key/value pair
- * @param attribName String - attribute key
- * @param attribValue String - attribute value
- * @return String value
- */
-function CookieLib_getCookieAttrib(cookieName, attribName)
-{
- var attribMap = CookieLib.getCookie(cookieName);
- return attribMap[attribName];
-}
-CookieLib.getCookieAttrib = CookieLib_getCookieAttrib;
-
-/**
- * Retrieves a map of all key/value pairs (attributes) stored in the specified cookie.
- * @param cookieName String - name of cookie
- * @return Array of all attributes
- */
-function CookieLib_getCookie(cookieName)
-{
- var attribMap = new Array();
- var cookie = CookieLib.getRawCookie(cookieName);
- if (typeof( cookie ) != "undefined" && cookie != null)
- {
- var attribArray = cookie.split(CookieLib.ATTRIB_DELIM);
- for (var i=0;i<attribArray.length;i++)
- {
- var index = attribArray[i].indexOf(CookieLib.ATTRIB_KEYVAL);
- var name = attribArray[i].substring(0,index);
- var value = attribArray[i].substring(index+1);
- attribMap[name] = value;
+ return null;
+ };
+
+ /**
+ * Cookies can hold multiple pieces of information. This methods saves a key/value pair to
+ * the specified cookie. Each key/value pair is separated by a special character
+ * defined by the ATTRIB_DELIM constant. Setting an attribute's value to null or empty string
+ * will remove it from the cookie.
+ * @param cookieName String - name of cookie that will hold the key/value pair
+ * @param attribName String - attribute key
+ * @param attribValue String - attribute value
+ */
+ org.apache.myfaces.CookieLib.setCookieAttrib = function(cookieName, attribName, attribValue) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = CookieLib.getCookie(cookieName);
+ attribMap[attribName] = attribValue;
+ CookieLib.setCookie(cookieName, attribMap);
+ };
+
+ /**
+ * Cookies can hold multiple pieces of information. This methods retrieves a value from the
+ * specified cookie using the specified key (attribName). Each key/value pair is separated by a
+ * special character defined by the ATTRIB_DELIM constant.
+ * @param cookieName String - name of cookie that that holds the key/value pair
+ * @param attribName String - attribute key
+ * @return String value
+ */
+ org.apache.myfaces.CookieLib.getCookieAttrib = function (cookieName, attribName) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = CookieLib.getCookie(cookieName);
+ return attribMap[attribName];
+ };
+
+ /**
+ * Retrieves a map of all key/value pairs (attributes) stored in the specified cookie.
+ * @param cookieName String - name of cookie
+ * @return Array of all attributes
+ */
+ org.apache.myfaces.CookieLib.getCookie = function (cookieName) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = new Array();
+ var cookie = CookieLib.getRawCookie(cookieName);
+ if (typeof( cookie ) != "undefined" && cookie != null) {
+ var attribArray = cookie.split(CookieLib.ATTRIB_DELIM);
+ for (var i = 0; i < attribArray.length; i++) {
+ var index = attribArray[i].indexOf(CookieLib.ATTRIB_KEYVAL);
+ var name = attribArray[i].substring(0, index);
+ var value = attribArray[i].substring(index + 1);
+ attribMap[name] = value;
+ }
}
- }
- return attribMap;
-}
-CookieLib.getCookie = CookieLib_getCookie;
-
-/**
- * Saves a map of cookie attributes to the specified cookie. Null or empty string values are not saved.
- * @param cookieName String - name of cookie to create
- * @param attribMap Array - holds key/value pairs to save in cookie
- */
-function CookieLib_setCookie(cookieName, attribMap)
-{
- var attrib = "";
- for (var name in attribMap)
- {
- var value = attribMap[name];
-
- if (typeof( value ) != "undefined" && value != null && value != "" && typeof(value) != "function")
- {
- if (name.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 && value.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 &&
- name.indexOf(CookieLib.ATTRIB_DELIM) < 0 && value.indexOf(CookieLib.ATTRIB_DELIM) < 0)
- {
- attrib += ((attrib == "") ? "" : CookieLib.ATTRIB_DELIM);
- attrib += (name + CookieLib.ATTRIB_KEYVAL + value);
- }
- else
- {
- alert("Cookie attribute name and/or value contains a delimeter (" +
- CookieLib.ATTRIB_KEYVAL + " or " + CookieLib.ATTRIB_DELIM + ").");
+ return attribMap;
+ };
+
+ /**
+ * Saves a map of cookie attributes to the specified cookie. Null or empty string values are not saved.
+ * @param cookieName String - name of cookie to create
+ * @param attribMap Array - holds key/value pairs to save in cookie
+ */
+ org.apache.myfaces.CookieLib.setCookie = function (cookieName, attribMap) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attrib = "";
+ for (var name in attribMap) {
+ var value = attribMap[name];
+
+ if (typeof( value ) != "undefined" && value != null && value != "" && typeof(value) != "function") {
+ if (name.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 && value.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 &&
+ name.indexOf(CookieLib.ATTRIB_DELIM) < 0 && value.indexOf(CookieLib.ATTRIB_DELIM) < 0) {
+ attrib += ((attrib == "") ? "" : CookieLib.ATTRIB_DELIM);
+ attrib += (name + CookieLib.ATTRIB_KEYVAL + value);
+ }
+ else {
+ alert("Cookie attribute name and/or value contains a delimeter (" +
+ CookieLib.ATTRIB_KEYVAL + " or " + CookieLib.ATTRIB_DELIM + ").");
+ }
}
}
- }
- document.cookie = cookieName + CookieLib.COOKIE_KEYVAL + escape(attrib);
-}
-CookieLib.setCookie = CookieLib_setCookie;
+ document.cookie = cookieName + CookieLib.COOKIE_KEYVAL + escape(attrib);
+ };
+}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/tree.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/tree.js?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/tree.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/tree2/resource/javascript/tree.js Mon Dec 17 13:24:09 2012
@@ -1,22 +1,31 @@
-function treeNavClick(spanId, navImageId, image1, image2, nodeImgId, expandImg, collapseImg, cookieName, nodeId) {
- var navSpan = document.getElementById(spanId);
- var displayStyle = navSpan.style.display;
- if (displayStyle == 'none') {
- displayStyle = 'block'
- CookieLib.setCookieAttrib(cookieName, nodeId, "x");
- } else {
- displayStyle = 'none';
- CookieLib.setCookieAttrib(cookieName, nodeId, "c");
- }
- navSpan.style.display = displayStyle;
- if (navImageId != '') {
- var navImage = document.getElementById(navImageId);
- if (navImage.src.indexOf(image1)>=0) navImage.src = image2; else navImage.src = image1;
- }
- if (nodeImgId != '') {
- var nodeImg = document.getElementById(nodeImgId);
- if (nodeImg.src.indexOf(expandImg) >=0)
- nodeImg.src = collapseImg;
- else nodeImg.src = expandImg;
- }
+window.org = window.org || {};
+org.apache = org.apache || {};
+org.apache.myfaces = org.apache.myfaces || {};
+
+if (!org.apache.myfaces.Tree) {
+ org.apache.myfaces.Tree = function () {
+ };
+
+ org.apache.myfaces.Tree.treeNavClick = function (spanId, navImageId, image1, image2, nodeImgId, expandImg, collapseImg, cookieName, nodeId) {
+ var navSpan = document.getElementById(spanId);
+ var displayStyle = navSpan.style.display;
+ if (displayStyle == 'none') {
+ displayStyle = 'block'
+ org.apache.myfaces.CookieLib.setCookieAttrib(cookieName, nodeId, "x");
+ } else {
+ displayStyle = 'none';
+ org.apache.myfaces.CookieLib.setCookieAttrib(cookieName, nodeId, "c");
+ }
+ navSpan.style.display = displayStyle;
+ if (navImageId != '') {
+ var navImage = document.getElementById(navImageId);
+ if (navImage.src.indexOf(image1) >= 0) navImage.src = image2; else navImage.src = image1;
+ }
+ if (nodeImgId != '') {
+ var nodeImg = document.getElementById(nodeImgId);
+ if (nodeImg.src.indexOf(expandImg) >= 0)
+ nodeImg.src = collapseImg;
+ else nodeImg.src = expandImg;
+ }
+ };
}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java (original)
+++ myfaces/tomahawk/trunk/core20/src/main/java/org/apache/myfaces/custom/tree2/HtmlTreeRenderer.java Mon Dec 17 13:24:09 2012
@@ -524,7 +524,7 @@ public class HtmlTreeRenderer extends Re
String imageId = IMAGE_PREFIX+tree.createUniqueId(context, null).substring(UIViewRoot.UNIQUE_ID_PREFIX.length());//IMAGE_PREFIX+(counter++);
image.setId(imageId);
image.setUrl(navSrcUrl);
-
+
Map imageAttrs = image.getAttributes();
imageAttrs.put(HTML.WIDTH_ATTR, "19");
imageAttrs.put(HTML.HEIGHT_ATTR, "18");
@@ -569,7 +569,7 @@ public class HtmlTreeRenderer extends Re
if (node.getChildCount() > 0)
{
String onClick = new StringBuffer()
- .append("treeNavClick('")
+ .append("org.apache.myfaces.Tree.treeNavClick('")
.append(spanId)
.append("', '")
.append(image.getClientId(context))
Modified: myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/cookielib.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/cookielib.js?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/cookielib.js (original)
+++ myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/cookielib.js Mon Dec 17 13:24:09 2012
@@ -2,123 +2,116 @@
// CookieLib Definition
// Contains general purpose javascript methods for managing html cookies
//=============================================================================
+window.org = window.org || {};
+org.apache = org.apache || {};
+org.apache.myfaces = org.apache.myfaces || {};
-function CookieLib(){}
+if (!org.apache.myfaces.CookieLib) {
-CookieLib.COOKIE_DELIM = ";";
-CookieLib.COOKIE_KEYVAL = "=";
-CookieLib.ATTRIB_DELIM = ";";
-CookieLib.ATTRIB_KEYVAL = "=";
-
-/**
- * Retrieves the specified cookie as a String of text
- * @param String name - name of cookie to retrieve
- * @return String cookie value or null if not found
- */
-function CookieLib_getRawCookie(name) {
- var search = name + CookieLib.COOKIE_KEYVAL;
- if (document.cookie)
- {
- if (document.cookie.length > 0)
- {
- offset = document.cookie.indexOf(search);
- if (offset != -1)
- {
- offset += search.length;
- end = document.cookie.indexOf(CookieLib.COOKIE_DELIM, offset);
- if (end == -1) end = document.cookie.length;
- return unescape(document.cookie.substring(offset, end));
+ org.apache.myfaces.CookieLib = function () {
+ }
+
+ org.apache.myfaces.CookieLib.COOKIE_DELIM = ";";
+ org.apache.myfaces.CookieLib.COOKIE_KEYVAL = "=";
+ org.apache.myfaces.CookieLib.ATTRIB_DELIM = ";";
+ org.apache.myfaces.CookieLib.ATTRIB_KEYVAL = "=";
+
+ /**
+ * Retrieves the specified cookie as a String of text
+ * @param {String} name - name of cookie to retrieve
+ * @return {String} cookie value or null if not found
+ */
+ org.apache.myfaces.CookieLib.getRawCookie = function (name) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var search = name + CookieLib.COOKIE_KEYVAL;
+ if (document.cookie) {
+ if (document.cookie.length > 0) {
+ var offset = document.cookie.indexOf(search);
+ if (offset != -1) {
+ offset += search.length;
+ var end = document.cookie.indexOf(CookieLib.COOKIE_DELIM, offset);
+ if (end == -1) end = document.cookie.length;
+ return unescape(document.cookie.substring(offset, end));
+ }
}
}
- }
- return null;
-}
-CookieLib.getRawCookie = CookieLib_getRawCookie;
-
-/**
- * Cookies can hold multiple pieces of information. This methods saves a key/value pair to
- * the specified cookie. Each key/value pair is separated by a special character
- * defined by the ATTRIB_DELIM constant. Setting an attribute's value to null or empty string
- * will remove it from the cookie.
- * @param cookieName String - name of cookie that will hold the key/value pair
- * @param attribName String - attribute key
- * @param attribValue String - attribute value
- */
-function CookieLib_setCookieAttrib(cookieName, attribName, attribValue)
-{
- var attribMap = CookieLib.getCookie(cookieName);
- attribMap[attribName] = attribValue;
- CookieLib.setCookie(cookieName,attribMap);
-}
-CookieLib.setCookieAttrib = CookieLib_setCookieAttrib;
-
-/**
- * Cookies can hold multiple pieces of information. This methods retrieves a value from the
- * specified cookie using the specified key (attribName). Each key/value pair is separated by a
- * special character defined by the ATTRIB_DELIM constant.
- * @param cookieName String - name of cookie that that holds the key/value pair
- * @param attribName String - attribute key
- * @param attribValue String - attribute value
- * @return String value
- */
-function CookieLib_getCookieAttrib(cookieName, attribName)
-{
- var attribMap = CookieLib.getCookie(cookieName);
- return attribMap[attribName];
-}
-CookieLib.getCookieAttrib = CookieLib_getCookieAttrib;
-
-/**
- * Retrieves a map of all key/value pairs (attributes) stored in the specified cookie.
- * @param cookieName String - name of cookie
- * @return Array of all attributes
- */
-function CookieLib_getCookie(cookieName)
-{
- var attribMap = new Array();
- var cookie = CookieLib.getRawCookie(cookieName);
- if (typeof( cookie ) != "undefined" && cookie != null)
- {
- var attribArray = cookie.split(CookieLib.ATTRIB_DELIM);
- for (var i=0;i<attribArray.length;i++)
- {
- var index = attribArray[i].indexOf(CookieLib.ATTRIB_KEYVAL);
- var name = attribArray[i].substring(0,index);
- var value = attribArray[i].substring(index+1);
- attribMap[name] = value;
+ return null;
+ };
+
+ /**
+ * Cookies can hold multiple pieces of information. This methods saves a key/value pair to
+ * the specified cookie. Each key/value pair is separated by a special character
+ * defined by the ATTRIB_DELIM constant. Setting an attribute's value to null or empty string
+ * will remove it from the cookie.
+ * @param cookieName String - name of cookie that will hold the key/value pair
+ * @param attribName String - attribute key
+ * @param attribValue String - attribute value
+ */
+ org.apache.myfaces.CookieLib.setCookieAttrib = function(cookieName, attribName, attribValue) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = CookieLib.getCookie(cookieName);
+ attribMap[attribName] = attribValue;
+ CookieLib.setCookie(cookieName, attribMap);
+ };
+
+ /**
+ * Cookies can hold multiple pieces of information. This methods retrieves a value from the
+ * specified cookie using the specified key (attribName). Each key/value pair is separated by a
+ * special character defined by the ATTRIB_DELIM constant.
+ * @param cookieName String - name of cookie that that holds the key/value pair
+ * @param attribName String - attribute key
+ * @return String value
+ */
+ org.apache.myfaces.CookieLib.getCookieAttrib = function (cookieName, attribName) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = CookieLib.getCookie(cookieName);
+ return attribMap[attribName];
+ };
+
+ /**
+ * Retrieves a map of all key/value pairs (attributes) stored in the specified cookie.
+ * @param cookieName String - name of cookie
+ * @return Array of all attributes
+ */
+ org.apache.myfaces.CookieLib.getCookie = function (cookieName) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attribMap = new Array();
+ var cookie = CookieLib.getRawCookie(cookieName);
+ if (typeof( cookie ) != "undefined" && cookie != null) {
+ var attribArray = cookie.split(CookieLib.ATTRIB_DELIM);
+ for (var i = 0; i < attribArray.length; i++) {
+ var index = attribArray[i].indexOf(CookieLib.ATTRIB_KEYVAL);
+ var name = attribArray[i].substring(0, index);
+ var value = attribArray[i].substring(index + 1);
+ attribMap[name] = value;
+ }
}
- }
- return attribMap;
-}
-CookieLib.getCookie = CookieLib_getCookie;
-
-/**
- * Saves a map of cookie attributes to the specified cookie. Null or empty string values are not saved.
- * @param cookieName String - name of cookie to create
- * @param attribMap Array - holds key/value pairs to save in cookie
- */
-function CookieLib_setCookie(cookieName, attribMap)
-{
- var attrib = "";
- for (var name in attribMap)
- {
- var value = attribMap[name];
-
- if (typeof( value ) != "undefined" && value != null && value != "" && typeof(value) != "function")
- {
- if (name.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 && value.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 &&
- name.indexOf(CookieLib.ATTRIB_DELIM) < 0 && value.indexOf(CookieLib.ATTRIB_DELIM) < 0)
- {
- attrib += ((attrib == "") ? "" : CookieLib.ATTRIB_DELIM);
- attrib += (name + CookieLib.ATTRIB_KEYVAL + value);
- }
- else
- {
- alert("Cookie attribute name and/or value contains a delimeter (" +
- CookieLib.ATTRIB_KEYVAL + " or " + CookieLib.ATTRIB_DELIM + ").");
+ return attribMap;
+ };
+
+ /**
+ * Saves a map of cookie attributes to the specified cookie. Null or empty string values are not saved.
+ * @param cookieName String - name of cookie to create
+ * @param attribMap Array - holds key/value pairs to save in cookie
+ */
+ org.apache.myfaces.CookieLib.setCookie = function (cookieName, attribMap) {
+ var CookieLib = org.apache.myfaces.CookieLib;
+ var attrib = "";
+ for (var name in attribMap) {
+ var value = attribMap[name];
+
+ if (typeof( value ) != "undefined" && value != null && value != "" && typeof(value) != "function") {
+ if (name.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 && value.indexOf(CookieLib.ATTRIB_KEYVAL) < 0 &&
+ name.indexOf(CookieLib.ATTRIB_DELIM) < 0 && value.indexOf(CookieLib.ATTRIB_DELIM) < 0) {
+ attrib += ((attrib == "") ? "" : CookieLib.ATTRIB_DELIM);
+ attrib += (name + CookieLib.ATTRIB_KEYVAL + value);
+ }
+ else {
+ alert("Cookie attribute name and/or value contains a delimeter (" +
+ CookieLib.ATTRIB_KEYVAL + " or " + CookieLib.ATTRIB_DELIM + ").");
+ }
}
}
- }
- document.cookie = cookieName + CookieLib.COOKIE_KEYVAL + escape(attrib);
-}
-CookieLib.setCookie = CookieLib_setCookie;
+ document.cookie = cookieName + CookieLib.COOKIE_KEYVAL + escape(attrib);
+ };
+}
\ No newline at end of file
Modified: myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/tree.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/tree.js?rev=1422921&r1=1422920&r2=1422921&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/tree.js (original)
+++ myfaces/tomahawk/trunk/core20/src/main/javascript/oam.custom.tree2.javascript/tree.js Mon Dec 17 13:24:09 2012
@@ -1,22 +1,31 @@
-function treeNavClick(spanId, navImageId, image1, image2, nodeImgId, expandImg, collapseImg, cookieName, nodeId) {
- var navSpan = document.getElementById(spanId);
- var displayStyle = navSpan.style.display;
- if (displayStyle == 'none') {
- displayStyle = 'block'
- CookieLib.setCookieAttrib(cookieName, nodeId, "x");
- } else {
- displayStyle = 'none';
- CookieLib.setCookieAttrib(cookieName, nodeId, "c");
- }
- navSpan.style.display = displayStyle;
- if (navImageId != '') {
- var navImage = document.getElementById(navImageId);
- if (navImage.src.indexOf(image1)>=0) navImage.src = image2; else navImage.src = image1;
- }
- if (nodeImgId != '') {
- var nodeImg = document.getElementById(nodeImgId);
- if (nodeImg.src.indexOf(expandImg) >=0)
- nodeImg.src = collapseImg;
- else nodeImg.src = expandImg;
- }
+window.org = window.org || {};
+org.apache = org.apache || {};
+org.apache.myfaces = org.apache.myfaces || {};
+
+if (!org.apache.myfaces.Tree) {
+ org.apache.myfaces.Tree = function () {
+ };
+
+ org.apache.myfaces.Tree.treeNavClick = function (spanId, navImageId, image1, image2, nodeImgId, expandImg, collapseImg, cookieName, nodeId) {
+ var navSpan = document.getElementById(spanId);
+ var displayStyle = navSpan.style.display;
+ if (displayStyle == 'none') {
+ displayStyle = 'block'
+ org.apache.myfaces.CookieLib.setCookieAttrib(cookieName, nodeId, "x");
+ } else {
+ displayStyle = 'none';
+ org.apache.myfaces.CookieLib.setCookieAttrib(cookieName, nodeId, "c");
+ }
+ navSpan.style.display = displayStyle;
+ if (navImageId != '') {
+ var navImage = document.getElementById(navImageId);
+ if (navImage.src.indexOf(image1) >= 0) navImage.src = image2; else navImage.src = image1;
+ }
+ if (nodeImgId != '') {
+ var nodeImg = document.getElementById(nodeImgId);
+ if (nodeImg.src.indexOf(expandImg) >= 0)
+ nodeImg.src = collapseImg;
+ else nodeImg.src = expandImg;
+ }
+ };
}
\ No newline at end of file