Bläddra i källkod

Prevent some doubled actions, fix runtime error

Yevhen Pavliuk 8 år sedan
förälder
incheckning
f1b24e9002
1 ändrade filer med 8 tillägg och 14 borttagningar
  1. 8
    14
      src/editor.html

+ 8
- 14
src/editor.html Visa fil

827
 				});
827
 				});
828
 			}
828
 			}
829
 
829
 
830
-			function setupSelectionChange(editorId) {
831
-				$(document).on('selectionchange',function(e){
832
-					zss_editor.calculateEditorHeightWithCaretPosition(editorId);
833
-					zss_editor.setScrollPosition();
834
-					zss_editor.enabledEditingItems(e);
835
-				});
836
-			}
837
-
838
 			function setupTouchEndFocus(editorId) {
830
 			function setupTouchEndFocus(editorId) {
839
 				$(window).on('touchend', function(e) {
831
 				$(window).on('touchend', function(e) {
840
 					if (!zss_editor.isDragging && (e.target.id == "zss_editor_footer"||e.target.nodeName.toLowerCase() == "html")) {
832
 					if (!zss_editor.isDragging && (e.target.id == "zss_editor_footer"||e.target.nodeName.toLowerCase() == "html")) {
879
 				setupTouchEndEnableEditing('zss_editor_title');
871
 				setupTouchEndEnableEditing('zss_editor_title');
880
 				setupTouchEndEnableEditing('zss_editor_content');
872
 				setupTouchEndEnableEditing('zss_editor_content');
881
 
873
 
882
-				setupSelectionChange('zss_editor_title');
883
-				setupSelectionChange('zss_editor_content');
874
+				$(document).on('selectionchange',function(e){
875
+					console.log('selectionchange');
876
+					zss_editor.calculateEditorHeightWithCaretPosition();
877
+					zss_editor.setScrollPosition();
878
+					zss_editor.enabledEditingItems(e);
879
+				});
884
 
880
 
885
 				$(window).on('scroll', function(e) {
881
 				$(window).on('scroll', function(e) {
886
 					zss_editor.updateOffset();
882
 					zss_editor.updateOffset();
1014
 				return topPosition;
1010
 				return topPosition;
1015
 			}
1011
 			}
1016
 
1012
 
1017
-			zss_editor.calculateEditorHeightWithCaretPosition = function(editorId) {
1013
+			zss_editor.calculateEditorHeightWithCaretPosition = function() {
1018
 
1014
 
1019
 				var padding = 50;
1015
 				var padding = 50;
1020
 				var c = zss_editor.getCaretYPosition();
1016
 				var c = zss_editor.getCaretYPosition();
1021
-				var e = document.getElementById(editorId);
1022
-
1023
-				var editor = $(`#${editorId}`);
1024
 
1017
 
1025
 				var offsetY = window.document.body.scrollTop;
1018
 				var offsetY = window.document.body.scrollTop;
1026
 				var height = zss_editor.contentHeight;
1019
 				var height = zss_editor.contentHeight;
1682
 		<div id="zss_editor_title" class="zss_editor_title" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
1675
 		<div id="zss_editor_title" class="zss_editor_title" contenteditable="true" placeholder="" disableLineBreaks="true"></div>
1683
 		<div id="separatorContainer"><hr></div>
1676
 		<div id="separatorContainer"><hr></div>
1684
 		<div id="zss_editor_content" class="zs_editor_content" contenteditable="true" placeholder=""></div>
1677
 		<div id="zss_editor_content" class="zs_editor_content" contenteditable="true" placeholder=""></div>
1678
+		<div id="zss_editor_footer"></div>
1685
 	</body>
1679
 	</body>
1686
 </html>
1680
 </html>