Song.Site/Templates/Mobi/Default2019/APICloud/common.js

(开头部分) 2KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

! function () {
    /* 使 apiready 更优雅. */
    window.apiready = function(){
        var evt = document.createEvent("HTMLEvents");
        evt.initEvent("apiready", false, false);

        document.dispatchEvent(evt);
        window.dispatchEvent(evt);
    }

    /* 使事件机制更加优雅. */
    window.addEventListener("apiready", function(){
        var apicloudEvents = ["pause", "resume", "online", "offline", "batterylow", "batterystatus", "scrolltobottom",
            "viewappear", "viewdisappear", "keyback", "keymenu", "tap", "swipeleft", "swiperight", "swipeup",
            "swipedown", "shake"];

        for(var idx in apicloudEvents){
            var apicloudEventName = apicloudEvents[idx];

            ! function(eventName){
                api.addEventListener({
                    name: eventName
                }, function(ret, err){
                    var evt = document.createEvent("HTMLEvents");
                    evt.initEvent(eventName, false, false);

                    for(var prop in ret){
                        evt[prop] = ret[prop];
                    }

                    document.dispatchEvent(evt);
                    window.dispatchEvent(evt);
                });
            }(apicloudEventName);
        }
    });


    window.addEventListener("apiready", function(){
        /* 重写 alert 方法. */
        window.alert = function(msg){
            api.alert({
                title: "提示",
                msg: msg,
                buttons: ["确定"]
            });
        }

        /* 一个获取导航栏高度的方法. */
        window.getNavHeight = function () {
            var h = 44;

            if("ios" == api.systemType && parseInt(api.systemVersion) >= 7){
                h = 64;
            }

            return h;
        }

        /* 一个关闭窗口,返回上一级页面的优雅实现. */
后面还有 25 行代码,解锁后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。