-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.coffee
68 lines (48 loc) · 1.89 KB
/
popup.coffee
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
$(document).ready ->
# get background page
bkg = chrome.extension.getBackgroundPage()
change_window_Font = (font, element) ->
bkg.changeFont(font, element)
change_window_color = (element, color) ->
bkg.changeColor(element, color)
change_extension_font = (element, e) ->
# prevent default
e.preventDefault()
# get the value of the selection list
query = "#" + "#{element}-font-list"
font = $("#{query}").val()
# attach link to google web fonts to head
$("head").append("<link href='http://fonts.googleapis.com/css?family=#{font}' rel='stylesheet' type='text/css'>")
# clean up font-name
temp = font.split("+")
font = temp.join(" ")
# attach css
$("#{element}").css 'font-family', font
$(this).css 'font-family', font
change_extension_color = (element, color , e) ->
# prevent default
e.preventDefault()
color = "#" + color
$("#{element}").css 'color', color
$('#h1-style').click (e) ->
# change extension settings
change_extension_font 'h1', e
change_extension_color 'h1', $('#h1-color').val(), e
# change window settings
change_window_Font $('#h1-font-list').val(), 'h1'
change_window_color 'h1', $('#h1-color').val()
$('#h2-style').click (e) ->
change_extension_color 'h2', $('#h2-color').val(), e
change_extension_font 'h2', e
change_window_Font $('#h2-font-list').val(), 'h2'
change_window_color 'h2', $('#h2-color').val()
$('#h3-style').click (e) ->
change_extension_color 'h3', $('#h3-color').val(), e
change_extension_font 'h3', e
change_window_Font $('#h3-font-list').val(), 'h3'
change_window_color 'h3', $('#h3-color').val()
$('#p-style').click (e) ->
change_extension_color 'p', $('#p-color').val(), e
change_extension_font 'p', e
change_window_Font $('#p-font-list').val(), 'p'
change_window_color 'p', $('#p-color').val()