blob: 9e32d89ebe5edfba28b255068bf5574f70d56155 (
plain)
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
|
jQuery(function($) {
"use strict";
var ASSET_TYPES = ['styles', 'scripts'],
p = '#page-edit-';
$(p + 'dialog').on('guff.loaded', function(ev) {
var r = ev.post_data;
$(p + 'theme').val(r.theme_id || 'site-default');
// set assets
$.each(ASSET_TYPES, function(i, key) {
$(p + key).val(r[key].join("\n"));
});
});
$(p + 'confirm').click(function() {
var theme_id = $(p + 'theme').val();
if (theme_id == 'site-default')
theme_id = null;
// get assets
var assets = ASSET_TYPES.reduce(function(r, key) {
var s = $(p + key).val().replace(/^\s+|\s$/mg, '');
r[key] = JSON.stringify((s.length > 0) ? s.split(/\s+/m) : []);
return r;
}, {});
$(p + 'dialog').trigger({
type: 'guff.save',
post_data: $.extend({
have_theme_id: 't',
theme_id: theme_id,
}, assets),
});
// stop event
return false;
});
});
|