diff options
-rw-r--r-- | javascript/initialise_elgg.js | 97 | ||||
-rw-r--r-- | views/default/canvas/layouts/widgets.php | 8 | ||||
-rw-r--r-- | views/default/widgets/wrapper.php | 9 |
3 files changed, 88 insertions, 26 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; + } +}; diff --git a/views/default/canvas/layouts/widgets.php b/views/default/canvas/layouts/widgets.php index b73a5401d..a13b67679 100644 --- a/views/default/canvas/layouts/widgets.php +++ b/views/default/canvas/layouts/widgets.php @@ -236,9 +236,9 @@ Choose the features you want to add to your page by dragging them from the <b>Wi </div><!-- /#customise_page_view --> <form action="<?php echo $vars['url']; ?>action/widgets/reorder" method="post"> -<textarea type="textarea" value="Main widgets" style="display:none" name="debugField1" id="debugField1" /><?php echo $mainwidgetstring; ?></textarea> -<textarea type="textarea" value="Right widgets" style="display:none" name="debugField2" id="debugField2" /><?php echo $sidebarwidgetstring; ?></textarea> -<textarea type="textarea" value="Left widgets" style="display:none" name="debugField3" id="debugField3" /><?php echo $leftbarwidgetstring; ?></textarea> +<textarea type="textarea" value="Left widgets" style="display:none" name="debugField1" id="debugField1" /><?php echo $mainwidgetstring; ?></textarea> +<textarea type="textarea" value="Middle widgets" style="display:none" name="debugField2" id="debugField2" /><?php echo $sidebarwidgetstring; ?></textarea> +<textarea type="textarea" value="Right widgets" style="display:none" name="debugField3" id="debugField3" /><?php echo $leftbarwidgetstring; ?></textarea> <input type="hidden" name="context" value="<?php echo get_context(); ?>" /> <input type="hidden" name="owner" value="<?php echo page_owner(); ?>" /> @@ -290,7 +290,7 @@ Choose the features you want to add to your page by dragging them from the <b>Wi foreach($area1widgets as $widget) { echo elgg_view_entity($widget); } - + ?> </div><!-- /#widgets_left --> diff --git a/views/default/widgets/wrapper.php b/views/default/widgets/wrapper.php index 274f3f35d..4fc752af9 100644 --- a/views/default/widgets/wrapper.php +++ b/views/default/widgets/wrapper.php @@ -66,7 +66,7 @@ echo elgg_view("widgets/{$handler}/view",$vars);
?>
-
+ <script language="javascript">
$(document).ready(function(){
setup_avatar_menu();
@@ -85,7 +85,7 @@ ?>
</div><!-- /.collapsable_box_content -->
- </div><!-- /.collapsable_box -->
+ </div><!-- /.collapsable_box -->
</div>
<script type="text/javascript">
@@ -93,6 +93,11 @@ $(document).ready(function() { $("#widgetcontent<?php echo $vars['entity']->getGUID(); ?>").load("<?php echo $vars['url']; ?>pg/view/<?php echo $vars['entity']->getGUID(); ?>?shell=no&username=<?php echo page_owner_entity()->username; ?>&context=<?php echo get_context(); ?>&callback=true");
+ // run function to check for widgets collapsed/expanded state
+ var forWidget = "widget<?php echo $vars['entity']->getGUID(); ?>";
+ widget_state(forWidget);
+
+
});
</script>
|