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 |
/* Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { // Elements that may be considered the "Block boundary" in an element path. var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1, legend:1,caption:1 }; // Elements that may be considered the "Block limit" in an element path. var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,form:1,fieldset:1 }; // Check if an element contains any block element. var checkHasBlock = function( element ) { var childNodes = element.getChildren(); for ( var i = 0, count = childNodes.count() ; i < count ; i++ ) { var child = childNodes.getItem( i ); if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] ) return true; } return false; }; /** * @class */ CKEDITOR.dom.elementPath = function( lastNode ) { var block = null; var blockLimit = null; var elements = []; var e = lastNode; while ( e ) { if ( e.type == CKEDITOR.NODE_ELEMENT ) { if ( !this.lastElement ) this.lastElement = e; var elementName = e.getName(); if ( CKEDITOR.env.ie && e.$.scopeName != 'HTML' ) elementName = e.$.scopeName.toLowerCase() + ':' + elementName; if ( !blockLimit ) { if ( !block && pathBlockElements[ elementName ] ) block = e; if ( pathBlockLimitElements[ elementName ] ) { // DIV is considered the Block, if no block is available (#525) // and if it doesn't contain other blocks. if ( !block && elementName == 'div' && !checkHasBlock( e ) ) block = e; else blockLimit = e; } } elements.push( e ); if ( elementName == 'body' ) break; } e = e.getParent(); } this.block = block; this.blockLimit = blockLimit; this.elements = elements; }; })(); CKEDITOR.dom.elementPath.prototype = { /** * Compares this element path with another one. * @param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be * compared with this one. * @returns {Boolean} "true" if the paths are equal, containing the same * number of elements and the same elements in the same order. */ compare : function( otherPath ) { var thisElements = this.elements; var otherElements = otherPath && otherPath.elements; if ( !otherElements || thisElements.length != otherElements.length ) return false; for ( var i = 0 ; i < thisElements.length ; i++ ) { if ( !thisElements[ i ].equals( otherElements[ i ] ) ) return false; } return true; }, contains : function( tagNames ) { var elements = this.elements; for ( var i = 0 ; i < elements.length ; i++ ) { if ( elements[ i ].getName() in tagNames ) return elements[ i ]; } return null; } }; |
Commits for namibiapublic/scripts/ckeditor/_source/core/dom/elementpath.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |