Skip to content
Snippets Groups Projects
Commit b2968a25 authored by Matthias Konitzny's avatar Matthias Konitzny :fire:
Browse files

Added "mode" shortcode attribute to control graph behaviour

parent d229dbbb
No related branches found
No related tags found
No related merge requests found
...@@ -13,6 +13,7 @@ export const COLOR_PALETTE = [ ...@@ -13,6 +13,7 @@ export const COLOR_PALETTE = [
// Just renaming a variable which is given by the PHP script. This avoids errors in all other files. // Just renaming a variable which is given by the PHP script. This avoids errors in all other files.
export const PLUGIN_PATH = ks_global.plugin_path; export const PLUGIN_PATH = ks_global.plugin_path;
export var SPACE = ks_global.space_id; export var SPACE = ks_global.space_id;
export const MODE = ks_global.mode;
export function setSpace(space) { export function setSpace(space) {
SPACE = space; SPACE = space;
......
...@@ -9,6 +9,7 @@ import { ...@@ -9,6 +9,7 @@ import {
CSS3DRenderer, CSS3DRenderer,
CSS3DSprite, CSS3DSprite,
} from "three/examples/jsm/renderers/CSS3DRenderer.js"; } from "three/examples/jsm/renderers/CSS3DRenderer.js";
import { MODE } from "../config";
/** /**
* The main ForceGraph. Displays the graph and handles all connected events. * The main ForceGraph. Displays the graph and handles all connected events.
...@@ -60,7 +61,9 @@ export default class Graph { ...@@ -60,7 +61,9 @@ export default class Graph {
.linkWidth((link) => this.getLinkWidth(link)) .linkWidth((link) => this.getLinkWidth(link))
.onNodeClick((node) => { .onNodeClick((node) => {
this.focusOnNode(node); this.focusOnNode(node);
this.infoOverlay.updateInfoOverlay(node); if (MODE === "default") {
this.infoOverlay.updateInfoOverlay(node);
}
}) })
.onNodeHover((node) => { .onNodeHover((node) => {
this.onNodeHover(node); this.onNodeHover(node);
......
...@@ -21,6 +21,14 @@ function ks_add_graph($atts = []): string ...@@ -21,6 +21,14 @@ function ks_add_graph($atts = []): string
return $div; return $div;
} }
function parse_atts($atts)
{
return shortcode_atts(array(
'space' => 'space',
'mode' => 'default'
), $atts);
}
function ks_echo_graph($atts = []): void function ks_echo_graph($atts = []): void
{ {
echo ks_add_graph($atts); echo ks_add_graph($atts);
...@@ -28,7 +36,15 @@ function ks_echo_graph($atts = []): void ...@@ -28,7 +36,15 @@ function ks_echo_graph($atts = []): void
function ks_localize($handle, $atts) function ks_localize($handle, $atts)
{ {
$space_id = kg_get_space_id_from_atts($atts); $params = parse_atts($atts);
if ($GLOBALS['build'] == 'debug'){
echo '<pre>';
echo "Shortcode attributes:<br>";
print_r($params);
echo '</pre>';
}
$space_id = kg_get_space_id_from_atts($atts); // TODO: Replace with $params
$plugin_dir = plugin_dir_url(__FILE__); $plugin_dir = plugin_dir_url(__FILE__);
wp_localize_script( wp_localize_script(
$handle, $handle,
...@@ -36,7 +52,8 @@ function ks_localize($handle, $atts) ...@@ -36,7 +52,8 @@ function ks_localize($handle, $atts)
array( array(
'ajax_url' => admin_url('admin-ajax.php'), 'ajax_url' => admin_url('admin-ajax.php'),
'space_id' => $space_id, 'space_id' => $space_id,
'plugin_path' => $plugin_dir 'plugin_path' => $plugin_dir,
'mode' => $params['mode']
) )
); );
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment