domReady source code, domready源码
domready源码,domready实现代码,js实现domready的源代码。
jquery的domready源码,require.js的domready源代码
.
[domReady sourceCode]
https://raw.githubusercontent.com/requirejs/domReady/latest/domReady.js
/**
* @license RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
* Available via the MIT or new BSD license.
* see: http://github.com/requirejs/domReady for details
*/
/*jslint */
/*global require: false, define: false, requirejs: false,
window: false, clearInterval: false, document: false,
self: false, setInterval: false */ define(function () {
'use strict'; var isTop, testDiv, scrollIntervalId,
isBrowser = typeof window !== "undefined" && window.document,
isPageLoaded = !isBrowser,
doc = isBrowser ? document : null,
readyCalls = []; function runCallbacks(callbacks) {
var i;
for (i = ; i < callbacks.length; i += ) {
callbacks[i](doc);
}
} function callReady() {
var callbacks = readyCalls; if (isPageLoaded) {
//Call the DOM ready callbacks
if (callbacks.length) {
readyCalls = [];
runCallbacks(callbacks);
}
}
} /**
* Sets the page as loaded.
*/
function pageLoaded() {
if (!isPageLoaded) {
isPageLoaded = true;
if (scrollIntervalId) {
clearInterval(scrollIntervalId);
} callReady();
}
} if (isBrowser) {
if (document.addEventListener) {
//Standards. Hooray! Assumption here that if standards based,
//it knows about DOMContentLoaded.
document.addEventListener("DOMContentLoaded", pageLoaded, false);
window.addEventListener("load", pageLoaded, false);
} else if (window.attachEvent) {
window.attachEvent("onload", pageLoaded); testDiv = document.createElement('div');
try {
isTop = window.frameElement === null;
} catch (e) {} //DOMContentLoaded approximation that uses a doScroll, as found by
//Diego Perini: http://javascript.nwbox.com/IEContentLoaded/,
//but modified by other contributors, including jdalton
if (testDiv.doScroll && isTop && window.external) {
scrollIntervalId = setInterval(function () {
try {
testDiv.doScroll();
pageLoaded();
} catch (e) {}
}, );
}
} //Check if document already complete, and if so, just trigger page load
//listeners. Latest webkit browsers also use "interactive", and
//will fire the onDOMContentLoaded before "interactive" but not after
//entering "interactive" or "complete". More details:
//http://dev.w3.org/html5/spec/the-end.html#the-end
//http://stackoverflow.com/questions/3665561/document-readystate-of-interactive-vs-ondomcontentloaded
//Hmm, this is more complicated on further use, see "firing too early"
//bug: https://github.com/requirejs/domReady/issues/1
//so removing the || document.readyState === "interactive" test.
//There is still a window.onload binding that should get fired if
//DOMContentLoaded is missed.
if (document.readyState === "complete") {
pageLoaded();
}
} /** START OF PUBLIC API **/ /**
* Registers a callback for DOM ready. If DOM is already ready, the
* callback is called immediately.
* @param {Function} callback
*/
function domReady(callback) {
if (isPageLoaded) {
callback(doc);
} else {
readyCalls.push(callback);
}
return domReady;
} domReady.version = '2.0.1'; /**
* Loader Plugin API method
*/
domReady.load = function (name, req, onLoad, config) {
if (config.isBuild) {
onLoad(null);
} else {
domReady(onLoad);
}
}; /** END OF PUBLIC API **/ return domReady;
});
.
domReady source code, domready源码的更多相关文章
- <Flume><Source Code><Flume源码阅读笔记>
Overview source采集的日志首先会传入ChannelProcessor, 在其内首先会通过Interceptors进行过滤加工,然后通过ChannelSelector选择channel. ...
- 编译Code::Blocks源码 with MinGW on Win
Build Code::Blocks源码 ---By 狂徒归来 CodeBlocks是一款非常优秀的IDE !可惜的是没有64位的版本,而且本来是轻量级别的IDE就应该够轻,能够像记事本工具一样,迅速 ...
- google code 上源码的下载方法
SVN全称是Subversion,是Apache的一个子项目 ,具体能够到SVN中文站(http://www.subversion.org.cn/)去了解下.Google Code是Google的一个 ...
- DirectShow中写push模式的source filter流程 + 源码(内附具体凝视)
尽管网上已有非常多关于DirectShow写source filter的资料.只是非常多刚開始学的朋友总说讲的不是非常清楚(可能当中作者省略了很多他觉得简 单的过程).读者总希望看到象第一步怎么做,第 ...
- 下载google code中源码的几个工具
Google code 一般以三种命令行方式提供源代码,格式如下: hg clone https://code.google.com/p/xxx/ git clone https://code.goo ...
- vs2008编译FileZilla服务端源码
vs2008编译FileZilla服务端源码 FileZilla服务端下载地址:https://download.filezilla-project.org/server/.FileZilla服务端源 ...
- VSCode & outline & source code
VSCode & outline & source code Dart 源码学习 outline 速览 dart-core List class instance-methods ht ...
- Asp.Net MVC4+EF6 Code First 权限管理系统 源码下载
这个权限管理系统是基于在@TZHSWEET 的权限管理系统之上做的修改.@TZHSWEET 那个是DB first. 这个是Code First.源码下载:http://download.csdn.n ...
- Hadoop2.5.2源码编译及导入Eclipse
前言:由于官网提供的64位hadoop是没有编译的,所以当我们用到64位的hadoop时,需要在自己的64位linux系统上编译hadoop源码.另外,要想在eclipse里查看hadoop源码,修改 ...
随机推荐
- MySQL基础学习之索引
创建新表新索引 CREATE TABLE 表名(数据名 类型,INDEX 索引名称(属性)) 创建存在表的索引 CREATE INDEX 索引名称 ON 表名(属性) 修改索引 ALTER TAB ...
- rsync与inotify 数据同步
发布:thebaby 来源:脚本学堂 [大 中 小] 本文介绍下,在linux系统中,使用rsync与inotify实现数据同步的一个实例,有研究文件同步的朋友可以作个参考.本文转自:ht ...
- 【4】创建一个自己的Bootstrap模板
什么也不说了,直接贴上代码吧,哈哈 <!DOCTYPE html> <html lang="zh-cn"> <head> <meta ch ...
- 安装Android Studio报failed to find java version for 'C:\windows\system32\java.exe':[2] The system cannot find the specified file.错误的解决方案
方案很简单,找到SYSTEM32目录下的java.exe文件,重命名为java.exe.orj. 方案出处:http://stackoverflow.com/questions/10339679/an ...
- can't add foreign key in mysql?
create table department (dept_name ), building ), budget numeric(,) ), primary key (dept_name) ); cr ...
- 蜗牛历险记(二) Web框架(中)
上篇简单介绍了框架所使用的Autofac,采用Autofac提供的Ioc管理整个Web项目中所有对象的生命周期,实现框架面向接口编程.接下来介绍框架的日志系统. 一.介绍之前 框架日志是否有存在的必要 ...
- pywinauto二次封装(pywinnat.py)
将pywinauto常用方法进行封装,使得pywinauto用起来更简单 #头文件的引入 from pywinauto import application from pywinauto import ...
- Objective-c开发中混合使用ARC
首选“Compile Sources”的位置: 选中工程->TARGETS->相应的target然后选中右侧的“Build Phases”,向下就找到“Compile Sources”了. ...
- JAVA自学之-----FileInputStream类
1, FileInputStream类函数创建: package coreJava; import java.io.FileInputStream; import java.io.IOExceptio ...
- [转载]C# 多选功能(checkedListBox控件)
// 全选; private void btn_allSelected_Click(object sender, EventArgs e) { //this.CheckedListBox1.Check ...