@@ -31,15 +31,15 @@ function mclick(myrect, word){
3131
3232
3333function setupMouseOverInteractions ( word ) {
34- word . rectSVG . mouseover ( function ( ) { mover ( word ) } ) ;
35- word . rectSVG . mouseout ( function ( ) { mout ( word ) } ) ;
34+ word . aboveRect . mouseover ( function ( ) { mover ( word ) } ) ;
35+ word . aboveRect . mouseout ( function ( ) { mout ( word ) } ) ;
3636 word . leftHandle . mouseover ( function ( ) { mover ( word ) } ) ;
3737 word . leftHandle . mouseout ( function ( ) { mout ( word ) } ) ;
3838
3939 word . rightHandle . mouseover ( function ( ) { mover ( word ) } ) ;
4040 word . rightHandle . mouseout ( function ( ) { mout ( word ) } ) ;
4141
42- word . rectSVG . mousemove ( function ( ) {
42+ word . aboveRect . mousemove ( function ( ) {
4343 // console.log("touchleave!");
4444 } ) ;
4545
@@ -255,19 +255,6 @@ function addDragStartingAndEndingListeners(elem) {
255255 prevX = - 1 ;
256256 console . log ( "dragEnd B - isDragging = " + isDragging ) ;
257257
258- if ( dragElem instanceof Word ) { //also check if x,y has changed, since even a click in place will trigger a dragEnd, which we don't want
259-
260- //dragElem.leftHandle.style(styles.handleFill.style);
261- //dragElem.rightHandle.style(styles.handleFill.style);
262-
263- //realignWords(); //overkill? this is kind of a hack - shouldn't need it - but right now sometimes words get stuck off a row when moving words to the right... not sure why, shouldn't happen!
264-
265- //redrawLinks(true);
266-
267- dragElem = null ;
268-
269-
270- }
271258
272259 } )
273260
@@ -418,17 +405,15 @@ function checkDragDirection(x) {
418405 return dragDir ;
419406}
420407
421- function setUpLeftHandleDraggable ( leftHandle , rect , text , word , i ) {
408+ function setUpLeftHandleDraggable ( word ) {
422409
423- addDragStartingAndEndingListeners ( leftHandle ) ;
410+ addDragStartingAndEndingListeners ( word . leftHandle ) ;
424411
425- leftHandle . draggable ( function ( x , y ) {
412+ word . leftHandle . draggable ( function ( x , y ) {
426413 rowOffsetWord = word ;
427414
428- var returnVal = dragLeftHandle ( x , leftHandle . bbox ( ) . y , word ) ;
415+ var returnVal = dragLeftHandle ( x , word . leftHandle . bbox ( ) . y , word ) ;
429416
430- //console.log("in leftHandle.draggable");
431-
432417 updateWords ( ) ;
433418
434419 redrawLinks ( false ) ; //actually - only redraw links that moving this word would affect + this row
@@ -437,15 +422,14 @@ function setUpLeftHandleDraggable(leftHandle, rect, text, word, i) {
437422 } ) ;
438423}
439424
440- function setUpRightHandleDraggable ( rightHandle , rect , text , word , i ) {
425+ function setUpRightHandleDraggable ( word ) {
441426
442- addDragStartingAndEndingListeners ( rightHandle ) ;
427+ addDragStartingAndEndingListeners ( word . rightHandle ) ;
443428
444- rightHandle . draggable ( function ( x , y ) {
429+ word . rightHandle . draggable ( function ( x , y ) {
445430 rowOffsetWord = word ;
446431
447- var returnVal = dragRightHandle ( x , rightHandle . bbox ( ) . y , word ) ;
448- //console.log("in rightHandle.draggable");
432+ var returnVal = dragRightHandle ( x , word . rightHandle . bbox ( ) . y , word ) ;
449433
450434 updateWords ( ) ;
451435
@@ -457,8 +441,6 @@ function setUpRightHandleDraggable(rightHandle, rect, text, word, i) {
457441
458442function dragLeftHandle ( x , y , word ) {
459443
460- dragElem = word ; //is this being used? TODO remove if not
461-
462444 var dragDir = checkDragDirection ( x ) ;
463445
464446 if ( dragDir == directions . BACKWARD ) {
@@ -498,9 +480,6 @@ function checkIfCanDragLeftHandleRight(x, y, word) {
498480
499481function dragRightHandle ( x , y , word ) {
500482
501- dragElem = word ;
502-
503-
504483 var dragDir = checkDragDirection ( x ) ;
505484
506485 if ( dragDir == directions . BACKWARD ) {
@@ -566,8 +545,8 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) {
566545 prevWordX = prevWord . tempX ;
567546 prevWordW = prevWord . tempW ;
568547 } else {
569- prevWordX = prevWord . rect . x ;
570- prevWordW = prevWord . rect . w ;
548+ prevWordX = prevWord . bbox . x ;
549+ prevWordW = prevWord . bbox . w ;
571550 }
572551
573552 //make sure our X val isn't *before* the rightX of the previous word
@@ -631,12 +610,12 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) {
631610 nextWordX = nextWord . tempX ;
632611 nextWordW = nextWord . tempW ;
633612 } else {
634- nextWordX = nextWord . rect . x ;
635- nextWordW = nextWord . rect . w ;
613+ nextWordX = nextWord . bbox . x ;
614+ nextWordW = nextWord . bbox . w ;
636615 }
637616
638617 if ( rx + w > nextWordX ) { //then need to push the next word
639- checkIfCanMoveRight ( rx + w , nextWordW , nextWord . rectSVG . y ( ) , nextWord , false ) ;
618+ checkIfCanMoveRight ( rx + w , nextWordW , nextWord . aboveRect . y ( ) , nextWord , false ) ;
640619 }
641620 }
642621
@@ -653,8 +632,8 @@ function checkIfCanMoveRight(x, w, y, word, adjustWidth) {
653632 prevWordX = prevWord . tempX ;
654633 prevWordW = prevWord . tempW ;
655634 } else {
656- prevWordX = prevWord . rect . x ;
657- prevWordW = prevWord . rect . w ;
635+ prevWordX = prevWord . bbox . x ;
636+ prevWordW = prevWord . bbox . w ;
658637 }
659638
660639 checkIfCanMoveRight ( prevWordX , prevWordW , y , prevWord , false ) ;
@@ -684,7 +663,7 @@ function checkIfCanMoveLeft(x, w, y, word, adjustWidth) {
684663 }
685664
686665 rx = svgWidth - edgepadding - w ;
687- ry = word . rect . y ;
666+ ry = word . bbox . y ;
688667
689668 //refire this checkIfCanMoveLeft, since it will push words on the previous row out of the way, if needed -- may break up this method into little pieces so can fire something more granular
690669 checkIfCanMoveLeft ( rx , w , y , word , false ) ;
@@ -707,8 +686,8 @@ function checkIfCanMoveLeft(x, w, y, word, adjustWidth) {
707686 prevWordX = prevWord . tempX ;
708687 prevWordW = prevWord . tempW ;
709688 } else {
710- prevWordX = prevWord . rect . x ;
711- prevWordW = prevWord . rect . w ;
689+ prevWordX = prevWord . bbox . x ;
690+ prevWordW = prevWord . bbox . w ;
712691 }
713692
714693 if ( rx < prevWordX + prevWordW ) {
@@ -749,21 +728,21 @@ function checkIfCanMoveLeft(x, w, y, word, adjustWidth) {
749728function moveWordToNewPosition ( w , nx , ny ) {
750729
751730 w . tempX = nx ;
752- w . tempW = w . rect . w ;
731+ w . tempW = w . bbox . w ;
753732
754- w . rectSVG . x ( nx ) ;
755- w . rectSVG . y ( ny ) ;
733+ w . aboveRect . x ( nx ) ;
734+ w . aboveRect . y ( ny ) ;
756735
757- w . rect = w . rectSVG . bbox ( ) ;
736+ w . bbox = w . aboveRect . bbox ( ) ;
758737 w . leftX = nx ;
759- w . rightX = nx + w . rect . w ;
738+ w . rightX = nx + w . bbox . w ;
760739
761740 w . percPos = ( w . leftX - edgepadding ) / ( svgWidth - edgepadding * 2 ) ;
762741
763742 w . underneathRect . x ( nx ) ;
764743 w . underneathRect . y ( ny ) ;
765744
766- w . text . x ( nx + ( w . rect . w / 2 ) - ( w . text . bbox ( ) . w / 2 ) ) ;
745+ w . text . x ( nx + ( w . bbox . w / 2 ) - ( w . text . bbox ( ) . w / 2 ) ) ;
767746 w . text . y ( ny + textpaddingY * 2 ) ; // - texts.wordText.descent);
768747
769748
@@ -772,7 +751,7 @@ function moveWordToNewPosition(w, nx, ny) {
772751 //Looks like the entire row size jumps one pixel when adding a new row... think this may cause the 1 px differentce
773752
774753 if ( w . tag != null ) {
775- w . tagtext . x ( nx + ( w . rect . w / 2 ) - ( w . tagtext . bbox ( ) . w / 2 ) ) ;
754+ w . tagtext . x ( nx + ( w . bbox . w / 2 ) - ( w . tagtext . bbox ( ) . w / 2 ) ) ;
776755 w . tagtext . y ( ny + textpaddingY / 2 ) ; // - texts.tagText.descent);
777756 }
778757
@@ -805,16 +784,15 @@ function setWordToXW(word, xval, wval) {
805784}
806785
807786function dragWord ( x , y , word ) {
808- dragElem = word ;
809787
810788 var dragDir = checkDragDirection ( x ) ;
811789
812790 if ( dragDir == directions . BACKWARD ) {
813- return checkIfCanMoveLeft ( x + rowOffsetX , word . rectSVG . width ( ) , y , word , false ) ;
791+ return checkIfCanMoveLeft ( x + rowOffsetX , word . aboveRect . bbox ( ) . width , y , word , false ) ;
814792 } else if ( dragDir == directions . FORWARD ) {
815- return checkIfCanMoveRight ( x + rowOffsetX , word . rectSVG . width ( ) , y , word , false ) ;
793+ return checkIfCanMoveRight ( x + rowOffsetX , word . aboveRect . bbox ( ) . width , y , word , false ) ;
816794 } else {
817- return { x :word . rectSVG . bbox ( ) . x , y :word . rectSVG . bbox ( ) . y } ;
795+ return { x :word . aboveRect . bbox ( ) . x , y :word . aboveRect . bbox ( ) . y } ;
818796 }
819797}
820798
@@ -824,7 +802,7 @@ function checkIfSpaceToMoveUpARow(width, prevRow) {
824802
825803 for ( var i = prevRow . words . length - 1 ; i >= 0 ; i -- ) {
826804 prevWord = prevRow . words [ i ] ;
827- cw += prevWord . rect . w ;
805+ cw += prevWord . bbox . w ;
828806
829807 if ( cw > rowWidth ) {
830808
@@ -834,7 +812,7 @@ function checkIfSpaceToMoveUpARow(width, prevRow) {
834812
835813 var pw = 0 ;
836814 for ( var ii = i ; ii >= 0 ; ii -- ) {
837- pw += prevWord . rect . w ;
815+ pw += prevWord . bbox . w ;
838816 }
839817
840818 return checkIfSpaceToMoveUpARow ( pw , rows [ prevRow . idx - 1 ] ) ;
@@ -854,7 +832,7 @@ function checkIfSpaceToMoveDownARow(width, nextRow) {
854832 //how many words on the next row would have to move forward for this word to fit on the next row?
855833 for ( var i = 0 ; i < nextRow . words . length ; i ++ ) {
856834 nextWord = nextRow . words [ i ] ;
857- cw += nextWord . rect . w ;
835+ cw += nextWord . bbox . w ;
858836
859837 if ( cw > rowWidth ) {
860838 //console.log("no, width doesn't fit on this row #... " + nextRow.idx);
@@ -865,7 +843,7 @@ function checkIfSpaceToMoveDownARow(width, nextRow) {
865843
866844 var nw = 0 ;
867845 for ( var ii = i ; ii < nextRow . words . length ; ii ++ ) {
868- nw += nextWord . rect . w ;
846+ nw += nextWord . bbox . w ;
869847 }
870848
871849 return checkIfSpaceToMoveDownARow ( nw , rows [ nextRow . idx + 1 ] ) ;
@@ -915,7 +893,7 @@ function moveWordUpARow(w) {
915893 if ( w . needsUpdate ) {
916894 nx = svgWidth - edgepadding - w . tempW ;
917895 } else {
918- nx = svgWidth - edgepadding - ( w . rightX - w . leftX ) ; //w.rectSVG .width();
896+ nx = svgWidth - edgepadding - ( w . rightX - w . leftX ) ; //w.aboveRect .width();
919897 }
920898
921899 moveWordToNewPosition ( w , nx , ny ) ;
@@ -936,14 +914,14 @@ function moveWordUpARow(w) {
936914
937915function setUpWordDraggable ( word ) {
938916
939- addDragStartingAndEndingListeners ( word . rectSVG ) ;
917+ addDragStartingAndEndingListeners ( word . aboveRect ) ;
940918
941- var dragEvent = word . rectSVG . draggable ( function ( x , y ) {
919+ var dragEvent = word . aboveRect . draggable ( function ( x , y ) {
942920 //return aaa(x,y);
943921
944922 rowOffsetWord = word ;
945923
946- var returnXY = dragWord ( x , word . rect . y , word ) ;
924+ var returnXY = dragWord ( x , word . bbox . y , word ) ;
947925
948926 //console.log("in word.draggable");
949927
@@ -961,6 +939,7 @@ function setUpWordDraggable(word) {
961939function dragRow ( x , y , row ) {
962940
963941 var prevY = row . rect . bbox ( ) . y ;
942+ //var prevY = row.bbox.y;
964943 var inc = y - prevY ;
965944
966945 var nextRowTooSmall = false ;
@@ -978,7 +957,7 @@ function dragRow(x, y, row) {
978957 //check that this row is not smaller than the word size in the row
979958
980959 if ( inc + dragRectSide + dragRectMargin < wordHeight ) {
981- row . rect . height ( wordHeight ) ;
960+ row . bbox . height ( wordHeight ) ;
982961 y = row . rect . bbox ( ) . y + row . rect . bbox ( ) . h - ( dragRectSide + dragRectMargin ) ;
983962 row . lineBottom . y ( y + dragRectSide + dragRectMargin ) ;
984963 } else if ( row . idx < rows . length - 1 && nextRowTooSmall == true ) { //check that this row is not expanding so large that it is bigger than the next row's smallest size
@@ -995,7 +974,7 @@ function dragRow(x, y, row) {
995974
996975
997976 for ( var i = 0 ; i < row . words . length ; i ++ ) {
998- setWordToY ( row . words [ i ] , row . lineBottom . bbox ( ) . y - row . words [ i ] . rectSVG . height ( ) ) ;
977+ setWordToY ( row . words [ i ] , row . lineBottom . bbox ( ) . y - row . words [ i ] . aboveRect . height ( ) ) ;
999978 //updateLinksOfWord(row.words[i]);
1000979 }
1001980
@@ -1034,15 +1013,15 @@ function dragRow(x, y, row) {
10341013
10351014
10361015function setWordToY ( word , wy ) {
1037- word . rectSVG . y ( wy ) ;
1038- word . rect = word . rectSVG . bbox ( ) ;
1016+ word . aboveRect . y ( wy ) ;
1017+ word . bbox = word . aboveRect . bbox ( ) ;
10391018 word . underneathRect . y ( wy ) ;
10401019 word . leftHandle . y ( wy ) ;
10411020 word . rightHandle . y ( wy ) ;
1042- word . text . y ( word . rect . y + textpaddingY * 2 ) ;
1021+ word . text . y ( word . bbox . y + textpaddingY * 2 ) ;
10431022
10441023 if ( word . tag != null ) {
1045- word . tagtext . y ( word . rect . y + textpaddingY / 2 ) ;
1024+ word . tagtext . y ( word . bbox . y + textpaddingY / 2 ) ;
10461025 }
10471026}
10481027
0 commit comments