Skip to content
Snippets Groups Projects
Commit 6667cd87 authored by Andreas Gohr's avatar Andreas Gohr
Browse files

changed the whole thing to a real popup

parent 86c97e91
No related branches found
No related tags found
No related merge requests found
...@@ -11,6 +11,8 @@ if(!defined('DOKU_INC')) die(); ...@@ -11,6 +11,8 @@ if(!defined('DOKU_INC')) die();
class admin_plugin_styling extends DokuWiki_Admin_Plugin { class admin_plugin_styling extends DokuWiki_Admin_Plugin {
public $ispopup = false;
/** /**
* @return int sort number in admin menu * @return int sort number in admin menu
*/ */
...@@ -25,15 +27,6 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin { ...@@ -25,15 +27,6 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin {
return true; return true;
} }
/**
* @param string $language
* @return string
*/
public function getMenuText($language) {
$js = $this->getLang('js');
return $js['menu'];
}
/** /**
* handle the different actions (also called from ajax) * handle the different actions (also called from ajax)
*/ */
...@@ -49,17 +42,19 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin { ...@@ -49,17 +42,19 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin {
* Render HTML output, e.g. helpful text and a form * Render HTML output, e.g. helpful text and a form
*/ */
public function html() { public function html() {
echo '<div id="plugin__styling">'; $class = 'nopopup';
ptln('<h1>'.$this->getMenuText('').'</h1>'); if($this->ispopup) $class = 'ispopup';
$this->form(false);
echo '<div id="plugin__styling" class="'.$class.'">';
ptln('<h1>'.$this->getLang('menu').'</h1>');
$this->form();
echo '</div>'; echo '</div>';
} }
/** /**
* Create the actual editing form * Create the actual editing form
* @param boolean $isajax
*/ */
public function form($isajax) { public function form() {
global $conf; global $conf;
global $ID; global $ID;
define('SIMPLE_TEST', 1); // hack, ideally certain functions should be moved out of css.php 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 { ...@@ -67,8 +62,8 @@ class admin_plugin_styling extends DokuWiki_Admin_Plugin {
$styleini = css_styleini($conf['template'], true); $styleini = css_styleini($conf['template'], true);
$replacements = $styleini['replacements']; $replacements = $styleini['replacements'];
if($isajax) { if($this->ispopup) {
$target = wl($ID, array('do' => 'styling_plugin')); $target = DOKU_BASE.'lib/plugins/styling/popup.php';
} else { } else {
$target = wl($ID, array('do' => 'admin', 'page' => 'styling')); $target = wl($ID, array('do' => 'admin', 'page' => 'styling'));
} }
......
...@@ -6,7 +6,9 @@ ...@@ -6,7 +6,9 @@
*/ */
// menu entry for admin plugins // menu entry for admin plugins
$lang['js']['menu'] = 'Template Style Settings'; $lang['menu'] = 'Template Style Settings';
$lang['js']['popup'] = 'Open as Popup'; $lang['js']['popup'] = 'Open as Popup';
// custom language strings for the plugin // custom language strings for the plugin
......
<?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>
/* DOKUWIKI:include_once iris.js */ /* DOKUWIKI:include_once iris.js */
jQuery(function () { jQuery(function () {
// add popup option to admin page
var $styling_plugin = jQuery('#plugin__styling'); 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 $hl = $styling_plugin.find('h1').first();
var $btn = jQuery('<button class="btn">' + LANG.plugins.styling.popup + '</button>'); var $btn = jQuery('<button class="btn">' + LANG.plugins.styling.popup + '</button>');
$hl.append($btn); $hl.append($btn);
$btn.click(function (e) { $btn.click(function (e) {
DokuCookie.setValue('styling_plugin', 1); var windowFeatures = "menubar=no,location=no,resizable=yes,scrollbars=yes,status=false,width=500,height=500";
document.location.href = document.location.href.replace(/&?do=admin/, ''); window.open(DOKU_BASE + 'lib/plugins/styling/popup.php', 'styling', windowFeatures)
}); });
return;
} }
// continue only if the styling Dialog is currently enabled // add the color picker
if (DokuCookie.getValue('styling_plugin') != 1) return; $styling_plugin.find('.color').iris({});
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 FIXME add saveAndUpdate to correct event // load preview in main window
$dialog.find('.color').iris({}); 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);
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment