-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcodenameToadFish.js
More file actions
130 lines (117 loc) · 2.91 KB
/
Copy pathcodenameToadFish.js
File metadata and controls
130 lines (117 loc) · 2.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/*
FILE: jsonHTML_Experimental.js
CODE NAME: TOADFISH.
Description: Experimental objects which may be included within the jsonHTML
project in the near future.
These are more advanced objects that mainly produce grid like
structures, and are managed utilizing micronDB.
*/
var toadFish = {};
toadFish.create2DArray = function(r) {
var arr = [];
for(var i = 0; i < r; ++i) {
arr[i] = [];
}
return arr;
};
toadFish.structure = function(arr, colName) {
var container = $jConstruct('div', {
collectionName: colName,
}).css({
'clear': 'left',
'float': 'left',
'display': 'block',
});
for(var i = 0; i < arr.length; ++i) {
var holder = $jConstruct('div');
if(!arr[i].length) { //in case it's not a 2D array.
holder.addChild(arr[i]);
} else { //then it is a 2D array.
holder.css({
'float': 'left',
});
}
for(var j = 0; j < arr[i].length; ++j) {
holder.addChild(arr[i][j]);
}
container.addChild(holder);
}
container.getCell = function(r, c) {
return container.children[c].children[r];
};
return container;
};
/*
NAME:
DROP
DESCRIPTION:
An object class which can generate single layer
drop-down menu's using jsonHTML and CSS.
REQUIRES:
dropDown.css
SYNTAX AND USE:
var btn = sig();
var dropDown = new toadFish.drop(btn);
dropDown.addOption({
name: 'new group',
event: {
func: function() {
console.log(this);
},
type: 'click',
},
});
dropDown.appendTo('#parentObject');
*/
toadFish.drop = function(inputBtn) {
var container = sig('div', {
class: 'dropdown',
}).event('click', function() {
var elm = document.getElementById(dropDownContainer.id);
if(elm.style.display == 'none' || elm.style.display == "") {
dropDownContainer.css({
'display': 'block',
});
toadFish.dropVisible = 1;
}
});
var dropDownContainer = sig('div', {
class: 'dropdown-content',
}).event('mouseleave', function() {
var elm = document.getElementById(dropDownContainer.id);
if(elm.style.display == 'block') {
dropDownContainer.css({
'display': 'none',
});
toadFish.dropVisible = 0;
}
});
container.addOption = function(obj) {
var nwOption = sig('div', {
text: obj.name,
class: 'dropdown-content-link',
}).event(obj.event.type, obj.event.func);
dropDownContainer.addChild(nwOption);
return nwOption
};
container.addChild(inputBtn);
container.addChild(dropDownContainer);
return container;
};
/* View full license in LICENSE.md
)
c (
o ) )
p ( v1.3.1
y .---------------------.
r | _____ |___
i | .'`_,-._`'. __ \
g | / ( [ ] ) \ | ||
h | /.-""`( )`""-.\ | ||
t | ' <'```(.)```'> ' | _||
| <'```(.)```'> |/ _/
2 | <'``(.)``'> ./
0 | <``\_/``> |
1 | `'---'` |
6 \github.com/trillobite/
\_________________/ Keep it black, keep it free.*/