30 | | var color = new $el( event.data.getTarget() ).getAttribute( 'title' ); |
31 | | $doc.getById( 'hicolor' ).setStyle( 'background-color', color ); |
32 | | $doc.getById( 'hicolortext' ).setHtml( color ); |
| 33 | if ( ! (evt instanceof CKEDITOR.dom.event ) ) |
| 34 | evt = new CKEDITOR.dom.event( evt ); |
| 35 | |
| 36 | var target = evt.getTarget(), |
| 37 | color; |
| 38 | |
| 39 | if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) ) |
| 40 | dialog.getContentElement( 'picker', 'selectedColor' ).setValue( color ); |
| 41 | } |
| 42 | |
| 43 | function updateHighlight( event ) |
| 44 | { |
| 45 | if ( ! (event instanceof CKEDITOR.dom.event ) ) |
| 46 | event = event.data; |
| 47 | |
| 48 | var target = event.getTarget(), |
| 49 | color; |
| 50 | |
| 51 | if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) ) |
| 52 | { |
| 53 | $doc.getById( 'hicolor' ).setStyle( 'background-color', color ); |
| 54 | $doc.getById( 'hicolortext' ).setHtml( color ); |
| 55 | } |
| 64 | var onMouseout = $tools.addFunction( clearHighlight ); |
| 65 | |
| 66 | var onClick = updateSelected, |
| 67 | onClickHandler = CKEDITOR.tools.addFunction( onClick ); |
| 68 | |
| 69 | var onFocus = updateHighlight, |
| 70 | onBlur = clearHighlight; |
| 71 | |
| 72 | var onKeydownHandler = CKEDITOR.tools.addFunction( function( ev ) |
| 73 | { |
| 74 | ev = new CKEDITOR.dom.event( ev ); |
| 75 | var element = ev.getTarget(); |
| 76 | var relative, nodeToMove; |
| 77 | var keystroke = ev.getKeystroke(); |
| 78 | var rtl = editor.lang.dir == 'rtl'; |
| 79 | |
| 80 | switch ( keystroke ) |
| 81 | { |
| 82 | // UP-ARROW |
| 83 | case 38 : |
| 84 | // relative is TR |
| 85 | if ( ( relative = element.getParent().getParent().getPrevious() ) ) |
| 86 | { |
| 87 | nodeToMove = relative.getChild( [element.getParent().getIndex(), 0] ); |
| 88 | nodeToMove.focus(); |
| 89 | onBlur( ev, element ); |
| 90 | onFocus( ev, nodeToMove ); |
| 91 | } |
| 92 | ev.preventDefault(); |
| 93 | break; |
| 94 | // DOWN-ARROW |
| 95 | case 40 : |
| 96 | // relative is TR |
| 97 | if ( ( relative = element.getParent().getParent().getNext() ) ) |
| 98 | { |
| 99 | nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] ); |
| 100 | if ( nodeToMove && nodeToMove.type == 1 ) |
| 101 | { |
| 102 | nodeToMove.focus(); |
| 103 | onBlur( ev, element ); |
| 104 | onFocus( ev, nodeToMove ); |
| 105 | } |
| 106 | } |
| 107 | ev.preventDefault(); |
| 108 | break; |
| 109 | // SPACE |
| 110 | // ENTER is already handled as onClick |
| 111 | case 32 : |
| 112 | onClick( ev ); |
| 113 | ev.preventDefault(); |
| 114 | break; |
| 115 | |
| 116 | // RIGHT-ARROW |
| 117 | case rtl ? 37 : 39 : |
| 118 | // relative is TD |
| 119 | if ( ( relative = element.getParent().getNext() ) ) |
| 120 | { |
| 121 | nodeToMove = relative.getChild( 0 ); |
| 122 | if ( nodeToMove.type == 1 ) |
| 123 | { |
| 124 | nodeToMove.focus(); |
| 125 | onBlur( ev, element ); |
| 126 | onFocus( ev, nodeToMove ); |
| 127 | ev.preventDefault( true ); |
| 128 | } |
| 129 | else |
| 130 | onBlur( null, element ); |
| 131 | } |
| 132 | // relative is TR |
| 133 | else if ( ( relative = element.getParent().getParent().getNext() ) ) |
| 134 | { |
| 135 | nodeToMove = relative.getChild( [ 0, 0 ] ); |
| 136 | if ( nodeToMove && nodeToMove.type == 1 ) |
| 137 | { |
| 138 | nodeToMove.focus(); |
| 139 | onBlur( ev, element ); |
| 140 | onFocus( ev, nodeToMove ); |
| 141 | ev.preventDefault( true ); |
| 142 | } |
| 143 | else |
| 144 | onBlur( null, element ); |
| 145 | } |
| 146 | break; |
| 147 | |
| 148 | // LEFT-ARROW |
| 149 | case rtl ? 39 : 37 : |
| 150 | // relative is TD |
| 151 | if ( ( relative = element.getParent().getPrevious() ) ) |
| 152 | { |
| 153 | nodeToMove = relative.getChild( 0 ); |
| 154 | nodeToMove.focus(); |
| 155 | onBlur( ev, element ); |
| 156 | onFocus( ev, nodeToMove ); |
| 157 | ev.preventDefault( true ); |
| 158 | } |
| 159 | // relative is TR |
| 160 | else if ( ( relative = element.getParent().getParent().getPrevious() ) ) |
| 161 | { |
| 162 | nodeToMove = relative.getLast().getChild( 0 ); |
| 163 | nodeToMove.focus(); |
| 164 | onBlur( ev, element ); |
| 165 | onFocus( ev, nodeToMove ); |
| 166 | ev.preventDefault( true ); |
| 167 | } |
| 168 | else |
| 169 | onBlur( null, element ); |
| 170 | break; |
| 171 | default : |
| 172 | // Do not stop not handled events. |
| 173 | return; |
| 174 | } |
| 175 | }); |
| 176 | |
73 | | // Pass unparsed color value in some markup-degradable form. |
74 | | cell.setAttribute( 'title', color ); |
| 209 | var index = cell.$.cellIndex + 1 + 18 * targetRow.rowIndex; |
| 210 | cell.append( CKEDITOR.dom.element.createFromHtml( |
| 211 | '<a href="javascript: void(0);" role="option"' + |
| 212 | ' aria-posinset="' + index + '"' + |
| 213 | ' aria-setsize="' + 13 * 18 + '"' + |
| 214 | ' style="cursor: pointer;display:block;width:100%;height:100% " title="'+ CKEDITOR.tools.htmlEncode( color )+ '"' + |
| 215 | ' onkeydown="CKEDITOR.tools.callFunction( ' + onKeydownHandler + ', event, this )"' + |
| 216 | ' onclick="CKEDITOR.tools.callFunction(' + onClickHandler + ', event, this ); return false;"' + |
| 217 | ' tabindex="-1"><span class="cke_voice_label">' + color + '</span></a>', CKEDITOR.document ) ); |