Author: artdaw
Date: 2009-07-10 11:52:18 -0400 (Fri, 10 Jul 2009)
New Revision: 14896
Added:
branches/community/3.3.X/docs/common-resources/en/src/main/script/jquery.cookie.js
Modified:
branches/community/3.3.X/docs/common-resources/en/src/main/css/html-common.css
branches/community/3.3.X/docs/common-resources/en/src/main/script/toggle.js
branches/community/3.3.X/docs/common-resources/en/src/main/xslt/collapsing-navigation.xsl
Log:
https://jira.jboss.org/jira/browse/RF-6058 - persistent menu is created
Modified: branches/community/3.3.X/docs/common-resources/en/src/main/css/html-common.css
===================================================================
---
branches/community/3.3.X/docs/common-resources/en/src/main/css/html-common.css 2009-07-10
15:49:56 UTC (rev 14895)
+++
branches/community/3.3.X/docs/common-resources/en/src/main/css/html-common.css 2009-07-10
15:52:18 UTC (rev 14896)
@@ -118,7 +118,7 @@
border: 1px solid #AAAAAA;
}
#title, ul.docnav{
- margin:0 auto;
+ /*margin:0 auto;*/
width:1000px;
margin-left:0px;
}
Added: branches/community/3.3.X/docs/common-resources/en/src/main/script/jquery.cookie.js
===================================================================
--- branches/community/3.3.X/docs/common-resources/en/src/main/script/jquery.cookie.js
(rev 0)
+++
branches/community/3.3.X/docs/common-resources/en/src/main/script/jquery.cookie.js 2009-07-10
15:52:18 UTC (rev 14896)
@@ -0,0 +1,97 @@
+/**
+ * Cookie plugin
+ *
+ * Copyright (c) 2006 Klaus Hartl (stilbuero.de)
+ * Dual licensed under the MIT and GPL licenses:
+ *
http://www.opensource.org/licenses/mit-license.php
+ *
http://www.gnu.org/licenses/gpl.html
+ *
+ */
+
+/**
+ * Create a cookie with the given name and value and other optional parameters.
+ *
+ * @example $.cookie('the_cookie', 'the_value');
+ * @desc Set the value of a cookie.
+ * @example $.cookie('the_cookie', 'the_value', { expires: 7, path:
'/', domain: 'jquery.com', secure: true });
+ * @desc Create a cookie with all available options.
+ * @example $.cookie('the_cookie', 'the_value');
+ * @desc Create a session cookie.
+ * @example $.cookie('the_cookie', null);
+ * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the
same path and domain
+ * used when the cookie was set.
+ *
+ * @param String name The name of the cookie.
+ * @param String value The value of the cookie.
+ * @param Object options An object literal containing key/value pairs to provide optional
cookie attributes.
+ * @option Number|Date expires Either an integer specifying the expiration date from now
on in days or a Date object.
+ * If a negative value is specified (e.g. a date in the
past), the cookie will be deleted.
+ * If set to null or omitted, the cookie will be a session
cookie and will not be retained
+ * when the the browser exits.
+ * @option String path The value of the path atribute of the cookie (default: path of
page that created the cookie).
+ * @option String domain The value of the domain attribute of the cookie (default: domain
of page that created the cookie).
+ * @option Boolean secure If true, the secure attribute of the cookie will be set and the
cookie transmission will
+ * require a secure protocol (like HTTPS).
+ * @type undefined
+ *
+ * @name $.cookie
+ * @cat Plugins/Cookie
+ * @author Klaus Hartl/klaus.hartl(a)stilbuero.de
+ */
+
+/**
+ * Get the value of a cookie with the given name.
+ *
+ * @example $.cookie('the_cookie');
+ * @desc Get the value of a cookie.
+ *
+ * @param String name The name of the cookie.
+ * @return The value of the cookie.
+ * @type String
+ *
+ * @name $.cookie
+ * @cat Plugins/Cookie
+ * @author Klaus Hartl/klaus.hartl(a)stilbuero.de
+ */
+jQuery.cookie = function(name, value, options) {
+ if (typeof value != 'undefined') { // name and value given, set cookie
+ options = options || {};
+ if (value === null) {
+ value = '';
+ options = $.extend({}, options); // clone object since it's unexpected
behavior if the expired property were changed
+ options.expires = -1;
+ }
+ var expires = '';
+ if (options.expires && (typeof options.expires == 'number' ||
options.expires.toUTCString)) {
+ var date;
+ if (typeof options.expires == 'number') {
+ date = new Date();
+ date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
+ } else {
+ date = options.expires;
+ }
+ expires = '; expires=' + date.toUTCString(); // use expires
attribute, max-age is not supported by IE
+ }
+ // NOTE Needed to parenthesize options.path and options.domain
+ // in the following expressions, otherwise they evaluate to undefined
+ // in the packed version for some reason...
+ var path = options.path ? '; path=' + (options.path) : '';
+ var domain = options.domain ? '; domain=' + (options.domain) :
'';
+ var secure = options.secure ? '; secure' : '';
+ document.cookie = [name, '=', encodeURIComponent(value), expires, path,
domain, secure].join('');
+ } else { // only name given, get cookie
+ var cookieValue = null;
+ if (document.cookie && document.cookie != '') {
+ var cookies = document.cookie.split(';');
+ for (var i = 0; i < cookies.length; i++) {
+ var cookie = jQuery.trim(cookies[i]);
+ // Does this cookie string begin with the name we want?
+ if (cookie.substring(0, name.length + 1) == (name + '=')) {
+ cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
+ break;
+ }
+ }
+ }
+ return cookieValue;
+ }
+};
\ No newline at end of file
Modified: branches/community/3.3.X/docs/common-resources/en/src/main/script/toggle.js
===================================================================
--- branches/community/3.3.X/docs/common-resources/en/src/main/script/toggle.js 2009-07-10
15:49:56 UTC (rev 14895)
+++ branches/community/3.3.X/docs/common-resources/en/src/main/script/toggle.js 2009-07-10
15:52:18 UTC (rev 14896)
@@ -1,12 +1,18 @@
var inputCorrect = false;
var textCorrect = false;
+//variables for menu
+var closedItems=new Array(), //define var for items to be stored in cookie
+ //name of the cookie for closed elements
+ cookieClosedItems=document.title.replace(/\s*|\s*/g,'')+"_closedItems";
+ cookieButtons=document.title.replace(/\s*|\s*/g,'')+"_Buttons";
+ StateOfButtons=new Array();
+
-
function showPopup(_popupId) {
document.getElementById(_popupId).style.display = "block";
document.getElementById('timeOutDiv').style.display = "block";
document.getElementById("feedback-maincontainer").style.display =
"block";
- document.getElementById("guide_words").style.display = "block";
+ document.getElementById("guide_words").style.display = "block";
}
@@ -114,13 +120,19 @@
});
$(this).html('collapse all');
$(this).css('background', 'url(images/arrowsExpand.png) no-repeat scroll 0
4px');
+ StateOfButtons[1]="expand";
+ jQuery.cookie(cookieButtons, StateOfButtons, { expires: 365 });
},
function () {
$("span.expand_collapse_toc:contains('-')").each(function (i,
node) {
toc.collapse($(node)[0]);
- });
- $(this).html('expand all');
- $(this).css('background', 'transparent url(images/arrowsCollapse.png)
no-repeat scroll 0 4px');
+ });
+ StateOfButtons[1]="collapse";
+
+
+ $(this).html('expand all');
+ $(this).css('background', 'transparent url(images/arrowsCollapse.png)
no-repeat scroll 0 4px');
+ jQuery.cookie(cookieButtons, StateOfButtons, { expires: 365 });
});
}else{
$("#expand_collapse").css('display', 'none');
@@ -136,7 +148,82 @@
var table = $(this).parents().get(4);
$(table).children('tbody').show();
$(this).children('img').attr('src', 'images/minus.gif');
- });
+ });
+
+ var target=new Object();
+ var itext=" ";
+ if (jQuery.cookie) {
+
+ /*if no cookie called "closedItems" exists, then create one with
+ elements you want hidden by default.
+ '1' is given as first value to prevent cookie from being
+ deleted if it contains no ids*/
+ //read cookie for closed elements
+ if (!jQuery.cookie(cookieClosedItems)) {
+ jQuery.cookie(cookieClosedItems, 'start_cookie_file, collapse', { expires:
365 });
+ }
+ //if cookie called "closedItems" exists
+ if (jQuery.cookie(cookieClosedItems)) {
+
+
+ //split cookie into array
+ closedItems = jQuery.cookie(cookieClosedItems).split(',');
+
+ //iterate through array and expand each element within it
+ for (var i = 0; i < closedItems.length; ++i) {
+
+ target=jQuery("a[href='"+closedItems[i]+"']")[0];
+ if(target){
+ target=target.parentNode.previousSibling.previousSibling;
+ toc.show(toc.findDD(target))
+ toc.hide(target);
+ toc.show(target.nextSibling);
+ }
+ }
+ }
+ //read cookie for buttons
+ if (!jQuery.cookie(cookieButtons)) {
+ jQuery.cookie(cookieButtons, 'start_cookie_file', { expires: 365 });
+ }
+ if (jQuery.cookie(cookieButtons)) {
+
+
+ //split cookie into array
+ StateOfButtons = jQuery.cookie(cookieButtons).split(',');
+ idButtons="#expand_collapse"
+
+
+ //iterate through array and expand each element within it
+ if(StateOfButtons[1])
+ {
+ if(StateOfButtons[1]=="expand"){
+ $(idButtons).html('collapse all')
+ .css('background', 'url(images/arrowsExpand.png) no-repeat scroll 0
4px')
+ .one("click", function(){
+ $("span.expand_collapse_toc:contains('-')").each(function (i,
node) {
+ toc.collapse($(node)[0]);
+ });
+ StateOfButtons[1]="collapse";
+ jQuery.cookie(cookieButtons, StateOfButtons, { expires: 365 });
+ $(this).html('expand all');
+ $(this).css('background', 'transparent
url(images/arrowsCollapse.png) no-repeat scroll 0 4px');
+
+ });
+
+
+
+ }
+ if(StateOfButtons[1]=="collapse")
+ {
+ $(idButtons).html('expand all')
+ .css('background', 'transparent url(images/arrowsCollapse.png)
no-repeat scroll 0 4px');
+ }
+ }
+ }
+
+
+ }
+
});
/*
@@ -151,6 +238,7 @@
});
});
+
function searchElements(){
var patt=new RegExp($("#search").val().toString(),"i",
"g");
$("div.toc a").each(function (i, el) {
@@ -171,7 +259,8 @@
$("div.time_out_div").css('display','none');
$("div.time_out_div").text('');
}
-*/
+*/
+
function dbToggle(node, expandText, collapseText) {
var dt = node.parentNode;
if (dt.nodeName.toLowerCase() == 'dt') {
@@ -191,27 +280,62 @@
}
-}
-
+}
+
+
var toc = {
expand: function(node) {
toc.show(toc.findDD(node))
toc.hide(node);
- toc.show(node.nextSibling);
+ toc.show(node.nextSibling);
+ toc.updateArray(node.nextSibling.nextSibling.getElementsByTagName('*'),
"expand");
},
collapse : function(node) {
toc.hide(toc.findDD(node))
toc.hide(node);
- toc.show(node.previousSibling);
- },
+ toc.show(node.previousSibling);
+ toc.updateArray(node.nextSibling.getElementsByTagName('*'),
"collapse");
+ },
+
findDD : function(node) {
- return node.parentNode.nextSibling;
+ return node.parentNode.nextSibling;
+ //return node.parent().next();
},
- hide: function(node) {
- node.style.display = "none";
+ hide : function(node) {
+ node.style.display = "none";
+ //node.attr("style","display: none ;");
+
},
- show: function(node) {
+ show : function(node) {
node.style.display = "";
- }
+ //node.attr("style","display: ;");
+ },
+ updateArray : function(node, collapse_expand) {
+
+ //get id of element clicked for adding to closed items array
+ var eId = jQuery(node).attr("href");
+
+ //look for element in cookie array
+ var arrPos = jQuery.inArray(eId, closedItems);
+ //arrPos=-1;
+
+ if (arrPos == -1 ) {
+
+ //element is not in array, so add it
+ if(collapse_expand!="collapse") closedItems.push(eId);
+
+ } else {
+
+ //element is in array, so remove it
+ if(collapse_expand!="expand") closedItems.splice(arrPos, 1);
+
+ }
+
+ //update cookie
+ jQuery.cookie(cookieClosedItems, closedItems, { expires: 365 });
+ }
+
};
+
+
Modified:
branches/community/3.3.X/docs/common-resources/en/src/main/xslt/collapsing-navigation.xsl
===================================================================
---
branches/community/3.3.X/docs/common-resources/en/src/main/xslt/collapsing-navigation.xsl 2009-07-10
15:49:56 UTC (rev 14895)
+++
branches/community/3.3.X/docs/common-resources/en/src/main/xslt/collapsing-navigation.xsl 2009-07-10
15:52:18 UTC (rev 14896)
@@ -166,6 +166,7 @@
<xsl:template name="user.head.content">
<xsl:param name="node" select="." />
<script type="text/javascript"
src="script/jquery.js"><xsl:comment>If you see this message, your web
browser doesn't support JavaScript or JavaScript is
disabled.</xsl:comment></script>
+ <script type="text/javascript"
src="script/jquery.cookie.js"><xsl:comment>If you see this message,
your web browser doesn't support JavaScript or JavaScript is
disabled.</xsl:comment></script>
<script type="text/javascript"
src="script/toggle.js"><xsl:comment>If you see this message, your web
browser doesn't support JavaScript or JavaScript is
disabled.</xsl:comment></script>
</xsl:template>