diff --git a/invenio/modules/search/static/css/search/searchbar.css b/invenio/modules/search/static/css/search/searchbar.css index aca75033d..da4305552 100644 --- a/invenio/modules/search/static/css/search/searchbar.css +++ b/invenio/modules/search/static/css/search/searchbar.css @@ -1,118 +1,137 @@ /* * This file is part of Invenio. * Copyright (C) 2014 CERN. * * Invenio is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of the * License, or (at your option) any later version. * * Invenio is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Invenio; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #search-label { font-size: 14px; } +/* ----------------------- */ + +.nav.nav-pill-gray > .active > a, +.nav.nav-pill-gray > li > a:hover { + background: none; + text-decoration: underline; + color: inherit; +} + +/* line below the tab bar */ + +._tab-form-group { + border-bottom: 1px solid #e7e7e7; +} + +._tab-form-group .nav-tabs { + border-bottom: none; +} + /* -------------- */ /* to make "add to search" form look consistent in much shrinked window values copied from bootstrap ones for higher than xs size counterparts -> to be unified using "less" */ .navbar-collapse { border-top: none; } .navbar-collapse .navbar-nav.navbar-left:first-child { margin-left: -15px; } .navbar-form { padding-top: 0; padding-bottom: 0; margin-right: 0; margin-left: 0; border: 0; } /* ------------ */ .navbar-row { width: 100%; margin: inherit; } .navbar-row .navbar-row-container { /* same colour as navbar border*/ border-top: 1px solid #e7e7e7; padding-top: 20px; padding-bottom: 20px; } .navbar-collapse { max-height: none; } /* prevents thick (double) borders around buttons standing next to each other */ .input-group-btn > .btn + .btn, .input-group-btn > .btn { margin-left: -1px; } /* to prevent shrinking search field after applying typeahead */ .input-group .form-control { width: 100%; } /* too keep searchbar with buttons in one line */ @media (min-width: 768px) { /* ld size */ #searchform-input-group { width: 670px; } } @media (min-width: 992px) { /* md size */ #searchform-input-group { width: 710px; } } @media (min-width: 1200px) { /* ld size */ #searchform-input-group { width: 915px; } } /* showing dropdown stil as dropdown on shrinked window */ @media (max-width: 767px) { .navbar-nav .open .dropdown-menu { position: absolute; margin-top: 2px; background-color: #ffffff; border: 1px solid rgba(0, 0, 0, 0.15); box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175); } .navbar-default .navbar-nav .open .dropdown-menu > li > a { color: #333333; } -} \ No newline at end of file +} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/controls.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/controls.html index d386b925b..f93e91a8b 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/controls.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/controls_base.html" %} diff --git a/invenio/modules/search/templates/search/form/controls_base.html b/invenio/modules/search/templates/search/form/controls_base.html new file mode 100644 index 000000000..4eb14f058 --- /dev/null +++ b/invenio/modules/search/templates/search/form/controls_base.html @@ -0,0 +1,58 @@ +{# +## This file is part of Invenio. +## Copyright (C) 2014 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} + +{%- block search_form_ctrls_input -%} +<input autocomplete="off" + data-items="4" + name="p" + class="form-control" + type="text" + tabindex="1" + value="{{ request.args.get('p', '') }}" + {%- if request.endpoint == 'search.index' %} + autofocus + {%- endif -%}/> +{%- endblock -%} + +{%- block search_form_ctrls_settings -%} +<span class="input-group-btn invenio-collapsable-tabs" data-toggle="buttons"> + <a href="#" + class="btn btn-default right-not-rounded left-not-rounded" + data-toggle="collapse" + data-target="#navbar-bottom"> {# title=FIXME #} + <i class="glyphicon glyphicon-plus"></i> + <b class="caret"></b> + </a> + <a href="#" + class="btn btn-default right-not-rounded left-not-rounded" + data-toggle="collapse" + data-target="#navbar-bottom2"> {# title=FIXME #} + <i class="glyphicon glyphicon-cog"></i> + <b class="caret"></b> + </a> +</span> +{%- endblock -%} + +{%- block search_form_ctrls_button -%} +<span class="input-group-btn"> + <button name="action_search" type="submit" class="btn btn-primary btn-inline-icon-hide-sm"> + <i class="glyphicon glyphicon-search"></i><span> {{ _("Search") }}</span> + </button> +</span> +{%- endblock -%} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/dropdown.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/dropdown.html index d386b925b..e20b3baec 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/dropdown.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/dropdown_base.html" %} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/dropdown_base.html similarity index 55% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/dropdown_base.html index d386b925b..447b0d83f 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/dropdown_base.html @@ -1,20 +1,36 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{%- from "search/helpers.html" import search_box with context -%} + +{%- block search_form_dropbox_boxes -%} +<div class="nav navbar-nav navbar-row"> + <div id="navbar-bottom" class="collapse"> + <div class="row navbar-row-container"> + <div class="col-md-12"> + {# This is done using document.write to hide it from non-JS users #} + <script type="text/javascript"> + var box = {{ search_box(collection, easy_search_form)|tojson|safe }}; + document.write(box); + </script> + </div> + </div> + </div> +</div> +{%- endblock -%} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/form.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/form.html index d386b925b..1e6b9e26e 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/form.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/form_base.html" %} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/form_base.html similarity index 52% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/form_base.html index d386b925b..067672f55 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/form_base.html @@ -1,20 +1,35 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{# Collect the nav links, forms, and other content for toggling #} +<form action="{{ url_for('search.search') }}" method="get" role="search" id="searchform"> +{%- block search_form_ctrls -%} + <input type="hidden" name="ln" value="{{g.ln}}"> + {%- if collection.id > 1 %} + <input type="hidden" name="cc" value="{{collection.name}}"> + {%- endif %} + <div class="nav navbar-nav navbar-left navbar-form"> + <div class="input-group" id="searchform-input-group"> + {% include "search/form/tips.html" %} + {% include "search/form/controls.html" %} + </div> + </div> +{%- endblock -%} + {% include "search/form/dropdown.html" %} +</form> diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/index.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/index.html index d386b925b..c0a99f6ea 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/index.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/index_base.html" %} diff --git a/invenio/modules/search/templates/search/form/index_base.html b/invenio/modules/search/templates/search/form/index_base.html new file mode 100644 index 000000000..02ca3c528 --- /dev/null +++ b/invenio/modules/search/templates/search/form/index_base.html @@ -0,0 +1,48 @@ +{# +## This file is part of Invenio. +## Copyright (C) 2014 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} + +{%- block search_form -%} +{%- block search_form_body -%} + +<div id="search-box-main" class="row"> + <div class="col-sm-12"> + <div class="navbar navbar-default"> + {% include "search/form/text.html" %} + {%- block search_form_form -%} + <div class="navbar-collapse"> + {% include "search/form/form.html" %} + {% include "search/form/settings.html" %} + </div> + {%- endblock search_form_form -%} + </div> + </div> +</div> +{%- block search_form_flashed_messages -%} +{%- for category, msg in get_flashed_messages(with_categories=True, + category_filter=['websearch-after-search-form']) %} +<div class="row"> + <div class="col-md-12"> + {{ msg|safe }} + </div> +</div> + {%- endfor %} +{%- endblock search_form_flashed_messages -%} + +{%- endblock search_form_body -%} +{%- endblock search_form -%} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/settings.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/settings.html index d386b925b..2c75eddaa 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/settings.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/settings_base.html" %} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/settings_base.html similarity index 68% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/settings_base.html index d386b925b..31cede2de 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/settings_base.html @@ -1,20 +1,30 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% from "search/helpers.html" import searchsettings_form with context %} + +<div class="nav navbar-nav navbar-row"> + <div id="navbar-bottom2" class="collapse"> + <div class="row navbar-row-container"> + <div class="col-md-12"> + {{ searchsettings_form(collection) }} + </div> + </div> + </div> +</div> diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/text.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/text.html index d386b925b..269a1f2c7 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/text.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/text_base.html" %} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/text_base.html similarity index 62% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/text_base.html index d386b925b..b0db029b6 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/text_base.html @@ -1,20 +1,31 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{%- block search_form_text -%} +{# Brand and toggle get grouped for better mobile display #} +{%- set nbrecs = collection.nbrecs -%} +{%- if not collection.nbrecs -%} + {%- set nbrecs = 0 -%} +{%- endif -%} +<div class="navbar-header"> + <span class="navbar-brand hidden-sm hidden-xs" id="search-label"> + {{- _("Search %(x_num)s records for", x_num=nbrecs) -}} + </span> +</div> +{%- endblock search_form_text -%} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/form/tips.html similarity index 90% copy from invenio/modules/search/templates/search/helpers.html copy to invenio/modules/search/templates/search/form/tips.html index d386b925b..705d68a57 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/form/tips.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{% extends "search/form/tips_base.html" %} diff --git a/invenio/modules/search/templates/search/form/tips_base.html b/invenio/modules/search/templates/search/form/tips_base.html new file mode 100644 index 000000000..51042fe87 --- /dev/null +++ b/invenio/modules/search/templates/search/form/tips_base.html @@ -0,0 +1,58 @@ +{# +## This file is part of Invenio. +## Copyright (C) 2014 CERN. +## +## Invenio is free software; you can redistribute it and/or +## modify it under the terms of the GNU General Public License as +## published by the Free Software Foundation; either version 2 of the +## License, or (at your option) any later version. +## +## Invenio is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with Invenio; if not, write to the Free Software Foundation, Inc., +## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. +#} + +{%- block search_form_ctrls_help -%} +<span class="input-group-btn"> + <a class="dropdown-toggle btn btn-default" + rel="tooltip" title="{{ _('Search Tips and Examples') }}" + data-placement="bottom" + data-delay="100" + data-toggle="dropdown" role="button" + href="#"><i class="glyphicon glyphicon-question-sign"></i> + </a> + <ul class="searchexamples dropdown-menu"> + <li> + <a href="/help/search-tips"> + <strong>{{ _("Search Tips") }}</strong> + <i class="pull-right glyphicon glyphicon-info-sign"></i> + </a> + </li> + <li> + <a href="/help/search-guide"> + <i class="pull-right glyphicon glyphicon-leaf"></i> + <strong>{{ _("Search Guide") }}</strong> + </a> + </li> +{%- if collection.examples %} + <li class="divider"></li> + <li class="dropdown-header"> + {{ _('Search examples') }} + </li> + {%- for e in collection.examples if e.body %} + <li> + <a href="{{ url_for('search.search', p=e.body) }}"> + <i class="pull-right glyphicon glyphicon-chevron-right"></i> + <span class="after-fix">{{ e.body }}</span> + </a> + </li> + {%- endfor %} +{%- endif %} + </ul> +</span> +{%- endblock search_form_ctrls_help-%} diff --git a/invenio/modules/search/templates/search/helpers.html b/invenio/modules/search/templates/search/helpers.html index d386b925b..b1819342e 100644 --- a/invenio/modules/search/templates/search/helpers.html +++ b/invenio/modules/search/templates/search/helpers.html @@ -1,20 +1,20 @@ {# ## This file is part of Invenio. -## Copyright (C) 2012, 2013 CERN. +## Copyright (C) 2012, 2013, 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% extends "search/helpers_base.html" %} \ No newline at end of file +{%- extends "search/helpers_base.html" -%} diff --git a/invenio/modules/search/templates/search/helpers_base.html b/invenio/modules/search/templates/search/helpers_base.html index 40fc7a94c..d4f8b8d03 100644 --- a/invenio/modules/search/templates/search/helpers_base.html +++ b/invenio/modules/search/templates/search/helpers_base.html @@ -1,928 +1,756 @@ {# ## This file is part of Invenio. ## Copyright (C) 2012, 2013, 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} {% macro record_brief_links(record) %}{% block record_brief_links scoped %} <p> {%- set recID = record['recid'] -%} {%- set i = recID %} {%- set similar = "recid:%s" % recID -%} {%- if config.CFG_WEBSEARCH_USE_ALEPH_SYSNOS -%} {%- set alephsysnos = record['system_number'] -%} {%- if len(alephsysnos) > 0 -%} {%- set recID = alephsysnos[0] -%} {%- set similar = "sysno:%d" % recID -%} {%- endif -%} {%- endif -%} {% block record_brief_links_details scoped %} <a class="text-success" data-hotkey-action="click" data-hotkey-value="g{{ i }}v" href="{{ url_for('record.metadata', recid=recID) }}"> {{ _("Detailed record") }} </a> - <a class="text-success" data-hotkey-action="click" data-hotkey-value="g{{ i }}s" href="{{ url_for('search.search', p=similar, rm='wrd') }}"> {{ _("Similar records") }} </a> {% endblock record_brief_links_details %} {# Citations link #} {% block record_brief_links_citations scoped %} {%- if config.CFG_BIBRANK_SHOW_CITATION_LINKS -%} {%- set num_citations = record['_cited_by_count'] -%} {%- if num_citations -%} - <a href="{{ url_for('search.search', p="refersto:recid:%d" % recID) }}" data-hotkey-action="click" data-hotkey-value="g{{ i }}r"> {{ _("Cited by %(x_num)i records", x_num=num_citations) if num_citations > 1 else _("Cited by 1 record") }} </a> {%- endif -%} {%- endif -%} {% endblock record_brief_links_citations %} {# Comments link #} {% block record_brief_links_comments scoped %} {%- if config.CFG_WEBCOMMENT_ALLOW_COMMENTS and config.CFG_WEBSEARCH_SHOW_COMMENT_COUNT -%} {%- set num_comments = record['_number_of_comments'] -%} {%- if num_comments -%} - <a href="{{ url_for('comments.comments', recid=recID) }}" data-hotkey-action="click" data-hotkey-value="g{{ i }}c"> <i class="glyphicon glyphicon-comment"></i> {{ _("%(x_num)i comments", x_num=num_comments) if num_comments > 1 else _("1 comment") }} </a> {%- endif -%} {%- endif -%} {% endblock record_brief_links_comments %} {# Reviews link #} {% block record_brief_links_reviews scoped %} {%- if config.CFG_WEBCOMMENT_ALLOW_REVIEWS and config.CFG_WEBSEARCH_SHOW_REVIEW_COUNT -%} {%- set num_reviews = record['_number_of_reviews'] -%} {%- if num_reviews -%} - <a href="{{ url_for('comments.reviews', recid=recID) }}"> <i class="glyphicon glyphicon-eye-open"></i> {{ _("%(x_num)i reviews", x_num=num_reviews) if num_reviews > 1 else _("1 review") }} </a> {%- endif -%} {%- endif -%} {% endblock record_brief_links_reviews %} </p> {% endblock record_brief_links %}{% endmacro %} {%- macro collection_tree(collections, limit=None) %} {%- set macrokwargs = kwargs %} {%- block collection_tree scoped %} {%- set idxs = [0] -%} <ul {{ macrokwargs|xmlattr }}> {% for collection in collections recursive %} <li> {# Do not show checkboxes in new UI {% if idxs|length == 1 %} <input type="checkbox" name="c" value="{{ collection.name }}" checked/> {% endif %} #} <a href="{{ url_for(".collection", name=collection.name, ln=g.ln, _external=True) }}"> {{ collection.name_ln }} </a> <small class="text-muted">({{ collection.nbrecs }})</small> {% if collection.collection_children and idxs|length < limit %} {%- do idxs.append(loop.index) -%} <ul {{ macrokwargs|xmlattr }}> {{ loop(collection.collection_children) }} </ul> {%- do idxs.pop() -%} {% endif %} </li> {% endfor %} </ul> {% endblock collection_tree %} {% endmacro %} {% macro portalbox_sidebar(portalboxes, width=2) %}{% set macrokwargs = kwargs %}{% block portalbox_sidebar scoped %} {% if portalboxes %} <div {{ macrokwargs|xmlattr }}> {% for cp in portalboxes %} <div class="panel panel-default"> <div class="panel-body"> <h5>{{ cp.portalbox.title }}</h5> <p>{{ cp.portalbox.body|safe }}</p> </div> </div> {% endfor %} </div> {% endif %} {% endblock portalbox_sidebar %}{% endmacro %} {% macro search_also(externalcollections) %}{% block search_also scoped %} {% if externalcollections %} <h4>{{ _("Search also:") }}</h4> <ul> {% for ex in externalcollections %} <li>{{ ex.name }} <a href="{{ ex.engine.base_url}}"> <img src="{{ url_for("static", filename="img/external-icon-light-8x8.gif")}}" alt="{{ ex.engine.base_url }}"/> </a></li> {% endfor %} </ul> {% endif %} {% endblock search_also %}{% endmacro %} {% macro _search_hidden_options() %} {%- for name in ['rg', 'of', 'so', 'sf', 'rm'] -%} {%- if request.args.get(name) -%} <input type="hidden" name="{{ name }}" value="{{ request.args.get(name, '') }}" /> {%- endif -%} {%- endfor -%} {% endmacro %} {% macro _search_simple_box(collection, easy_search_form) %} {% block _search_simple_box scoped %} {% for f in easy_search_form if not f.name=='csrf_token' %} <div class="form-group"> <label class="col-md-2 col-sm-3 control-label" for="{{ f.label.field_id }}"> {{ f.label.text }} </label> <div class="col-md-10 col-sm-9"> {{ f(class_='form-control') }} </div> </div> {% endfor %} <div class="form-group"> <div class="col-md-offset-2 col-md-10 col-sm-offset-3 col-sm-9"> <div class="pull-right"> <button name="action_browse" class="btn"> <i class="glyphicon glyphicon-list"></i> {{ _("Browse") }} </button> <button name="action_search" type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-search"></i> {{ _("Search") }} </button> </div> </div> </div> {% endblock _search_simple_box %} {% endmacro %} {% macro _search_advanced_box(collection) %} {% block _search_advanced_box scoped %} <div class="form-group"> <label class="col-sm-3 col-md-2 control-label" for="p1"> {{ _('what') }}? </label> <div class="col-sm-9 col-md-10"> <input type="text" id="p1" name="p1" value="" class="form-control"/> </div> </div> <div class="form-group"> <label class="col-sm-3 col-md-2 control-label" for="p2"> {{ _('where') }}? </label> <div class="col-sm-9 col-md-10"> <select class="form-control" id="p2" name="f"> {% for (code, name) in collection.search_within %} <option value="{{ code }}"> {{ name }} </option> {% endfor %} </select> </div> </div> <div class="form-group"> <label class="col-sm-3 col-md-2 control-label" for="m1"> {{ _('how') }}? </label> <div class="col-sm-9 col-md-10"> <select name="m1" id="m1" class="form-control"> {%- for v in config.CFG_WEBSEACH_MATCHING_TYPES|sort(attribute='order') -%} <option value="{{ v.code }}">{{ _(v.title)|safe }}</option> {%- endfor -%} </select> </div> </div> {% for id, soo in collection.search_options|groupby('id_field') %} <hr/> <div class="form-group"> <label class="control-label col-sm-3 col-md-2" for="{{ soo[0].field.code }}"> {{- soo[0].field.name_ln -}} </label> <div class="col-sm-9 col-md-10"> <div class="input-group"> <select class="form-control" id="{{ soo[0].field.code }}" name="{{ soo[0].field.code }}"> <option value="">*** {{ _('select') }} ***</option> {% for so in soo %} <option value="{{ so.fieldvalue.value }}"> {{ so.fieldvalue.name }} </option> {% endfor %} </select> <span data-target="p" data-source="{{ soo[0].field.code }}" class="btn appender"> <i class="glyphicon glyphicon-ok"></i> </span> </div> </div> </div> {% endfor %} <div class="form-group"> <div class="col-md-offset-2 col-md-10 col-sm-offset-3 col-sm-9"> <div class="pull-left"> <button id="add_to_search-button" class="btn"> <i class="glyphicon glyphicon-plus"></i> {{ _("Add to search") }} </button> </div> <div class="pull-right"> <button name="action_browse" class="btn"> <i class="glyphicon glyphicon-list"></i> {{ _("Browse") }} </button> <button name="action_search" type="submit" class="btn btn-primary"> <i class="glyphicon glyphicon-search"></i> {{ _("Search") }} </button> </div> </div> </div> {% endblock _search_advanced_box %} {% endmacro %} {% macro search_box(collection, easy_search_form) %} {% block search_box scoped %} <div class="form-horizontal add_to_search-form"> <div class="form-group _tab-form-group"> <label class="col-sm-3 col-md-2 control-label"> {{ _('Add to search') }} </label> <div class="col-md-10 col-sm-9" data-toggle="buttons"> <div class="btn-group pull-left" id="add_type-btn-group" data-toggle="buttons"> <label class="btn btn-sm btn-default active"> <input type="radio" name="op1" value="a" active/>{{ _('AND') }} </label> <label class="btn btn-sm btn-default"> <input type="radio" name="op1" value="o"/>{{ _('OR') }} </label> <label class="btn btn-sm btn-default"> <input type="radio" name="op1" value="n"/>{{ _('AND NOT') }} </label> </div> <div class="pull-right"> <ul class="nav nav-tabs pull-right tab-buttons"> <li class="active"> <a href="#simple-search" id="simple-search-tab-button" data-toggle="tab">{{ _('simple') }}</a> </li> <li> <a href="#advanced-search" id="advanced-search-tab-button" data-toggle="tab">{{ _('advanced') }}</a> </li> </ul> </div> </div> </div> <div class="tab-content"> <div class="tab-pane active" id="simple-search"> {{ _search_simple_box(collection, easy_search_form) }} </div> <div class="tab-pane" id="advanced-search"> {{ _search_advanced_box(collection) }} </div> </div> </div> - -<style> -.nav.nav-pill-gray > .active > a, -.nav.nav-pill-gray > li > a:hover { - background: none; - text-decoration: underline; - color: inherit; -} - -/* line below the tab bar */ - -._tab-form-group { - border-bottom: 1px solid #e7e7e7; -} - -._tab-form-group .nav-tabs { - border-bottom: none; -} - -/* ----------------------- */ - - -</style> {% endblock search_box %} {% endmacro %} {% macro searchsettings_form(collection) %} {% block searchsettings_form scoped %} <form action="{{ url_for('search.search') }}" name="settings" method="get" class="form-horizontal"> <div class="row"> <input name="p" value="{{ request.args.get('p','') }}" type="hidden" /> <div class="form-group col-md-6"> <label class="control-label col-sm-6 col-xs-5">{{ _('Display on page') }}</label> <div class="col-sm-6 col-xs-7"> <select name="rg" class="btn-sm form-control"> {%- for i in [10, 25, 50, 100, 250, 500] -%} {%- if i <= config.CFG_WEBSEARCH_MAX_RECORDS_IN_GROUPS -%} <option value="{{ i }}"{{ ' selected' if request.args.get('rg',10)==i.__str__() }}>{{ i }} {{ _('results') }}</option> {%- endif -%} {%- endfor -%} </select> </div> </div> <div class="form-group col-md-6"> <label class="control-label col-sm-6 col-xs-5">{{ _('Output format') }}</label> <div class="col-sm-6 col-xs-7"> <select name="of" class="btn-sm form-control"> {%- for i in collection.formatoptions if i.content_type == 'text/html' and i.visibility == 1 -%} <option value="{{ i.code }}"{{ ' selected' if request.args.get('of','hb')==i.code }}>{{ i.name }}</option> {%- endfor -%} </select> </div> </div> {% if collection.rnkMETHODs|length %} <div class="form-group col-md-6"> <label class="control-label col-sm-6 col-xs-5">{{ _('Ranking') }}</label> <div class="btn-group col-sm-6 col-xs-7"> <select name='rm' class="btn-xs form-control"> {% for rnk_method in collection.rnkMETHODs %} <option value="{{ rnk_method.rnkMETHOD.name }}"> {{ rnk_method.rnkMETHOD.get_name_ln() }} </option> {% endfor %} </select> </div> </div> {% endif %} <div class="form-group col-md-6"> <label class="control-label col-sm-6 col-xs-5">{{ _('Sort by most') }}</label> <div class="btn-group col-sm-6 col-xs-7" data-toggle="buttons"> {%- for (k,v,vv) in [('recent', 'rm', ''), ('cited', 'rm', 'citation'), ('relevant', 'rm', 'wrd')] -%} <label class="btn btn-sm btn-default {{ 'active' if request.args.get(v,'') == vv}}"> <input type="radio" name="{{ v }}" value="{{ vv }}" {{ 'checked="checked"'|safe if request.args.get(v,'') == vv}}> {{ _(k) }} </label> {%- endfor -%} </div> </div> <div class="form-group col-md-6"> <label class="col-sm-6 control-label col-xs-5">{{ _('Search form') }}</label> <div class="btn-group col-sm-6 col-xs-7" data-toggle="buttons"> {%- for (k,v) in [(_('Simple'), 'simple'), (_('Advanced'), 'advanced')] -%} {%- set active = v=='simple' -%} <label class="btn btn-sm btn-default"> <input type="radio" name="box" value="{{ v }}" {{ 'checked="checked"'|safe if active}}> {{ k }} </label> {%- endfor -%} </div> </div> </div> <div class="form-group col-md-6 pull-right"> {%- if not current_user.is_guest -%} <button name="action_save" rel="tooltip" title="{{ _('store permanently in user settings') }}" data-placement="bottom" class="btn btn-primary btn-sm pull-left"> <i class="glyphicon glyphicon-hdd"></i> {{ _('Save') }} </button> {%- endif -%} <button name="action_search" rel="tooltip" title="{{ _('use settings in current search') }}" data-placement="bottom" class="btn btn-sm pull-right"> <i class="glyphicon glyphicon-ok"></i> {{ _('Apply') }} </button> </div> </form> {% endblock searchsettings_form %}{% endmacro %} -{% macro search_form(collection, easy_search_form) %}{% block search_form scoped %} -{%- block search_form_body scoped %} - <div id="search-box-main" class="row"> - <div class="col-sm-12"> - <nav class="navbar navbar-default" role="navigation"> - {% block search_form_text scoped %} - <!-- Brand and toggle get grouped for better mobile display --> - <div class="navbar-header"> - <span class="navbar-brand hidden-sm hidden-xs" id="search-label"> - {%- set nbrecs = collection.nbrecs -%} - {%- if not collection.nbrecs -%} - {%- set nbrecs = 0 -%} - {%- endif -%} - {{ _("Search %(x_num)s records for", x_num=nbrecs) }} - </span> - </div> - {% endblock search_form_text %} - - - <!-- Collect the nav links, forms, and other content for toggling --> - {% block search_form_form scoped %} - <div class="navbar-collapse"> - <form action="{{ url_for('search.search') }}" - name="search" - method="get" - role="search" - id="searchform"> - {% block search_form_ctrls scoped %} - <input type="hidden" name="ln" value="{{g.ln}}"> - {% if collection.id > 1 %} - <input type="hidden" name="cc" value="{{collection.name}}"> - {% endif %} - <div class="nav navbar-nav navbar-left navbar-form"> - <div class="input-group" id="searchform-input-group"> - {% block search_form_ctrls_help scoped %} - <span class="input-group-btn"> - <a class="dropdown-toggle btn btn-default" - rel="tooltip" title="{{ _('Search Tips and Examples') }}" - data-placement="bottom" - data-delay="100" - data-toggle="dropdown" role="button" - href="#"><i class="glyphicon glyphicon-question-sign"></i> - </a> - <ul class="searchexamples dropdown-menu"> - <li> - <a href="/help/search-tips"> - <strong>{{ _("Search Tips") }}</strong> - <i class="pull-right glyphicon glyphicon-info-sign"></i> - </a> - </li> - <li> - <a href="/help/search-guide"> - <i class="pull-right glyphicon glyphicon-leaf"></i> - <strong>{{ _("Search Guide") }}</strong> - </a> - </li> - {% if collection.examples %} - <li class="divider"></li> - <li class="dropdown-header"> - {{ _('Search examples') }} - </li> - {%- for e in collection.examples if e.body -%} - <li> - <a href="{{ url_for('search.search', p=e.body) }}"> - <i class="pull-right glyphicon glyphicon-chevron-right"></i> - <span class="after-fix">{{ e.body }}</span> - </a> - </li> - {%- endfor -%} - {% endif %} - </ul> - </span> - {% endblock search_form_ctrls_help %} - {% block search_form_ctrls_input scoped %} - <input autocomplete="off" - data-items="4" - name="p" - class="form-control" - type="text" - {# placeholder="{{ _('Example') }}: {{ search_placeholder }}" #} - tabindex="1" - value="{{ request.args.get('p', '') }}" - {%- if request.endpoint == 'search.index' %} - autofocus - {%- endif -%} - />{% endblock search_form_ctrls_input %}{# No space! #} - {% block search_form_ctrls_settings scoped %}<span class="input-group-btn invenio-collapsable-tabs" data-toggle="buttons"> - <a href="#" class="btn btn-default right-not-rounded left-not-rounded" data-toggle="collapse" data-target="#navbar-bottom"> - <i class="glyphicon glyphicon-plus"></i> - <b class="caret"></b> - </a> - <a href="#" class="btn btn-default right-not-rounded left-not-rounded" data-toggle="collapse" data-target="#navbar-bottom2"> - <i class="glyphicon glyphicon-cog"></i> - <b class="caret"></b> - </a> - </span> - {% endblock search_form_ctrls_settings %} - {% block search_form_ctrls_button scoped %} - <span class="input-group-btn"> - <button name="action_search" type="submit" class="btn btn-primary btn-inline-icon-hide-sm"> - <i class="glyphicon glyphicon-search"></i><span> {{ _("Search") }}</span> - </button> - </span> - {% endblock search_form_ctrls_button %} - </div> - </div> - {% endblock search_form_ctrls %} - {% block search_form_dropdown_boxes scoped %} - <div class="nav navbar-nav navbar-row"> - <div id="navbar-bottom" class="collapse"> - <div class="row navbar-row-container"> - <div class="col-md-12"> - <script type="text/javascript"> - var box = {{ search_box(collection, easy_search_form)|tojson|safe }}; - document.write(box); - </script> - </div> - </div> - </div> - </div> - {% endblock search_form_dropdown_boxes %} - </form> - {% block search_form_settings scoped %} - <div class="nav navbar-nav navbar-row"> - <div id="navbar-bottom2" class="collapse"> - <div class="row navbar-row-container"> - <div class="col-md-12"> - {{ searchsettings_form(collection) }} - </div> - </div> - </div> - </div> - {% endblock search_form_settings %} - </div><!-- /.navbar-collapse --> - {% endblock search_form_form %} - </nav> - </div> - </div> - {% for category, msg in get_flashed_messages(with_categories=True, category_filter=['websearch-after-search-form']) %} - <div class="row"> - <div class="col-md-12"> - {{ msg|safe }} - </div> - </div> - {% endfor %} -{%- endblock search_form_body %} -{% endblock search_form %}{% endmacro %} - - {% macro search_form_javascript(collection) %}{% block search_form_javascript %} <script> $(function () { $("form[name=search]").submit(function() { $('.add_to_search-form').remove(); return true; // ensure form still submits }) // side buttons for results number field $('form[name=settings] select[name="of"]').buttonSelect({ button: '<div class="btn btn-sm btn-default" />' , span: '<span class="btn btn-sm btn-default" style="width: 100px;" />' , next: '<i class="glyphicon glyphicon-chevron-right"></i>' , prev: '<i class="glyphicon glyphicon-chevron-left"></i>' }) // side buttons for output format field $('form[name=settings] select[name="rg"]').buttonSelect({ button: '<div class="btn btn-sm btn-default" />' , span: '<span class="btn btn-sm btn-default" style="width: 100px;" />' , next: '<i class="glyphicon glyphicon-plus"></i>' , prev: '<i class="glyphicon glyphicon-minus"></i>' }) // if (!("autofocus" in $("form[name=search] input[name=q]"))) { // // ensure we get the focus always in search input // $("form[name=search] input[name=q]").focus(); // } //-------------------- /** * Allows to deactivate a radio buttons (like check-buttons) * and make them behave as radio ones when the another one is clicked * * @method radio_checkbox_hybrid * @param radioButtons jQuerySelector for all the buttons in a group */ var radio_checkbox_hybrid = function (radioButtons) { radioButtons.click(function () { var buttons = $(this).siblings(); if (buttons.hasClass("active")) { buttons.click(); } }); } radio_checkbox_hybrid($(".invenio-collapsable-tabs a")) //--------------------- var op1_fn = {'a': 'AND ', 'o': 'OR ', 'n': 'AND NOT '}, m1_fn = { {%- for v in config.CFG_WEBSEACH_MATCHING_TYPES -%} '{{ v.code }}': function(val, f) { {{ v.tokenize|safe }} }{{ ',' if not loop.last }} {%- endfor -%} }; // the visible search field var $search_query_field = $('form[name=search] input[name=p]'); // all fields containg search query, there are some hidden ones too var $all_search_query_fields = $('[name=p]'); /** * Sets value of the main search field. Should be used * instead of jQuery's val() to update typeahead's * internal query. * * @method setSearchFieldValue * @param {String} val value to be set */ function setSearchFieldValue(val) { $search_query_field.data('search_typeahead').setFieldValue(val); $all_search_query_fields.val(val); } /** * Merges value from 'advanced' tab in 'Add to search' form * with the current search query * * @method addAdvancedQuery * @returns {String} search query after adding the form content */ function getAdvancedQuery() { var m1 = $('[name=m1]').val(), p1 = $('[name=p1]').val(), f = $('[name=f]').val(), p = $('[name=p]'); if (p1 === "") { return ''; } if (f !== "") { f +=':'; } return m1_fn[m1](p1,f); }; /** * Removes query value from 'what?' field in 'advanced' tab * * @method cleanAdvancedQuery */ function cleanAdvancedQueryForm() { $('[name=p1]').val(''); } /** * Creates search query from 'simple' tab in 'Add to search' form * * @method getSimpleQuery * @returns {String} query from the form content * */ function getSimpleQuery() { var query_str = ''; // get values var p = $('[name=p]'), op1 = $('#add_type-btn-group .active').children(':first').val(), author = $('#author').val(), title = $('#title').val(), rn = $('#rn').val(), aff = $('#aff').val() cn = $('#cn').val(), k = $('#k').val(), //eprinttype = $('#eprint-type').val(), //eprintnumber = $('#eprint-number').val(), j = $('#journal-name').val(), jvol = $('#journal-vol').val(), jpage = $('#journal-page').val(); // filter and build var query = []; if (author !== '') { query.push('author:' + author); } if (title !== '') { query.push('title:' + title); } if (rn !== '') { query.push('reportnumber:' + rn); } if (aff !== '') { query.push('affiliation:' + aff); } if (cn !== '') { query.push('collaboration:' + cn); } if (k !== '') { query.push('keyword:' + k); } if (j !== '') { query.push('journal:' + j); } if (jvol !== '') { query.push('909C4v:' + jvol); } if (jpage !== '') { query.push('909C4c:' + jpage); } if (query.length > 0) { query_str = query.join(' '+op1_fn[op1]) } return query_str; }; /** * Adds query from 'advanced' tab to the search field * * @method addAdvancedQueryToSearch */ function addAdvancedQueryToSearch() { var current_query = $.trim($search_query_field.val()); var new_part = getAdvancedQuery(); cleanAdvancedQueryForm(); setSearchFieldValue(mergeQuery(current_query, new_part)); } /** * Merges new part to old query using currently * chosen logic function * * @method mergeQuery * @param {String} old_query old query * @param {String} new_part a string which user is going to merge */ function mergeQuery(current_query, new_part) { var op1 = $('#add_type-btn-group .active').children(':first').val(); var op = (op1=='a' && current_query=="")?'':op1_fn[op1]; if (current_query !== "" && new_part !== "") { current_query += ' ' + op; } return current_query + new_part; } /** * Updates query value in the search field * * @method makeSearchQuery */ function makeSearchQuery() { var active_tab = $('.add_to_search-form .tab-buttons li.active a').attr('href'); if (active_tab === '#simple-search') { var current_query = $.trim($search_query_field.val()); var new_part = getSimpleQuery(); setSearchFieldValue(mergeQuery(current_query, new_part)); } else { addAdvancedQueryToSearch(); $('.add_to_search-form .appender').trigger('click'); } } // search buttons $('.add_to_search-form button[name=action_search]').on('click', function(e) { makeSearchQuery(); e.stopPropagation(); }); // browse buttons $('.add_to_search-form button[name=action_browse]').on('click', function(e) { makeSearchQuery(); var $main_search_button = $('#searchform-input-group button[name=action_search]'); $main_search_button.attr('name', 'action_browse'); $main_search_button.trigger('click'); }); $('#add_to_search-button').on('click', function(e) { addAdvancedQueryToSearch(); return false; }); $('.add_to_search-form #advanced-search [name=p1]').keypress(function(event) { // on 'return' key if ( event.which == 13 ) { addAdvancedQueryToSearch(); return false; } }); $('.add_to_search-form #advanced-search .appender').on('click', function(e) { var op1 = $('#add_type-btn-group .active').children(':first').val(), btn = $(this), source = $('[name='+btn.attr('data-source')+']'), target = $('[name='+btn.attr('data-target')+']'), val = $.trim(target.val()), op = (op1=='a' && val=="")?'':op1_fn[op1]; if (val !== "") { val += ' ' + op; } if (source.val() === "") { return false } if (source.val().length > 0) { target.val(val+source.attr('name')+':"'+source.val()+'"'); source.val(''); } e.stopPropagation(); return false; }); // -------------- SEARCH FIELD TYPEAHEAD ---------------- var searchField = $('form[name=search] input[name=p]'); var area_keywords = $.map({{ collection.search_within[1:]|tojson|safe }}, function(val, i) { return val[0]; } ); {%- for id, soo in collection.search_options|groupby('id_field') -%} area_keywords.push('{{ soo[0].field.code }}:'); {%- endfor -%} {% block searchfield_typeahead_configuration %} var parser_options = getDefaultParserConf(area_keywords); searchField.searchTypeahead({ value_hints_url: '/list/%TYPE?q=%QUERY', options_sets: { invenio: parser_options }, default_set: 'invenio' }); {% endblock searchfield_typeahead_configuration %} // END -------------- SEARCH FIELD TYPEAHEAD -------------- END // ------------ typeahead for "Add to search" form ---------------- $('[data-provide="typeahead-url"]').each(function (i, field) { var $field = $(field); var engine = new Bloodhound({ datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.value); }, queryTokenizer: Bloodhound.tokenizers.whitespace, limit: 10, remote: { url: $field.data('source'), replace: function(url, query) { return url + '?q=' + query; }, filter: function(response) { return response.results; } } }); engine.initialize(); $field.typeahead({ minLength: 3 }, { source: engine.ttAdapter(), displayKey: 'value' }); }); // --------------------------------------------------------------- }); </script> {% endblock search_form_javascript %}{% endmacro %} diff --git a/invenio/modules/search/templates/search/searchbar_frame.html b/invenio/modules/search/templates/search/searchbar_frame.html index cd36f0318..015e607fd 100644 --- a/invenio/modules/search/templates/search/searchbar_frame.html +++ b/invenio/modules/search/templates/search/searchbar_frame.html @@ -1,54 +1,48 @@ {# ## This file is part of Invenio. ## Copyright (C) 2012, 2014 CERN. ## ## Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. #} -{% from "_formhelpers.html" import render_filter_form with context %} -{% from "search/helpers.html" import collection_tree, portalbox_sidebar, search_also, search_form, search_form_javascript, record_brief_links with context %} +{% from "search/helpers.html" import search_form_javascript with context %} {% extends "page.html" %} {# set title = collection.name_ln if collection.id > 1 else None #} {% block header %} {{ super() }} {%- js url_for('static', filename='js/jquery-caret.js') -%} {%- js url_for('static', filename='js/typeahead.js'), '10-invenio' -%} {%- js url_for('search.static', filename='js/search/search_parser.js') -%} {%- js url_for('search.static', filename='js/search/typeahead.js') -%} {%- js url_for('search.static', filename='js/search/default_typeahead_configuration.js') -%} {%- js url_for('search.static', filename='js/search/facet.js') -%} {%- js url_for('static', filename='js/bootstrap-select.js') -%} {# {% js url_for('static', 'js/jquery.hotkeys.js') %}#} {# {% js url_for('search.static', filename='js/search/hotkeys.js') %}#} {%- css url_for('static', filename='css/typeahead.js-bootstrap.css'), '50-search' -%} {%- css url_for('search.static', filename='css/search/searchbar.css'), '50-search' -%} {% endblock %} {% block body %} + {%- include "search/form/index.html" -%} - {%- block search_form -%} - {{ search_form(collection, easy_search_form) }} - {%- endblock %} - - {% block inner_content %} - {% endblock %} - + {% block inner_content %}{% endblock %} {% endblock %} {% block javascript %} {{ super() }} {{ search_form_javascript(collection) }} {% endblock %}