namibia
df0489e1eeeeab5a9bd44e1d84fce49924fe1bac
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
/* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview The "elementspath" plugin. It shows all elements in the DOM * parent tree relative to the current selection in the editing area. */ (function() { var commands = { toolbarFocus : { editorFocus : false, readOnly : 1, exec : function( editor ) { var idBase = editor._.elementsPath.idBase; var element = CKEDITOR.document.getById( idBase + '0' ); // Make the first button focus accessible for IE. (#3417) // Adobe AIR instead need while of delay. element && element.focus( CKEDITOR.env.ie || CKEDITOR.env.air ); } } }; var emptyHtml = '<span class="cke_empty"> </span>'; CKEDITOR.plugins.add( 'elementspath', { requires : [ 'selection' ], init : function( editor ) { var spaceId = 'cke_path_' + editor.name; var spaceElement; var getSpaceElement = function() { if ( !spaceElement ) spaceElement = CKEDITOR.document.getById( spaceId ); return spaceElement; }; var idBase = 'cke_elementspath_' + CKEDITOR.tools.getNextNumber() + '_'; editor._.elementsPath = { idBase : idBase, filters : [] }; editor.on( 'themeSpace', function( event ) { if ( event.data.space == 'bottom' ) { event.data.html += '<span id="' + spaceId + '_label" class="cke_voice_label">' + editor.lang.elementsPath.eleLabel + '</span>' + '<div id="' + spaceId + '" class="cke_path" role="group" aria-labelledby="' + spaceId + '_label">' + emptyHtml + '</div>'; } }); function onClick( elementIndex ) { editor.focus(); var element = editor._.elementsPath.list[ elementIndex ]; if ( element.is( 'body' ) ) { var range = new CKEDITOR.dom.range( editor.document ); range.selectNodeContents( element ); range.select(); } else editor.getSelection().selectElement( element ); } var onClickHanlder = CKEDITOR.tools.addFunction( onClick ); var onKeyDownHandler = CKEDITOR.tools.addFunction( function( elementIndex, ev ) { var idBase = editor._.elementsPath.idBase, element; ev = new CKEDITOR.dom.event( ev ); var rtl = editor.lang.dir == 'rtl'; switch ( ev.getKeystroke() ) { case rtl ? 39 : 37 : // LEFT-ARROW case 9 : // TAB element = CKEDITOR.document.getById( idBase + ( elementIndex + 1 ) ); if ( !element ) element = CKEDITOR.document.getById( idBase + '0' ); element.focus(); return false; case rtl ? 37 : 39 : // RIGHT-ARROW case CKEDITOR.SHIFT + 9 : // SHIFT + TAB element = CKEDITOR.document.getById( idBase + ( elementIndex - 1 ) ); if ( !element ) element = CKEDITOR.document.getById( idBase + ( editor._.elementsPath.list.length - 1 ) ); element.focus(); return false; case 27 : // ESC editor.focus(); return false; case 13 : // ENTER // Opera case 32 : // SPACE onClick( elementIndex ); return false; } return true; }); editor.on( 'selectionChange', function( ev ) { var env = CKEDITOR.env, selection = ev.data.selection, element = selection.getStartElement(), html = [], editor = ev.editor, elementsList = editor._.elementsPath.list = [], filters = editor._.elementsPath.filters; while ( element ) { var ignore = 0, name; if ( element.data( 'cke-display-name' ) ) name = element.data( 'cke-display-name' ); else if ( element.data( 'cke-real-element-type' ) ) name = element.data( 'cke-real-element-type' ); else name = element.getName(); for ( var i = 0; i < filters.length; i++ ) { var ret = filters[ i ]( element, name ); if ( ret === false ) { ignore = 1; break; } name = ret || name; } if ( !ignore ) { var index = elementsList.push( element ) - 1; // Use this variable to add conditional stuff to the // HTML (because we are doing it in reverse order... unshift). var extra = ''; // Some browsers don't cancel key events in the keydown but in the // keypress. // TODO: Check if really needed for Gecko+Mac. if ( env.opera || ( env.gecko && env.mac ) ) extra += ' onkeypress="return false;"'; // With Firefox, we need to force the button to redraw, otherwise it // will remain in the focus state. if ( env.gecko ) extra += ' onblur="this.style.cssText = this.style.cssText;"'; var label = editor.lang.elementsPath.eleTitle.replace( /%1/, name ); html.unshift( '<a' + ' id="', idBase, index, '"' + ' href="javascript:void(\'', name, '\')"' + ' tabindex="-1"' + ' title="', label, '"' + ( ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) ? ' onfocus="event.preventBubble();"' : '' ) + ' hidefocus="true" ' + ' onkeydown="return CKEDITOR.tools.callFunction(', onKeyDownHandler, ',', index, ', event );"' + extra , ' onclick="CKEDITOR.tools.callFunction('+ onClickHanlder, ',', index, '); return false;"', ' role="button" aria-labelledby="' + idBase + index + '_label">', name, '<span id="', idBase, index, '_label" class="cke_label">' + label + '</span>', '</a>' ); } if ( name == 'body' ) break; element = element.getParent(); } var space = getSpaceElement(); space.setHtml( html.join('') + emptyHtml ); editor.fire( 'elementsPathUpdate', { space : space } ); }); function empty() { spaceElement && spaceElement.setHtml( emptyHtml ); delete editor._.elementsPath.list; } editor.on( 'readOnly', empty ); editor.on( 'contentDomUnload', empty ); editor.addCommand( 'elementsPathFocus', commands.toolbarFocus ); } }); })(); /** * Fired when the contents of the elementsPath are changed * @name CKEDITOR.editor#elementsPathUpdate * @event * @param {Object} eventData.space The elementsPath container */ |
Commits for namibiapublic/scripts/ckeditor/_source/plugins/elementspath/plugin.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |