U.Extend.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035
  1. //#region 选择器区域
  2. //var win = window;// doc = document;
  3. window._$_ = window.$; //记录命名控件 //全局使用 解决jquery覆盖我们的选择器的问题。
  4. /*下面的写法会导致程序在window.onload之前执行,为什么要在window.onload之前执行,如果非要执行,能否把所有要做window.onload之前执行的整合在一个文件?并列明必须先执行的理由?*/
  5. /*
  6. 选择器前言
  7. 好处:
  8. 1、简化项目的代码
  9. 2、当我对系统的ocument.getElementById document.getElementsByTagName document.getElementsByClassName有奇异 觉得里面需要修改添加一些新的方法处理 可以统一处理
  10. */
  11. //#region 创建元素
  12. /*
  13. *使用$$操作符简化编码长度。
  14. *例:$$("div", { "style": { "cssText": "font-size:16px;float:left;line-height:33px;width:40%;margin:0px 0px 0px 15px;" }, "innerHTML": "文件名" }, Inner_J)
  15. * @param {string} 元素的类型tagName 例如:"div"
  16. * @param {object} 集合,类似 { "style": { "cssText": "font-size:16px;float:left;line-height:33px;width:40%;margin:0px 0px 0px 15px;" }, "innerHTML": "文件名" }
  17. * @param {element} 所要追加的父亲元素,把第二个参数作为孩子节点追加到第三个参数。par代表父亲元素
  18. * @param {element} 追加的位置,如果有此参数,则把创建的元素追加到此元素的前面。此元素必须为第三个参数的孩子节点。
  19. */
  20. window.$$ = function (str, obj, par, child) { //创建基本元素元素
  21. //不传递第三个参数,即父亲元素,则只创建,不追加。不呈现。
  22. par = par || "";
  23. var i, _element;
  24. var _UL = par ? par.length : 0; //
  25. var _UAE = { "frag": "createDocumentFragment", "text": "createTextNode" };
  26. if (_UAE[str]) {
  27. _element = document[_UAE[str]]();
  28. }
  29. else {
  30. _element = document.createElement(str);
  31. }
  32. //添加元素
  33. //如果有样式或者有属性?则给元素添加属性
  34. if (obj) {
  35. $(_element).addAttrArray(obj);
  36. }
  37. //如果存在父亲,则追加孩子节点。
  38. if (par) {
  39. //如果存在第四个参数,则追加到第四个参数的前面。否则,追加在最后面。
  40. if (child) {
  41. par.insertBefore(_element, child);
  42. }
  43. else {
  44. par.appendChild(_element);
  45. }
  46. }
  47. return _element;
  48. }
  49. window.$$.NS = function (UNE, UDE, UPE, UCE, UUE) { //创建带有命名空间的元素
  50. var _UDOD = $(document.createElementNS(UUE || "http://www.w3.org/2000/svg", UNE));
  51. _UDOD.addAttrArray(UDE); (UPE) && (_UDOD.appendTo(UPE, 0, UCE)); return _UDOD[0]; //添加属性
  52. }
  53. //#endregion
  54. //#region 选择器区
  55. //#region 1473用的快速选择器 去除没有必要的功能 只保留简单的选择功能
  56. /**
  57. * 初始化编辑区域
  58. *
  59. * @param {string} 选择 首先我们会定义3个获取元素的方法代替系统的 document.getElementById document.getElementsByTagName document.getElementsByClassName
  60. * @param {元素} 在元素下面搜索符合参数一的所有孩子节点
  61. 例一、$("#U_Help");找名为U_Help唯一id。
  62. 例二、$("div", UDKF):在元素UDKF下面搜索所有div元素。
  63. 例三:$(".className", UDKF) 在元素UDKF下面找classname等于classname的元素。不建议用,性能太低。
  64. */
  65. $ = function (name, el) {
  66. el = el || document; //如果不指定元素,默认为document.
  67. if (U.Ut.isString(name)) { //检测为普通选择器使用
  68. var _el = $.getElementByString(name, el); //获取制定的元素
  69. if (!_el || !_el.init) { //没有给初始化的工具
  70. return new $.SetMethod(_el); //这个是方法集合
  71. }
  72. return _el;
  73. }
  74. else { //复杂选择器使用
  75. return U.Select(name, el);
  76. }
  77. }
  78. //通过元素的来获取
  79. /**
  80. * 使用正则表带是
  81. *
  82. * @param {string} 选择
  83. * @param {document} 搜索的层次
  84. */
  85. $.getElementByString = function (name, doc) {
  86. var _e, //这个是获取成功的函数
  87. _r = name.substring(0, 1), //获取特殊字符 . # 或者 ""
  88. _n = name.substring(1, name.length); //去除特殊字符后
  89. doc = doc || document;
  90. //这里是判断获取
  91. try { //这里利用基础的选择器选取数据
  92. switch (_r) {
  93. case "#": //根据id获取 因为id获取只能通过全局搜索 但是由于项目中有存在克隆的情况 会出现id不唯一的情况
  94. (doc == document && U.MS.EN.test(_n)) && (_e = document.getElementById(_n));
  95. break;
  96. case ".": //根据className获取
  97. (U.MS.EN.test(_n)) && (_e = doc.getElementsByClassName(_n));
  98. break;
  99. default: //标签的获取 //获取指定的元素
  100. (U.MS.EN.test(name)) && (_e = doc.getElementsByTagName(name)); //除去特殊字符的处理
  101. break;
  102. }
  103. }
  104. catch (e) { }
  105. if (_e == null) { //基础的选择器无效 使用html5
  106. _e = window.SelectorElement(name, doc);
  107. if (!_e) { //基础选择器html5选择器使用 无法获取结果 使用自定义复杂选择器
  108. _e = U.Select(name, doc);
  109. }
  110. }
  111. //返回
  112. return _e;
  113. }
  114. /**
  115. * 元素方法
  116. *
  117. * @param {$object} 设置的域
  118. */
  119. $.SetMethod = function (el) {
  120. el = el || [];
  121. if (U.Ut.IHtmlC(el) || el.length == null) {
  122. el = [el];
  123. }
  124. this.length = el.length;
  125. for (var i = 0; i < el.length; i++) {
  126. if (el[i]) {
  127. this[i] = el[i];
  128. (el[i].id) && (this[el[i].id] = el[i]);
  129. }
  130. }
  131. }
  132. //#region 出让命名空间
  133. //出让命名空间
  134. //只有外部项目才会使用 为了和其他框架兼容的方案
  135. $.noConflict = function (UDE) {
  136. var _UDE = window._$_;
  137. if (_UDE && _UDE != $) {
  138. window._$_ = window.$; window.$ = _UDE;
  139. return window._$_;
  140. }
  141. return $;
  142. }
  143. //#endregion
  144. //#endregion
  145. //#region 通用选择器
  146. /**
  147. * 初始化编辑区域
  148. *
  149. * @param {string} 选择的元素,例如"div"
  150. * @param {document} 搜索的层次
  151. * 返回值:数组 [elment,elment,element]
  152. <body>
  153. <div class="classname">
  154. <div class="classname">
  155. <input />
  156. </div>
  157. <div class="classname">
  158. <input />
  159. </div>
  160. <div class="classname"></div>
  161. <div class="classname"></div>
  162. </div>
  163. <div>
  164. <div>
  165. <input />
  166. </div>
  167. <div>
  168. <input />
  169. </div>
  170. <div></div>
  171. <div></div>
  172. </div>
  173. </body>
  174. var a=U.Select("div.classname",body);
  175. var b=U.Select("input,a)
  176. */
  177. U.Select = function (USE, UD) { //定义类
  178. if (U.Ut.isFunction(USE)) {//函数的处理
  179. U.Select(document).ready(USE);
  180. }
  181. else {//返回选择器的实例
  182. return (new U.Select.fn.init(USE, UD));
  183. }
  184. }
  185. /**
  186. * 初始化编辑区域
  187. *
  188. * @param {string} 选择特殊字符串 包含# & []
  189. * @param {document} 搜索的层次
  190. */
  191. U.Select.GetSelector = function (UST) { //处理选择器
  192. if (UST == "#") { //getElementById 的选择符
  193. return " #";
  194. }
  195. else if (UST == "&") { //className联合的选择符
  196. return " ";
  197. }
  198. else if (UST.charAt(0) == "!") { //自定义参数的选择符
  199. return "[name='" + UST.substr(1) + "']";
  200. }
  201. else { //自定义参数使用
  202. return "[" + UST.substr(1).replace(U.Select.fn.match.ename, "='$1'") + "]";
  203. }
  204. };
  205. /**
  206. * 动画处理使用
  207. *
  208. * @param {string} 选择特殊字符串 包含# & []
  209. * @param {document} 搜索的层次
  210. * @param {document} 搜索的层次
  211. */
  212. U.Select.IsAnimate = function (UDE, UIE, UCL) {
  213. var i = UIE || 0, _UL = UIE == null ? UDE.length : UIE + 1, _UTF = arguments.length > 0;
  214. for (; i < _UL; i++) {
  215. if (_UTF) {
  216. UDE[i].__Animate__ = [UDE[i].style.cssText, UDE[i].className, UCL];
  217. }
  218. else {
  219. UDE[i].__Animate__ = null; delete UDE[i].__Animate__;
  220. }
  221. }
  222. };
  223. /**
  224. * 这里是选择器的方法集合
  225. *
  226. */
  227. U.Select.fn = U.Select.prototype = {//原型对象使用
  228. /**
  229. * 定义选择器构造器
  230. *
  231. * @param {string} 选择特殊字符串 包含# & []
  232. * @param {document} 搜索的层次
  233. * @return {$object} 返回创建的对象
  234. */
  235. init: function (USE, UD) {//
  236. var _UCE = this.context,
  237. _URE = this.selector;
  238. //设置值
  239. this.length = this.length || 0; //选择元素的总长度
  240. this.context = _UCE || UD || document; //选择器的域
  241. this.selector = (typeof USE === "string" ? _URE ? _URE + " " + USE : USE : USE); //选择器的所在的搜索字符串
  242. //获取元素选择
  243. this.select(USE, UD); //选择元素
  244. return this;
  245. },
  246. /**
  247. * 定义选择器构造器
  248. *
  249. * @param {string} 选择特殊字符串 包含# & []
  250. * @param {document} 搜索的层次
  251. */
  252. select: function (USE, UD) { //选择器选择
  253. UD = UD || document;
  254. if (U.Ut.isString(USE)) { //判断是为选择字符串
  255. if (USE.indexOf("<") > -1) { //判断是否为创建元素的字符串
  256. _UDE = $$(USE);
  257. }
  258. else {
  259. var i, j, k, _UTP, _UIE, _UTF, _UVE, _UGE, _UXE, _UJE, _UOT, _UST = "",
  260. _UDE = UD,
  261. _UME = this.match, //获取选取的正则
  262. _UCE = USE.replace(_UME.escape, U.Select.GetSelector),
  263. _UCN = _UME.con,
  264. _UKE = [],
  265. _UBE = browser.ver; //浏览器版本
  266. _UBE = (_UBE[1] == "msie" && _UBE[2].toInt()); //ie的版本
  267. //拆分选择器
  268. do {
  269. _UCN.exec("");
  270. _UCE = _UCN.exec(_UCE);
  271. _UKE.push(_UCE[1] + (_UCE[2] || ""));
  272. _UCE = _UCE[3];
  273. }
  274. while (_UCE); //生成获取集合
  275. _UXE: for (i = 0; (i < _UKE.length && _UDE); i++) {
  276. if (_UBE < 6 && _UME.nregular.test((_UTF = _UKE[i + 1]))) {//处理选择伪类等
  277. if (_UTF == "+" || _UTF == "~") { //向下选择
  278. if (_UOT = (_UME.pos.test(_UKE[i]) || _UME.child.test(_UKE[i]))) { _UVE = this.getelement(_UKE[i], _UDE, _UST); (U.Ut.IHtmlC(_UVE)) && (_UVE = [_UVE]); } else { _UJE = this.getType(_UKE[i]); }
  279. _UIE = this.getType(_UKE[i + 2]); _UDE = this.gete(_UDE, _UIE[4], _UST, _UIE);
  280. for (j = 0; j < _UDE.length; j++) { //判断获取
  281. _UTP = false; this.celement.apply[_UDE[j]], [_UTF == "+" ? "previousSibling" : "prevaAll", NaN, _UGE = []]; //获取
  282. for (k = 0; k < _UGE.length; k++) { if (_UOT) { if (_UVE.indexOf(_UGE[k]) > -1) { _UTP = true; break; } } else if (_UGE[0][_UJE[3]].toLowerCase() == _UKE[i]) { _UTP = true; break; } } (!_UTP) && (_UDE.splice(j, 1), j--);
  283. }
  284. }
  285. else if (_UTF == ">") { //子元素
  286. _UVE = this.getelement(_UKE[i], _UDE, _UST); if (typeof _UVE == "string") { _UVE == this.gete(_UDE, "", _UST); }
  287. if ((_UDE = _UVE)) {
  288. (U.Ut.IHtmlC(_UDE)) && (_UDE = [_UDE]); _UGE = []; _UIE = this.getType(_UKE[i + 2]); _UVE = this.gete(_UDE, _UIE[4], "", _UIE);
  289. for (j = 0; j < _UVE.length; j++) { for (k = 0; k < _UDE.length; k++) { if (_UDE[k] == _UVE[j].parentNode) { _UGE.push(_UVE[j]); break; } } }; _UDE = _UGE;
  290. }
  291. }
  292. _UST = ""; i += 2; (_UIE[2]) && (_UDE = this.getelement("", _UDE, _UIE[2]));
  293. }
  294. else { if (_UKE[i].length > 1 && _UKE[i].indexOf("*") > -1) { _UKE[i] = _UKE[i].substr(1); if (!(_UDE = document[_UKE[i]])) { if (browser.msie) { _UDE = document.getElementById(_UKE[i]); } else { _UDE = document.embeds[_UKE[i]]; } } _UST = ""; } else { _UVE = this.getelement(_UKE[i], _UDE, _UST); if (typeof _UVE == "string") { _UST += _UVE; } else if (_UVE) { _UDE = _UVE; _UST = ""; } else if (_UVE === null) { _UDE = null; break _UXE; } else { _UST += _UKE[i]; } } } //IE6以上的直接使用选择器
  295. }
  296. if (_UST && _UDE) { _UIE = this.getType(_UST); _UTF = (_UIE && !_UIE[2].trim()); _UDE = this.gete(_UDE, _UIE ? _UIE[4] : "", _UTF ? "" : _UST, _UTF ? _UIE : null); } //添加元素
  297. }
  298. }
  299. else { var _UDE = USE || []; }
  300. (_UDE) && (this.osadd(_UDE)); return this;
  301. },
  302. //正则匹配选择器
  303. match: {
  304. number: /\(([\s\S]*?)\)/, //数字的使用
  305. ename: /=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*/g, //[]选择符的使用
  306. escape: /(&|![\w\u00c0-\uFFFF\-]|\@[\w\u00c0-\uFFFF\-]+=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*)/g, //需要转义的正则
  307. nregular: /[>|+|~]/g, //伪类选择
  308. con: /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, //通用符的使用
  309. className: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, //className的定义
  310. id: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, //id的定义
  311. name: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, //name选择符处理
  312. attr: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
  313. tagName: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, child: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, //标签选择符处理
  314. pos: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, //子元素选择器
  315. pseudo: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
  316. },
  317. //多个选择
  318. osel: function (UTP, UTV, UDE, UTE) {
  319. var i, j, _UKE, _UAE = [], _UCE = [], _UTP = "parentNode", _UTF = true;
  320. if (UTP) { //选择
  321. _UCE = [];
  322. for (i = 0; i < UDE.length; i++) {
  323. if (UDE[i][UTP] == UTV || UDE[i].getAttribute(UTP) == UTV || UTV === undefined) {
  324. _UCE.push(UDE[i]);
  325. }
  326. }
  327. }
  328. else {
  329. for (i = 0; i < UDE.length; i++) {
  330. for (j = 0; j < _UAE.length; j++) {
  331. if (UDE[i][_UTP] == _UAE[j][0]) {
  332. _UAE[j][1].push(UDE[i]); break;
  333. }
  334. _UAE.push[UDE[i][_UTP], [UDE[i]]];
  335. }
  336. } //选择的元素
  337. for (i = 0; i < _UAE.length; i++) { //选择
  338. _UKE = (UTE && _UAE[0][UTE]) ? _UAE[0][UTE](UTP) : SelectorElement(UTP, _UAE[0]); //获取
  339. for (j = 0; j < _UKE.length; j++) {
  340. if (!_UAE[1].length) { break; }
  341. ((i = _UAE[1].indexOf(_UKE[j])) > -1) && (_UCE.push(_UKE[j]), _UAE[1].splice(i, 1));
  342. }
  343. }
  344. }
  345. return _UCE;
  346. },
  347. //添加选择的元素
  348. osadd: function (UDE) {
  349. if (U.Ut.IHtmlC(UDE) || UDE.length == null) {
  350. UDE = [UDE];
  351. }
  352. for (var i = 0; i < UDE.length; i++) {
  353. if (UDE[i]) {
  354. this[this.length++] = UDE[i];
  355. (UDE[i].id) && (this[UDE[i].id] = UDE[i]);
  356. }
  357. }
  358. return this; //添加元素
  359. },
  360. //移除元素
  361. del: function (UIE, UTF) {
  362. var i, _UL = this.length; (UIE != null) && (this[UIE] = null);
  363. if (!UTF) {
  364. for (i = 0; i < _UL; i++) {
  365. if (this[i] == null) {
  366. if (this[i + 1]) {
  367. this[i] = this[i + 1];
  368. this[i + 1] = null;
  369. }
  370. else { delete this[i]; } this.length--;
  371. }
  372. }
  373. }
  374. },
  375. gete: function (UDE, UTP, UTS, USM) {//获取元素
  376. var i, _UCE, _UKE = []; (U.Ut.IHtmlC(UDE)) && (UDE = [UDE]);
  377. for (i = 0; i < UDE.length; i++) {
  378. _UCE = UDE[i]; _UCE = (!UTS && (USM[1].length >= USM[0].length - 1) && _UCE[UTP]) ? _UCE[UTP](USM[1]) : SelectorElement(UTS + (USM ? USM[0] : ""), _UCE);
  379. if (_UCE) { (U.Ut.IHtmlC(_UCE)) && (_UCE = [_UCE]); _UKE = _UKE.concat(U.M.toArray(_UCE)); }
  380. }
  381. return _UKE;
  382. },
  383. getelement: function (UCE, UDE, USE) {//通过选择字符串获取元素
  384. var i, _UME = this.match, _UAE = UCE ? this.getType(UCE) : "", _UST = _UAE && _UAE[2], _UBE = browser.ver, _UTF = _UME.pos.test(_UST) || _UME.child.test(_UST); _UBE = (_UBE[1] == "msie", _UBE[2].toInt()); if (!_UAE && UCE) { return _UAE; }
  385. if (_UAE && USE !== true && (_UAE[0] == UCE || _UAE[2].indexOf(":") == -1) || (!_UTF || (!_UBE || _UBE > 8 || (UCE.indexOf("first-child") > -1 && _UBE > 6)))) { return UCE + " "; } //兼容添加选择值
  386. else {
  387. if (_UTF) { //过滤选择 //伪类选择
  388. _UST = _UST.split(":"); _UAE[0] += _UST[0]; UDE = this.gete(UDE, _UAE[4], USE, _UAE);
  389. for (i = 1; i < _UST.length; i++) { if (_UST[i] && !U.Ut.IHtmlC(UDE)) { UDE = this.selecte[_UST[i].split("(")[0]].call(this, UDE, _UST[i]); } }
  390. }
  391. else { UDE = this.gete(UDE, _UAE[4], "", _UAE); }; return UDE
  392. }
  393. },
  394. getType: function (UCE) {//获取格式
  395. var i, _UJE, _UME = this.match, _UAE = { "name": "getElementsByName", "id": "getElementById", "tagName": "getElementsByTagName", "className": "getElementsByClassName" };
  396. for (i in _UAE) { if ((_UJE = _UME[i].exec(UCE))) { return [_UJE[0], _UJE[1], UCE.replace(_UJE[0], ""), i, _UAE[i]]; } } //获取值
  397. },
  398. getValue: function (USE) { //通过选择字符串生成响应的选择
  399. var i, _UDE = {}, _UNC = this.common.nregular, _UC = this.common.regular, _UNCA = (USE.match(_UNC) || []), _UCA = USE.match(_UC) || ["*"];
  400. for (i = 0; i < _UCA.length; i++) { switch (_UNCA[j]) { case "!": _UDE["name"] = _UCA[j]; break; case "#": _UDE["id"] = _UCA[j]; break; case ".": _UDE["className"] = _UCA[j]; break; case "": case "&": _UDE["tagName"] = _UCA[j]; break; } } //获取
  401. return _UDE;
  402. },
  403. extend: function (UDE) { //扩展选择器
  404. U.Ut.AddObj(this, UDE)
  405. },
  406. length: 0, //初始化长度
  407. splice: Array.prototype.splice, //筛选的方法
  408. constructor: U.Select //原型构造器设为本身
  409. }
  410. U.Select.fn.init.prototype = U.Select.fn; //添加扩展
  411. //#endregion
  412. //#region 扩展选择器
  413. U.Select.fn.extend({
  414. //参数一:字符串,形如"div"
  415. //参数二:整形,从哪个下标开始找。
  416. find: function (USE, UIE) { //获取元素的后代
  417. var j;
  418. var i = UIE || 0;
  419. var _UL = UIE + 1 || this.length;
  420. var _elements = []; //
  421. for (; i < _UL; i++) {
  422. _elements.concat(U.Select(USE, this[i]));
  423. // _elements.init(USE, this[i]);
  424. } //筛选
  425. //去除选取出来的重复项[element,elment,elment,element]
  426. _elements.unique();
  427. return _elements;
  428. },
  429. filter: function (UTF, UDE) {//结果集筛选
  430. UDE = UDE || this; var _UTF, _UCE = [], j, i = 0; if (typeof UTF == "string") { UTF = this.getValue(UTF) } //处理制定的选择 转化成可识别选择
  431. for (i = 0; i < this.length; i++) {
  432. for (j in UTF) { if (UTF.hasOwnProperty(j)) { if (this[i][j] != UTF[j]) { break; } } }
  433. (this[i][j] == UTF[j]) && (_UCE.push(this[i]));
  434. }
  435. return U.Select().osadd(_UCE); //添加子元素到制定的位置
  436. },
  437. Nodes: function (UIE) { //获取所有的子元素
  438. UIE = UIE || 0; return this[UIE] ? this[UIE].childNodes : null;
  439. },
  440. //UIE 需要给选择的元素数组的第几个
  441. Child: function (UIE) {//获取有效元素孩子节点
  442. UIE = UIE || 0; //由于选择选择出来的元素是数组,所以需要筛选出第几个需要获取子节点
  443. var _UDE = this[UIE] ? U.M.GTCN(this[UIE].childNodes) : null; //如果选择的元素存在则获取子节点 通过U.M.GTCN 可以把 #text节点过滤
  444. return _UDE;
  445. // UIE = UIE || 0; var _UDE = this[UIE] ? U.M.GTCN(this[UIE].childNodes, UTP) : null;
  446. // return UIF != null ? _UDE[UIF] : _UDE;
  447. },
  448. siblings: function (UIE) { //当前元素所有的兄弟节点
  449. var i, _UDE = ["preva", "next"], _UAE = U.Select();
  450. for (i = 0; i < _UDE.length; i++) { this.celement(_UDE[i] + "All", UIE, _UAE); }
  451. return _UAE
  452. },
  453. celement: function (UTP, UIE, UAE) { //获取元素
  454. var _UDOD, j, i = UIE || 0, _UL = UIE + 1 || this.length, _UTF = { "prevaAll": "previousSibling", "nextAll": "nextSibling"}[UTP]; UTP = _UTF || UTP; UAE = UAE || U.Select();
  455. for (i = 0; i < _UL; i++) { //获取指定元素结果
  456. j = 1; _UDOD = this[i]; while ((j > 0 || (_UTF && _UDOD)) && _UDOD[UTP]) {
  457. do { _UDOD = _UDOD[UTP]; }
  458. while (_UDOD && _UDOD.nodeType !== 1);
  459. (_UDOD) && (UAE[UAE.length++] = _UDOD);
  460. j--;
  461. }
  462. }
  463. return UAE;
  464. },
  465. ofparent: function (UIE, UTF) {//获取offsetParent
  466. var i = UIE || 0, _UL = UIE + 1 || this.length, UAE = U.Select();
  467. for (i = 0; i < _UL; i++) { UAE[UAE.length++] = U.M.TOSP(this[i]); }
  468. return UAE;
  469. },
  470. prev: function (UIE) { //当前元素前一个兄弟节点
  471. return this.celement("previousSibling", UIE);
  472. },
  473. prevaAll: function (UIE) {//当前元素之前所有的兄弟节点
  474. return this.celement("prevaAll", UIE);
  475. },
  476. next: function (UIE) { //当前元素之后第一个兄弟节点
  477. return this.celement("nextSibling", UIE);
  478. },
  479. nextAll: function (UIE) { //当前元素之后所有的兄弟节点
  480. return this.celement("nextAll", UIE);
  481. },
  482. //如果没有参数,则是查找自己的父亲,如果有参数,则查找符合条件的祖先元素。
  483. //如果UTF是数字n,则向上查找n层祖先。
  484. //如果UTF是属性,则查找符合条件的属性。
  485. Parent: function (UTF) {//获取上级父亲层
  486. var i, _USE, _UDOD = this[0]; UTF = UTF || 1;
  487. if (U.Ut.isNumber(UTF)) { for (i = 0; i < UTF; i++) { (_UDOD) && (_UDOD = _UDOD.parentNode); } }
  488. else if (U.Ut.isString(UTF)) { _UDOD = U.M.GTPN(_UDOD, UTF); }
  489. else {
  490. _USE: while (_UDOD && _UDOD != document) {
  491. for (i in UTF) {
  492. if (UTF.hasOwnProperty(i)) {
  493. if (UTF[i] != _UDOD[i] && _UDOD.getAttribute(i) != UTF[i]) {
  494. _UDOD = _UDOD.parentNode;
  495. } else { break _USE; }
  496. }
  497. }
  498. }
  499. } //条件搜索
  500. return _UDOD;
  501. },
  502. replaceAll: function (UDE, UIE) {
  503. var _UME, i = UIE || 0, _UL = UIE + 1 || 1;
  504. for (; i < _UL; i++) {
  505. if (U.Ut.isString(UDE)) { _UME = $$(UDE); } else { _UME = U.Select(UDE).clone(true); }
  506. this.Parent(1, i).replaceChild(this[i], _UME);
  507. }
  508. },
  509. //获取孩子节点,能够过滤txt文本。否则,txt文本也可能作为孩子节点,不能精确匹配。
  510. //UIE 基本没有用
  511. //UIF 是获取返回子元素的第几个。
  512. //UTP 基本没有用
  513. childg: function (UIE, UIF, UTP) {//获取孩子节点
  514. return U.Select(this.Child.apply(this, arguments));
  515. },
  516. parentg: function (UTF, ITF) {//获取父亲节点
  517. return U.Select(this.Parent(UTF, ITF));
  518. },
  519. even: function () { //获取偶数元素
  520. return this.Auxiliary.selectel("even", this);
  521. },
  522. odd: function () { //获取奇数元素
  523. return this.Auxiliary.selectel("odd", this);
  524. },
  525. eq: function (UIE) { //索引制定位置的元素
  526. return this.Auxiliary.selectel("=" + UIE, this);
  527. },
  528. gt: function (UIE) { //索引大于的元素
  529. return this.Auxiliary.selectel(">" + UIE, this);
  530. },
  531. lt: function (UIE) {//索引小于的元素
  532. return this.Auxiliary.selectel("<" + UIE, this);
  533. },
  534. each: function (UCB, UDE) { //遍历数据
  535. if (UCB) { var i; UDE = UDE || this; for (i = 0; i < UDE.length; i++) { UCB(i, UDE[i]); } }
  536. },
  537. only: function (UIE) { //选择没有兄弟节点的元素
  538. var i, j, _UCE, _UPE, UL = UIE + 1 || this.length;
  539. for (i = 0; i < UL; i++) { _UCE = this.parentg(1, i).Child(); (_UCE.length != 1 || _UCE[0] != this[i]) && (this.del(i, true)); }
  540. this.del(); return this;
  541. },
  542. checked: function (UIE) {//获取所有给单选或者复选的元素
  543. var _UCE, j, i = UIE || 0, _UL = UIE + 1 || this.length, _UVE = U.Select();
  544. for (i = 0; i < _UL; i++) {
  545. _UCE = U.Select("input@type=checkbox", this[i]); //获取复选框
  546. for (j = 0; j < _UCE.length; j++) { (_UCE[j].checked) && (_UVE.osadd(_UCE[j])); } //添加所有给复选的元素
  547. }
  548. return _UVE;
  549. },
  550. selected: function (UIE) {//获取下拉列表中给选择的元素
  551. var _UCE, j, i = UIE || 0, _UL = UIE + 1 || this.length, _UVE = U.Select();
  552. for (i = 0; i < _UL; i++) { }
  553. },
  554. clone: function (UTF, UIE, UDOD, UDID, USE) { //克隆元素
  555. var _UDTD, _UDE = [], i = UIE || 0, _UL = UIE + 1 || this.length;
  556. for (; i < _UL; i++) { _UDE.push(this[i].cloneNode(UTF || false)); }
  557. _UDTD = U.Select(_UDE); (USE) && (_UDTD.Aattr(USE)); (UDID && !UDOD) && (UDOD = U.Select(UDID).Parent());
  558. (UDOD) && (_UDTD.appendTo(UDOD, undefined, UDID)); return _UDTD; //直接追加元素
  559. },
  560. appendTo: function (UDOD, UIE, UDTD) {//添加元素到制定的位置
  561. var i = UIE || 0, _UL = UIE + 1 || this.length; UDOD = U.Select(UDOD);
  562. for (; i < _UL; i++) { UDOD["append"](this[i], 0, UDTD || null); }
  563. return this;
  564. },
  565. append: function (UDOD, UIE, UDTD) {//插入元素
  566. if (UDOD) {
  567. if (typeof UDOD == "string") { UDOD = $$("div", { "innerHTML": UDOD }).childNodes; } else { (UDOD.length == null || UDOD.tagName) && (UDOD = [UDOD]); }
  568. var i, _UL = UDOD.length; for (i = 0; i < UDOD.length; ((_UL == UDOD.length) && (i++))) { this[UIE || 0][UDTD ? "insertBefore" : "appendChild"](UDOD[i] || UDOD, UDTD || null); }
  569. } return this;
  570. },
  571. before: function (UDOD, UIE) { //被选择元素前插入指定元素
  572. var i = UIE || 0, _UL = (UIE || 0) + 1;
  573. for (; i < UIE; i++) { this.append(UDOD, i, this[i].firstChild); }
  574. },
  575. remove: function (UIE, UTF) {//移除元素
  576. var _UDOD, i = UIE = UIE || 0, _UL = (UIE || this.length - 1) + 1;
  577. if (UTF == "animate") { this.fadeOut("fast", function (UIF) { var _UDOD = this[i]; (_UDOD && _UDOD.parentNode) && (_UDOD.parentNode.removeChild(_UDOD)); }, UIE); }
  578. else { for (; i < _UL; i++) { _UDOD = this[i]; (_UDOD && _UDOD.parentNode) && (_UDOD.parentNode.removeChild(_UDOD)); } }
  579. return this;
  580. },
  581. top: function (UIE) { //获取offsetTop
  582. return this[UIE || 0].offsetTop;
  583. },
  584. left: function (UIE) { //获取offsetLeft
  585. return this[UIE || 0].offsetLeft;
  586. },
  587. width: function (UIE) {//获取长
  588. return U.M.GETHW(this[UIE || 0], "width");
  589. },
  590. innerWidth: function (UIE) { //获取内宽度 包含padding
  591. return this[UIE || 0].clientWidth;
  592. },
  593. outerWidth: function (UIE, UTF) { //获取整体宽度 包含 padding border ture包含margin
  594. this[UIE || 0].offsetWidth + this.css("marginLeft") + this.css("marginRight");
  595. },
  596. height: function (UIE) { //获取宽
  597. return U.M.GETHW(this[UIE || 0], "height");
  598. },
  599. innerHeight: function () { //内高度
  600. return this[UIE || 0].clientHeight;
  601. },
  602. outerHeight: function () { //外高度
  603. this[UIE || 0].offsetWidth + this.css("marginTop") + this.css("marginBottom");
  604. },
  605. replaceC: function (UDOD, UIE) { //元素顶替
  606. UIE = UIE || 0; var _UDPD, _UDTD = this[UIE];
  607. if (_UDTD) { _UDPD = this.Parent(1, UIE); (_UDPD) && (_UDPD.replaceChild(UDOD, _UDTD)); this[UIE] = UDOD; }; return this;
  608. },
  609. Center: function (ITF, UCB) { //元素居中
  610. var i = ITF || 0, _UL = ITF + 1 || this.length;
  611. for (; i < _UL; i++) { U.D.PopupWindow(this[i]); } //居中弹出
  612. (UCB) && (UCB()); return this;
  613. },
  614. html: function (UHT, UIE) { return UHT != null ? this.Aattr({ "innerHTML": UHT }, UIE) : this[UIE || 0].innerHTML; }, //获取innerhtml
  615. text: function (UHT, UIE) { return UHT != null ? this.Aattr({ "innerText": UHT }, UIE) : this[UIE || 0].innerText; }, //获取innerText
  616. GetElementInfo: function (ITF) { return U.M.GetElementInfo(this[ITF || 0]); }, //获取元素的大小和位置等等
  617. //和jquery一致,
  618. css: function (UDE, UVE, UIE) {//获取指定的css值
  619. if (UDE) {
  620. var i = UIE || 0, _UL = UIE + 1 || this.length, _UTF = (typeof UDE == "object");
  621. if (UVE != null || _UTF) {
  622. if (_UTF) { this.addAttrArray({ "style": UDE }, UVE); } //添加style
  623. else { for (i; i < _UL; i++) { UDE = U.M.CssTHH(UDE); this[i].style[UDE] = UVE; } } //循环添加class值
  624. }
  625. else { return U.M.GetStyle(this[i], UDE); } //获取css值
  626. }
  627. return this;
  628. },
  629. getBackgroundColor: function (UDE) { //获取设置背景图片
  630. if (U.Ut.isString(UDE)) { }
  631. else if (U.Ut.isArray(UDE)) { }
  632. },
  633. first: function () { //获取结果里的第一个元素
  634. return U.Select(this[0]);
  635. },
  636. last: function () { //获取最后一个元素
  637. return U.Select(this[this.length - 1]);
  638. },
  639. addClass: function (UCN, ITF) { //添加Class
  640. U.M.ARClass(this, ITF, UCN, "Add");
  641. return this;
  642. },
  643. removeClass: function (UCN, ITF) {//移除制定的class
  644. U.M.ARClass(this, ITF, UCN, "RE");
  645. return this;
  646. },
  647. hasClass: function (UCN, ITF) {//判断元素是否有制定的class
  648. return U.M.ARClass(this, ITF, UCN, "");
  649. },
  650. attr: function (USN, UV, UIE, UTP) { //添加属性
  651. var i, _UCE, _UTF = (typeof UDE == "object");
  652. if (!UV && _UTF) { //添加属性
  653. _UCE = USN; (!_UTF) && (_UCE = {}, _UCE[USN] = UV);
  654. for (i in _UCE) { (_UCE.hasOwnProperty(i)) && (U.M.SRAttr(this, USN, UV, UIE ? (UIE.length ? UIE : [UIE]) : null)); } //添加属性
  655. }
  656. else { return UTP ? this[UIE || 0][UTP].getAttribute(USN) : this[UIE || 0].getAttribute(USN); } //获取属性
  657. },
  658. rmAttr: function (USN, UIE, UTP) { //移除属性
  659. U.M.SRAttr(UIE != null ? [this[UIE]] : this, USN, null, UTP); //移除元素
  660. return this;
  661. },
  662. Aattr: function (UDE, UIE) { return this.addAttrArray(UDE, UIE); },
  663. addAttrArray: function (UDE, UIE) {//赋值区域
  664. var i, j, k, _UNE, _UTP, _UVE, _UAE, _UST, _UTE = this, i = UIE || 0, _UL = UIE + 1 || this.length, _UGE = { "class": "className", "html": "innerHTML", "text": "innerText", "float": "cssFloat" }, _UME = ["width,height,top,bottom,left,right", "px"];
  665. for (; (i < _UL && i < this.length); i++) {
  666. for (j in UDE) {
  667. if (UDE.hasOwnProperty(j)) {
  668. if (j == "style") { //style赋值
  669. _UVE = ""; _UAE = UDE[j];
  670. for (k in _UAE) { //添加cssText
  671. if (_UAE.hasOwnProperty(k)) {
  672. _UTP = U.M.CssTHH(k, true); _UNE = _UAE[k];
  673. if ((k in this[i][j]) && (_UTP == "css-text" || _UAE[k]) && this[i].cloneNode) {
  674. if (_UTP == "css-text") { _UVE = _UAE[k] + ";" + _UVE; } //cssText赋值
  675. else { (_UME[0].split(",").indexOf(_UTP, null, true) > -1 && U.Ut.isStringInt(_UNE)) && (_UNE += _UME[1]); _UVE += _UTP + ":" + _UNE + ";"; } //单个属性赋值
  676. continue;
  677. }
  678. this[i][j][U.M.CssTHH(k)] = _UAE[k] || "";
  679. }
  680. }
  681. (_UVE != null) && (this[i][j]["cssText"] += ";" + _UVE); //添加css值
  682. }
  683. else { //其它属性赋值
  684. if (j.indexOf("on") == 0 && "array,string".indexOf(U.M.GetType((_UVE = UDE[j]))) > -1) { ((_UVE = UDE[j]) && typeof _UVE[0] == "function") && (_UVE = [_UVE]); UDE[j] = U.M.apply(this[i], _UVE); } //事件特殊处理
  685. if (typeof (_UAE = this[i])[j] == "object" && typeof UDE[j] == "object") { U.Ut.AddObj(_UAE[j], UDE[j]); } //object赋值
  686. else { if (_UAE[j] !== UDE[j]) { _UST = _UAE[j]; k = _UGE[j] || j; if (U.Ut.isString((_UVE = UDE[j])) && U.M.Arrt(_UAE, k)) { try { _UAE.setAttribute(k, _UVE); } catch (e) { } } _UAE[k] = UDE[j]; } } //非原属性下的
  687. }
  688. }
  689. }
  690. }
  691. return this;
  692. },
  693. animate: function (UDE, USP, UCB, UIF, UGE) { //css3动画效果和js原始动画 动画排队
  694. if (UDE) {
  695. var i, j, k, _UTE, _UKW, _USE, _UE, _UDID, _UTID, _UME,
  696. _UL = UIF + 1 || this.length,
  697. _UDSD = $$("div").style,
  698. _UAE = [{ "style": {} }, "", {}],
  699. _UCE = ["width", "height", "top", "bottom", "left", "right"],
  700. _UBE = U.CI.getBrowser(), _UTF = _UBE.browser == "msie" && parseInt(_UBE["ver"]), _USD = { "fast": 300, "normal": 1000, "slow": 3000}[USP], _UAF = UDE["IES"]; delete UDE["IES"]; _USD = _USD || USP || 1000;
  701. for (i in UDE) { if (UDE.hasOwnProperty(i)) { if (_UDSD[(_UKW = U.M.CssTHH(i))] === undefined) { _UAE[0][i] = UDE[i]; } else { _UAE[0]["style"][_UKW] = UDE[i]; if (_UKW == "cssText") { _UAE[1] += UDE[i] + ";"; } else { _UAE[1] += (_UKW = U.M.CssTHH(i, true)) + ":" + UDE[i] + ";"; for (j = 0; j < _UCE.length; j++) { if (_UCE[j] == i || _UKW.indexOf(_UCE[j]) > -1) { _UAE[2][_UKW] = ""; break; } } } } } } //设置css3动画和js动画
  702. for (i = (UIF || 0); i < _UL; i++) { _USE = ""; for (j in _UAE[2]) { if (UDE.hasOwnProperty(j)) { j += j.indexOf("padding") > -1 ? "-width" : ""; _UE = this.css(j, null, i); _UE = isNaN(_UE.toInt()) ? ((this[j] ? this[j](i) : 0) + "px") : _UE; _USE += j + ":" + _UE + ";"; } }; (_USE) && (this.addAttrArray({ "style": { "cssText": _USE} }, i)); } //设置初始值
  703. if (_UTF && _UTF < 10 && _UAF == null) { this.addAttrArray(_UAE[0], UIF); (U.Ut.isFunction(UCB)) && (UCB()); } //Ie8不动画 (UCB) && (setTimeout(UCB, 0));
  704. else { //IE9以上动画渲染
  705. if (((!_UTF || _UTF > 9) && (_UAE[1] || _UAE[0].className))) { //css3动画加速
  706. _USE = U.M.GCssAe();
  707. _UDID = "UEM" + Guid.guidNoDash();
  708. _UE = _USE[0] + ":all " + (_USD / 1000) + "s linear;";
  709. if (UGE) {
  710. for (i in UGE) { _UE += _USE[0] + "-" + i + ":" + UGE[i] + ";"; }
  711. }
  712. _UE = "." + _UDID + " {" + _UE + "}"; //设置动画属性
  713. this.bind(_USE[1], (_UTE = U.M.apply(this, function () {
  714. this.unbind(_USE[1], _UTE);
  715. U.M.AsynCssEM.apply(this, [_UDID, _UDSD, UCB, UIF]);
  716. }))); //添加动画
  717. _UDSD = U.M.CCssStyle(_UE);
  718. U.Select.IsAnimate(this, UIF, _UDID);
  719. this.addClass(_UDID, UIF);
  720. (_UAE[0].className) && (this.addClass(_UAE[0].className, UIF), delete _UAE[0].className);
  721. this.addAttrArray(_UAE[0], UIF); delete _UAE[0].className; delete _UAE[0].style; //移除设置回调
  722. }
  723. for (i in _UAE[0]) {
  724. if (_UAE[0].hasOwnProperty(i)) { //非css动画或者IE8动画
  725. _UME = U.M.Animation({ "cb": U.M.apply(this, [[this.Auxiliary.animate, [[UIF, _UL, _UTID, _USE ? null : UCB], _UAE[0]]]]), "ti": _USD }); //动画加速
  726. U.Select.IsAnimate(this, UIF, _UME);
  727. break;
  728. }
  729. }
  730. }
  731. }
  732. return this;
  733. },
  734. stop: function (UIE) { //停止动画回播
  735. var _USE, i = UIE || 0,
  736. _UL = UIE == null ? this.length : UIE + 1;
  737. for (; i < _UL; i++) {
  738. if ((_USE = this[i].__Animate__)) {
  739. if (U.Ut.isString(_USE[2])) {
  740. this[i].className = _USE[2];
  741. this.addClass(_USE[1], i);
  742. this.css("cssText", _USE[0], i);
  743. }
  744. else {
  745. _USE[2].stop();
  746. }
  747. }
  748. }
  749. },
  750. opacity: function (UVE, UIE) { //设置透明度 全兼容
  751. if (this.length) {
  752. var i, _USE = {}, _UDE = { opacity: 1, "-webkit-opacity": 1, "-moz-opacity": 1, "-khtml-opacity": "", filter: "" };
  753. for (i in _UDE) { if (i in this[0].style) { _USE[i] = (_UDE[i] = i == "filter" ? "alpha(opacity=" + (UVE * 100) + ")" : UVE); } }
  754. }
  755. },
  756. fadeIn: function (USP, UCB, UIE) {//动画淡出,,
  757. var i, _UKE, _USE = {}, _UDOD = $$("div").style, _UDE = ["opacity", "-webkit-opacity", "-moz-opacity", "-khtml-opacity", "filter"]; UCB = U.M.apply(this, [[this.addAttrArray, [{ "style": (_UKE = { "display": "none" }) }, UIE]], [UCB]]); //设置回调
  758. for (i = 0; i < _UDE.length; i++) { if (_UDE[i] in _UDOD) { _UKE[_UDE[i]] = ""; _USE[_UDE[i]] = _UDE[i] == "filter" ? "alpha(opacity=0)" : "0"; break; } }; return this.animate(_USE, USP || "fast", UCB, UIE); //查看
  759. },
  760. fadeOut: function (USP, UCB, UIE) {//动画淡入
  761. var i, _USE = {}, _UDOD = $$("div").style, _UDE = ["opacity", "-webkit-opacity", "-moz-opacity", "-khtml-opacity", "filter"]; for (i = 0; i < _UDE.length; i++) { if (_UDE[i] in _UDOD) { _USE[_UDE[i]] = _UDE[i] == "filter" ? "alpha(opacity=100)" : "1"; _UDE = _UDE[i]; break; } };
  762. _USE[_UDE] = _UDE == "filter" ? "alpha(opacity=100)" : "1"; this.addAttrArray({ "style": { "display": "block"} }); return this.animate(_USE, USP || "fast", UCB, UIE); //查看 _USE
  763. },
  764. slideUp: function (USP, UCB, UIE) { //滑动消失
  765. this.slideToggle(USP, UCB, UIE);
  766. },
  767. slideDown: function (USP, UCB, UIE) { //滑动出现
  768. this.slideToggle(USP, UCB, UIE, false);
  769. },
  770. transition: function (UDE, USP, UCB, UIE) { //过度动画使用
  771. var i, j, _UDW, _UTP, _UFN, _UAE = {}, _UHE = {}, _UME = [["scale", ""], ["translate,perspective", "px"], ["skew,rotate", "deg"]], _UCE = U.M.GCssAe(); //scale
  772. if (_UCE) {//Html5兼容
  773. _UTP = _UCE[2] + "transform"; _UAE[_UTP] = "";
  774. _UFN: for (i in UDE) {
  775. for (j = 0; j < _UME.length; j++) { if (_UME[j][0].split(",").indexOf(i) > -1) { _UDW = _UME[j][1]; _UAE[_UTP] += i + "(" + UDE[i] + _UDW + ") "; continue _UFN; } }
  776. _UHE[_UTP + "-" + i] = UDE[i];
  777. }
  778. this.addAttrArray({ "style": _UHE }).animate(_UAE, USP, UCB, UIE); //执行动画
  779. }
  780. },
  781. slideToggle: function (UST, UCB, UIE, UTF) {//滑动效果
  782. var j, _UTP, _UDE, _USC, i = UIE || 0, _UL = UIE + 1 || this.length, _USE = { height: "", marginBottom: "", marginTop: "", paddingBottom: "", paddingTop: "", display: "block" }, _UKE = _USE; //变化值
  783. for (; i < _UL; i++) { //设置动画
  784. _USC = this.css("cssText"); _$(_USE).Each(U.M.apply(this, function (UAE, UIE) { if (UIE != "display") { if (UIE == "height") { _USE[UIE] = this.height() + "px"; } else { _USE[UIE] = this.css(UIE, null, i); } } })); //原初始值
  785. _UDE = [_USE, { "cssText": "height:0px;margin-top:0;margin-bottom:0;padding-top:0;padding-bottom:0;display:block;overflow:hidden"}]; //初始化隐藏动画
  786. if ((_UTP = (UTF === false || (UTF == null && this.css("display", "") == "none")))) { _UDE.reverse(); } //设置显示动画
  787. this.addAttrArray({ style: _UDE[0] }, i).animate(_UDE[1], UST, U.M.apply(this, [[this.Auxiliary.slideToggle, [_USC + ";display:" + (_UTP ? "block" : "none"), i, _UL, UCB]]]), i); //设置出现和取消
  788. }
  789. },
  790. hide: function (UIE) { //隐藏元素
  791. this.css({ "display": "none" }, UIE);
  792. },
  793. show: function (UIE) { //显示元素
  794. this.css({ "display": "block" }, UIE);
  795. },
  796. ready: function (UCB) { //添加doc ready函数
  797. var _UTF = document.attachEvent ? "readystatechange" : "DOMContentLoaded", _UCB = [];
  798. _UCB[0] = U.M.apply(document, [[U.M.ReEvent, [_UTF, document, _UCB]], [UCB]]); U.M.AddEvent(_UTF, document, _UCB[0]);
  799. },
  800. load: function (UCB) { //load加载页面
  801. (!this.length) && (this.osadd(window)); var _UFN = function () { this.unbind("load", _UFN, 0); UCB(); };
  802. this.bind("load", _UFN, 0);
  803. },
  804. contents: function () { },
  805. mouseenter: function (UCB, UIE) { //enter事件
  806. this.addAttrArray({ "onmouseover": [[U.M.mouseLE, [UCB]]] }, UIE);
  807. return this;
  808. },
  809. mouseleave: function (UCB, UIE) { //leave事件
  810. this.addAttrArray({ "onmouseout": [[U.M.mouseLE, [UCB]]] }, UIE);
  811. return this;
  812. },
  813. resize: function (UCB, UIE) { //resize事件
  814. this.bind("resize", U.M.resize(UCB), UIE);
  815. },
  816. resizestart: function (UCB, UIE) { //resoze开始
  817. this.resize({ s: UCB }, UIE);
  818. },
  819. resizeend: function (UCB, UIE) { //设置sizeend
  820. this.resize({ e: UCB }, UIE);
  821. },
  822. message: function () { //message 事件绑定
  823. },
  824. //此bind和系统bind有什么区别?系统bind可以实现:var foo = { x: 3} var bar = function(){ console.log(this.x);} bar(); // undefined var boundFunc = bar.bind(foo);boundFunc(); // 3 但系统bind不支持ie8以下。
  825. bind: function (UDE, UAE, UIE) { //事件绑定
  826. if (UDE) {
  827. var j, _UTP;
  828. var _UTF = (typeof UDE == "string");
  829. var _UIF = (_UTF ? UIE : UAE), i = _UIF || 0, _UL = (_UIF + 1) || this.length;
  830. (_UTF) && (_UTP = UDE, (UDE = {})[_UTP] = UAE);
  831. for (; i < _UL; i++) {
  832. for (j in UDE) {
  833. if (UDE.hasOwnProperty(j)) {
  834. new this.cacheE(this[i]).addevent(j, UDE[j]);
  835. U.M.AddEvent(j, this[i], UDE[j]);
  836. }
  837. }
  838. }
  839. return this;
  840. }
  841. },
  842. unbind: function (UDE, UAE, UIE) { //事件绑定取消
  843. var _UTF = (typeof UDE == "string"), _UIF = (_UTF ? UIE : UAE), i = _UIF || 0, _UL = (_UIF + 1) || this.length;
  844. for (; i < _UL; i++) { new this.cacheE(this[i]).removeEvent(UDE, UAE); } return this; //移除事件
  845. },
  846. mousedown: function (UCB, UTF, UIE) { //左右事件
  847. (UCB) && (this.bind("mousedown", function () { var _UTF = event.button; _UTF = _UTF == 2 || _UTF == 3; if (!UTF || (UTF == "right" && _UTF) || (UTF == "left" && !_UTF)) { UCB(); } }, UIE));
  848. return this;
  849. },
  850. on: function (UE, US, UCB, UIE) { //事件绑定
  851. var _UDE = this; (US) && (_UDE = this.find(US, UIE)); _UDE.bind(UE, UCB, UIE);
  852. },
  853. off: function (UE, US, UCB, UIE) { //取消事件绑定
  854. var _UDE = this; (US) && (_UDE = this.find(US, UIE)); _UDE.unbind(UE, UCB, UIE);
  855. },
  856. scrollTo: function (UT, UTI) {//移动变化
  857. var _UDOD = this[0]; (_UDOD) && (U.M.SCT(UT, _UDOD, UTI));
  858. }
  859. });
  860. //#region 事件监听区域
  861. U.Select.fn.extend({
  862. cache: [], //保存对象使用选择器保留值
  863. cacheE: function (UDOD) {//保存对象的值
  864. var i, _UDE = U.Select.fn.cache;
  865. for (i = 0; i < _UDE.length; i++) { if (_UDE[i].UDOD === UDOD) { return _UDE[i]; } } //获取制定的元素绑定
  866. this.events = {}; this.UDOD = UDOD; this.id = Guid.guidNoDash(); _UDE.push(this); return this; //添加事件监听对象
  867. }
  868. });
  869. U.Select.fn.cacheE.prototype = {
  870. removeEvent: function (UDE, UAE) { //删除event
  871. var i, j, _UME, _UDOD = this.UDOD, _UCE = this.events; (typeof UDE == "string") && (_UME = UDE, (UDE = {})[_UME] = UAE); UDE = UDE || _UCE;
  872. for (i in UDE) { if (UDE.hasOwnProperty(i) && (_UME = _UCE[i])) { for (j = 0; j < _UME.length; j++) { if (_UME[j] == UDE[i] || _UCE == UDE || !UDE[i]) { U.M.ReEvent(i, _UDOD, _UME.splice(j, 1)[0]); j--; } } } } //清除事件
  873. },
  874. addevent: function (UDE, UAE) { //添加event监听
  875. var i, _UCE = this.events;
  876. (!_UCE[UDE]) && (_UCE[UDE] = []); _UCE[UDE].push(UAE);
  877. }
  878. }
  879. //#endregion
  880. //#region 辅助函数
  881. U.Select.fn.extend({
  882. selecte: {
  883. "only-child": function (UDE) { //获取作为单一孩子节点元素
  884. return Array.prototype.slice.call(U.Select(UDE).only());
  885. },
  886. "nth-child": function (UDE, UTP) { //获取第几个元素
  887. var i, j, _UCE, _UN = UTP.match(this.match.number)[1], _UTF = _UN.indexOf("n") > -1, _UAE = []; _UN = _UN.toInt();
  888. if (!_UTF || _UN) {
  889. for (i = 0; i < UDE.length; i++) {
  890. _UCE = U.Select(UDE[i]).parentg().Child();
  891. if (_UTF) { for (j = _UN; j <= _UCE.length; j += _UN) { if (UDE[i] == _UCE[j - 1]) { _UAE.push(UDE[i]); (_UN == 1) && (j++); break; } } } //(xn)查找
  892. else { (_UCE[_UN - 1] == UDE[i]) && (_UAE.push(UDE[i])); } //直接获取第几个
  893. }
  894. }
  895. return _UAE;
  896. },
  897. "first-child": function (UDE) { //获取开头元素
  898. var i, _UAE = [];
  899. for (i = 0; i < UDE.length; i++) { (!U.Select(UDE[i]).prev().lenght) && (_UAE.push(UDE[i])); }
  900. return _UAE;
  901. },
  902. "last-child": function (UDE) { //获取末尾元素
  903. var i, _UAE = [];
  904. for (i = 0; i < UDE.length; i++) { (!U.Select(UDE[i]).next().length) && (_UAE.push(UDE[i])); }
  905. return _UAE;
  906. },
  907. first: function (UDE) { //获取第一个匹配的元素
  908. return UDE.length ? UDE[0] : UDE;
  909. },
  910. last: function (UDE) { //获取最后一个匹配元素
  911. return UDE.length ? UDE[UDE.length - 1] : UDE;
  912. },
  913. nth: function (UDE, UTP) { //获取匹配的第几个元素
  914. var i, _UAE = [], _UN = UTP.match(this.match.number)[1], _UTF = _UN.indexOf("n") > -1; _UN = _UN.toInt();
  915. if (_UTF || _UN) {
  916. if (_UTF) { for (i = _UN; i <= UDE.length; i += _UN) { _UAE.push(UDE[i - 1]); } }
  917. else { (UDE[_UN]) && (_UAE.push(UDE[_UN])); }
  918. }
  919. return _UAE;
  920. },
  921. getevenodd: function (UDE, UTP) { //获取奇数和偶数集
  922. var i, j, _UDPD, _UCE, _UTF, _UPE = [], _UAE = [];
  923. for (i = 0; i < UDE.length; i++) {
  924. _UCE = null; _UDPD = UDE[i].parentNode;
  925. for (j = 0; j < _UPE.length; j++) { if (_UPE[j][0] == _UDPD) { _UCE = _UPE[j]; _UCE[1].push(UDE[i]); } }
  926. (!_UCE) && (_UPE.push((_UCE = [_UDPD, [UDE[i]]]))); _UTF = (_UCE[1].length - 1) % 2; ((UTP == "even" && !_UTF) || (UTP == "odd" && _UTF)) && (_UAE.push(UDE[i]));
  927. }
  928. return _UAE;
  929. },
  930. even: function (UDE) { //获取偶数集
  931. return this.selecte.getevenodd(UDE, "even");
  932. },
  933. odd: function (UDE) { //获取奇数集
  934. return this.selecte.getevenodd(UDE, "odd");
  935. },
  936. eq: function (UDE, UTP) { //获取制定的位置列
  937. return UDE[UTP.match(this.match.number)[1].toInt()];
  938. },
  939. gt: function (UDE, UTP) { //索引大于的元素
  940. U.Select(UDE).gt(UTP.match(this.match.number)[1].toInt());
  941. },
  942. lt: function (UDE, UTP) {//索引小于的元素
  943. U.Select(UDE).lt(UTP.match(this.match.number)[1].toInt());
  944. },
  945. "first-of-type": function () { },
  946. "last-of-type": function () { },
  947. "only-of-type": function () { },
  948. "nth-last-child": function () { },
  949. "nth-of-type": function () { },
  950. "nth-last-of-type": function () { }
  951. },
  952. Auxiliary: {
  953. an: function (UDE) { //缓存对象设置
  954. },
  955. slideToggle: function (UDE, UIE, UL, UCB) { //下拉动画回调
  956. this[UIE].style.cssText = UDE; (UIE == UL - 1 && UCB) && (UCB());
  957. },
  958. animate: function (UDE, UAE, UIE) {//js动画调用使用区域
  959. var _UTF, _USE, i = UDE[0] || 0,
  960. _UL = UDE[1] || i + 1,
  961. _UTID = UDE[2],
  962. _UCB = UDE[3];
  963. for (; i < _UL; i++) {
  964. if (UIE) { _USE = U.M.JsEM(this[i], UAE, UIE); }
  965. else { _USE = UAE; _UTF = true; } this.addAttrArray(_USE, i);
  966. }
  967. if (_UTF) {
  968. (_UTID == null && _UCB) && (_UCB()); return true;
  969. }
  970. },
  971. selectel: function (UTF, UDE) { //条件选择元素
  972. var _UFT, i = 0, _UL = UDE.length, _UCE = [], _UAE = U.Select(), _UIE = UTF.match(U.MS.RNum);
  973. if (_UIE) { _UIE = _UIE[0].toInt(); switch (UTF.replace(_UIE + "", "")) { case ">": i = _UIE + 1; break; case "<": _UL = _UIE; break; default: i = _UIE; _UL = i + 1; break; } }
  974. for (; i < _UL; i++) { switch (UTF) { case "even": _UFT = !(i % 2); break; case "odd": _UFT = (i % 2) > 0; break; default: _UFT = true; break; } (_UFT) && (_UCE.push(UDE[i])); _UFT = false; }
  975. return _UAE.osadd(_UCE);
  976. }
  977. }
  978. });
  979. //简单的复杂的方法统一
  980. $.SetMethod.prototype = U.Select.prototype;
  981. //#endregion
  982. //#endregion