Skip to content
Snippets Groups Projects
Commit 4a512151 authored by Mingsong Hu's avatar Mingsong Hu
Browse files

Support more theme options for jsTree

parent 78d7c577
No related branches found
No related tags found
No related merge requests found
......@@ -14,13 +14,24 @@
const treeContainer = $(this);
const parentID = treeContainer.attr('parent-id');
const searchTextID = (parentID) ? '#hm-jstree-search-' + parentID : '#hm-jstree-search';
const theme = treeContainer.attr("theme");
const dots = treeContainer.attr("dots");
const optionsJson = treeContainer.attr("options");
const dataURL = treeContainer.attr('data-source') + '&parent=0';
const updateURL = treeContainer.attr('url-update')
let reload = true;
let rollback = false;
let after = 1;
let themes = {
dots: false,
name: 'default'
};
let options;
if (optionsJson) {
options = JSON.parse(optionsJson);
if (options.theme) {
themes = options.theme;
}
}
// Ajax callback to refresh the tree.
if (reload) {
// Build the tree.
......@@ -36,11 +47,7 @@
return node;
}
},
themes: {
dots: dots === '1',
name: theme
},
'check_callback' : true,
themes: themes,
"multiple": false,
},
search: {
......
......@@ -98,13 +98,7 @@ class HmMenuForm extends MenuForm {
$source_url = Url::fromRoute('hierarchy_manager.menu.tree.json', ['mid' => $mid], ['query' => ['token' => $token, 'destination' => $destination]])->toString();
$update_url = Url::fromRoute('hierarchy_manager.menu.tree.update', ['mid' => $mid], ['query' => ['token' => $token]])->toString();
$config = $display_profile->get("config");
if (!empty($config)) {
$options = json_decode($config);
}
else {
$options = NULL;
}
return $display_plugin_instance->getForm($source_url, $update_url, $form, $form_state, $options);
return $display_plugin_instance->getForm($source_url, $update_url, $form, $form_state, $config);
}
}
......
......@@ -62,13 +62,7 @@ class HmOverviewTerms extends OverviewTerms {
$source_url = Url::fromRoute('hierarchy_manager.taxonomy.tree.json', ['vid' => $vid], ['query' => ['token' => $token, 'destination' => $destination]])->toString();
$update_url = Url::fromRoute('hierarchy_manager.taxonomy.tree.update', ['vid' => $vid], ['query' => ['token' => $token]])->toString();
$config = $display_profile->get("config");
if (!empty($config)) {
$options = json_decode($config);
}
else {
$options = NULL;
}
return $instance->getForm($source_url, $update_url, $form, $form_state, $options);
return $instance->getForm($source_url, $update_url, $form, $form_state, $config);
}
}
}
......
......@@ -28,22 +28,16 @@ class HmDisplayJstree extends HmDisplayPluginBase implements HmDisplayPluginInte
$parent_id = $parent_formObj->getFormId();
}
// The jsTree theme.
// The jsTree default theme.
$theme = 'default';
$dot = '';
if (isset($options->theme)) {
if (isset($options->theme->name)) {
// The name of the theme.
$theme = $options->theme->name;
}
if (isset($options->theme->dot)) {
// The dot line setting.
$dot = $options->theme->dot ? '1' : '0';
if (!empty($options)) {
$jsonObj = json_decode($options);
if (isset($jsonObj->theme) && isset($jsonObj->theme->name)) {
$theme = $jsonObj->theme->name;
}
}
// Search input.
$form['search'] = [
'#type' => 'textfield',
......@@ -73,8 +67,7 @@ class HmDisplayJstree extends HmDisplayPluginBase implements HmDisplayPluginInte
],
'id' => isset($parent_id) ? 'hm-jstree-' . $parent_id : 'hm-jstree',
'parent-id' => isset($parent_id) ? $parent_id : '',
'theme' => $theme,
'dots' => $dot,
'options' => $options,
'data-source' => $url_source,
'url-update' => $url_update,
],
......
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