codecamp

Blend UI 页面控制 API

Control

removeSplashScreen ( )

去除启动屏幕(仅Native App可用)
Blend.ui.removeSplashScreen();


实例

document.addEventListener("blendready",function(){
    Blend.ui.removeSplashScreen();
});


exitApp ( )

退出应用(仅Native App可用)
Blend.ui.exitApp();


实例

document.addEventListener("blendready",function(){
    //监听系统消息,弹出退出确认框
    Blend.ui.on("backPressedBeforeExit",function(e){
    //Android系统按下返回键的消息为backPressedBeforeExit
        if(window.confirm("确定要退出吗?")){
             Blend.ui.exitApp();
        }
    });
});


layerStopRefresh ( [layerId] ) : String

停止下拉刷新,需要配置页面刷新相关参数并注册"layerPullDown"下拉事件响应。
Blend.ui.layerStopRefresh([layerId]);
参数类型说明是否必须
layerIdString停止对应id的layer下拉刷新功能,默认停止当前页面下拉刷新功能。

返回 * layerId : String 停止刷新操作的id 实例

document.addEventListener("blendready", function() {
    Blend.ui.layerInit("0", function(dom) {
        var contentLayer = new Blend.ui.Layer({
            "id": "contentLayerId",
            "url": "content.html",
            "active": true,
            "pullToRefresh":true,
            "pullText":"下拉可以刷新⊙0⊙",
            "loadingText":"更新中,请等待...",
            "releaseText":"释放更新⊙0⊙"
        });

        Blend.ui.on("layerPullDown",function(event){
            //模拟一次http请求操作
            setTimeout(function(){
                $("#content", dom).prepend("刷新操作");
                //到了5秒后将会停止页面下拉刷新状态
                Blend.ui.layerStopRefresh("contentLayerId");
            },5000);
        });
    });
});


layerBack ( [layerId] )

退出当前layer,显示layerId对应的页面
Blend.ui.layerBack([layerId])
参数类型说明是否必须
layerIdString退出当前页面后要显示的页面id

实例

//script脚本部分代码
     var layer = new Blend.ui.Layer({
        "url":"content.html",
        "id":"contentLayer",
        "active":true
     });
     Blend.ui.layerBack();


layerStopLoading ([layerId])

消除页面的loading样式

Blend.ui.layerStopLoading([layerId])
参数类型说明是否必须
layerIdString消除id为layerId的页面loading样式,默认消除当前页面loading样式。


返回

  • layerId : String 消除页面的loading样式的id


实例

document.addEventListener("blendready", function() {
    Blend.ui.layerInit("0", function(dom) {
        //点击按钮切换页面
        $('#button', dom).click(function(e) {
            Blend.ui.fire("createContentLayer", "0");
        });

        var contentLayer;
        Blend.ui.on("createContentLayer", function(event) {
            if (contentLayer) {
                contentLayer.in();
            } else {
                contentLayer = new Blend.ui.Layer({
                    "id": "contentLayerId",
                    "url": "content.html",
                    "active": true,
                    "autoStopLoading":false,
                    "maxLoadingTime":1000,
                    "loadingIcon":"base64图片字符串,不包含头"
                });
            }
        });
    });
});
Blend UI 自定义事件 API
Blend UI Layer API文档
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }