|
@ -9,7 +9,7 @@
|
9
|
9
|
*/
|
10
|
10
|
|
11
|
11
|
var ipuUI = {
|
12
|
|
version: '0.2.2'
|
|
12
|
version: '0.2.2.z' // 针对ios PopPicker, DtPicker组件优化
|
13
|
13
|
};
|
14
|
14
|
|
15
|
15
|
// tap点击效果处理,只针对jquery上面的click事件,依赖touch事件
|
|
@ -93,10 +93,10 @@
|
93
|
93
|
|
94
|
94
|
//根据不同浏览器获取不同原生事件event
|
95
|
95
|
var hasTouch = "ontouchstart" in window,
|
96
|
|
START_EVENT = hasTouch ? 'touchstart' : 'mousedown',
|
97
|
|
MOVE_EVENT = hasTouch ? 'touchmove' : 'mousemove',
|
98
|
|
END_EVENT = hasTouch ? 'touchend' : 'mouseup',
|
99
|
|
CANCEL_EVENT = hasTouch ? 'touchcancel' : '';
|
|
96
|
START_EVENT = hasTouch ? 'touchstart' : 'mousedown',
|
|
97
|
MOVE_EVENT = hasTouch ? 'touchmove' : 'mousemove',
|
|
98
|
END_EVENT = hasTouch ? 'touchend' : 'mouseup',
|
|
99
|
CANCEL_EVENT = hasTouch ? 'touchcancel' : '';
|
100
|
100
|
|
101
|
101
|
$(function () {
|
102
|
102
|
var startXY, tapEl, timeOutID;
|
|
@ -305,7 +305,7 @@
|
305
|
305
|
*/
|
306
|
306
|
show: function (index, time) {
|
307
|
307
|
this._pause();
|
308
|
|
this.iscroll.scrollToPage(index, 0, time);
|
|
308
|
this.scrollToPage(index, 0, time);
|
309
|
309
|
},
|
310
|
310
|
/**
|
311
|
311
|
* 开始自动播放
|
|
@ -500,43 +500,43 @@
|
500
|
500
|
*/
|
501
|
501
|
DtPicker.prototype.defaultOption = {
|
502
|
502
|
template: ''
|
503
|
|
+ '<div class="ipu-poppicker ipu-dtpicker">'
|
504
|
|
+ ' <div class="ipu-poppicker-header">'
|
505
|
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-cancel">取消</button>'
|
506
|
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-ok">确定</button>'
|
507
|
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-clear">清除</button>'
|
508
|
|
+ ' </div>'
|
509
|
|
+ ' <div class="ipu-poppicker-title">'
|
510
|
|
+ ' <label class="ipu-dtpicker-y"></label>'
|
511
|
|
+ ' <label class="ipu-dtpicker-m"></label>'
|
512
|
|
+ ' <label class="ipu-dtpicker-d"></label>'
|
513
|
|
+ ' <label class="ipu-dtpicker-h"></label>'
|
514
|
|
+ ' <label class="ipu-dtpicker-mi"></label>'
|
515
|
|
+ ' </div>'
|
516
|
|
+ ' <div>'
|
517
|
|
+ ' <div class="ipu-poppicker-body">'
|
518
|
|
+ ' <div class="ipu-picker" data-id="picker-y">'
|
519
|
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
520
|
|
+ ' <ul></ul>'
|
521
|
|
+ ' </div>'
|
522
|
|
+ ' <div class="ipu-picker" data-id="picker-m">'
|
523
|
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
524
|
|
+ ' <ul></ul>'
|
525
|
|
+ ' </div>'
|
526
|
|
+ ' <div class="ipu-picker" data-id="picker-d">'
|
527
|
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
528
|
|
+ ' <ul></ul>'
|
529
|
|
+ ' </div>'
|
530
|
|
+ ' <div class="ipu-picker" data-id="picker-h">'
|
531
|
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
532
|
|
+ ' <ul></ul>'
|
533
|
|
+ ' </div>'
|
534
|
|
+ ' <div class="ipu-picker" data-id="picker-mi">'
|
535
|
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
536
|
|
+ ' <ul></ul>'
|
537
|
|
+ ' </div>'
|
538
|
|
+ ' </div>'
|
539
|
|
+ '</div>',
|
|
503
|
+ '<div class="ipu-poppicker ipu-dtpicker">'
|
|
504
|
+ ' <div class="ipu-poppicker-header">'
|
|
505
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-cancel">取消</button>'
|
|
506
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-ok">确定</button>'
|
|
507
|
+ ' <button class="ipu-btn ipu-btn-s ipu-poppicker-btn-clear">清除</button>'
|
|
508
|
+ ' </div>'
|
|
509
|
+ ' <div class="ipu-poppicker-title">'
|
|
510
|
+ ' <label class="ipu-dtpicker-y"></label>'
|
|
511
|
+ ' <label class="ipu-dtpicker-m"></label>'
|
|
512
|
+ ' <label class="ipu-dtpicker-d"></label>'
|
|
513
|
+ ' <label class="ipu-dtpicker-h"></label>'
|
|
514
|
+ ' <label class="ipu-dtpicker-mi"></label>'
|
|
515
|
+ ' </div>'
|
|
516
|
+ ' <div>'
|
|
517
|
+ ' <div class="ipu-poppicker-body">'
|
|
518
|
+ ' <div class="ipu-picker" data-id="picker-y">'
|
|
519
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
|
520
|
+ ' <ul></ul>'
|
|
521
|
+ ' </div>'
|
|
522
|
+ ' <div class="ipu-picker" data-id="picker-m">'
|
|
523
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
|
524
|
+ ' <ul></ul>'
|
|
525
|
+ ' </div>'
|
|
526
|
+ ' <div class="ipu-picker" data-id="picker-d">'
|
|
527
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
|
528
|
+ ' <ul></ul>'
|
|
529
|
+ ' </div>'
|
|
530
|
+ ' <div class="ipu-picker" data-id="picker-h">'
|
|
531
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
|
532
|
+ ' <ul></ul>'
|
|
533
|
+ ' </div>'
|
|
534
|
+ ' <div class="ipu-picker" data-id="picker-mi">'
|
|
535
|
+ ' <div class="ipu-picker-selectbox"></div>'
|
|
536
|
+ ' <ul></ul>'
|
|
537
|
+ ' </div>'
|
|
538
|
+ ' </div>'
|
|
539
|
+ '</div>',
|
540
|
540
|
buttons: ['取消', '确认', '清除'],
|
541
|
541
|
labels: ['年', '月', '日', '时', '分'],
|
542
|
542
|
type: 'datetime',
|
|
@ -689,7 +689,7 @@
|
689
|
689
|
value = '00:00';
|
690
|
690
|
} else {
|
691
|
691
|
value = defaultPickerDate.getFullYear() + '-' + (defaultPickerDate.getMonth() + 1) + '-' + defaultPickerDate.getDate() + ' '
|
692
|
|
+ defaultPickerDate.getHours() + ':' + defaultPickerDate.getMinutes();
|
|
692
|
+ defaultPickerDate.getHours() + ':' + defaultPickerDate.getMinutes();
|
693
|
693
|
}
|
694
|
694
|
}
|
695
|
695
|
var parsedValue = self._parseSetValue(value);
|
|
@ -961,7 +961,7 @@
|
961
|
961
|
value = value.getHours() + ":" + value.getMinutes();
|
962
|
962
|
} else {
|
963
|
963
|
value = value.getFullYear() + '-' + (value.getMonth() + 1) + '-' + value.getDate() + ' '
|
964
|
|
+ value.getHours() + ":" + value.getMinutes();
|
|
964
|
+ value.getHours() + ":" + value.getMinutes();
|
965
|
965
|
}
|
966
|
966
|
}
|
967
|
967
|
|
|
@ -1109,6 +1109,7 @@
|
1109
|
1109
|
}
|
1110
|
1110
|
this.mask.show();
|
1111
|
1111
|
this.setSelectedValue(this.value);
|
|
1112
|
this.holder.show().width();
|
1112
|
1113
|
this.holder.addClass("ipu-current");
|
1113
|
1114
|
};
|
1114
|
1115
|
|
|
@ -1131,7 +1132,10 @@
|
1131
|
1132
|
*/
|
1132
|
1133
|
DtPicker.prototype.hide = function () {
|
1133
|
1134
|
this.mask.close();
|
1134
|
|
this.holder.removeClass("ipu-current");
|
|
1135
|
var _this = this;
|
|
1136
|
this.holder.removeClass("ipu-current").transitionEnd(function () {
|
|
1137
|
_this.holder.hide();
|
|
1138
|
});
|
1135
|
1139
|
};
|
1136
|
1140
|
|
1137
|
1141
|
// 应该移除callback参数,提取出业成一个工具方法
|
|
@ -1252,6 +1256,13 @@
|
1252
|
1256
|
clickBack: null
|
1253
|
1257
|
},
|
1254
|
1258
|
_init: function () {
|
|
1259
|
var oldComponent = $(this.el).data('ipu-hammer-carousel');
|
|
1260
|
if (oldComponent) {
|
|
1261
|
oldComponent.destroy();
|
|
1262
|
}
|
|
1263
|
|
|
1264
|
$(this.el).data('ipu-hammer-carousel', this);
|
|
1265
|
|
1255
|
1266
|
this.wrapper = $(">.ipu-carousel-wrapper", this.el);
|
1256
|
1267
|
this.carouselItems = $(">li", this.wrapper);
|
1257
|
1268
|
this.itemSize = this.carouselItems.size(); // 子项数量
|
|
@ -1289,9 +1300,11 @@
|
1289
|
1300
|
this.hammer.on("panstart panmove panend pancancel", Hammer.bindFn(this._onPan, this));
|
1290
|
1301
|
|
1291
|
1302
|
this._sizeCount();
|
1292
|
|
$(window).resize(function () { // 在窗口尺寸变化时,更新尺寸信息
|
|
1303
|
this._sizeRefresh = function () {
|
1293
|
1304
|
that.refresh();
|
1294
|
|
});
|
|
1305
|
};
|
|
1306
|
|
|
1307
|
$(window).bind("resize", this._sizeRefresh); // 在窗口尺寸变化时,更新尺寸信息
|
1295
|
1308
|
|
1296
|
1309
|
if (this.option.index == null) {
|
1297
|
1310
|
var activeIndex = this.carouselItems.filter(".ipu-current").index();
|
|
@ -1492,6 +1505,19 @@
|
1492
|
1505
|
} else if (ev.type == 'panmove') {
|
1493
|
1506
|
this._move(delta);
|
1494
|
1507
|
}
|
|
1508
|
},
|
|
1509
|
destroy: function () { // 增加销毁处理
|
|
1510
|
$(this.wrapper).css("transform", "translate3d(0, 0, 0)");
|
|
1511
|
this.hammer.destroy();
|
|
1512
|
if (this.indicator) {
|
|
1513
|
this.indicator.remove();
|
|
1514
|
}
|
|
1515
|
$(window).unbind("resize", this._sizeRefresh); // 解绑事件监听
|
|
1516
|
|
|
1517
|
this.option.autoPlay = false;
|
|
1518
|
if (this.timeoutId) {
|
|
1519
|
clearTimeout(this.timeoutId);
|
|
1520
|
}
|
1495
|
1521
|
}
|
1496
|
1522
|
});
|
1497
|
1523
|
|
|
@ -1558,7 +1584,7 @@
|
1558
|
1584
|
|
1559
|
1585
|
function __dealCssEvent(eventNameArr, callback) {
|
1560
|
1586
|
var events = eventNameArr,
|
1561
|
|
i, dom = this;// jshint ignore:line
|
|
1587
|
i, dom = this;// jshint ignore:line
|
1562
|
1588
|
|
1563
|
1589
|
function fireCallBack(e) {
|
1564
|
1590
|
/*jshint validthis:true */
|
|
@ -1869,7 +1895,7 @@
|
1869
|
1895
|
modal.openModal = function (modalObj, cb) {
|
1870
|
1896
|
modalObj = $(modalObj);
|
1871
|
1897
|
var isModal = modalObj.hasClass('ipu-modal'),
|
1872
|
|
isNotToast = !modalObj.hasClass('ipu-toast');
|
|
1898
|
isNotToast = !modalObj.hasClass('ipu-toast');
|
1873
|
1899
|
isNotToast = false; // 强制打开新窗口
|
1874
|
1900
|
|
1875
|
1901
|
if ($('.ipu-modal.ipu-modal-in:not(.ipu-modal-out)').length && defaults.modalStack && isModal && isNotToast) {
|
|
@ -1939,22 +1965,18 @@
|
1939
|
1965
|
if (typeof modalObj !== 'undefined' && modalObj.length === 0) {
|
1940
|
1966
|
return;
|
1941
|
1967
|
}
|
1942
|
|
if (modalObj == null) {
|
1943
|
|
return;
|
1944
|
|
}
|
1945
|
1968
|
var isModal = modalObj.hasClass('ipu-modal'),
|
1946
|
|
isPopup = modalObj.hasClass('ipu-popup'),
|
1947
|
|
isToast = modalObj.hasClass('ipu-toast'),
|
1948
|
|
isLoginScreen = modalObj.hasClass('ipu-login-screen'),
|
1949
|
|
isPickerModal = modalObj.hasClass('ipu-picker-modal'),
|
1950
|
|
removeOnClose = modalObj.hasClass('ipu-remove-on-close'),
|
1951
|
|
overlay = isPopup ? $('.ipu-popup-overlay') : $('.ipu-modal-overlay');
|
|
1969
|
isPopup = modalObj.hasClass('ipu-popup'),
|
|
1970
|
isToast = modalObj.hasClass('ipu-toast'),
|
|
1971
|
isLoginScreen = modalObj.hasClass('ipu-login-screen'),
|
|
1972
|
isPickerModal = modalObj.hasClass('ipu-picker-modal'),
|
|
1973
|
removeOnClose = modalObj.hasClass('ipu-remove-on-close'),
|
|
1974
|
overlay = isPopup ? $('.ipu-popup-overlay') : $('.ipu-modal-overlay');
|
1952
|
1975
|
if (isPopup) {
|
1953
|
1976
|
if (modalObj.length === $('.ipu-popup.ipu-modal-in').length) {
|
1954
|
1977
|
overlay.removeClass('ipu-modal-overlay-visible');
|
1955
|
1978
|
}
|
1956
|
|
}
|
1957
|
|
else if (!(isPickerModal || isToast)) {
|
|
1979
|
} else if (!(isPickerModal || isToast)) {
|
1958
|
1980
|
overlay.removeClass('ipu-modal-overlay-visible');
|
1959
|
1981
|
}
|
1960
|
1982
|
modalObj.trigger('close');
|
|
@ -1977,8 +1999,7 @@
|
1977
|
1999
|
if (removeOnClose && modalObj.length > 0) {
|
1978
|
2000
|
modalObj.remove();
|
1979
|
2001
|
}
|
1980
|
|
}
|
1981
|
|
else {
|
|
2002
|
} else {
|
1982
|
2003
|
modalObj.remove();
|
1983
|
2004
|
}
|
1984
|
2005
|
});
|
|
@ -2190,7 +2211,7 @@
|
2190
|
2211
|
(function (ipuUI, $) {
|
2191
|
2212
|
function __dealCssEvent(eventNameArr, callback) {
|
2192
|
2213
|
var events = eventNameArr,
|
2193
|
|
i, dom = this;// jshint ignore:line
|
|
2214
|
i, dom = this;// jshint ignore:line
|
2194
|
2215
|
|
2195
|
2216
|
function fireCallBack(e) {
|
2196
|
2217
|
if (e.target !== this) return;
|
|
@ -2900,10 +2921,10 @@
|
2900
|
2921
|
*
|
2901
|
2922
|
* // layer=2时的数据结构,有额外data属性存放下一层级数据
|
2902
|
2923
|
* var data-1 = [{
|
2903
|
|
* text:'湖南',value:'HN', data:[{text:'长沙', value:'CS'}, {text:'湘谭', value:'XT'}]
|
2904
|
|
* },{
|
2905
|
|
* text:'湖北',value:'HB', data:[{text:'武汉', value:'WH'}, {text:'天门', value:'TM'}]
|
2906
|
|
* }
|
|
2924
|
* text:'湖南',value:'HN', data:[{text:'长沙', value:'CS'}, {text:'湘谭', value:'XT'}]
|
|
2925
|
* },{
|
|
2926
|
* text:'湖北',value:'HB', data:[{text:'武汉', value:'WH'}, {text:'天门', value:'TM'}]
|
|
2927
|
* }
|
2907
|
2928
|
* ];
|
2908
|
2929
|
|
2909
|
2930
|
*
|
|
@ -2974,17 +2995,17 @@
|
2974
|
2995
|
*/
|
2975
|
2996
|
PopPicker.prototype.defaultOption = {
|
2976
|
2997
|
template: '<div class="ipu-poppicker">'
|
2977
|
|
+ '<div class="ipu-poppicker-header">'
|
2978
|
|
+ '<button class="ipu-btn ipu-btn-s ipu-poppicker-btn-cancel">取消</button>'
|
2979
|
|
+ '<button class="ipu-btn ipu-btn-s ipu-poppicker-btn-ok">确定</button>'
|
2980
|
|
+ '</div>'
|
2981
|
|
+ '<div class="ipu-poppicker-body">'
|
2982
|
|
+ '</div>'
|
2983
|
|
+ '</div>',
|
|
2998
|
+ '<div class="ipu-poppicker-header">'
|
|
2999
|
+ '<button class="ipu-btn ipu-btn-s ipu-poppicker-btn-cancel">取消</button>'
|
|
3000
|
+ '<button class="ipu-btn ipu-btn-s ipu-poppicker-btn-ok">确定</button>'
|
|
3001
|
+ '</div>'
|
|
3002
|
+ '<div class="ipu-poppicker-body">'
|
|
3003
|
+ '</div>'
|
|
3004
|
+ '</div>',
|
2984
|
3005
|
pickerTemplate: '<div class="ipu-picker">'
|
2985
|
|
+ '<div class="ipu-picker-selectbox"></div>'
|
2986
|
|
+ '<ul></ul>'
|
2987
|
|
+ '</div>',
|
|
3006
|
+ '<div class="ipu-picker-selectbox"></div>'
|
|
3007
|
+ '<ul></ul>'
|
|
3008
|
+ '</div>',
|
2988
|
3009
|
data: [], // 数据
|
2989
|
3010
|
layer: 1, // 数据层级
|
2990
|
3011
|
btns: ['取消', '确认'],
|
|
@ -3014,6 +3035,7 @@
|
3014
|
3035
|
this.option.callBack = callBack;
|
3015
|
3036
|
}
|
3016
|
3037
|
this.mask.show();
|
|
3038
|
this.holder.show().width();
|
3017
|
3039
|
this.holder.addClass("ipu-current");
|
3018
|
3040
|
};
|
3019
|
3041
|
|
|
@ -3022,7 +3044,10 @@
|
3022
|
3044
|
*/
|
3023
|
3045
|
PopPicker.prototype.hide = function () {
|
3024
|
3046
|
this.mask.close();
|
3025
|
|
this.holder.removeClass("ipu-current");
|
|
3047
|
var _this = this;
|
|
3048
|
this.holder.removeClass("ipu-current").transitionEnd(function () {
|
|
3049
|
_this.holder.hide();
|
|
3050
|
});
|
3026
|
3051
|
};
|
3027
|
3052
|
|
3028
|
3053
|
/**
|
|
@ -3533,7 +3558,8 @@
|
3533
|
3558
|
});
|
3534
|
3559
|
|
3535
|
3560
|
// 处理ios点击延迟问题
|
3536
|
|
FastClick.attach(document.body);
|
|
3561
|
// FastClick.attach(document.body);
|
|
3562
|
// ios 输入框响应不好,暂时屏蔽fastclick的处理
|
3537
|
3563
|
});
|
3538
|
3564
|
|
3539
|
3565
|
return ipuUI;
|