-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathscript.js
109 lines (88 loc) · 2.35 KB
/
script.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
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
$(document).ready(function() {
viewportHeight = $(window).innerHeight();
$('.stage').css('min-height', viewportHeight);
// Set initial values
//$('.base_size').val(16).select();
$('.base_size').val(24);
baseSize = 1.5;
scaleRatio = 1.5;
scaleCalc();
$('.input_select_all').click(function () {
$(this).select();
});
$('.base_size').bind("change paste keyup", function() {
if($.isNumeric($(this).val())){
baseSize = $(this).val() / 16;
}
else {
baseSize = 0;
};
$('.base_em').text(Math.round(baseSize*1000)/1000);
scaleSelect();
});
$('.preview_text').bind("change paste keyup", function() {
previewText = $(this).val();
$('.scale_preview_text').text(previewText);
});
$('.web_font').bind("change paste keyup", function() {
webFont = $(this).val();
$('head').append(webFont);
});
$('.web_font_name').bind("change paste keyup", function() {
webFontName = $(this).val();
$('.scale_webfont').attr('style', webFontName);
});
$('.font_scale').bind("change paste keyup", function() {
scaleSelect();
});
function scaleSelect() {
scaleRatio = $('.font_scale').val();
scaleCalc();
};
function scaleCalc() {
function scaleHigh() {
a = baseSize;
b = scaleRatio;
result = baseSize;
$($('.scale_high').get().reverse()).each(function(index) {
$(this).css('font-size', Math.round(result*1000)/1000 + 'em');
result = a*b;
a = result;
});
};
function scaleHighLabel() {
a = 1;
b = scaleRatio;
result = 1;
$($('.scale_high_label').get().reverse()).each(function(index) {
$(this).text(Math.round(result*1000)/1000 + 'em');
result = a*b;
a = result;
});
};
function scaleLow() {
a = baseSize;
b = scaleRatio;
result = baseSize;
$('.scale_low').each(function(index) {
result = a/b;
a = result;
$(this).css('font-size', Math.round(result*1000)/1000 + 'em');
});
};
function scaleLowLabel() {
a = 1;
b = scaleRatio;
result = 1;
$('.scale_low_label').each(function(index) {
result = a/b;
a = result;
$(this).text(Math.round(result*1000)/1000 + 'em');
});
};
scaleHigh();
scaleHighLabel();
scaleLow();
scaleLowLabel();
};
});