refactored edlp_ajax_node module to edlp_ajax to be able to get taxonomy terms
This commit is contained in:
+3
-3
@@ -1,11 +1,11 @@
|
|||||||
# @Author: Bachir Soussi Chiadmi <bach>
|
# @Author: Bachir Soussi Chiadmi <bach>
|
||||||
# @Email: bachir@figureslibres.io
|
# @Email: bachir@figureslibres.io
|
||||||
# @Filename: edlp_ajax_node.info.yml
|
# @Filename: edlp_ajax.info.yml
|
||||||
# @License: GPL-V3
|
# @License: GPL-V3
|
||||||
|
|
||||||
|
|
||||||
name: Edlp Ajax Node
|
name: Edlp Ajax
|
||||||
type: module
|
type: module
|
||||||
description: Manage ajax node loading for edlp d8.
|
description: Manage ajax entity loading for edlp d8.
|
||||||
core: 8.x
|
core: 8.x
|
||||||
package: Edlp
|
package: Edlp
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
# @Author: Bachir Soussi Chiadmi <bach>
|
||||||
|
# @Email: bachir@figureslibres.io
|
||||||
|
# @Filename: edlp_ajax.module
|
||||||
|
# @License: GPL-V3
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_theme().
|
||||||
|
*/
|
||||||
|
function edlp_ajax_theme($existing, $type, $theme, $path) {
|
||||||
|
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
||||||
|
return array(
|
||||||
|
'edlp_ajax' => array(
|
||||||
|
'file' => 'includes/edlp_ajax.inc',
|
||||||
|
'variables' => array(
|
||||||
|
'entity_type' => 'node',
|
||||||
|
'entity' => NULL,
|
||||||
|
'view_mode' => 'default'
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements hook_theme_suggestions_HOOK().
|
||||||
|
*/
|
||||||
|
function edlp_ajax_theme_suggestions_edlp_ajax(array $vars) {
|
||||||
|
// dpm($vars);
|
||||||
|
$suggestions = [];
|
||||||
|
// $node = $variables['elements']['#node'];
|
||||||
|
$sanitized_view_mode = strtr($vars['view_mode'], '.', '_');
|
||||||
|
//
|
||||||
|
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'];
|
||||||
|
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $sanitized_view_mode;
|
||||||
|
// $suggestions[] = 'node__' . $node->bundle() . '__' . $sanitized_view_mode;
|
||||||
|
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id();
|
||||||
|
$suggestions[] = 'edlp_ajax__' . $vars['entity_type'] . '__' . $vars['entity']->id() . '__' . $sanitized_view_mode;
|
||||||
|
|
||||||
|
return $suggestions;
|
||||||
|
}
|
||||||
+8
-8
@@ -6,20 +6,20 @@
|
|||||||
# @Last modified time: 20-12-2017
|
# @Last modified time: 20-12-2017
|
||||||
# @License: GPL-V3
|
# @License: GPL-V3
|
||||||
|
|
||||||
edlp_ajax_node.node:
|
edlp_ajax.node:
|
||||||
path: '/edlp/node/{nid}/{viewmode}'
|
path: '/edlp/ajax/{entity_type}/{id}/{viewmode}'
|
||||||
defaults:
|
defaults:
|
||||||
_controller: '\Drupal\edlp_ajax_node\Controller\EdlpAjaxNodeController::node'
|
_controller: '\Drupal\edlp_ajax\Controller\EdlpAjaxController::entity'
|
||||||
_title: 'Node'
|
_title: 'EdlpAjax'
|
||||||
viewmode: 'default'
|
viewmode: 'default'
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'access content'
|
_permission: 'access content'
|
||||||
|
|
||||||
edlp_ajax_node.ajaxnode:
|
edlp_ajax.ajaxnode:
|
||||||
path: '/edlp/node/{nid}/ajax/{viewmode}'
|
path: '/edlp/ajax/json/{entity_type}/{id}/{viewmode}'
|
||||||
defaults:
|
defaults:
|
||||||
_controller: '\Drupal\edlp_ajax_node\Controller\EdlpAjaxNodeController::nodejson'
|
_controller: '\Drupal\edlp_ajax\Controller\EdlpAjaxController::entityjson'
|
||||||
_title: 'AjaxNode'
|
_title: 'EdlpAjaxJson'
|
||||||
viewmode: 'default'
|
viewmode: 'default'
|
||||||
requirements:
|
requirements:
|
||||||
_permission: 'access content'
|
_permission: 'access content'
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// use Drupal\Core\Url;
|
||||||
|
|
||||||
|
function template_preprocess_edlp_ajax(&$vars){
|
||||||
|
// dpm($vars);
|
||||||
|
/*
|
||||||
|
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||||
|
*/
|
||||||
|
$view_builder = \Drupal::entityTypeManager()->getViewBuilder($vars['entity_type']);
|
||||||
|
$vars['content'] = $view_builder->view($vars['entity'], $vars['view_mode']);
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Drupal\edlp_ajax\Controller;
|
||||||
|
|
||||||
|
use Drupal\Core\Controller\ControllerBase;
|
||||||
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
|
|
||||||
|
class EdlpAjaxController extends ControllerBase {
|
||||||
|
|
||||||
|
private function query() {
|
||||||
|
$this->entity = entity_load($this->entity_type, $this->id);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function toRenderable(){
|
||||||
|
$this->query();
|
||||||
|
|
||||||
|
if($this->entity){
|
||||||
|
return array(
|
||||||
|
"#theme"=>'edlp_ajax',
|
||||||
|
"#entity_type" => $this->entity_type,
|
||||||
|
'#entity' => $this->entity,
|
||||||
|
'#view_mode' => $this->viewmode,
|
||||||
|
);
|
||||||
|
}else{
|
||||||
|
return array(
|
||||||
|
'#markup'=>'404! '.$this->entity_type.' '.$this->id." not found!"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display entity as a page.
|
||||||
|
*
|
||||||
|
* @return renderable array
|
||||||
|
*/
|
||||||
|
public function entity($entity_type, $id, $viewmode) {
|
||||||
|
$this->entity_type = $entity_type;
|
||||||
|
$this->id = $id;
|
||||||
|
$this->viewmode = $viewmode;
|
||||||
|
return $this->toRenderable();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get entity as json through ajax.
|
||||||
|
*
|
||||||
|
* @return json
|
||||||
|
*/
|
||||||
|
public function entityjson($entity_type, $id, $viewmode) {
|
||||||
|
$this->entity_type = $entity_type;
|
||||||
|
$this->id = $id;
|
||||||
|
$this->viewmode = $viewmode;
|
||||||
|
$renderable = $this->toRenderable();
|
||||||
|
$rendered = render($renderable);
|
||||||
|
|
||||||
|
$response = new JsonResponse();
|
||||||
|
$response->setData([
|
||||||
|
'test' => 'hello edlp ajax',
|
||||||
|
'id' => $this->id,
|
||||||
|
'view_mode' => $this->viewmode,
|
||||||
|
'bundle' => $this->entity->getType(),
|
||||||
|
'entity_type' => $this->entity_type,
|
||||||
|
'rendered'=> $rendered,
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{{ content }}
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
# @Author: Bachir Soussi Chiadmi <bach>
|
|
||||||
# @Email: bachir@figureslibres.io
|
|
||||||
# @Filename: edlp_ajax_node.module
|
|
||||||
# @License: GPL-V3
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Implements hook_theme().
|
|
||||||
*/
|
|
||||||
function edlp_ajax_node_theme($existing, $type, $theme, $path) {
|
|
||||||
// @see https://www.drupal.org/docs/8/theming/twig/create-custom-twig-templates-from-custom-module
|
|
||||||
return array(
|
|
||||||
'edlp_ajax_node' => array(
|
|
||||||
'file' => 'includes/edlp_ajax_node.inc',
|
|
||||||
'variables' => array(
|
|
||||||
'node_object' => NULL,
|
|
||||||
'view_mode' => 'default'
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
// use Drupal\Core\Url;
|
|
||||||
|
|
||||||
function template_preprocess_edlp_ajax_node(&$vars){
|
|
||||||
// dpm($vars);
|
|
||||||
/*
|
|
||||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
|
||||||
*/
|
|
||||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
|
||||||
$vars['node'] = $view_builder->view($vars['node_object'], $vars['view_mode']);
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Drupal\edlp_ajax_node\Controller;
|
|
||||||
|
|
||||||
use Drupal\Core\Controller\ControllerBase;
|
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
|
||||||
|
|
||||||
|
|
||||||
class EdlpAjaxNodeController extends ControllerBase {
|
|
||||||
|
|
||||||
private function query() {
|
|
||||||
$this->node = entity_load('node', $this->nid);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function toRenderable(){
|
|
||||||
$this->query();
|
|
||||||
|
|
||||||
if($this->node){
|
|
||||||
return array(
|
|
||||||
"#theme"=>'edlp_ajax_node',
|
|
||||||
'#node_object' => $this->node,
|
|
||||||
'#view_mode' => $this->viewmode,
|
|
||||||
);
|
|
||||||
}else{
|
|
||||||
return array(
|
|
||||||
'#markup'=>'404! Node '.$this->nid." not found!"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Display node as a page.
|
|
||||||
*
|
|
||||||
* @return renderable array
|
|
||||||
*/
|
|
||||||
public function node($nid, $viewmode) {
|
|
||||||
$this->nid = $nid;
|
|
||||||
$this->viewmode = $viewmode;
|
|
||||||
return $this->toRenderable();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get node as json through ajax.
|
|
||||||
*
|
|
||||||
* @return json
|
|
||||||
*/
|
|
||||||
public function nodejson($nid, $viewmode) {
|
|
||||||
$this->nid = $nid;
|
|
||||||
$this->viewmode = $viewmode;
|
|
||||||
$renderable = $this->toRenderable();
|
|
||||||
$rendered = render($renderable);
|
|
||||||
|
|
||||||
$response = new JsonResponse();
|
|
||||||
$response->setData([
|
|
||||||
'test' => 'hello edlp ajax node',
|
|
||||||
'nid' => $this->nid,
|
|
||||||
'view_mode' => $this->viewmode,
|
|
||||||
'rendered'=> $rendered,
|
|
||||||
]);
|
|
||||||
|
|
||||||
return $response;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
{{ node }}
|
|
||||||
@@ -155,41 +155,30 @@
|
|||||||
this.r = 5;
|
this.r = 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// this.base_radius = _base_radius;
|
|
||||||
// this.g = {
|
|
||||||
// l : 1, // drawing line width
|
|
||||||
// s : 1 // drawing space between squares
|
|
||||||
// };
|
|
||||||
// this.real_radius = this.base_radius + (this.g.l+this.g.s)*this.entrees.length;
|
|
||||||
|
|
||||||
// prototype function not available on construct :(
|
|
||||||
// this.calcWallLimits();
|
|
||||||
this.wall_limits = {
|
|
||||||
top: _canvas_props.margin_top +this.r,
|
|
||||||
right: _canvas.width -_canvas_props.margin_right -this.r,
|
|
||||||
bottom: _canvas.height -_canvas_props.margin_bottom -this.r,
|
|
||||||
left: _canvas_props.margin_left +this.r
|
|
||||||
}
|
|
||||||
|
|
||||||
this.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
|
|
||||||
this.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
|
|
||||||
|
|
||||||
this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
|
this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
|
||||||
|
|
||||||
this.hover = false;
|
this.hover = false;
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
|
|
||||||
// physics
|
|
||||||
this.p = _physics.makeParticle(this.mass, this.x, this.y);
|
|
||||||
this.p.velocity = new Physics.Vector((Math.random()-0.5)*_p_velocity_factor, (Math.random()-0.5)*_p_velocity_factor);
|
|
||||||
|
|
||||||
// if(this.id == '620'){
|
|
||||||
// _node_pop_up.setNode(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// prototypes
|
// prototypes
|
||||||
if (typeof Node.initialized == "undefined") {
|
if (typeof Node.initialized == "undefined") {
|
||||||
|
|
||||||
|
Node.prototype.init = function(){
|
||||||
|
this.calcWallLimits();
|
||||||
|
|
||||||
|
this.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
|
||||||
|
this.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
|
||||||
|
|
||||||
|
// physics
|
||||||
|
this.p = _physics.makeParticle(this.mass, this.x, this.y);
|
||||||
|
this.p.velocity = new Physics.Vector((Math.random()-0.5)*_p_velocity_factor, (Math.random()-0.5)*_p_velocity_factor);
|
||||||
|
|
||||||
|
// if(this.id == '620'){
|
||||||
|
// _node_pop_up.setNode(this);
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
Node.prototype.calcWallLimits = function(){
|
Node.prototype.calcWallLimits = function(){
|
||||||
this.wall_limits = {
|
this.wall_limits = {
|
||||||
top: _canvas_props.margin_top +this.r,
|
top: _canvas_props.margin_top +this.r,
|
||||||
@@ -223,6 +212,7 @@
|
|||||||
if (Math.abs(this.p.velocity.x) < this.velocity_threshold
|
if (Math.abs(this.p.velocity.x) < this.velocity_threshold
|
||||||
&& Math.abs(this.p.velocity.y) < this.velocity_threshold){
|
&& Math.abs(this.p.velocity.y) < this.velocity_threshold){
|
||||||
this.p.velocity.multiplyScalar(0);
|
this.p.velocity.multiplyScalar(0);
|
||||||
|
// this.p.makeFixed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,8 +277,8 @@
|
|||||||
// actif entouré de rouge
|
// actif entouré de rouge
|
||||||
|
|
||||||
_ctx.beginPath();
|
_ctx.beginPath();
|
||||||
// _ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
_ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
||||||
_ctx.fillStyle = edlp_vars[this.e_color];
|
// _ctx.fillStyle = edlp_vars[this.e_color];
|
||||||
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
||||||
|
|
||||||
if(this.opened){
|
if(this.opened){
|
||||||
@@ -303,7 +293,7 @@
|
|||||||
Node.initialized = true;
|
Node.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
// TODO: we may convert a lot of computation into a web worker https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
// TODO: we may convert a lot of computation into a web worker https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
||||||
function checkParticulesCollisions(){
|
function checkParticulesCollisions(){
|
||||||
|
|||||||
@@ -155,41 +155,30 @@
|
|||||||
this.r = 5;
|
this.r = 5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// this.base_radius = _base_radius;
|
|
||||||
// this.g = {
|
|
||||||
// l : 1, // drawing line width
|
|
||||||
// s : 1 // drawing space between squares
|
|
||||||
// };
|
|
||||||
// this.real_radius = this.base_radius + (this.g.l+this.g.s)*this.entrees.length;
|
|
||||||
|
|
||||||
// prototype function not available on construct :(
|
|
||||||
// this.calcWallLimits();
|
|
||||||
this.wall_limits = {
|
|
||||||
top: _canvas_props.margin_top +this.r,
|
|
||||||
right: _canvas.width -_canvas_props.margin_right -this.r,
|
|
||||||
bottom: _canvas.height -_canvas_props.margin_bottom -this.r,
|
|
||||||
left: _canvas_props.margin_left +this.r
|
|
||||||
}
|
|
||||||
|
|
||||||
this.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
|
|
||||||
this.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
|
|
||||||
|
|
||||||
this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
|
this.e_color = 'e_col_'+this.entrees[Math.floor(Math.random(this.entrees.length))];
|
||||||
|
|
||||||
this.hover = false;
|
this.hover = false;
|
||||||
this.opened = false;
|
this.opened = false;
|
||||||
|
|
||||||
// physics
|
|
||||||
this.p = _physics.makeParticle(this.mass, this.x, this.y);
|
|
||||||
this.p.velocity = new Physics.Vector((Math.random()-0.5)*_p_velocity_factor, (Math.random()-0.5)*_p_velocity_factor);
|
|
||||||
|
|
||||||
// if(this.id == '620'){
|
|
||||||
// _node_pop_up.setNode(this);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// prototypes
|
// prototypes
|
||||||
if (typeof Node.initialized == "undefined") {
|
if (typeof Node.initialized == "undefined") {
|
||||||
|
|
||||||
|
Node.prototype.init = function(){
|
||||||
|
this.calcWallLimits();
|
||||||
|
|
||||||
|
this.x = this.wall_limits.left + Math.random()*(this.wall_limits.right - this.wall_limits.left);
|
||||||
|
this.y = this.wall_limits.top + Math.random()*(this.wall_limits.bottom - this.wall_limits.top);
|
||||||
|
|
||||||
|
// physics
|
||||||
|
this.p = _physics.makeParticle(this.mass, this.x, this.y);
|
||||||
|
this.p.velocity = new Physics.Vector((Math.random()-0.5)*_p_velocity_factor, (Math.random()-0.5)*_p_velocity_factor);
|
||||||
|
|
||||||
|
// if(this.id == '620'){
|
||||||
|
// _node_pop_up.setNode(this);
|
||||||
|
// }
|
||||||
|
};
|
||||||
|
|
||||||
Node.prototype.calcWallLimits = function(){
|
Node.prototype.calcWallLimits = function(){
|
||||||
this.wall_limits = {
|
this.wall_limits = {
|
||||||
top: _canvas_props.margin_top +this.r,
|
top: _canvas_props.margin_top +this.r,
|
||||||
@@ -223,6 +212,7 @@
|
|||||||
if (Math.abs(this.p.velocity.x) < this.velocity_threshold
|
if (Math.abs(this.p.velocity.x) < this.velocity_threshold
|
||||||
&& Math.abs(this.p.velocity.y) < this.velocity_threshold){
|
&& Math.abs(this.p.velocity.y) < this.velocity_threshold){
|
||||||
this.p.velocity.multiplyScalar(0);
|
this.p.velocity.multiplyScalar(0);
|
||||||
|
// this.p.makeFixed();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,8 +277,8 @@
|
|||||||
// actif entouré de rouge
|
// actif entouré de rouge
|
||||||
|
|
||||||
_ctx.beginPath();
|
_ctx.beginPath();
|
||||||
// _ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
_ctx.fillStyle = !this.p.resting() ? edlp_vars[this.e_color] : 'rgb(0, 0, 0)';
|
||||||
_ctx.fillStyle = edlp_vars[this.e_color];
|
// _ctx.fillStyle = edlp_vars[this.e_color];
|
||||||
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
_ctx.fillRect(this.x - this.r,this.y - this.r,this.r*2,this.r*2);
|
||||||
|
|
||||||
if(this.opened){
|
if(this.opened){
|
||||||
@@ -303,7 +293,7 @@
|
|||||||
Node.initialized = true;
|
Node.initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.init();
|
this.init();
|
||||||
};
|
};
|
||||||
// TODO: we may convert a lot of computation into a web worker https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
// TODO: we may convert a lot of computation into a web worker https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Using_web_workers
|
||||||
function checkParticulesCollisions(){
|
function checkParticulesCollisions(){
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ edlp_vars = {
|
|||||||
// cartel functions
|
// cartel functions
|
||||||
loadNode(nid){
|
loadNode(nid){
|
||||||
this.$cartel.addClass('loading');
|
this.$cartel.addClass('loading');
|
||||||
$.getJSON('/edlp/node/'+nid+'/ajax/player_cartel', {})
|
$.getJSON('/edlp/ajax/json/node/'+nid+'/player_cartel', {})
|
||||||
.done(this.onNodeLoaded.bind(this))
|
.done(this.onNodeLoaded.bind(this))
|
||||||
.fail(this.onNodeLoadFail.bind(this));
|
.fail(this.onNodeLoadFail.bind(this));
|
||||||
},
|
},
|
||||||
@@ -242,11 +242,7 @@ edlp_vars = {
|
|||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
// avoid already ajaxified links
|
// avoid already ajaxified links
|
||||||
// if($this.is('.ajax-enable')) return;
|
// if($this.is('.ajax-enable')) return;
|
||||||
var sys_path = $this.attr('data-drupal-link-system-path');
|
if($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]);
|
|
||||||
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
|
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -260,19 +256,28 @@ edlp_vars = {
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var sys_path = $(this).attr('data-drupal-link-system-path');
|
var sys_path = $(this).attr('data-drupal-link-system-path');
|
||||||
|
var ajax_path = sys_path;
|
||||||
if(sys_path == '<front>'){
|
if(sys_path == '<front>'){
|
||||||
backToFrontPage();
|
backToFrontPage();
|
||||||
return false;
|
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');
|
_$body.addClass('ajax-loading');
|
||||||
$link.addClass('ajax-loading');
|
$link.addClass('ajax-loading');
|
||||||
// check for viewmode attribute
|
|
||||||
path += '/ajax';
|
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||||
if($link.attr('viewmode') != ''){
|
|
||||||
path += '/'+$link.attr('viewmode');
|
|
||||||
}
|
|
||||||
$.getJSON(path, {})
|
$.getJSON(path, {})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
onAjaxLinkLoaded(data, $link, sys_path);
|
onAjaxLinkLoaded(data, $link, sys_path);
|
||||||
@@ -298,9 +303,16 @@ edlp_vars = {
|
|||||||
_$content_container.html(data.rendered);
|
_$content_container.html(data.rendered);
|
||||||
|
|
||||||
// add body class for currently loaded content
|
// 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
|
// 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)
|
if(m)
|
||||||
_$body.addClass('path-edlp-node');
|
_$body.addClass('path-edlp-node');
|
||||||
|
|
||||||
|
|||||||
@@ -1607,7 +1607,7 @@ footer {
|
|||||||
footer .block-block-edlp-entrees {
|
footer .block-block-edlp-entrees {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
display: inline-block; }
|
display: inline-block; }
|
||||||
body:not(.path-frontpage) footer .block-block-edlp-entrees {
|
body.path-productions footer .block-block-edlp-entrees {
|
||||||
display: none; }
|
display: none; }
|
||||||
footer .block-block-edlp-entrees ul {
|
footer .block-block-edlp-entrees ul {
|
||||||
white-space: nowrap; }
|
white-space: nowrap; }
|
||||||
|
|||||||
@@ -97,7 +97,7 @@
|
|||||||
// cartel functions
|
// cartel functions
|
||||||
loadNode(nid){
|
loadNode(nid){
|
||||||
this.$cartel.addClass('loading');
|
this.$cartel.addClass('loading');
|
||||||
$.getJSON('/edlp/node/'+nid+'/ajax/player_cartel', {})
|
$.getJSON('/edlp/ajax/json/node/'+nid+'/player_cartel', {})
|
||||||
.done(this.onNodeLoaded.bind(this))
|
.done(this.onNodeLoaded.bind(this))
|
||||||
.fail(this.onNodeLoadFail.bind(this));
|
.fail(this.onNodeLoadFail.bind(this));
|
||||||
},
|
},
|
||||||
@@ -219,11 +219,7 @@
|
|||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
// avoid already ajaxified links
|
// avoid already ajaxified links
|
||||||
// if($this.is('.ajax-enable')) return;
|
// if($this.is('.ajax-enable')) return;
|
||||||
var sys_path = $this.attr('data-drupal-link-system-path');
|
if($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]);
|
|
||||||
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
|
$this.on('click', onClickAjaxLink).addClass('ajax-enable');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -237,19 +233,28 @@
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
var sys_path = $(this).attr('data-drupal-link-system-path');
|
var sys_path = $(this).attr('data-drupal-link-system-path');
|
||||||
|
var ajax_path = sys_path;
|
||||||
if(sys_path == '<front>'){
|
if(sys_path == '<front>'){
|
||||||
backToFrontPage();
|
backToFrontPage();
|
||||||
return false;
|
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');
|
_$body.addClass('ajax-loading');
|
||||||
$link.addClass('ajax-loading');
|
$link.addClass('ajax-loading');
|
||||||
// check for viewmode attribute
|
|
||||||
path += '/ajax';
|
var path = window.location.origin + drupalSettings.path.baseUrl + ajax_path;
|
||||||
if($link.attr('viewmode') != ''){
|
|
||||||
path += '/'+$link.attr('viewmode');
|
|
||||||
}
|
|
||||||
$.getJSON(path, {})
|
$.getJSON(path, {})
|
||||||
.done(function(data){
|
.done(function(data){
|
||||||
onAjaxLinkLoaded(data, $link, sys_path);
|
onAjaxLinkLoaded(data, $link, sys_path);
|
||||||
@@ -275,9 +280,16 @@
|
|||||||
_$content_container.html(data.rendered);
|
_$content_container.html(data.rendered);
|
||||||
|
|
||||||
// add body class for currently loaded content
|
// 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
|
// 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)
|
if(m)
|
||||||
_$body.addClass('path-edlp-node');
|
_$body.addClass('path-edlp-node');
|
||||||
|
|
||||||
|
|||||||
@@ -590,7 +590,7 @@ footer{
|
|||||||
|
|
||||||
.block-block-edlp-entrees{
|
.block-block-edlp-entrees{
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
body:not(.path-frontpage) & {display:none}
|
body.path-productions & {display:none}
|
||||||
|
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
// vertical-align: top;
|
// 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>
|
||||||
+7
@@ -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>
|
||||||
@@ -28,7 +28,7 @@ module:
|
|||||||
editor: 0
|
editor: 0
|
||||||
edlp_admin: 0
|
edlp_admin: 0
|
||||||
edlp_agenda: 0
|
edlp_agenda: 0
|
||||||
edlp_ajax_node: 0
|
edlp_ajax: 0
|
||||||
edlp_corpus: 0
|
edlp_corpus: 0
|
||||||
edlp_fils: 0
|
edlp_fils: 0
|
||||||
edlp_home: 0
|
edlp_home: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user