diff options
author | Andreas Gohr <andi@splitbrain.org> | 2015-06-26 12:57:58 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2015-06-26 12:57:58 +0200 |
commit | 6667cd8743e57a4492cfbcbe1066ea48d444f7a2 (patch) | |
tree | 3c420d60f9497a747ad887c5be1d948bb3d8b762 /lib | |
parent | 86c97e91e4aa9ed17ed75df279181e4b61353c7c (diff) | |
download | rpg-6667cd8743e57a4492cfbcbe1066ea48d444f7a2.tar.gz rpg-6667cd8743e57a4492cfbcbe1066ea48d444f7a2.tar.bz2 |
changed the whole thing to a real popup
Diffstat (limited to 'lib')
-rw-r--r-- | lib/plugins/styling/admin.php | 27 | ||||
-rw-r--r-- | lib/plugins/styling/lang/en/lang.php | 4 | ||||
-rw-r--r-- | lib/plugins/styling/popup.php | 28 | ||||
-rw-r--r-- | lib/plugins/styling/script.js | 73 |
4 files changed, 56 insertions, 76 deletions
diff --git a/lib/plugins/styling/admin.php b/lib/plugins/styling/admin.php index 3c2ab577c..627efbd15 100644 --- a/lib/plugins/styling/admin.php +++ b/lib/plugins/styling/admin.php @@ -11,6 +11,8 @@ if(!defined('DOKU_INC')) die(); class admin_plugin_styling extends DokuWiki_Admin_Plugin { + public $ispopup = false; + /** * @return int sort number in admin menu */ @@ -26,15 +28,6 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin { } /** - * @param string $language - * @return string - */ - public function getMenuText($language) { - $js = $this->getLang('js'); - return $js['menu']; - } - - /** * handle the different actions (also called from ajax) */ public function handle() { @@ -49,17 +42,19 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin { * Render HTML output, e.g. helpful text and a form */ public function html() { - echo '<div id="plugin__styling">'; - ptln('<h1>'.$this->getMenuText('').'</h1>'); - $this->form(false); + $class = 'nopopup'; + if($this->ispopup) $class = 'ispopup'; + + echo '<div id="plugin__styling" class="'.$class.'">'; + ptln('<h1>'.$this->getLang('menu').'</h1>'); + $this->form(); echo '</div>'; } /** * Create the actual editing form - * @param boolean $isajax */ - public function form($isajax) { + public function form() { global $conf; global $ID; define('SIMPLE_TEST', 1); // hack, ideally certain functions should be moved out of css.php @@ -67,8 +62,8 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin { $styleini = css_styleini($conf['template'], true); $replacements = $styleini['replacements']; - if($isajax) { - $target = wl($ID, array('do' => 'styling_plugin')); + if($this->ispopup) { + $target = DOKU_BASE.'lib/plugins/styling/popup.php'; } else { $target = wl($ID, array('do' => 'admin', 'page' => 'styling')); } diff --git a/lib/plugins/styling/lang/en/lang.php b/lib/plugins/styling/lang/en/lang.php index d100d4324..85ac0ec29 100644 --- a/lib/plugins/styling/lang/en/lang.php +++ b/lib/plugins/styling/lang/en/lang.php @@ -6,7 +6,9 @@ */ // menu entry for admin plugins -$lang['js']['menu'] = 'Template Style Settings'; +$lang['menu'] = 'Template Style Settings'; + + $lang['js']['popup'] = 'Open as Popup'; // custom language strings for the plugin diff --git a/lib/plugins/styling/popup.php b/lib/plugins/styling/popup.php new file mode 100644 index 000000000..eea4f3bfd --- /dev/null +++ b/lib/plugins/styling/popup.php @@ -0,0 +1,28 @@ +<?php +if(!defined('DOKU_INC')) define('DOKU_INC', dirname(__FILE__) . '/../../../'); +require_once(DOKU_INC . 'inc/init.php'); +//close session +session_write_close(); +header('Content-Type: text/html; charset=utf-8'); + +/** @var admin_plugin_styling $plugin */ +$plugin = plugin_load('admin', 'styling'); +if(!auth_isadmin()) die('only admins allowed'); +$plugin->ispopup = true; + +// handle posts +$plugin->handle(); + +// output plugin in a very minimal template: +?> +<html> +<head> + <title><?php echo $plugin->getLang('menu') ?></title> + <?php tpl_metaheaders(false) ?> +</head> +<body> + <div class="dokuwiki page"> + <?php $plugin->html() ?> + </div> +</body> +</html> diff --git a/lib/plugins/styling/script.js b/lib/plugins/styling/script.js index 6dc4c84ed..8b4563986 100644 --- a/lib/plugins/styling/script.js +++ b/lib/plugins/styling/script.js @@ -1,74 +1,29 @@ /* DOKUWIKI:include_once iris.js */ jQuery(function () { - // add popup option to admin page + var $styling_plugin = jQuery('#plugin__styling'); - if ($styling_plugin.length) { + if(!$styling_plugin.length) return; + + + if (!$styling_plugin.hasClass('ispopup')) { var $hl = $styling_plugin.find('h1').first(); var $btn = jQuery('<button class="btn">' + LANG.plugins.styling.popup + '</button>'); $hl.append($btn); $btn.click(function (e) { - DokuCookie.setValue('styling_plugin', 1); - document.location.href = document.location.href.replace(/&?do=admin/, ''); + var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=false,width=500,height=500"; + window.open(DOKU_BASE + 'lib/plugins/styling/popup.php', 'styling', windowFeatures) }); + return; } - // continue only if the styling Dialog is currently enabled - if (DokuCookie.getValue('styling_plugin') != 1) return; - - var styling_timeout = null; - - // create dialog element - var $dialog = jQuery(document.createElement('div')); - jQuery('body').append($dialog); - - /** - * updates the current CSS with a new preview one - */ - function styling_updateCSS() { - var now = new Date().getTime(); - var $style = jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]'); - $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now); - } - - // prepare the dialog - $dialog.dialog({ - 'autoOpen': false, - 'title': LANG.plugins.styling.menu, - 'width': 500, - 'height': 500, - 'position': {'my': 'left bottom', 'at': 'left bottom-40', 'of': window}, - 'closeOnEscape': true, - - // bring everything back to normal on close - 'close': function (event, ui) { - // disable the styling plugin again - DokuCookie.setValue('styling_plugin', 0); - // reload - document.location.reload() - } - }); - - - // load the dialog content and apply listeners - $dialog.load( - DOKU_BASE + 'lib/exe/ajax.php', - { - 'call': 'plugin_styling', - 'run': 'html', - 'id': JSINFO.id - }, - function () { - // load the preview template - styling_updateCSS(); - - // open the dialog - $dialog.dialog('open'); + // add the color picker + $styling_plugin.find('.color').iris({}); - // add the color picker FIXME add saveAndUpdate to correct event - $dialog.find('.color').iris({}); - } - ); + // load preview in main window + var now = new Date().getTime(); + var $style = window.opener.jQuery('link[rel=stylesheet][href*="lib/exe/css.php"]'); + $style.attr('href', DOKU_BASE + 'lib/exe/css.php?preview=1&tseed=' + now); }); |