cytoplasm 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/app/assets/javascripts/cytoplasm/cytoAjax.js.erb +6 -7
- data/app/assets/javascripts/cytoplasm/cytoRadio.js.erb +4 -0
- data/app/assets/javascripts/cytoplasm/cytoSelect.js.erb +1 -1
- data/app/assets/javascripts/cytoplasm/cytoplasm.js.erb +90 -11
- data/app/assets/stylesheets/cytoplasm/cytoplasm.less +5 -0
- data/app/controllers/cytoplasm/fonts_controller.rb +86 -15
- data/app/views/cytoplasm/fonts/index.html.erb +113 -0
- data/app/views/cytoplasm/settings/edit.html.erb +2 -2
- data/app/views/cytoplasm/settings/index.html.erb +1 -1
- data/config/routes.rb +10 -2
- data/lib/cytoplasm.rb +1 -1
- data/lib/cytoplasm/version.rb +1 -1
- data/test/dummy/Gemfile +40 -0
- data/test/dummy/Gemfile.lock +133 -0
- data/test/dummy/app/views/demos/index.html.erb +1 -0
- data/test/dummy/app/views/docs/index.html.erb +1 -0
- data/test/dummy/config/initializers/cytoplasm.vars.yml +3 -2
- data/test/dummy/dummy.gemspec +0 -0
- data/test/dummy/log/development.log +115966 -0
- data/test/dummy/public/cytoplasm/cytoplasm.vars.less +4 -5
- data/test/dummy/public/fonts/googlewebfonts.yml +4 -0
- data/test/dummy/tmp/cache/assets/C77/C20/sprockets%2F165a39476f3fa731c0af49432141049c +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/CC4/F20/sprockets%2F7579067f2838847e2cf44a39d418fb1b +0 -0
- data/test/dummy/tmp/cache/assets/D03/6B0/sprockets%2Fd3cfc780201b87a3439e35c5236bb71a +0 -0
- data/test/dummy/tmp/cache/assets/D06/7A0/sprockets%2Fa46b76e739460d2691f4121ffa8a0ca0 +0 -0
- data/test/dummy/tmp/cache/assets/D0E/4A0/sprockets%2F6b27287928ba630c1b25dfa80ee18b48 +0 -0
- data/test/dummy/tmp/cache/assets/D0E/7D0/sprockets%2F89200785fe2710582a6c1b8d04ae7fbe +0 -0
- data/test/dummy/tmp/cache/assets/D12/1E0/sprockets%2Fba248329196c372b79d1f4c4f2a771bf +0 -0
- data/test/dummy/tmp/cache/assets/D14/170/sprockets%2F40a7b83bb067eea7ce2c8394e1529287 +0 -0
- data/test/dummy/tmp/cache/assets/D49/450/sprockets%2F2b7712073416ff8853efff262ddec53f +0 -0
- data/test/dummy/tmp/cache/assets/D50/750/sprockets%2F7fbcc321810c8f493f86364fee480ed9 +0 -0
- data/test/dummy/tmp/cache/assets/D6E/3E0/sprockets%2F1be4cbdc9c19703c546405f087aee92d +0 -0
- data/test/dummy/tmp/cache/assets/D73/5F0/sprockets%2F6aee922214ffea56b31595f1a5ed8c92 +0 -0
- data/test/dummy/tmp/cache/assets/D87/C40/sprockets%2F9dcd7a6999affe28e91e514cee079016 +0 -0
- data/test/dummy/tmp/cache/assets/DA4/140/sprockets%2F24502b9d4e4eea6f709e089c0fdff30f +0 -0
- data/test/dummy/tmp/cache/assets/DBE/210/sprockets%2Fbedb89fd02eac0dc7aa93c820c612343 +0 -0
- data/test/dummy/tmp/cache/assets/DFB/400/sprockets%2F0c2b7f7aeeee011a378b79e3bc28fae5 +0 -0
- data/test/dummy/tmp/cache/assets/E05/E70/sprockets%2Fead5bfd3417fc5de81d3794c3e443cfe +0 -0
- data/test/dummy/tmp/cache/assets/E69/B60/sprockets%2Ffdbf7ec615e9a92e4857cdade17f4daa +0 -0
- data/test/dummy/tmp/cache/assets/E8D/B40/sprockets%2Fb862bf7fb4b4c634aeaa9dfc97babc6b +0 -0
- metadata +35 -4
@@ -15,21 +15,20 @@
|
|
15
15
|
};
|
16
16
|
$.cytoAjax = function(script,data_to_pass,success,error){
|
17
17
|
// Set default parameters
|
18
|
-
if (typeof script != "string" || script == "") return
|
18
|
+
if (typeof script != "string" || script == "") return console.warn("$.cytoAjax requires a string as the first parameter (script).");
|
19
19
|
if (data_to_pass==null || typeof data_to_pass != "object") {
|
20
20
|
if (typeof data_to_pass == "function") {
|
21
|
-
if (typeof success == "function") error = success;
|
21
|
+
if (success!=null && typeof success == "function") error = success;
|
22
22
|
success = data_to_pass;
|
23
23
|
}
|
24
|
-
data_to_pass = {
|
25
|
-
}
|
24
|
+
data_to_pass = {};
|
25
|
+
}
|
26
26
|
|
27
27
|
// Make request
|
28
28
|
$.ajax({
|
29
29
|
url:script,
|
30
|
-
type:'
|
31
|
-
|
32
|
-
processData:false,
|
30
|
+
type:'POST',
|
31
|
+
data:data_to_pass,
|
33
32
|
success:function(data,textStatus,jqXHR) {
|
34
33
|
try {
|
35
34
|
data = $.parseJSON(data);
|
@@ -94,6 +94,10 @@
|
|
94
94
|
mousedown:function(e){
|
95
95
|
e.preventDefault();
|
96
96
|
if ($(this).hasClass('active')) return false;
|
97
|
+
$(this).addClass('active');
|
98
|
+
},
|
99
|
+
mouseup:function(e){
|
100
|
+
e.preventDefault();
|
97
101
|
methods.value.apply($this,[$(this).data('cytoradio-value')]);
|
98
102
|
settings.widget.inputList.inputs.elements.trigger('change');
|
99
103
|
},
|
@@ -392,7 +392,7 @@
|
|
392
392
|
var settings = $this.data('cytoSelect');
|
393
393
|
if (!$this.hasClass('cytoSelect') || settings==null) return console.warn("You must instanciate $.cytoSelect before calling the clear method!");
|
394
394
|
|
395
|
-
$this.children('option').
|
395
|
+
$this.children('option').remove();
|
396
396
|
if (refresh) methods.refresh.apply($this);
|
397
397
|
});
|
398
398
|
},
|
@@ -10,11 +10,7 @@ var Cytoplasm;
|
|
10
10
|
|
11
11
|
$(document).ready(function(){
|
12
12
|
// Setup header
|
13
|
-
var header = $("header");
|
14
|
-
header.find('h1').click(function(){window.location = "<%=((defined? root_url) ? root_url : "/")%>";});
|
15
|
-
|
16
|
-
// Fix for cytoButtons not activating
|
17
|
-
|
13
|
+
var header = $("header").find('h1').click(function(){window.location = "<%=((defined? root_url) ? root_url : "/")%>";}).end();
|
18
14
|
|
19
15
|
// Setup callback messages
|
20
16
|
$.each(["success","sending","error"],function(i,v){
|
@@ -39,24 +35,95 @@ var Cytoplasm;
|
|
39
35
|
var vars = {};
|
40
36
|
var ready = false;
|
41
37
|
|
38
|
+
var parseGradient = function(grad,reverse){
|
39
|
+
// Return untouched if not gradient
|
40
|
+
if (grad.indexOf("gradient")==-1) return grad;
|
41
|
+
if (reverse!=true) reverse = false;
|
42
|
+
var o = {};
|
43
|
+
|
44
|
+
var halves = grad.split("(");
|
45
|
+
o.type = halves[0];
|
46
|
+
o.params = halves[1].split(")")[0].split(",");
|
47
|
+
if (o.type.indexOf("linear")>-1) {
|
48
|
+
if (isColorStop(o.params[0])) o.params.unshift("to bottom");
|
49
|
+
o.params[0] = normalizeDirection(o.params[0]);
|
50
|
+
if (reverse) o.params[0] = invertDirection(o.params[0]);
|
51
|
+
o.dir = o.params[0];
|
52
|
+
o.colors = o.params.slice(1);
|
53
|
+
} else if (o.type.indexOf("radial")>-1) {
|
54
|
+
var firstcolor;
|
55
|
+
if (isColorStop(o.params[0])) o.params.unshift("center");
|
56
|
+
$.each(o.params,function(i,p){if (isColorStop(p)) {firstcolor = i;return false;}});
|
57
|
+
o.dir = o.params[0];
|
58
|
+
o.colors = o.params.slice(firstcolor);
|
59
|
+
} else return false;
|
60
|
+
|
61
|
+
var params = o.params.join(",");
|
62
|
+
|
63
|
+
// String types
|
64
|
+
o.shortened = o.type+"("+denormalizeDirection(o.dir)+","+o.colors.join(",")+");";
|
65
|
+
|
66
|
+
o.expanded = "background-color:"+((o.colors[0].indexOf("%")>-1) ? o.colors[0].split(" ").slice(0,-1).join(" ") : o.colors[0]) + ";";
|
67
|
+
o.expanded += "background-image:-webkit-"+o.type+"("+params+");";
|
68
|
+
o.expanded += "background-image:-moz-"+o.type+"("+params+");";
|
69
|
+
o.expanded += "background-image:-o-"+o.type+"("+params+");";
|
70
|
+
o.expanded += "background-image:-ms-"+o.type+"("+params+");";
|
71
|
+
o.expanded += "background-image:"+o.shortened;
|
72
|
+
|
73
|
+
return o;
|
74
|
+
};
|
75
|
+
var expandGradient = function(orig){
|
76
|
+
if (typeof orig != "string") return console.warn("Cytoplasm.expandGradient only accepts string arguments!");
|
77
|
+
// Return untouched if not gradient
|
78
|
+
if (orig.indexOf("gradient")==-1) return orig;
|
79
|
+
|
80
|
+
var g = parseGradient(orig);
|
81
|
+
return g.expanded;
|
82
|
+
};
|
42
83
|
var reverseGradient = function(orig){
|
43
84
|
if (typeof orig != "string") return console.warn("Cytoplasm.reverseGradient only accepts string arguments!");
|
44
85
|
// Return untouched if not gradient
|
45
86
|
if (orig.indexOf("gradient")==-1) return orig;
|
46
|
-
|
47
|
-
var
|
48
|
-
|
87
|
+
|
88
|
+
var g = parseGradient(orig,true);
|
89
|
+
return g.shortened;
|
90
|
+
};
|
91
|
+
var normalizeDirection = function(dir){
|
49
92
|
var newdir = dir;
|
93
|
+
if (newdir.slice(0,3)!="to ") return newdir;
|
94
|
+
return invertDirection(newdir).slice(3);
|
95
|
+
};
|
96
|
+
var denormalizeDirection = function(dir){
|
97
|
+
var newdir = dir;
|
98
|
+
if (newdir.slice(0,3)=="to ") return newdir;
|
99
|
+
return "to "+invertDirection(newdir);
|
100
|
+
};
|
101
|
+
var invertDirection = function(dir){
|
102
|
+
var newdir = " "+dir+" ";
|
50
103
|
if (dir.indexOf("top")>-1) newdir = newdir.replace("top","bottom");
|
51
104
|
else if (dir.indexOf("bottom")>-1) newdir = newdir.replace("bottom","top");
|
52
105
|
if (dir.indexOf("left")>-1) newdir = newdir.replace("left","right");
|
53
106
|
else if (dir.indexOf("right")>-1) newdir = newdir.replace("right","left");
|
54
|
-
|
107
|
+
newdir = newdir.slice(2,-2);
|
108
|
+
return newdir;
|
109
|
+
};
|
110
|
+
var isColorStop = function(str){
|
111
|
+
var cache, p=parseInt, nstr = str;
|
112
|
+
if (nstr.slice(-1) == "%") nstr = nstr.split(" ").slice(0,-1).join(" ");
|
113
|
+
nstr = nstr.replace(/\s\s*/g,'') // Remove all spaces
|
114
|
+
if ($.inArray(nstr,['aqua','black','blue','fuchsia','gray','grey','green','lime','maroon','navy','olive','purple','red','silver','teal','white','yellow'])>-1) return true;
|
115
|
+
return (nstr.match(/^#([\da-fA-F]{2})([\da-fA-F]{2})([\da-fA-F]{2})/) || nstr.match(/^#([\da-fA-F])([\da-fA-F])([\da-fA-F])/) || nstr.match(/^rgba\(([\d]+),([\d]+),([\d]+),([\d]+|[\d]*.[\d]+)\)/) || nstr.match(/^rgb\(([\d]+),([\d]+),([\d]+)\)/));
|
55
116
|
};
|
56
117
|
var compileStyles = function(element,styles){
|
57
118
|
output = "";
|
58
119
|
output += element+" { ";
|
59
|
-
$.each(styles,function(prop,value){
|
120
|
+
$.each(styles,function(prop,value){
|
121
|
+
if (typeof value == "object") output += compileStyles(prop,value);
|
122
|
+
else {
|
123
|
+
if (prop == "background" && value.indexOf("gradient")>-1) output += expandGradient(value);
|
124
|
+
else output += prop+" : "+value+"; ";
|
125
|
+
}
|
126
|
+
});
|
60
127
|
output += " } ";
|
61
128
|
return output;
|
62
129
|
};
|
@@ -140,7 +207,19 @@ var Cytoplasm;
|
|
140
207
|
};
|
141
208
|
|
142
209
|
// Heading sizes
|
143
|
-
|
210
|
+
(function(){
|
211
|
+
var verbose = false;
|
212
|
+
var huge = parseInt(vars.fonts.sizes.huge), normal = parseInt(vars.fonts.sizes.normal);
|
213
|
+
var hRange = huge - normal;
|
214
|
+
$.each([1,2,3,4,5,6],function(i,num){
|
215
|
+
if (verbose) console.log("----- H"+num+" -----");
|
216
|
+
var factor = Math.pow(vars.fonts.sizes.heading_factor,i);
|
217
|
+
if (verbose) console.log("Factor: "+factor);
|
218
|
+
var size = parseInt(vars.fonts.sizes.normal) + (hRange/factor);
|
219
|
+
if (verbose) console.log("Size: "+size);
|
220
|
+
$('h'+num.toString()).css("font-size",size);
|
221
|
+
});
|
222
|
+
})();
|
144
223
|
// Logo positioning
|
145
224
|
if (vars.layout.header.logo.align == "center") styles.header["#logo"].left = (($(window).width()-$('header #logo').width())/2) + vars.layout.header.logo.x;
|
146
225
|
else styles.header["#logo"][vars.layout.header.logo.align] = vars.layout.header.logo.x+10;
|
@@ -1,42 +1,113 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'open-uri'
|
3
|
+
require 'yaml'
|
3
4
|
|
4
5
|
module Cytoplasm
|
5
6
|
class FontsController < ApplicationController
|
6
7
|
|
8
|
+
@@fonts = {
|
9
|
+
"fontsquirrel" => false,
|
10
|
+
"googlewebfonts" => false,
|
11
|
+
"imported" => false
|
12
|
+
}
|
13
|
+
@@fontsdir = "public/fonts"
|
14
|
+
@@gwf_file = @@fontsdir + "/googlewebfonts.yml"
|
15
|
+
|
7
16
|
def fetch_imported
|
8
|
-
imported
|
9
|
-
|
17
|
+
return @@fonts["imported"] unless @@fonts["imported"] == false
|
18
|
+
|
19
|
+
imported = {"fontsquirrel" => {}, "googlewebfonts" => {}}
|
10
20
|
|
11
|
-
#
|
12
|
-
|
13
|
-
fontsdir = Dir.open(fontsdir)
|
14
|
-
else
|
21
|
+
# Create @@fontsdir if it doesn't exist
|
22
|
+
unless File.exists?(@@fontsdir)
|
15
23
|
Dir.chdir("public")
|
16
|
-
fontsdir = Dir.mkdir("fonts")
|
24
|
+
@@fontsdir = Dir.mkdir("fonts")
|
17
25
|
Dir.chdir("../")
|
18
26
|
end
|
19
27
|
|
20
|
-
|
21
|
-
|
28
|
+
# Create @@gwf_file if it doesn't exist
|
29
|
+
File.open(@@gwf_file,'w') {|f| f.write("")} unless File.exists?(@@gwf_file)
|
30
|
+
|
31
|
+
# Fetch imported FontSquirrel fonts
|
32
|
+
Dir.open(@@fontsdir).each {|file| imported["fontsquirrel"][file] = fetch_fs_family(file) if File.directory?(file) and file!="." and file!=".."}
|
33
|
+
|
34
|
+
# Attempt to load YAML from @@gwf_file
|
35
|
+
begin
|
36
|
+
c = YAML::load_file(@@gwf_file)
|
37
|
+
rescue
|
38
|
+
puts "Failed to parse YAML in #{@@gwf_file}!"
|
22
39
|
end
|
23
|
-
|
40
|
+
|
41
|
+
# Fetch imported GoogleWebFonts fonts
|
42
|
+
c["imported"].each {|f| imported["googlewebfonts"][f] = fetch_gwf_family(f)} unless c["imported"].nil?
|
43
|
+
|
44
|
+
@@fonts["imported"] = imported
|
45
|
+
return @@fonts["imported"]
|
24
46
|
end
|
25
47
|
|
26
|
-
def
|
27
|
-
return
|
48
|
+
def fetch_fs_all
|
49
|
+
return @@fonts["fontsquirrel"] unless @@fonts["fontsquirrel"] == false
|
50
|
+
fonts = {}
|
51
|
+
fetch_json("http://www.fontsquirrel.com/api/fontlist/all").each {|f| fonts[f["family_name"]] = f}
|
52
|
+
@@fonts["fontsquirrel"] = fonts
|
53
|
+
return @@fonts["fontsquirrel"]
|
54
|
+
end
|
55
|
+
def fetch_gwf_all
|
56
|
+
return @@fonts["googlewebfonts"] unless @@fonts["googlewebfonts"] == false
|
57
|
+
gwf = {}
|
58
|
+
fetch_json("https://www.googleapis.com/webfonts/v1/webfonts?key="+Cytoplasm.conf("fontloader.googlewebfonts_apikey"))["items"].each {|f| gwf[f["family"]] = f}
|
59
|
+
@@fonts["googlewebfonts"] = gwf
|
60
|
+
return @@fonts["googlewebfonts"]
|
61
|
+
end
|
62
|
+
def fetch_fs_family(family)
|
63
|
+
fetch_json("http://www.fontsquirrel.com/api/familyinfo/"+family)
|
64
|
+
end
|
65
|
+
def fetch_gwf_family(family)
|
66
|
+
gwf = fetch_gwf_all()
|
67
|
+
return (!gwf[family].nil?) ? gwf[family] : false;
|
28
68
|
end
|
29
69
|
|
30
70
|
def fetch_all
|
31
|
-
success = {"fontsquirrel" => {}, "googlewebfonts" => {},"imported" => {}}
|
71
|
+
success = {"fontsquirrel" => {}, "googlewebfonts" => {},"imported" => {"fontsquirrel" => {}, "googlewebfonts" => {}}}
|
32
72
|
|
33
|
-
success["fontsquirrel"] =
|
34
|
-
|
73
|
+
success["fontsquirrel"] = fetch_fs_all()
|
74
|
+
success["googlewebfonts"] = fetch_gwf_all()
|
35
75
|
success["imported"] = fetch_imported()
|
36
76
|
|
37
77
|
render :text => Cytoplasm::Ajax.success(success)
|
38
78
|
end
|
39
79
|
|
80
|
+
def import
|
81
|
+
puts params
|
82
|
+
success = {}
|
83
|
+
case params[:directory]
|
84
|
+
when "fontsquirrel"
|
85
|
+
open(@@fontsdir+"/"+params[:family]['family_urlname']+".zip","wb") do |file|
|
86
|
+
success["url"] = "http://www.fontsquirrel.com/fontfacekit/"+params[:family]['family_urlname']
|
87
|
+
file << open(success["url"]).read
|
88
|
+
end
|
89
|
+
|
90
|
+
|
91
|
+
when "googlewebfonts"
|
92
|
+
|
93
|
+
end
|
94
|
+
render :text => Cytoplasm::Ajax.success(success)
|
95
|
+
end
|
96
|
+
|
97
|
+
def remove
|
98
|
+
case params[:directory]
|
99
|
+
when "fontsquirrel"
|
100
|
+
|
101
|
+
when "googlewebfonts"
|
102
|
+
|
103
|
+
end
|
104
|
+
render :text => Cytoplasm::Ajax.success()
|
105
|
+
end
|
106
|
+
|
107
|
+
def index
|
108
|
+
@installed = fetch_imported()
|
109
|
+
end
|
110
|
+
|
40
111
|
private
|
41
112
|
def fetch_json(url)
|
42
113
|
return ActiveSupport::JSON.decode(open(url).read)
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<h2>Cytoplasm Font Manager</h2>
|
2
|
+
|
3
|
+
<hr />
|
4
|
+
|
5
|
+
<% if @installed["fontsquirrel"].any? or @installed["googlewebfonts"].any? %>
|
6
|
+
<h3>Installed Fonts</h3>
|
7
|
+
|
8
|
+
<% {"fontsquirrel" => "FontSquirrel","googlewebfonts" => "Google Web Fonts"}.each do |dir,name| %>
|
9
|
+
<% if @installed[dir].any? %>
|
10
|
+
<h6><%=name%></h6>
|
11
|
+
<ul>
|
12
|
+
<% @installed[dir].each do |fam,f| %>
|
13
|
+
<li><%=fam%></li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
18
|
+
<% end %>
|
19
|
+
|
20
|
+
<hr />
|
21
|
+
|
22
|
+
<h3>Install New Fonts</h3>
|
23
|
+
|
24
|
+
<p>
|
25
|
+
<input type="radio" name="fonts_directory" data-label="Font Squirrel API" value="fontsquirrel" data-exclude="true" checked="checked" class="cytoRadio" />
|
26
|
+
<input type="radio" name="fonts_directory" data-label="Google Web Fonts" value="googlewebfonts" data-exclude="true" />
|
27
|
+
</p>
|
28
|
+
|
29
|
+
<p><select name="fonts_family" id="fontfamilyselect" data-exclude="true" class="cytoSelect"></select></p>
|
30
|
+
|
31
|
+
<p><button id="font_import_button" class="cytoButton large">Import Font Family</button></p>
|
32
|
+
|
33
|
+
<script type="text/javascript">
|
34
|
+
(function($){
|
35
|
+
$.Cytoplasm("ready",function(){
|
36
|
+
$.cytoAjax("/cytoplasm/fonts/fetch_all",function(data){
|
37
|
+
console.log(data);
|
38
|
+
console.log(data.imported);
|
39
|
+
var fds = $('input[name=fonts_directory]');
|
40
|
+
var ffs = $('#fontfamilyselect');
|
41
|
+
var ib = $('#font_import_button');
|
42
|
+
|
43
|
+
// Directory select
|
44
|
+
fds.cytoRadio("options",{
|
45
|
+
events:{
|
46
|
+
change:$.debounce(100,true,function(e){
|
47
|
+
var fonts = {};
|
48
|
+
var imported = {};
|
49
|
+
switch ($(this).cytoRadio("value")) {
|
50
|
+
case "fontsquirrel":
|
51
|
+
$.each(data.fontsquirrel,function(fam,f){fonts[fam] = f.family_name;});
|
52
|
+
if (data.imported.length>0) {
|
53
|
+
$.each(data.imported,function(fam,f){imported[fam] = fam;});
|
54
|
+
iffs.cytoSelect("update",imported);
|
55
|
+
}
|
56
|
+
break;
|
57
|
+
case "googlewebfonts":
|
58
|
+
$.each(data.googlewebfonts,function(fam,f){fonts[fam] = fam;});
|
59
|
+
break;
|
60
|
+
default:return false;
|
61
|
+
}
|
62
|
+
ffs.cytoSelect("update",fonts);
|
63
|
+
})
|
64
|
+
}
|
65
|
+
});
|
66
|
+
|
67
|
+
// Family select
|
68
|
+
ffs.cytoSelect("options",{
|
69
|
+
events:{
|
70
|
+
change:function(cy,e){
|
71
|
+
var dir = fds.cytoRadio("value");
|
72
|
+
var f = data[dir][$(this).cytoSelect("value")];
|
73
|
+
if (f!=null) switch (dir) {
|
74
|
+
case "fontsquirrel":
|
75
|
+
// Check if font has already been imported
|
76
|
+
if (!$.isEmptyObject(data.imported[dir]) && data.imported[dir][f.family_urlname] != null) ib.addClass('active').html("Font Family Imported");
|
77
|
+
else ib.removeClass('active').html("Import Font Family");
|
78
|
+
break;
|
79
|
+
case "googlewebfonts":
|
80
|
+
console.log(data.imported[dir][f.family]);
|
81
|
+
if (!$.isEmptyObject(data.imported[dir]) && data.imported[dir][f.family] != null) ib.addClass('active').html("Font Family Imported");
|
82
|
+
else ib.removeClass('active').html("Import Font Family");
|
83
|
+
break;
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
87
|
+
});
|
88
|
+
|
89
|
+
// Font Import Button
|
90
|
+
ib.css({"margin-top":10}).click(function(e){
|
91
|
+
e.preventDefault();
|
92
|
+
var dir = fds.cytoRadio("value");
|
93
|
+
var f = data[dir][ffs.cytoSelect("value")];
|
94
|
+
var name = (dir=="fontsquirrel") ? f.family_name : f.family;
|
95
|
+
if (!ib.hasClass('active')) {
|
96
|
+
// Import font
|
97
|
+
$.cytoAjax("/cytoplasm/fonts/import",{directory:dir,family:f},function(data){
|
98
|
+
$.cytoAjaxResponse('Font "'+name+'" has been imported successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
99
|
+
ib.addClass('active').html("Font Family Imported");
|
100
|
+
});
|
101
|
+
} else {
|
102
|
+
// Remove font
|
103
|
+
if (confirm("Are you sure you want to remove this font from your fonts library?")) $.cytoAjax("/cytoplasm/fonts/remove",{directory:dir,family:f},function(data){
|
104
|
+
$.cytoAjaxResponse('Font "'+name+'" has been removed successfully.<br /><a href="#" onClick="window.location.reload();">You must reload to apply these changes.</a>');
|
105
|
+
ib.removeClass('active').html("Import Font Family");
|
106
|
+
});
|
107
|
+
}
|
108
|
+
});
|
109
|
+
|
110
|
+
});
|
111
|
+
});
|
112
|
+
})(jQuery);
|
113
|
+
</script>
|
@@ -309,8 +309,6 @@
|
|
309
309
|
// Fetch fonts
|
310
310
|
$.cytoAjax("/cytoplasm/fonts/fetch_all",function(data){
|
311
311
|
console.log(data);
|
312
|
-
|
313
|
-
// Directory select
|
314
312
|
var fds = $('input[name=fonts_directory]');
|
315
313
|
var ffs = $('#fontfamilyselect');
|
316
314
|
var iffs = $('.ind_font_fam_select');
|
@@ -345,6 +343,7 @@
|
|
345
343
|
});
|
346
344
|
*/
|
347
345
|
|
346
|
+
// Directory select
|
348
347
|
fds.cytoRadio("value",$.Cytoplasm("conf","fontloader.directory")).cytoRadio("options",{
|
349
348
|
events:{
|
350
349
|
change:$.debounce(100,true,function(e){
|
@@ -371,6 +370,7 @@
|
|
371
370
|
}
|
372
371
|
});
|
373
372
|
|
373
|
+
// Family select
|
374
374
|
ffs.cytoSelect("options",{
|
375
375
|
events:{
|
376
376
|
change:function(cy,e){
|