diff options
Diffstat (limited to 'ishtar_common/static/js')
| -rw-r--r-- | ishtar_common/static/js/ishtar.js | 67 | 
1 files changed, 67 insertions, 0 deletions
| diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index 00a9b66a0..0f8b0cba2 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -417,3 +417,70 @@ function activate_own_search(){      });      return false;  } + +function get_label_from_input(input){ +    if (input.parent().filter('.input-group').length){ +        input = input.parent(); +    } +    return "<strong>" + input.prev().html() + "</strong>"; +} + + +function update_search_resume(){ +    var summary = ""; +    var inputs = $('#advanced-search-form input').map( +        function(){ +            var v = ""; +            var item_for_label = $(this); +            if ($(this).filter(":checkbox:checked").length){ +                var check = $(this).val(); +                if (check == "on"){ +                    v = YES; +                } else { +                    v = $(this).parent().first().contents().filter(function() { +                        return this.nodeType == 3; +                    }).text(); +                    item_for_label = $(this).parent().parent().parent(); +                } +            } else if ($(this).filter(":text").length){ +                v = $(this).val(); +            } else if ($(this).filter('input[type="number"]').length){ +                v = $(this).val(); +            } +            if (v == "") return; +            if (summary) summary += " ; "; +            summary += get_label_from_input(item_for_label) + " " + v; +        } +    ).get(); +    var selects = $('#advanced-search-form select').each( +        function(){ +            $(this).find('option').not(':first').filter(':selected').map( +                function(){ +                    var item_for_label = $(this).parent(); +                    if(item_for_label.filter('optgroup').length){ +                        item_for_label = item_for_label.parent(); +                    } +                    if (summary) summary += " ; "; +                    summary += get_label_from_input(item_for_label) + " " + $(this).text(); +            }); +        } +    ); + +    if (summary != ""){ +        $('#advanced-search-resume-content').html(summary); +        $('#advanced-search-resume').show(); +    } else { +        $('#advanced-search-resume').hide(); +    } +} + + +function register_advanced_search(){ +    $(".advanced-search-reset").click( +        function(){ +            document.getElementById('advanced-search-form').reset(); +            $('#advanced-search-resume').hide(); +        } +    ); +    $(".advanced-search-valid").click(update_search_resume); +} | 
