Changeset 5601
- Timestamp:
- 06/11/10 19:33:39 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
CKEditor/branches/features/contenteditable/_source/plugins/list/plugin.js
r5600 r5601 433 433 // Group the blocks up because there are many cases where multiple lists have to be created, 434 434 // or multiple lists have to be cancelled. 435 var database = {}, 435 var listGroups = [], 436 database = {}, 436 437 rangeIterator = ranges.createIterator(), 437 438 index = 0; … … 439 440 while ( ( range = rangeIterator.getNextRange() ) && ++index ) 440 441 { 441 var listGroups = [];442 442 var boundaryNodes = range.getBoundaryNodes(), 443 443 startNode = boundaryNodes.startNode, … … 506 506 } 507 507 } 508 509 // Now we have two kinds of list groups, groups rooted at a list, and groups rooted at a block limit element. 510 // We either have to build lists or remove lists, for removing a list does not makes sense when we are looking 511 // at the group that's not rooted at lists. So we have three cases to handle. 512 var listsCreated = []; 513 while ( listGroups.length > 0 ) 514 { 515 groupObj = listGroups.shift(); 516 if ( this.state == CKEDITOR.TRISTATE_OFF ) 517 { 518 if ( listNodeNames[ groupObj.root.getName() ] ) 519 changeListType.call( this, editor, groupObj, database, listsCreated ); 520 else 521 createList.call( this, editor, groupObj, listsCreated ); 522 } 523 else if ( this.state == CKEDITOR.TRISTATE_ON && listNodeNames[ groupObj.root.getName() ] ) 524 removeList.call( this, editor, groupObj, database ); 525 } 526 527 // For all new lists created, merge adjacent, same type lists. 528 for ( i = 0 ; i < listsCreated.length ; i++ ) 529 { 530 listNode = listsCreated[i]; 531 var mergeSibling, listCommand = this; 532 ( mergeSibling = function( rtl ){ 533 534 var sibling = listNode[ rtl ? 535 'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) ); 536 if ( sibling && sibling.getName && 537 sibling.getName() == listCommand.type ) 538 { 539 sibling.remove(); 540 // Move children order by merge direction.(#3820) 541 sibling.moveChildren( listNode, rtl ? true : false ); 542 } 543 } )(); 544 mergeSibling( true ); 545 } 546 508 } 509 510 // Now we have two kinds of list groups, groups rooted at a list, and groups rooted at a block limit element. 511 // We either have to build lists or remove lists, for removing a list does not makes sense when we are looking 512 // at the group that's not rooted at lists. So we have three cases to handle. 513 var listsCreated = []; 514 while ( listGroups.length > 0 ) 515 { 516 groupObj = listGroups.shift(); 517 if ( this.state == CKEDITOR.TRISTATE_OFF ) 518 { 519 if ( listNodeNames[ groupObj.root.getName() ] ) 520 changeListType.call( this, editor, groupObj, database, listsCreated ); 521 else 522 createList.call( this, editor, groupObj, listsCreated ); 523 } 524 else if ( this.state == CKEDITOR.TRISTATE_ON && listNodeNames[ groupObj.root.getName() ] ) 525 removeList.call( this, editor, groupObj, database ); 526 } 527 528 // For all new lists created, merge adjacent, same type lists. 529 for ( i = 0 ; i < listsCreated.length ; i++ ) 530 { 531 listNode = listsCreated[i]; 532 var mergeSibling, listCommand = this; 533 ( mergeSibling = function( rtl ){ 534 535 var sibling = listNode[ rtl ? 536 'getPrevious' : 'getNext' ]( CKEDITOR.dom.walker.whitespaces( true ) ); 537 if ( sibling && sibling.getName && 538 sibling.getName() == listCommand.type ) 539 { 540 sibling.remove(); 541 // Move children order by merge direction.(#3820) 542 sibling.moveChildren( listNode, rtl ? true : false ); 543 } 544 } )(); 545 mergeSibling( true ); 547 546 } 548 547
Note: See TracChangeset
for help on using the changeset viewer.
