aboutsummaryrefslogtreecommitdiff
path: root/data/assets
diff options
context:
space:
mode:
Diffstat (limited to 'data/assets')
-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";