| | 1 | (function() |
| | 2 | { |
| | 3 | function getListElement( editor, listTag ) |
| | 4 | { |
| | 5 | var range; |
| | 6 | try { range = editor.getSelection().getRanges()[ 0 ]; } |
| | 7 | catch( e ) { return null; } |
| | 8 | |
| | 9 | range.shrink( CKEDITOR.SHRINK_TEXT ); |
| | 10 | return range.getCommonAncestor().getAscendant( listTag, true ); |
| | 11 | } |
| | 12 | |
| | 13 | function listStyle( editor, startupPage ) |
| | 14 | { |
| | 15 | if ( startupPage == 'bulletedListStyle' ) |
| | 16 | { |
| | 17 | return { |
| | 18 | title : editor.lang.list.bulletedTitle, |
| | 19 | minWidth : 300, |
| | 20 | minHeight : 50, |
| | 21 | contents : |
| | 22 | [ |
| | 23 | { |
| | 24 | elements : |
| | 25 | [ |
| | 26 | { |
| | 27 | type : 'select', |
| | 28 | label : editor.lang.list.type, |
| | 29 | id: 'type', |
| | 30 | style: 'width: 150px; margin: auto', |
| | 31 | items : |
| | 32 | [ |
| | 33 | [ editor.lang.list.circle, 'circle' ], |
| | 34 | [ editor.lang.list.disc, 'disc' ], |
| | 35 | [ editor.lang.list.square, 'square' ] |
| | 36 | ], |
| | 37 | setup : function( element ) |
| | 38 | { |
| | 39 | var value = element.getStyle( 'list-style-type' ) || 'disc'; |
| | 40 | this.setValue( value ); |
| | 41 | }, |
| | 42 | commit : function( element ) |
| | 43 | { |
| | 44 | element.setStyle( 'list-style-type', this.getValue() ); |
| | 45 | } |
| | 46 | } |
| | 47 | ] |
| | 48 | } |
| | 49 | ], |
| | 50 | onShow: function() |
| | 51 | { |
| | 52 | var editor = this.getParentEditor(), |
| | 53 | element = getListElement( editor, 'ul' ); |
| | 54 | |
| | 55 | element && this.setupContent( element ); |
| | 56 | }, |
| | 57 | onOk: function() |
| | 58 | { |
| | 59 | var editor = this.getParentEditor(), |
| | 60 | element = getListElement( editor, 'ul' ); |
| | 61 | |
| | 62 | element && this.commitContent( element ); |
| | 63 | } |
| | 64 | } |
| | 65 | } |
| | 66 | else if ( startupPage == 'numberedListStyle' ) |
| | 67 | { |
| | 68 | return { |
| | 69 | title : editor.lang.list.numberedTitle, |
| | 70 | minWidth : 300, |
| | 71 | minHeight : 50, |
| | 72 | contents : |
| | 73 | [ |
| | 74 | { |
| | 75 | elements : |
| | 76 | [ |
| | 77 | { |
| | 78 | type : 'hbox', |
| | 79 | widths : [ '25%', '75%' ], |
| | 80 | children : |
| | 81 | [ |
| | 82 | { |
| | 83 | label: editor.lang.list.start, |
| | 84 | id: 'start', |
| | 85 | type: 'text', |
| | 86 | setup : function( element ) |
| | 87 | { |
| | 88 | var value = element.getAttribute( 'start' ) || 1; |
| | 89 | value && this.setValue( value ); |
| | 90 | }, |
| | 91 | commit : function( element ) |
| | 92 | { |
| | 93 | element.setAttribute( 'start', this.getValue() ); |
| | 94 | } |
| | 95 | }, |
| | 96 | { |
| | 97 | type : 'select', |
| | 98 | label : editor.lang.list.type, |
| | 99 | style: 'width: 100%', |
| | 100 | items : |
| | 101 | [ |
| | 102 | [ editor.lang.list.inherit, 'inherit' ], |
| | 103 | [ editor.lang.list.armenian, 'armenian' ], |
| | 104 | [ editor.lang.list.georgian, 'georgian' ], |
| | 105 | [ editor.lang.list.lowerRoman, 'lower-roman' ], |
| | 106 | [ editor.lang.list.upperRoman, 'upper-roman' ], |
| | 107 | [ editor.lang.list.lowerAlpha, 'lower-alpha' ], |
| | 108 | [ editor.lang.list.upperAlpha, 'upper-alpha' ], |
| | 109 | [ editor.lang.list.lowerLatin, 'lower-latin' ], |
| | 110 | [ editor.lang.list.upperLatin, 'upper-latin' ], |
| | 111 | [ editor.lang.list.lowerGreek, 'lower-greek' ], |
| | 112 | [ editor.lang.list.decimal, 'decimal' ], |
| | 113 | [ editor.lang.list.decimalLeadingZero, 'decimal-leading-zero' ] |
| | 114 | ], |
| | 115 | setup : function( element ) |
| | 116 | { |
| | 117 | var value = element.getStyle( 'list-style-type' ) || 'inherit'; |
| | 118 | this.setValue( value ); |
| | 119 | }, |
| | 120 | commit : function( element ) |
| | 121 | { |
| | 122 | element.setStyle( 'list-style-type', this.getValue() ); |
| | 123 | } |
| | 124 | } |
| | 125 | ] |
| | 126 | } |
| | 127 | ] |
| | 128 | } |
| | 129 | ], |
| | 130 | onShow: function() |
| | 131 | { |
| | 132 | var editor = this.getParentEditor(), |
| | 133 | element = getListElement( editor, 'ol' ); |
| | 134 | |
| | 135 | element && this.setupContent( element ); |
| | 136 | }, |
| | 137 | onOk: function() |
| | 138 | { |
| | 139 | var editor = this.getParentEditor(), |
| | 140 | element = getListElement( editor, 'ol' ); |
| | 141 | |
| | 142 | element && this.commitContent( element ); |
| | 143 | } |
| | 144 | } |
| | 145 | } |
| | 146 | }; |
| | 147 | |
| | 148 | CKEDITOR.dialog.add( 'numberedListStyle', function( editor ) |
| | 149 | { |
| | 150 | return listStyle( editor, 'numberedListStyle' ); |
| | 151 | }); |
| | 152 | |
| | 153 | CKEDITOR.dialog.add( 'bulletedListStyle', function( editor ) |
| | 154 | { |
| | 155 | return listStyle( editor, 'bulletedListStyle' ); |
| | 156 | }); |
| | 157 | })(); |
| | 158 | No newline at end of file |