1. /*!
  2. * Cloudgamer JavaScript Library v0.1
  3. * Copyright (c) 2009 cloudgamer
  4. * Blog: http://cloudgamer.cnblogs.com/
  5. * Date: 2009-10-15
  6. */
  7.  
  8. var $$, $$B, $$A, $$F, $$D, $$E, $$CE, $$S;
  9.  
  10. (function(undefined){
  11.  
  12. var O, B, A, F, D, E, CE, S;
  13.  
  14. /*Object*/
  15.  
  16. O = function (id) {
  17. return "string" == typeof id ? document.getElementById(id) : id;
  18. };
  19.  
  20. O.emptyFunction = function(){};
  21.  
  22. O.extend = function (destination, source, override) {
  23. if (override === undefined) override = true;
  24. for (var property in source) {
  25. if (override || !(property in destination)) {
  26. destination[property] = source[property];
  27. }
  28. }
  29. return destination;
  30. };
  31.  
  32. O.deepextend = function (destination, source) {
  33. for (var property in source) {
  34. var copy = source[property];
  35. if ( destination === copy ) continue;
  36. if ( typeof copy === "object" ){
  37. destination[property] = arguments.callee( destination[property] || {}, copy );
  38. }else{
  39. destination[property] = copy;
  40. }
  41. }
  42. return destination;
  43. };
  44.  
  45. /*from youa*/
  46. O.wrapper = function(me, parent) {
  47. var ins = function() { me.apply(this, arguments); };
  48. var subclass = function() {};
  49. subclass.prototype = parent.prototype;
  50. ins.prototype = new subclass;
  51. return ins;
  52. };
  53.  
  54. /*Browser*/
  55.  
  56. /*from youa*/
  57. B = (function(ua){
  58. var b = {
  59. msie: /msie/.test(ua) && !/opera/.test(ua),
  60. opera: /opera/.test(ua),
  61. safari: /webkit/.test(ua) && !/chrome/.test(ua),
  62. firefox: /firefox/.test(ua),
  63. chrome: /chrome/.test(ua)
  64. };
  65. var vMark = "";
  66. for (var i in b) {
  67. if (b[i]) { vMark = "safari" == i ? "version" : i; break; }
  68. }
  69. b.version = vMark && RegExp("(?:" + vMark + ")[\\/: ]([\\d.]+)").test(ua) ? RegExp.$1 : "0";
  70.  
  71. b.ie = b.msie;
  72. b.ie6 = b.msie && parseInt(b.version, 10) == 6;
  73. b.ie7 = b.msie && parseInt(b.version, 10) == 7;
  74. b.ie8 = b.msie && parseInt(b.version, 10) == 8;
  75.  
  76. return b;
  77. })(window.navigator.userAgent.toLowerCase());
  78.  
  79. /*Array*/
  80.  
  81. A = function(){
  82.  
  83. var ret = {
  84. isArray: function( obj ) {
  85. return Object.prototype.toString.call(obj) === "[object Array]";
  86. },
  87. indexOf: function( array, elt, from ){
  88. if (array.indexOf) {
  89. return isNaN(from) ? array.indexOf(elt) : array.indexOf(elt, from);
  90. } else {
  91. var len = array.length;
  92. from = isNaN(from) ? 0
  93. : from < 0 ? Math.ceil(from) + len : Math.floor(from);
  94.  
  95. for ( ; from < len; from++ ) { if ( array[from] === elt ) return from; }
  96. return -1;
  97. }
  98. },
  99. lastIndexOf: function( array, elt, from ){
  100. if (array.lastIndexOf) {
  101. return isNaN(from) ? array.lastIndexOf(elt) : array.lastIndexOf(elt, from);
  102. } else {
  103. var len = array.length;
  104. from = isNaN(from) || from >= len - 1 ? len - 1
  105. : from < 0 ? Math.ceil(from) + len : Math.floor(from);
  106.  
  107. for ( ; from > -1; from-- ) { if ( array[from] === elt ) return from; }
  108. return -1;
  109. }
  110. }
  111. };
  112.  
  113. function each( object, callback ) {
  114. if ( undefined === object.length ){
  115. for ( var name in object ) {
  116. if (false === callback( object[name], name, object )) break;
  117. }
  118. } else {
  119. for ( var i = 0, len = object.length; i < len; i++ ) {
  120. if (i in object) { if (false === callback( object[i], i, object )) break; }
  121. }
  122. }
  123. };
  124.  
  125. each({
  126. forEach: function( object, callback, thisp ){
  127. each( object, function(){ callback.apply(thisp, arguments); } );
  128. },
  129. map: function( object, callback, thisp ){
  130. var ret = [];
  131. each( object, function(){ ret.push(callback.apply(thisp, arguments)); });
  132. return ret;
  133. },
  134. filter: function( object, callback, thisp ){
  135. var ret = [];
  136. each( object, function(item){
  137. callback.apply(thisp, arguments) && ret.push(item);
  138. });
  139. return ret;
  140. },
  141. every: function( object, callback, thisp ){
  142. var ret = true;
  143. each( object, function(){
  144. if ( !callback.apply(thisp, arguments) ){ ret = false; return false; };
  145. });
  146. return ret;
  147. },
  148. some: function( object, callback, thisp ){
  149. var ret = false;
  150. each( object, function(){
  151. if ( callback.apply(thisp, arguments) ){ ret = true; return false; };
  152. });
  153. return ret;
  154. }
  155. }, function(method, name){
  156. ret[name] = function( object, callback, thisp ){
  157. if (object[name]) {
  158. return object[name]( callback, thisp );
  159. } else {
  160. return method( object, callback, thisp );
  161. }
  162. }
  163. });
  164.  
  165. return ret;
  166. }();
  167.  
  168. /*Function*/
  169.  
  170. F = (function(){
  171. var slice = Array.prototype.slice;
  172. return {
  173. bind: function( fun, thisp ) {
  174. var args = slice.call(arguments, 2);
  175. return function() {
  176. return fun.apply(thisp, args.concat(slice.call(arguments)));
  177. }
  178. },
  179. bindAsEventListener: function( fun, thisp ) {
  180. var args = slice.call(arguments, 2);
  181. return function(event) {
  182. return fun.apply(thisp, [E.fixEvent(event)].concat(args));
  183. }
  184. }
  185. };
  186. })();
  187.  
  188. /*Dom*/
  189.  
  190. D = {
  191. getScrollTop: function(node) {
  192. var doc = node ? node.ownerDocument : document;
  193. return doc.documentElement.scrollTop || doc.body.scrollTop;
  194. },
  195. getScrollLeft: function(node) {
  196. var doc = node ? node.ownerDocument : document;
  197. return doc.documentElement.scrollLeft || doc.body.scrollLeft;
  198. },
  199. contains: document.defaultView
  200. ? function (a, b) { return !!( a.compareDocumentPosition(b) & 16 ); }
  201. : function (a, b) { return a != b && a.contains(b); },
  202. rect: function(node){
  203. var left = 0, top = 0, right = 0, bottom = 0;
  204. //ie8的getBoundingClientRect获取不准确
  205. if ( !node.getBoundingClientRect || B.ie8 ) {
  206. var n = node;
  207. while (n) { left += n.offsetLeft, top += n.offsetTop; n = n.offsetParent; };
  208. right = left + node.offsetWidth; bottom = top + node.offsetHeight;
  209. } else {
  210. var rect = node.getBoundingClientRect();
  211. left = right = D.getScrollLeft(node); top = bottom = D.getScrollTop(node);
  212. left += rect.left; right += rect.right;
  213. top += rect.top; bottom += rect.bottom;
  214. };
  215. return { "left": left, "top": top, "right": right, "bottom": bottom };
  216. },
  217. clientRect: function(node) {
  218. var rect = D.rect(node), sLeft = D.getScrollLeft(node), sTop = D.getScrollTop(node);
  219. rect.left -= sLeft; rect.right -= sLeft;
  220. rect.top -= sTop; rect.bottom -= sTop;
  221. return rect;
  222. },
  223. curStyle: document.defaultView
  224. ? function (elem) { return document.defaultView.getComputedStyle(elem, null); }
  225. : function (elem) { return elem.currentStyle; },
  226. getStyle: document.defaultView
  227. ? function (elem, name) {
  228. var style = document.defaultView.getComputedStyle(elem, null);
  229. return name in style ? style[ name ] : style.getPropertyValue( name );
  230. }
  231. : function (elem, name) {
  232. var style = elem.style, curStyle = elem.currentStyle;
  233. //透明度 from youa
  234. if ( name == "opacity" ) {
  235. if ( /alpha\(opacity=(.*)\)/i.test(curStyle.filter) ) {
  236. var opacity = parseFloat(RegExp.$1);
  237. return opacity ? opacity / 100 : 0;
  238. }
  239. return 1;
  240. }
  241. if ( name == "float" ) { name = "styleFloat"; }
  242. var ret = curStyle[ name ] || curStyle[ S.camelize( name ) ];
  243. //单位转换 from jqury
  244. if ( !/^-?\d+(?:px)?$/i.test( ret ) && /^\-?\d/.test( ret ) ) {
  245. var left = style.left, rtStyle = elem.runtimeStyle, rsLeft = rtStyle.left;
  246.  
  247. rtStyle.left = curStyle.left;
  248. style.left = ret || 0;
  249. ret = style.pixelLeft + "px";
  250.  
  251. style.left = left;
  252. rtStyle.left = rsLeft;
  253. }
  254. return ret;
  255. },
  256. setStyle: function(elems, style, value) {
  257. if ( !elems.length ) { elems = [ elems ]; }
  258. if ( typeof style == "string" ) { var s = style; style = {}; style[s] = value; }
  259. A.forEach( elems, function(elem ) {
  260. for (var name in style) {
  261. var value = style[name];
  262. if (name == "opacity" && B.ie) {
  263. //ie透明度设置 from jquery
  264. elem.style.filter = (elem.currentStyle && elem.currentStyle.filter || "").replace( /alpha\([^)]*\)/, "" ) + " alpha(opacity=" + (value * 100 | 0) + ")";
  265. } else if (name == "float") {
  266. elem.style[ B.ie ? "styleFloat" : "cssFloat" ] = value;
  267. } else {
  268. elem.style[ S.camelize( name ) ] = value;
  269. }
  270. };
  271. });
  272. },
  273. getSize: function(elem) {
  274. var width = elem.offsetWidth, height = elem.offsetHeight;
  275. if ( !width && !height ) {
  276. var repair = !D.contains( document.body, elem ), parent;
  277. if ( repair ) {//如果元素不在body上
  278. parent = elem.parentNode;
  279. document.body.insertBefore(elem, document.body.childNodes[0]);
  280. }
  281. var style = elem.style,
  282. cssShow = { position: "absolute", visibility: "hidden", display: "block", left: "-9999px", top: "-9999px" },
  283. cssBack = { position: style.position, visibility: style.visibility, display: style.display, left: style.left, top: style.top };
  284. D.setStyle( elem, cssShow );
  285. width = elem.offsetWidth; height = elem.offsetHeight;
  286. D.setStyle( elem, cssBack );
  287. if ( repair ) {
  288. parent ? parent.appendChild(elem) : document.body.removeChild(elem);
  289. }
  290. }
  291. return { "width": width, "height": height };
  292. }
  293. };
  294.  
  295. /*Event*/
  296. E = (function(){
  297. /*from dean edwards*/
  298. var addEvent, removeEvent, guid = 1,
  299. storage = function( element, type, handler ){
  300. if (!handler.$$guid) handler.$$guid = guid++;
  301. if (!element.events) element.events = {};
  302. var handlers = element.events[type];
  303. if (!handlers) {
  304. handlers = element.events[type] = {};
  305. if (element["on" + type]) {
  306. handlers[0] = element["on" + type];
  307. }
  308. }
  309. };
  310. if ( window.addEventListener ) {
  311. var fix = { "mouseenter": "mouseover", "mouseleave": "mouseout" };
  312. addEvent = function( element, type, handler ){
  313. if ( type in fix ) {
  314. storage( element, type, handler );
  315. var fixhandler = element.events[type][handler.$$guid] = function(event){
  316. var related = event.relatedTarget;
  317. if ( !related || (element != related && !(element.compareDocumentPosition(related) & 16)) ){
  318. handler.call(this, event);
  319. }
  320. };
  321. element.addEventListener(fix[type], fixhandler, false);
  322. } else {
  323. element.addEventListener(type, handler, false);
  324. };
  325. };
  326. removeEvent = function( element, type, handler ){
  327. if ( type in fix ) {
  328. if (element.events && element.events[type]) {
  329. element.removeEventListener(fix[type], element.events[type][handler.$$guid], false);
  330. delete element.events[type][handler.$$guid];
  331. }
  332. } else {
  333. element.removeEventListener(type, handler, false);
  334. };
  335. };
  336. } else {
  337. addEvent = function( element, type, handler ){
  338. storage( element, type, handler );
  339. element.events[type][handler.$$guid] = handler;
  340. element["on" + type] = handleEvent;
  341. };
  342. removeEvent = function( element, type, handler ){
  343. if (element.events && element.events[type]) {
  344. delete element.events[type][handler.$$guid];
  345. }
  346. };
  347. function handleEvent() {
  348. var returnValue = true, event = fixEvent();
  349. var handlers = this.events[event.type];
  350. for (var i in handlers) {
  351. this.$$handleEvent = handlers[i];
  352. if (this.$$handleEvent(event) === false) {
  353. returnValue = false;
  354. }
  355. }
  356. return returnValue;
  357. };
  358. }
  359.  
  360. function fixEvent(event) {
  361. if (event) return event;
  362. event = window.event;
  363. event.pageX = event.clientX + D.getScrollLeft(event.srcElement);
  364. event.pageY = event.clientY + D.getScrollTop(event.srcElement);
  365. event.target = event.srcElement;
  366. event.stopPropagation = stopPropagation;
  367. event.preventDefault = preventDefault;
  368. var relatedTarget = {
  369. "mouseout": event.toElement, "mouseover": event.fromElement
  370. }[ event.type ];
  371. if ( relatedTarget ){ event.relatedTarget = relatedTarget;}
  372.  
  373. return event;
  374. };
  375. function stopPropagation() { this.cancelBubble = true; };
  376. function preventDefault() { this.returnValue = false; };
  377.  
  378. return {
  379. "addEvent": addEvent,
  380. "removeEvent": removeEvent,
  381. "fixEvent": fixEvent
  382. };
  383. })();
  384.  
  385. /*CustomEvent*/
  386.  
  387. CE = (function(){
  388. var guid = 1;
  389. return {
  390. addEvent: function( object, type, handler ){
  391. if (!handler.$$$guid) handler.$$$guid = guid++;
  392. if (!object.cusevents) object.cusevents = {};
  393. if (!object.cusevents[type]) object.cusevents[type] = {};
  394. object.cusevents[type][handler.$$$guid] = handler;
  395. },
  396. removeEvent: function( object, type, handler ){
  397. if (object.cusevents && object.cusevents[type]) {
  398. delete object.cusevents[type][handler.$$$guid];
  399. }
  400. },
  401. fireEvent: function( object, type ){
  402. if (!object.cusevents) return;
  403. var args = Array.prototype.slice.call(arguments, 2),
  404. handlers = object.cusevents[type];
  405. for (var i in handlers) {
  406. handlers[i].apply(object, args);
  407. }
  408. },
  409. clearEvent: function( object ){
  410. if (!object.cusevents) return;
  411. for (var type in object.cusevents) {
  412. var handlers = object.cusevents[type];
  413. for (var i in handlers) {
  414. handlers[i] = null;
  415. }
  416. object.cusevents[type] = null;
  417. }
  418. object.cusevents = null;
  419. }
  420. };
  421. })();
  422.  
  423. /*String*/
  424.  
  425. S = {
  426. camelize: function(s){
  427. return s.replace(/-([a-z])/ig, function(all, letter) { return letter.toUpperCase(); });
  428. }
  429. };
  430.  
  431. /*System*/
  432.  
  433. // remove css image flicker
  434. if (B.ie6) {
  435. try {
  436. document.execCommand("BackgroundImageCache", false, true);
  437. } catch(e) {}
  438. };
  439.  
  440. /*define*/
  441.  
  442. $$ = O; $$B = B; $$A = A; $$F = F; $$D = D; $$E = E; $$CE = CE; $$S = S;
  443.  
  444. })();

CJL.0.1.js的更多相关文章

  1. 非常好的一个JS代码(CJL.0.1.js)

    /*! * Cloudgamer JavaScript Library v0.1 * Copyright (c) 2009 cloudgamer * Blog: http://cloudgamer.c ...

  2. MyEclipse导入jquery-1.8.0.min.js等文件报错的解决方案

    1.选中报错的jquery文件例如"jquery-1.8.0.min.js". 2.右键选择 MyEclipse-->Exclude From Validation . 3. ...

  3. jquery-2.0.3.js和jquery-2.0.3.min.js的区别

    两个文件的作用是完全一样的. jquery-2.0.3.js里的代码是没有进行处理的原代码,适合于人们阅读与研究. jquery-2.0.3.min.js里的代码进行过特殊的处理, 如变量的名称基本都 ...

  4. MVC3.0+knockout.js+Ajax 实现简单的增删改查

    MVC3.0+knockout.js+Ajax 实现简单的增删改查 自从到北京入职以来就再也没有接触MVC,很多都已经淡忘了,最近一直在看knockout.js 和webAPI,本来打算采用MVC+k ...

  5. vue init初始化项目后 npm run dev报错 10% building modules 1/1 modules 0 activeevents.js:182 throw er; // Unhandled 'error' event

    报错信息: 10% building modules 1/1 modules 0 activeevents.js:182       throw er; // Unhandled 'error' ev ...

  6. EpiiAdmin 开源的php交互性管理后台框架, 让复杂的交互变得更简单!Phper快速搭建交互性平台的开发框架,基于Thinkphp5.1+Adminlte3.0+Require.js。

    EpiiAdmin EpiiAdmin php开源交互性管理后台框架,基于Thinkphp5.1+Adminlte3.0+Require.js, 让复杂的交互变得更简单!Phper快速搭建交互性平台的 ...

  7. 2018.6.18 MyEclipse导入jquery-1.8.0.min.js等文件报错的解决方案

    MyEclipse导入jQuery-1.8.0.min.js等文件的时候有时候会报了一堆missing semicolon的错误.怎么解决这个报错呢?方法如下: 1.选中报错的jquery文件例如&q ...

  8. Deno 1.0 & Node.js

    Deno 1.0 & Node.js A secure runtime for JavaScript and TypeScript. https://deno.land/v1 https:// ...

  9. vue2.0 flexible.js + rem 进行自适应开发

    1.在页面中引入flexible.js base.js /** * flexible.js 阿里前端自适应解决方案 */ ;(function(win, lib) { var doc = win.do ...

随机推荐

  1. BZOJ2301——莫比乌斯&&整除分块

    题目 对于给出的n个询问,每次求有多少个数对(x,y),满足a≤x≤b,c≤y≤d,且gcd(x,y) = k,gcd(x,y)函数为x和y的最大公约数. 分析 莫比乌斯经典入门题. (我也刚学,就写 ...

  2. zhengrui集训D1-D5笔记

    Day_1 计数 它咕掉了 Day_1 序列数据结构 它咕掉了 Day_2 线性代数 高斯消元\Large{高斯消元}高斯消元 普通版:略 模质数:求逆 模合数:exgcd 逆矩阵\Large{逆矩阵 ...

  3. JQuery实践--实用工具函数

    实用工具函数,$命名空间的一系列函数,但不操作包装集.它要么操作除DOM元素以外的Javascript对象,要么执行一些非对象相关的操作. JQuery的浏览器检测标志可在任何就绪处理程序执行之前使用 ...

  4. P4568 [JLOI2011]飞行路线 分层图最短路

    思路:裸的分层图最短路 提交:1次 题解: 如思路 代码: #include<cstdio> #include<iostream> #include<cstring> ...

  5. [shell]如何测试shell脚本,保证正确

    如何用最快最有效的方式进行测试? 很多开发的习惯是,二话不说,写完/拿到,就跑一把,看看输入,输出,想要的操作是否完成,也就过了. 其实这是十分不严谨的,若是未经过QA,风险还是相当大的. 以下即sh ...

  6. Apache Kudu: Hadoop生态系统的新成员实现对快速数据的快速分析

    A new addition to the open source Apache Hadoop ecosystem, Apache Kudu completes Hadoop's storage la ...

  7. 解决JAVA单步调试键盘输入被JDB占用的问题

    解决JAVA单步调试键盘输入被JDB占用的问题 问题来源: 在完成本周任务时,编写的代码中含有Scanner类,编译及运行过程均正确,但使用JDB单步调试时,运行到输入行无法在JDB内部输入变量值. ...

  8. java课后实验性问题7

    1.异常处理 import javax.swing.*; class AboutException { public static void main(String[] a) { int i = 1, ...

  9. Pro*C编程研究一:从.pc到.exe

    [第一步]在Windows下编辑一个.pc程序(Pro*C源程序,作者用到:C:\proctest\exam1.pc),其内容如下: #include <stdio.h> #include ...

  10. Quickstart: Create and publish a package using Visual Studio (.NET Framework, Windows)

    https://docs.microsoft.com/en-us/nuget/quickstart/create-and-publish-a-package-using-visual-studio-n ...