aboutsummaryrefslogtreecommitdiff
path: root/js/components/layout/bread-crumb.reel/bread-crumb.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/layout/bread-crumb.reel/bread-crumb.js')
-rwxr-xr-xjs/components/layout/bread-crumb.reel/bread-crumb.js48
1 files changed, 22 insertions, 26 deletions
diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js
index ac131f2c..a3c743a4 100755
--- a/js/components/layout/bread-crumb.reel/bread-crumb.js
+++ b/js/components/layout/bread-crumb.reel/bread-crumb.js
@@ -9,6 +9,11 @@ var Montage = require("montage/core/core").Montage,
9 9
10exports.Breadcrumb = Montage.create(Component, { 10exports.Breadcrumb = Montage.create(Component, {
11 11
12 breadcrumbBt: {
13 value: null,
14 serializable: true
15 },
16
12 _currentDocument: { 17 _currentDocument: {
13 enumerable: false, 18 enumerable: false,
14 value: null 19 value: null
@@ -51,22 +56,6 @@ exports.Breadcrumb = Montage.create(Component, {
51 } 56 }
52 }, 57 },
53 58
54 _container:{
55 value:null
56 },
57
58 container: {
59 set: function(value) {
60 if(this._container !== value) {
61 this._container = value;
62 this.createContainerElements();
63 }
64 },
65 get: function() {
66 return this._container;
67 }
68 },
69
70 containerElements: { 59 containerElements: {
71 value: [] 60 value: []
72 }, 61 },
@@ -74,31 +63,37 @@ exports.Breadcrumb = Montage.create(Component, {
74 prepareForDraw: { 63 prepareForDraw: {
75 value: function() { 64 value: function() {
76 this.breadcrumbBt.addEventListener("action", this, false); 65 this.breadcrumbBt.addEventListener("action", this, false);
66 this.addPropertyChangeListener("currentDocument.model.domContainer", this)
77 } 67 }
78 }, 68 },
79 69
80 createContainerElements: { 70 handleChange: {
81 value: function() { 71 value: function() {
82 var parentNode; 72 if(this.currentDocument && this.currentDocument.model.getProperty("domContainer")) {
73 this.createContainerElements(this.currentDocument.model.getProperty("domContainer"));
74 }
75 }
76 },
77
78 createContainerElements: {
79 value: function(container) {
83 80
84// delete this.containerElements; 81// delete this.containerElements;
85 this.containerElements = []; 82 this.containerElements = [];
86 83
87 parentNode = this.container; 84 while(container !== this.currentDocument.model.documentRoot) {
88 85 this.containerElements.unshift({"node": container, "nodeUuid":container.uuid, "label": container.nodeName});
89 while(parentNode !== this.currentDocument.model.documentRoot) { 86 container = container.parentNode;
90 this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName});
91 parentNode = parentNode.parentNode;
92 } 87 }
93 88
94 // This is always the top container which is now hardcoded to body 89 // This is always the top container which is now hardcoded to body
95 this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": parentNode.nodeName}); 90 this.containerElements.unshift({"node": container, "nodeUuid":container.uuid, "label": container.nodeName});
96 } 91 }
97 }, 92 },
98 93
99 handleAction: { 94 handleAction: {
100 value: function(evt) { 95 value: function(evt) {
101 if(evt.target.value === this.container.uuid) { 96 if(evt.target.value === this.currentDocument.model.domContainer.uuid) {
102 return; 97 return;
103 } 98 }
104 99
@@ -109,7 +104,8 @@ exports.Breadcrumb = Montage.create(Component, {
109 } 104 }
110 105
111 // TODO: This is bound 2 ways, update the internal property 106 // TODO: This is bound 2 ways, update the internal property
112 this.application.ninja.currentSelectedContainer = this.containerElements[i].node; 107 this.currentDocument.model.domContainer = this.containerElements[i].node;
108 this.application.ninja.selectionController.executeSelectElement();
113 } 109 }
114 } 110 }
115}); 111});