From 7514bf7301738651a92500f2cdad4eae2d81ea7b Mon Sep 17 00:00:00 2001 From: Stefanos Grammenos Date: Thu, 20 Apr 2017 13:00:34 +0300 Subject: [PATCH] Reload only if setting is modified --- index.php | 2 +- jscss-source/css.css | 69 ++++++++++++++++++++++++++++++++++++++++++++ jscss-source/js.js | 51 ++++++++++++++++++++++++++++++++ version | 2 +- 4 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 jscss-source/css.css create mode 100644 jscss-source/js.js diff --git a/index.php b/index.php index 07b6c474..519b44ee 100644 --- a/index.php +++ b/index.php @@ -144,7 +144,7 @@ public static function css() { } public static function js() { $scripts = <<<'EOT' - + EOT; return wCMS::_hook('js', $scripts)[0]; } diff --git a/jscss-source/css.css b/jscss-source/css.css new file mode 100644 index 00000000..e7dace32 --- /dev/null +++ b/jscss-source/css.css @@ -0,0 +1,69 @@ +#adminPanel{ + background:#e5e5e5; + color:#aaa; + font-family:"Lucida Sans Unicode",Verdana; + font-size:14px; +} +#adminPanel a,.alert a{ + color:#aaa; + border:0; +} +#adminPanel a.btn{ + color:#fff; +} +#adminPanel span.editText{ + color:#555; +} +span.editText{ + border:2px dashed #ccc; +} +span.editText,.toggle{ + display:block; + cursor:pointer; +} +span.editText textarea{ + outline: 0; + border:none; + width:100%; + resize:none; + color:inherit; + font-size:inherit; + font-family:inherit; + background-color:transparent; + overflow:hidden; + box-sizing:content-box; +} +span.editText:empty{ + min-height:20px; +} +#save{ + color: #ccc; + left:0; + width:100%; + height:100%; + display:none; + position:fixed; + text-align:center; + padding-top:100px; + background:rgba(51,51,51,.8); + z-index:2448; +} +.change{ + padding-left:15px; +} +.marginTop20{ + margin-top:20px; +} +.padding20{ + padding:20px; +} +.subTitle{ + font-size:18px; + margin:10px 0 5px; +} +.fontSize24{ + font-size:24px; +} +.note-editor{ + border:2px dashed #ccc; +} diff --git a/jscss-source/js.js b/jscss-source/js.js new file mode 100644 index 00000000..ba386219 --- /dev/null +++ b/jscss-source/js.js @@ -0,0 +1,51 @@ +var g_changing = false, + g_saved = ''; + +function nl2br(value) { + return (value + "").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, "$1
$2") +} + +function fieldSave(id, value, dataTarget) { + g_changing = (g_saved!=value); + if (!g_changing){ + $(this).parent().html(g_saved); + return + }; + $("#save").show(); + + $.post( + "", { fieldname: id, content: value, target: dataTarget }, + function(a) {} + ).always( + function() { + window.location.reload(); + } + ) +} + +function onEdit() { + if (g_changing) return; + var $this = $(this), + title = $this.attr('title'), + id = $this.attr('id'), + target= $this.data('target'), + value = $this.hasClass('editable') ? ["", ""] : ["nl2br(", ")"]; + + g_saved = $this.html(); + + title = title ? '"'+title+'"' : ''; + value = value.join('this.value'); + + var fBlur = 'fieldSave.call(this, '+[ "'"+id+"'", value, "'"+target+"'"].join(',')+')'; + + $this.html('"); + $this.children(":first").focus(); + autosize($("textarea")), + g_changing = true; +} + +function onReady() { + $("span.editText").click(onEdit); +} + +$(document).ready(onReady); \ No newline at end of file diff --git a/version b/version index e9307ca5..50ffc5aa 100644 --- a/version +++ b/version @@ -1 +1 @@ -2.0.2 +2.0.3