Page MenuHomec4science

websearch_admin_index.html
No OneTemporary

File Metadata

Created
Sat, Jan 4, 07:09

websearch_admin_index.html

{#
## This file is part of Invenio.
## Copyright (C) 2012 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 th with context %}
{% from "_formhelpers.html" import render_filter_form with context %}
{% from "websearch_admin_helpers.html" import collection_tree with context %}
{% from "websearch_helpers.html" import search_also with context %}
{% extends "page.html" %}
{% set title = _("WebSearch Admin") %}
{% block header %}
{{ super() }}
{% js "js/jquery-ui.min.js" %}
{% endblock header %}
{% block body %}
<style>
/* This minimal height is important to be able to attach
* an item to any list of collection tree.
*/
.sortable ul { min-height:10px; }
.sortable ul li:first-child {
margin-top: 10px !important;
}
.invenio-state-active {
background-color: #EEE;
}
ul.sortable:hover:empty
,.invenio-state-highlight {
height: 1.5em; line-height: 1.2em;
border: 0.2em dashed #ccc;
border-radius-topright: 30px 20px;
border-radius-topleft: 30px 20px;
}
</style>
<div class="subnav">
<ul class="nav nav-pills" >
<li class="dropdown">
<a class="dropdown-toggle"
data-toggle="dropdown"
href="#">{{ _('Collection') }}
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><a href="#">{{ _('Create New') }}</a></li>
<li><a href="#">{{ _('Add to Tree') }}</a></li>
</ul>
</li>
<li> <a href="#">{{ _('Manage Collection Tree') }}</a></li>
</ul>
</div>
<div class="row">
<div style="min-height: 30px; padding: 10px;" class="trash droppable connectedSortable span8" data-id="0">
<i class="icon icon-trash"></i> {{ _('Drop here to delete.') }}
</div>
</div>
<div class="row">
<div class="span4 collection">
<h4>{{ _("Narrow by collections") }}</h4>
{{ collection_tree(collection, '_collection_children_r', class="nav nav-list sortable
connectedSortable" ) }}
</div>
<div class="span4 collection">
<h4>{{ _("Focus on") }}</h4>
{{ collection_tree(collection, '_collection_children_v', class="nav nav-list sortable
connectedSortable") }}
</div>
<div class="span4 collection">
<ul class="nav nav-list">
<li class="nav-header">{{ _('Orphans') }}</li>
<li>
<ul class="nav nav-list draggable" data-id="0" data-len="{{ orphans|length() }}" >
{% if orphans %}
{% for c in orphans %}
<li data-id-son="{{ c.id }}"
data-id-dad="0"
data-type="{{ c.type }}">
<a href="{{ url_for(".manage_collection", name=c.name) }}" >
{{ c.name }}
</a>
</li>
{% endfor %}
{% endif %}
</ul>
</li>
</ul>
</div>
</div>
<script>
$(document).ready(function() {
/*
* Callback for drop event.
*
* ui: jquery-ui prepared ui object.
* index: new index of the collection.
* sthis: sortable source object.
*/
function drop_callback(ui, index, sthis) {
// Makes the ajax request
$.ajax( '{{url_for('.modifycollectiontree')}}', {
statusCode: {
406: function() {
alert("{{ _('Invalid tree modification.') }}");
$(ui.item).hide('shake', { times: 2 }, 200, function() {
if (sthis != null) {
$(sthis).sortable('cancel');
} else {
$(ui.item).hide();
}
});
return false;
}
},
type: 'POST',
data: $.param({
id_son: $(ui.item).attr("data-id-son"),
id_dad: $(ui.item).attr("data-id-dad"),
id_new_dad: $(ui.item).parent().attr("data-id"),
score: index,
type: $(ui.item).attr("data-type")
})
}
).done(function(data) {
$(ui.item).attr("data-id-dad", $(ui.item).parent().attr("data-id"));
});
}
// Drag and drop JS code for manipulating collections.
$( ".sortable" ).sortable({
connectWith: ".connectedSortable",
placeholder: 'invenio-state-highlight',
revert: true,
distance: 30,
delay: 200,
cursor: "move",
helper: function(event, elt) {
if (event.shiftKey) {
/*
* Clone the object while SHIFT key is pressed during dragging.
*/
var l = $(elt).clone();
$(elt).after(l);
$(elt).attr('data-id-dad', 0);
return elt;
} else {
return elt;
}
},
stop: function(event, ui) {
drop_callback(ui, ui.item.index(), this);
}
});
$( ".sortable" ).disableSelection();
$( ".draggable li" ).draggable({
/*
* BEWARE: it's important to connect only with parent
* sortable because of their nesting the event is clonned
* to all connected lists.
*/
connectToSortable: "ul.connectedSortable[data-id=1]",
cursor: "move",
helper: "clone",
distance: 30,
delay: 200,
revert: "invalid"
});
$( ".droppable" ).droppable({
hoverClass: "invenio-state-active",
accept: ".sortable li",
activeClass: "invenio-state-highlight",
drop: function( event, ui ) {
ui.item = ui.draggable;
drop_callback(ui, 0, null);
$(ui.item).remove();
ui.item = null;
$(this).find( ".placeholder" ).remove();
return false;
}
});
});
</script>
{% endblock %}

Event Timeline