39 | | if ( listNode ) |
40 | | { |
41 | | if ( this.name == 'outdent' ) |
42 | | return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); |
43 | | else |
44 | | { |
45 | | while ( listItem && ( listItem = listItem.getPrevious( CKEDITOR.dom.walker.whitespaces( true ) ) ) ) |
46 | | { |
47 | | if ( listItem.getName && listItem.getName() == 'li' ) |
48 | | return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); |
49 | | } |
50 | | return setState.call( this, editor, CKEDITOR.TRISTATE_DISABLED ); |
51 | | } |
52 | | } |
| 26 | if ( list ) |
| 27 | return setState.call( this, editor, CKEDITOR.TRISTATE_OFF ); |
205 | | if ( this.useIndentClasses ) |
206 | | { |
207 | | // Transform current class name to indent step index. |
208 | | var indentClass = block.$.className.match( this.classNameRegex ), |
209 | | indentStep = 0; |
210 | | if ( indentClass ) |
211 | | { |
212 | | indentClass = indentClass[1]; |
213 | | indentStep = this.indentClassMap[ indentClass ]; |
214 | | } |
| 181 | function indentElement( editor, element ) |
| 182 | { |
| 183 | if ( this.useIndentClasses ) |
| 184 | { |
| 185 | // Transform current class name to indent step index. |
| 186 | var indentClass = element.$.className.match( this.classNameRegex ), |
| 187 | indentStep = 0; |
| 188 | if ( indentClass ) |
| 189 | { |
| 190 | indentClass = indentClass[1]; |
| 191 | indentStep = this.indentClassMap[ indentClass ]; |
| 192 | } |
216 | | // Operate on indent step index, transform indent step index back to class |
217 | | // name. |
218 | | if ( this.name == 'outdent' ) |
219 | | indentStep--; |
220 | | else |
221 | | indentStep++; |
222 | | indentStep = Math.min( indentStep, editor.config.indentClasses.length ); |
223 | | indentStep = Math.max( indentStep, 0 ); |
224 | | var className = CKEDITOR.tools.ltrim( block.$.className.replace( this.classNameRegex, '' ) ); |
225 | | if ( indentStep < 1 ) |
226 | | block.$.className = className; |
227 | | else |
228 | | block.$.className = CKEDITOR.tools.ltrim( className + ' ' + editor.config.indentClasses[ indentStep - 1 ] ); |
229 | | } |
230 | | else |
231 | | { |
232 | | var currentOffset = parseInt( block.getStyle( this.indentCssProperty ), 10 ); |
233 | | if ( isNaN( currentOffset ) ) |
234 | | currentOffset = 0; |
235 | | currentOffset += ( this.name == 'indent' ? 1 : -1 ) * editor.config.indentOffset; |
236 | | currentOffset = Math.max( currentOffset, 0 ); |
237 | | currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; |
238 | | block.setStyle( this.indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' ); |
239 | | if ( block.getAttribute( 'style' ) === '' ) |
240 | | block.removeAttribute( 'style' ); |
241 | | } |
242 | | } |
243 | | } |
| 194 | // Operate on indent step index, transform indent step index back to class |
| 195 | // name. |
| 196 | if ( this.name == 'outdent' ) |
| 197 | indentStep--; |
| 198 | else |
| 199 | indentStep++; |
| 200 | |
| 201 | if ( indentStep < 0 ) |
| 202 | return false; |
| 203 | |
| 204 | indentStep = Math.min( indentStep, editor.config.indentClasses.length ); |
| 205 | indentStep = Math.max( indentStep, 0 ); |
| 206 | var className = CKEDITOR.tools.ltrim( element.$.className.replace( this.classNameRegex, '' ) ); |
| 207 | if ( indentStep < 1 ) |
| 208 | element.$.className = className; |
| 209 | else |
| 210 | element.addClass( editor.config.indentClasses[ indentStep - 1 ] ); |
| 211 | } |
| 212 | else |
| 213 | { |
| 214 | var currentOffset = parseInt( element.getStyle( this.indentCssProperty ), 10 ); |
| 215 | if ( isNaN( currentOffset ) ) |
| 216 | currentOffset = 0; |
| 217 | currentOffset += ( this.name == 'indent' ? 1 : -1 ) * editor.config.indentOffset; |
| 218 | |
| 219 | if ( currentOffset < 0 ) |
| 220 | return false; |
| 221 | |
| 222 | currentOffset = Math.max( currentOffset, 0 ); |
| 223 | currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; |
| 224 | element.setStyle( this.indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' ); |
| 225 | if ( element.getAttribute( 'style' ) === '' ) |
| 226 | element.removeAttribute( 'style' ); |
| 227 | } |
| 228 | |
| 229 | return true; |
| 230 | } |
277 | | if ( nearestListBlock ) |
278 | | indentList.call( this, editor, range, nearestListBlock ); |
279 | | else |
280 | | indentBlock.call( this, editor, range ); |
| 266 | if ( nearestListBlock ) |
| 267 | { |
| 268 | var firstItem = nearestListBlock.getFirst( function ( node ) { return node.type == CKEDITOR.NODE_ELEMENT && node.is( 'li' ) } ), |
| 269 | indentWholeList = firstItem.equals( rangeRoot ) || firstItem.contains( rangeRoot ); |
| 270 | |
| 271 | // Indent the entire list if cursor is inside the first list item. (#3893) |
| 272 | if ( !( indentWholeList && indentElement.call( this, editor, nearestListBlock ) ) ) |
| 273 | indentList.call( this, editor, range, nearestListBlock ); |
| 274 | } |
| 275 | else |
| 276 | indentBlock.call( this, editor, range ); |