comparison core.js @ 833:39f982f9f9f1

Enter key press will always trigger 'next' in any popup survey
author Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk>
date Fri, 27 Nov 2015 12:20:56 +0000
parents 16ee07203740
children 2647dd909229
comparison
equal deleted inserted replaced
832:00614dce607d 833:39f982f9f9f1
137 blank.style.zIndex = 2; 137 blank.style.zIndex = 2;
138 blank.style.visibility = 'visible'; 138 blank.style.visibility = 'visible';
139 $(window).keypress(function(e){ 139 $(window).keypress(function(e){
140 if (e.keyCode == 13 && popup.popup.style.visibility == 'visible') 140 if (e.keyCode == 13 && popup.popup.style.visibility == 'visible')
141 { 141 {
142 // Enter key pressed
143 var textarea = $(popup.popupContent).find('textarea');
144 if (textarea.length != 0)
145 {
146 if (textarea[0] == document.activeElement)
147 {return;}
148 }
149 popup.buttonProceed.onclick(); 142 popup.buttonProceed.onclick();
150 } 143 }
151 }); 144 });
152 }; 145 };
153 146
156 this.popup.style.visibility = 'hidden'; 149 this.popup.style.visibility = 'hidden';
157 var blank = document.getElementsByClassName('testHalt')[0]; 150 var blank = document.getElementsByClassName('testHalt')[0];
158 blank.style.zIndex = -2; 151 blank.style.zIndex = -2;
159 blank.style.visibility = 'hidden'; 152 blank.style.visibility = 'hidden';
160 this.buttonPrevious.style.visibility = 'inherit'; 153 this.buttonPrevious.style.visibility = 'inherit';
154 $(window).keypress(function(e){});
161 }; 155 };
162 156
163 this.postNode = function() { 157 this.postNode = function() {
164 // This will take the node from the popupOptions and display it 158 // This will take the node from the popupOptions and display it
165 var node = this.popupOptions[this.currentIndex]; 159 var node = this.popupOptions[this.currentIndex];
187 break; 181 break;
188 case 'huge': 182 case 'huge':
189 textArea.cols = "50"; 183 textArea.cols = "50";
190 textArea.rows = "10"; 184 textArea.rows = "10";
191 break; 185 break;
192 }
193 document.onkeydown=function(){
194 if(window.event.keyCode=='13'){ // when you hit enter
195 window.event.preventDefault(); // don't make newline
196 popup.proceedClicked(); // go to the next window (or start the test or submit)
197 }
198 } 186 }
199 this.popupResponse.appendChild(textArea); 187 this.popupResponse.appendChild(textArea);
200 textArea.focus(); 188 textArea.focus();
201 } else if (node.type == 'checkbox') { 189 } else if (node.type == 'checkbox') {
202 this.popupTitle.textContent = node.statement; 190 this.popupTitle.textContent = node.statement;