Example usage for com.google.gwt.dom.client ScriptElement setLang

List of usage examples for com.google.gwt.dom.client ScriptElement setLang

Introduction

In this page you can find the example usage for com.google.gwt.dom.client ScriptElement setLang.

Prototype

@Override
    public void setLang(String lang) 

Source Link

Usage

From source file:com.github.gwtbootstrap.showcase.client.NonResShowcase.java

License:Apache License

public void onModuleLoad() {
    initWidget(uiBinder.createAndBindUi(this));
    // addSectionToContainer("Get Started", "setup", new Setup());
    // addSectionToContainer("Get Support", "support", new Support());
    addSectionToContainer("Buttons", "buttons", new Buttons());
    addSectionToContainer("Grid System", "gridSystem", new GridSystem());
    addSectionToContainer("Navigation", "navigation", new Navigation());
    addSectionToContainer("Hero Unit", "hero", new HeroUnit());
    addSectionToContainer("Forms", "forms", new Forms());
    addSectionToContainer("Page Header", "pageheader", new PageHeader());
    addSectionToContainer("Progress Bar", "progressbar", new ProgressBar());
    addSectionToContainer("Alerts", "alerts", new Alerts());
    addSectionToContainer("Pagination", "pagination", new Pagination());
    addSectionToContainer("Dropdown", "dropdown", new Dropdown());
    addSectionToContainer("Modal", "modal", new Modal());
    addSectionToContainer("Datepicker", "datepicker", new Datepicker());
    addSectionToContainer("Datetimepicker", "datetimepicker", new Datetimepicker());
    addSectionToContainer("Tooltip", "tooltip", new Tooltips());
    addSectionToContainer("Popover", "popover", new Popovers());
    addSectionToContainer("Icons", "icons", new Icons());

    RootPanel.get("content").add(this);
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("https://apis.google.com/js/plusone.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);/*from w w  w. ja v  a  2  s .c o m*/

    github_buttons.getElement().setInnerHTML(
            "<iframe src=\"http://markdotto.github.com/github-buttons/github-btn.html?user=gwtbootstrap&repo=gwt-bootstrap&type=watch&count=true\"\n"
                    + "                                allowtransparency=\"true\" frameborder=\"0\" scrolling=\"0\" width=\"110px\" height=\"20px\"></iframe>"
                    + "<br /><iframe src=\"http://markdotto.github.com/github-buttons/github-btn.html?user=gwtbootstrap&repo=gwt-bootstrap&type=fork&count=true\"\n"
                    + "  allowtransparency=\"true\" frameborder=\"0\" scrolling=\"0\" width=\"95px\" height=\"20px\"></iframe>");

    JavaScriptInjector.inject(
            "!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");");
    JavaScriptInjector.inject(
            "(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = \"//connect.facebook.net/en_US/all.js#xfbml=1\";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));");

    Scheduler.get().scheduleFinally(new ScheduledCommand() {

        @Override
        public void execute() {
            History.fireCurrentHistoryState();
        }
    });
}

From source file:com.github.gwtbootstrap.showcase.client.Showcase.java

License:Apache License

public void onModuleLoad() {

    CustomResources res = GWT.create(CustomResources.class);
    res.showcase().ensureInjected();/*w  ww  . j  av  a2  s .c o m*/
    ClientFactory factory = GWT.create(ClientFactory.class);

    subnav = factory.getSubnav();

    initWidget(uiBinder.createAndBindUi(this));

    ActivityMapper activityMapper = new AppActivityMapper(factory);

    ActivityManager activityManager = new ActivityManager(activityMapper, factory.getEventBus());

    activityManager.setDisplay(main);
    PlaceHistoryMapper mapper = factory.getPlaceHistoryMapper();
    final PlaceHistoryHandler handler = new PlaceHistoryHandler(mapper);
    handler.register(factory.getPlaceController(), factory.getEventBus(), new OverviewPlace(""));

    final Map<Menus, NavLink> map = new EnumMap<Menus, NavLink>(Menus.class);
    for (Menus menu : Menus.values()) {
        NavLink link = new NavLink(menu.getDisplay());
        link.setHref("#" + menu.getName() + ":");

        if (menu == Menus.GWT) {
            nav.add(new Divider());
        }
        nav.add(link);

        map.put(menu, link);
    }

    factory.getEventBus().addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() {

        @Override
        public void onPlaceChange(PlaceChangeEvent event) {
            Place place = event.getNewPlace();

            if (place instanceof HasMenuPlace) {
                HasMenuPlace menuPlace = (HasMenuPlace) place;

                for (Map.Entry<Menus, NavLink> entry : map.entrySet()) {
                    if (entry.getKey().equals(menuPlace.getMenu())) {
                        entry.getValue().setActive(true);
                    } else {
                        entry.getValue().setActive(false);
                    }
                }

            }
        }
    });

    // addSectionToContainer("Get Started", "setup", new Setup());
    // addSectionToContainer("Get Support", "support", new Support());
    // addSectionToContainer("Buttons", "buttons", new Buttons());
    // addSectionToContainer("Grid System", "gridSystem", new GridSystem());
    // addSectionToContainer("Navigation", "navigation", new Navigation());
    // addSectionToContainer("Hero Unit", "hero", new HeroUnit());
    // addSectionToContainer("Forms", "forms", new Forms());
    // addSectionToContainer("Page Header", "pageheader", new PageHeader());
    // addSectionToContainer("Progress Bar", "progressbar", new
    // ProgressBar());
    // addSectionToContainer("Alerts", "alerts", new Alerts());
    // addSectionToContainer("Pagination", "pagination", new Pagination());
    // addSectionToContainer("Dropdown", "dropdown", new Dropdown());
    // addSectionToContainer("Modal", "modal", new Modal());
    // addSectionToContainer("Datepicker", "datepicker", new Datepicker());
    // addSectionToContainer("Tooltip", "tooltip", new Tooltips());
    // addSectionToContainer("Popover", "popover", new Popovers());
    // addSectionToContainer("Icons", "icons", new Icons());

    RootPanel.get("content").add(this);
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("https://apis.google.com/js/plusone.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);

    //        github_buttons
    //                .getElement()
    //                .setInnerHTML(
    //                        "<iframe src=\"http://ghbtns.com/github-btn.html?user=gwtbootstrap&repo=gwt-bootstrap&type=watch&count=true\"\n"
    //                                + "                                allowtransparency=\"true\" frameborder=\"0\" scrolling=\"0\" width=\"110px\" height=\"20px\"></iframe>"
    //                                + "<br /><iframe src=\"http://ghbtns.com/github-btn.html?user=gwtbootstrap&repo=gwt-bootstrap&type=fork&count=true\"\n"
    //                                + "  allowtransparency=\"true\" frameborder=\"0\" scrolling=\"0\" width=\"95px\" height=\"20px\"></iframe>");

    JavaScriptInjector.inject(
            "!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=\"//platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");");
    JavaScriptInjector.inject(
            "(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = d.createElement(s); js.id = id;js.src = \"//connect.facebook.net/en_US/all.js#xfbml=1\";fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));");

    String token = History.getToken();
    if (!token.equals("")) {
        History.newItem("");
        History.newItem(token);
    }
}

From source file:com.google.gwt.sample.vanfood.client.TwitterPopup.java

public TwitterPopup(Vendor vendor) {

    super(true);/*from  w ww. ja  v a 2s.  c om*/
    this.setStyleName("PopupPanel");

    int left = (Window.getClientWidth()) / 3;
    int top = (Window.getClientHeight()) / 2;
    this.setPopupPosition(left, top);

    String vendorName = null;
    try {
        vendorName = vendor.getName();
    } catch (Exception e) {

    }
    if ((vendorName == null) || (vendorName.equalsIgnoreCase("Name not available")))
        vendorName = "a street vendor";
    Label desc = new Label("You've added " + vendorName + " to your favourites list." + "\n"
            + "(Click outside the box to close)");
    mainPanel.add(desc);

    String url = "<a href=\"https://twitter.com/share\" class=\"twitter-share-button\" data-text=\"I just added "
            + vendorName + " to my list of favourite street vendors\" target=\"_blank\">Tweet</a>";
    HTML html = new HTML(url);

    mainPanel.add(html);

    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("http://platform.twitter.com/widgets.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);

    this.add(mainPanel);

}

From source file:com.thinqq.qsports.client.wireframe.QSportsWireFrameImpl.java

License:Open Source License

public QSportsWireFrameImpl(ClientFactory clientFactory) {
    this.clientFactory = clientFactory;
    style.ensureInjected();/*w w  w .  j a va 2  s.c o m*/
    initWidget(binder.createAndBindUi(this));
    addHandlers();
    HTML tweetContent = new HTML(
            "<a class=\"twitter-timeline\"  href=\"https://twitter.com/CricketQSports/cricketq\"  data-widget-id=\"368013046121115648\">Tweets from @CricketQSports/cricketq</a> "
                    + "<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+\"://platform.twitter.com/widgets.js\";fjs.parentNode.insertBefore(js,fjs);}}(document,\"script\",\"twitter-wjs\");</script>");
    //addTeams();
    tweet.add(tweetContent);
    Document doc = Document.get();
    ScriptElement script = doc.createScriptElement();
    script.setSrc("http://platform.twitter.com/widgets.js");
    script.setType("text/javascript");
    script.setLang("javascript");
    doc.getBody().appendChild(script);

    // TO TEST

    SafeHtml homeImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-home.png'/>");
    SafeHtml addMatchImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-batsman.png'/>");

    SafeHtml peopleImage = SafeHtmlUtils.fromTrustedString("<img src='/images/icon-people.png'/>");
    //       MenuBar home = new MenuBar(true);
    Command homeCommand = new Command() {

        @Override
        public void execute() {
            Window.alert("fire the view request event to show the home view");

        }
    };

    Command peopleCommand = new Command() {

        @Override
        public void execute() {
            // TODO Navigate to people tab.

        }
    };
    MenuBar addMatch = new MenuBar(true);

    testMenu.addItem(homeImage, homeCommand);
    testMenu.addItem(addMatchImage, addMatch);
    testMenu.addItem(peopleImage, peopleCommand);

    SafeHtml createMatchText = SafeHtmlUtils.fromSafeConstant("New Match");
    SafeHtml createTeamText = SafeHtmlUtils.fromSafeConstant("New Team");
    createMatch = new MenuItem(createMatchText);
    createMatch = new MenuItem(createMatchText);
    createMatch.addStyleName("fancybox");
    createTeam = new MenuItem(createTeamText);
    addMatch.addItem(createMatch);
    addMatch.addItem(createTeam);

    createTeam.setCommand(new Command() {

        @Override
        public void execute() {
            Genie.getEventmanager().fireEvent(new CreateNewTeamEvent());

        }
    });

    createMatch.setCommand(new Command() {

        @Override
        public void execute() {
            Genie.getEventmanager().fireEvent(new CreateNewMatchEvent());

        }
    });
}

From source file:fr.squat51.geoportail.client.Maps.java

License:Apache License

public static void loadApi(String key, String version, Runnable onLoad) {
    ScriptElement license = Document.get().createScriptElement();
    license.setSrc("http://api.ign.fr/geoportail/api?key=" + key + "&amp;");
    license.setLang("javascript");
    license.setType("text/javascript");
    Document.get().getBody().appendChild(license);

    ScriptElement script = Document.get().createScriptElement();
    script.setSrc("http://api.ign.fr/geoportail/api/js/" + version + "/Geoportal.js");
    script.setLang("javascript");
    script.setType("text/javascript");
    Document.get().getBody().appendChild(script);

    //TODO, enforce singleton state?
    Scheduler.get().scheduleFixedDelay(Maps.newInstance().checkLoad(onLoad), 250);
}

From source file:org.cruxframework.crux.core.client.utils.ScriptTagHandler.java

License:Apache License

private static ScriptElement cloneScript(ScriptElement script) {
    Document doc = Document.get();
    ScriptElement cloneScript = doc.createScriptElement();
    cloneScript.setType("text/javascript");
    cloneScript.setLang("javascript");
    if (script.hasAttribute("src")) {
        cloneScript.setSrc(script.getSrc());
    } else {//from  w  w  w  . j  a v  a2  s  .c  om
        getScriptInjector().copyScriptContent(script, cloneScript);
    }

    return cloneScript;
}

From source file:org.spacetimeresearch.gwt.addthis.client.AddThisWidget.java

License:Apache License

/**
 * Construct a new AddThisWidget.//from   w  w w .  j  a  v a  2  s . c  o  m
 *
 * @param pubId addthis identification.
 * @param message addthis message.
 * @param popupSchedule delay time in Milliseconds to render the popup.
 */
public AddThisWidget(String pubId, String message, int popupSchedule) {
    super();
    if (pubIdLoadedScript == null) {
        pubIdLoadedScript = new HashSet<String>();
    }
    Document doc = Document.get();
    if (!pubIdLoadedScript.contains(pubId)) {
        ScriptElement script = doc.createScriptElement();
        script.setSrc("http://s7.addthis.com/js/250/addthis_widget.js#pub=" + pubId);
        script.setType("text/javascript");
        script.setLang("javascript");
        doc.getBody().appendChild(script);
        pubIdLoadedScript.add(pubId);
    }

    this.pubId = pubId;
    assert getPubId() != null : "pubID not set to a non null value!";

    if (message != null) {
        this.message = message;
    }

    setPopupSchedule(popupSchedule);
    this.anchorElement = doc.createAnchorElement();
    this.setElement(anchorElement);
}