首先先上**:
先看兩個函式 這兩個函式在接下來用得上。isundefined和 isdefined
isundefined函式定義如下:
isundefined這個函式判斷value是否為『undefined』型別。function
isundefined
(value)
只有value 為』undefined』型別時,都會返回 true.
如果value為null或其他型別,則這個函式都會返回 false;
isdefined函式如下:
isdefined判斷value值是否為』undefined』;function
isdefined
(value)
如果為undefined則返回false 否則其他的返回true
接下來看主函式 bindjquery.
var bindjqueryfired=false;
function
bindjquery
() var jqname=jq();
jquery=isundefined(jqname) ?window.jquery:
!jqname ? undefined :
window[jqname];
if(jquery&&jquery.fn.on);
originalcleandata=jquery.cleandata;
jquery.cleandata=function
(elems)
}originalcleandata(elems);
};}else
angular.element=jqlite;
bindjqueryfired=true;]
以上就是bindjquery的**段,下面來分批進行介紹各部分作用。
var bindjqueryfired=false;
這句話的作用相當與乙個開關,首次載入的時候定義為開啟狀態,當滿足某些條件後,自動關閉。
既然使用了jq()這個函式,那麼咋麼來看看jq()這個函式怎麼定義的function
bindjquery
()
jq()這個函式有什麼作用?function
jq()
/*定義臨時變數,儲存從dom元素中查詢到的elememnt*/
var el;
/*定義 變數 i 用於for迴圈*/
var i;
/* ngattrprefixes是乙個陣列,定義了首位元組,用於記錄
* angularjs中所有可能出現的頭位元組。
*/var ngattrprefixes=['ng-','data-ng-','ng:','x-ng-'];
/*定義變數ii 用於定義ngattrprefixes陣列的長度*/
var ii=ngattrprefixes.length;
/*prefix 用於獲取ngattrprefixes裡的變數,用於for迴圈*/
var prefix;
/*定義name 獲取el元素的屬性值*/
var name;
for(i=0;i/*遍歷ngattrprfixes 並把內容賦給 prefix*/
prefix=ngattrprefixes[i];
/*在整個文件中查詢元素或id或class中查詢
* ng-jq、data-ng-jq、ng\:jq、x-ng-jq這幾個值,如果找到將它賦給el;
* 如果沒有找到直接跳過。
* 當找到以上幾個值後並賦給el後,查詢這個元素上的屬性名分別為
* ng-jq、data-ng-jq、ng:jq、x-ng-jq
*/並將這些屬性名上的值賦給name;
if(el=window.document.queryselector('['+prefix.replace(':','\\:')+'jq]'))
}/*最後將這個name值賦給jq.name*/
return (jq.name_=name);
};
接下來回到主函式 bindjquery這個函式中。
文章還在編寫矯正中,有的地方肯定不足,請諒解 。。。function bindjquery()
/*獲取到jq.name並將值賦給jqname*/
var jqname=jq();
/* 假設 jq()函式返回了乙個值不是'undefined' */
* 則isundefined(jqname)返回值為true jquery=window.jquery;*/
* 如果jq()函式返回的是乙個值 jq.name; */
* 則isundefined(jqname)返回false */
* 首先先判讀 !jqname是否為true */
* (由於jqname現在返回的值有效,則現在的 !jqname為 false) */
* 則 jquery=window[jqname]; */
* 什麼時候會執行jquery=undefined. */
* 當jqname即不為js裡定義的 string bool,number,null,object,undefined,以外的型別 */
* 會執行jquery=undefined; */
* 應該防止程式出錯而定義的。 */
jquery=isundefined(jqname) ?window.jquery:
!jqname ? undefined :
window[jqname];
/*前面一定給jquery賦值 接下來判斷是否有jquery.fn.on這個函式。 */
/* 將jquery賦給angularjs自己定義的jqlite. */
/* extend函式是在第乙個引數下面新增其他的方法。 */
/* 並且在jquery.fn jquery 原型下面新增幾個方法。這幾個方法,我還沒有 */
/* 琢磨,有時間在和大家分享。 */
if(jquery&&jquery.fn.on));
originalcleandata=jquery.cleandata;
/*jquery.cleandata這個函式沒有看懂。*/
jquery.cleandata=function(elems)
}originalcleandata(elems);
};}else
/*將jqlite賦給angular.element*/
angular.element=jqlite;
/*將開關關閉*/
bindjqueryfired=true;
ngx process options函式詳解
ngx process options是初始化init cycle中的一些如 conf file,prefix,conf prefix等字段的功能,其方法的定義在src core nginx.c中,以下為詳細 主要功能是將ngx prefix,配置檔案的位置資訊,以及命令列引數的資訊初始化到cycl...
linux clock gettime函式詳解
注意 1.精確級別,納秒級別 原型long sys clock gettime clockid t which clock,struct timespec tp which clock引數解釋 clock realtime 系統實時時間,隨系統實時時間改變而改變,即從utc1970 1 1 0 0 ...
遞迴函式(詳例)
從函式棧的角度的運用 簡單的列印運用 includevoid function int n int main void function int n return 非空鍊錶的遞迴找最大值 lim findmax lim headptr 為了更好的理解遞迴的執行過程 在呼叫自生到最後時,if head...