Exemplo n.º 1
0
        public void walkDomFragment(Node node, AbstractBehavior parentBehavior = null)
        {
            investigateNode(node, parentBehavior);

            //free this for GC when we are done, it has references to a lot of DOM elements
            this.extensionsToBeApplied = null;
        }
Exemplo n.º 2
0
        public void walkDomChildren(Node parentNode, AbstractBehavior parentBehavior = null)
        {
            //The fact that we have two entry point into here walkChildren and walkDomFragment continues to screw us
            walkChildren(parentNode, parentBehavior);

            //free this for GC when we are done, it has references to a lot of DOM elements
            this.extensionsToBeApplied = null;
        }
Exemplo n.º 3
0
        public void walkChildren(Node parentNode, InjectionClassBuilder classBuilder, AbstractBehavior parentBehavior = null)
        {
            var node = parentNode.firstChild;

            while (node != null) {
                investigateNode(node, classBuilder, parentBehavior);
                node = node.nextSibling;
            }
        }
Exemplo n.º 4
0
        private void investigateDomElement(HtmlElement element, AbstractBehavior parentBehavior)
        {
            var currentBehavior = parentBehavior;
            var domWalker = this;

            var id = element.getAttribute("id");

            if (id != null) {
                //we have a reference to the element now, so remove the id so we dont have to deal with conflicts and clashes
                element.removeAttribute("id");
            }

            var elementDescriptor = elementDescriptorFactory.describeElement(element, extensionsToBeApplied);

            if (elementDescriptor.context != null) {
                //change the class builder for everything under this point in the DOM
                classBuilder = domExtensionFactory.buildChildClassBuilder(classBuilder, element, elementDescriptor.context);
                //change the domWalker for everything under this point in the DOM
                domWalker = (DomWalker)classBuilder.buildClass("randori.dom.DomWalker");
            }

            if (elementDescriptor.behavior != null) {
                //build a context for this behavior IF it turns out that this particular element defines one
                currentBehavior = domExtensionFactory.buildBehavior( classBuilder, element, elementDescriptor.behavior );

                //we have a new behavior, this effectively causes us to use a new context for the nodes below it
                //Make sure we add ourselves to our parent though
                if (parentBehavior != null) {
                    parentBehavior.injectPotentialNode(id, currentBehavior);
                }

            } else {
                if (id != null && currentBehavior != null) {
                    currentBehavior.injectPotentialNode(id, jQueryContext.J(element));
                }
            }

            if (elementDescriptor.fragment != null) {
                //build a context for this behavior IF it turns out that this particular element defines one
                domExtensionFactory.buildNewContent(element, elementDescriptor.fragment);
                //change the domWalker for everything under this point in the DOM
                domWalker = (DomWalker)classBuilder.buildClass("randori.dom.DomWalker");
            }

            domWalker.walkChildren(element, currentBehavior);

            //Now that we have figured out all of the items under this dom element, setup the behavior
            if (currentBehavior != null && currentBehavior != parentBehavior) {
                currentBehavior.verifyAndRegister();
            }
        }
Exemplo n.º 5
0
 public void walkDomFragment(Node node, InjectionClassBuilder classBuilder, AbstractBehavior parentBehavior = null)
 {
     investigateNode(node, classBuilder, parentBehavior);
 }
Exemplo n.º 6
0
        private void investigateNode(Node node, InjectionClassBuilder classBuilder, AbstractBehavior parentBehavior)
        {
            if (node.nodeType == Node.ELEMENT_NODE) {

                //Just an optimization, need to create constants for all of these things
                if (node.nodeName == "SCRIPT" || node.nodeName == "META") {
                    return;
                }

                if ( node.nodeName == "LINK" ) {
                    investigateLinkElement(node.As<HtmlLinkElement>());
                } else {
                    investigateDomElement(node.As<HtmlElement>(), classBuilder, parentBehavior);
                }

            } else if (node.nodeType == Node.TEXT_NODE) {
                //This is a text node, check to see if it needs internationalization
                localizationProvider.investigateTextNode(node);
            } else {
                walkChildren(node, classBuilder, parentBehavior);
            }
        }
Exemplo n.º 7
0
        private void walkChildren(Node parentNode, AbstractBehavior parentBehavior = null)
        {
            var node = parentNode.firstChild;

            if (extensionsToBeApplied == null && (parentNode.nodeType == Node.ELEMENT_NODE)) {
                //We build our extension cache from the first element we find
                entryElement = parentNode.As<HtmlElement>();
                extensionsToBeApplied = styleExtensionManager.getExtensionsForFragment(entryElement);
            }

            while (node != null) {
                investigateNode(node, parentBehavior);
                node = node.nextSibling;
            }
        }
Exemplo n.º 8
0
        private void investigateNode(Node node, AbstractBehavior parentBehavior)
        {
            if (node.nodeType == Node.ELEMENT_NODE) {

                if (extensionsToBeApplied == null) {
                    //We build our extension cache from the first element we find
                    entryElement = node.As<HtmlElement>();
                    extensionsToBeApplied = styleExtensionManager.getExtensionsForFragment(entryElement);
                }

                //Just an optimization, need to create constants for all of these things.... removed as kendo uses script nodes for templates node.nodeName == "SCRIPT" ||
                if (node.nodeName == "META") {
                    return;
                }

                if ( node.nodeName == "LINK" ) {
                    investigateLinkElement(node.As<HtmlLinkElement>());
                } else {
                    investigateDomElement(node.As<HtmlElement>(), parentBehavior);
                }

            } else if (node.nodeType == Node.TEXT_NODE) {
                //This is a text node, check to see if it needs internationalization
                localizationProvider.investigateTextNode(node);
            } else {
                walkChildren(node, parentBehavior);
            }
        }