aboutsummaryrefslogtreecommitdiff
path: root/javascript
diff options
context:
space:
mode:
authorpete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-29 21:07:00 +0000
committerpete <pete@36083f99-b078-4883-b0ff-0f9b5a30f544>2008-07-29 21:07:00 +0000
commita4610b309edc583ec4f4b34fb8f8f712f898e5c2 (patch)
tree5779645df70110e906c7f5428d46d9c7a7b0e0b0 /javascript
parenta0f9057a19471da8c5e05a1d58a8c82c5f17a413 (diff)
downloadelgg-a4610b309edc583ec4f4b34fb8f8f712f898e5c2.tar.gz
elgg-a4610b309edc583ec4f4b34fb8f8f712f898e5c2.tar.bz2
individual widgets state now saved in cookies
git-svn-id: https://code.elgg.org/elgg/trunk@1587 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'javascript')
-rw-r--r--javascript/initialise_elgg.js97
1 files changed, 77 insertions, 20 deletions
diff --git a/javascript/initialise_elgg.js b/javascript/initialise_elgg.js
index 1ba222e0f..c8305b108 100644
--- a/javascript/initialise_elgg.js
+++ b/javascript/initialise_elgg.js
@@ -51,10 +51,15 @@ $(document).ready(function () {
stop: function(e,ui) {
// refresh list before updating hidden fields with new widget order
$(this).sortable( "refresh" );
- var widgetNameRight = outputWidgetList('#middlecolumn_widgets');
- var widgetNameMain = outputWidgetList('#leftcolumn_widgets');
- document.getElementById('debugField1').value = widgetNameMain;
- document.getElementById('debugField2').value = widgetNameRight;
+
+ var widgetNamesLeft = outputWidgetList('#leftcolumn_widgets');
+ var widgetNamesMiddle = outputWidgetList('#middlecolumn_widgets');
+ var widgetNamesRight = outputWidgetList('#rightcolumn_widgets');
+
+ document.getElementById('debugField1').value = widgetNamesLeft;
+ document.getElementById('debugField2').value = widgetNamesMiddle;
+ document.getElementById('debugField3').value = widgetNamesRight;
+
}
});
@@ -75,6 +80,10 @@ $(document).ready(function () {
accept: ".draggable_widget",
hoverClass: 'droppable-hover'
});
+
+
+
+
}); /* end document ready function */
@@ -116,6 +125,20 @@ function outputWidgetList(forElement) {
}
+// widget panel collapsed/expanded state
+function widget_state(forWidget) {
+
+ var thisWidgetState = $.cookie(forWidget);
+
+ if (thisWidgetState == 'collapsed') {
+
+ forWidget = "#" + forWidget;
+
+ $(forWidget).find("div.collapsable_box_content").hide();
+ $(forWidget).find("a.toggle_box_contents").html('+');
+ $(forWidget).find("a.toggle_box_edit_panel").fadeOut('medium');
+ };
+}
// toggle widget box contents
@@ -126,12 +149,21 @@ var toggleContent = function(e) {
$(this).html('-');
$(this.parentNode).children("[class=toggle_box_edit_panel]").fadeIn('medium');
+ // set cookie for widget panel open-state
+ var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
+ $.cookie(thisWidgetName, 'expanded', { expires: 365 });
+
+
} else {
targetContent.slideUp(400);
$(this).html('+');
$(this.parentNode).children("[class=toggle_box_edit_panel]").fadeOut('medium');
// make sure edit pane is closed
$(this.parentNode.parentNode).children("[class=collapsable_box_editpanel]").hide();
+
+ // set cookie for widget panel closed-state
+ var thisWidgetName = $(this.parentNode.parentNode.parentNode).attr('id');
+ $.cookie(thisWidgetName, 'collapsed', { expires: 365 });
}
return false;
};
@@ -139,21 +171,6 @@ var toggleContent = function(e) {
-// widget more info button
-function setupMoreInfoButton() {
- $('img.more_info').click(function () {
- // grab widget description from hidden field
- //var widgetdescription = $("input[@name='description']", this.parentNode.parentNode.parentNode ).attr('value');
-
- //document.getElementById('debugField3').value = widgetdescription;
-
- return false;
- });
-}
-
-
-
-
function widget_moreinfo() {
$("img.more_info").hover(function(e) {
@@ -189,7 +206,47 @@ function widget_moreinfo() {
};
-
+jQuery.cookie = function(name, value, options) {
+ if (typeof value != 'undefined') { // name and value given, set cookie
+ options = options || {};
+ if (value === null) {
+ value = '';
+ 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
+ }
+ // CAUTION: 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;
+ }
+};