forked from Semantic-Org/example-github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeme.js
More file actions
executable file
·167 lines (151 loc) · 4.32 KB
/
theme.js
File metadata and controls
executable file
·167 lines (151 loc) · 4.32 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*******************************
Theme JS
*******************************/
/*
This is boilerplate to show initializing components
The way this is wrapped will vary by platform/framework
*/
$(document)
.ready(function() {
var
$sidebar = $('.ui.sidebar'),
$launcher = $('.launch'),
$css = $('link.themable'),
$menuToggle = $sidebar.find('.first.checkbox'),
$buttonToggle = $sidebar.find('.second.checkbox'),
$minimalToggle = $sidebar.find('.third.checkbox'),
$blockToggle = $sidebar.find('.fourth.checkbox'),
$ribbonToggle = $sidebar.find('.fifth.checkbox'),
$themeDropdown = $sidebar.find('.theme.dropdown'),
previousClass,
regExp = /(\/components\/).*(\/[a-z]*.css)/
;
$sidebar
.sidebar({
transition: 'push',
dimPage: false
})
.sidebar('attach events', $launcher)
;
$menuToggle
.checkbox('uncheck')
.checkbox({
onChecked: function() {
$('.wide.column').parent().append($('.wide.column'));
$('.vertical.tabular.menu').removeClass('right');
},
onUnchecked: function() {
$('.wide.column').parent().prepend($('.wide.column'));
$('.vertical.tabular.menu').addClass('right');
}
})
;
$buttonToggle
.checkbox('uncheck')
.checkbox({
onChange: function(layout) {
$('.forked.repo.icon')
.closest('.button')
.toggleClass('secondary')
;
$('.star.icon')
.closest('.button')
.toggleClass('labeled icon')
;
$('.cloud.download').closest('.button').toggleClass('green');
}
})
;
$minimalToggle
.checkbox('uncheck')
.checkbox({
onChecked: function() {
$('.column .vertical.menu')
.removeClass('tabular')
.addClass('secondary')
;
$('.ui.table')
.prev()
.attr('class', 'ui bottom attached latest segment')
;
},
onUnchecked: function() {
$('.column .vertical.menu')
.addClass('tabular')
.removeClass('secondary')
;
$('.ui.table')
.prev()
.attr('class', 'ui attached latest segment')
;
},
onChange: function(layout) {
$('.ui.table')
.toggleClass('very basic')
;
$('.git.compare')
.closest('.button')
.toggleClass('green positive')
;
$('.column .ui.button').toggleClass('basic');
}
})
;
$blockToggle
.checkbox('uncheck')
.checkbox({
onChecked: function() {
previousClass = $('.column .vertical.menu').attr('class');
$('.column .vertical.menu')
.attr('class', 'ui fluid vertical repo menu')
.find('.divider').attr('style', 'display:none')
;
},
onUnchecked: function() {
if(previousClass) {
$('.column .vertical.menu')
.attr('class', previousClass)
.find('.divider').removeAttr('style')
;
}
}
})
;
$ribbonToggle
.checkbox('uncheck')
.checkbox({
onChecked: function() {
$('.column .vertical.menu').attr('style', 'display: none;');
$('.alternate.menu').attr('style', 'display: block;');
},
onUnchecked: function() {
$('.column .vertical.menu').removeAttr('style');
$('.alternate.menu').removeAttr('style');
}
})
;
$themeDropdown
.dropdown({
onChange: function(theme) {
var
type = $(this).attr('name') || false
;
$.each($css, function() {
var
currentHREF = $(this).attr('href'),
newHREF = currentHREF.replace(regExp, '$1' + theme + '$2')
;
if(type == 'global' || currentHREF.search(type) !== -1) {
$(this).attr('href', newHREF);
}
});
// make other dropdown match
if(type == 'global') {
$themeDropdown.dropdown('set value', theme);
}
}
})
.dropdown('set selected', 'github')
;
})
;