-
Notifications
You must be signed in to change notification settings - Fork 1
/
fonts.js
92 lines (72 loc) · 3.36 KB
/
fonts.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
(function(){
var pluginName = "fonts";
var plugin = function(){
$lib = AtKit.lib();
// Internationalisation
AtKit.addLocalisationMap("en", {
"fonts_dialogTitle" : "Page font settings",
"fonts_fontFace" : "Font Face",
"fonts_lineSpacing" : "Line Spacing",
"fonts_apply": "Apply"
});
AtKit.addLocalisationMap("ar", {
"fonts_dialogTitle" : "التحكم في نوع الخط",
"fonts_fontFace" : "نوع الخط",
"fonts_lineSpacing": "المسافات بين الأسطر",
"fonts_apply": "تطبيق"
});
// Font settings
var fontDialogs = {
'main': '<h1>' + AtKit.localisation('fonts_dialogTitle') + '</h1><label for="sbfontface">' + AtKit.localisation('fonts_fontFace') + ':</label> <select id="sbfontface"><option value="sitespecific">--Site Specific--</option><option value="arial">Arial</option><option value="courier">Courier</option><option value="cursive">Cursive</option><option value="fantasy">Fantasy</option><option value="georgia">Georgia</option><option value="helvetica">Helvetica</option><option value="impact">Impact</option><option value="monaco">Monaco</option><option value="monospace">Monospace</option><option value="sans-serif">Sans-Serif</option><option value="tahoma">Tahoma</option><option value="times new roman">Times New Roman</option><option value="trebuchet ms">Trebuchet MS</option><option value="verdant">Verdana</option></select><br /><br /> <label for="sblinespacing">' + AtKit.localisation('fonts_lineSpacing') + '</label> <input type="text" name="sblinespacing" id="sblinespacing" maxlength="3" size="3" value="100">%<br /><br /><button id="ATApplyFont">' + AtKit.localisation('fonts_apply') + '</a></div>'
};
AtKit.addFn('changeFont', function(args){
// Get all HTML tags from AtKit
var tags = AtKit.getHtmlTags();
if(args.fontFace != "--Site Specific--"){
// Change font family
for(var i = 0; i < tags.length; i++){
$lib(tags[i]).css('font-family', args.fontFace);
}
// Change line height
for(var k = 0; k < tags.length; k++){
$lib(tags[k]).css('line-height', args.lineHeight + '%');
}
// Set ATbar line height back to 0%
$lib('#sbar').find('div').css('line-height', '0%');
}
})
AtKit.addButton(
'fontSettings',
AtKit.localisation("fonts_dialogTitle"),
AtKit.getPluginURL() + 'images/font.png',
function(dialogs, functions){
AtKit.message(dialogs.main);
$lib('#ATApplyFont').click(function(){
AtKit.call('changeFont', {
'fontFace': $lib('#sbfontface').val(),
'lineHeight': $lib('#sblinespacing').val()
});
});
$lib("#sbfontface").focus();
},
fontDialogs, null
);
}
if(typeof window['AtKit'] == "undefined"){
window.AtKitLoaded = function(){
var eventAction = null;
this.subscribe = function(fn) {
eventAction = fn;
};
this.fire = function(sender, eventArgs) {
if (eventAction != null) {
eventAction(sender, eventArgs);
}
};
}
window['AtKitLoaded'] = new AtKitLoaded();
window['AtKitLoaded'].subscribe(function(){ AtKit.registerPlugin(pluginName, plugin); });
} else {
AtKit.registerPlugin(pluginName, plugin);
}
})();