From 720f1d71233ab9f6be3ea4ae4b09d823fdca7367 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Thu, 1 Sep 2016 17:09:58 -0700 Subject: actively set all the theme options on the display settings page based on the current theme selection --- Zotlabs/Module/Theme_info.php | 10 +++++++++- view/js/main.js | 6 ------ view/js/mod_settings.js | 22 ++++++++++++++++++++++ view/theme/redbasic/php/theme.php | 3 +-- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Zotlabs/Module/Theme_info.php b/Zotlabs/Module/Theme_info.php index 054ab6447..eb4a28279 100644 --- a/Zotlabs/Module/Theme_info.php +++ b/Zotlabs/Module/Theme_info.php @@ -9,6 +9,8 @@ class Theme_info extends \Zotlabs\Web\Controller { $theme = argv(1); if(! $theme) killme(); + + $schemalist = array(); $theme_config = ""; if(($themeconfigfile = $this->get_theme_config_file($theme)) != null){ @@ -17,6 +19,12 @@ class Theme_info extends \Zotlabs\Web\Controller { $clsname = ucfirst($theme) . 'Config'; $th_config = new $clsname(); $schemas = $th_config->get_schemas(); + if($schemas) { + foreach($schemas as $k => $v) { + $schemalist[] = [ 'key' => $k, 'val' => $v ]; + } + } + } $theme_config = theme_content($a); } @@ -39,7 +47,7 @@ class Theme_info extends \Zotlabs\Web\Controller { 'desc' => $desc, 'version' => $version, 'credits' => $credits, - 'schemas' => $schemas, + 'schemas' => $schemalist, 'config' => $theme_config ]; json_return_and_die($ret); diff --git a/view/js/main.js b/view/js/main.js index 21157bdfe..627110c49 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1247,12 +1247,6 @@ Array.prototype.remove = function(item) { return this.push.apply(this, rest); }; -function previewTheme(elm) { - theme = $(elm).val(); - $.getJSON('pretheme?f=&theme=' + theme,function(data) { - $('#theme-preview').html('
' + data.desc + '
' + data.version + '
' + data.credits + '
' + theme + ''); - }); -} $(document).ready(function() { diff --git a/view/js/mod_settings.js b/view/js/mod_settings.js index 4ff702b22..db321ae70 100644 --- a/view/js/mod_settings.js +++ b/view/js/mod_settings.js @@ -8,6 +8,8 @@ $(document).ready(function() { $('.token-mirror').html($('#id_token').val()); $('#id_token').keyup( function() { $('.token-mirror').html($('#id_token').val()); }); + previewTheme($('#id_theme')[0]); + $("#id_permissions_role").change(function() { var role = $("#id_permissions_role").val(); if(role == 'custom') @@ -17,6 +19,26 @@ $(document).ready(function() { }); }); + +function setTheme(elm) { + $('#settings-form').submit(); +} + + +function previewTheme(elm) { + theme = $(elm).val(); + $.getJSON('theme_info/' + theme,function(data) { + $('#theme-preview').html('
' + data.desc + '
' + data.version + '
' + data.credits + '
' + theme + ''); + $('#id_schema').empty(); + $(data.schemas).each(function(index,item) { + $('