當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.getGlobal方法代碼示例

本文整理匯總了TypeScript中perfmjs/utils.utils.getGlobal方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript utils.getGlobal方法的具體用法?TypeScript utils.getGlobal怎麽用?TypeScript utils.getGlobal使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在perfmjs/utils.utils的用法示例。


在下文中一共展示了utils.getGlobal方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function


//.........這裏部分代碼省略.........
            });
        }
    }

    function domContentLoaded() {
        // W3C
        if (doc.addEventListener) {
            doc.removeEventListener("DOMContentLoaded", domContentLoaded, false);
            domReady();
        }

        // IE
        else if (doc.readyState === "complete") {
            // we're here because readyState === "complete" in oldIE
            // which is good enough for us to call the dom ready!
            doc.detachEvent("onreadystatechange", domContentLoaded);
            domReady();
        }
    }

    // Catch cases where ready() is called after the browser event has already occurred.
    // we once tried to use readyState "interactive" here, but it caused issues like the one
    // discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
    if (doc.readyState === "complete") {
        domReady();
    }

    // W3C
    else if (doc.addEventListener) {
        doc.addEventListener("DOMContentLoaded", domContentLoaded, false);

        // A fallback to window.onload, that will always work
        win.addEventListener("load", domReady, false);
    }

    // IE
    else {
        // Ensure firing before onload, maybe late but safe also for iframes
        doc.attachEvent("onreadystatechange", domContentLoaded);

        // A fallback to window.onload, that will always work
        win.attachEvent("onload", domReady);

        // If IE and not a frame
        // continually check to see if the document is ready
        var top = false;

        try {
            top = !win.frameElement && doc.documentElement;
        } catch (e) { }

        if (top && top.doScroll) {
            (function doScrollCheck() {
                if (!isDomReady) {
                    try {
                        // Use the trick by Diego Perini
                        // http://javascript.nwbox.com/IEContentLoaded/
                        top.doScroll("left");
                    } catch (error) {
                        // let's not get nasty by setting a timeout too small.. (loop mania guaranteed if assets are queued)
                        win.clearTimeout(api.readyTimeout);
                        api.readyTimeout = win.setTimeout(doScrollCheck, 50);
                        return;
                    }

                    // and execute any waiting functions
                    domReady();
                }
            }());
        }
    }
    //#endregion

    //#region Public Exports
    // INFO: determine which method to use for loading
    api.load  = api.js = isAsync ? apiLoadAsync : apiLoadHack;
    api.test  = conditional;
    api.ready = ready;
    //#endregion

    //#region INIT
    // perform this when DOM is ready
    api.ready(doc, function () {
        if (allLoaded()) {
            each(handlers.ALL, function (callback) {
                one(callback);
            });
        }

        if (api.feature) {
            api.feature("domloaded", true);
        }
    });
    //#endregion

    /*for perfmjs begin*/
    utils.getGlobal('headLoad');
    utils.root.headLoad = api;
    /*for perfmjs end*/
}(window);
開發者ID:perfmjs,項目名稱:perfmjs,代碼行數:101,代碼來源:head.load.ts

示例2: function

 * 如:
 <script type="text/javascript" src="/perfmjs/js/core2/onlyforload.js?v=2012120303^{n:'css-comm',f:'',t:'css',m:'fb;jq',d:'http://s.no100.com'}"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/onlyforload.js?v=2012120301^{n:'widget-comm',f:'http://s.no100.com/perfmjs/js/core2/include-comm.js',t:'js',m:'ssq',d:'http://s.no100.com'}"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/onlyforload.js?v=2012120302^{n:'js-comm',f:'http://s.no100.com/perfmjs/js/core2/include-comm.js',t:'js',m:'jq;dlt',d:'http://s.no100.com'}"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/jquery-1.8.3.js"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/_utils.js"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/base.js"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/json.js"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/joquery.js"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/head.load.js"></script>
 或者使用以下壓縮地址
 <script type="text/javascript" src="/perfmjs/js/core2/onlyforload.js?v=2012120303^{n:'css-comm',f:'',t:'css',m:'jq;fb',d:'http://s.no100.com'}"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/onlyforload.js?v=2012120302^{n:'js-comm',f:'http://s.no100.com/perfmjs/js/core2/include-comm.js',t:'js',m:'jq;dlt',d:'http://s.no100.com'}"></script>
 <script type="text/javascript" src="/perfmjs/js/core2/core.min.js?v=2012120301^{n:'widget-comm',f:'http://s.no100.com/perfmjs/js/core2/include-comm.js',t:'js',m:'ssq',d:'http://s.no100.com'}"></script>
 */
_utils.getGlobal('loader');
var $$ = _utils.root;
$$.loader = {
    writejs: function(src, encode) {
        document.write('<script type="text/javascript" src='+src+' charset="'+(encode||"UTF-8")+'"></script>');
    },
    writecss: function(link, asyncCss) {
        asyncCss = asyncCss || true;
        if (asyncCss) {
            var cssNode = document.createElement('link');
            cssNode.type = 'text/css'; cssNode.rel = 'stylesheet'; cssNode.href = link;
            document.getElementsByTagName("head")[0].appendChild(cssNode);
        } else {
            //放在頭部的css最好要同步下載且放在head元素中
            document.write('<link type="text/css" rel="stylesheet" href="' + link + '" />');
        }
開發者ID:perfmjs,項目名稱:perfmjs,代碼行數:31,代碼來源:loader.ts


注:本文中的perfmjs/utils.utils.getGlobal方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。