uil 0.1.0 → 4.0.1

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,209 +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
- //if( ! e.target.files ) return;
128
-
129
- //var file = e.target.files[0];
130
-
131
- //this.c[3].type = "null";
132
- // console.log( this.c[4] )
133
-
134
- if( file === undefined ) return;
135
-
136
- var reader = new FileReader();
137
- var fname = file.name;
138
- var type = fname.substring(fname.lastIndexOf('.')+1, fname.length );
139
-
140
- if( type === 'png' || type === 'jpg' ) reader.readAsDataURL( file );
141
- else if( type === 'z' ) reader.readAsBinaryString( file );
142
- else if( type === 'sea' ) reader.readAsArrayBuffer( file );
143
- else reader.readAsText( file );
144
-
145
- reader.onload = function(e) {
146
-
147
- if( this.callback ) this.callback( e.target.result, fname, type );
148
- //this.c[3].type = "file";
149
- //this.send( e.target.result );
150
- }.bind(this);
151
-
152
- };
153
-
154
- Button.prototype.click = function( e ){
155
-
156
- var i = e.target.name || 0;
157
- var v = this.value[i];
158
-
159
- this.send( v );
160
-
161
- };
162
-
163
- Button.prototype.label = function( string, n ){
164
-
165
- n = n || 2;
166
- this.c[n].textContent = string;
167
-
168
- };
169
-
170
- Button.prototype.icon = function( string, y, n ){
171
-
172
- n = n || 2;
173
- this.s[n].padding = ( y || 0 ) +'px 0px';
174
- this.c[n].innerHTML = string;
175
-
176
- };
177
-
178
- Button.prototype.rSize = function(){
179
-
180
- Proto.prototype.rSize.call( this );
181
-
182
- var s = this.s;
183
- var w = this.sb;
184
- var d = this.sa;
185
-
186
- var i = this.lng;
187
- var dc = 3;
188
- var size = Math.floor( ( w-(dc*(i-1)) ) / i );
189
-
190
- while(i--){
191
-
192
- s[i+2].width = size + 'px';
193
- s[i+2].left = d + ( size * i ) + ( dc * i) + 'px';
194
-
195
- }
196
-
197
- if( this.isDragButton ){
198
- s[4].left = (d+size+dc) + 'px';
199
- s[4].width = size + 'px';
200
- }
201
-
202
- if( this.isLoadButton ){
203
- s[3].left = d + 'px';
204
- s[3].width = size + 'px';
205
- }
206
-
207
- };
208
-
209
- export { Button };
@@ -1,197 +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 = o.radius || 15;
16
-
17
- this.width = (this.radius*2)+20;
18
-
19
- if(o.width !== undefined){
20
- this.width = o.width;
21
- this.radius = ~~ (this.width-20)*0.5;
22
- }
23
-
24
- if(o.size !== undefined){
25
- this.width = o.size;
26
- this.radius = ~~ (this.width-20)*0.5;
27
- }
28
-
29
- this.w = this.height = this.radius * 2;
30
- this.h = o.height || (this.height + 40);
31
-
32
- this.twoPi = Math.PI * 2;
33
-
34
- this.top = 0;
35
-
36
- this.c[0].style.width = this.width +'px';
37
-
38
- if(this.c[1] !== undefined) {
39
-
40
- this.c[1].style.width = this.width +'px';
41
- this.c[1].style.textAlign = 'center';
42
- this.top = 20;
43
-
44
- }
45
-
46
- this.percent = 0;
47
-
48
- this.c[2] = Tools.dom( 'div', Tools.css.txtnumber + 'text-align:center; top:'+(this.height+24)+'px; width:'+this.width+'px; color:'+ this.fontColor );
49
-
50
- 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)' });
51
- 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 });
52
- 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 });
53
-
54
- this.c[3].events = [ 'mouseover', 'mousedown', 'mouseout' ];
55
-
56
- this.init();
57
-
58
- this.update();
59
-
60
- };
61
-
62
- Circular.prototype = Object.create( Proto.prototype );
63
- Circular.prototype.constructor = Circular;
64
-
65
- Circular.prototype.handleEvent = function( e ) {
66
-
67
- e.preventDefault();
68
-
69
- switch( e.type ) {
70
- case 'mouseover': this.over( e ); break;
71
- case 'mousedown': this.down( e ); break;
72
- case 'mouseout': this.out( e ); break;
73
-
74
- case 'mouseup': this.up( e ); break;
75
- case 'mousemove': this.move( e ); break;
76
- }
77
-
78
- };
79
-
80
- Circular.prototype.mode = function( mode ){
81
-
82
- switch(mode){
83
- case 0: // base
84
- this.s[2].color = this.fontColor;
85
- Tools.setSvg( this.c[3], 'fill','rgba(0,0,0,0.2)');
86
- Tools.setSvg( this.c[4], 'fill', this.fontColor );
87
- break;
88
- case 1: // over
89
- this.s[2].color = this.colorPlus;
90
- Tools.setSvg( this.c[3], 'fill','rgba(0,0,0,0.6)');
91
- Tools.setSvg( this.c[4], 'fill', this.colorPlus );
92
- break;
93
-
94
- }
95
- }
96
-
97
- Circular.prototype.over = function( e ){
98
-
99
- this.isOver = true;
100
- this.mode(1);
101
-
102
- };
103
-
104
- Circular.prototype.out = function( e ){
105
-
106
- this.isOver = false;
107
- if(this.isDown) return;
108
- this.mode(0);
109
-
110
- };
111
-
112
- Circular.prototype.up = function( e ){
113
-
114
- this.isDown = false;
115
- document.removeEventListener( 'mouseup', this, false );
116
- document.removeEventListener( 'mousemove', this, false );
117
-
118
- if(this.isOver) this.mode(1);
119
- else this.mode(0);
120
-
121
- this.sendEnd();
122
-
123
- };
124
-
125
- Circular.prototype.down = function( e ){
126
-
127
- this.isDown = true;
128
- document.addEventListener( 'mouseup', this, false );
129
- document.addEventListener( 'mousemove', this, false );
130
-
131
- this.rect = this.c[3].getBoundingClientRect();
132
- this.old = this.value;
133
- this.oldr = null;
134
- this.move( e );
135
-
136
- };
137
-
138
- Circular.prototype.move = function( e ){
139
-
140
- if( !this.isDown ) return;
141
-
142
- var x = this.radius - (e.clientX - this.rect.left);
143
- var y = this.radius - (e.clientY - this.rect.top);
144
-
145
- this.r = Math.atan2( y, x ) - (Math.PI * 0.5);
146
- this.r = (((this.r%this.twoPi)+this.twoPi)%this.twoPi);
147
-
148
- if( this.oldr !== null ){
149
-
150
- var dif = this.r - this.oldr;
151
- this.r = Math.abs(dif) > Math.PI ? this.oldr : this.r;
152
-
153
- if(dif > 6) this.r = 0;
154
- if(dif < -6) this.r = this.twoPi;
155
-
156
- }
157
-
158
- var steps = 1 / this.twoPi;
159
- var value = this.r * steps;
160
-
161
- var n = ( ( this.range * value ) + this.min ) - this.old;
162
-
163
- if(n >= this.step || n <= this.step){
164
- n = ~~ ( n / this.step );
165
- this.value = this.numValue( this.old + ( n * this.step ) );
166
- this.update( true );
167
- this.old = this.value;
168
- this.oldr = this.r;
169
- }
170
-
171
- };
172
-
173
- Circular.prototype.makePath = function(){
174
-
175
- var r = this.radius;
176
- //var start = 0;
177
- var end = this.percent * this.twoPi - 0.001;
178
- //var x1 = r + r * Math.sin(start);
179
- //var y1 = r - r * Math.cos(start);
180
- var x2 = r + r * Math.sin(end);
181
- var y2 = r - r * Math.cos(end);
182
- //var big = end - start > Math.PI ? 1 : 0;
183
- var big = end > Math.PI ? 1 : 0;
184
- return "M " + r + "," + r + " L " + r + "," + 0 + " A " + r + "," + r + " 0 " + big + " 1 " + x2 + "," + y2 + " Z";
185
-
186
- };
187
-
188
- Circular.prototype.update = function( up ){
189
-
190
- this.c[2].textContent = this.value;
191
- this.percent = ( this.value - this.min ) / this.range;
192
- Tools.setSvg( this.c[4], 'd', this.makePath() );
193
- if( up ) this.send();
194
-
195
- };
196
-
197
- export { Circular };