diff --git a/CHANGES.txt b/CHANGES.txt index 7050129..630b9c7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -10,6 +10,13 @@ Changelog - Fixed conditional initialization of querywidget, see https://dev.plone.org/ticket/12529 [kroman0] +- The widget can now be hidden, when clicking on the + window or the widget. The event is only effective + when the widget is displayed. + [bosim] + +- Translations are now in Plone domain + [bosim] 1.0b2 (2012-03-19) ------------------ diff --git a/plone/formwidget/querystring/querywidget.js b/plone/formwidget/querystring/querywidget.js index 630cfde..de26667 100644 --- a/plone/formwidget/querystring/querywidget.js +++ b/plone/formwidget/querystring/querywidget.js @@ -223,6 +223,16 @@ $.get(query, {}, function (data) { $('.QueryWidget .previewresults').html(data); }); }; + /* Clicking outside a multipleSelectionWidget will close all open + multipleSelectionWidgets */ + $.querywidget.hideMultiSelectionWidgetEvent = function(event) { + if ($(event.target).parents('.multipleSelectionWidget').length) { + return; + } + $('.multipleSelectionWidget dd').hide(); + } + + // Enhance for javascript browsers $(document).ready(function () { @@ -274,6 +284,9 @@ $('#formfield-form-widgets-sort_on').hide(); $('#formfield-form-widgets-sort_reversed').hide(); + // Bind the event that listens on the window and hide the widget + $(window).bind('click', $.querywidget.hideMultiSelectionWidgetEvent); + }); // Init widget @@ -322,20 +335,16 @@ }); $('.multipleSelectionWidget dt').live('click', function () { - $(this).parent().children('dd').toggle(); - }); - - /* Clicking outside a multipleSelectionWidget will close all open - multipleSelectionWidgets */ - - $(window).click(function(event){ - if ($(event.target).parents('.multipleSelectionWidget').length) { - return; + var multiselectionwidget = $(this).parent().children('dd'); + if($(multiselectionwidget).is(':visible')) { + $(multiselectionwidget).hide(); + $(window).unbind('click', $.querywidget.hideMultiSelectionWidgetEvent); + } else { + $(multiselectionwidget).show(); + $(window).bind('click', $.querywidget.hideMultiSelectionWidgetEvent); } - $('.multipleSelectionWidget dd').hide(); }); - $('.queryindex').live('change', function () { var fname = $(this).closest('.QueryWidget').attr('data-fieldname'); var index = $(this).find(':selected')[0].value;