}
if ($type & self::TAG) {
- // CODE FROM CRM/Tag/Form/Tag.php //
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
- ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
-
$fName = 'tag';
if ($fieldName) {
$fName = $fieldName;
// get the list of all the categories
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree('civicrm_contact', TRUE);
+ // let's not load jstree if there are not children. This also fixes blank
+ // display at the beginning of checkboxes
+ $form->assign('loadjsTree', FALSE);
+ if (!empty(CRM_Utils_Array::retrieveValueRecursive($tree, 'children'))) {
+ // CODE FROM CRM/Tag/Form/Tag.php //
+ CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
+ ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
+ $form->assign('loadjsTree', TRUE);
+ }
$elements = array();
self::climbtree($form, $tree, $elements);
* @return void
*/
public function buildQuickForm() {
- CRM_Core_Resources::singleton()
- ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
- ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
// get categories for the contact id
$entityTag = CRM_Core_BAO_EntityTag::getTag($this->_entityID, $this->_entityTable);
$this->assign('tagged', $entityTag);
$tags = new CRM_Core_BAO_Tag();
$tree = $tags->getTree($this->_entityTable, TRUE);
+
+ // let's not load jstree if there are not children. This also fixes blank
+ // display at the beginning of checkboxes
+ $this->assign('loadjsTree', FALSE);
+ if (!empty(CRM_Utils_Array::retrieveValueRecursive($tree, 'children'))) {
+ CRM_Core_Resources::singleton()
+ ->addScriptFile('civicrm', 'packages/jquery/plugins/jstree/jquery.jstree.js', 0, 'html-header', FALSE)
+ ->addStyleFile('civicrm', 'packages/jquery/plugins/jstree/themes/default/style.css', 0, 'html-header');
+ $this->assign('loadjsTree', TRUE);
+ }
$this->assign('tree', $tree);
$this->assign('tag', $allTag);
background: none repeat scroll 0 0 transparent;
}
+/* unset the styling for the li in jstree */
+#tagtree ul {
+ list-style: none;
+ margin: 0px;
+ padding: 0px;
+}
+
/* Class for successful upgrade */
.crm-container .upgrade-success {
background-color: #00CC00;
highlightSelected();
});
- //load js tree.
- $("#tagtree").jstree({
- plugins : ["themes", "html_data"],
- themes: {
- "theme": 'classic',
- "dots": false,
- "icons": false,
- "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
- }
- });
-
+ var childTag = {/literal}{$loadjsTree}{literal};
+ if (childTag) {
+ //load js tree.
+ $("#tagtree").jstree({
+ plugins : ["themes", "html_data"],
+ themes: {
+ "theme": 'classic',
+ "dots": false,
+ "icons": false,
+ "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
+ }
+ });
+ }
{/literal}
{if !empty($permission) && $permission neq 'edit'}
{literal}
{$form.group.html}
</td>
{/if}
+ {if !$type || $type eq 'tag'}
+ <td width="70%">{if $title}<span class="label">{$form.tag.label}</span>{/if}
+ <div id="tagtree">
+ {include file="CRM/Contact/Form/Edit/Tagtree.tpl" level=1}
+ </div>
+ </td>
+ <tr><td>{include file="CRM/common/Tagset.tpl"}</td></tr>
+ {/if}
</tr>
-
- {if !$type || $type eq 'tag'}
- <tr>
- <td width="70%"><span class="label">{if $title}{$form.$key.label}{/if}</span>
- <div id="tagtree">
- {include file="CRM/Contact/Form/Edit/Tagtree.tpl" level=1}
- </div>
- </td>
- </tr>
- <tr><td>{include file="CRM/common/Tagset.tpl"}</td></tr>
- {/if}
- </table>
+ </table>
{if $title}
</div>
</div><!-- /.crm-accordion-wrapper -->
highlightSelected();
CRM.updateContactSummaryTags();
});
-
- //load js tree.
- $("#tagtree").jstree({
- plugins : ["themes", "html_data"],
- themes: {
- "theme": 'classic',
- "dots": false,
- "icons": false,
- "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
- }
- });
-
+ var childTag = {/literal}{$loadjsTree}{literal};
+ if (childTag) {
+ //load js tree.
+ $("#tagtree").jstree({
+ plugins : ["themes", "html_data"],
+ themes: {
+ "theme": 'classic',
+ "dots": false,
+ "icons": false,
+ "url": CRM.config.resourceBase + 'packages/jquery/plugins/jstree/themes/classic/style.css'
+ }
+ });
+ }
{/literal}
{if $permission neq 'edit'}
{literal}