aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js/admin/dialogs
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-07-30 00:46:09 -0400
committerPaul Duncan <pabs@pablotron.org>2016-07-30 00:46:09 -0400
commit040cbfc93f870fd4242d112757bf1c52ddf7a2a0 (patch)
treef71599ed30a3a96021b3e335512a9e508caf9000 /data/assets/js/admin/dialogs
parent183cc31c0b5f812c0f0fcd8a292e378a9695417f (diff)
downloadguff-040cbfc93f870fd4242d112757bf1c52ddf7a2a0.tar.bz2
guff-040cbfc93f870fd4242d112757bf1c52ddf7a2a0.zip
load and save custom page assets
Diffstat (limited to 'data/assets/js/admin/dialogs')
-rw-r--r--data/assets/js/admin/dialogs/page-edit.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/data/assets/js/admin/dialogs/page-edit.js b/data/assets/js/admin/dialogs/page-edit.js
index 95c9a63..9e32d89 100644
--- a/data/assets/js/admin/dialogs/page-edit.js
+++ b/data/assets/js/admin/dialogs/page-edit.js
@@ -1,12 +1,18 @@
jQuery(function($) {
"use strict";
- var p = '#page-edit-';
+ 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() {
@@ -14,13 +20,21 @@ jQuery(function($) {
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: {
+ post_data: $.extend({
have_theme_id: 't',
theme_id: theme_id,
- },
+ }, assets),
});
// stop event