예제 #1
0
        public ElementDescriptor describeElement(HtmlElement element, HashMap <StyleExtensionMapEntry> possibleExtensions)
        {
            //This is purely an efficiency gain. By making a merged map for this one element, we stop everyone from cycling through
            //every class on an element to pull out their own piece of data
            var entry      = possibleExtensions.get(element);
            var descriptor = new ElementDescriptor {
                context   = element.getAttribute("data-context"),
                behavior  = element.hasAttribute("data-mediator") ? element.getAttribute("data-mediator") : element.getAttribute("data-behavior"),
                fragment  = element.getAttribute("data-fragment"),
                formatter = element.getAttribute("data-formatter"),
                validator = element.getAttribute("data-validator")
            };

            if (entry != null)
            {
                if (descriptor.context == null)
                {
                    descriptor.context = entry.getExtensionValue("context");
                }

                if (descriptor.behavior == null)
                {
                    //mediator and behavior are really the same thing and hence mutually exclusive
                    descriptor.behavior = entry.hasExtensionType("mediator")?entry.getExtensionValue("mediator"):entry.getExtensionValue("behavior");
                }

                if (descriptor.fragment == null)
                {
                    descriptor.fragment = entry.getExtensionValue("fragment");
                }

                if (descriptor.formatter == null)
                {
                    descriptor.formatter = entry.getExtensionValue("formatter");
                }

                if (descriptor.validator == null)
                {
                    descriptor.validator = entry.getExtensionValue("validator");
                }
            }

            return(descriptor);
        }
예제 #2
0
        public ElementDescriptor describeElement(HtmlElement element )
        {
            //This is purely an efficiency gain. By making a merged map for this one element, we stop everyone from cycling through
            //every class on an element to pull out their own piece of data
            var entry = styleExtensionManager.getMergedEntryForElement(element);
            var descriptor = new ElementDescriptor {
                context = element.getAttribute("data-context"),
                behavior = element.hasAttribute("data-mediator") ? element.getAttribute("data-mediator") : element.getAttribute("data-behavior"),
                fragment = element.getAttribute("data-fragment"),
                formatter = element.getAttribute( "data-formatter" ),
                validator = element.getAttribute( "data-validator" )
            };

            if ( entry != null ) {
                if (descriptor.context == null) {
                    descriptor.context = entry.getExtensionClass("module");
                }

                if (descriptor.behavior == null) {
                    //mediator and behavior are really the same thing and hence mutually exclusive
                    descriptor.behavior = entry.hasExtensionType("mediator")?entry.getExtensionClass("mediator"):entry.getExtensionClass("behavior");
                }

                if (descriptor.fragment == null) {
                    descriptor.fragment = entry.getExtensionClass("fragment");
                }

                if (descriptor.formatter == null) {
                    descriptor.formatter = entry.getExtensionClass("formatter");
                }

                if (descriptor.validator == null) {
                    descriptor.validator = entry.getExtensionClass("validator");
                }
            }

            return descriptor;
        }