U.PH.js 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //#region 手机应用处理使用
  2. Namespace.register("U.PH");
  3. //Touch事件执行
  4. if ("ontouchstart" in document) {
  5. (U.M.OTS) && (U.M.ReEvent("touchstart", document, U.M.OTS, true));
  6. //touchstart
  7. U.M.AddEvent("touchstart", document, U.M.OTS = function () {
  8. var i, _UDOD = event.srcElement; U.M.UTX = null; U.M.StopBubble();
  9. U.M.ReEvent("touchstart", document, U.M.OTS, true); //移除start事件
  10. U.M.TouchE(_UDOD, "touchstart"); U.M.AddEvent("touchstart", document, U.M.OTS, true); //添加事件取消冒泡
  11. U.M.AddEvent("touchmove", document, U.M.OTSM); //添加move事件监听
  12. U.M.AddEvent("touchend", document, U.M.OTSE, true); //end事件等待
  13. }, true);
  14. U.M.OTSM = function () { //移动监视
  15. U.M.UTX = true; U.M.ReEvent("touchmove", document, U.M.OTSM); U.M.TouchE(event.srcElement, "touchmove"); U.M.StopBubble();
  16. }
  17. //执行toucastart
  18. U.M.OTSE = function (UDOD) {
  19. U.M.ReEvent("touchend", document, U.M.OTSE, true); U.M.StopBubble(); //移除事件
  20. if (!U.M.UTX) { U.M.TouchE(event.srcElement, "touchend"); } //事件执行
  21. }
  22. }
  23. /**
  24. * 对象数组,需要批量给对象添加属性。
  25. * @param {array} U.CD的自定义变量或者Array,Object等系统变量
  26. * @param {object} 属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
  27. * @param {object} 属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
  28. */
  29. U.PH.up = function (UDOD, UCB, UDE) {
  30. new _UDE.init(UDOD, UCB, UDE);
  31. }
  32. /**
  33. * 对象数组,需要批量给对象添加属性。
  34. * @param {array} U.CD的自定义变量或者Array,Object等系统变量
  35. * @param {object} 属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
  36. * @param {object} 属性的集合,形如:{ "domain": "1473.cn", "SystemId": 0}
  37. */
  38. U.PH.up.init = function (UDOD, UCB, UDE) {
  39. U.Ut.AddObj(this, { obj: UDOD,
  40. cb: UCB,
  41. s: U.M.apply(this, this.start),
  42. m: U.M.apply(this, this.move),
  43. e: U.M.apply(this, this.end)
  44. });
  45. (UDE) && (U.Ut.AddObj(this, UDE)); //生成变量
  46. U.M.AddEvent("touchstart", UDOD, this.s);
  47. U.M.AddEvent("touchmove", UDOD, this.m); U.M.AddEvent("touchend", UDOD, this.e); //事件添加
  48. }
  49. U.PH.up.init.prototype = {
  50. start: function () { //启动使用
  51. (!this.obj.scrollTop) && (this.tf = true, this.entf = false, this.t = U.M.GetMousep());
  52. },
  53. move: function () { //使用启动
  54. U.M.StopBubble();
  55. if (this.tf) {
  56. var _UDE = U.M.GetMousep(),
  57. _UTY = _UDE.Y - this.t.Y;
  58. if (_UTY > 0) {
  59. this.entf = _UTY;
  60. (U.Ut.isFunction(this.mcb)) && (this.mcb(_UTY));
  61. }
  62. else { this.entf = false; }
  63. }
  64. },
  65. end: function () { //结束
  66. if (this.tf && this.entf && U.Ut.isFunction(this.cb)) { this.cb(this.entf); } this.tf = this.entf = this.t = null;
  67. if (this.sf) { U.M.ReEvent("touchstart", this.obj, this.s); U.M.ReEvent("touchmove", this.obj, this.m); U.M.ReEvent("touchend", this.obj, this.e); } //结束释放
  68. }
  69. }
  70. //#endregion