Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97004845
websearch_helpers.html
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Jan 1, 13:31
Size
26 KB
Mime Type
text/html
Expires
Fri, Jan 3, 13:31 (2 d)
Engine
blob
Format
Raw Data
Handle
23310029
Attached To
R3600 invenio-infoscience
websearch_helpers.html
View Options
{#
## This file is part of Invenio.
## Copyright (C) 2012, 2013 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) %}
<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 -%}
<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', p=similar, rm='wrd') }}"
>
{{ _("Similar records") }}
</a>
{# Citations link #}
{%- if config.CFG_BIBRANK_SHOW_CITATION_LINKS -%}
{%- set num_citations = record['_cited_by_count'] -%}
{%- if num_citations -%}
-
<a
href=
"{{ url_for('.search', p="
refersto:recid:
%
d
"
%
recID
)
}}"
data-hotkey-action=
"click"
data-hotkey-value=
"g{{ i }}r"
>
{{ _("Cited by %i records") % num_citations if num_citations > 1 else _("Cited by 1 record") }}
</a>
{%- endif -%}
{%- endif -%}
{# Comments link #}
{%- 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('webcomment.comments', recid=recID) }}"
data-hotkey-action=
"click"
data-hotkey-value=
"g{{ i }}c"
>
<i
class=
"icon-comment"
></i>
{{ _("%i comments") % num_comments if num_comments > 1 else _("1 comment") }}
</a>
{%- endif -%}
{%- endif -%}
{# Reviews link #}
{%- 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('webcomment.reviews', recid=recID) }}"
>
<i
class=
"icon-eye-open"
></i>
{{ _("%i reviews") % num_reviews if num_reviews > 1 else _("1 review") }}
</a>
{%- endif -%}
{%- endif -%}
</p>
{% endmacro %}
{% macro collection_tree(collections, limit=None) %}
{%- set idxs = [0] -%}
<ul
{{
kwargs
|
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)
}}"
>
{{ collection.name_ln }}
<small
class=
"muted"
>
({{ collection.nbrecs }})
</small>
</a>
{% if collection.collection_children and idxs|length
< limit
%}
{%
-
do
idxs
.
append
(
loop
.
index
)
-
%}
<
ul
{{
kwargs
|
xmlattr
}}
>
{{ loop(collection.collection_children) }}
</ul>
{%- do idxs.pop() -%}
{% endif %}
</li>
{% endfor %}
</ul>
{% endmacro %}
{% macro portalbox_sidebar(portalboxes, width=2) %}
{% if portalboxes %}
<div
{{
kwargs
|
xmlattr
}}
>
<ul
class=
"thumbnails"
>
{% for cp in portalboxes %}
<li
class=
"span{{ width }}"
>
<div
class=
"thumbnail"
>
<h5>
{{ cp.portalbox.title }}
</h5>
<p>
{{ cp.portalbox.body|safe }}
</p>
</div>
</li>
{% endfor %}
</ul>
</div>
{% endif %}
{% endmacro %}
{% macro search_also(externalcollections) %}
{% 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 %}
{% 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) %}
{% for f in easy_search_form if not f.name=='csrf_token' %}
<div
class=
"control-group"
>
<label
class=
"control-label"
>
{{ f.label.text }}
</label>
<div
class=
"controls controls-row"
>
{{ f|safe }}
</div>
</div>
{% endfor %}
{% endmacro %}
{% macro _search_advanced_box(collection) %}
<div
class=
"control-group"
>
<label
class=
"control-label"
>
<strong>
{{ _('what') }}?
</strong>
</label>
<div
class=
"controls"
>
<input
type=
"text"
name=
"p1"
value=
""
class=
"span3"
/>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
>
<strong>
{{ _('where') }}?
</strong>
</label>
<div
class=
"controls"
>
<select
class=
"span2"
name=
"f"
>
{% for (code, name) in collection.search_within %}
<option
value=
"{{ code }}"
>
{{ name }}
</option>
{% endfor %}
</select>
</div>
</div>
<div
class=
"control-group"
>
<label
class=
"control-label"
>
<strong>
{{ _('how') }}?
</strong>
</label>
<div
class=
"controls"
>
<select
class=
"span2"
name=
"m1"
>
{%- for v in config.CFG_WEBSEACH_MATCHING_TYPES|sort(attribute='order') -%}
<option
value=
"{{ v.code }}"
>
{{ _(v.title)|safe }}
</option>
{%- endfor -%}
</select>
<span
id=
"addtosearch"
class=
"btn"
>
<i
class=
"icon-ok"
></i>
</span>
</div>
</div>
{% for id, soo in collection.search_options|groupby('id_field') %}
<hr/>
<div
class=
"control-group"
>
<label
class=
"control-label"
>
{{ soo[0].field.name_ln }}
</label>
<div
class=
"controls"
>
<select
class=
"span2"
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=
"icon-ok"
></i>
</span>
</div>
</div>
{% endfor %}
{% endmacro %}
{% macro search_box(collection) %}
<div
style=
"padding: 0px;"
class=
"dropdown-menu donothide"
>
<div
class=
"row"
>
<div
class=
"span6"
style=
"min-width: 400px;"
>
<div
class=
"modal-header"
>
<button
type=
"button"
style=
"z-index:9999; position: relative;"
class=
"close"
onclick=
"
$
('.dropdown').removeClass('open open-permanent')"
>
×
</button>
<div
class=
"control"
style=
"margin-bottom: 0px;"
>
<label
class=
"control-label"
>
<strong>
{{ _('Add to search') }}
</strong>
</label>
<div
class=
"controls"
>
<div
style=
"padding-top:4px;"
class=
"btn-group"
data-toggle=
"buttons-radio"
>
<label
class=
"btn btn-mini active"
>
<input
style=
"display:none;"
type=
"radio"
name=
"op1"
value=
"a"
checked
/>
{{ _('AND') }}
</label>
<label
class=
"btn btn-mini"
>
<input
style=
"display:none;"
type=
"radio"
name=
"op1"
value=
"o"
/>
{{ _('OR') }}
</label>
<label
class=
"btn btn-mini"
>
<input
style=
"display:none;"
type=
"radio"
name=
"op1"
value=
"n"
/>
{{ _('AND NOT') }}
</label>
</div>
</div>
</div>
</div>
<!-- end modal-header-->
<div
style=
"max-height: 800px;"
class=
"modal-body"
>
<div
class=
"tab-content"
>
<div
class=
"tab-pane active"
id=
"simple-search"
>
{{ _search_simple_box(collection) }}
</div>
<div
class=
"tab-pane"
id=
"advanced-search"
>
{{ _search_advanced_box(collection) }}
</div>
</div>
</div>
<!-- end modal-body -->
<div
class=
"modal-footer"
>
<small><ul
class=
"nav nav-pills nav-pill-gray pull-left"
style=
"margin-bottom: 0px; text-align: left;"
>
<li
class=
"active"
>
<a
href=
"#simple-search"
data-toggle=
"tab"
>
{{ _('simple') }}
</a>
</li>
<li>
<a
href=
"#advanced-search"
data-toggle=
"tab"
>
{{ _('advanced') }}
</a>
</li>
</ul></small>
<button
name=
"action_browse"
class=
"btn"
>
<i
class=
"icon-list"
></i>
{{ _("Browse") }}
</button>
<button
name=
"action_search"
type=
"submit"
class=
"btn btn-primary"
>
<i
class=
"icon-search icon-white"
></i>
{{ _("Search") }}
</button>
</div>
<!-- end modal-footer -->
</div>
<!-- end span5 -->
</div>
<!-- end row -->
</div>
<!-- end dropdown-menu -->
<style>
.nav.nav-pill-gray
>
.active
>
a
,
.nav.nav-pill-gray
>
li
>
a
:hover
{
background
:
none
;
text-decoration
:
underline
;
color
:
inherit
;
}
#searchdropdown
.searchexamples
i
.pull-right
{
margin-right
:
-6px
;
margin-top
:
3px
;
opacity
:
.
25
;
}
#searchdropdown
.searchexamples
.after-fix
{
padding-right
:
20px
;
}
.open-permanent
.donothide
{
display
:
block
!important
;
}
</style>
{% endmacro %}
{% macro search_form(collection) %}
<div
id=
"search-box-main"
class=
"row"
>
<div
class=
"span12"
>
<div
class=
"well well-small"
style=
"margin-bottom: 20px; margin-left: -9px; margin-right: -9px;"
>
<div
class=
"row"
>
<form
action=
"{{ url_for('.search') }}"
name=
"settings"
method=
"get"
style=
"margin-bottom: 0px; position: relative; z-index: 1;"
class=
"pull-right form-inline"
>
<input
name=
"p"
value=
"{{ request.args.get('p','') }}"
type=
"hidden"
/>
<div
id=
"settingsdropdown"
class=
"pull-right btn-group dropdown"
>
<button
class=
"btn dropdown-toggle add-open-permanent"
data-target=
"#settingsdropdown"
data-toggle=
"dropdown"
>
<i
class=
"icon-cog"
></i>
<span
class=
"caret"
></span>
</button>
<ul
class=
"dropdown-menu donothide clearfix"
style=
"min-width: 300px; padding-bottom: 0px;"
>
<li
class=
"nav-header"
>
{{ _('Search settings') }}
</li>
<li
class=
"divider"
></li>
<li
class=
"clearfix nav-list"
>
<div
class=
"control-group clearfix"
>
<label
class=
"control-label pull-left"
>
{{ _('Display on page') }}
</label>
<div
class=
"controls pull-right"
>
<select
name=
"rg"
style=
"height: inherit; line-height: inherit;"
class=
"btn-small span2"
>
{%- 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=
"control-group clearfix"
>
<label
class=
"control-label pull-left"
>
{{ _('Output format') }}
</label>
<div
class=
"controls pull-right"
>
<select
name=
"of"
style=
"height: inherit; line-height: inherit;"
class=
"btn-small span2"
>
{%- 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>
<div
class=
"clearfix"
>
<label
class=
"control-label pull-left"
>
{{ _('Sort by most') }}
</label>
<div
class=
"controls pull-right"
>
<div
class=
"btn-group"
data-toggle=
"buttons-radio"
>
{%- for (k,v,vv) in [('recent', 'rm', ''), ('cited', 'rm', 'citation'), ('relevant', 'rm', 'wrd')] -%}
<label
class=
"btn btn-mini {{ 'active' if request.args.get(v,'') == vv}}"
>
<input
style=
"display:none;"
type=
"radio"
name=
"{{ v }}"
value=
"{{ vv }}"
{{
'
checked=
"checked"
'|
safe
if
request
.
args
.
get
(
v
,'')
==
vv
}}
>
{{ _(k) }}
</label>
{%- endfor -%}
</div>
</div>
</div>
</li>
<li
class=
"divider"
></li>
<li
class=
"clearfix nav-list"
>
<div
class=
"control-group clearfix"
>
<label
class=
"control-label pull-left"
>
{{ _('Search form') }}
</label>
<div
class=
"controls pull-right"
>
<div
class=
"btn-group"
data-toggle=
"buttons-radio"
>
{%- for (k,v) in [(_('Simple'), 'simple'), (_('Advanced'), 'advanced')] -%}
{%- set active = v=='simple' -%}
<label
class=
"btn btn-mini"
>
<input
style=
"display:none;"
type=
"radio"
name=
"box"
value=
"{{ v }}"
{{
'
checked=
"checked"
'|
safe
if
active
}}
>
{{ k }}
</label>
{%- endfor -%}
</div>
</div>
</div>
</li>
<li
class=
"modal-footer nav-list clearfix"
>
{%- 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-small pull-left"
>
<i
class=
"icon-hdd icon-white"
></i>
{{ _('Save') }}
</button>
{%- endif -%}
<button
name=
"action_search"
rel=
"tooltip"
title=
"{{ _('use settings in current search') }}"
data-placement=
"bottom"
class=
"btn btn-small pull-right"
>
<i
class=
"icon-ok"
></i>
{{ _('Apply') }}
</button>
</li>
</ul>
</div>
</form>
<form
action=
"{{ url_for('.search') }}"
name=
"search"
method=
"get"
style=
"margin-bottom: 0px;"
class=
"form-horizontal span11"
>
<div
class=
"row"
>
<div
class=
"span2 visible-desktop"
>
<label
for=
"p"
style=
"padding-top: 5px; text-align: right; font-size: 90%;"
>
{%- set nbrecs = collection.nbrecs -%}
{%- if not collection.nbrecs -%}
{%- set nbrecs = 0 -%}
{%- endif -%}
{{ _("Search %s records for")|format(nbrecs) }}
</label>
</div>
<div
class=
"span9"
>
<div
id=
"searchdropdown"
class=
"dropdown"
>
{#
{% set search_placeholder = _('Input query') %}
{% if collection.examples %}
{% set search_placeholder = (collection.examples|random).body %}
{% endif %}
#}
<div
class=
"input-prepend input-append"
>
<div
class=
"dropdown add-on"
>
<a
class=
"dropdown-toggle"
rel=
"tooltip"
title=
"{{ _('Search Tips and Examples') }}"
data-placement=
"bottom"
data-delay=
"100"
data-toggle=
"dropdown"
role=
"button"
href=
"#"
><i
class=
"icon-question-sign"
></i></a>
<ul
class=
"searchexamples dropdown-menu"
style=
"text-align: left;"
>
<li>
<a
href=
"/help/search-tips"
>
<i
class=
"pull-right icon-info-sign"
></i>
<strong>
{{ _("Search Tips") }}
</strong>
</a>
</li>
<li>
<a
href=
"/help/search-guide"
>
<i
class=
"pull-right icon-leaf"
></i>
<strong>
{{ _("Search Guide") }}
</strong>
</a>
</li>
{% if collection.examples %}
<li
class=
"divider"
></li>
<li
class=
"nav-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 icon-chevron-right"
></i>
<span
class=
"after-fix"
>
{{ e.body }}
</span>
</a>
</li>
{%- endfor -%}
{% endif %}
</ul>
</div>
<!--
No space!
-->
<input
autocomplete=
"off"
data-provide=
"typeahead"
data-items=
"4"
name=
"p"
class=
"span6"
type=
"text"
style=
"min-width:200px;"
{#
placeholder=
"{{ _('Example') }}: {{ search_placeholder }}"
#}
tabindex=
"1"
value=
"{{ request.args.get('p', '') }}"
{%
-
if
request
.
endpoint =
=
'
search
.
index
'
-
%}
autofocus
{%
-
endif
-
%}
/>
<!--
No space!
-->
<span
data-toggle=
"dropdown"
data-target=
"#searchdropdown"
class=
"add-on btn add-open-permanent"
>
<i
class=
"caret"
></i>
</span>
</div>
{#
# This is a dirty hack for browser without Javascript support.
#}
<script>
var
box
=
{{
search_box
(
collection
)
|
tojson
|
safe
}};
document
.
write
(
box
);
</script>
<!-- Hidden configuration fields -->
{% if collection.id != 1 %}
<input
type=
"hidden"
name=
"cc"
value=
"{{ collection.name }}"
/>
{% endif %}
{{ _search_hidden_options() }}
<!-- end of configuration fields -->
<button
name=
"action_search"
type=
"submit"
class=
"btn btn-primary"
>
<i
class=
"icon-search icon-white"
></i>
<span
class=
"hidden-phone"
>
{{ _("Search") }}
</span>
</button>
{#
<span
class=
"help-inline"
>
<a
href=
"/help/search-tips"
>
{{ _("Search Tips") }}
</a>
</span>
#}
</div>
</div>
<!-- end controls -->
</div>
</form>
</div>
<!-- end sub row -->
</div>
<!-- end span12 -->
</div>
</div>
<!-- end row -->
{% endmacro %}
{% macro search_form_javascript(collection) %}
<script>
$
(
function
()
{
$
(
"form[name=search]"
).
submit
(
function
()
{
$
(
'.donothide'
).
remove
();
return
true
;
// ensure form still submits
})
$
(
'#settingsdropdown select[name="of"]'
).
buttonSelect
({
button
:
'<div class="btn btn-mini" />'
,
span
:
'<span class="btn btn-mini" style="width: 80px;" />'
,
next
:
'<i class="icon icon-chevron-right"></i>'
,
prev
:
'<i class="icon icon-chevron-left"></i>'
})
$
(
'#settingsdropdown select[name="rg"]'
).
buttonSelect
({
button
:
'<div class="btn btn-mini" />'
,
span
:
'<span class="btn btn-mini" style="width: 80px;" />'
,
next
:
'<i class="icon icon-plus"></i>'
,
prev
:
'<i class="icon icon-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();
//}
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
-%
}
};
var
addtosearch_callback
=
function
(
e
)
{
var
op1
=
$
(
'[name=op1]:checked'
).
val
(),
m1
=
$
(
'[name=m1]'
).
val
(),
p1
=
$
(
'[name=p1]'
).
val
(),
f
=
$
(
'[name=f]'
).
val
(),
p
=
$
(
'[name=p]'
),
val
=
$
.
trim
(
p
.
val
()),
op
=
(
op1
==
'a'
&&
val
==
""
)
?
''
:
op1_fn
[
op1
];
if
(
val
!==
""
)
{
val
+=
' '
+
op
;
}
if
(
p1
===
""
)
{
return
false
;
}
if
(
f
!==
""
)
{
f
+=
':'
;
}
p
.
val
(
val
+
m1_fn
[
m1
](
p1
,
f
));
$
(
'[name=p1]'
).
val
(
''
);
e
.
stopPropagation
();
return
false
;
};
function
perform_easy_search
()
{
// get values
var
p
=
$
(
'[name=p]'
),
val
=
$
.
trim
(
p
.
val
()),
op1
=
$
(
'[name=op1]:checked'
).
val
(),
op
=
(
op1
==
'a'
&&
val
==
""
)
?
''
:
op1_fn
[
op1
],
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
();
if
(
val
!==
""
)
{
val
+=
' '
+
op
;
}
// 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
);
}
//query = query.replace(/topcite (\d+)?\+/, 'topcite
$
1->99999');
//query = query.replace(' and ', ' ');
//query = query.replace(/ /g, '+');
//window.location = search_url;
if
(
query
.
length
>
0
)
{
p
.
val
(
val
+
query
.
join
(
' '
+
op1_fn
[
op1
]));
}
};
$
(
'.donothide .btn-primary'
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
'.modal-footer li.active a'
).
attr
(
'href'
)
===
'#simple-search'
)
{
perform_easy_search
();
}
else
{
addtosearch_callback
(
e
);
$
(
'#searchdropdown .appender'
).
trigger
(
'click'
);
}
});
$
(
'form[name=search] button[name=action_browse]'
).
on
(
'click'
,
function
(
e
)
{
$
(
'form[name=search] button[name=action_search]'
)
.
attr
(
'name'
,
'action_browse'
);
$
(
'.donothide .btn-primary'
).
trigger
(
'click'
);
});
$
(
'#advanced-search #addtosearch'
).
on
(
'click'
,
addtosearch_callback
);
$
(
'#advanced-search [name=p1]'
).
keypress
(
function
(
event
)
{
if
(
event
.
which
==
13
)
{
if
(
$
(
this
).
val
()
!==
''
)
{
event
.
preventDefault
();
addtosearch_callback
(
event
);
}
}
});
$
(
'#searchdropdown #advanced-search .appender'
).
on
(
'click'
,
function
(
e
)
{
var
op1
=
$
(
'[name=op1]:checked'
).
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
;
});
$
(
'.add-open-permanent'
).
on
(
'click'
,
function
(
e
)
{
$
(
this
).
parents
(
'.dropdown'
).
addClass
(
'open-permanent'
)
})
$
(
document
).
on
(
'click'
,
function
(
e
)
{
if
(
$
(
e
.
target
).
parents
(
'.donothide'
).
length
<=
0
)
{
$
(
'.open-permanent'
).
removeClass
(
'open-permanent'
)
}
})
var
source
=
$
.
map
({{
collection
.
search_within
[
1
:
]
|
tojson
|
safe
}},
function
(
val
,
i
)
{
return
val
[
0
]
+
':'
;});
//['author:', 'title:', 'isbn:'];
source
.
push
(
'AND '
);
source
.
push
(
'OR '
);
source
.
push
(
'AND NOT '
);
var
sources
=
{
{
%
for
id
,
soo
in
collection
.
search_options
|
groupby
(
'id_field'
)
%
}
'{{ soo[0].field.code }}'
:
[{
%
for
so
in
soo
%
}
'{{ so.fieldvalue.name }}'
{{
','
if
not
loop
.
last
}}
{
%
endfor
%
}
]{{
','
if
not
loop
.
last
}}
{
%
endfor
%
}
};
{
%
for
id
,
soo
in
collection
.
search_options
|
groupby
(
'id_field'
)
%
}
source
.
push
(
'{{ soo[0].field.code }}:'
);
{
%
endfor
%
}
sources
[
'author'
]
=
function
(
query
)
{
var
typeahead
=
this
$
.
ajax
({
type
:
'GET'
,
url
:
'{{ url_for('
search
.
autocomplete
', field='
exactauthor
') }}'
,
data
:
$
.
param
({
q
:
query
.
substr
(
query
.
lastIndexOf
(
':'
)
+
1
)
})
}).
done
(
function
(
data
)
{
var
a
=
[
query
.
substr
(
query
.
lastIndexOf
(
':'
)
+
1
)]
,
b
=
data
.
results
,
c
=
a
.
concat
(
b
)
typeahead
.
process
(
c
)
}).
fail
(
function
(
data
)
{
var
a
=
[
query
.
substr
(
query
.
lastIndexOf
(
':'
)
+
1
)]
typeahead
.
process
(
a
)
})
};
$
(
'form[name=search] input[name=p]'
).
searchTypeahead
({
source
:
source
,
sources
:
sources
,
type
:
'search'
});
$
(
'body'
).
on
(
'focus.typeahead.data-api'
,
'[data-provide="typeahead-url"]'
,
function
(
e
)
{
var
$
this
=
$
(
this
)
if
(
$
this
.
data
(
'typeahead'
))
return
e
.
preventDefault
()
var
data_url
=
$
this
.
data
(
'source'
)
var
options
=
{
source
:
function
(
query
)
{
var
typeahead
=
this
$
.
ajax
({
type
:
'GET'
,
url
:
data_url
,
data
:
$
.
param
({
q
:
query
})
}).
done
(
function
(
data
)
{
typeahead
.
process
(
data
.
results
)
})
}
}
var
data
=
$
.
extend
({},
$
this
.
data
(),
options
)
$
this
.
typeahead
(
data
)
}
);
});
</script>
{% endmacro %}
Event Timeline
Log In to Comment