-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathfix_size.js
More file actions
110 lines (97 loc) · 3.19 KB
/
fix_size.js
File metadata and controls
110 lines (97 loc) · 3.19 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
(function () {
'use strict';
function startPlugin() {
window.fix_size_plugin = true;
function addPlugin() {
Lampa.Lang.add({
settings_interface_size_fixed: {
be: 'Фіксаваны памер',
bg: 'Фиксиран размер',
cs: 'Pevná velikost',
en: 'Fixed size',
he: 'גודל קבוע',
pt: 'Tamanho fixo',
ru: 'Фиксированный размер',
uk: 'Фіксований розмір',
zh: '固定大小'
}
});
Lampa.SettingsApi.addParam({
component: 'interface',
param: {
name: 'interface_size_fixed',
type: 'select',
values: {
'10': '10',
'12': '12',
'14': '14',
'16': '16',
'18': '18',
'20': '20',
'22': '22',
'24': '24',
'28': '28',
'32': '32'
},
"default": '16'
},
field: {
name: Lampa.Lang.translate('settings_interface_size_fixed')
},
onChange: function onChange() {
var name = Lampa.Controller.enabled().name;
Lampa.Layer.update();
Lampa.Controller.toggle(name);
}
});
Lampa.Settings.listener.follow('open', function (e) {
if (e.name == 'interface') {
var item = e.body.find('[data-name="interface_size_fixed"]');
item.detach();
item.insertAfter(e.body.find('[data-name="interface_size"]'));
}
});
var css = $('style#fix_size_css');
if (!css.length) {
css = $('<style type="text/css" id="fix_size_css"></style>');
css.appendTo('head');
}
css.html('.card--category { width: 16em !important }');
var platform_screen = Lampa.Platform.screen;
Lampa.Platform.screen = function (need) {
if (need === 'tv') {
try {
var stack = new Error().stack.split('\n');
var offset = stack[0] === 'Error' ? 1 : 0;
if (/^( *at +new +)?create\$i/.test(stack[1 + offset]) && /^( *at +)?component(\/this)?\.append/.test(stack[2 + offset])) {
return false;
}
} catch (e) {}
}
return platform_screen(need);
};
var layer_update = Lampa.Layer.update;
Lampa.Layer.update = function (where) {
var font_size = parseInt(Lampa.Storage.field('interface_size_fixed')) || 16;
$('body').css({
fontSize: font_size + 'px'
});
layer_update(where);
};
var timer;
$(window).on('resize', function () {
clearTimeout(timer);
timer = setTimeout(function () {
Lampa.Layer.update();
}, 150);
});
Lampa.Layer.update();
}
if (window.appready) addPlugin();else {
Lampa.Listener.follow('app', function (e) {
if (e.type == 'ready') addPlugin();
});
}
}
if (!window.fix_size_plugin) startPlugin();
})();