[Tree] Display tree correctly

This commit is contained in:
Victor Woeltjen 2016-03-11 14:40:04 -08:00
parent dc2b3e85cc
commit 7ee8d0a3f7
3 changed files with 11 additions and 13 deletions

View File

@ -22,13 +22,13 @@
/*global define*/
define([
'angular',
'zepto',
'text!../../res/templates/tree/toggle.html'
], function (angular, toggleTemplate) {
], function ($, toggleTemplate) {
function ToggleView(state) {
this.expanded = !!state;
this.callbacks = [];
this.el = angular.element(toggleTemplate);
this.el = $(toggleTemplate);
this.el.on('click', function () {
this.model(!this.expanded);
}.bind(this));

View File

@ -22,15 +22,13 @@
/*global define*/
define([
'angular',
'zepto',
'text!../../res/templates/tree/node.html',
'./ToggleView',
'./TreeLabelView'
], function (angular, nodeTemplate, ToggleView, TreeLabelView) {
], function ($, nodeTemplate, ToggleView, TreeLabelView) {
'use strict';
var $ = angular.element.bind(angular);
function TreeNodeView(subtreeFactory) {
this.li = $('<li>');
@ -40,6 +38,8 @@ define([
if (!this.subtreeView) {
this.subtreeView = subtreeFactory();
this.subtreeView.model(this.activeObject);
this.li.find('.tree-item-subtree').eq(0)
.append($(this.subtreeView.elements()));
}
$(this.subtreeView.elements()).removeClass('hidden');
} else if (this.subtreeView) {
@ -51,8 +51,8 @@ define([
this.li.append($(nodeTemplate));
this.li.find('span').eq(0)
.append(this.toggleView.elements())
.append(this.labelView.elements());
.append($(this.toggleView.elements()))
.append($(this.labelView.elements()));
this.model(undefined);
}

View File

@ -22,13 +22,11 @@
/*global define*/
define([
'angular',
'zepto',
'./TreeNodeView'
], function (angular, TreeNodeView) {
], function ($, TreeNodeView) {
'use strict';
var $ = angular.element.bind(angular);
function TreeView() {
this.ul = $('<ul class="tree"></ul>');
this.nodeViews = [];