next.celebs.DemoUtils.java Source code

Java tutorial

Introduction

Here is the source code for next.celebs.DemoUtils.java

Source

/*
 * Copyright 2011 Vancouver Ywebb Consulting Ltd
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package next.celebs;

import next.i.view.XDragScrollView;
import next.i.view.widgets.XPopup;

import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Frame;

public class DemoUtils {

    public static native void openURL(String url)/*-{
                                                 $wnd.open(url, 'target=_blank');
                                                 }-*/;

    public static void openWiki(final String url) {
        openWiki(null, url);
    }

    public static void openWiki(String source, final String url) {

        int h = Window.getClientHeight();
        int w = Window.getClientWidth();

        // mobile phone
        if (h + w < 1000) {
            openURL(url);

        } else {
            final Frame frame = new Frame(url);
            Style s = frame.getElement().getStyle();
            s.setProperty("width", "100%");
            s.setProperty("height", "100%");

            final XPopup popup = new XPopup();
            final XDragScrollView view = new XDragScrollView();
            view.add(frame);
            popup.setWidget(view);
            popup.setTop("35px");
            popup.setRight("5%");
            popup.setLeft("10%");
            popup.setBottom("10%");
            popup.show();
        }

    }

}