From dea0ba28f950867532eae572e7bcda49e81bbcf0 Mon Sep 17 00:00:00 2001 From: ArthurHoaro Date: Wed, 18 Nov 2015 17:40:42 +0100 Subject: Fixes #378 - Plugin administration UI. --- inc/plugin_admin.js | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++ inc/shaarli.css | 60 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 127 insertions(+) create mode 100644 inc/plugin_admin.js (limited to 'inc') diff --git a/inc/plugin_admin.js b/inc/plugin_admin.js new file mode 100644 index 00000000..134ffb33 --- /dev/null +++ b/inc/plugin_admin.js @@ -0,0 +1,67 @@ +/** + * Change the position counter of a row. + * + * @param elem Element Node to change. + * @param toPos int New position. + */ +function changePos(elem, toPos) +{ + var elemName = elem.getAttribute('data-line') + + elem.setAttribute('data-order', toPos); + var hiddenInput = document.querySelector('[name="order_'+ elemName +'"]'); + hiddenInput.setAttribute('value', toPos); +} + +/** + * Move a row up or down. + * + * @param pos Element Node to move. + * @param move int Move: +1 (down) or -1 (up) + */ +function changeOrder(pos, move) +{ + var newpos = parseInt(pos) + move; + var line = document.querySelector('[data-order="'+ pos +'"]'); + var changeline = document.querySelector('[data-order="'+ newpos +'"]'); + var parent = changeline.parentNode; + + changePos(line, newpos); + changePos(changeline, parseInt(pos)); + var changeItem = move < 0 ? changeline : changeline.nextSibling; + parent.insertBefore(line, changeItem); +} + +/** + * Move a row up in the table. + * + * @param pos int row counter. + * + * @returns false + */ +function orderUp(pos) +{ + if (pos == 0) { + return false; + } + changeOrder(pos, -1); + return false; +} + +/** + * Move a row down in the table. + * + * @param pos int row counter. + * + * @returns false + */ +function orderDown(pos) +{ + var lastpos = document.querySelector('[data-order]:last-child').getAttribute('data-order'); + if (pos == lastpos) { + return false; + } + + changeOrder(pos, +1); + return false; +} diff --git a/inc/shaarli.css b/inc/shaarli.css index 96e2cae1..f137555e 100644 --- a/inc/shaarli.css +++ b/inc/shaarli.css @@ -1103,6 +1103,66 @@ ul.errors { float: left; } +#pluginsadmin { + width: 80%; + padding: 20px 0 0 20px; +} + +#pluginsadmin section { + padding: 20px 0; +} + +#pluginsadmin .plugin_parameters { + margin: 10px 0; +} + +#pluginsadmin h1 { + font-style: normal; +} + +#pluginsadmin h2 { + font-size: 1.4em; + font-weight: bold; +} + +#pluginsadmin table { + width: 100%; +} + +#pluginsadmin table, #pluginsadmin th, #pluginsadmin td { + border-width: 1px 0; + border-style: solid; + border-color: #c0c0c0; +} + +#pluginsadmin table th { + font-weight: bold; + padding: 10px 0; +} + +#pluginsadmin table td { + padding: 5px 0; +} + +#pluginsadmin input[type=submit] { + margin: 10px 0; +} + +#pluginsadmin .plugin_parameter { + padding: 5px 0; + border-width: 1px 0; + border-style: solid; + border-color: #c0c0c0; +} + +#pluginsadmin .float_label { + float: left; + width: 20%; +} + +#pluginsadmin a { + color: black; +} /* 404 page */ .error-container { -- cgit v1.2.3