Changeset 835
- Timestamp:
- 09/17/07 11:46:41 (6 years ago)
- Location:
- FCKeditor/trunk
- Files:
-
- 2 edited
-
editor/_source/commandclasses/fckindentcommands.js (modified) (4 diffs)
-
fckconfig.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
FCKeditor/trunk/editor/_source/commandclasses/fckindentcommands.js
r834 r835 28 28 this.IndentCSSProperty = FCKConfig.ContentLangDirection.IEquals( 'ltr' ) ? 'marginLeft' : 'marginRight' ; 29 29 } 30 31 FCKIndentCommand._InitIndentModeParameters = function() 32 { 33 if ( FCKConfig.IndentClasses && FCKConfig.IndentClasses.length > 0 ) 34 { 35 this._UseIndentClasses = true ; 36 this._IndentClassMap = {} ; 37 for ( var i = 0 ; i < FCKConfig.IndentClasses.length ;i++ ) 38 this._IndentClassMap[FCKConfig.IndentClasses[i]] = i + 1 ; 39 this._ClassNameRegex = new RegExp( '(?:^|\\s+)(' + FCKConfig.IndentClasses.join( '|' ) + ')(?=$|\\s)' ) ; 40 } 41 else 42 this._UseIndentClasses = false ; 43 } 44 30 45 31 46 FCKIndentCommand.prototype = … … 56 71 GetState : function() 57 72 { 58 // TODO: If we're not in a list, and the starting block's indentation is zero, and the current 73 // Disabled if not WYSIWYG. 74 if ( FCK.EditMode != FCK_EDITMODE_WYSIWYG || ! FCK.EditorWindow ) 75 return FCK_TRISTATE_DISABLED ; 76 77 // Initialize parameters if not already initialzed. 78 if ( FCKIndentCommand._UseIndentClasses == undefined ) 79 FCKIndentCommand._InitIndentModeParameters() ; 80 81 // If we're not in a list, and the starting block's indentation is zero, and the current 59 82 // command is the outdent command, then we should return FCK_TRISTATE_DISABLED. 60 return FCK_TRISTATE_OFF; 83 var startContainer = FCKSelection.GetBoundaryParentElement( true ) ; 84 var endContainer = FCKSelection.GetBoundaryParentElement( false ) ; 85 var listNode = FCKDomTools.GetCommonParentNode( startContainer, endContainer, ['ul','ol'] ) ; 86 87 if ( ( ! FCKIndentCommand._UseIndentClasses && this.Name.IEquals( 'indent' ) ) || listNode ) 88 return FCK_TRISTATE_OFF; 89 90 var path = new FCKElementPath( startContainer ) ; 91 if ( FCKIndentCommand._UseIndentClasses ) 92 { 93 var indentClass = path.Block.className.match( FCKIndentCommand._ClassNameRegex ) ; 94 var indentStep = 0 ; 95 if ( indentClass != null ) 96 { 97 indentClass = indentClass[1] ; 98 indentStep = FCKIndentCommand._IndentClassMap[indentClass] ; 99 } 100 if ( ( this.Name == 'outdent' && indentStep == 0 ) || 101 ( this.Name == 'indent' && indentStep == FCKConfig.IndentClasses.length ) ) 102 return FCK_TRISTATE_DISABLED ; 103 return FCK_TRISTATE_OFF ; 104 } 105 else 106 { 107 var indent = parseInt( path.Block.style[this.IndentCSSProperty], 10 ) ; 108 if ( isNaN( indent ) ) 109 indent = 0 ; 110 if ( indent <= 0 ) 111 return FCK_TRISTATE_DISABLED ; 112 return FCK_TRISTATE_OFF ; 113 } 61 114 }, 62 115 … … 76 129 continue ; 77 130 78 // Offset distance is assumed to be in pixels for now. 79 var currentOffset = parseInt( block.style[this.IndentCSSProperty], 10 ) ; 80 if ( isNaN( currentOffset ) ) 81 currentOffset = 0 ; 82 currentOffset += this.Offset ; 83 currentOffset = Math.max( currentOffset, 0 ) ; 84 block.style[this.IndentCSSProperty] = currentOffset + 'px' ; 131 if ( FCKIndentCommand._UseIndentClasses ) 132 { 133 // Transform current class name to indent step index. 134 var indentClass = block.className.match( FCKIndentCommand._ClassNameRegex ) ; 135 var indentStep = 0 ; 136 if ( indentClass != null ) 137 { 138 indentClass = indentClass[1] ; 139 indentStep = FCKIndentCommand._IndentClassMap[indentClass] ; 140 } 141 142 // Operate on indent step index, transform indent step index back to class name. 143 if ( this.Name.IEquals( 'outdent' ) ) 144 indentStep-- ; 145 else if ( this.Name.IEquals( 'indent' ) ) 146 indentStep++ ; 147 indentStep = Math.min( indentStep, FCKConfig.IndentClasses.length ) ; 148 indentStep = Math.max( indentStep, 0 ) ; 149 var className = block.className.replace( FCKIndentCommand._ClassNameRegex, '' ) ; 150 if ( indentStep < 1 ) 151 block.className = className ; 152 else 153 block.className = ( className.length > 0 ? className + ' ' : '' ) + 154 FCKConfig.IndentClasses[indentStep - 1] ; 155 } 156 else 157 { 158 // Offset distance is assumed to be in pixels for now. 159 var currentOffset = parseInt( block.style[this.IndentCSSProperty], 10 ) ; 160 if ( isNaN( currentOffset ) ) 161 currentOffset = 0 ; 162 currentOffset += this.Offset ; 163 currentOffset = Math.max( currentOffset, 0 ) ; 164 block.style[this.IndentCSSProperty] = currentOffset + 'px' ; 165 } 85 166 } 86 167 }, … … 90 171 // Our starting and ending points of the range might be inside some blocks under a list item... 91 172 // So before playing with the iterator, we need to expand the block to include the list items. 92 // TODO 173 var startContainer = range.StartContainer ; 174 var endContainer = range.EndContainer ; 175 while ( startContainer && ! startContainer.nodeName.IEquals( ['li', 'ul', 'ol'] ) ) 176 startContainer = startContainer.parentNode ; 177 while ( endContainer && ! endContainer.nodeName.IEquals( ['li', 'ul', 'ol'] ) ) 178 endContainer = endContainer.parentNode ; 179 range.SetStart( startContainer, 1 ) ; 180 range.SetEnd( endContainer, 2 ) ; 181 182 if ( ! startContainer || ! endContainer ) 183 return ; 184 185 // Now we can iterate over the individual items. 93 186 var iterator = new FCKDomRangeIterator( range ) ; 94 187 var block ; -
FCKeditor/trunk/fckconfig.js
r834 r835 62 62 // The distance of an indentation step, in pixels. 63 63 FCKConfig.IndentLength = 40 ; 64 65 // Alternatively, FCKeditor allows the use of CSS classes for block indentation. 66 // This overrides the IndentLength setting. 67 FCKConfig.IndentClasses = [] ; 64 68 65 69 FCKConfig.ProcessHTMLEntities = true ;
Note: See TracChangeset
for help on using the changeset viewer.
