cytoplasm 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/cytoplasm/cytoLogo.js.erb +3 -0
- data/app/assets/javascripts/cytoplasm/cytoRadio.js.erb +3 -2
- data/app/assets/javascripts/cytoplasm/cytoplasm.js.erb +45 -18
- data/app/assets/stylesheets/cytoplasm/cytoplasm.less +1 -5
- data/app/controllers/cytoplasm/fonts_controller.rb +26 -6
- data/app/controllers/cytoplasm/settings_controller.rb +4 -0
- data/app/views/cytoplasm/fonts/_installer.html.erb +107 -0
- data/app/views/cytoplasm/fonts/_li.html.erb +65 -0
- data/app/views/cytoplasm/fonts/_list.html.erb +20 -0
- data/app/views/cytoplasm/fonts/index.html.erb +5 -159
- data/app/views/cytoplasm/fonts/show.html.erb +11 -0
- data/app/views/cytoplasm/settings/colors.html.erb +1 -0
- data/app/views/cytoplasm/settings/{edit.html.erb → general.html.erb} +3 -193
- data/app/views/cytoplasm/settings/index.html.erb +4 -6
- data/app/views/cytoplasm/settings/layout.html.erb +56 -0
- data/config/routes.rb +5 -2
- data/lib/cytoplasm.rb +13 -5
- data/lib/cytoplasm/version.rb +1 -1
- data/test/dummy/app/views/demos/index.html.erb +12 -11
- data/test/dummy/app/views/demos/jquery.html.erb +107 -0
- data/test/dummy/app/views/home/index.html.erb +26 -57
- data/test/dummy/app/views/layouts/application.html.erb +2 -2
- data/test/dummy/config/routes.rb +2 -0
- data/test/dummy/log/development.log +99955 -0
- data/test/dummy/log/test.log +20 -0
- data/test/dummy/public/cytoplasm/cytoplasm.vars.less +7 -1
- data/test/dummy/public/fonts/Vitamin/VITAMINO-webfont.eot +0 -0
- data/test/dummy/public/fonts/Vitamin/VITAMINO-webfont.svg +136 -0
- data/test/dummy/public/fonts/Vitamin/VITAMINO-webfont.ttf +0 -0
- data/test/dummy/public/fonts/Vitamin/VITAMINO-webfont.woff +0 -0
- data/test/dummy/public/fonts/Vitamin/VITAMIN_-webfont.eot +0 -0
- data/test/dummy/public/fonts/Vitamin/VITAMIN_-webfont.svg +137 -0
- data/test/dummy/public/fonts/Vitamin/VITAMIN_-webfont.ttf +0 -0
- data/test/dummy/public/fonts/Vitamin/VITAMIN_-webfont.woff +0 -0
- data/test/dummy/public/fonts/Vitamin/demo.html +38 -0
- data/test/dummy/public/fonts/Vitamin/pizzadude.dk License.txt +8 -0
- data/test/dummy/public/fonts/Vitamin/stylesheet.css +28 -0
- data/test/dummy/public/fonts/enabled.yml +6 -2
- data/test/dummy/tmp/cache/assets/C84/4A0/sprockets%2F8a760be2f29a644c90004cd461744978 +0 -0
- data/test/dummy/tmp/cache/assets/CAC/280/sprockets%2F408a235a236b0a3aa1302733211db5ba +0 -0
- data/test/dummy/tmp/cache/assets/CAE/FD0/sprockets%2F3bb22e4d409072c2278c1771893ec19e +0 -0
- data/test/dummy/tmp/cache/assets/D03/6B0/sprockets%2Fd3cfc780201b87a3439e35c5236bb71a +0 -0
- data/test/dummy/tmp/cache/assets/D0E/7D0/sprockets%2F89200785fe2710582a6c1b8d04ae7fbe +0 -0
- data/test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 +0 -0
- data/test/dummy/tmp/cache/assets/D28/830/sprockets%2F1cd2012fe85799b84951d6fc7c8ff079 +0 -0
- data/test/dummy/tmp/cache/assets/D36/B20/sprockets%2F0dd47218aa33bc293a136c358f2eed67 +0 -0
- data/test/dummy/tmp/cache/assets/D50/750/sprockets%2F7fbcc321810c8f493f86364fee480ed9 +0 -0
- data/test/dummy/tmp/cache/assets/D73/5F0/sprockets%2F6aee922214ffea56b31595f1a5ed8c92 +0 -0
- data/test/dummy/tmp/cache/assets/DBE/210/sprockets%2Fbedb89fd02eac0dc7aa93c820c612343 +0 -0
- data/test/dummy/tmp/cache/assets/E69/B60/sprockets%2Ffdbf7ec615e9a92e4857cdade17f4daa +0 -0
- metadata +52 -16
- data/app/views/cytoplasm/fonts/_font_li.html.erb +0 -23
- data/test/dummy/tmp/pids/server.pid +0 -1
@@ -86,10 +86,11 @@
|
|
86
86
|
if (settings.widget.inputList.inputs.elements.find(':checked')) methods.value.apply(settings.widget.inputList.inputs.elements,[settings.widget.inputList.inputs.elements.find(':checked').val()]);
|
87
87
|
|
88
88
|
// Bindings
|
89
|
-
settings.widget.inputList.inputs.elements
|
89
|
+
//settings.widget.inputList.inputs.elements
|
90
|
+
$('input[name="'+$this.attr('name')+'"]:first-child').change($.debounce(100,true,function(e){
|
90
91
|
methods.value.apply(settings.widget.inputList.inputs.elements,[settings.widget.inputList.inputs.elements.filter(':checked').val()])
|
91
92
|
settings.events.change.apply(settings.widget.inputList.inputs.elements,[settings,e]);
|
92
|
-
}))
|
93
|
+
}));//.trigger('change');
|
93
94
|
settings.widget.buttonList.buttons.elements.bind({
|
94
95
|
mousedown:function(e){
|
95
96
|
e.preventDefault();
|
@@ -15,12 +15,7 @@ var Cytoplasm;
|
|
15
15
|
// Setup callback messages
|
16
16
|
$.each(["success","sending","error"],function(i,v){
|
17
17
|
var $this = $('#'+v+'_message');
|
18
|
-
if (!$this.is('*'))
|
19
|
-
$this = $('<p />').addClass('callback_message').attr("id",v+"_message");
|
20
|
-
//if (header.children(':first-child').is('h1')) $this.insertAfter(header.children(':first-child'));
|
21
|
-
//else $this.prependTo(header);
|
22
|
-
$this.hide().appendTo(header);
|
23
|
-
}
|
18
|
+
if (!$this.is('*')) $this = $('<p />').addClass('callback_message').attr("id",v+"_message").hide().appendTo(header);
|
24
19
|
});
|
25
20
|
});
|
26
21
|
})(jQuery);
|
@@ -33,7 +28,14 @@ var Cytoplasm;
|
|
33
28
|
};
|
34
29
|
var conf = {};
|
35
30
|
var vars = {};
|
36
|
-
var ready = false
|
31
|
+
var ready = false, readyFunctions = [
|
32
|
+
function(){
|
33
|
+
var allexceptheader = $('body').children(':not(header)').animate({opacity:1},250,function(){
|
34
|
+
$('body').css('overflow-y','scroll');
|
35
|
+
$(window).bind('beforeunload',function(){allexceptheader.animate({opacity:0},100);});
|
36
|
+
});
|
37
|
+
}
|
38
|
+
];
|
37
39
|
|
38
40
|
// Gradient manipulation library
|
39
41
|
var parseGradient = function(grad,reverse){
|
@@ -136,12 +138,19 @@ var Cytoplasm;
|
|
136
138
|
$('body').css("overflow","hidden").children(':not(header)').css("opacity",0);
|
137
139
|
|
138
140
|
// Fetch latest settings via AJAX
|
139
|
-
$.
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
141
|
+
$.ajax("/cytoplasm/settings/fetch",{
|
142
|
+
type:"POST",
|
143
|
+
success:function(data){
|
144
|
+
data = $.parseJSON(data);
|
145
|
+
conf = data.conf;
|
146
|
+
vars = data.vars;
|
147
|
+
$(document).ready(function(){
|
148
|
+
$('body').data('cytoplasm',settings);
|
149
|
+
methods.setStyles.apply();
|
150
|
+
ready = true;
|
151
|
+
$.each(readyFunctions,function(i,f){f.apply();});
|
152
|
+
});
|
153
|
+
}
|
145
154
|
});
|
146
155
|
},
|
147
156
|
setStyles:function(){
|
@@ -156,7 +165,8 @@ var Cytoplasm;
|
|
156
165
|
body:{
|
157
166
|
background:vars.colors.global.background,
|
158
167
|
font:vars.fonts.sizes.normal+" "+vars.fonts.faces.regular,
|
159
|
-
color:vars.colors.global.text
|
168
|
+
color:vars.colors.global.text,
|
169
|
+
padding:vars.layout.padding
|
160
170
|
},
|
161
171
|
'::selection':{
|
162
172
|
background:vars.colors.global.accent,
|
@@ -179,6 +189,8 @@ var Cytoplasm;
|
|
179
189
|
"font-weight":lightweight
|
180
190
|
},
|
181
191
|
header:{
|
192
|
+
margin:vars.layout.header.margin,
|
193
|
+
padding:vars.layout.header.padding,
|
182
194
|
'#logo':{
|
183
195
|
position:vars.layout.header.logo.position,
|
184
196
|
top:vars.layout.header.logo.y+10
|
@@ -190,6 +202,14 @@ var Cytoplasm;
|
|
190
202
|
}
|
191
203
|
}
|
192
204
|
},
|
205
|
+
'#main_content':{
|
206
|
+
margin:vars.layout.content.margin,
|
207
|
+
padding:vars.layout.content.padding
|
208
|
+
},
|
209
|
+
'footer':{
|
210
|
+
margin:vars.layout.footer.margin,
|
211
|
+
padding:vars.layout.footer.padding
|
212
|
+
},
|
193
213
|
'table.cytoTable':{
|
194
214
|
background:vars.colors.plugins.cytoTable.background,
|
195
215
|
td:{
|
@@ -286,17 +306,24 @@ var Cytoplasm;
|
|
286
306
|
destroy:function(){
|
287
307
|
$('body').data('cytoplasm',null);
|
288
308
|
},
|
289
|
-
ready:function(
|
309
|
+
ready:function(func){
|
310
|
+
if (typeof func != "function") return console.warn("$.Cytoplasm's ready method requires a function to be passed as its first and only argument.");
|
311
|
+
if (ready==true) return func.apply();
|
312
|
+
else readyFunctions.push(func);
|
313
|
+
|
314
|
+
/*
|
315
|
+
|
290
316
|
var interval = setInterval(function(){
|
291
|
-
if (ready) {
|
317
|
+
if (ready==true) {
|
292
318
|
clearInterval(interval);
|
293
319
|
var allexceptheader = $('body').children(':not(header)').animate({opacity:1},250,function(){
|
294
320
|
$('body').css('overflow-y','scroll');
|
295
321
|
$(window).bind('beforeunload',function(){allexceptheader.animate({opacity:0},100);});
|
296
|
-
|
322
|
+
func.apply();
|
297
323
|
});
|
298
324
|
}
|
299
325
|
},10);
|
326
|
+
*/
|
300
327
|
}
|
301
328
|
};
|
302
329
|
|
@@ -306,6 +333,6 @@ var Cytoplasm;
|
|
306
333
|
else $.error('Method ' + method + ' does not exist on jQuery.Cytoplasm!');
|
307
334
|
};
|
308
335
|
|
309
|
-
|
336
|
+
$.Cytoplasm();
|
310
337
|
|
311
338
|
})(jQuery);
|
@@ -15,8 +15,6 @@ h1, h2, h3, h4, h5, h6 {
|
|
15
15
|
|
16
16
|
// Header
|
17
17
|
header {
|
18
|
-
margin:0px;
|
19
|
-
padding:10px;
|
20
18
|
overflow:hidden;
|
21
19
|
|
22
20
|
h1 {
|
@@ -45,8 +43,6 @@ nav {
|
|
45
43
|
// Main Content
|
46
44
|
#main_content {
|
47
45
|
min-height:400px;
|
48
|
-
margin:0px;
|
49
|
-
padding:20px;
|
50
46
|
background:white;
|
51
47
|
overflow:hidden;
|
52
48
|
box-shadow:0px 0px 10px rgba(0,0,0,0.8);
|
@@ -64,7 +60,7 @@ nav {
|
|
64
60
|
|
65
61
|
// Footer
|
66
62
|
footer {
|
67
|
-
|
63
|
+
|
68
64
|
}
|
69
65
|
|
70
66
|
// jQuery Plugins
|
@@ -6,15 +6,22 @@ require 'fileutils'
|
|
6
6
|
|
7
7
|
module Cytoplasm
|
8
8
|
class FontsController < ApplicationController
|
9
|
+
before_filter :load_cache, :only => [:index,:show,:fetch_all]
|
9
10
|
|
10
|
-
|
11
|
+
# Configuration
|
12
|
+
@@directories = {"fontsquirrel" => "FontSquirrel","googlewebfonts" => "Google Web Fonts"}
|
11
13
|
@@fontsdir = "public/fonts"
|
12
14
|
@@gwf_file = @@fontsdir + "/googlewebfonts.yml"
|
13
15
|
@@enabled_file = @@fontsdir + "/enabled.yml"
|
14
16
|
|
17
|
+
# For internal usage, DO NOT MODIFY
|
18
|
+
@@cache = false
|
19
|
+
|
15
20
|
class << self
|
16
|
-
#attr_accessor :fonts
|
17
21
|
|
22
|
+
def directories
|
23
|
+
@@directories
|
24
|
+
end
|
18
25
|
def fonts
|
19
26
|
@@cache = fetch_fonts() if @@cache == false
|
20
27
|
return @fonts
|
@@ -195,9 +202,11 @@ module Cytoplasm
|
|
195
202
|
e = {}
|
196
203
|
["fontsquirrel","googlewebfonts"].each do |dir|
|
197
204
|
e[dir] = {}
|
198
|
-
enabled[dir].
|
205
|
+
enabled[dir].each do |fam,variants|
|
199
206
|
# Make list of variants to enable
|
200
|
-
|
207
|
+
c = []
|
208
|
+
c += variants.keys if dir=="googlewebfonts"
|
209
|
+
e[dir][fam] = c
|
201
210
|
end
|
202
211
|
end
|
203
212
|
open(@@enabled_file,"w+") {|f| f.write(e.to_yaml)}
|
@@ -315,16 +324,18 @@ module Cytoplasm
|
|
315
324
|
end
|
316
325
|
|
317
326
|
def fetch_all
|
318
|
-
@@cache = Cytoplasm::FontsController.fetch_fonts() if @@cache == false
|
319
327
|
render :text => Cytoplasm::Ajax.success(@@cache)
|
320
328
|
end
|
321
329
|
|
322
330
|
def index
|
323
|
-
@@cache = Cytoplasm::FontsController.fetch_fonts() if @@cache == false
|
324
331
|
@installed = Cytoplasm::FontsController.fetch_imported()
|
325
332
|
@enabled = Cytoplasm::FontsController.fetch_enabled()
|
326
333
|
end
|
327
334
|
|
335
|
+
def show
|
336
|
+
@font = Cytoplasm::FontsController.fetch_family(params[:directory],params[:family])
|
337
|
+
end
|
338
|
+
|
328
339
|
def import
|
329
340
|
render :text => Cytoplasm::Ajax.success(Cytoplasm::FontsController.import(params[:directory],params[:family]))
|
330
341
|
end
|
@@ -338,5 +349,14 @@ module Cytoplasm
|
|
338
349
|
render :text => Cytoplasm::Ajax.success(Cytoplasm::FontsController.disable(params[:directory],params[:family]))
|
339
350
|
end
|
340
351
|
|
352
|
+
private
|
353
|
+
def load_cache
|
354
|
+
@@cache = Cytoplasm::FontsController.fetch_fonts() if @@cache == false
|
355
|
+
end
|
356
|
+
def refresh_cache
|
357
|
+
@@cache = false
|
358
|
+
load_cache()
|
359
|
+
end
|
360
|
+
|
341
361
|
end
|
342
362
|
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
<h3>Install New Fonts</h3>
|
2
|
+
<table class="cytoTable">
|
3
|
+
<tr>
|
4
|
+
<td class='labelcell'>Directory:</td>
|
5
|
+
<td>
|
6
|
+
<input type="radio" name="fonts_directory" data-label="Font Squirrel API" value="fontsquirrel" data-exclude="true" checked="checked" class="cytoRadio" />
|
7
|
+
<input type="radio" name="fonts_directory" data-label="Google Web Fonts" value="googlewebfonts" data-exclude="true" />
|
8
|
+
</td>
|
9
|
+
</tr>
|
10
|
+
<tr>
|
11
|
+
<td class='labelcell'>Family:</td>
|
12
|
+
<td><select name="fonts_family" id="fontfamilyselect" data-exclude="true" class="cytoSelect"></select></td>
|
13
|
+
</tr>
|
14
|
+
<tr>
|
15
|
+
<td class='labelcell'>Options:</td>
|
16
|
+
<td><input type="checkbox" id="font_import_autoenable" data-exclude="true" checked="checked" /> Automatically enable this font after installing</td>
|
17
|
+
</tr>
|
18
|
+
<tr><td colspan="2"><button id="font_import_button" class="cytoButton large">Install Font Family</button></td></tr>
|
19
|
+
</table>
|
20
|
+
|
21
|
+
<script type="text/javascript">
|
22
|
+
(function($){
|
23
|
+
var Cytofonts;
|
24
|
+
$.cytoAjax("/cytoplasm/fonts/fetch_all",function(data){
|
25
|
+
Cytofonts = data;
|
26
|
+
$.Cytoplasm("ready",function(){
|
27
|
+
var fds = $('input[name=fonts_directory]');
|
28
|
+
var ffs = $('#fontfamilyselect');
|
29
|
+
var iae = $('#font_import_autoenable');
|
30
|
+
var ib = $('#font_import_button');
|
31
|
+
|
32
|
+
// Directory select
|
33
|
+
fds.cytoRadio("options",{
|
34
|
+
events:{
|
35
|
+
change:$.debounce(100,true,function(e){
|
36
|
+
var fonts = {};
|
37
|
+
var imported = {};
|
38
|
+
switch ($(this).cytoRadio("value")) {
|
39
|
+
case "fontsquirrel":
|
40
|
+
$.each(Cytofonts.fontsquirrel,function(fam,f){fonts[fam] = f.family_name;});
|
41
|
+
if (Cytofonts.imported.length>0) {
|
42
|
+
$.each(Cytofonts.imported,function(fam,f){imported[fam] = fam;});
|
43
|
+
iffs.cytoSelect("update",imported);
|
44
|
+
}
|
45
|
+
break;
|
46
|
+
case "googlewebfonts":
|
47
|
+
$.each(Cytofonts.googlewebfonts,function(fam,f){fonts[fam] = fam;});
|
48
|
+
break;
|
49
|
+
default:return false;
|
50
|
+
}
|
51
|
+
ffs.cytoSelect("update",fonts);
|
52
|
+
})
|
53
|
+
}
|
54
|
+
});
|
55
|
+
|
56
|
+
// Family select
|
57
|
+
ffs.cytoSelect("options",{
|
58
|
+
events:{
|
59
|
+
change:function(cy,e){
|
60
|
+
var dir = fds.cytoRadio("value");
|
61
|
+
var f = Cytofonts[dir][$(this).cytoSelect("value")];
|
62
|
+
if (f!=null) switch (dir) {
|
63
|
+
case "fontsquirrel":
|
64
|
+
// Check if font has already been imported
|
65
|
+
if (!$.isEmptyObject(Cytofonts.imported[dir]) && Cytofonts.imported[dir][f.family_urlname] != null) ib.addClass('active').html("Font Family Installed");
|
66
|
+
else ib.removeClass('active').html("Install Font Family");
|
67
|
+
break;
|
68
|
+
case "googlewebfonts":
|
69
|
+
console.log(Cytofonts.imported[dir][f.family]);
|
70
|
+
if (!$.isEmptyObject(Cytofonts.imported[dir]) && Cytofonts.imported[dir][f.family] != null) ib.addClass('active').html("Font Family Installed");
|
71
|
+
else ib.removeClass('active').html("Install Font Family");
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
}
|
76
|
+
});
|
77
|
+
|
78
|
+
// Font Import Button
|
79
|
+
ib.css({"margin-top":10}).click(function(e){
|
80
|
+
e.preventDefault();
|
81
|
+
var dir = fds.cytoRadio("value");
|
82
|
+
var f = Cytofonts[dir][ffs.cytoSelect("value")];
|
83
|
+
var name = (dir=="fontsquirrel") ? f.family_name : f.family;
|
84
|
+
var urlname = (dir=="fontsquirrel") ? f.family_urlname : f.family;
|
85
|
+
if (!ib.hasClass('active')) {
|
86
|
+
// Import font
|
87
|
+
$.cytoAjax("/cytoplasm/fonts/import",{directory:dir,family:urlname},function(data){
|
88
|
+
if (!iae.prop("checked")) $.cytoAjaxResponse('Font "'+name+'" has been installed successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
89
|
+
else $.cytoAjax("/cytoplasm/fonts/enable",{family:urlname,directory:dir},function(data2){
|
90
|
+
$.cytoAjaxResponse('Font "'+name+'" has been enabled successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
91
|
+
});
|
92
|
+
ib.addClass('active').html("Font Family Installed");
|
93
|
+
});
|
94
|
+
} else {
|
95
|
+
// Remove font
|
96
|
+
if (confirm("Are you sure you want to uninstall this font from your fonts library?")) $.cytoAjax("/cytoplasm/fonts/remove",{directory:dir,family:f},function(data){
|
97
|
+
$.cytoAjaxResponse('Font "'+name+'" has been uninstalled successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
98
|
+
ib.removeClass('active').html("Install Font Family");
|
99
|
+
});
|
100
|
+
}
|
101
|
+
});
|
102
|
+
|
103
|
+
});
|
104
|
+
|
105
|
+
});
|
106
|
+
})(jQuery);
|
107
|
+
</script>
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<% f["variants"] = f["familyinfo"] if dir == "fontsquirrel" %>
|
2
|
+
<li data-family="<%=fam%>" data-directory="<%=dir%>" data-uid="<%=uid = Cytoplasm.generate_uid()%>" style="padding:0px;list-style:none;margin:0px;">
|
3
|
+
<table class="cytoTable">
|
4
|
+
<tr><td colspan=2><h6><%=link_to(fam,cytoplasm_show_font_url(dir,fam))%></h6></td></tr>
|
5
|
+
<% unless f["variants"].nil? or f["variants"].empty? %><% f["variants"].each do |v| %>
|
6
|
+
<tr>
|
7
|
+
<% if dir=="fontsquirrel" %>
|
8
|
+
<td class="labelcell"><%=v["style_name"]%>:</td>
|
9
|
+
<td style="background:white;text-align:center;"><%=image_tag(v["listing_image"])%></td>
|
10
|
+
<% elsif dir=="googlewebfonts" %>
|
11
|
+
<td class="labelcell"><%=v%>:</td>
|
12
|
+
<td style="background:white;text-align:center;"><span class="gwf-preview" style="font-family:'<%=fam%>';font-size:48px;font-weight:<%=v%>;">AaBbCcDdEeFfGgHhIiJjKk</span></td>
|
13
|
+
<% end %>
|
14
|
+
</tr>
|
15
|
+
<% end end %>
|
16
|
+
<tr>
|
17
|
+
<td colspan=2>
|
18
|
+
<%=link_to("Details",((dir=="fontsquirrel")?"http://www.fontsquirrel.com/fonts/":"http://www.google.com/webfonts/specimen/")+fam,:class => "font_details",:target => "_blank")%> |
|
19
|
+
<%=link_to("Preview","#",:class => "font_preview")%> |
|
20
|
+
<%=link_to((Cytoplasm::FontsController.is_enabled?(dir,fam))?"Disable":"Enable","#",:class => "font_enable_disable")%> |
|
21
|
+
<%=link_to("Uninstall","#",:class => "font_uninstall")%>
|
22
|
+
</td>
|
23
|
+
</tr>
|
24
|
+
</table>
|
25
|
+
</li>
|
26
|
+
|
27
|
+
<script type="text/javascript">
|
28
|
+
(function($){
|
29
|
+
$.Cytoplasm("ready",function(){
|
30
|
+
|
31
|
+
$('[data-uid="<%=uid%>"] .font_enable_disable').click(function(e){
|
32
|
+
e.preventDefault();
|
33
|
+
var $this = $(this);
|
34
|
+
var li = $this.parents("li");
|
35
|
+
var fam = li.data('family');
|
36
|
+
var dir = li.data('directory');
|
37
|
+
|
38
|
+
if ($this.html()=="Enable") {
|
39
|
+
$.cytoAjax("/cytoplasm/fonts/enable",{family:fam,directory:dir},function(data){
|
40
|
+
$.cytoAjaxResponse('Font "'+fam+'" has been enabled successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
41
|
+
$this.html("Disable");
|
42
|
+
});
|
43
|
+
} else if ($this.html()=="Disable") {
|
44
|
+
$.cytoAjax("/cytoplasm/fonts/disable",{family:li.data('family'),directory:dir},function(data){
|
45
|
+
$.cytoAjaxResponse('Font "'+fam+'" has been disabled successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
46
|
+
$this.html("Enable");
|
47
|
+
});
|
48
|
+
} else return false;
|
49
|
+
});
|
50
|
+
|
51
|
+
$('.font_uninstall').click(function(e){
|
52
|
+
e.preventDefault();
|
53
|
+
var $this = $(this);
|
54
|
+
var li = $this.parents("li");
|
55
|
+
var fam = li.data('family');
|
56
|
+
var dir = li.data('directory');
|
57
|
+
|
58
|
+
if (confirm('Are you sure you want to uninstall this font?')) $.cytoAjax("/cytoplasm/fonts/remove",{family:fam,directory:dir},function(data){
|
59
|
+
$.cytoAjaxResponse('Font "'+fam+'" has been uninstalled successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
60
|
+
li.hide(400);
|
61
|
+
});
|
62
|
+
});
|
63
|
+
});
|
64
|
+
})(jQuery);
|
65
|
+
</script>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%
|
2
|
+
uid = Cytoplasm.generate_uid()
|
3
|
+
Cytoplasm::FontsController.directories.each do |dir,name| %>
|
4
|
+
<% if list[dir].any? %>
|
5
|
+
<h4><%=name%></h4>
|
6
|
+
<ul data-uid="<%=uid%>" style="margin:0px;padding:0px;">
|
7
|
+
<% list[dir].each do |fam,f| %>
|
8
|
+
<%=render :partial => 'li', :locals => {:fam => fam, :f => f, :dir => dir} %>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
<% end %>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<script type="text/javascript">
|
15
|
+
(function($){
|
16
|
+
$.Cytoplasm("ready",function(){
|
17
|
+
var ul = $('[data-uid="<%=uid%>"]');
|
18
|
+
});
|
19
|
+
})(jQuery);
|
20
|
+
</script>
|