1
|
/**
|
1
|
/**
|
2
|
-* jQuery WeUI V1.2.1
|
|
|
3
|
-* By 言川
|
|
|
4
|
-* http://lihongxun945.github.io/jquery-weui/
|
2
|
+ * jQuery WeUI V1.2.1
|
|
|
3
|
+ * By 言川
|
|
|
4
|
+ * http://lihongxun945.github.io/jquery-weui/
|
5
|
*/
|
5
|
*/
|
6
|
/* global $:true */
|
6
|
/* global $:true */
|
7
|
/* global WebKitCSSMatrix:true */
|
7
|
/* global WebKitCSSMatrix:true */
|
|
@@ -577,27 +577,27 @@ |
|
@@ -577,27 +577,27 @@ |
577
|
(function(window, document, exportName, undefined) {
|
577
|
(function(window, document, exportName, undefined) {
|
578
|
'use strict';
|
578
|
'use strict';
|
579
|
|
579
|
|
580
|
-var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
|
|
581
|
-var TEST_ELEMENT = document.createElement('div');
|
580
|
+ var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
|
|
|
581
|
+ var TEST_ELEMENT = document.createElement('div');
|
582
|
|
582
|
|
583
|
-var TYPE_FUNCTION = 'function';
|
583
|
+ var TYPE_FUNCTION = 'function';
|
584
|
|
584
|
|
585
|
-var round = Math.round;
|
|
|
586
|
-var abs = Math.abs;
|
|
|
587
|
-var now = Date.now;
|
585
|
+ var round = Math.round;
|
|
|
586
|
+ var abs = Math.abs;
|
|
|
587
|
+ var now = Date.now;
|
588
|
|
588
|
|
589
|
-/**
|
589
|
+ /**
|
590
|
* set a timeout with a given scope
|
590
|
* set a timeout with a given scope
|
591
|
* @param {Function} fn
|
591
|
* @param {Function} fn
|
592
|
* @param {Number} timeout
|
592
|
* @param {Number} timeout
|
593
|
* @param {Object} context
|
593
|
* @param {Object} context
|
594
|
* @returns {number}
|
594
|
* @returns {number}
|
595
|
*/
|
595
|
*/
|
596
|
-function setTimeoutContext(fn, timeout, context) {
|
596
|
+ function setTimeoutContext(fn, timeout, context) {
|
597
|
return setTimeout(bindFn(fn, context), timeout);
|
597
|
return setTimeout(bindFn(fn, context), timeout);
|
598
|
-}
|
598
|
+ }
|
599
|
|
599
|
|
600
|
-/**
|
600
|
+ /**
|
601
|
* if the argument is an array, we want to execute the fn on each entry
|
601
|
* if the argument is an array, we want to execute the fn on each entry
|
602
|
* if it aint an array we don't want to do a thing.
|
602
|
* if it aint an array we don't want to do a thing.
|
603
|
* this is used by all the methods that accept a single and array argument.
|
603
|
* this is used by all the methods that accept a single and array argument.
|
|
@@ -606,21 +606,21 @@ function setTimeoutContext(fn, timeout, context) { |
|
@@ -606,21 +606,21 @@ function setTimeoutContext(fn, timeout, context) { |
606
|
* @param {Object} [context]
|
606
|
* @param {Object} [context]
|
607
|
* @returns {Boolean}
|
607
|
* @returns {Boolean}
|
608
|
*/
|
608
|
*/
|
609
|
-function invokeArrayArg(arg, fn, context) {
|
609
|
+ function invokeArrayArg(arg, fn, context) {
|
610
|
if (Array.isArray(arg)) {
|
610
|
if (Array.isArray(arg)) {
|
611
|
each(arg, context[fn], context);
|
611
|
each(arg, context[fn], context);
|
612
|
return true;
|
612
|
return true;
|
613
|
}
|
613
|
}
|
614
|
return false;
|
614
|
return false;
|
615
|
-}
|
615
|
+ }
|
616
|
|
616
|
|
617
|
-/**
|
617
|
+ /**
|
618
|
* walk objects and arrays
|
618
|
* walk objects and arrays
|
619
|
* @param {Object} obj
|
619
|
* @param {Object} obj
|
620
|
* @param {Function} iterator
|
620
|
* @param {Function} iterator
|
621
|
* @param {Object} context
|
621
|
* @param {Object} context
|
622
|
*/
|
622
|
*/
|
623
|
-function each(obj, iterator, context) {
|
623
|
+ function each(obj, iterator, context) {
|
624
|
var i;
|
624
|
var i;
|
625
|
|
625
|
|
626
|
if (!obj) {
|
626
|
if (!obj) {
|
|
@@ -640,16 +640,16 @@ function each(obj, iterator, context) { |
|
@@ -640,16 +640,16 @@ function each(obj, iterator, context) { |
640
|
obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
640
|
obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
|
641
|
}
|
641
|
}
|
642
|
}
|
642
|
}
|
643
|
-}
|
643
|
+ }
|
644
|
|
644
|
|
645
|
-/**
|
645
|
+ /**
|
646
|
* wrap a method with a deprecation warning and stack trace
|
646
|
* wrap a method with a deprecation warning and stack trace
|
647
|
* @param {Function} method
|
647
|
* @param {Function} method
|
648
|
* @param {String} name
|
648
|
* @param {String} name
|
649
|
* @param {String} message
|
649
|
* @param {String} message
|
650
|
* @returns {Function} A new function wrapping the supplied method.
|
650
|
* @returns {Function} A new function wrapping the supplied method.
|
651
|
*/
|
651
|
*/
|
652
|
-function deprecate(method, name, message) {
|
652
|
+ function deprecate(method, name, message) {
|
653
|
var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
653
|
var deprecationMessage = 'DEPRECATED METHOD: ' + name + '\n' + message + ' AT \n';
|
654
|
return function() {
|
654
|
return function() {
|
655
|
var e = new Error('get-stack-trace');
|
655
|
var e = new Error('get-stack-trace');
|
|
@@ -663,17 +663,17 @@ function deprecate(method, name, message) { |
|
@@ -663,17 +663,17 @@ function deprecate(method, name, message) { |
663
|
}
|
663
|
}
|
664
|
return method.apply(this, arguments);
|
664
|
return method.apply(this, arguments);
|
665
|
};
|
665
|
};
|
666
|
-}
|
666
|
+ }
|
667
|
|
667
|
|
668
|
-/**
|
668
|
+ /**
|
669
|
* extend object.
|
669
|
* extend object.
|
670
|
* means that properties in dest will be overwritten by the ones in src.
|
670
|
* means that properties in dest will be overwritten by the ones in src.
|
671
|
* @param {Object} target
|
671
|
* @param {Object} target
|
672
|
* @param {...Object} objects_to_assign
|
672
|
* @param {...Object} objects_to_assign
|
673
|
* @returns {Object} target
|
673
|
* @returns {Object} target
|
674
|
*/
|
674
|
*/
|
675
|
-var assign;
|
|
|
676
|
-if (typeof Object.assign !== 'function') {
|
675
|
+ var assign;
|
|
|
676
|
+ if (typeof Object.assign !== 'function') {
|
677
|
assign = function assign(target) {
|
677
|
assign = function assign(target) {
|
678
|
if (target === undefined || target === null) {
|
678
|
if (target === undefined || target === null) {
|
679
|
throw new TypeError('Cannot convert undefined or null to object');
|
679
|
throw new TypeError('Cannot convert undefined or null to object');
|
|
@@ -692,11 +692,11 @@ if (typeof Object.assign !== 'function') { |
|
@@ -692,11 +692,11 @@ if (typeof Object.assign !== 'function') { |
692
|
}
|
692
|
}
|
693
|
return output;
|
693
|
return output;
|
694
|
};
|
694
|
};
|
695
|
-} else {
|
695
|
+ } else {
|
696
|
assign = Object.assign;
|
696
|
assign = Object.assign;
|
697
|
-}
|
697
|
+ }
|
698
|
|
698
|
|
699
|
-/**
|
699
|
+ /**
|
700
|
* extend object.
|
700
|
* extend object.
|
701
|
* means that properties in dest will be overwritten by the ones in src.
|
701
|
* means that properties in dest will be overwritten by the ones in src.
|
702
|
* @param {Object} dest
|
702
|
* @param {Object} dest
|
|
@@ -704,7 +704,7 @@ if (typeof Object.assign !== 'function') { |
|
@@ -704,7 +704,7 @@ if (typeof Object.assign !== 'function') { |
704
|
* @param {Boolean} [merge=false]
|
704
|
* @param {Boolean} [merge=false]
|
705
|
* @returns {Object} dest
|
705
|
* @returns {Object} dest
|
706
|
*/
|
706
|
*/
|
707
|
-var extend = deprecate(function extend(dest, src, merge) {
|
707
|
+ var extend = deprecate(function extend(dest, src, merge) {
|
708
|
var keys = Object.keys(src);
|
708
|
var keys = Object.keys(src);
|
709
|
var i = 0;
|
709
|
var i = 0;
|
710
|
while (i < keys.length) {
|
710
|
while (i < keys.length) {
|
|
@@ -714,26 +714,26 @@ var extend = deprecate(function extend(dest, src, merge) { |
|
@@ -714,26 +714,26 @@ var extend = deprecate(function extend(dest, src, merge) { |
714
|
i++;
|
714
|
i++;
|
715
|
}
|
715
|
}
|
716
|
return dest;
|
716
|
return dest;
|
717
|
-}, 'extend', 'Use `assign`.');
|
717
|
+ }, 'extend', 'Use `assign`.');
|
718
|
|
718
|
|
719
|
-/**
|
719
|
+ /**
|
720
|
* merge the values from src in the dest.
|
720
|
* merge the values from src in the dest.
|
721
|
* means that properties that exist in dest will not be overwritten by src
|
721
|
* means that properties that exist in dest will not be overwritten by src
|
722
|
* @param {Object} dest
|
722
|
* @param {Object} dest
|
723
|
* @param {Object} src
|
723
|
* @param {Object} src
|
724
|
* @returns {Object} dest
|
724
|
* @returns {Object} dest
|
725
|
*/
|
725
|
*/
|
726
|
-var merge = deprecate(function merge(dest, src) {
|
726
|
+ var merge = deprecate(function merge(dest, src) {
|
727
|
return extend(dest, src, true);
|
727
|
return extend(dest, src, true);
|
728
|
-}, 'merge', 'Use `assign`.');
|
728
|
+ }, 'merge', 'Use `assign`.');
|
729
|
|
729
|
|
730
|
-/**
|
730
|
+ /**
|
731
|
* simple class inheritance
|
731
|
* simple class inheritance
|
732
|
* @param {Function} child
|
732
|
* @param {Function} child
|
733
|
* @param {Function} base
|
733
|
* @param {Function} base
|
734
|
* @param {Object} [properties]
|
734
|
* @param {Object} [properties]
|
735
|
*/
|
735
|
*/
|
736
|
-function inherit(child, base, properties) {
|
736
|
+ function inherit(child, base, properties) {
|
737
|
var baseP = base.prototype,
|
737
|
var baseP = base.prototype,
|
738
|
childP;
|
738
|
childP;
|
739
|
|
739
|
|
|
@@ -744,76 +744,76 @@ function inherit(child, base, properties) { |
|
@@ -744,76 +744,76 @@ function inherit(child, base, properties) { |
744
|
if (properties) {
|
744
|
if (properties) {
|
745
|
assign(childP, properties);
|
745
|
assign(childP, properties);
|
746
|
}
|
746
|
}
|
747
|
-}
|
747
|
+ }
|
748
|
|
748
|
|
749
|
-/**
|
749
|
+ /**
|
750
|
* simple function bind
|
750
|
* simple function bind
|
751
|
* @param {Function} fn
|
751
|
* @param {Function} fn
|
752
|
* @param {Object} context
|
752
|
* @param {Object} context
|
753
|
* @returns {Function}
|
753
|
* @returns {Function}
|
754
|
*/
|
754
|
*/
|
755
|
-function bindFn(fn, context) {
|
755
|
+ function bindFn(fn, context) {
|
756
|
return function boundFn() {
|
756
|
return function boundFn() {
|
757
|
return fn.apply(context, arguments);
|
757
|
return fn.apply(context, arguments);
|
758
|
};
|
758
|
};
|
759
|
-}
|
759
|
+ }
|
760
|
|
760
|
|
761
|
-/**
|
761
|
+ /**
|
762
|
* let a boolean value also be a function that must return a boolean
|
762
|
* let a boolean value also be a function that must return a boolean
|
763
|
* this first item in args will be used as the context
|
763
|
* this first item in args will be used as the context
|
764
|
* @param {Boolean|Function} val
|
764
|
* @param {Boolean|Function} val
|
765
|
* @param {Array} [args]
|
765
|
* @param {Array} [args]
|
766
|
* @returns {Boolean}
|
766
|
* @returns {Boolean}
|
767
|
*/
|
767
|
*/
|
768
|
-function boolOrFn(val, args) {
|
768
|
+ function boolOrFn(val, args) {
|
769
|
if (typeof val == TYPE_FUNCTION) {
|
769
|
if (typeof val == TYPE_FUNCTION) {
|
770
|
return val.apply(args ? args[0] || undefined : undefined, args);
|
770
|
return val.apply(args ? args[0] || undefined : undefined, args);
|
771
|
}
|
771
|
}
|
772
|
return val;
|
772
|
return val;
|
773
|
-}
|
773
|
+ }
|
774
|
|
774
|
|
775
|
-/**
|
775
|
+ /**
|
776
|
* use the val2 when val1 is undefined
|
776
|
* use the val2 when val1 is undefined
|
777
|
* @param {*} val1
|
777
|
* @param {*} val1
|
778
|
* @param {*} val2
|
778
|
* @param {*} val2
|
779
|
* @returns {*}
|
779
|
* @returns {*}
|
780
|
*/
|
780
|
*/
|
781
|
-function ifUndefined(val1, val2) {
|
781
|
+ function ifUndefined(val1, val2) {
|
782
|
return (val1 === undefined) ? val2 : val1;
|
782
|
return (val1 === undefined) ? val2 : val1;
|
783
|
-}
|
783
|
+ }
|
784
|
|
784
|
|
785
|
-/**
|
785
|
+ /**
|
786
|
* addEventListener with multiple events at once
|
786
|
* addEventListener with multiple events at once
|
787
|
* @param {EventTarget} target
|
787
|
* @param {EventTarget} target
|
788
|
* @param {String} types
|
788
|
* @param {String} types
|
789
|
* @param {Function} handler
|
789
|
* @param {Function} handler
|
790
|
*/
|
790
|
*/
|
791
|
-function addEventListeners(target, types, handler) {
|
791
|
+ function addEventListeners(target, types, handler) {
|
792
|
each(splitStr(types), function(type) {
|
792
|
each(splitStr(types), function(type) {
|
793
|
target.addEventListener(type, handler, false);
|
793
|
target.addEventListener(type, handler, false);
|
794
|
});
|
794
|
});
|
795
|
-}
|
795
|
+ }
|
796
|
|
796
|
|
797
|
-/**
|
797
|
+ /**
|
798
|
* removeEventListener with multiple events at once
|
798
|
* removeEventListener with multiple events at once
|
799
|
* @param {EventTarget} target
|
799
|
* @param {EventTarget} target
|
800
|
* @param {String} types
|
800
|
* @param {String} types
|
801
|
* @param {Function} handler
|
801
|
* @param {Function} handler
|
802
|
*/
|
802
|
*/
|
803
|
-function removeEventListeners(target, types, handler) {
|
803
|
+ function removeEventListeners(target, types, handler) {
|
804
|
each(splitStr(types), function(type) {
|
804
|
each(splitStr(types), function(type) {
|
805
|
target.removeEventListener(type, handler, false);
|
805
|
target.removeEventListener(type, handler, false);
|
806
|
});
|
806
|
});
|
807
|
-}
|
807
|
+ }
|
808
|
|
808
|
|
809
|
-/**
|
809
|
+ /**
|
810
|
* find if a node is in the given parent
|
810
|
* find if a node is in the given parent
|
811
|
* @method hasParent
|
811
|
* @method hasParent
|
812
|
* @param {HTMLElement} node
|
812
|
* @param {HTMLElement} node
|
813
|
* @param {HTMLElement} parent
|
813
|
* @param {HTMLElement} parent
|
814
|
* @return {Boolean} found
|
814
|
* @return {Boolean} found
|
815
|
*/
|
815
|
*/
|
816
|
-function hasParent(node, parent) {
|
816
|
+ function hasParent(node, parent) {
|
817
|
while (node) {
|
817
|
while (node) {
|
818
|
if (node == parent) {
|
818
|
if (node == parent) {
|
819
|
return true;
|
819
|
return true;
|
|
@@ -821,35 +821,35 @@ function hasParent(node, parent) { |
|
@@ -821,35 +821,35 @@ function hasParent(node, parent) { |
821
|
node = node.parentNode;
|
821
|
node = node.parentNode;
|
822
|
}
|
822
|
}
|
823
|
return false;
|
823
|
return false;
|
824
|
-}
|
824
|
+ }
|
825
|
|
825
|
|
826
|
-/**
|
826
|
+ /**
|
827
|
* small indexOf wrapper
|
827
|
* small indexOf wrapper
|
828
|
* @param {String} str
|
828
|
* @param {String} str
|
829
|
* @param {String} find
|
829
|
* @param {String} find
|
830
|
* @returns {Boolean} found
|
830
|
* @returns {Boolean} found
|
831
|
*/
|
831
|
*/
|
832
|
-function inStr(str, find) {
|
832
|
+ function inStr(str, find) {
|
833
|
return str.indexOf(find) > -1;
|
833
|
return str.indexOf(find) > -1;
|
834
|
-}
|
834
|
+ }
|
835
|
|
835
|
|
836
|
-/**
|
836
|
+ /**
|
837
|
* split string on whitespace
|
837
|
* split string on whitespace
|
838
|
* @param {String} str
|
838
|
* @param {String} str
|
839
|
* @returns {Array} words
|
839
|
* @returns {Array} words
|
840
|
*/
|
840
|
*/
|
841
|
-function splitStr(str) {
|
841
|
+ function splitStr(str) {
|
842
|
return str.trim().split(/\s+/g);
|
842
|
return str.trim().split(/\s+/g);
|
843
|
-}
|
843
|
+ }
|
844
|
|
844
|
|
845
|
-/**
|
845
|
+ /**
|
846
|
* find if a array contains the object using indexOf or a simple polyFill
|
846
|
* find if a array contains the object using indexOf or a simple polyFill
|
847
|
* @param {Array} src
|
847
|
* @param {Array} src
|
848
|
* @param {String} find
|
848
|
* @param {String} find
|
849
|
* @param {String} [findByKey]
|
849
|
* @param {String} [findByKey]
|
850
|
* @return {Boolean|Number} false when not found, or the index
|
850
|
* @return {Boolean|Number} false when not found, or the index
|
851
|
*/
|
851
|
*/
|
852
|
-function inArray(src, find, findByKey) {
|
852
|
+ function inArray(src, find, findByKey) {
|
853
|
if (src.indexOf && !findByKey) {
|
853
|
if (src.indexOf && !findByKey) {
|
854
|
return src.indexOf(find);
|
854
|
return src.indexOf(find);
|
855
|
} else {
|
855
|
} else {
|
|
@@ -862,25 +862,25 @@ function inArray(src, find, findByKey) { |
|
@@ -862,25 +862,25 @@ function inArray(src, find, findByKey) { |
862
|
}
|
862
|
}
|
863
|
return -1;
|
863
|
return -1;
|
864
|
}
|
864
|
}
|
865
|
-}
|
865
|
+ }
|
866
|
|
866
|
|
867
|
-/**
|
867
|
+ /**
|
868
|
* convert array-like objects to real arrays
|
868
|
* convert array-like objects to real arrays
|
869
|
* @param {Object} obj
|
869
|
* @param {Object} obj
|
870
|
* @returns {Array}
|
870
|
* @returns {Array}
|
871
|
*/
|
871
|
*/
|
872
|
-function toArray(obj) {
|
872
|
+ function toArray(obj) {
|
873
|
return Array.prototype.slice.call(obj, 0);
|
873
|
return Array.prototype.slice.call(obj, 0);
|
874
|
-}
|
874
|
+ }
|
875
|
|
875
|
|
876
|
-/**
|
876
|
+ /**
|
877
|
* unique array with objects based on a key (like 'id') or just by the array's value
|
877
|
* unique array with objects based on a key (like 'id') or just by the array's value
|
878
|
* @param {Array} src [{id:1},{id:2},{id:1}]
|
878
|
* @param {Array} src [{id:1},{id:2},{id:1}]
|
879
|
* @param {String} [key]
|
879
|
* @param {String} [key]
|
880
|
* @param {Boolean} [sort=False]
|
880
|
* @param {Boolean} [sort=False]
|
881
|
* @returns {Array} [{id:1},{id:2}]
|
881
|
* @returns {Array} [{id:1},{id:2}]
|
882
|
*/
|
882
|
*/
|
883
|
-function uniqueArray(src, key, sort) {
|
883
|
+ function uniqueArray(src, key, sort) {
|
884
|
var results = [];
|
884
|
var results = [];
|
885
|
var values = [];
|
885
|
var values = [];
|
886
|
var i = 0;
|
886
|
var i = 0;
|
|
@@ -905,15 +905,15 @@ function uniqueArray(src, key, sort) { |
|
@@ -905,15 +905,15 @@ function uniqueArray(src, key, sort) { |
905
|
}
|
905
|
}
|
906
|
|
906
|
|
907
|
return results;
|
907
|
return results;
|
908
|
-}
|
908
|
+ }
|
909
|
|
909
|
|
910
|
-/**
|
910
|
+ /**
|
911
|
* get the prefixed property
|
911
|
* get the prefixed property
|
912
|
* @param {Object} obj
|
912
|
* @param {Object} obj
|
913
|
* @param {String} property
|
913
|
* @param {String} property
|
914
|
* @returns {String|Undefined} prefixed
|
914
|
* @returns {String|Undefined} prefixed
|
915
|
*/
|
915
|
*/
|
916
|
-function prefixed(obj, property) {
|
916
|
+ function prefixed(obj, property) {
|
917
|
var prefix, prop;
|
917
|
var prefix, prop;
|
918
|
var camelProp = property[0].toUpperCase() + property.slice(1);
|
918
|
var camelProp = property[0].toUpperCase() + property.slice(1);
|
919
|
|
919
|
|
|
@@ -928,66 +928,66 @@ function prefixed(obj, property) { |
|
@@ -928,66 +928,66 @@ function prefixed(obj, property) { |
928
|
i++;
|
928
|
i++;
|
929
|
}
|
929
|
}
|
930
|
return undefined;
|
930
|
return undefined;
|
931
|
-}
|
931
|
+ }
|
932
|
|
932
|
|
933
|
-/**
|
933
|
+ /**
|
934
|
* get a unique id
|
934
|
* get a unique id
|
935
|
* @returns {number} uniqueId
|
935
|
* @returns {number} uniqueId
|
936
|
*/
|
936
|
*/
|
937
|
-var _uniqueId = 1;
|
|
|
938
|
-function uniqueId() {
|
937
|
+ var _uniqueId = 1;
|
|
|
938
|
+ function uniqueId() {
|
939
|
return _uniqueId++;
|
939
|
return _uniqueId++;
|
940
|
-}
|
940
|
+ }
|
941
|
|
941
|
|
942
|
-/**
|
942
|
+ /**
|
943
|
* get the window object of an element
|
943
|
* get the window object of an element
|
944
|
* @param {HTMLElement} element
|
944
|
* @param {HTMLElement} element
|
945
|
* @returns {DocumentView|Window}
|
945
|
* @returns {DocumentView|Window}
|
946
|
*/
|
946
|
*/
|
947
|
-function getWindowForElement(element) {
|
947
|
+ function getWindowForElement(element) {
|
948
|
var doc = element.ownerDocument || element;
|
948
|
var doc = element.ownerDocument || element;
|
949
|
return (doc.defaultView || doc.parentWindow || window);
|
949
|
return (doc.defaultView || doc.parentWindow || window);
|
950
|
-}
|
950
|
+ }
|
951
|
|
951
|
|
952
|
-var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
952
|
+ var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
953
|
|
953
|
|
954
|
-var SUPPORT_TOUCH = ('ontouchstart' in window);
|
|
|
955
|
-var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
|
|
|
956
|
-var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
954
|
+ var SUPPORT_TOUCH = ('ontouchstart' in window);
|
|
|
955
|
+ var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
|
|
|
956
|
+ var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
957
|
|
957
|
|
958
|
-var INPUT_TYPE_TOUCH = 'touch';
|
|
|
959
|
-var INPUT_TYPE_PEN = 'pen';
|
|
|
960
|
-var INPUT_TYPE_MOUSE = 'mouse';
|
|
|
961
|
-var INPUT_TYPE_KINECT = 'kinect';
|
958
|
+ var INPUT_TYPE_TOUCH = 'touch';
|
|
|
959
|
+ var INPUT_TYPE_PEN = 'pen';
|
|
|
960
|
+ var INPUT_TYPE_MOUSE = 'mouse';
|
|
|
961
|
+ var INPUT_TYPE_KINECT = 'kinect';
|
962
|
|
962
|
|
963
|
-var COMPUTE_INTERVAL = 25;
|
963
|
+ var COMPUTE_INTERVAL = 25;
|
964
|
|
964
|
|
965
|
-var INPUT_START = 1;
|
|
|
966
|
-var INPUT_MOVE = 2;
|
|
|
967
|
-var INPUT_END = 4;
|
|
|
968
|
-var INPUT_CANCEL = 8;
|
965
|
+ var INPUT_START = 1;
|
|
|
966
|
+ var INPUT_MOVE = 2;
|
|
|
967
|
+ var INPUT_END = 4;
|
|
|
968
|
+ var INPUT_CANCEL = 8;
|
969
|
|
969
|
|
970
|
-var DIRECTION_NONE = 1;
|
|
|
971
|
-var DIRECTION_LEFT = 2;
|
|
|
972
|
-var DIRECTION_RIGHT = 4;
|
|
|
973
|
-var DIRECTION_UP = 8;
|
|
|
974
|
-var DIRECTION_DOWN = 16;
|
970
|
+ var DIRECTION_NONE = 1;
|
|
|
971
|
+ var DIRECTION_LEFT = 2;
|
|
|
972
|
+ var DIRECTION_RIGHT = 4;
|
|
|
973
|
+ var DIRECTION_UP = 8;
|
|
|
974
|
+ var DIRECTION_DOWN = 16;
|
975
|
|
975
|
|
976
|
-var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
|
977
|
-var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
|
978
|
-var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
976
|
+ var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
|
977
|
+ var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
|
978
|
+ var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
979
|
|
979
|
|
980
|
-var PROPS_XY = ['x', 'y'];
|
|
|
981
|
-var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
980
|
+ var PROPS_XY = ['x', 'y'];
|
|
|
981
|
+ var PROPS_CLIENT_XY = ['clientX', 'clientY'];
|
982
|
|
982
|
|
983
|
-/**
|
983
|
+ /**
|
984
|
* create new input type manager
|
984
|
* create new input type manager
|
985
|
* @param {Manager} manager
|
985
|
* @param {Manager} manager
|
986
|
* @param {Function} callback
|
986
|
* @param {Function} callback
|
987
|
* @returns {Input}
|
987
|
* @returns {Input}
|
988
|
* @constructor
|
988
|
* @constructor
|
989
|
*/
|
989
|
*/
|
990
|
-function Input(manager, callback) {
|
990
|
+ function Input(manager, callback) {
|
991
|
var self = this;
|
991
|
var self = this;
|
992
|
this.manager = manager;
|
992
|
this.manager = manager;
|
993
|
this.callback = callback;
|
993
|
this.callback = callback;
|
|
@@ -1004,9 +1004,9 @@ function Input(manager, callback) { |
|
@@ -1004,9 +1004,9 @@ function Input(manager, callback) { |
1004
|
|
1004
|
|
1005
|
this.init();
|
1005
|
this.init();
|
1006
|
|
1006
|
|
1007
|
-}
|
1007
|
+ }
|
1008
|
|
1008
|
|
1009
|
-Input.prototype = {
|
1009
|
+ Input.prototype = {
|
1010
|
/**
|
1010
|
/**
|
1011
|
* should handle the inputEvent data and trigger the callback
|
1011
|
* should handle the inputEvent data and trigger the callback
|
1012
|
* @virtual
|
1012
|
* @virtual
|
|
@@ -1030,15 +1030,15 @@ Input.prototype = { |
|
@@ -1030,15 +1030,15 @@ Input.prototype = { |
1030
|
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
1030
|
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
1031
|
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
1031
|
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
1032
|
}
|
1032
|
}
|
1033
|
-};
|
1033
|
+ };
|
1034
|
|
1034
|
|
1035
|
-/**
|
1035
|
+ /**
|
1036
|
* create new input type manager
|
1036
|
* create new input type manager
|
1037
|
* called by the Manager constructor
|
1037
|
* called by the Manager constructor
|
1038
|
* @param {Hammer} manager
|
1038
|
* @param {Hammer} manager
|
1039
|
* @returns {Input}
|
1039
|
* @returns {Input}
|
1040
|
*/
|
1040
|
*/
|
1041
|
-function createInputInstance(manager) {
|
1041
|
+ function createInputInstance(manager) {
|
1042
|
var Type;
|
1042
|
var Type;
|
1043
|
var inputClass = manager.options.inputClass;
|
1043
|
var inputClass = manager.options.inputClass;
|
1044
|
|
1044
|
|
|
@@ -1054,15 +1054,15 @@ function createInputInstance(manager) { |
|
@@ -1054,15 +1054,15 @@ function createInputInstance(manager) { |
1054
|
Type = TouchMouseInput;
|
1054
|
Type = TouchMouseInput;
|
1055
|
}
|
1055
|
}
|
1056
|
return new (Type)(manager, inputHandler);
|
1056
|
return new (Type)(manager, inputHandler);
|
1057
|
-}
|
1057
|
+ }
|
1058
|
|
1058
|
|
1059
|
-/**
|
1059
|
+ /**
|
1060
|
* handle input events
|
1060
|
* handle input events
|
1061
|
* @param {Manager} manager
|
1061
|
* @param {Manager} manager
|
1062
|
* @param {String} eventType
|
1062
|
* @param {String} eventType
|
1063
|
* @param {Object} input
|
1063
|
* @param {Object} input
|
1064
|
*/
|
1064
|
*/
|
1065
|
-function inputHandler(manager, eventType, input) {
|
1065
|
+ function inputHandler(manager, eventType, input) {
|
1066
|
var pointersLen = input.pointers.length;
|
1066
|
var pointersLen = input.pointers.length;
|
1067
|
var changedPointersLen = input.changedPointers.length;
|
1067
|
var changedPointersLen = input.changedPointers.length;
|
1068
|
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
1068
|
var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
|
|
@@ -1087,14 +1087,14 @@ function inputHandler(manager, eventType, input) { |
|
@@ -1087,14 +1087,14 @@ function inputHandler(manager, eventType, input) { |
1087
|
|
1087
|
|
1088
|
manager.recognize(input);
|
1088
|
manager.recognize(input);
|
1089
|
manager.session.prevInput = input;
|
1089
|
manager.session.prevInput = input;
|
1090
|
-}
|
1090
|
+ }
|
1091
|
|
1091
|
|
1092
|
-/**
|
1092
|
+ /**
|
1093
|
* extend the data with some usable properties like scale, rotate, velocity etc
|
1093
|
* extend the data with some usable properties like scale, rotate, velocity etc
|
1094
|
* @param {Object} manager
|
1094
|
* @param {Object} manager
|
1095
|
* @param {Object} input
|
1095
|
* @param {Object} input
|
1096
|
*/
|
1096
|
*/
|
1097
|
-function computeInputData(manager, input) {
|
1097
|
+ function computeInputData(manager, input) {
|
1098
|
var session = manager.session;
|
1098
|
var session = manager.session;
|
1099
|
var pointers = input.pointers;
|
1099
|
var pointers = input.pointers;
|
1100
|
var pointersLength = pointers.length;
|
1100
|
var pointersLength = pointers.length;
|
|
@@ -1144,9 +1144,9 @@ function computeInputData(manager, input) { |
|
@@ -1144,9 +1144,9 @@ function computeInputData(manager, input) { |
1144
|
target = input.srcEvent.target;
|
1144
|
target = input.srcEvent.target;
|
1145
|
}
|
1145
|
}
|
1146
|
input.target = target;
|
1146
|
input.target = target;
|
1147
|
-}
|
1147
|
+ }
|
1148
|
|
1148
|
|
1149
|
-function computeDeltaXY(session, input) {
|
1149
|
+ function computeDeltaXY(session, input) {
|
1150
|
var center = input.center;
|
1150
|
var center = input.center;
|
1151
|
var offset = session.offsetDelta || {};
|
1151
|
var offset = session.offsetDelta || {};
|
1152
|
var prevDelta = session.prevDelta || {};
|
1152
|
var prevDelta = session.prevDelta || {};
|
|
@@ -1166,14 +1166,14 @@ function computeDeltaXY(session, input) { |
|
@@ -1166,14 +1166,14 @@ function computeDeltaXY(session, input) { |
1166
|
|
1166
|
|
1167
|
input.deltaX = prevDelta.x + (center.x - offset.x);
|
1167
|
input.deltaX = prevDelta.x + (center.x - offset.x);
|
1168
|
input.deltaY = prevDelta.y + (center.y - offset.y);
|
1168
|
input.deltaY = prevDelta.y + (center.y - offset.y);
|
1169
|
-}
|
1169
|
+ }
|
1170
|
|
1170
|
|
1171
|
-/**
|
1171
|
+ /**
|
1172
|
* velocity is calculated every x ms
|
1172
|
* velocity is calculated every x ms
|
1173
|
* @param {Object} session
|
1173
|
* @param {Object} session
|
1174
|
* @param {Object} input
|
1174
|
* @param {Object} input
|
1175
|
*/
|
1175
|
*/
|
1176
|
-function computeIntervalInputData(session, input) {
|
1176
|
+ function computeIntervalInputData(session, input) {
|
1177
|
var last = session.lastInterval || input,
|
1177
|
var last = session.lastInterval || input,
|
1178
|
deltaTime = input.timeStamp - last.timeStamp,
|
1178
|
deltaTime = input.timeStamp - last.timeStamp,
|
1179
|
velocity, velocityX, velocityY, direction;
|
1179
|
velocity, velocityX, velocityY, direction;
|
|
@@ -1201,14 +1201,14 @@ function computeIntervalInputData(session, input) { |
|
@@ -1201,14 +1201,14 @@ function computeIntervalInputData(session, input) { |
1201
|
input.velocityX = velocityX;
|
1201
|
input.velocityX = velocityX;
|
1202
|
input.velocityY = velocityY;
|
1202
|
input.velocityY = velocityY;
|
1203
|
input.direction = direction;
|
1203
|
input.direction = direction;
|
1204
|
-}
|
1204
|
+ }
|
1205
|
|
1205
|
|
1206
|
-/**
|
1206
|
+ /**
|
1207
|
* create a simple clone from the input used for storage of firstInput and firstMultiple
|
1207
|
* create a simple clone from the input used for storage of firstInput and firstMultiple
|
1208
|
* @param {Object} input
|
1208
|
* @param {Object} input
|
1209
|
* @returns {Object} clonedInputData
|
1209
|
* @returns {Object} clonedInputData
|
1210
|
*/
|
1210
|
*/
|
1211
|
-function simpleCloneInputData(input) {
|
1211
|
+ function simpleCloneInputData(input) {
|
1212
|
// make a simple copy of the pointers because we will get a reference if we don't
|
1212
|
// make a simple copy of the pointers because we will get a reference if we don't
|
1213
|
// we only need clientXY for the calculations
|
1213
|
// we only need clientXY for the calculations
|
1214
|
var pointers = [];
|
1214
|
var pointers = [];
|
|
@@ -1228,14 +1228,14 @@ function simpleCloneInputData(input) { |
|
@@ -1228,14 +1228,14 @@ function simpleCloneInputData(input) { |
1228
|
deltaX: input.deltaX,
|
1228
|
deltaX: input.deltaX,
|
1229
|
deltaY: input.deltaY
|
1229
|
deltaY: input.deltaY
|
1230
|
};
|
1230
|
};
|
1231
|
-}
|
1231
|
+ }
|
1232
|
|
1232
|
|
1233
|
-/**
|
1233
|
+ /**
|
1234
|
* get the center of all the pointers
|
1234
|
* get the center of all the pointers
|
1235
|
* @param {Array} pointers
|
1235
|
* @param {Array} pointers
|
1236
|
* @return {Object} center contains `x` and `y` properties
|
1236
|
* @return {Object} center contains `x` and `y` properties
|
1237
|
*/
|
1237
|
*/
|
1238
|
-function getCenter(pointers) {
|
1238
|
+ function getCenter(pointers) {
|
1239
|
var pointersLength = pointers.length;
|
1239
|
var pointersLength = pointers.length;
|
1240
|
|
1240
|
|
1241
|
// no need to loop when only one touch
|
1241
|
// no need to loop when only one touch
|
|
@@ -1257,29 +1257,29 @@ function getCenter(pointers) { |
|
@@ -1257,29 +1257,29 @@ function getCenter(pointers) { |
1257
|
x: round(x / pointersLength),
|
1257
|
x: round(x / pointersLength),
|
1258
|
y: round(y / pointersLength)
|
1258
|
y: round(y / pointersLength)
|
1259
|
};
|
1259
|
};
|
1260
|
-}
|
1260
|
+ }
|
1261
|
|
1261
|
|
1262
|
-/**
|
1262
|
+ /**
|
1263
|
* calculate the velocity between two points. unit is in px per ms.
|
1263
|
* calculate the velocity between two points. unit is in px per ms.
|
1264
|
* @param {Number} deltaTime
|
1264
|
* @param {Number} deltaTime
|
1265
|
* @param {Number} x
|
1265
|
* @param {Number} x
|
1266
|
* @param {Number} y
|
1266
|
* @param {Number} y
|
1267
|
* @return {Object} velocity `x` and `y`
|
1267
|
* @return {Object} velocity `x` and `y`
|
1268
|
*/
|
1268
|
*/
|
1269
|
-function getVelocity(deltaTime, x, y) {
|
1269
|
+ function getVelocity(deltaTime, x, y) {
|
1270
|
return {
|
1270
|
return {
|
1271
|
x: x / deltaTime || 0,
|
1271
|
x: x / deltaTime || 0,
|
1272
|
y: y / deltaTime || 0
|
1272
|
y: y / deltaTime || 0
|
1273
|
};
|
1273
|
};
|
1274
|
-}
|
1274
|
+ }
|
1275
|
|
1275
|
|
1276
|
-/**
|
1276
|
+ /**
|
1277
|
* get the direction between two points
|
1277
|
* get the direction between two points
|
1278
|
* @param {Number} x
|
1278
|
* @param {Number} x
|
1279
|
* @param {Number} y
|
1279
|
* @param {Number} y
|
1280
|
* @return {Number} direction
|
1280
|
* @return {Number} direction
|
1281
|
*/
|
1281
|
*/
|
1282
|
-function getDirection(x, y) {
|
1282
|
+ function getDirection(x, y) {
|
1283
|
if (x === y) {
|
1283
|
if (x === y) {
|
1284
|
return DIRECTION_NONE;
|
1284
|
return DIRECTION_NONE;
|
1285
|
}
|
1285
|
}
|
|
@@ -1288,16 +1288,16 @@ function getDirection(x, y) { |
|
@@ -1288,16 +1288,16 @@ function getDirection(x, y) { |
1288
|
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
1288
|
return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
1289
|
}
|
1289
|
}
|
1290
|
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
1290
|
return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
1291
|
-}
|
1291
|
+ }
|
1292
|
|
1292
|
|
1293
|
-/**
|
1293
|
+ /**
|
1294
|
* calculate the absolute distance between two points
|
1294
|
* calculate the absolute distance between two points
|
1295
|
* @param {Object} p1 {x, y}
|
1295
|
* @param {Object} p1 {x, y}
|
1296
|
* @param {Object} p2 {x, y}
|
1296
|
* @param {Object} p2 {x, y}
|
1297
|
* @param {Array} [props] containing x and y keys
|
1297
|
* @param {Array} [props] containing x and y keys
|
1298
|
* @return {Number} distance
|
1298
|
* @return {Number} distance
|
1299
|
*/
|
1299
|
*/
|
1300
|
-function getDistance(p1, p2, props) {
|
1300
|
+ function getDistance(p1, p2, props) {
|
1301
|
if (!props) {
|
1301
|
if (!props) {
|
1302
|
props = PROPS_XY;
|
1302
|
props = PROPS_XY;
|
1303
|
}
|
1303
|
}
|
|
@@ -1305,69 +1305,69 @@ function getDistance(p1, p2, props) { |
|
@@ -1305,69 +1305,69 @@ function getDistance(p1, p2, props) { |
1305
|
y = p2[props[1]] - p1[props[1]];
|
1305
|
y = p2[props[1]] - p1[props[1]];
|
1306
|
|
1306
|
|
1307
|
return Math.sqrt((x * x) + (y * y));
|
1307
|
return Math.sqrt((x * x) + (y * y));
|
1308
|
-}
|
1308
|
+ }
|
1309
|
|
1309
|
|
1310
|
-/**
|
1310
|
+ /**
|
1311
|
* calculate the angle between two coordinates
|
1311
|
* calculate the angle between two coordinates
|
1312
|
* @param {Object} p1
|
1312
|
* @param {Object} p1
|
1313
|
* @param {Object} p2
|
1313
|
* @param {Object} p2
|
1314
|
* @param {Array} [props] containing x and y keys
|
1314
|
* @param {Array} [props] containing x and y keys
|
1315
|
* @return {Number} angle
|
1315
|
* @return {Number} angle
|
1316
|
*/
|
1316
|
*/
|
1317
|
-function getAngle(p1, p2, props) {
|
1317
|
+ function getAngle(p1, p2, props) {
|
1318
|
if (!props) {
|
1318
|
if (!props) {
|
1319
|
props = PROPS_XY;
|
1319
|
props = PROPS_XY;
|
1320
|
}
|
1320
|
}
|
1321
|
var x = p2[props[0]] - p1[props[0]],
|
1321
|
var x = p2[props[0]] - p1[props[0]],
|
1322
|
y = p2[props[1]] - p1[props[1]];
|
1322
|
y = p2[props[1]] - p1[props[1]];
|
1323
|
return Math.atan2(y, x) * 180 / Math.PI;
|
1323
|
return Math.atan2(y, x) * 180 / Math.PI;
|
1324
|
-}
|
1324
|
+ }
|
1325
|
|
1325
|
|
1326
|
-/**
|
1326
|
+ /**
|
1327
|
* calculate the rotation degrees between two pointersets
|
1327
|
* calculate the rotation degrees between two pointersets
|
1328
|
* @param {Array} start array of pointers
|
1328
|
* @param {Array} start array of pointers
|
1329
|
* @param {Array} end array of pointers
|
1329
|
* @param {Array} end array of pointers
|
1330
|
* @return {Number} rotation
|
1330
|
* @return {Number} rotation
|
1331
|
*/
|
1331
|
*/
|
1332
|
-function getRotation(start, end) {
|
1332
|
+ function getRotation(start, end) {
|
1333
|
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
1333
|
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
1334
|
-}
|
1334
|
+ }
|
1335
|
|
1335
|
|
1336
|
-/**
|
1336
|
+ /**
|
1337
|
* calculate the scale factor between two pointersets
|
1337
|
* calculate the scale factor between two pointersets
|
1338
|
* no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
|
1338
|
* no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
|
1339
|
* @param {Array} start array of pointers
|
1339
|
* @param {Array} start array of pointers
|
1340
|
* @param {Array} end array of pointers
|
1340
|
* @param {Array} end array of pointers
|
1341
|
* @return {Number} scale
|
1341
|
* @return {Number} scale
|
1342
|
*/
|
1342
|
*/
|
1343
|
-function getScale(start, end) {
|
1343
|
+ function getScale(start, end) {
|
1344
|
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
1344
|
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
1345
|
-}
|
1345
|
+ }
|
1346
|
|
1346
|
|
1347
|
-var MOUSE_INPUT_MAP = {
|
1347
|
+ var MOUSE_INPUT_MAP = {
|
1348
|
mousedown: INPUT_START,
|
1348
|
mousedown: INPUT_START,
|
1349
|
mousemove: INPUT_MOVE,
|
1349
|
mousemove: INPUT_MOVE,
|
1350
|
mouseup: INPUT_END
|
1350
|
mouseup: INPUT_END
|
1351
|
-};
|
1351
|
+ };
|
1352
|
|
1352
|
|
1353
|
-var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
|
|
1354
|
-var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
1353
|
+ var MOUSE_ELEMENT_EVENTS = 'mousedown';
|
|
|
1354
|
+ var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
|
1355
|
|
1355
|
|
1356
|
-/**
|
1356
|
+ /**
|
1357
|
* Mouse events input
|
1357
|
* Mouse events input
|
1358
|
* @constructor
|
1358
|
* @constructor
|
1359
|
* @extends Input
|
1359
|
* @extends Input
|
1360
|
*/
|
1360
|
*/
|
1361
|
-function MouseInput() {
|
1361
|
+ function MouseInput() {
|
1362
|
this.evEl = MOUSE_ELEMENT_EVENTS;
|
1362
|
this.evEl = MOUSE_ELEMENT_EVENTS;
|
1363
|
this.evWin = MOUSE_WINDOW_EVENTS;
|
1363
|
this.evWin = MOUSE_WINDOW_EVENTS;
|
1364
|
|
1364
|
|
1365
|
this.pressed = false; // mousedown state
|
1365
|
this.pressed = false; // mousedown state
|
1366
|
|
1366
|
|
1367
|
Input.apply(this, arguments);
|
1367
|
Input.apply(this, arguments);
|
1368
|
-}
|
1368
|
+ }
|
1369
|
|
1369
|
|
1370
|
-inherit(MouseInput, Input, {
|
1370
|
+ inherit(MouseInput, Input, {
|
1371
|
/**
|
1371
|
/**
|
1372
|
* handle mouse events
|
1372
|
* handle mouse events
|
1373
|
* @param {Object} ev
|
1373
|
* @param {Object} ev
|
|
@@ -1400,48 +1400,48 @@ inherit(MouseInput, Input, { |
|
@@ -1400,48 +1400,48 @@ inherit(MouseInput, Input, { |
1400
|
srcEvent: ev
|
1400
|
srcEvent: ev
|
1401
|
});
|
1401
|
});
|
1402
|
}
|
1402
|
}
|
1403
|
-});
|
1403
|
+ });
|
1404
|
|
1404
|
|
1405
|
-var POINTER_INPUT_MAP = {
|
1405
|
+ var POINTER_INPUT_MAP = {
|
1406
|
pointerdown: INPUT_START,
|
1406
|
pointerdown: INPUT_START,
|
1407
|
pointermove: INPUT_MOVE,
|
1407
|
pointermove: INPUT_MOVE,
|
1408
|
pointerup: INPUT_END,
|
1408
|
pointerup: INPUT_END,
|
1409
|
pointercancel: INPUT_CANCEL,
|
1409
|
pointercancel: INPUT_CANCEL,
|
1410
|
pointerout: INPUT_CANCEL
|
1410
|
pointerout: INPUT_CANCEL
|
1411
|
-};
|
1411
|
+ };
|
1412
|
|
1412
|
|
1413
|
// in IE10 the pointer types is defined as an enum
|
1413
|
// in IE10 the pointer types is defined as an enum
|
1414
|
-var IE10_POINTER_TYPE_ENUM = {
|
1414
|
+ var IE10_POINTER_TYPE_ENUM = {
|
1415
|
2: INPUT_TYPE_TOUCH,
|
1415
|
2: INPUT_TYPE_TOUCH,
|
1416
|
3: INPUT_TYPE_PEN,
|
1416
|
3: INPUT_TYPE_PEN,
|
1417
|
4: INPUT_TYPE_MOUSE,
|
1417
|
4: INPUT_TYPE_MOUSE,
|
1418
|
5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
|
1418
|
5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
|
1419
|
-};
|
1419
|
+ };
|
1420
|
|
1420
|
|
1421
|
-var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
|
|
1422
|
-var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
1421
|
+ var POINTER_ELEMENT_EVENTS = 'pointerdown';
|
|
|
1422
|
+ var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
|
1423
|
|
1423
|
|
1424
|
// IE10 has prefixed support, and case-sensitive
|
1424
|
// IE10 has prefixed support, and case-sensitive
|
1425
|
-if (window.MSPointerEvent && !window.PointerEvent) {
|
1425
|
+ if (window.MSPointerEvent && !window.PointerEvent) {
|
1426
|
POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
1426
|
POINTER_ELEMENT_EVENTS = 'MSPointerDown';
|
1427
|
POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
1427
|
POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
|
1428
|
-}
|
1428
|
+ }
|
1429
|
|
1429
|
|
1430
|
-/**
|
1430
|
+ /**
|
1431
|
* Pointer events input
|
1431
|
* Pointer events input
|
1432
|
* @constructor
|
1432
|
* @constructor
|
1433
|
* @extends Input
|
1433
|
* @extends Input
|
1434
|
*/
|
1434
|
*/
|
1435
|
-function PointerEventInput() {
|
1435
|
+ function PointerEventInput() {
|
1436
|
this.evEl = POINTER_ELEMENT_EVENTS;
|
1436
|
this.evEl = POINTER_ELEMENT_EVENTS;
|
1437
|
this.evWin = POINTER_WINDOW_EVENTS;
|
1437
|
this.evWin = POINTER_WINDOW_EVENTS;
|
1438
|
|
1438
|
|
1439
|
Input.apply(this, arguments);
|
1439
|
Input.apply(this, arguments);
|
1440
|
|
1440
|
|
1441
|
this.store = (this.manager.session.pointerEvents = []);
|
1441
|
this.store = (this.manager.session.pointerEvents = []);
|
1442
|
-}
|
1442
|
+ }
|
1443
|
|
1443
|
|
1444
|
-inherit(PointerEventInput, Input, {
|
1444
|
+ inherit(PointerEventInput, Input, {
|
1445
|
/**
|
1445
|
/**
|
1446
|
* handle mouse events
|
1446
|
* handle mouse events
|
1447
|
* @param {Object} ev
|
1447
|
* @param {Object} ev
|
|
@@ -1489,32 +1489,32 @@ inherit(PointerEventInput, Input, { |
|
@@ -1489,32 +1489,32 @@ inherit(PointerEventInput, Input, { |
1489
|
store.splice(storeIndex, 1);
|
1489
|
store.splice(storeIndex, 1);
|
1490
|
}
|
1490
|
}
|
1491
|
}
|
1491
|
}
|
1492
|
-});
|
1492
|
+ });
|
1493
|
|
1493
|
|
1494
|
-var SINGLE_TOUCH_INPUT_MAP = {
|
1494
|
+ var SINGLE_TOUCH_INPUT_MAP = {
|
1495
|
touchstart: INPUT_START,
|
1495
|
touchstart: INPUT_START,
|
1496
|
touchmove: INPUT_MOVE,
|
1496
|
touchmove: INPUT_MOVE,
|
1497
|
touchend: INPUT_END,
|
1497
|
touchend: INPUT_END,
|
1498
|
touchcancel: INPUT_CANCEL
|
1498
|
touchcancel: INPUT_CANCEL
|
1499
|
-};
|
1499
|
+ };
|
1500
|
|
1500
|
|
1501
|
-var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
|
|
1502
|
-var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
1501
|
+ var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
|
|
|
1502
|
+ var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
|
1503
|
|
1503
|
|
1504
|
-/**
|
1504
|
+ /**
|
1505
|
* Touch events input
|
1505
|
* Touch events input
|
1506
|
* @constructor
|
1506
|
* @constructor
|
1507
|
* @extends Input
|
1507
|
* @extends Input
|
1508
|
*/
|
1508
|
*/
|
1509
|
-function SingleTouchInput() {
|
1509
|
+ function SingleTouchInput() {
|
1510
|
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
1510
|
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
1511
|
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
1511
|
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
1512
|
this.started = false;
|
1512
|
this.started = false;
|
1513
|
|
1513
|
|
1514
|
Input.apply(this, arguments);
|
1514
|
Input.apply(this, arguments);
|
1515
|
-}
|
1515
|
+ }
|
1516
|
|
1516
|
|
1517
|
-inherit(SingleTouchInput, Input, {
|
1517
|
+ inherit(SingleTouchInput, Input, {
|
1518
|
handler: function TEhandler(ev) {
|
1518
|
handler: function TEhandler(ev) {
|
1519
|
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
1519
|
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
1520
|
|
1520
|
|
|
@@ -1541,15 +1541,15 @@ inherit(SingleTouchInput, Input, { |
|
@@ -1541,15 +1541,15 @@ inherit(SingleTouchInput, Input, { |
1541
|
srcEvent: ev
|
1541
|
srcEvent: ev
|
1542
|
});
|
1542
|
});
|
1543
|
}
|
1543
|
}
|
1544
|
-});
|
1544
|
+ });
|
1545
|
|
1545
|
|
1546
|
-/**
|
1546
|
+ /**
|
1547
|
* @this {TouchInput}
|
1547
|
* @this {TouchInput}
|
1548
|
* @param {Object} ev
|
1548
|
* @param {Object} ev
|
1549
|
* @param {Number} type flag
|
1549
|
* @param {Number} type flag
|
1550
|
* @returns {undefined|Array} [all, changed]
|
1550
|
* @returns {undefined|Array} [all, changed]
|
1551
|
*/
|
1551
|
*/
|
1552
|
-function normalizeSingleTouches(ev, type) {
|
1552
|
+ function normalizeSingleTouches(ev, type) {
|
1553
|
var all = toArray(ev.touches);
|
1553
|
var all = toArray(ev.touches);
|
1554
|
var changed = toArray(ev.changedTouches);
|
1554
|
var changed = toArray(ev.changedTouches);
|
1555
|
|
1555
|
|
|
@@ -1558,30 +1558,30 @@ function normalizeSingleTouches(ev, type) { |
|
@@ -1558,30 +1558,30 @@ function normalizeSingleTouches(ev, type) { |
1558
|
}
|
1558
|
}
|
1559
|
|
1559
|
|
1560
|
return [all, changed];
|
1560
|
return [all, changed];
|
1561
|
-}
|
1561
|
+ }
|
1562
|
|
1562
|
|
1563
|
-var TOUCH_INPUT_MAP = {
|
1563
|
+ var TOUCH_INPUT_MAP = {
|
1564
|
touchstart: INPUT_START,
|
1564
|
touchstart: INPUT_START,
|
1565
|
touchmove: INPUT_MOVE,
|
1565
|
touchmove: INPUT_MOVE,
|
1566
|
touchend: INPUT_END,
|
1566
|
touchend: INPUT_END,
|
1567
|
touchcancel: INPUT_CANCEL
|
1567
|
touchcancel: INPUT_CANCEL
|
1568
|
-};
|
1568
|
+ };
|
1569
|
|
1569
|
|
1570
|
-var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
1570
|
+ var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
|
1571
|
|
1571
|
|
1572
|
-/**
|
1572
|
+ /**
|
1573
|
* Multi-user touch events input
|
1573
|
* Multi-user touch events input
|
1574
|
* @constructor
|
1574
|
* @constructor
|
1575
|
* @extends Input
|
1575
|
* @extends Input
|
1576
|
*/
|
1576
|
*/
|
1577
|
-function TouchInput() {
|
1577
|
+ function TouchInput() {
|
1578
|
this.evTarget = TOUCH_TARGET_EVENTS;
|
1578
|
this.evTarget = TOUCH_TARGET_EVENTS;
|
1579
|
this.targetIds = {};
|
1579
|
this.targetIds = {};
|
1580
|
|
1580
|
|
1581
|
Input.apply(this, arguments);
|
1581
|
Input.apply(this, arguments);
|
1582
|
-}
|
1582
|
+ }
|
1583
|
|
1583
|
|
1584
|
-inherit(TouchInput, Input, {
|
1584
|
+ inherit(TouchInput, Input, {
|
1585
|
handler: function MTEhandler(ev) {
|
1585
|
handler: function MTEhandler(ev) {
|
1586
|
var type = TOUCH_INPUT_MAP[ev.type];
|
1586
|
var type = TOUCH_INPUT_MAP[ev.type];
|
1587
|
var touches = getTouches.call(this, ev, type);
|
1587
|
var touches = getTouches.call(this, ev, type);
|
|
@@ -1596,15 +1596,15 @@ inherit(TouchInput, Input, { |
|
@@ -1596,15 +1596,15 @@ inherit(TouchInput, Input, { |
1596
|
srcEvent: ev
|
1596
|
srcEvent: ev
|
1597
|
});
|
1597
|
});
|
1598
|
}
|
1598
|
}
|
1599
|
-});
|
1599
|
+ });
|
1600
|
|
1600
|
|
1601
|
-/**
|
1601
|
+ /**
|
1602
|
* @this {TouchInput}
|
1602
|
* @this {TouchInput}
|
1603
|
* @param {Object} ev
|
1603
|
* @param {Object} ev
|
1604
|
* @param {Number} type flag
|
1604
|
* @param {Number} type flag
|
1605
|
* @returns {undefined|Array} [all, changed]
|
1605
|
* @returns {undefined|Array} [all, changed]
|
1606
|
*/
|
1606
|
*/
|
1607
|
-function getTouches(ev, type) {
|
1607
|
+ function getTouches(ev, type) {
|
1608
|
var allTouches = toArray(ev.touches);
|
1608
|
var allTouches = toArray(ev.touches);
|
1609
|
var targetIds = this.targetIds;
|
1609
|
var targetIds = this.targetIds;
|
1610
|
|
1610
|
|
|
@@ -1657,9 +1657,9 @@ function getTouches(ev, type) { |
|
@@ -1657,9 +1657,9 @@ function getTouches(ev, type) { |
1657
|
uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
1657
|
uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
|
1658
|
changedTargetTouches
|
1658
|
changedTargetTouches
|
1659
|
];
|
1659
|
];
|
1660
|
-}
|
1660
|
+ }
|
1661
|
|
1661
|
|
1662
|
-/**
|
1662
|
+ /**
|
1663
|
* Combined touch and mouse input
|
1663
|
* Combined touch and mouse input
|
1664
|
*
|
1664
|
*
|
1665
|
* Touch has a higher priority then mouse, and while touching no mouse events are allowed.
|
1665
|
* Touch has a higher priority then mouse, and while touching no mouse events are allowed.
|
|
@@ -1669,10 +1669,10 @@ function getTouches(ev, type) { |
|
@@ -1669,10 +1669,10 @@ function getTouches(ev, type) { |
1669
|
* @extends Input
|
1669
|
* @extends Input
|
1670
|
*/
|
1670
|
*/
|
1671
|
|
1671
|
|
1672
|
-var DEDUP_TIMEOUT = 2500;
|
|
|
1673
|
-var DEDUP_DISTANCE = 25;
|
1672
|
+ var DEDUP_TIMEOUT = 2500;
|
|
|
1673
|
+ var DEDUP_DISTANCE = 25;
|
1674
|
|
1674
|
|
1675
|
-function TouchMouseInput() {
|
1675
|
+ function TouchMouseInput() {
|
1676
|
Input.apply(this, arguments);
|
1676
|
Input.apply(this, arguments);
|
1677
|
|
1677
|
|
1678
|
var handler = bindFn(this.handler, this);
|
1678
|
var handler = bindFn(this.handler, this);
|
|
@@ -1681,9 +1681,9 @@ function TouchMouseInput() { |
|
@@ -1681,9 +1681,9 @@ function TouchMouseInput() { |
1681
|
|
1681
|
|
1682
|
this.primaryTouch = null;
|
1682
|
this.primaryTouch = null;
|
1683
|
this.lastTouches = [];
|
1683
|
this.lastTouches = [];
|
1684
|
-}
|
1684
|
+ }
|
1685
|
|
1685
|
|
1686
|
-inherit(TouchMouseInput, Input, {
|
1686
|
+ inherit(TouchMouseInput, Input, {
|
1687
|
/**
|
1687
|
/**
|
1688
|
* handle mouse and touch events
|
1688
|
* handle mouse and touch events
|
1689
|
* @param {Hammer} manager
|
1689
|
* @param {Hammer} manager
|
|
@@ -1715,18 +1715,18 @@ inherit(TouchMouseInput, Input, { |
|
@@ -1715,18 +1715,18 @@ inherit(TouchMouseInput, Input, { |
1715
|
this.touch.destroy();
|
1715
|
this.touch.destroy();
|
1716
|
this.mouse.destroy();
|
1716
|
this.mouse.destroy();
|
1717
|
}
|
1717
|
}
|
1718
|
-});
|
1718
|
+ });
|
1719
|
|
1719
|
|
1720
|
-function recordTouches(eventType, eventData) {
|
1720
|
+ function recordTouches(eventType, eventData) {
|
1721
|
if (eventType & INPUT_START) {
|
1721
|
if (eventType & INPUT_START) {
|
1722
|
this.primaryTouch = eventData.changedPointers[0].identifier;
|
1722
|
this.primaryTouch = eventData.changedPointers[0].identifier;
|
1723
|
setLastTouch.call(this, eventData);
|
1723
|
setLastTouch.call(this, eventData);
|
1724
|
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
1724
|
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
1725
|
setLastTouch.call(this, eventData);
|
1725
|
setLastTouch.call(this, eventData);
|
1726
|
}
|
1726
|
}
|
1727
|
-}
|
1727
|
+ }
|
1728
|
|
1728
|
|
1729
|
-function setLastTouch(eventData) {
|
1729
|
+ function setLastTouch(eventData) {
|
1730
|
var touch = eventData.changedPointers[0];
|
1730
|
var touch = eventData.changedPointers[0];
|
1731
|
|
1731
|
|
1732
|
if (touch.identifier === this.primaryTouch) {
|
1732
|
if (touch.identifier === this.primaryTouch) {
|
|
@@ -1741,9 +1741,9 @@ function setLastTouch(eventData) { |
|
@@ -1741,9 +1741,9 @@ function setLastTouch(eventData) { |
1741
|
};
|
1741
|
};
|
1742
|
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
1742
|
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
1743
|
}
|
1743
|
}
|
1744
|
-}
|
1744
|
+ }
|
1745
|
|
1745
|
|
1746
|
-function isSyntheticEvent(eventData) {
|
1746
|
+ function isSyntheticEvent(eventData) {
|
1747
|
var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
1747
|
var x = eventData.srcEvent.clientX, y = eventData.srcEvent.clientY;
|
1748
|
for (var i = 0; i < this.lastTouches.length; i++) {
|
1748
|
for (var i = 0; i < this.lastTouches.length; i++) {
|
1749
|
var t = this.lastTouches[i];
|
1749
|
var t = this.lastTouches[i];
|
|
@@ -1753,33 +1753,33 @@ function isSyntheticEvent(eventData) { |
|
@@ -1753,33 +1753,33 @@ function isSyntheticEvent(eventData) { |
1753
|
}
|
1753
|
}
|
1754
|
}
|
1754
|
}
|
1755
|
return false;
|
1755
|
return false;
|
1756
|
-}
|
1756
|
+ }
|
1757
|
|
1757
|
|
1758
|
-var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
|
|
1759
|
-var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
1758
|
+ var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
|
|
|
1759
|
+ var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
|
1760
|
|
1760
|
|
1761
|
// magical touchAction value
|
1761
|
// magical touchAction value
|
1762
|
-var TOUCH_ACTION_COMPUTE = 'compute';
|
|
|
1763
|
-var TOUCH_ACTION_AUTO = 'auto';
|
|
|
1764
|
-var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
|
|
|
1765
|
-var TOUCH_ACTION_NONE = 'none';
|
|
|
1766
|
-var TOUCH_ACTION_PAN_X = 'pan-x';
|
|
|
1767
|
-var TOUCH_ACTION_PAN_Y = 'pan-y';
|
|
|
1768
|
-var TOUCH_ACTION_MAP = getTouchActionProps();
|
1762
|
+ var TOUCH_ACTION_COMPUTE = 'compute';
|
|
|
1763
|
+ var TOUCH_ACTION_AUTO = 'auto';
|
|
|
1764
|
+ var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
|
|
|
1765
|
+ var TOUCH_ACTION_NONE = 'none';
|
|
|
1766
|
+ var TOUCH_ACTION_PAN_X = 'pan-x';
|
|
|
1767
|
+ var TOUCH_ACTION_PAN_Y = 'pan-y';
|
|
|
1768
|
+ var TOUCH_ACTION_MAP = getTouchActionProps();
|
1769
|
|
1769
|
|
1770
|
-/**
|
1770
|
+ /**
|
1771
|
* Touch Action
|
1771
|
* Touch Action
|
1772
|
* sets the touchAction property or uses the js alternative
|
1772
|
* sets the touchAction property or uses the js alternative
|
1773
|
* @param {Manager} manager
|
1773
|
* @param {Manager} manager
|
1774
|
* @param {String} value
|
1774
|
* @param {String} value
|
1775
|
* @constructor
|
1775
|
* @constructor
|
1776
|
*/
|
1776
|
*/
|
1777
|
-function TouchAction(manager, value) {
|
1777
|
+ function TouchAction(manager, value) {
|
1778
|
this.manager = manager;
|
1778
|
this.manager = manager;
|
1779
|
this.set(value);
|
1779
|
this.set(value);
|
1780
|
-}
|
1780
|
+ }
|
1781
|
|
1781
|
|
1782
|
-TouchAction.prototype = {
|
1782
|
+ TouchAction.prototype = {
|
1783
|
/**
|
1783
|
/**
|
1784
|
* set the touchAction value on the element or enable the polyfill
|
1784
|
* set the touchAction value on the element or enable the polyfill
|
1785
|
* @param {String} value
|
1785
|
* @param {String} value
|
|
@@ -1868,14 +1868,14 @@ TouchAction.prototype = { |
|
@@ -1868,14 +1868,14 @@ TouchAction.prototype = { |
1868
|
this.manager.session.prevented = true;
|
1868
|
this.manager.session.prevented = true;
|
1869
|
srcEvent.preventDefault();
|
1869
|
srcEvent.preventDefault();
|
1870
|
}
|
1870
|
}
|
1871
|
-};
|
1871
|
+ };
|
1872
|
|
1872
|
|
1873
|
-/**
|
1873
|
+ /**
|
1874
|
* when the touchActions are collected they are not a valid value, so we need to clean things up. *
|
1874
|
* when the touchActions are collected they are not a valid value, so we need to clean things up. *
|
1875
|
* @param {String} actions
|
1875
|
* @param {String} actions
|
1876
|
* @returns {*}
|
1876
|
* @returns {*}
|
1877
|
*/
|
1877
|
*/
|
1878
|
-function cleanTouchActions(actions) {
|
1878
|
+ function cleanTouchActions(actions) {
|
1879
|
// none
|
1879
|
// none
|
1880
|
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
1880
|
if (inStr(actions, TOUCH_ACTION_NONE)) {
|
1881
|
return TOUCH_ACTION_NONE;
|
1881
|
return TOUCH_ACTION_NONE;
|
|
@@ -1903,9 +1903,9 @@ function cleanTouchActions(actions) { |
|
@@ -1903,9 +1903,9 @@ function cleanTouchActions(actions) { |
1903
|
}
|
1903
|
}
|
1904
|
|
1904
|
|
1905
|
return TOUCH_ACTION_AUTO;
|
1905
|
return TOUCH_ACTION_AUTO;
|
1906
|
-}
|
1906
|
+ }
|
1907
|
|
1907
|
|
1908
|
-function getTouchActionProps() {
|
1908
|
+ function getTouchActionProps() {
|
1909
|
if (!NATIVE_TOUCH_ACTION) {
|
1909
|
if (!NATIVE_TOUCH_ACTION) {
|
1910
|
return false;
|
1910
|
return false;
|
1911
|
}
|
1911
|
}
|
|
@@ -1918,9 +1918,9 @@ function getTouchActionProps() { |
|
@@ -1918,9 +1918,9 @@ function getTouchActionProps() { |
1918
|
touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
1918
|
touchMap[val] = cssSupports ? window.CSS.supports('touch-action', val) : true;
|
1919
|
});
|
1919
|
});
|
1920
|
return touchMap;
|
1920
|
return touchMap;
|
1921
|
-}
|
1921
|
+ }
|
1922
|
|
1922
|
|
1923
|
-/**
|
1923
|
+ /**
|
1924
|
* Recognizer flow explained; *
|
1924
|
* Recognizer flow explained; *
|
1925
|
* All recognizers have the initial state of POSSIBLE when a input session starts.
|
1925
|
* All recognizers have the initial state of POSSIBLE when a input session starts.
|
1926
|
* The definition of a input session is from the first input until the last input, with all it's movement in it. *
|
1926
|
* The definition of a input session is from the first input until the last input, with all it's movement in it. *
|
|
@@ -1947,21 +1947,21 @@ function getTouchActionProps() { |
|
@@ -1947,21 +1947,21 @@ function getTouchActionProps() { |
1947
|
* |
|
1947
|
* |
|
1948
|
* Ended/Recognized
|
1948
|
* Ended/Recognized
|
1949
|
*/
|
1949
|
*/
|
1950
|
-var STATE_POSSIBLE = 1;
|
|
|
1951
|
-var STATE_BEGAN = 2;
|
|
|
1952
|
-var STATE_CHANGED = 4;
|
|
|
1953
|
-var STATE_ENDED = 8;
|
|
|
1954
|
-var STATE_RECOGNIZED = STATE_ENDED;
|
|
|
1955
|
-var STATE_CANCELLED = 16;
|
|
|
1956
|
-var STATE_FAILED = 32;
|
1950
|
+ var STATE_POSSIBLE = 1;
|
|
|
1951
|
+ var STATE_BEGAN = 2;
|
|
|
1952
|
+ var STATE_CHANGED = 4;
|
|
|
1953
|
+ var STATE_ENDED = 8;
|
|
|
1954
|
+ var STATE_RECOGNIZED = STATE_ENDED;
|
|
|
1955
|
+ var STATE_CANCELLED = 16;
|
|
|
1956
|
+ var STATE_FAILED = 32;
|
1957
|
|
1957
|
|
1958
|
-/**
|
1958
|
+ /**
|
1959
|
* Recognizer
|
1959
|
* Recognizer
|
1960
|
* Every recognizer needs to extend from this class.
|
1960
|
* Every recognizer needs to extend from this class.
|
1961
|
* @constructor
|
1961
|
* @constructor
|
1962
|
* @param {Object} options
|
1962
|
* @param {Object} options
|
1963
|
*/
|
1963
|
*/
|
1964
|
-function Recognizer(options) {
|
1964
|
+ function Recognizer(options) {
|
1965
|
this.options = assign({}, this.defaults, options || {});
|
1965
|
this.options = assign({}, this.defaults, options || {});
|
1966
|
|
1966
|
|
1967
|
this.id = uniqueId();
|
1967
|
this.id = uniqueId();
|
|
@@ -1975,9 +1975,9 @@ function Recognizer(options) { |
|
@@ -1975,9 +1975,9 @@ function Recognizer(options) { |
1975
|
|
1975
|
|
1976
|
this.simultaneous = {};
|
1976
|
this.simultaneous = {};
|
1977
|
this.requireFail = [];
|
1977
|
this.requireFail = [];
|
1978
|
-}
|
1978
|
+ }
|
1979
|
|
1979
|
|
1980
|
-Recognizer.prototype = {
|
1980
|
+ Recognizer.prototype = {
|
1981
|
/**
|
1981
|
/**
|
1982
|
* @virtual
|
1982
|
* @virtual
|
1983
|
* @type {Object}
|
1983
|
* @type {Object}
|
|
@@ -2196,14 +2196,14 @@ Recognizer.prototype = { |
|
@@ -2196,14 +2196,14 @@ Recognizer.prototype = { |
2196
|
* @virtual
|
2196
|
* @virtual
|
2197
|
*/
|
2197
|
*/
|
2198
|
reset: function() { }
|
2198
|
reset: function() { }
|
2199
|
-};
|
2199
|
+ };
|
2200
|
|
2200
|
|
2201
|
-/**
|
2201
|
+ /**
|
2202
|
* get a usable string, used as event postfix
|
2202
|
* get a usable string, used as event postfix
|
2203
|
* @param {Const} state
|
2203
|
* @param {Const} state
|
2204
|
* @returns {String} state
|
2204
|
* @returns {String} state
|
2205
|
*/
|
2205
|
*/
|
2206
|
-function stateStr(state) {
|
2206
|
+ function stateStr(state) {
|
2207
|
if (state & STATE_CANCELLED) {
|
2207
|
if (state & STATE_CANCELLED) {
|
2208
|
return 'cancel';
|
2208
|
return 'cancel';
|
2209
|
} else if (state & STATE_ENDED) {
|
2209
|
} else if (state & STATE_ENDED) {
|
|
@@ -2214,14 +2214,14 @@ function stateStr(state) { |
|
@@ -2214,14 +2214,14 @@ function stateStr(state) { |
2214
|
return 'start';
|
2214
|
return 'start';
|
2215
|
}
|
2215
|
}
|
2216
|
return '';
|
2216
|
return '';
|
2217
|
-}
|
2217
|
+ }
|
2218
|
|
2218
|
|
2219
|
-/**
|
2219
|
+ /**
|
2220
|
* direction cons to string
|
2220
|
* direction cons to string
|
2221
|
* @param {Const} direction
|
2221
|
* @param {Const} direction
|
2222
|
* @returns {String}
|
2222
|
* @returns {String}
|
2223
|
*/
|
2223
|
*/
|
2224
|
-function directionStr(direction) {
|
2224
|
+ function directionStr(direction) {
|
2225
|
if (direction == DIRECTION_DOWN) {
|
2225
|
if (direction == DIRECTION_DOWN) {
|
2226
|
return 'down';
|
2226
|
return 'down';
|
2227
|
} else if (direction == DIRECTION_UP) {
|
2227
|
} else if (direction == DIRECTION_UP) {
|
|
@@ -2232,32 +2232,32 @@ function directionStr(direction) { |
|
@@ -2232,32 +2232,32 @@ function directionStr(direction) { |
2232
|
return 'right';
|
2232
|
return 'right';
|
2233
|
}
|
2233
|
}
|
2234
|
return '';
|
2234
|
return '';
|
2235
|
-}
|
2235
|
+ }
|
2236
|
|
2236
|
|
2237
|
-/**
|
2237
|
+ /**
|
2238
|
* get a recognizer by name if it is bound to a manager
|
2238
|
* get a recognizer by name if it is bound to a manager
|
2239
|
* @param {Recognizer|String} otherRecognizer
|
2239
|
* @param {Recognizer|String} otherRecognizer
|
2240
|
* @param {Recognizer} recognizer
|
2240
|
* @param {Recognizer} recognizer
|
2241
|
* @returns {Recognizer}
|
2241
|
* @returns {Recognizer}
|
2242
|
*/
|
2242
|
*/
|
2243
|
-function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
2243
|
+ function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
2244
|
var manager = recognizer.manager;
|
2244
|
var manager = recognizer.manager;
|
2245
|
if (manager) {
|
2245
|
if (manager) {
|
2246
|
return manager.get(otherRecognizer);
|
2246
|
return manager.get(otherRecognizer);
|
2247
|
}
|
2247
|
}
|
2248
|
return otherRecognizer;
|
2248
|
return otherRecognizer;
|
2249
|
-}
|
2249
|
+ }
|
2250
|
|
2250
|
|
2251
|
-/**
|
2251
|
+ /**
|
2252
|
* This recognizer is just used as a base for the simple attribute recognizers.
|
2252
|
* This recognizer is just used as a base for the simple attribute recognizers.
|
2253
|
* @constructor
|
2253
|
* @constructor
|
2254
|
* @extends Recognizer
|
2254
|
* @extends Recognizer
|
2255
|
*/
|
2255
|
*/
|
2256
|
-function AttrRecognizer() {
|
2256
|
+ function AttrRecognizer() {
|
2257
|
Recognizer.apply(this, arguments);
|
2257
|
Recognizer.apply(this, arguments);
|
2258
|
-}
|
2258
|
+ }
|
2259
|
|
2259
|
|
2260
|
-inherit(AttrRecognizer, Recognizer, {
|
2260
|
+ inherit(AttrRecognizer, Recognizer, {
|
2261
|
/**
|
2261
|
/**
|
2262
|
* @namespace
|
2262
|
* @namespace
|
2263
|
* @memberof AttrRecognizer
|
2263
|
* @memberof AttrRecognizer
|
|
@@ -2307,22 +2307,22 @@ inherit(AttrRecognizer, Recognizer, { |
|
@@ -2307,22 +2307,22 @@ inherit(AttrRecognizer, Recognizer, { |
2307
|
}
|
2307
|
}
|
2308
|
return STATE_FAILED;
|
2308
|
return STATE_FAILED;
|
2309
|
}
|
2309
|
}
|
2310
|
-});
|
2310
|
+ });
|
2311
|
|
2311
|
|
2312
|
-/**
|
2312
|
+ /**
|
2313
|
* Pan
|
2313
|
* Pan
|
2314
|
* Recognized when the pointer is down and moved in the allowed direction.
|
2314
|
* Recognized when the pointer is down and moved in the allowed direction.
|
2315
|
* @constructor
|
2315
|
* @constructor
|
2316
|
* @extends AttrRecognizer
|
2316
|
* @extends AttrRecognizer
|
2317
|
*/
|
2317
|
*/
|
2318
|
-function PanRecognizer() {
|
2318
|
+ function PanRecognizer() {
|
2319
|
AttrRecognizer.apply(this, arguments);
|
2319
|
AttrRecognizer.apply(this, arguments);
|
2320
|
|
2320
|
|
2321
|
this.pX = null;
|
2321
|
this.pX = null;
|
2322
|
this.pY = null;
|
2322
|
this.pY = null;
|
2323
|
-}
|
2323
|
+ }
|
2324
|
|
2324
|
|
2325
|
-inherit(PanRecognizer, AttrRecognizer, {
|
2325
|
+ inherit(PanRecognizer, AttrRecognizer, {
|
2326
|
/**
|
2326
|
/**
|
2327
|
* @namespace
|
2327
|
* @namespace
|
2328
|
* @memberof PanRecognizer
|
2328
|
* @memberof PanRecognizer
|
|
@@ -2387,19 +2387,19 @@ inherit(PanRecognizer, AttrRecognizer, { |
|
@@ -2387,19 +2387,19 @@ inherit(PanRecognizer, AttrRecognizer, { |
2387
|
}
|
2387
|
}
|
2388
|
this._super.emit.call(this, input);
|
2388
|
this._super.emit.call(this, input);
|
2389
|
}
|
2389
|
}
|
2390
|
-});
|
2390
|
+ });
|
2391
|
|
2391
|
|
2392
|
-/**
|
2392
|
+ /**
|
2393
|
* Pinch
|
2393
|
* Pinch
|
2394
|
* Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
|
2394
|
* Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
|
2395
|
* @constructor
|
2395
|
* @constructor
|
2396
|
* @extends AttrRecognizer
|
2396
|
* @extends AttrRecognizer
|
2397
|
*/
|
2397
|
*/
|
2398
|
-function PinchRecognizer() {
|
2398
|
+ function PinchRecognizer() {
|
2399
|
AttrRecognizer.apply(this, arguments);
|
2399
|
AttrRecognizer.apply(this, arguments);
|
2400
|
-}
|
2400
|
+ }
|
2401
|
|
2401
|
|
2402
|
-inherit(PinchRecognizer, AttrRecognizer, {
|
2402
|
+ inherit(PinchRecognizer, AttrRecognizer, {
|
2403
|
/**
|
2403
|
/**
|
2404
|
* @namespace
|
2404
|
* @namespace
|
2405
|
* @memberof PinchRecognizer
|
2405
|
* @memberof PinchRecognizer
|
|
@@ -2426,22 +2426,22 @@ inherit(PinchRecognizer, AttrRecognizer, { |
|
@@ -2426,22 +2426,22 @@ inherit(PinchRecognizer, AttrRecognizer, { |
2426
|
}
|
2426
|
}
|
2427
|
this._super.emit.call(this, input);
|
2427
|
this._super.emit.call(this, input);
|
2428
|
}
|
2428
|
}
|
2429
|
-});
|
2429
|
+ });
|
2430
|
|
2430
|
|
2431
|
-/**
|
2431
|
+ /**
|
2432
|
* Press
|
2432
|
* Press
|
2433
|
* Recognized when the pointer is down for x ms without any movement.
|
2433
|
* Recognized when the pointer is down for x ms without any movement.
|
2434
|
* @constructor
|
2434
|
* @constructor
|
2435
|
* @extends Recognizer
|
2435
|
* @extends Recognizer
|
2436
|
*/
|
2436
|
*/
|
2437
|
-function PressRecognizer() {
|
2437
|
+ function PressRecognizer() {
|
2438
|
Recognizer.apply(this, arguments);
|
2438
|
Recognizer.apply(this, arguments);
|
2439
|
|
2439
|
|
2440
|
this._timer = null;
|
2440
|
this._timer = null;
|
2441
|
this._input = null;
|
2441
|
this._input = null;
|
2442
|
-}
|
2442
|
+ }
|
2443
|
|
2443
|
|
2444
|
-inherit(PressRecognizer, Recognizer, {
|
2444
|
+ inherit(PressRecognizer, Recognizer, {
|
2445
|
/**
|
2445
|
/**
|
2446
|
* @namespace
|
2446
|
* @namespace
|
2447
|
* @memberof PressRecognizer
|
2447
|
* @memberof PressRecognizer
|
|
@@ -2497,19 +2497,19 @@ inherit(PressRecognizer, Recognizer, { |
|
@@ -2497,19 +2497,19 @@ inherit(PressRecognizer, Recognizer, { |
2497
|
this.manager.emit(this.options.event, this._input);
|
2497
|
this.manager.emit(this.options.event, this._input);
|
2498
|
}
|
2498
|
}
|
2499
|
}
|
2499
|
}
|
2500
|
-});
|
2500
|
+ });
|
2501
|
|
2501
|
|
2502
|
-/**
|
2502
|
+ /**
|
2503
|
* Rotate
|
2503
|
* Rotate
|
2504
|
* Recognized when two or more pointer are moving in a circular motion.
|
2504
|
* Recognized when two or more pointer are moving in a circular motion.
|
2505
|
* @constructor
|
2505
|
* @constructor
|
2506
|
* @extends AttrRecognizer
|
2506
|
* @extends AttrRecognizer
|
2507
|
*/
|
2507
|
*/
|
2508
|
-function RotateRecognizer() {
|
2508
|
+ function RotateRecognizer() {
|
2509
|
AttrRecognizer.apply(this, arguments);
|
2509
|
AttrRecognizer.apply(this, arguments);
|
2510
|
-}
|
2510
|
+ }
|
2511
|
|
2511
|
|
2512
|
-inherit(RotateRecognizer, AttrRecognizer, {
|
2512
|
+ inherit(RotateRecognizer, AttrRecognizer, {
|
2513
|
/**
|
2513
|
/**
|
2514
|
* @namespace
|
2514
|
* @namespace
|
2515
|
* @memberof RotateRecognizer
|
2515
|
* @memberof RotateRecognizer
|
|
@@ -2528,19 +2528,19 @@ inherit(RotateRecognizer, AttrRecognizer, { |
|
@@ -2528,19 +2528,19 @@ inherit(RotateRecognizer, AttrRecognizer, { |
2528
|
return this._super.attrTest.call(this, input) &&
|
2528
|
return this._super.attrTest.call(this, input) &&
|
2529
|
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
2529
|
(Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
2530
|
}
|
2530
|
}
|
2531
|
-});
|
2531
|
+ });
|
2532
|
|
2532
|
|
2533
|
-/**
|
2533
|
+ /**
|
2534
|
* Swipe
|
2534
|
* Swipe
|
2535
|
* Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
|
2535
|
* Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
|
2536
|
* @constructor
|
2536
|
* @constructor
|
2537
|
* @extends AttrRecognizer
|
2537
|
* @extends AttrRecognizer
|
2538
|
*/
|
2538
|
*/
|
2539
|
-function SwipeRecognizer() {
|
2539
|
+ function SwipeRecognizer() {
|
2540
|
AttrRecognizer.apply(this, arguments);
|
2540
|
AttrRecognizer.apply(this, arguments);
|
2541
|
-}
|
2541
|
+ }
|
2542
|
|
2542
|
|
2543
|
-inherit(SwipeRecognizer, AttrRecognizer, {
|
2543
|
+ inherit(SwipeRecognizer, AttrRecognizer, {
|
2544
|
/**
|
2544
|
/**
|
2545
|
* @namespace
|
2545
|
* @namespace
|
2546
|
* @memberof SwipeRecognizer
|
2546
|
* @memberof SwipeRecognizer
|
|
@@ -2584,9 +2584,9 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
|
@@ -2584,9 +2584,9 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
2584
|
|
2584
|
|
2585
|
this.manager.emit(this.options.event, input);
|
2585
|
this.manager.emit(this.options.event, input);
|
2586
|
}
|
2586
|
}
|
2587
|
-});
|
2587
|
+ });
|
2588
|
|
2588
|
|
2589
|
-/**
|
2589
|
+ /**
|
2590
|
* A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
|
2590
|
* A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
|
2591
|
* between the given interval and position. The delay option can be used to recognize multi-taps without firing
|
2591
|
* between the given interval and position. The delay option can be used to recognize multi-taps without firing
|
2592
|
* a single tap.
|
2592
|
* a single tap.
|
|
@@ -2596,7 +2596,7 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
|
@@ -2596,7 +2596,7 @@ inherit(SwipeRecognizer, AttrRecognizer, { |
2596
|
* @constructor
|
2596
|
* @constructor
|
2597
|
* @extends Recognizer
|
2597
|
* @extends Recognizer
|
2598
|
*/
|
2598
|
*/
|
2599
|
-function TapRecognizer() {
|
2599
|
+ function TapRecognizer() {
|
2600
|
Recognizer.apply(this, arguments);
|
2600
|
Recognizer.apply(this, arguments);
|
2601
|
|
2601
|
|
2602
|
// previous time and center,
|
2602
|
// previous time and center,
|
|
@@ -2607,9 +2607,9 @@ function TapRecognizer() { |
|
@@ -2607,9 +2607,9 @@ function TapRecognizer() { |
2607
|
this._timer = null;
|
2607
|
this._timer = null;
|
2608
|
this._input = null;
|
2608
|
this._input = null;
|
2609
|
this.count = 0;
|
2609
|
this.count = 0;
|
2610
|
-}
|
2610
|
+ }
|
2611
|
|
2611
|
|
2612
|
-inherit(TapRecognizer, Recognizer, {
|
2612
|
+ inherit(TapRecognizer, Recognizer, {
|
2613
|
/**
|
2613
|
/**
|
2614
|
* @namespace
|
2614
|
* @namespace
|
2615
|
* @memberof PinchRecognizer
|
2615
|
* @memberof PinchRecognizer
|
|
@@ -2699,30 +2699,30 @@ inherit(TapRecognizer, Recognizer, { |
|
@@ -2699,30 +2699,30 @@ inherit(TapRecognizer, Recognizer, { |
2699
|
this.manager.emit(this.options.event, this._input);
|
2699
|
this.manager.emit(this.options.event, this._input);
|
2700
|
}
|
2700
|
}
|
2701
|
}
|
2701
|
}
|
2702
|
-});
|
2702
|
+ });
|
2703
|
|
2703
|
|
2704
|
-/**
|
2704
|
+ /**
|
2705
|
* Simple way to create a manager with a default set of recognizers.
|
2705
|
* Simple way to create a manager with a default set of recognizers.
|
2706
|
* @param {HTMLElement} element
|
2706
|
* @param {HTMLElement} element
|
2707
|
* @param {Object} [options]
|
2707
|
* @param {Object} [options]
|
2708
|
* @constructor
|
2708
|
* @constructor
|
2709
|
*/
|
2709
|
*/
|
2710
|
-function Hammer(element, options) {
|
2710
|
+ function Hammer(element, options) {
|
2711
|
options = options || {};
|
2711
|
options = options || {};
|
2712
|
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
2712
|
options.recognizers = ifUndefined(options.recognizers, Hammer.defaults.preset);
|
2713
|
return new Manager(element, options);
|
2713
|
return new Manager(element, options);
|
2714
|
-}
|
2714
|
+ }
|
2715
|
|
2715
|
|
2716
|
-/**
|
2716
|
+ /**
|
2717
|
* @const {string}
|
2717
|
* @const {string}
|
2718
|
*/
|
2718
|
*/
|
2719
|
-Hammer.VERSION = '2.0.8';
|
2719
|
+ Hammer.VERSION = '2.0.8';
|
2720
|
|
2720
|
|
2721
|
-/**
|
2721
|
+ /**
|
2722
|
* default settings
|
2722
|
* default settings
|
2723
|
* @namespace
|
2723
|
* @namespace
|
2724
|
*/
|
2724
|
*/
|
2725
|
-Hammer.defaults = {
|
2725
|
+ Hammer.defaults = {
|
2726
|
/**
|
2726
|
/**
|
2727
|
* set if DOM events are being triggered.
|
2727
|
* set if DOM events are being triggered.
|
2728
|
* But this is slower and unused by simple implementations, so disabled by default.
|
2728
|
* But this is slower and unused by simple implementations, so disabled by default.
|
|
@@ -2828,18 +2828,18 @@ Hammer.defaults = { |
|
@@ -2828,18 +2828,18 @@ Hammer.defaults = { |
2828
|
*/
|
2828
|
*/
|
2829
|
tapHighlightColor: 'rgba(0,0,0,0)'
|
2829
|
tapHighlightColor: 'rgba(0,0,0,0)'
|
2830
|
}
|
2830
|
}
|
2831
|
-};
|
2831
|
+ };
|
2832
|
|
2832
|
|
2833
|
-var STOP = 1;
|
|
|
2834
|
-var FORCED_STOP = 2;
|
2833
|
+ var STOP = 1;
|
|
|
2834
|
+ var FORCED_STOP = 2;
|
2835
|
|
2835
|
|
2836
|
-/**
|
2836
|
+ /**
|
2837
|
* Manager
|
2837
|
* Manager
|
2838
|
* @param {HTMLElement} element
|
2838
|
* @param {HTMLElement} element
|
2839
|
* @param {Object} [options]
|
2839
|
* @param {Object} [options]
|
2840
|
* @constructor
|
2840
|
* @constructor
|
2841
|
*/
|
2841
|
*/
|
2842
|
-function Manager(element, options) {
|
2842
|
+ function Manager(element, options) {
|
2843
|
this.options = assign({}, Hammer.defaults, options || {});
|
2843
|
this.options = assign({}, Hammer.defaults, options || {});
|
2844
|
|
2844
|
|
2845
|
this.options.inputTarget = this.options.inputTarget || element;
|
2845
|
this.options.inputTarget = this.options.inputTarget || element;
|
|
@@ -2860,9 +2860,9 @@ function Manager(element, options) { |
|
@@ -2860,9 +2860,9 @@ function Manager(element, options) { |
2860
|
item[2] && recognizer.recognizeWith(item[2]);
|
2860
|
item[2] && recognizer.recognizeWith(item[2]);
|
2861
|
item[3] && recognizer.requireFailure(item[3]);
|
2861
|
item[3] && recognizer.requireFailure(item[3]);
|
2862
|
}, this);
|
2862
|
}, this);
|
2863
|
-}
|
2863
|
+ }
|
2864
|
|
2864
|
|
2865
|
-Manager.prototype = {
|
2865
|
+ Manager.prototype = {
|
2866
|
/**
|
2866
|
/**
|
2867
|
* set options
|
2867
|
* set options
|
2868
|
* @param {Object} options
|
2868
|
* @param {Object} options
|
|
@@ -3104,14 +3104,14 @@ Manager.prototype = { |
|
@@ -3104,14 +3104,14 @@ Manager.prototype = { |
3104
|
this.input.destroy();
|
3104
|
this.input.destroy();
|
3105
|
this.element = null;
|
3105
|
this.element = null;
|
3106
|
}
|
3106
|
}
|
3107
|
-};
|
3107
|
+ };
|
3108
|
|
3108
|
|
3109
|
-/**
|
3109
|
+ /**
|
3110
|
* add/remove the css properties as defined in manager.options.cssProps
|
3110
|
* add/remove the css properties as defined in manager.options.cssProps
|
3111
|
* @param {Manager} manager
|
3111
|
* @param {Manager} manager
|
3112
|
* @param {Boolean} add
|
3112
|
* @param {Boolean} add
|
3113
|
*/
|
3113
|
*/
|
3114
|
-function toggleCssProps(manager, add) {
|
3114
|
+ function toggleCssProps(manager, add) {
|
3115
|
var element = manager.element;
|
3115
|
var element = manager.element;
|
3116
|
if (!element.style) {
|
3116
|
if (!element.style) {
|
3117
|
return;
|
3117
|
return;
|
|
@@ -3129,21 +3129,21 @@ function toggleCssProps(manager, add) { |
|
@@ -3129,21 +3129,21 @@ function toggleCssProps(manager, add) { |
3129
|
if (!add) {
|
3129
|
if (!add) {
|
3130
|
manager.oldCssProps = {};
|
3130
|
manager.oldCssProps = {};
|
3131
|
}
|
3131
|
}
|
3132
|
-}
|
3132
|
+ }
|
3133
|
|
3133
|
|
3134
|
-/**
|
3134
|
+ /**
|
3135
|
* trigger dom event
|
3135
|
* trigger dom event
|
3136
|
* @param {String} event
|
3136
|
* @param {String} event
|
3137
|
* @param {Object} data
|
3137
|
* @param {Object} data
|
3138
|
*/
|
3138
|
*/
|
3139
|
-function triggerDomEvent(event, data) {
|
3139
|
+ function triggerDomEvent(event, data) {
|
3140
|
var gestureEvent = document.createEvent('Event');
|
3140
|
var gestureEvent = document.createEvent('Event');
|
3141
|
gestureEvent.initEvent(event, true, true);
|
3141
|
gestureEvent.initEvent(event, true, true);
|
3142
|
gestureEvent.gesture = data;
|
3142
|
gestureEvent.gesture = data;
|
3143
|
data.target.dispatchEvent(gestureEvent);
|
3143
|
data.target.dispatchEvent(gestureEvent);
|
3144
|
-}
|
3144
|
+ }
|
3145
|
|
3145
|
|
3146
|
-assign(Hammer, {
|
3146
|
+ assign(Hammer, {
|
3147
|
INPUT_START: INPUT_START,
|
3147
|
INPUT_START: INPUT_START,
|
3148
|
INPUT_MOVE: INPUT_MOVE,
|
3148
|
INPUT_MOVE: INPUT_MOVE,
|
3149
|
INPUT_END: INPUT_END,
|
3149
|
INPUT_END: INPUT_END,
|
|
@@ -3194,22 +3194,22 @@ assign(Hammer, { |
|
@@ -3194,22 +3194,22 @@ assign(Hammer, { |
3194
|
inherit: inherit,
|
3194
|
inherit: inherit,
|
3195
|
bindFn: bindFn,
|
3195
|
bindFn: bindFn,
|
3196
|
prefixed: prefixed
|
3196
|
prefixed: prefixed
|
3197
|
-});
|
3197
|
+ });
|
3198
|
|
3198
|
|
3199
|
// this prevents errors when Hammer is loaded in the presence of an AMD
|
3199
|
// this prevents errors when Hammer is loaded in the presence of an AMD
|
3200
|
// style loader but by script tag, not by the loader.
|
3200
|
// style loader but by script tag, not by the loader.
|
3201
|
-var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
|
|
|
3202
|
-freeGlobal.Hammer = Hammer;
|
3201
|
+ var freeGlobal = (typeof window !== 'undefined' ? window : (typeof self !== 'undefined' ? self : {})); // jshint ignore:line
|
|
|
3202
|
+ freeGlobal.Hammer = Hammer;
|
3203
|
|
3203
|
|
3204
|
-if (typeof define === 'function' && define.amd) {
|
3204
|
+ if (typeof define === 'function' && define.amd) {
|
3205
|
define(function() {
|
3205
|
define(function() {
|
3206
|
return Hammer;
|
3206
|
return Hammer;
|
3207
|
});
|
3207
|
});
|
3208
|
-} else if (typeof module != 'undefined' && module.exports) {
|
3208
|
+ } else if (typeof module != 'undefined' && module.exports) {
|
3209
|
module.exports = Hammer;
|
3209
|
module.exports = Hammer;
|
3210
|
-} else {
|
3210
|
+ } else {
|
3211
|
window[exportName] = Hammer;
|
3211
|
window[exportName] = Hammer;
|
3212
|
-}
|
3212
|
+ }
|
3213
|
|
3213
|
|
3214
|
})(window, document, 'Hammer');
|
3214
|
})(window, document, 'Hammer');
|
3215
|
|
3215
|
|
|
@@ -3640,8 +3640,8 @@ if (typeof define === 'function' && define.amd) { |
|
@@ -3640,8 +3640,8 @@ if (typeof define === 'function' && define.amd) { |
3640
|
}($);
|
3640
|
}($);
|
3641
|
|
3641
|
|
3642
|
/* ===============================================================================
|
3642
|
/* ===============================================================================
|
3643
|
-************ Pull to refreh ************
|
|
|
3644
|
-=============================================================================== */
|
3643
|
+ ************ Pull to refreh ************
|
|
|
3644
|
+ =============================================================================== */
|
3645
|
/* global $:true */
|
3645
|
/* global $:true */
|
3646
|
|
3646
|
|
3647
|
+function ($) {
|
3647
|
+function ($) {
|
|
@@ -3761,8 +3761,8 @@ if (typeof define === 'function' && define.amd) { |
|
@@ -3761,8 +3761,8 @@ if (typeof define === 'function' && define.amd) { |
3761
|
}($);
|
3761
|
}($);
|
3762
|
|
3762
|
|
3763
|
/* ===============================================================================
|
3763
|
/* ===============================================================================
|
3764
|
-************ Infinite ************
|
|
|
3765
|
-=============================================================================== */
|
3764
|
+ ************ Infinite ************
|
|
|
3765
|
+ =============================================================================== */
|
3766
|
/* global $:true */
|
3766
|
/* global $:true */
|
3767
|
+function ($) {
|
3767
|
+function ($) {
|
3768
|
"use strict";
|
3768
|
"use strict";
|
|
@@ -3889,8 +3889,8 @@ if (typeof define === 'function' && define.amd) { |
|
@@ -3889,8 +3889,8 @@ if (typeof define === 'function' && define.amd) { |
3889
|
}($);
|
3889
|
}($);
|
3890
|
|
3890
|
|
3891
|
/*===========================
|
3891
|
/*===========================
|
3892
|
-Device/OS Detection
|
|
|
3893
|
-===========================*/
|
3892
|
+ Device/OS Detection
|
|
|
3893
|
+ ===========================*/
|
3894
|
/* global $:true */
|
3894
|
/* global $:true */
|
3895
|
;(function ($) {
|
3895
|
;(function ($) {
|
3896
|
"use strict";
|
3896
|
"use strict";
|
|
@@ -3994,8 +3994,8 @@ Device/OS Detection |
|
@@ -3994,8 +3994,8 @@ Device/OS Detection |
3994
|
})($);
|
3994
|
})($);
|
3995
|
|
3995
|
|
3996
|
/*======================================================
|
3996
|
/*======================================================
|
3997
|
-************ Picker ************
|
|
|
3998
|
-======================================================*/
|
3997
|
+ ************ Picker ************
|
|
|
3998
|
+ ======================================================*/
|
3999
|
/* global $:true */
|
3999
|
/* global $:true */
|
4000
|
/* jshint unused:false */
|
4000
|
/* jshint unused:false */
|
4001
|
/* jshint multistr:true */
|
4001
|
/* jshint multistr:true */
|
|
@@ -4962,8 +4962,8 @@ Device/OS Detection |
|
@@ -4962,8 +4962,8 @@ Device/OS Detection |
4962
|
}($);
|
4962
|
}($);
|
4963
|
|
4963
|
|
4964
|
/*======================================================
|
4964
|
/*======================================================
|
4965
|
-************ Calendar ************
|
|
|
4966
|
-======================================================*/
|
4965
|
+ ************ Calendar ************
|
|
|
4966
|
+ ======================================================*/
|
4967
|
/* global $:true */
|
4967
|
/* global $:true */
|
4968
|
/*jshint unused: false*/
|
4968
|
/*jshint unused: false*/
|
4969
|
+function ($) {
|
4969
|
+function ($) {
|
|
@@ -5886,12 +5886,22 @@ Device/OS Detection |
|
@@ -5886,12 +5886,22 @@ Device/OS Detection |
5886
|
$(this.input).picker(p);
|
5886
|
$(this.input).picker(p);
|
5887
|
}
|
5887
|
}
|
5888
|
|
5888
|
|
|
|
5889
|
+ var date=new Date();
|
|
|
5890
|
+ var dat=date.getDate();
|
|
|
5891
|
+ console.log(dat);
|
|
|
5892
|
+ if(dat<10){
|
|
|
5893
|
+ dat='0'+dat;
|
|
|
5894
|
+ }else{
|
|
|
5895
|
+ dat=dat
|
|
|
5896
|
+ }
|
5889
|
Datetime.prototype = {
|
5897
|
Datetime.prototype = {
|
5890
|
getDays : function(max) {
|
5898
|
getDays : function(max) {
|
5891
|
var days = [];
|
5899
|
var days = [];
|
5892
|
- for(var i=1; i<= (max||31);i++) {
|
|
|
5893
|
- days.push(i < 10 ? "0"+i : i);
|
|
|
5894
|
- }
|
5900
|
+
|
|
|
5901
|
+ //for(var i=1; i<= (max||31);i++) {
|
|
|
5902
|
+ // days.push(i < 10 ? "0"+i : i);
|
|
|
5903
|
+ //}
|
|
|
5904
|
+ days.push(dat);
|
5895
|
return days;
|
5905
|
return days;
|
5896
|
},
|
5906
|
},
|
5897
|
|
5907
|
|
|
@@ -5967,7 +5977,16 @@ Device/OS Detection |
|
@@ -5967,7 +5977,16 @@ Device/OS Detection |
5967
|
{
|
5977
|
{
|
5968
|
values: (function () {
|
5978
|
values: (function () {
|
5969
|
var dates = [];
|
5979
|
var dates = [];
|
5970
|
- for (var i=1; i<=31; i++) dates.push(formatNumber(i));
|
5980
|
+ var date=new Date();
|
|
|
5981
|
+ var dat=date.getDate();
|
|
|
5982
|
+ console.log(dat);
|
|
|
5983
|
+ if(dat<10){
|
|
|
5984
|
+ dat='0'+dat;
|
|
|
5985
|
+ }else{
|
|
|
5986
|
+ dat=dat
|
|
|
5987
|
+ }
|
|
|
5988
|
+ //for (var i=1; i<=31; i++)
|
|
|
5989
|
+ dates.push(dat);
|
5971
|
return dates;
|
5990
|
return dates;
|
5972
|
})()
|
5991
|
})()
|
5973
|
},
|
5992
|
},
|
|
@@ -6014,11 +6033,17 @@ Device/OS Detection |
|
@@ -6014,11 +6033,17 @@ Device/OS Detection |
6014
|
});
|
6033
|
});
|
6015
|
};
|
6034
|
};
|
6016
|
|
6035
|
|
|
|
6036
|
+//自定义月
|
|
|
6037
|
+ var date=new Date();
|
|
|
6038
|
+ var month=date.getMonth()+1;
|
|
|
6039
|
+ if(month<10){
|
|
|
6040
|
+ month='0'+month
|
|
|
6041
|
+ }else{
|
|
|
6042
|
+ month=month;
|
|
|
6043
|
+ }
|
6017
|
|
6044
|
|
6018
|
|
6045
|
|
6019
|
defaults = $.fn.datetimePicker.prototype.defaults = {
|
6046
|
defaults = $.fn.datetimePicker.prototype.defaults = {
|
6020
|
-
|
|
|
6021
|
-
|
|
|
6022
|
input: undefined, // 默认值
|
6047
|
input: undefined, // 默认值
|
6023
|
min: undefined, // YYYY-MM-DD 最大最小值只比较年月日,不比较时分秒
|
6048
|
min: undefined, // YYYY-MM-DD 最大最小值只比较年月日,不比较时分秒
|
6024
|
max: undefined, // YYYY-MM-DD
|
6049
|
max: undefined, // YYYY-MM-DD
|
|
@@ -6026,7 +6051,7 @@ Device/OS Detection |
|
@@ -6026,7 +6051,7 @@ Device/OS Detection |
6026
|
monthSplit: '-',
|
6051
|
monthSplit: '-',
|
6027
|
dateSplit: '', // 默认为空
|
6052
|
dateSplit: '', // 默认为空
|
6028
|
datetimeSplit: ' ', // 日期和时间之间的分隔符,不可为空
|
6053
|
datetimeSplit: ' ', // 日期和时间之间的分隔符,不可为空
|
6029
|
- monthes: ('01 02 03 04 05 06 07 08 09 10 11 12').split(' '),
|
6054
|
+ monthes: (month).split(' '),
|
6030
|
// monthes:month.split(' '),
|
6055
|
// monthes:month.split(' '),
|
6031
|
years: (function () {
|
6056
|
years: (function () {
|
6032
|
var arr = [];
|
6057
|
var arr = [];
|
|
@@ -6078,8 +6103,8 @@ Device/OS Detection |
|
@@ -6078,8 +6103,8 @@ Device/OS Detection |
6078
|
}($);
|
6103
|
}($);
|
6079
|
|
6104
|
|
6080
|
/*======================================================
|
6105
|
/*======================================================
|
6081
|
-************ Picker ************
|
|
|
6082
|
-======================================================*/
|
6106
|
+ ************ Picker ************
|
|
|
6107
|
+ ======================================================*/
|
6083
|
/* global $:true */
|
6108
|
/* global $:true */
|
6084
|
|
6109
|
|
6085
|
+ function($) {
|
6110
|
+ function($) {
|
|
@@ -6135,8 +6160,8 @@ Device/OS Detection |
|
@@ -6135,8 +6160,8 @@ Device/OS Detection |
6135
|
}($);
|
6160
|
}($);
|
6136
|
|
6161
|
|
6137
|
/* ===============================================================================
|
6162
|
/* ===============================================================================
|
6138
|
-************ Notification ************
|
|
|
6139
|
-=============================================================================== */
|
6163
|
+ ************ Notification ************
|
|
|
6164
|
+ =============================================================================== */
|
6140
|
/* global $:true */
|
6165
|
/* global $:true */
|
6141
|
+function ($) {
|
6166
|
+function ($) {
|
6142
|
"use strict";
|
6167
|
"use strict";
|
|
@@ -6348,8 +6373,8 @@ Device/OS Detection |
|
@@ -6348,8 +6373,8 @@ Device/OS Detection |
6348
|
}($);
|
6373
|
}($);
|
6349
|
|
6374
|
|
6350
|
/* ===============================================================================
|
6375
|
/* ===============================================================================
|
6351
|
-************ Swipeout ************
|
|
|
6352
|
-=============================================================================== */
|
6376
|
+ ************ Swipeout ************
|
|
|
6377
|
+ =============================================================================== */
|
6353
|
/* global $:true */
|
6378
|
/* global $:true */
|
6354
|
|
6379
|
|
6355
|
+function ($) {
|
6380
|
+function ($) {
|