-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgr.js
59 lines (44 loc) · 1.65 KB
/
gr.js
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
$.extend({
gr: function(jqobj) {
// find immediate child small GR
var smallGR = $('>.small-gr', jqobj);
console.log(smallGR);
// find immediate child large GR
var largeGR = $('>.large-gr', jqobj);
console.log(largeGR);
var gr = 0.5 * (1 + Math.sqrt(5));
// determine to split by width or height
if (jqobj.hasClass('width-gr')) {
var width = jqobj.width();
var smallWidth = (gr-1) * width / gr;
var largeWidth = width / gr;
console.log(width);
console.log(smallWidth);
console.log(largeWidth);
jqobj.css('display', '-webkit-box');
jqobj.css('-webkit-box-orient', 'horizontal');
// smallGR.css('-webkit-box-flex', '0');
// largeGR.css('-webkit-box-flex', '1');
smallGR.width(smallWidth);
largeGR.width(largeWidth);
$.gr(smallGR);
$.gr(largeGR);
} else if (jqobj.hasClass('height-gr')) {
var height = jqobj.height();
var smallHeight = (gr-1) * height / gr;
var largeHeight = height / gr;
console.log(height);
console.log(smallHeight);
console.log(largeHeight);
jqobj.css('display', '-webkit-box');
jqobj.css('-webkit-box-orient', 'vertical');
// smallGR.css('-webkit-box-flex', '0');
// largeGR.css('-webkit-box-flex', '1');
smallGR.height(smallHeight);
largeGR.height(largeHeight);
$.gr(smallGR);
$.gr(largeGR);
}
}
});
// jqobj is a jquery object