refactored edlp_ajax_node module to edlp_ajax to be able to get taxonomy terms

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-08 16:44:54 +01:00
parent fb4701f043
commit 3980479031
21 changed files with 248 additions and 206 deletions
@@ -120,7 +120,7 @@ edlp_vars = {
// cartel functions
loadNode(nid){
this.$cartel.addClass('loading');
$.getJSON('/edlp/node/'+nid+'/ajax/player_cartel', {})
$.getJSON('/edlp/ajax/json/node/'+nid+'/player_cartel', {})
.done(this.onNodeLoaded.bind(this))
.fail(this.onNodeLoadFail.bind(this));
},
@@ -242,11 +242,7 @@ edlp_vars = {
var $this = $(this);
// avoid already ajaxified links
// if($this.is('.ajax-enable')) return;
var sys_path = $this.attr('data-drupal-link-system-path');
if(sys_path){
// convert node link to edlp_ajax_node module links
m = sys_path.match(/^\/?(node\/\d+)$/g);
if(m) $this.attr('data-drupal-link-system-path', 'edlp/'+m[0]);
if($this.attr('data-drupal-link-system-path')){
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
}
});
@@ -260,19 +256,28 @@ edlp_vars = {
return false;
var sys_path = $(this).attr('data-drupal-link-system-path');
var ajax_path = sys_path;
if(sys_path == '<front>'){
backToFrontPage();
return false;
}
m = ajax_path.match(/^\/?(node\/\d+)$/g);
if(m){
// convert node link to edlp_ajax_node module links
ajax_path = 'edlp/ajax/json/'+m[0];
// check for viewmode attribute
if($link.attr('viewmode')){
ajax_path += '/'+$link.attr('viewmode');
}
}else{
// convert other link to ajax
ajax_path += '/ajax'
}
var path = window.location.origin + drupalSettings.path.baseUrl + sys_path;
_$body.addClass('ajax-loading');
$link.addClass('ajax-loading');
// check for viewmode attribute
path += '/ajax';
if($link.attr('viewmode') != ''){
path += '/'+$link.attr('viewmode');
}
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
$.getJSON(path, {})
.done(function(data){
onAjaxLinkLoaded(data, $link, sys_path);
@@ -298,9 +303,16 @@ edlp_vars = {
_$content_container.html(data.rendered);
// add body class for currently loaded content
_$body.removeClass().addClass('path-'+sys_path.replace(/\//g, '-'));
var body_classes = [
'path-'+sys_path.replace(/\//g, '-'),
'entity-type-'+data.entity_type,
'bundle-'+data.bundle,
'view-mode-'+data.view_mode
];
_$body.removeClass().addClass(body_classes.join(' '));
// id node add a generic path-node class to body
m = sys_path.match(/^\/?(edlp\/node\/\d+)$/g);
m = sys_path.match(/^\/?(node\/\d+)$/g);
if(m)
_$body.addClass('path-edlp-node');
@@ -1607,7 +1607,7 @@ footer {
footer .block-block-edlp-entrees {
pointer-events: none;
display: inline-block; }
body:not(.path-frontpage) footer .block-block-edlp-entrees {
body.path-productions footer .block-block-edlp-entrees {
display: none; }
footer .block-block-edlp-entrees ul {
white-space: nowrap; }
@@ -97,7 +97,7 @@
// cartel functions
loadNode(nid){
this.$cartel.addClass('loading');
$.getJSON('/edlp/node/'+nid+'/ajax/player_cartel', {})
$.getJSON('/edlp/ajax/json/node/'+nid+'/player_cartel', {})
.done(this.onNodeLoaded.bind(this))
.fail(this.onNodeLoadFail.bind(this));
},
@@ -219,11 +219,7 @@
var $this = $(this);
// avoid already ajaxified links
// if($this.is('.ajax-enable')) return;
var sys_path = $this.attr('data-drupal-link-system-path');
if(sys_path){
// convert node link to edlp_ajax_node module links
m = sys_path.match(/^\/?(node\/\d+)$/g);
if(m) $this.attr('data-drupal-link-system-path', 'edlp/'+m[0]);
if($this.attr('data-drupal-link-system-path')){
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
}
});
@@ -237,19 +233,28 @@
return false;
var sys_path = $(this).attr('data-drupal-link-system-path');
var ajax_path = sys_path;
if(sys_path == '<front>'){
backToFrontPage();
return false;
}
m = ajax_path.match(/^\/?(node\/\d+)$/g);
if(m){
// convert node link to edlp_ajax_node module links
ajax_path = 'edlp/ajax/json/'+m[0];
// check for viewmode attribute
if($link.attr('viewmode')){
ajax_path += '/'+$link.attr('viewmode');
}
}else{
// convert other link to ajax
ajax_path += '/ajax'
}
var path = window.location.origin + drupalSettings.path.baseUrl + sys_path;
_$body.addClass('ajax-loading');
$link.addClass('ajax-loading');
// check for viewmode attribute
path += '/ajax';
if($link.attr('viewmode') != ''){
path += '/'+$link.attr('viewmode');
}
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
$.getJSON(path, {})
.done(function(data){
onAjaxLinkLoaded(data, $link, sys_path);
@@ -275,9 +280,16 @@
_$content_container.html(data.rendered);
// add body class for currently loaded content
_$body.removeClass().addClass('path-'+sys_path.replace(/\//g, '-'));
var body_classes = [
'path-'+sys_path.replace(/\//g, '-'),
'entity-type-'+data.entity_type,
'bundle-'+data.bundle,
'view-mode-'+data.view_mode
];
_$body.removeClass().addClass(body_classes.join(' '));
// id node add a generic path-node class to body
m = sys_path.match(/^\/?(edlp\/node\/\d+)$/g);
m = sys_path.match(/^\/?(node\/\d+)$/g);
if(m)
_$body.addClass('path-edlp-node');
@@ -590,7 +590,7 @@ footer{
.block-block-edlp-entrees{
pointer-events: none;
body:not(.path-frontpage) & {display:none}
body.path-productions & {display:none}
display: inline-block;
// vertical-align: top;
@@ -1,7 +0,0 @@
<div class="row">
<div class="col small-col-12 med-col-4 large-col-4">
<div class="wrapper">
{{ node }}
</div>
</div>
</div>
@@ -0,0 +1,7 @@
<div class="row">
<div class="col small-col-12 med-col-6 large-col-6">
<div class="wrapper">
{{ content }}
</div>
</div>
</div>
@@ -0,0 +1,7 @@
<div class="row">
<div class="col small-col-12 med-col-6 large-col-6">
<div class="wrapper">
{{ content }}
</div>
</div>
</div>
@@ -0,0 +1,7 @@
<div class="row">
<div class="col small-col-12 med-col-6 large-col-6">
<div class="wrapper">
{{ content }}
</div>
</div>
</div>