Skip to content
Permalink
Browse files

Adjustment to elementspath plugin path entries creation. Changed iter…

…ation to start from oldest parent down to node itself.
  • Loading branch information...
mlewand committed Oct 17, 2013
1 parent 213414c commit 0c426c592cecd905eeabc0cbd37115eb7fd05b1d
Showing with 25 additions and 15 deletions.
  1. +25 −15 plugins/elementspath/plugin.js
@@ -145,14 +145,25 @@
var env = CKEDITOR.env,
editable = editor.editable(),
selection = ev.data.selection,
element = selection.getStartElement(),
html = [],
elementsList = privateContext.list = [],
filters = privateContext.filters;
namesList = [],
filters = privateContext.filters,
isContentEditable = true,
name,
elementsChain = selection.getStartElement().getParents(),
chainLength = elementsChain.length;

while ( element ) {
var ignore = 0,
name;
for ( var j = 0; j < chainLength; j++ ) {
var element = elementsChain[ j ],
ignore = 0;

isContentEditable = element.hasAttribute( 'contenteditable' ) ?
element.getAttribute( 'contenteditable' ) == 'true' : isContentEditable;

// Widget wrappers are exception here and should be displayed.
if ( !isContentEditable && element.getAttribute( 'data-cke-widget-wrapper' ) != '1' )
ignore = 1;

if ( element.data( 'cke-display-name' ) )
name = element.data( 'cke-display-name' );
@@ -171,10 +182,15 @@
}

if ( !ignore ) {
var index = elementsList.push( element ) - 1,
label = editor.lang.elementspath.eleTitle.replace( /%1/, name );
elementsList.unshift( element );
namesList.unshift( name );
}
}

var item = pathItemTpl.output({
for ( var iterationLimit = elementsList.length-1, index = 0; index < iterationLimit; index++ ) {
name = namesList[ index ];
var label = editor.lang.elementspath.eleTitle.replace( /%1/, name ),
item = pathItemTpl.output( {
id: idBase + index,
label: label,
text: name,
@@ -183,14 +199,8 @@
keyDownFn: onKeyDownHandler,
clickFn: onClickHanlder
} );
html.unshift( item );

}

if ( element.equals( editable ) )
break;

element = element.getParent();
html.unshift( item );
}

var space = getSpaceElement();

0 comments on commit 0c426c5

Please sign in to comment.
You can’t perform that action at this time.