uil 1.0.1 → 4.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,217 +0,0 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
3
-
4
- function Button ( o ) {
5
-
6
- Proto.call( this, o );
7
-
8
- this.value = o.value || [this.txt];
9
-
10
- this.buttonColor = o.bColor || Tools.colors.button;
11
-
12
- this.isLoadButton = o.loader || false;
13
- this.isDragButton = o.drag || false;
14
- if(this.isDragButton ) this.isLoadButton = true;
15
- this.r = o.r || 3;
16
-
17
- this.lng = this.value.length;
18
-
19
- for(var i = 0; i < this.lng; i++){
20
- this.c[i+2] = Tools.dom( 'div', Tools.css.txt + 'text-align:center; border:1px solid ' + Tools.colors.border+'; top:1px; pointer-events:auto; cursor:pointer; background:'+this.buttonColor+'; height:'+(this.h-2)+'px; border-radius:'+this.r+'px; line-height:'+(this.h-4)+'px;' );
21
- this.c[i+2].style.color = this.fontColor;
22
-
23
- this.c[i+2].events = [ 'click', 'mouseover', 'mousedown', 'mouseup', 'mouseout' ];
24
- this.c[i+2].innerHTML = this.value[i];//this.txt;
25
- this.c[i+2].name = i;
26
- }
27
-
28
- if( this.c[1] !== undefined ) this.c[1].textContent = '';
29
-
30
-
31
- if( this.isLoadButton ) this.initLoader();
32
- if( this.isDragButton ){
33
- this.lng ++;
34
- this.initDrager();
35
- }
36
-
37
- this.init();
38
-
39
- };
40
-
41
- Button.prototype = Object.create( Proto.prototype );
42
- Button.prototype.constructor = Button;
43
-
44
- Button.prototype.handleEvent = function( e ) {
45
-
46
- e.preventDefault();
47
-
48
- switch( e.type ) {
49
- case 'click': this.click( e ); break;
50
- case 'mouseover': this.mode( 1, e ); break;
51
- case 'mousedown': this.mode( 2, e ); break;
52
- case 'mouseup': this.mode( 0, e ); break;
53
- case 'mouseout': this.mode( 0, e ); break;
54
- case 'change': this.fileSelect( e.target.files[0] ); break;
55
-
56
- case 'dragover': this.dragover(); break;
57
- case 'dragend': this.dragend(); break;
58
- case 'dragleave': this.dragend(); break;
59
- case 'drop': this.drop( e ); break;
60
- }
61
-
62
- };
63
-
64
- Button.prototype.dragover = function(){
65
- this.s[4].borderColor = Tools.colors.select;
66
- this.s[4].color = Tools.colors.select;
67
- };
68
- Button.prototype.dragend = function(){
69
- this.s[4].borderColor = this.fontColor;
70
- this.s[4].color = this.fontColor;
71
- };
72
- Button.prototype.drop = function(e){
73
- this.dragend();
74
- this.fileSelect( e.dataTransfer.files[0] );
75
- };
76
-
77
- Button.prototype.mode = function( mode, e ){
78
-
79
- var s = this.s;
80
- var i = e.target.name || 0;
81
- if(i==='loader') i = 0;
82
-
83
-
84
- switch( mode ){
85
- case 0: // base
86
- s[i+2].color = this.fontColor;
87
- s[i+2].background = this.buttonColor;
88
- break;
89
- case 1: // over
90
- s[i+2].color = '#FFF';
91
- s[i+2].background = Tools.colors.select;
92
- break;
93
- case 2: // edit / down
94
- s[i+2].color = this.fontColor;
95
- s[i+2].background = Tools.colors.down;
96
- break;
97
-
98
- }
99
- }
100
-
101
- Button.prototype.initDrager = function(){
102
-
103
- this.c[4] = Tools.dom( 'div', Tools.css.txt +' text-align:center; line-height:'+(this.h-8)+'px; border:1px dashed '+this.fontColor+'; top:2px; pointer-events:auto; cursor:default; height:'+(this.h-4)+'px; border-radius:'+this.r+'px;' );
104
- this.c[4].textContent = 'DRAG';
105
-
106
- this.c[2].events = [ ];
107
- this.c[4].events = [ 'dragover', 'dragend', 'dragleave', 'drop' ];
108
-
109
-
110
- };
111
-
112
- Button.prototype.initLoader = function(){
113
-
114
- this.c[3] = Tools.dom( 'input', Tools.css.basic +'border:1px solid '+Tools.colors.border+'; top:1px; opacity:0; pointer-events:auto; cursor:pointer; height:'+(this.h-2)+'px;' );
115
- this.c[3].name = 'loader';
116
- this.c[3].type = "file";
117
-
118
- this.c[2].events = [ ];
119
- this.c[3].events = [ 'change', 'mouseover', 'mousedown', 'mouseup', 'mouseout' ];
120
-
121
- //this.hide = document.createElement('input');
122
-
123
- };
124
-
125
- Button.prototype.fileSelect = function( file ){
126
-
127
- var dataUrl = [ 'png', 'jpg', 'mp4', 'webm', 'ogg' ];
128
- var dataBuf = [ 'sea', 'bvh', 'BVH', 'z' ];
129
-
130
- //if( ! e.target.files ) return;
131
-
132
- //var file = e.target.files[0];
133
-
134
- //this.c[3].type = "null";
135
- // console.log( this.c[4] )
136
-
137
- if( file === undefined ) return;
138
-
139
- var reader = new FileReader();
140
- var fname = file.name;
141
- var type = fname.substring(fname.lastIndexOf('.')+1, fname.length );
142
-
143
- if( dataUrl.indexOf( type ) !== -1 ) reader.readAsDataURL( file );
144
- else if( dataBuf.indexOf( type ) !== -1 ) reader.readAsArrayBuffer( file );
145
- else reader.readAsText( file );
146
-
147
- // if( type === 'png' || type === 'jpg' || type === 'mp4' || type === 'webm' || type === 'ogg' ) reader.readAsDataURL( file );
148
- //else if( type === 'z' ) reader.readAsBinaryString( file );
149
- //else if( type === 'sea' || type === 'bvh' || type === 'BVH' || type === 'z') reader.readAsArrayBuffer( file );
150
- //else if( ) reader.readAsArrayBuffer( file );
151
- //else reader.readAsText( file );
152
-
153
- reader.onload = function(e) {
154
-
155
- if( this.callback ) this.callback( e.target.result, fname, type );
156
- //this.c[3].type = "file";
157
- //this.send( e.target.result );
158
- }.bind(this);
159
-
160
- };
161
-
162
- Button.prototype.click = function( e ){
163
-
164
- var i = e.target.name || 0;
165
- var v = this.value[i];
166
-
167
- this.send( v );
168
-
169
- };
170
-
171
- Button.prototype.label = function( string, n ){
172
-
173
- n = n || 2;
174
- this.c[n].textContent = string;
175
-
176
- };
177
-
178
- Button.prototype.icon = function( string, y, n ){
179
-
180
- n = n || 2;
181
- this.s[n].padding = ( y || 0 ) +'px 0px';
182
- this.c[n].innerHTML = string;
183
-
184
- };
185
-
186
- Button.prototype.rSize = function(){
187
-
188
- Proto.prototype.rSize.call( this );
189
-
190
- var s = this.s;
191
- var w = this.sb;
192
- var d = this.sa;
193
-
194
- var i = this.lng;
195
- var dc = 3;
196
- var size = Math.floor( ( w-(dc*(i-1)) ) / i );
197
-
198
- while(i--){
199
-
200
- s[i+2].width = size + 'px';
201
- s[i+2].left = d + ( size * i ) + ( dc * i) + 'px';
202
-
203
- }
204
-
205
- if( this.isDragButton ){
206
- s[4].left = (d+size+dc) + 'px';
207
- s[4].width = size + 'px';
208
- }
209
-
210
- if( this.isLoadButton ){
211
- s[3].left = d + 'px';
212
- s[3].width = size + 'px';
213
- }
214
-
215
- };
216
-
217
- export { Button };
@@ -1,198 +0,0 @@
1
- import { Tools } from '../core/Tools';
2
- import { Proto } from '../core/Proto';
3
-
4
- function Circular ( o ) {
5
-
6
- Proto.call( this, o );
7
-
8
- //this.type = 'circular';
9
- this.autoWidth = false;
10
-
11
- this.buttonColor = Tools.colors.button;
12
-
13
- this.setTypeNumber( o );
14
-
15
- this.radius = Math.floor((this.width-20)*0.5);
16
-
17
- /*this.radius = o.radius || 15;
18
-
19
- this.width = (this.radius*2)+20;
20
-
21
- if(o.width !== undefined){
22
- this.width = o.width;
23
- this.radius = ~~ (this.width-20)*0.5;
24
- }
25
-
26
- if(o.size !== undefined){
27
- this.width = o.size;
28
- this.radius = ~~ (this.width-20)*0.5;
29
- }*/
30
-
31
- this.w = this.height = this.radius * 2;
32
- this.h = o.height || (this.height + 40);
33
-
34
- this.twoPi = Math.PI * 2;
35
-
36
- this.top = 0;
37
-
38
- this.c[0].style.width = this.width +'px';
39
-
40
- if(this.c[1] !== undefined) {
41
-
42
- this.c[1].style.width = this.width +'px';
43
- this.c[1].style.textAlign = 'center';
44
- this.top = 20;
45
-
46
- }
47
-
48
- this.percent = 0;
49
-
50
- this.c[2] = Tools.dom( 'div', Tools.css.txtnumber + 'text-align:center; top:'+(this.height+24)+'px; width:'+this.width+'px; color:'+ this.fontColor );
51
- this.c[3] = Tools.dom( 'circle', Tools.css.basic + 'left:10px; top:'+this.top+'px; width:'+this.w+'px; height:'+this.height+'px; pointer-events:auto; cursor:pointer;', { cx:this.radius, cy:this.radius, r:this.radius, fill:'rgba(0,0,0,0.3)' });
52
- this.c[4] = Tools.dom( 'path', Tools.css.basic + 'left:10px; top:'+this.top+'px; width:'+this.w+'px; height:'+this.height+'px;', { d:this.makePath(), fill:this.fontColor });
53
- this.c[5] = Tools.dom( 'circle', Tools.css.basic + 'left:10px; top:'+this.top+'px; width:'+this.w+'px; height:'+this.height+'px;', { cx:this.radius, cy:this.radius, r:this.radius*0.5, fill:this.buttonColor, 'stroke-width':1, stroke:Tools.colors.stroke });
54
-
55
- this.c[3].events = [ 'mouseover', 'mousedown', 'mouseout' ];
56
-
57
- this.init();
58
-
59
- this.update();
60
-
61
- };
62
-
63
- Circular.prototype = Object.create( Proto.prototype );
64
- Circular.prototype.constructor = Circular;
65
-
66
- Circular.prototype.handleEvent = function( e ) {
67
-
68
- e.preventDefault();
69
-
70
- switch( e.type ) {
71
- case 'mouseover': this.over( e ); break;
72
- case 'mousedown': this.down( e ); break;
73
- case 'mouseout': this.out( e ); break;
74
-
75
- case 'mouseup': this.up( e ); break;
76
- case 'mousemove': this.move( e ); break;
77
- }
78
-
79
- };
80
-
81
- Circular.prototype.mode = function( mode ){
82
-
83
- switch(mode){
84
- case 0: // base
85
- this.s[2].color = this.fontColor;
86
- Tools.setSvg( this.c[3], 'fill','rgba(0,0,0,0.2)');
87
- Tools.setSvg( this.c[4], 'fill', this.fontColor );
88
- break;
89
- case 1: // over
90
- this.s[2].color = this.colorPlus;
91
- Tools.setSvg( this.c[3], 'fill','rgba(0,0,0,0.6)');
92
- Tools.setSvg( this.c[4], 'fill', this.colorPlus );
93
- break;
94
-
95
- }
96
- }
97
-
98
- Circular.prototype.over = function( e ){
99
-
100
- this.isOver = true;
101
- this.mode(1);
102
-
103
- };
104
-
105
- Circular.prototype.out = function( e ){
106
-
107
- this.isOver = false;
108
- if(this.isDown) return;
109
- this.mode(0);
110
-
111
- };
112
-
113
- Circular.prototype.up = function( e ){
114
-
115
- this.isDown = false;
116
- document.removeEventListener( 'mouseup', this, false );
117
- document.removeEventListener( 'mousemove', this, false );
118
-
119
- if(this.isOver) this.mode(1);
120
- else this.mode(0);
121
-
122
- this.sendEnd();
123
-
124
- };
125
-
126
- Circular.prototype.down = function( e ){
127
-
128
- this.isDown = true;
129
- document.addEventListener( 'mouseup', this, false );
130
- document.addEventListener( 'mousemove', this, false );
131
-
132
- this.rect = this.c[3].getBoundingClientRect();
133
- this.old = this.value;
134
- this.oldr = null;
135
- this.move( e );
136
-
137
- };
138
-
139
- Circular.prototype.move = function( e ){
140
-
141
- if( !this.isDown ) return;
142
-
143
- var x = this.radius - (e.clientX - this.rect.left);
144
- var y = this.radius - (e.clientY - this.rect.top);
145
-
146
- this.r = Math.atan2( y, x ) - (Math.PI * 0.5);
147
- this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi);
148
-
149
- if( this.oldr !== null ){
150
-
151
- var dif = this.r - this.oldr;
152
- this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r;
153
-
154
- if(dif > 6) this.r = 0;
155
- if(dif < -6) this.r = this.twoPi;
156
-
157
- }
158
-
159
- var steps = 1 / this.twoPi;
160
- var value = this.r * steps;
161
-
162
- var n = ( ( this.range * value ) + this.min ) - this.old;
163
-
164
- if(n >= this.step || n <= this.step){
165
- n = ~~ ( n / this.step );
166
- this.value = this.numValue( this.old + ( n * this.step ) );
167
- this.update( true );
168
- this.old = this.value;
169
- this.oldr = this.r;
170
- }
171
-
172
- };
173
-
174
- Circular.prototype.makePath = function(){
175
-
176
- var r = this.radius;
177
- //var start = 0;
178
- var end = this.percent * this.twoPi - 0.001;
179
- //var x1 = r + r * Math.sin(start);
180
- //var y1 = r - r * Math.cos(start);
181
- var x2 = r + r * Math.sin(end);
182
- var y2 = r - r * Math.cos(end);
183
- //var big = end - start > Math.PI ? 1 : 0;
184
- var big = end > Math.PI ? 1 : 0;
185
- return "M " + r + "," + r + " L " + r + "," + 0 + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2 + " Z";
186
-
187
- };
188
-
189
- Circular.prototype.update = function( up ){
190
-
191
- this.c[2].textContent = this.value;
192
- this.percent = ( this.value - this.min ) / this.range;
193
- Tools.setSvg( this.c[4], 'd', this.makePath() );
194
- if( up ) this.send();
195
-
196
- };
197
-
198
- export { Circular };