diff options
Diffstat (limited to 'data/assets/js/admin/dialogs/page-edit.js')
-rw-r--r-- | data/assets/js/admin/dialogs/page-edit.js | 20 |
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 |