我思故我強

          prototype學習資料(一)


          prototype學習資料(一)

          關(guān)鍵字: ? prototype學習資料????
          js 代碼
          1. prototype?1.3.1?版本和之前的?1.2.0?版本有了不少改進,并增加了新的功能:? ??
          2. 1.?增加了事件注冊管理? ??
          3. 2.?增加了空間定位的常用函數(shù)? ??
          4. 3.?改善了?xmlhttp?的封裝? ??
          5. 4.?移除了?Effect.js,交給?Rico?或者?script.aculo.us?這些擴展庫類實現(xiàn)。? ??
          6. 5.?bug?修復? ??
          7. 代碼:? ??
          8. /**? ?
          9. *?定義一個全局對象,?屬性?Version?在發(fā)布的時候會替換為當前版本號? ?
          10. */ ? ??
          11. var ?Prototype?=?{? ??
          12. Version:?'1.3.1',? ??
          13. //?一個空方法,其后的代碼常會用到,先前的版本該方法被定義于?Ajax?類中。? ??
          14. emptyFunction:? function ()?{}? ??
          15. }? ??
          16. /**? ?
          17. *?創(chuàng)建一種類型,注意其屬性?create?是一個方法,返回一個構(gòu)造函數(shù)。? ?
          18. *?一般使用如下? ?
          19. *?var?X?=?Class.create();?返回一個類型,類似于?java?的一個Class實例。? ?
          20. *?要使用?X?類型,需繼續(xù)用?new?X()來獲取一個實例,如同?java?的?Class.newInstance()方法。? ?
          21. *? ?
          22. *?返回的構(gòu)造函數(shù)會執(zhí)行名為?initialize?的方法,?initialize?是?Ruby?對象的構(gòu)造器方法名字。? ?
          23. *?此時initialize方法還沒有定義,其后的代碼中創(chuàng)建新類型時會建立相應的同名方法。? ?
          24. *? ?
          25. */ ? ??
          26. var ?Class?=?{? ??
          27. create:? function ()?{? ??
          28. return ? function ()?{? ??
          29. this .initialize.apply( this ,?arguments);? ??
          30. }? ??
          31. }? ??
          32. }? ??
          33. /**? ?
          34. *?創(chuàng)建一個對象,從變量名來思考,本意也許是定義一個抽象類,以后創(chuàng)建新對象都?extend?它。? ?
          35. *?但從其后代碼的應用來看,?Abstract?更多是為了保持命名空間清晰的考慮。? ?
          36. *?也就是說,我們可以給?Abstract?這個對象實例添加新的對象定義。? ?
          37. */ ? ??
          38. var ?Abstract?=? new ?Object();? ??
          39. Object.extend?=? function (destination,?source)?{? ??
          40. for ?(property? in ?source)?{? ??
          41. destination[property]?=?source[property];? ??
          42. }? ??
          43. return ?destination;? ??
          44. }? ??
          45. /**? ?
          46. *?獲取參數(shù)對象的所有屬性和方法,有點象多重繼承。但是這種繼承是動態(tài)獲得的。? ?
          47. *?如:? ?
          48. *?var?a?=?new?ObjectA(),?b?=?new?ObjectB();? ?
          49. *?var?c?=?a.extend(b);? ?
          50. *?此時?c?對象同時擁有?a?和?b?對象的屬性和方法。但是與多重繼承不同的是,c?instanceof?ObjectB?將返回false。? ?
          51. *? ?
          52. *?舊版本的該方法定義如下:? ?
          53. *?Object.prototype.extend?=?function(object)?{? ?
          54. *?for?(property?in?object)?{? ?
          55. *?this[property]?=?object[property];? ?
          56. *?}? ?
          57. *?return?this;? ?
          58. *?}? ?
          59. *? ?
          60. *?新的形式新定義了一個靜態(tài)方法?Object.extend,這樣做的目的大概是為了使代碼更為清晰? ?
          61. */ ? ??
          62. Object.prototype.extend?=? function (object)?{? ??
          63. return ?Object.extend.apply( this ,?[ this ,?object]);? ??
          64. }? ??
          65. /**? ?
          66. *?這個方法很有趣,它封裝一個javascript函數(shù)對象,返回一個新函數(shù)對象,新函數(shù)對象的主體和原對象相同,但是bind()方法參數(shù)將被用作當前對象的對象。? ?
          67. *?也就是說新函數(shù)中的?this?引用被改變?yōu)閰?shù)提供的對象。? ?
          68. *?比如:? ?
          69. *?? ?
          70. *?? ?
          71. *?.................? ?
          72. *?<script>? ?
          73. *?var?aaa?=?document.getElementById("aaa");? ?
          74. *?var?bbb?=?document.getElementById("bbb");? ?
          75. *?aaa.showValue?=?function()?{alert(this.value);}? ?
          76. *?aaa.showValue2?=?aaa.showValue.bind(bbb);? ?
          77. *?</script>? ?
          78. *?那么,調(diào)用aaa.showValue?將返回"aaa",?但調(diào)用aaa.showValue2?將返回"bbb"。? ?
          79. *? ?
          80. *?apply?是ie5.5后才出現(xiàn)的新方法(Netscape好像很早就支持了)。? ?
          81. *?該方法更多的資料參考MSDN?http://msdn.microsoft.com/library/e...6jsmthApply.asp? ?
          82. *?閱讀其后的代碼就會發(fā)現(xiàn),bind?被應用的很廣泛,該方法和?Object.prototype.extend?一樣是?Prototype?的核心。? ?
          83. *?還有一個?call?方法,應用起來和?apply?類似。可以一起研究下。? ?
          84. */ ? ??
          85. Function.prototype.bind?=? function (object)?{? ??
          86. var ?__method?=? this ;? ??
          87. return ? function ()?{? ??
          88. __method.apply(object,?arguments);? ??
          89. }? ??
          90. }? ??
          91. /**? ?
          92. *?和bind一樣,不過這個方法一般用做html控件對象的事件處理。所以要傳遞event對象? ?
          93. *?注意這時候,用到了?Function.call。它與?Function.apply?的不同好像僅僅是對參數(shù)形式的定義。? ?
          94. */ ? ??
          95. Function.prototype.bindAsEventListener?=? function (object)?{? ??
          96. var ?__method?=? this ;? ??
          97. return ? function (event)?{? ??
          98. __method.call(object,?event?||?window.event);? ??
          99. }? ??
          100. }? ??
          101. /**? ?
          102. *?將整數(shù)形式RGB顏色值轉(zhuǎn)換為HEX形式? ?
          103. */ ? ??
          104. Number.prototype.toColorPart?=? function ()?{? ??
          105. var ?digits?=? this .toString(16);? ??
          106. if ?( this ?<?16)? return ?'0'?+?digits;? ??
          107. return ?digits;? ??
          108. }? ??
          109. /**? ?
          110. *?典型?Ruby?風格的函數(shù),將參數(shù)中的方法逐個調(diào)用,返回第一個成功執(zhí)行的方法的返回值? ?
          111. */ ? ??
          112. var ?Try?=?{? ??
          113. these:? function ()?{? ??
          114. var ?returnValue;? ??
          115. for ?( var ?i?=?0;?i?<?arguments.length;?i++)?{? ??
          116. var ?lambda?=?arguments;? ??
          117. try ?{? ??
          118. returnValue?=?lambda();? ??
          119. break ;? ??
          120. }? catch ?(e)?{}? ??
          121. }? ??
          122. return ?returnValue;? ??
          123. }? ??
          124. }? ??
          125. /*--------------------------------------------------------------------------*/ ? ??
          126. /**? ?
          127. *?一個設計精巧的定時執(zhí)行器? ?
          128. *?首先由?Class.create()?創(chuàng)建一個?PeriodicalExecuter?類型,? ?
          129. *?然后用對象直接量的語法形式設置原型。? ?
          130. *? ?
          131. *?需要特別說明的是?rgisterCallback?方法,它調(diào)用上面定義的函數(shù)原型方法bind,?并傳遞自己為參數(shù)。? ?
          132. *?之所以這樣做,是因為?setTimeout?默認總以?window?對象為當前對象,也就是說,如果?registerCallback?方法定義如下的話:? ?
          133. *?registerCallback:?function()?{? ?
          134. *?setTimeout(this.onTimerEvent,?this.frequency?*?1000);? ?
          135. *?}? ?
          136. *?那么,this.onTimeoutEvent?方法執(zhí)行失敗,因為它無法訪問?this.currentlyExecuting?屬性。? ?
          137. *?而使用了bind以后,該方法才能正確的找到this,也就是PeriodicalExecuter的當前實例。? ?
          138. */ ? ??
          139. var ?PeriodicalExecuter?=?Class.create();? ??
          140. PeriodicalExecuter.prototype?=?{? ??
          141. initialize:? function (callback,?frequency)?{? ??
          142. this .callback?=?callback;? ??
          143. this .frequency?=?frequency;? ??
          144. this .currentlyExecuting?=? false ;? ??
          145. this .registerCallback();? ??
          146. },? ??
          147. registerCallback:? function ()?{? ??
          148. setInterval( this .onTimerEvent.bind( this ),? this .frequency?*?1000);? ??
          149. },? ??
          150. onTimerEvent:? function ()?{? ??
          151. if ?(! this .currentlyExecuting)?{? ??
          152. try ?{? ??
          153. this .currentlyExecuting?=? true ;? ??
          154. this .callback();? ??
          155. }? finally ?{? ??
          156. this .currentlyExecuting?=? false ;? ??
          157. }? ??
          158. }? ??
          159. }? ??
          160. }? ??
          161. /*--------------------------------------------------------------------------*/ ? ??
          162. /**? ?
          163. *?這個函數(shù)就?Ruby?了。我覺得它的作用主要有兩個? ?
          164. *?1.?大概是?document.getElementById(id)?的最簡化調(diào)用。? ?
          165. *?比如:$("aaa")?將返回?aaa?對象? ?
          166. *?2.?得到對象數(shù)組? ?
          167. *?比如:?$("aaa","bbb")?返回一個包括id為"aaa"和"bbb"兩個input控件對象的數(shù)組。? ?
          168. */ ? ??
          169. function ?$()?{? ??
          170. var ?elements?=? new ?Array();? ??
          171. for ?( var ?i?=?0;?i?<?arguments.length;?i++)?{? ??
          172. var ?element?=?arguments;? ??
          173. if ?( typeof ?element?==?'string')? ??
          174. element?=?document.getElementById(element);? ??
          175. if ?(arguments.length?==?1)? ??
          176. return ?element;? ??
          177. elements.push(element);? ??
          178. }? ??
          179. return ?elements;? ??
          180. }? ??
          181. /**? ?
          182. *?為兼容舊版本的瀏覽器增加?Array?的?push?方法。? ?
          183. */ ? ??
          184. if ?(!Array.prototype.push)?{? ??
          185. Array.prototype.push?=? function ()?{? ??
          186. var ?startLength?=? this .length;? ??
          187. for ?( var ?i?=?0;?i?<?arguments.length;?i++)? ??
          188. this [startLength?+?i]?=?arguments;? ??
          189. return ? this .length;? ??
          190. }? ??
          191. }? ??
          192. /**? ?
          193. *?為兼容舊版本的瀏覽器增加?Function?的?apply?方法。? ?
          194. */ ? ??
          195. if ?(!Function.prototype.apply)?{? ??
          196. //?Based?on?code?from?http://www.youngpup.net/? ??
          197. Function.prototype.apply?=? function (object,?parameters)?{? ??
          198. var ?parameterStrings?=? new ?Array();? ??
          199. if ?(!object)?object?=?window;? ??
          200. if ?(!parameters)?parameters?=? new ?Array();? ??
          201. ??
          202. for ?( var ?i?=?0;?i?<?parameters.length;?i++)? ??
          203. parameterStrings?=?'parameters['?+?i?+?']';? ??
          204. ??
          205. object.__apply__?=? this ;? ??
          206. var ?result?=?eval('object.__apply__('?+? ??
          207. parameterStrings.join(',?')?+?')');? ??
          208. object.__apply__?=? null ;? ??
          209. ??
          210. return ?result;? ??
          211. }? ??
          212. }? ??
          213. /**? ?
          214. *?擴展?javascript?內(nèi)置的?String?對象? ?
          215. */ ? ??
          216. String.prototype.extend({? ??
          217. /**? ?
          218. *?去掉字符串中的標簽? ?
          219. */ ? ??
          220. stripTags:? function ()?{? ??
          221. return ? this .replace(/</?[^>]+>/gi,? '' );? ??
          222. },? ??
          223. /**? ?
          224. *?這個方法很常見,通常的實現(xiàn)都是用正則表達式替換特殊字符為html規(guī)范定義的命名實體或者十進制編碼,比如:? ?
          225. *?string.replace(/&/g,?"&").replace(//g,?">");? ?
          226. *?而這里的實現(xiàn)借用瀏覽器自身的內(nèi)部替換,確實巧妙。? ?
          227. */ ? ??
          228. escapeHTML:? function ()?{? ??
          229. var ?div?=?document.createElement('div');? ??
          230. var ?text?=?document.createTextNode( this );? ??
          231. div.appendChild(text);? ??
          232. return ?div.innerHTML;? ??
          233. },? ??
          234. /**? ?
          235. *?同上? ?
          236. */ ? ??
          237. unescapeHTML:? function ()?{? ??
          238. var ?div?=?document.createElement('div');? ??
          239. div.innerHTML?=? this .stripTags();? ??
          240. return ?div.childNodes[0].nodeValue;? ??
          241. }? ??
          242. });? ??
          243. /**? ?
          244. *?定義?Ajax?對象,?靜態(tài)方法?getTransport?方法返回一個?XMLHttp?對象? ?
          245. */ ? ??
          246. var ?Ajax?=?{? ??
          247. getTransport:? function ()?{? ??
          248. return ?Try.these(? ??
          249. function ()?{ return ? new ?ActiveXObject('Msxml2.XMLHTTP')},? ??
          250. function ()?{ return ? new ?ActiveXObject('Microsoft.XMLHTTP')},? ??
          251. function ()?{ return ? new ?XMLHttpRequest()}? ??
          252. )?||? false ;? ??
          253. }? ??
          254. }? ??
          255. /**? ?
          256. *?我以為此時的Ajax對象起到命名空間的作用。? ?
          257. *?Ajax.Base?聲明為一個基礎(chǔ)對象類型? ?
          258. *?注意?Ajax.Base?并沒有使用?Class.create()?的方式來創(chuàng)建,我想是因為作者并不希望?Ajax.Base?被庫使用者實例化。? ?
          259. *?作者在其他對象類型的聲明中,將會繼承于它。? ?
          260. *?就好像?java?中的私有抽象類? ?
          261. */ ? ??
          262. Ajax.Base?=? function ()?{};? ??
          263. Ajax.Base.prototype?=?{? ??
          264. /**? ?
          265. *?extend?(見上)?的用法真是讓人耳目一新? ?
          266. *?options?首先設置默認屬性,然后再?extend?參數(shù)對象,那么參數(shù)對象中也有同名的屬性,那么就覆蓋默認屬性值。? ?
          267. *?想想如果我寫這樣的實現(xiàn),應該類似如下:? ?
          268. setOptions:?function(options)?{? ?
          269. this.options.methed?=?options.methed??options.methed?:?'post';? ?
          270. ..........? ?
          271. }? ?
          272. 我想很多時候,java?限制了?js?的創(chuàng)意。? ?
          273. */ ? ??
          274. setOptions:? function (options)?{? ??
          275. this .options?=?{? ??
          276. method:?'post',? ??
          277. asynchronous:? true ,? ??
          278. parameters:? '' ? ??
          279. }.extend(options?||?{});? ??
          280. },? ??
          281. /**? ?
          282. *?如果 xmlhttp?調(diào)用返回正確的HTTP狀態(tài)值,函數(shù)返回ture, 反之false。? ?
          283. *?xmlhttp 的?readyState?屬性不足以準確判斷?xmlhttp 遠程調(diào)用成功,該方法是readyState判斷的一個前提條件? ?
          284. */ ? ??
          285. responseIsSuccess:? function ()?{? ??
          286. return ? this .transport.status?==?undefined? ??
          287. ||? this .transport.status?==?0? ??
          288. ||?( this .transport.status?>=?200?&&? this .transport.status?<?300);? ??
          289. },? ??
          290. /**? ?
          291. *?如果 xmlhttp?調(diào)用返回錯誤的HTTP狀態(tài)值,函數(shù)返回ture, 反之false。? ?
          292. */ ? ??
          293. responseIsFailure:? function ()?{? ??
          294. return ?! this .responseIsSuccess();? ??
          295. }? ??
          296. }? ??
          297. /**? ?
          298. *?Ajax.Request?封裝?XmlHttp? ?
          299. */ ? ??
          300. Ajax.Request?=?Class.create();? ??
          301. /**? ?
          302. *?定義四種事件(狀態(tài)),?參考http://msdn.microsoft.com/workshop/...eadystate_1.asp? ?
          303. */ ? ??
          304. Ajax.Request.Events?=? ??
          305. ['Uninitialized',?'Loading',?'Loaded',?'Interactive',?'Complete'];? ??
          306. /**? ?
          307. * 相比先前的版本,對于 xmlhttp?的調(diào)用和返回值處理分離得更為清晰? ?
          308. */ ? ??
          309. Ajax.Request.prototype?=?( new ?Ajax.Base()).extend({? ??
          310. initialize:? function (url,?options)?{? ??
          311. this .transport?=?Ajax.getTransport();? ??
          312. this .setOptions(options);? ??
          313. this .request(url);? ??
          314. },? ??
          315.   /**? ?
          316. *?新增加?request?方法封裝?xmlhttp 的調(diào)用過程。? ?
          317. */ ? ??
          318. request:? function (url)?{? ??
          319. var ?parameters?=? this .options.parameters?||? '' ;? ??
          320. if ?(parameters.length?>?0)?parameters?+=?'&_=';? ??
          321. try ?{? ??
          322. if ?( this .options.method?==?'get')? ??
          323. url?+=?'?'?+?parameters;? ??
          324. this .transport.open( this .options.method,?url,? ??
          325. this .options.asynchronous);? ??
          326. if ?( this .options.asynchronous)?{? ??
          327. this .transport.onreadystatechange?=? this .onStateChange.bind( this );? ??
          328. setTimeout(( function ()?{ this .respondToReadyState(1)}).bind( this ),?10);? ??
          329. }? ??
          330. this .setRequestHeaders();? ??
          331. var ?body?=? this .options.postBody??? this .options.postBody?:?parameters;? ??
          332. this .transport.send( this .options.method?==?'post'???body?:? null );? ??
          333. }? catch ?(e)?{? ??
          334. }? ??
          335. },? ??
          336. /**? ?
          337. *?新增加的?setRequestHeaders?方法允許添加自定義的http?header? ?
          338. */ ? ??
          339. setRequestHeaders:? function ()?{? ??
          340. var ?requestHeaders?=? ??
          341. ['X-Requested-With',?'XMLHttpRequest',? ??
          342. 'X-Prototype-Version',?Prototype.Version];? ??
          343. if ?( this .options.method?==?'post')?{? ??
          344. requestHeaders.push('Content-type',? ??
          345. 'application/x-www-form-urlencoded');? ??
          346. /*?Force?"Connection:?close"?for?Mozilla?browsers?to?work?around? ?
          347. *?a?bug?where?XMLHttpReqeuest?sends?an?incorrect?Content-length? ?
          348. *?header.?See?Mozilla?Bugzilla?#246651.? ?
          349. */ ? ??
          350. if ?( this .transport.overrideMimeType)? ??
          351. requestHeaders.push('Connection',?'close');? ??
          352. }? ??
          353. /**? ?
          354. *?其后的?apply?方法的調(diào)用有些奇技淫巧的意味? ?
          355. *?從上下文中我們可以分析出?this.options.requestHeaders?是調(diào)用者自定義的http?header數(shù)組。? ?
          356. *?requestHeaders?也是一個數(shù)組,將一個數(shù)組中的元素逐個添加到另一個元素中,直接調(diào)用? ?
          357. *?requestHeaders.push(this.options.requestHeaders)? ?
          358. *?是不行的,因為該調(diào)用導致?this.options.requestHeaders?整個數(shù)組作為一個元素添加到?requestHeaders中。? ?
          359. *?javascript的Array對象還提供一個concat?的方法表面上滿足要求,但是concat實際上是創(chuàng)建一個新數(shù)組,將兩個數(shù)組的元素添加到新數(shù)組中。? ?
          360. *?所以,下面的代碼也可以替換為? ?
          361. *?requestHeaders?=?requestHeaders.concat(this.options.requestHeaders);? ?
          362. *?很顯然,作者不喜歡這樣的代碼方式? ?
          363. *?而?apply?方法的語法?apply([thisObj[,argArray]])?本身就要求第二個參數(shù)是一個數(shù)組或者arguments對象。? ?
          364. *?所以巧妙的實現(xiàn)了?concat?函數(shù)的作用。? ?
          365. *?令人拍案叫絕啊!? ?
          366. */ ? ??
          367. if ?( this .options.requestHeaders)? ??
          368. requestHeaders.push.apply(requestHeaders,? this .options.requestHeaders);? ??
          369. for ?( var ?i?=?0;?i?<?requestHeaders.length;?i?+=?2)? ??
          370. this .transport.setRequestHeader(requestHeaders,?requestHeaders[i+1]);? ??
          371. },? ??
          372. onStateChange:? function ()?{? ??
          373. var ?readyState?=? this .transport.readyState;? ??
          374. /**? ?
          375. *?如果不是?Loading?狀態(tài),就調(diào)用回調(diào)函數(shù)? ?
          376. */ ? ??
          377. if ?(readyState?!=?1)? ??
          378. this .respondToReadyState( this .transport.readyState);? ??
          379. },? ??
          380. /**? ?
          381. *?回調(diào)函數(shù)定義在?this.options?屬性中,比如:? ?
          382. var?option?=?{? ?
          383. onLoaded?:?function(req)?{...};? ?
          384. ......? ?
          385. }? ?
          386. new?Ajax.Request(url,?option);? ?
          387. */ ? ??
          388. respondToReadyState:? function (readyState)?{? ??
          389. var ?event?=?Ajax.Request.Events[readyState];? ??
          390. /**? ?
          391. *?新增的回調(diào)函數(shù)處理,調(diào)用者還可以在options中定義?on200,?onSuccess?這樣的回調(diào)函數(shù)? ?
          392. *?在?readyState?為完成狀態(tài)的時候調(diào)用? ?
          393. */ ? ??
          394. if ?(event?==?'Complete')? ??
          395. ( this .options['on'?+? this .transport.status]? ??
          396. ||? this .options['on'?+?( this .responseIsSuccess()???'Success'?:?'Failure')]? ??
          397. ||?Prototype.emptyFunction)( this .transport);? ??
          398. ( this .options['on'?+?event]?||?Prototype.emptyFunction)( this .transport);? ??
          399. /*?Avoid?memory?leak?in?MSIE:?clean?up?the?oncomplete?event?handler?*/ ? ??
          400. if ?(event?==?'Complete')? ??
          401. this .transport.onreadystatechange?=?Prototype.emptyFunction;? ??
          402. }? ??
          403. });? ??
          404. /**? ?
          405. *?Ajax.Updater?用于綁定一個html元素與?XmlHttp調(diào)用的返回值。類似與?buffalo?的?bind。? ?
          406. *?如果?options?中有?insertion(見后)?對象的話,?insertion?能提供更多的插入控制。? ?
          407. */ ? ??
          408. Ajax.Updater?=?Class.create();? ??
          409. Ajax.Updater.ScriptFragment?=?'(?:<script>)((n|.)*?)(?:</script>)';? ??
          410. Ajax.Updater.prototype.extend(Ajax.Request.prototype).extend({? ??
          411. initialize:? function (container,?url,?options)?{? ??
          412. /**? ?
          413. *?containers?就是被綁定的?html?對象,xmlhttp的返回值被賦給該對象的?innerHTML?屬性。? ?
          414. *?相比新版本,containers?根據(jù)container參數(shù)定義?success?和?failure?引用,如果它們被定義的話,根據(jù)xmlhttp調(diào)用是否成功來選擇? ?
          415. *?更新對象,假想調(diào)用可能如下:? ?
          416. *?var?c?=?{success:?$("successDiv"),?failure:?$("failureDiv")};? ?
          417. *?new?Ajax.Updater(c,?url,?options);? ?
          418. *?那么調(diào)用成功則?successDiv?顯示成功信息或者數(shù)據(jù),反之?failureDiv?顯示錯誤信息? ?
          419. */ ? ??
          420. this .containers?=?{? ??
          421. success:?container.success???$(container.success)?:?$(container),? ??
          422. failure:?container.failure???$(container.failure)?:? ??
          423. (container.success??? null ?:?$(container))? ??
          424. }? ??
          425. this .transport?=?Ajax.getTransport();? ??
          426. this .setOptions(options);? ??
          427. var ?onComplete?=? this .options.onComplete?||?Prototype.emptyFunction;? ??
          428. this .options.onComplete?=?( function ()?{? ??
          429. this .updateContent();? ??
          430. onComplete( this .transport);? ??
          431. }).bind( this );? ??
          432. this .request(url);? ??
          433. },? ??
          434. updateContent:? function ()?{? ??
          435. var ?receiver?=? this .responseIsSuccess()??? ??
          436. this .containers.success?:? this .containers.failure;? ??
          437. var ?match?=? new ?RegExp(Ajax.Updater.ScriptFragment,?'img');? ??
          438. var ?response?=? this .transport.responseText.replace(match,? '' );? ??
          439. var ?scripts?=? this .transport.responseText.match(match);? ??
          440. if ?(receiver)?{? ??
          441. if ?( this .options.insertion)?{? ??
          442. new ? this .options.insertion(receiver,?response);? ??
          443. }? else ?{? ??
          444. receiver.innerHTML?=?response;? ??
          445. }? ??
          446. }? ??
          447. if ?( this .responseIsSuccess())?{? ??
          448. if ?( this .onComplete)? ??
          449. setTimeout(( function ()?{ this .onComplete(? ??
          450. this .transport)}).bind( this ),?10);? ??
          451. }???

          posted on 2007-09-20 19:36 李云澤 閱讀(362) 評論(0)  編輯  收藏 所屬分類: Prototype(Ajax)

          主站蜘蛛池模板: 宝应县| 永福县| 上林县| 肃宁县| 鄂托克旗| 郧西县| 汨罗市| 合肥市| 乌鲁木齐市| 黄浦区| 嘉峪关市| 云安县| 泊头市| 汉川市| 葵青区| 苏尼特右旗| 辉南县| 泰来县| 宁德市| 新郑市| 金堂县| 临高县| 名山县| 雷山县| 武乡县| 平谷区| 阿拉善盟| 嘉定区| 正镶白旗| 北川| 崇信县| 潜江市| 盘山县| 明星| 丘北县| 庆安县| 皋兰县| 樟树市| 出国| 建宁县| 延安市|