aboutsummaryrefslogtreecommitdiff
path: root/js/components
diff options
context:
space:
mode:
Diffstat (limited to 'js/components')
-rw-r--r--js/components/editable.reel/editable.js18
-rw-r--r--js/components/hintable.reel/hintable.js20
-rwxr-xr-xjs/components/layout/bread-crumb.reel/bread-crumb.js4
3 files changed, 31 insertions, 11 deletions
diff --git a/js/components/editable.reel/editable.js b/js/components/editable.reel/editable.js
index 9c8946c4..dad93b31 100644
--- a/js/components/editable.reel/editable.js
+++ b/js/components/editable.reel/editable.js
@@ -38,6 +38,7 @@ exports.Editable = Montage.create(Component, {
38 set : function(el) { 38 set : function(el) {
39 this._element = el; 39 this._element = el;
40 this._element.addEventListener('keydown', this, false); 40 this._element.addEventListener('keydown', this, false);
41 this._element.addEventListener('keyup', this, false);
41 this._element.addEventListener('input', this, false); 42 this._element.addEventListener('input', this, false);
42 43
43 if(this.startOnEvent) { 44 if(this.startOnEvent) {
@@ -115,12 +116,15 @@ exports.Editable = Montage.create(Component, {
115 ///// Save the preEditValue 116 ///// Save the preEditValue
116 this._preEditValue = this.value; 117 this._preEditValue = this.value;
117 118
119 // Initialize enteredValue with current value
120 this.enteredValue = this.value;
121
118 if(this.selectOnStart) { 122 if(this.selectOnStart) {
119 this.selectAll(); 123 this.selectAll();
120 } 124 }
121 125
122 if(this.stopOnBlur) { 126 if(this.stopOnBlur) {
123 console.log('adding mousedown event listener'); 127 //console.log('adding mousedown event listener');
124 ///// Simulate blur on editable node by listening to the doc 128 ///// Simulate blur on editable node by listening to the doc
125 document.addEventListener('mouseup', this, false); 129 document.addEventListener('mouseup', this, false);
126 } 130 }
@@ -189,7 +193,13 @@ exports.Editable = Montage.create(Component, {
189 handleKeydown : { 193 handleKeydown : {
190 value : function(e) { 194 value : function(e) {
191 var k = e.keyCode; 195 var k = e.keyCode;
192 console.log('keyCode: ' + k); 196 }
197 },
198
199 handleKeyup : {
200 value : function(e) {
201 // Record change in value
202 this.enteredValue = this._element.firstChild.data;
193 } 203 }
194 }, 204 },
195 ///// Text input has changed values 205 ///// Text input has changed values
@@ -204,7 +214,7 @@ exports.Editable = Montage.create(Component, {
204 }, 214 },
205 handleMouseup : { 215 handleMouseup : {
206 value : function(e) { 216 value : function(e) {
207 console.log('handle mouse down'); 217 //console.log('handle mouse down');
208 ///// Listen for simulated blur event 218 ///// Listen for simulated blur event
209 if(this.stopOnBlur && e._event.target !== this._element) { 219 if(this.stopOnBlur && e._event.target !== this._element) {
210 this.blur(); 220 this.blur();
@@ -213,7 +223,7 @@ exports.Editable = Montage.create(Component, {
213 }, 223 },
214 handleEvent : { 224 handleEvent : {
215 value : function(e) { 225 value : function(e) {
216 console.log("event type : " + e._event.type); 226 //console.log("event type : " + e._event.type);
217 ///// If configured, start on specified event 227 ///// If configured, start on specified event
218 if(e._event.type === this.startOnEvent) { 228 if(e._event.type === this.startOnEvent) {
219 this.start(); 229 this.start();
diff --git a/js/components/hintable.reel/hintable.js b/js/components/hintable.reel/hintable.js
index 5ed46b3c..6e3b2aaf 100644
--- a/js/components/hintable.reel/hintable.js
+++ b/js/components/hintable.reel/hintable.js
@@ -90,10 +90,10 @@ exports.Hintable = Montage.create(Editable, {
90 hintNext : { 90 hintNext : {
91 value : function(e) { 91 value : function(e) {
92 if(e) { e.preventDefault(); } 92 if(e) { e.preventDefault(); }
93 console.log('next1'); 93 //console.log('next1');
94 94
95 if(this._matchIndex < this.matches.length - 1) { 95 if(this._matchIndex < this.matches.length - 1) {
96 console.log('next'); 96 //console.log('next');
97 ++this._matchIndex; 97 ++this._matchIndex;
98 this.hint = this._getHintDifference(); 98 this.hint = this._getHintDifference();
99 } 99 }
@@ -102,9 +102,9 @@ exports.Hintable = Montage.create(Editable, {
102 hintPrev : { 102 hintPrev : {
103 value : function(e) { 103 value : function(e) {
104 if(e) { e.preventDefault(); } 104 if(e) { e.preventDefault(); }
105 console.log('prev1'); 105 //console.log('prev1');
106 if(this._matchIndex !== 0) { 106 if(this._matchIndex !== 0) {
107 console.log('prev'); 107 //console.log('prev');
108 --this._matchIndex; 108 --this._matchIndex;
109 this.hint = this._getHintDifference(); 109 this.hint = this._getHintDifference();
110 } 110 }
@@ -135,7 +135,7 @@ exports.Hintable = Montage.create(Editable, {
135 /// revert to old value 135 /// revert to old value
136 this.value = (this._preEditValue); 136 this.value = (this._preEditValue);
137 this._sendEvent('revert'); 137 this._sendEvent('revert');
138 console.log('reverting'); 138 //console.log('reverting');
139 139
140 } 140 }
141 } 141 }
@@ -157,6 +157,14 @@ exports.Hintable = Montage.create(Editable, {
157 157
158 this._super(arguments); 158 this._super(arguments);
159 159
160 /// Remove the phantom "<BR>" element that is generated when
161 /// content editable element is empty
162 this._children(this._element, function(item) {
163 return item.nodeName === 'BR';
164 }).forEach(function(item) {
165 this._element.removeChild(item);
166 }, this);
167
160 if(k === 39) { 168 if(k === 39) {
161 selection = window.getSelection(); 169 selection = window.getSelection();
162 text = selection.baseNode.textContent; 170 text = selection.baseNode.textContent;
@@ -180,7 +188,7 @@ exports.Hintable = Montage.create(Editable, {
180 188
181 var val = this.value, 189 var val = this.value,
182 matches, hint; 190 matches, hint;
183 console.log('val = "' + val + '"'); 191 //console.log('val = "' + val + '"');
184 //// Handle auto-suggest if configured 192 //// Handle auto-suggest if configured
185 if(this.hints instanceof Array) { 193 if(this.hints instanceof Array) {
186 194
diff --git a/js/components/layout/bread-crumb.reel/bread-crumb.js b/js/components/layout/bread-crumb.reel/bread-crumb.js
index f35972b6..faf5e2f8 100755
--- a/js/components/layout/bread-crumb.reel/bread-crumb.js
+++ b/js/components/layout/bread-crumb.reel/bread-crumb.js
@@ -23,6 +23,7 @@ exports.Breadcrumb = Montage.create(Component, {
23 value: function(){ 23 value: function(){
24 if(!this.application.ninja.documentController.activeDocument) { 24 if(!this.application.ninja.documentController.activeDocument) {
25 this.disabled = true; 25 this.disabled = true;
26 this.application.ninja.currentSelectedContainer = this.application.ninja.currentDocument.documentRoot;
26 } 27 }
27 } 28 }
28 }, 29 },
@@ -70,7 +71,7 @@ exports.Breadcrumb = Montage.create(Component, {
70 71
71 // This is always the top container which is now hardcoded to body 72 // This is always the top container which is now hardcoded to body
72 this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": "Body"}); 73 this.containerElements.unshift({"node": parentNode, "nodeUuid":parentNode.uuid, "label": "Body"});
73 74 NJevent("breadCrumbBinding",this)
74 75
75 76
76 } 77 }
@@ -79,6 +80,7 @@ exports.Breadcrumb = Montage.create(Component, {
79 handleAction: { 80 handleAction: {
80 value: function(evt) { 81 value: function(evt) {
81 82
83 this.application.ninja.currentDocument.breadCrumbClick=true;
82 if(evt.target.value === this.container.uuid) { 84 if(evt.target.value === this.container.uuid) {
83 return; 85 return;
84 } 86 }