Example usage for com.google.gwt.query.client GQuery html

List of usage examples for com.google.gwt.query.client GQuery html

Introduction

In this page you can find the example usage for com.google.gwt.query.client GQuery html.

Prototype

public String html() 

Source Link

Document

Get the innerHTML of the first matched element.

Usage

From source file:org.lirazs.gbackbone.client.core.view.TemplateFactory.java

License:Apache License

public static Template template(final GQuery selector) {
    return new TemplateImpl(selector.html());
}

From source file:org.lirazs.gbackbone.client.core.view.TemplateFactory.java

License:Apache License

public static Template template(final GQuery selector, Map<String, String> settings) {
    return new TemplateImpl(selector.html(), new Options(settings));
}

From source file:org.lirazs.gbackbone.client.core.view.TemplateFactory.java

License:Apache License

public static Template template(final GQuery selector, Options settings) {
    return new TemplateImpl(selector.html(), settings);
}

From source file:org.lirazs.gbackbone.client.core.view.View.java

License:Apache License

private void bindAnnotatedTemplate() {
    try {/* www.j  a v  a 2s. co m*/
        ClassType classType = TypeOracle.Instance.getClassType(getClass());
        ViewTemplate annotation = classType.getAnnotation(ViewTemplate.class);

        if (annotation != null && classType.isClass() != null) {
            String templateValue = annotation.value();
            String templateFilePath = annotation.filePath();
            String templateSelector = annotation.selector();
            final boolean autoRender = annotation.autoRender();
            final boolean callRenderWhenComplete = annotation.callRenderWhenComplete();

            if (templateValue != null && !templateValue.isEmpty()) { // rendering the template value as is
                template = TemplateFactory.template(templateValue);
                if (autoRender) {
                    Options attributes = getTemplateAttributes();
                    get$El().html(template.apply(attributes));
                }
                if (callRenderWhenComplete) {
                    render();
                }

            } else if (templateSelector != null && !templateSelector.isEmpty()) { // rendering the template value as is
                GQuery scriptElement = GQuery.$(templateSelector);
                template = TemplateFactory.template(scriptElement.html());
                if (autoRender) {
                    Options attributes = getTemplateAttributes();
                    get$El().html(template.apply(attributes));
                }
                if (callRenderWhenComplete) {
                    render();
                }

            } else if (templateFilePath != null && !templateFilePath.isEmpty()) { // rendering the template async
                trigger("template:load");

                Promise promise = TemplateFactory.loadTemplate(templateFilePath);
                promise.progress(new Function() {
                    @Override
                    public void f() {
                        int progress = getArgument(0);
                        trigger("template:progress", progress);
                    }
                });
                promise.done(new Function() {
                    @Override
                    public void f() {
                        template = getArgument(0);
                        if (autoRender) {
                            Options attrs = getTemplateAttributes();
                            get$El().html(template.apply(attrs));
                        }
                        trigger("template:complete");

                        if (callRenderWhenComplete) {
                            render();
                        }
                    }
                });
            }
        }
    } catch (MethodInvokeException e) {
        e.printStackTrace();
    } catch (ReflectionRequiredException e) {
        // do nothing... a reflection operation was operated on an inner class
    }
}