added genres an langues condition to search, added close column bouton
This commit is contained in:
@@ -634,9 +634,7 @@
|
||||
// | _|| ' \ _| '_/ -_) -_|_-<
|
||||
// |___|_||_\__|_| \___\___/__/
|
||||
function filterEntree(t){
|
||||
// shuydown articles if active
|
||||
if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');
|
||||
shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
@@ -661,6 +659,28 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ___ _
|
||||
// / __| ___ __ _ _ _ __| |_
|
||||
// \__ \/ -_) _` | '_/ _| ' \
|
||||
// |___/\___\__,_|_| \__|_||_|
|
||||
function filterSearchResults(nids){
|
||||
shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
if(nids.indexOf(_nodes[n].nid) == -1){
|
||||
_nodes[n].setAside();
|
||||
}else{
|
||||
_nodes[n].setCentered();
|
||||
// record centered nodes for inter node repulsions
|
||||
_nodes_centered.push(_nodes[n]);
|
||||
}
|
||||
}
|
||||
createNodesRepulsions();
|
||||
};
|
||||
|
||||
|
||||
// ___ _ _ _
|
||||
// / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
|
||||
// \__ \/ _| '_/ _` | ' \| '_ \ | | ' \/ _` |
|
||||
@@ -733,7 +753,11 @@
|
||||
_no_articles_nodes[i].unFade();
|
||||
}
|
||||
};
|
||||
|
||||
function shutDownArticles(){
|
||||
// shutdown articles if active
|
||||
if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');
|
||||
};
|
||||
// ___ _
|
||||
// | __|_ _____ _ _| |_ ___
|
||||
// | _|\ V / -_) ' \ _(_-<
|
||||
@@ -808,6 +832,10 @@
|
||||
.on('search-results-loaded', function(e){
|
||||
console.log("Edlp Corpus, search-results-loaded",e.results);
|
||||
// TODO: filter map's nodes
|
||||
filterSearchResults(e.results);
|
||||
})
|
||||
.on('search-closed', function(e){
|
||||
scrambleCollection();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -634,9 +634,7 @@
|
||||
// | _|| ' \ _| '_/ -_) -_|_-<
|
||||
// |___|_||_\__|_| \___\___/__/
|
||||
function filterEntree(t){
|
||||
// shuydown articles if active
|
||||
if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');
|
||||
shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
@@ -661,6 +659,28 @@
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// ___ _
|
||||
// / __| ___ __ _ _ _ __| |_
|
||||
// \__ \/ -_) _` | '_/ _| ' \
|
||||
// |___/\___\__,_|_| \__|_||_|
|
||||
function filterSearchResults(nids){
|
||||
shutDownArticles();
|
||||
|
||||
_nodes_centered = [];
|
||||
for (var n = 0; n < _nodes.length; n++) {
|
||||
if(nids.indexOf(_nodes[n].nid) == -1){
|
||||
_nodes[n].setAside();
|
||||
}else{
|
||||
_nodes[n].setCentered();
|
||||
// record centered nodes for inter node repulsions
|
||||
_nodes_centered.push(_nodes[n]);
|
||||
}
|
||||
}
|
||||
createNodesRepulsions();
|
||||
};
|
||||
|
||||
|
||||
// ___ _ _ _
|
||||
// / __| __ _ _ __ _ _ __ | |__| (_)_ _ __ _
|
||||
// \__ \/ _| '_/ _` | ' \| '_ \ | | ' \/ _` |
|
||||
@@ -733,7 +753,11 @@
|
||||
_no_articles_nodes[i].unFade();
|
||||
}
|
||||
};
|
||||
|
||||
function shutDownArticles(){
|
||||
// shutdown articles if active
|
||||
if(_$articles_link.is('.is-active'))
|
||||
_$articles_link.trigger('click');
|
||||
};
|
||||
// ___ _
|
||||
// | __|_ _____ _ _| |_ ___
|
||||
// | _|\ V / -_) ' \ _(_-<
|
||||
@@ -808,6 +832,10 @@
|
||||
.on('search-results-loaded', function(e){
|
||||
console.log("Edlp Corpus, search-results-loaded",e.results);
|
||||
// TODO: filter map's nodes
|
||||
filterSearchResults(e.results);
|
||||
})
|
||||
.on('search-closed', function(e){
|
||||
scrambleCollection();
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
|
||||
function initEvents(){
|
||||
$('body')
|
||||
.on('new-content-ajax-loaded', initAjax);
|
||||
.on('new-content-ajax-loaded', initAjax)
|
||||
.on('edlp_search_search_form-col-closed', onSearchClosed);
|
||||
};
|
||||
|
||||
function initAjax(){
|
||||
@@ -41,7 +42,15 @@
|
||||
args.entries.push($(this).val());
|
||||
});
|
||||
|
||||
loadResults(args)
|
||||
// langues
|
||||
args.langues = $('input[name="langues"]', this).val();
|
||||
|
||||
// genres
|
||||
args.genres = $('input[name="genres"]', this).val();
|
||||
|
||||
console.log('EdlpSearch onSubmitForm() : args',args);
|
||||
|
||||
loadResults(args);
|
||||
|
||||
return false;
|
||||
};
|
||||
@@ -49,6 +58,8 @@
|
||||
function loadResults(args){
|
||||
console.log('EdlpSearch loadResults() : args', args);
|
||||
_$form.addClass('ajax-loading');
|
||||
_$body.addClass('ajax-loading');
|
||||
$('[theme="edlp_search_results"]', _$container).addClass('ajax-loading');
|
||||
var path = window.location.origin + drupalSettings.path.baseUrl +settings.results_ajax_url;
|
||||
$.getJSON(path, args)
|
||||
.done(function(data){
|
||||
@@ -61,6 +72,9 @@
|
||||
|
||||
function onResultsLoaded(data){
|
||||
console.log('EdlpSearch onResultsLoaded()', data);
|
||||
_$form.removeClass('ajax-loading');
|
||||
_$body.removeClass('ajax-loading');
|
||||
|
||||
// insert results col
|
||||
$prev_results = $('[theme="edlp_search_results"]', _$container);
|
||||
if($prev_results.length){
|
||||
@@ -68,7 +82,7 @@
|
||||
}else{
|
||||
_$container.append(data.rendered);
|
||||
}
|
||||
|
||||
|
||||
// trigger event
|
||||
_$body.trigger({
|
||||
'type':'search-results-loaded',
|
||||
@@ -81,5 +95,12 @@
|
||||
console.warn('EdlpSearch : search results ajax load failed : '+error, jqxhr.responseText);
|
||||
};
|
||||
|
||||
function onSearchClosed(e){
|
||||
console.log('Edlp Search onSearchClosed()', e);
|
||||
$('div[theme="edlp_search_results"]').remove();
|
||||
// trigger event
|
||||
_$body.trigger({'type':'search-closed'});
|
||||
}
|
||||
|
||||
init();
|
||||
})(jQuery, Drupal, drupalSettings);
|
||||
|
||||
@@ -273,6 +273,16 @@ class EdlpSearchController extends ControllerBase {
|
||||
$query->keys($this->keys);
|
||||
}
|
||||
|
||||
// TODO: langues
|
||||
if (!empty($this->langues)) {
|
||||
$query->addCondition('field_langues', $this->langues, "=");
|
||||
}
|
||||
|
||||
// TODO: genres
|
||||
if (!empty($this->genres)) {
|
||||
$query->addCondition('field_genres', $this->genres, "=");
|
||||
}
|
||||
|
||||
// entries
|
||||
if (!empty($this->entries)){
|
||||
$entries_condition_group = $query->createConditionGroup();
|
||||
@@ -283,13 +293,8 @@ class EdlpSearchController extends ControllerBase {
|
||||
$query->addConditionGroup($entries_condition_group);
|
||||
}
|
||||
|
||||
|
||||
// TODO: genres
|
||||
|
||||
// TODO: locuteurs
|
||||
|
||||
// TODO: langues
|
||||
|
||||
$result = $query->execute();
|
||||
$items = $result->getResultItems();
|
||||
// dpm($items);
|
||||
@@ -318,6 +323,8 @@ class EdlpSearchController extends ControllerBase {
|
||||
private function getRequestSearchArgs(){
|
||||
// dpm($this->request);
|
||||
$this->keys = $this->request->query->get('keys');
|
||||
$this->langues = $this->request->query->get('langues');
|
||||
$this->genres = $this->request->query->get('genres');
|
||||
$this->entries = $this->request->query->get('entries');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user