active_administration 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -1
- data/README.md +2 -1
- data/active_administration.gemspec +2 -1
- data/app/assets/javascripts/active_administration/README.md +0 -0
- data/app/assets/javascripts/active_administration/metro-accordion.js +70 -0
- data/app/assets/javascripts/active_administration/metro-button-set.js +88 -0
- data/app/assets/javascripts/active_administration/metro-calendar.js +437 -0
- data/app/assets/javascripts/active_administration/metro-carousel.js +304 -0
- data/app/assets/javascripts/active_administration/metro-core.js +39 -0
- data/app/assets/javascripts/active_administration/metro-countdown.js +200 -0
- data/app/assets/javascripts/active_administration/metro-date-format.js +137 -0
- data/app/assets/javascripts/active_administration/metro-datepicker.js +138 -0
- data/app/assets/javascripts/active_administration/metro-dialog.js +221 -0
- data/app/assets/javascripts/active_administration/metro-drag-tile.js +46 -0
- data/app/assets/javascripts/active_administration/metro-dropdown.js +112 -0
- data/app/assets/javascripts/active_administration/metro-fluentmenu.js +57 -0
- data/app/assets/javascripts/active_administration/metro-global.js +4 -0
- data/app/assets/javascripts/active_administration/metro-hint.js +104 -0
- data/app/assets/javascripts/active_administration/metro-initiator.js +271 -0
- data/app/assets/javascripts/active_administration/metro-input-control.js +318 -0
- data/app/assets/javascripts/active_administration/metro-listview.js +53 -0
- data/app/assets/javascripts/active_administration/metro-live-tile.js +162 -0
- data/app/assets/javascripts/active_administration/metro-loader.js +46 -0
- data/app/assets/javascripts/active_administration/metro-locale.js +132 -0
- data/app/assets/javascripts/active_administration/metro-notify.js +120 -0
- data/app/assets/javascripts/active_administration/metro-panel.js +41 -0
- data/app/assets/javascripts/active_administration/metro-plugin-template.js +21 -0
- data/app/assets/javascripts/active_administration/metro-progressbar.js +97 -0
- data/app/assets/javascripts/active_administration/metro-pull.js +38 -0
- data/app/assets/javascripts/active_administration/metro-rating.js +99 -0
- data/app/assets/javascripts/active_administration/metro-scroll.js +756 -0
- data/app/assets/javascripts/active_administration/metro-slider.js +304 -0
- data/app/assets/javascripts/active_administration/metro-stepper.js +105 -0
- data/app/assets/javascripts/active_administration/metro-streamer.js +214 -0
- data/app/assets/javascripts/active_administration/metro-tab-control.js +96 -0
- data/app/assets/javascripts/active_administration/metro-table.js +74 -0
- data/app/assets/javascripts/active_administration/metro-tile-transform.js +65 -0
- data/app/assets/javascripts/active_administration/metro-times.js +190 -0
- data/app/assets/javascripts/active_administration/metro-touch-handler.js +65 -0
- data/app/assets/javascripts/active_administration/metro-treeview.js +64 -0
- data/app/assets/javascripts/active_administration/metro-wizard.js +148 -0
- data/app/assets/stylesheets/active_administration/accordion.less +64 -0
- data/app/assets/stylesheets/active_administration/balloon.less +88 -0
- data/app/assets/stylesheets/active_administration/breadcrumbs.less +118 -0
- data/app/assets/stylesheets/active_administration/buttons.less +383 -0
- data/app/assets/stylesheets/active_administration/calendar.less +123 -0
- data/app/assets/stylesheets/active_administration/carousel.less +118 -0
- data/app/assets/stylesheets/active_administration/colors.less +589 -0
- data/app/assets/stylesheets/active_administration/countdown.less +57 -0
- data/app/assets/stylesheets/active_administration/dataTables.less +134 -0
- data/app/assets/stylesheets/active_administration/fluent-menu.less +231 -0
- data/app/assets/stylesheets/active_administration/forms.less +414 -0
- data/app/assets/stylesheets/active_administration/funcs.less +178 -0
- data/app/assets/stylesheets/active_administration/grid.less +91 -0
- data/app/assets/stylesheets/active_administration/hint.less +120 -0
- data/app/assets/stylesheets/active_administration/iconFont-content.less +1353 -0
- data/app/assets/stylesheets/active_administration/iconFont.less +47 -0
- data/app/assets/stylesheets/active_administration/icons.less +10 -0
- data/app/assets/stylesheets/active_administration/images.less +75 -0
- data/app/assets/stylesheets/active_administration/layout.less +137 -0
- data/app/assets/stylesheets/active_administration/lists.less +258 -0
- data/app/assets/stylesheets/active_administration/menus.less +469 -0
- data/app/assets/stylesheets/active_administration/metro-bootstrap-responsive.less +300 -0
- data/app/assets/stylesheets/active_administration/metro-bootstrap.less +68 -0
- data/app/assets/stylesheets/active_administration/misc.less +72 -0
- data/app/assets/stylesheets/active_administration/navigation-bar.less +317 -0
- data/app/assets/stylesheets/active_administration/notice.less +52 -0
- data/app/assets/stylesheets/active_administration/notify.less +43 -0
- data/app/assets/stylesheets/active_administration/pagination.less +83 -0
- data/app/assets/stylesheets/active_administration/panels.less +38 -0
- data/app/assets/stylesheets/active_administration/progress-bar.less +25 -0
- data/app/assets/stylesheets/active_administration/rating.less +103 -0
- data/app/assets/stylesheets/active_administration/reset.less +219 -0
- data/app/assets/stylesheets/active_administration/scroll.less +141 -0
- data/app/assets/stylesheets/active_administration/sidebar.less +158 -0
- data/app/assets/stylesheets/active_administration/slider.less +106 -0
- data/app/assets/stylesheets/active_administration/stepper.less +80 -0
- data/app/assets/stylesheets/active_administration/streamer.less +250 -0
- data/app/assets/stylesheets/active_administration/tab-control.less +79 -0
- data/app/assets/stylesheets/active_administration/tables.less +170 -0
- data/app/assets/stylesheets/active_administration/tiles.less +599 -0
- data/app/assets/stylesheets/active_administration/transform.less +23 -0
- data/app/assets/stylesheets/active_administration/treeview.less +96 -0
- data/app/assets/stylesheets/active_administration/typography.less +382 -0
- data/app/assets/stylesheets/active_administration/utils.less +180 -0
- data/app/assets/stylesheets/active_administration/variables.less +250 -0
- data/app/assets/stylesheets/active_administration/window.less +225 -0
- data/app/assets/stylesheets/active_administration/wizard.less +53 -0
- data/lib/active_admin/version.rb +1 -1
- metadata +103 -10
@@ -0,0 +1,96 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
$.widget("metro.tabcontrol", {
|
3
|
+
|
4
|
+
version: "1.0.0",
|
5
|
+
|
6
|
+
options: {
|
7
|
+
effect: 'none',
|
8
|
+
activateStoredTab: false,
|
9
|
+
tabclick: function(tab){},
|
10
|
+
tabchange: function(tab){}
|
11
|
+
},
|
12
|
+
|
13
|
+
_create: function(){
|
14
|
+
var that = this,
|
15
|
+
element = this.element,
|
16
|
+
tabs = $(element.children(".tabs")).children("li"),
|
17
|
+
frames = $(element.children(".frames")).children(".frame"),
|
18
|
+
element_id = element.attr("id");
|
19
|
+
|
20
|
+
if (element.data('effect') != undefined) {
|
21
|
+
this.options.effect = element.data('effect');
|
22
|
+
}
|
23
|
+
|
24
|
+
this.init(tabs, frames);
|
25
|
+
|
26
|
+
tabs.each(function(){
|
27
|
+
|
28
|
+
var tab = $(this).children("a");
|
29
|
+
|
30
|
+
tab.on('click', function(e){
|
31
|
+
e.preventDefault();
|
32
|
+
|
33
|
+
that.options.tabclick(this);
|
34
|
+
|
35
|
+
if ($(this).parent().hasClass('disabled')) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
|
39
|
+
tabs.removeClass("active");
|
40
|
+
tab.parent("li").addClass("active");
|
41
|
+
|
42
|
+
frames.hide();
|
43
|
+
var current_frame = $(tab.attr("href"));
|
44
|
+
switch (that.options.effect) {
|
45
|
+
case 'slide': current_frame.slideDown(); break;
|
46
|
+
case 'fade': current_frame.fadeIn(); break;
|
47
|
+
default: current_frame.show();
|
48
|
+
}
|
49
|
+
|
50
|
+
that._trigger('change', null, current_frame);
|
51
|
+
that.options.tabchange(this);
|
52
|
+
|
53
|
+
if (element_id != undefined) window.localStorage.setItem(element_id+"-current-tab", $(this).attr("href"));
|
54
|
+
});
|
55
|
+
});
|
56
|
+
|
57
|
+
if (this.options.activateStoredTab) this._activateStoredTab(tabs);
|
58
|
+
},
|
59
|
+
|
60
|
+
init: function(tabs, frames){
|
61
|
+
var that = this;
|
62
|
+
tabs.each(function(){
|
63
|
+
if ($(this).hasClass("active")) {
|
64
|
+
var current_frame = $($($(this).children("a")).attr("href"));
|
65
|
+
frames.hide();
|
66
|
+
current_frame.show();
|
67
|
+
that._trigger('change', null, current_frame);
|
68
|
+
}
|
69
|
+
});
|
70
|
+
},
|
71
|
+
|
72
|
+
_activateStoredTab: function(tabs){
|
73
|
+
var current_stored_tab = window.localStorage.getItem(this.element.attr('id')+'-current-tab');
|
74
|
+
|
75
|
+
if (current_stored_tab != undefined) {
|
76
|
+
tabs.each(function(){
|
77
|
+
var a = $(this).children("a");
|
78
|
+
if (a.attr("href") == current_stored_tab) {
|
79
|
+
a.click();
|
80
|
+
}
|
81
|
+
});
|
82
|
+
}
|
83
|
+
},
|
84
|
+
|
85
|
+
_destroy: function(){
|
86
|
+
|
87
|
+
},
|
88
|
+
|
89
|
+
_setOption: function(key, value){
|
90
|
+
this._super('_setOption', key, value);
|
91
|
+
}
|
92
|
+
})
|
93
|
+
})( jQuery );
|
94
|
+
|
95
|
+
|
96
|
+
|
@@ -0,0 +1,74 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
$.widget("metro.tablecontrol", {
|
3
|
+
|
4
|
+
version: "1.0.0",
|
5
|
+
|
6
|
+
options: {
|
7
|
+
width: '100%',
|
8
|
+
height: 'auto',
|
9
|
+
cls: 'table',
|
10
|
+
checkRow: false,
|
11
|
+
colModel: [],
|
12
|
+
data: []
|
13
|
+
},
|
14
|
+
|
15
|
+
_create: function(){
|
16
|
+
var element = this.element,
|
17
|
+
table;
|
18
|
+
|
19
|
+
element.css({
|
20
|
+
width: this.options.width,
|
21
|
+
height: this.options.height
|
22
|
+
});
|
23
|
+
|
24
|
+
table = this.createTable(element);
|
25
|
+
|
26
|
+
this.addHeader(table, this.options.colModel);
|
27
|
+
this.addTableData(table, this.options.data);
|
28
|
+
|
29
|
+
table.addClass(this.options.cls);
|
30
|
+
},
|
31
|
+
|
32
|
+
addHeader: function(container, data){
|
33
|
+
var thead = $("<thead/>").appendTo(container);
|
34
|
+
var th, tr = $("<tr/>").appendTo(thead);
|
35
|
+
$.each(data, function(index, column){
|
36
|
+
th = $("<th/>").addClass(column.hcls).html(column.caption).appendTo(tr);
|
37
|
+
});
|
38
|
+
},
|
39
|
+
|
40
|
+
createTable: function(container){
|
41
|
+
return $("<table/>").appendTo(container);
|
42
|
+
},
|
43
|
+
|
44
|
+
addTableData: function(container, data){
|
45
|
+
var that = this,
|
46
|
+
tbody = $("<tbody/>").appendTo(container);
|
47
|
+
|
48
|
+
$.each(data, function(i, row){
|
49
|
+
that.addRowData(tbody, row);
|
50
|
+
});
|
51
|
+
},
|
52
|
+
|
53
|
+
addRowData: function(container, row){
|
54
|
+
var td, tr = $("<tr/>").appendTo(container);
|
55
|
+
if (row.__row_class != undefined) {
|
56
|
+
tr.addClass(row.__row_class);
|
57
|
+
}
|
58
|
+
$.each(this.options.colModel, function(index, val){
|
59
|
+
td = $("<td/>").css("width", val.width).addClass(val.cls).html(row[val.field]).appendTo(tr);
|
60
|
+
});
|
61
|
+
},
|
62
|
+
|
63
|
+
_destroy: function(){
|
64
|
+
},
|
65
|
+
|
66
|
+
_setOption: function(key, value){
|
67
|
+
this._super('_setOption', key, value);
|
68
|
+
}
|
69
|
+
})
|
70
|
+
})( jQuery );
|
71
|
+
|
72
|
+
$(function(){
|
73
|
+
$('[data-role=table]').tablecontrol();
|
74
|
+
});
|
@@ -0,0 +1,65 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
$.widget("metro.tileTransform", {
|
3
|
+
|
4
|
+
version: "1.0.0",
|
5
|
+
|
6
|
+
options: {
|
7
|
+
},
|
8
|
+
|
9
|
+
_create: function(){
|
10
|
+
var element = this.element;
|
11
|
+
var dim = {w: element.width(), h: element.height()};
|
12
|
+
|
13
|
+
element.on('click', function(e){
|
14
|
+
// e.preventDefault();
|
15
|
+
// if (element[0].tagName == 'A' && element.attr('href')) {
|
16
|
+
// document.location.href = element.attr('href');
|
17
|
+
// }
|
18
|
+
});
|
19
|
+
|
20
|
+
element.on('mousedown', function(e){
|
21
|
+
var X = e.pageX - $(this).offset().left, Y = e.pageY - $(this).offset().top;
|
22
|
+
var transform = 'top';
|
23
|
+
|
24
|
+
if (X < dim.w * 1/3 && (Y < dim.h * 1/2 || Y > dim.h * 1/2 )) {
|
25
|
+
transform = 'left';
|
26
|
+
} else if (X > dim.w * 2/3 && (Y < dim.h * 1/2 || Y > dim.h * 1/2 )) {
|
27
|
+
transform = 'right'
|
28
|
+
} else if (X > dim.w*1/3 && X<dim.w*2/3 && Y > dim.h/2) {
|
29
|
+
transform = 'bottom';
|
30
|
+
}
|
31
|
+
|
32
|
+
$(this).addClass("tile-transform-"+transform);
|
33
|
+
|
34
|
+
if (element[0].tagName == 'A' && element.attr('href')) {
|
35
|
+
setTimeout(function(){
|
36
|
+
document.location.href = element.attr('href');
|
37
|
+
}, 500);
|
38
|
+
}
|
39
|
+
});
|
40
|
+
|
41
|
+
element.on('mouseup', function(){
|
42
|
+
$(this)
|
43
|
+
.removeClass("tile-transform-left")
|
44
|
+
.removeClass("tile-transform-right")
|
45
|
+
.removeClass("tile-transform-top")
|
46
|
+
.removeClass("tile-transform-bottom");
|
47
|
+
});
|
48
|
+
element.on('mouseleave', function(){
|
49
|
+
$(this)
|
50
|
+
.removeClass("tile-transform-left")
|
51
|
+
.removeClass("tile-transform-right")
|
52
|
+
.removeClass("tile-transform-top")
|
53
|
+
.removeClass("tile-transform-bottom");
|
54
|
+
});
|
55
|
+
},
|
56
|
+
|
57
|
+
_destroy: function(){
|
58
|
+
|
59
|
+
},
|
60
|
+
|
61
|
+
_setOption: function(key, value){
|
62
|
+
this._super('_setOption', key, value);
|
63
|
+
}
|
64
|
+
})
|
65
|
+
})( jQuery );
|
@@ -0,0 +1,190 @@
|
|
1
|
+
(function( $ ) {
|
2
|
+
$.widget("metro.times", {
|
3
|
+
|
4
|
+
version: "1.0.0",
|
5
|
+
|
6
|
+
options: {
|
7
|
+
style: {
|
8
|
+
background: "bg-dark",
|
9
|
+
foreground: "fg-white",
|
10
|
+
divider: "fg-dark"
|
11
|
+
},
|
12
|
+
blink: true,
|
13
|
+
alarm: {
|
14
|
+
h: 0,
|
15
|
+
m: 0,
|
16
|
+
s: 0
|
17
|
+
},
|
18
|
+
ontick: function(h, m, s){},
|
19
|
+
onalarm: function(){}
|
20
|
+
},
|
21
|
+
|
22
|
+
wrappers: {},
|
23
|
+
|
24
|
+
_interval: 0,
|
25
|
+
|
26
|
+
_create: function(){
|
27
|
+
var that = this, element = this.element;
|
28
|
+
|
29
|
+
$.each(['Hours','Minutes','Seconds'],function(){
|
30
|
+
$('<span class="count'+this+'">').html(
|
31
|
+
'<span class="digit-wrapper">\
|
32
|
+
<span class="digit">0</span>\
|
33
|
+
</span>\
|
34
|
+
<span class="digit-wrapper">\
|
35
|
+
<span class="digit">0</span>\
|
36
|
+
</span>'
|
37
|
+
).appendTo(element);
|
38
|
+
|
39
|
+
if(this!="Seconds"){
|
40
|
+
element.append('<span class="divider"></span>');
|
41
|
+
}
|
42
|
+
});
|
43
|
+
|
44
|
+
this.wrappers = this.element.find('.digit-wrapper');
|
45
|
+
|
46
|
+
if (element.data('blink') != undefined) {
|
47
|
+
this.options.blink = element.data('blick');
|
48
|
+
}
|
49
|
+
|
50
|
+
if (element.data('styleBackground') != undefined) {
|
51
|
+
this.options.style.background = element.data('styleBackground');
|
52
|
+
}
|
53
|
+
|
54
|
+
if (element.data('styleForeground') != undefined) {
|
55
|
+
this.options.style.foreground = element.data('styleForeground');
|
56
|
+
}
|
57
|
+
|
58
|
+
if (element.data('styleDivider') != undefined) {
|
59
|
+
this.options.style.divider = element.data('styleDivider');
|
60
|
+
}
|
61
|
+
|
62
|
+
if (this.options.style.background != "default") {
|
63
|
+
this.element.find(".digit").addClass(this.options.style.background);
|
64
|
+
}
|
65
|
+
|
66
|
+
if (this.options.style.foreground != "default") {
|
67
|
+
this.element.find(".digit").addClass(this.options.style.foreground);
|
68
|
+
}
|
69
|
+
|
70
|
+
if (this.options.style.divider != "default") {
|
71
|
+
this.element.find(".divider").addClass(this.options.style.divider);
|
72
|
+
}
|
73
|
+
|
74
|
+
if (element.data('alarm') != undefined) {
|
75
|
+
var _alarm = element.data('alarm').split(":");
|
76
|
+
this.options.alarm.h = _alarm[0] != undefined ? _alarm[0] : 0;
|
77
|
+
this.options.alarm.m = _alarm[1] != undefined ? _alarm[1] : 0;
|
78
|
+
this.options.alarm.s = _alarm[2] != undefined ? _alarm[2] : 0;
|
79
|
+
}
|
80
|
+
|
81
|
+
if (element.data('onalarm') != undefined) {
|
82
|
+
}
|
83
|
+
|
84
|
+
setTimeout( function(){
|
85
|
+
that.tick()
|
86
|
+
}, 1000);
|
87
|
+
},
|
88
|
+
|
89
|
+
_destroy: function(){
|
90
|
+
|
91
|
+
},
|
92
|
+
|
93
|
+
_setOption: function(key, value){
|
94
|
+
this._super('_setOption', key, value);
|
95
|
+
},
|
96
|
+
|
97
|
+
|
98
|
+
tick: function(){
|
99
|
+
var that = this;
|
100
|
+
|
101
|
+
this._interval = setInterval(function(){
|
102
|
+
var _date = new Date();
|
103
|
+
|
104
|
+
var h, m, s;
|
105
|
+
|
106
|
+
h = _date.getHours();
|
107
|
+
that.updateDuo(0, 1, h);
|
108
|
+
|
109
|
+
m = _date.getMinutes();
|
110
|
+
that.updateDuo(2, 3, m);
|
111
|
+
|
112
|
+
s = _date.getSeconds();
|
113
|
+
that.updateDuo(4, 5, s);
|
114
|
+
|
115
|
+
// Calling an optional user supplied callback
|
116
|
+
that.options.ontick(h, m, s);
|
117
|
+
|
118
|
+
that.blinkDivider();
|
119
|
+
|
120
|
+
var alarm = that.options.alarm;
|
121
|
+
|
122
|
+
if (alarm) {
|
123
|
+
if (
|
124
|
+
(alarm.h != undefined && alarm.h == h)
|
125
|
+
&& (alarm.m != undefined && alarm.m == m)
|
126
|
+
&& (alarm.s != undefined && alarm.s == s)
|
127
|
+
) {
|
128
|
+
|
129
|
+
that.options.onalarm();
|
130
|
+
that._trigger('alarm');
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
// Scheduling another call of this function in 1s
|
135
|
+
}, 1000);
|
136
|
+
},
|
137
|
+
|
138
|
+
blinkDivider: function(){
|
139
|
+
if (this.options.blink)
|
140
|
+
this.element.find(".divider").toggleClass("no-visible");
|
141
|
+
},
|
142
|
+
|
143
|
+
updateDuo: function(minor, major, value){
|
144
|
+
this.switchDigit(this.wrappers.eq(minor),Math.floor(value/10)%10);
|
145
|
+
this.switchDigit(this.wrappers.eq(major),value%10);
|
146
|
+
},
|
147
|
+
|
148
|
+
switchDigit: function(wrapper, number){
|
149
|
+
var digit = wrapper.find('.digit');
|
150
|
+
|
151
|
+
if(digit.is(':animated')){
|
152
|
+
return false;
|
153
|
+
}
|
154
|
+
|
155
|
+
if(wrapper.data('digit') == number){
|
156
|
+
// We are already showing this number
|
157
|
+
return false;
|
158
|
+
}
|
159
|
+
|
160
|
+
wrapper.data('digit', number);
|
161
|
+
|
162
|
+
var replacement = $('<span>',{
|
163
|
+
'class':'digit',
|
164
|
+
css:{
|
165
|
+
top:'-2.1em',
|
166
|
+
opacity:0
|
167
|
+
},
|
168
|
+
html:number
|
169
|
+
});
|
170
|
+
|
171
|
+
replacement.addClass(this.options.style.background);
|
172
|
+
replacement.addClass(this.options.style.foreground);
|
173
|
+
|
174
|
+
digit
|
175
|
+
.before(replacement)
|
176
|
+
.removeClass('static')
|
177
|
+
.animate({top:'2.5em',opacity:0},'fast',function(){
|
178
|
+
digit.remove();
|
179
|
+
});
|
180
|
+
|
181
|
+
replacement
|
182
|
+
.delay(100)
|
183
|
+
.animate({top:0,opacity:1},'fast');
|
184
|
+
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
});
|
188
|
+
})( jQuery );
|
189
|
+
|
190
|
+
|
@@ -0,0 +1,65 @@
|
|
1
|
+
var hasTouch = 'ontouchend' in window, eventTimer;
|
2
|
+
var moveDirection = 'undefined', startX, startY, deltaX, deltaY, mouseDown = false
|
3
|
+
|
4
|
+
function addTouchEvents(element){
|
5
|
+
if (hasTouch) {
|
6
|
+
element.addEventListener("touchstart", touch2Mouse, true);
|
7
|
+
element.addEventListener("touchmove", touch2Mouse, true);
|
8
|
+
element.addEventListener("touchend", touch2Mouse, true);
|
9
|
+
}
|
10
|
+
}
|
11
|
+
|
12
|
+
function touch2Mouse(e)
|
13
|
+
{
|
14
|
+
var theTouch = e.changedTouches[0];
|
15
|
+
var mouseEv;
|
16
|
+
|
17
|
+
switch(e.type)
|
18
|
+
{
|
19
|
+
case "touchstart": mouseEv="mousedown"; break;
|
20
|
+
case "touchend": mouseEv="mouseup"; break;
|
21
|
+
case "touchmove": mouseEv="mousemove"; break;
|
22
|
+
default: return;
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
if (mouseEv == "mousedown") {
|
27
|
+
eventTimer = (new Date()).getTime();
|
28
|
+
startX = theTouch.clientX;
|
29
|
+
startY = theTouch.clientY;
|
30
|
+
mouseDown = true;
|
31
|
+
}
|
32
|
+
|
33
|
+
if (mouseEv == "mouseup") {
|
34
|
+
if ((new Date()).getTime() - eventTimer <= 500) {
|
35
|
+
mouseEv = "click";
|
36
|
+
} else if ((new Date()).getTime() - eventTimer > 1000) {
|
37
|
+
mouseEv = "longclick";
|
38
|
+
}
|
39
|
+
eventTimer = 0;
|
40
|
+
mouseDown = false;
|
41
|
+
}
|
42
|
+
|
43
|
+
if (mouseEv == "mousemove") {
|
44
|
+
if (mouseDown) {
|
45
|
+
deltaX = theTouch.clientX - startX;
|
46
|
+
deltaY = theTouch.clientY - startY;
|
47
|
+
moveDirection = deltaX > deltaY ? 'horizontal' : 'vertical';
|
48
|
+
}
|
49
|
+
}
|
50
|
+
|
51
|
+
var mouseEvent = document.createEvent("MouseEvent");
|
52
|
+
mouseEvent.initMouseEvent(mouseEv, true, true, window, 1, theTouch.screenX, theTouch.screenY, theTouch.clientX, theTouch.clientY, false, false, false, false, 0, null);
|
53
|
+
theTouch.target.dispatchEvent(mouseEvent);
|
54
|
+
|
55
|
+
e.preventDefault();
|
56
|
+
}
|
57
|
+
|
58
|
+
|
59
|
+
/* To add touch support for element need create listeners for component dom element
|
60
|
+
if (hasTouch) {
|
61
|
+
element.addEventListener("touchstart", touch2Mouse, true);
|
62
|
+
element.addEventListener("touchmove", touch2Mouse, true);
|
63
|
+
element.addEventListener("touchend", touch2Mouse, true);
|
64
|
+
}
|
65
|
+
*/
|