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