aboutsummaryrefslogtreecommitdiff
path: root/data/assets/js
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
parent183cc31c0b5f812c0f0fcd8a292e378a9695417f (diff)
downloadguff-040cbfc93f870fd4242d112757bf1c52ddf7a2a0.tar.bz2
guff-040cbfc93f870fd4242d112757bf1c52ddf7a2a0.zip
load and save custom page assets
Diffstat (limited to 'data/assets/js')
-rw-r--r--data/assets/js/admin/dialogs/page-edit.js20
-rw-r--r--data/assets/js/util.js17
2 files changed, 17 insertions, 20 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
diff --git a/data/assets/js/util.js b/data/assets/js/util.js
index cde0f25..7986120 100644
--- a/data/assets/js/util.js
+++ b/data/assets/js/util.js
@@ -1,20 +1,3 @@
-jQuery.fn.reduce = (function() {
- "use strict";
-
- if (Array.prototype.reduce) {
- return Array.prototype.reduce;
- } else {
- return function(a, cb, r) {
- a = [].concat(a);
-
- for (var i = 0, l = a.length; i < l; i++)
- r = cb(r, a[i]);
-
- return r;
- };
- }
-})();
-
jQuery(function($) {
"use strict";