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 | indentStep = Math.min( indentStep, editor.config.indentClasses.length ); |
| 201 | indentStep = Math.max( indentStep, 0 ); |
| 202 | var className = CKEDITOR.tools.ltrim( element.$.className.replace( this.classNameRegex, '' ) ); |
| 203 | if ( indentStep < 1 ) |
| 204 | element.$.className = className; |
| 205 | else |
| 206 | element.addClass( editor.config.indentClasses[ indentStep - 1 ] ); |
| 207 | } |
| 208 | else |
| 209 | { |
| 210 | var currentOffset = parseInt( element.getStyle( this.indentCssProperty ), 10 ); |
| 211 | if ( isNaN( currentOffset ) ) |
| 212 | currentOffset = 0; |
| 213 | currentOffset += ( this.name == 'indent' ? 1 : -1 ) * editor.config.indentOffset; |
| 214 | currentOffset = Math.max( currentOffset, 0 ); |
| 215 | currentOffset = Math.ceil( currentOffset / editor.config.indentOffset ) * editor.config.indentOffset; |
| 216 | element.setStyle( this.indentCssProperty, currentOffset ? currentOffset + editor.config.indentUnit : '' ); |
| 217 | if ( element.getAttribute( 'style' ) === '' ) |
| 218 | element.removeAttribute( 'style' ); |
| 219 | } |
| 220 | } |
276 | | if ( nearestListBlock ) |
277 | | indentList.call( this, editor, range, nearestListBlock ); |
278 | | else |
279 | | indentBlock.call( this, editor, range ); |
| 254 | var previousListItem = rangeRoot.getAscendant( 'li', true ); |
| 255 | while ( previousListItem && ( previousListItem = |
| 256 | previousListItem.getPrevious( CKEDITOR.dom.walker.whitespaces( true ) ) ) ) |
| 257 | { |
| 258 | if ( previousListItem.getName && previousListItem.getName() == 'li' ) |
| 259 | { |
| 260 | indentList.call( this, editor, range, nearestListBlock ); |
| 261 | break; |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | if( !previousListItem ) |
| 266 | { |
| 267 | // Indent the entire list if cursor is inside the first list item. (#3893) |
| 268 | if( nearestListBlock ) |
| 269 | indentElement.call( this, editor, nearestListBlock ); |
| 270 | else |
| 271 | indentBlock.call( this, editor, range ); |
| 272 | } |