Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
d071b66c
Commit
d071b66c
authored
9 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
autopreview in styler plugin
parent
a93f9a7a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lib/plugins/styler/action.php
+6
-1
6 additions, 1 deletion
lib/plugins/styler/action.php
lib/plugins/styler/admin.php
+4
-4
4 additions, 4 deletions
lib/plugins/styler/admin.php
lib/plugins/styler/script.js
+81
-38
81 additions, 38 deletions
lib/plugins/styler/script.js
with
91 additions
and
43 deletions
lib/plugins/styler/action.php
+
6
−
1
View file @
d071b66c
...
...
@@ -91,11 +91,16 @@ class action_plugin_styler extends DokuWiki_Action_Plugin {
$event
->
stopPropagation
();
global
$ID
;
global
$INPUT
;
$ID
=
getID
();
/** @var admin_plugin_styler $hlp */
$hlp
=
plugin_load
(
'admin'
,
'styler'
);
$hlp
->
form
(
true
);
if
(
$INPUT
->
str
(
'run'
)
==
'preview'
)
{
$hlp
->
run_preview
();
}
else
{
$hlp
->
form
(
true
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
lib/plugins/styler/admin.php
+
4
−
4
View file @
d071b66c
...
...
@@ -87,13 +87,13 @@ class admin_plugin_styler extends DokuWiki_Admin_Plugin {
echo
'<tr>'
;
echo
'<td>'
.
$name
.
'</td>'
;
echo
'<td><input name="tpl['
.
hsc
(
$key
)
.
']" value="'
.
hsc
(
$value
)
.
'" '
.
$this
->
colorClass
(
$key
)
.
' />'
;
echo
'<td><input
type="text"
name="tpl['
.
hsc
(
$key
)
.
']" value="'
.
hsc
(
$value
)
.
'" '
.
$this
->
colorClass
(
$key
)
.
' />'
;
echo
'</tr>'
;
}
echo
'</table>'
;
echo
'<p class="center">'
;
echo
'<input type="submit" name="run[preview]" value="'
.
$this
->
getLang
(
'btn_preview'
)
.
'">'
;
echo
'<input type="submit" name="run[preview]"
class="btn_preview"
value="'
.
$this
->
getLang
(
'btn_preview'
)
.
'">'
;
echo
'<input type="submit" name="run[reset]" value="'
.
$this
->
getLang
(
'btn_reset'
)
.
'">'
;
#FIXME only if preview.ini exists
echo
'</p>'
;
...
...
@@ -139,9 +139,9 @@ class admin_plugin_styler extends DokuWiki_Admin_Plugin {
}
/**
* saves the preview.ini
* saves the preview.ini
(alos called from ajax directly)
*/
p
rotected
function
run_preview
()
{
p
ublic
function
run_preview
()
{
global
$conf
;
$ini
=
$conf
[
'cachedir'
]
.
'/preview.ini'
;
io_saveFile
(
$ini
,
$this
->
makeini
());
...
...
This diff is collapsed.
Click to expand it.
lib/plugins/styler/script.js
+
81
−
38
View file @
d071b66c
...
...
@@ -7,43 +7,86 @@ jQuery(function () {
document
.
location
.
href
=
document
.
location
.
href
.
replace
(
/do=admin/
,
''
);
}
// The Styler Dialog is currently enabled, display it here and apply the preview styles
if
(
DokuCookie
.
getValue
(
'
styler_plugin
'
)
==
1
)
{
// load dialog
var
$dialog
=
jQuery
(
document
.
createElement
(
'
div
'
));
jQuery
(
'
body
'
).
append
(
$dialog
);
$dialog
.
load
(
DOKU_BASE
+
'
/lib/exe/ajax.php
'
,
{
'
call
'
:
'
plugin_styler
'
,
'
id
'
:
JSINFO
.
id
},
function
()
{
// load the preview template
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
);
// open the dialog
var
$dlg
=
$dialog
.
dialog
({
'
title
'
:
LANG
.
plugins
.
styler
.
menu
,
'
width
'
:
500
,
'
height
'
:
500
,
'
top
'
:
50
,
'
position
'
:
{
'
my
'
:
'
left bottom
'
,
'
at
'
:
'
left bottom
'
,
'
of
'
:
window
},
// bring everything back to normal
'
close
'
:
function
(
event
,
ui
)
{
// disable the styler plugin again
DokuCookie
.
setValue
(
'
styler_plugin
'
,
0
);
// reload
document
.
location
.
reload
()
}
});
jQuery
(
'
.styler .color
'
).
iris
({
});
}
);
// continue only if the Styler Dialog is currently enabled
if
(
DokuCookie
.
getValue
(
'
styler_plugin
'
)
!=
1
)
return
;
var
styler_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
styler_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
);
}
/**
* save current values and reload preview (debounced)
*/
function
styler_saveAndUpdate
()
{
if
(
styler_timeout
)
window
.
clearTimeout
(
styler_timeout
);
styler_timeout
=
window
.
setTimeout
(
function
()
{
styler_timeout
=
null
;
var
params
=
$dialog
.
find
(
'
input[type=text]
'
).
serializeArray
();
params
[
params
.
length
]
=
{
name
:
'
call
'
,
value
:
'
plugin_styler
'
};
params
[
params
.
length
]
=
{
name
:
'
run
'
,
value
:
'
preview
'
};
jQuery
.
post
(
DOKU_BASE
+
'
/lib/exe/ajax.php
'
,
params
,
styler_updateCSS
);
},
500
);
}
// load the dialog content and apply listeners
$dialog
.
load
(
DOKU_BASE
+
'
/lib/exe/ajax.php
'
,
{
'
call
'
:
'
plugin_styler
'
,
'
run
'
:
'
html
'
,
'
id
'
:
JSINFO
.
id
},
function
()
{
// load the preview template
styler_updateCSS
();
// open the dialog
$dialog
.
dialog
({
'
title
'
:
LANG
.
plugins
.
styler
.
menu
,
'
width
'
:
500
,
'
height
'
:
500
,
'
top
'
:
50
,
'
position
'
:
{
'
my
'
:
'
left bottom
'
,
'
at
'
:
'
left bottom
'
,
'
of
'
:
window
},
// bring everything back to normal
'
close
'
:
function
(
event
,
ui
)
{
// disable the styler plugin again
DokuCookie
.
setValue
(
'
styler_plugin
'
,
0
);
// reload
document
.
location
.
reload
()
}
});
// we don't need the manual preview in JS mode
$dialog
.
find
(
'
.btn_preview
'
).
hide
();
// add the color picker FIXME add saveAndUpdate to correct event
$dialog
.
find
(
'
.color
'
).
iris
({
});
// listen to keyup events
$dialog
.
find
(
'
input[type=text]
'
).
keyup
(
function
()
{
console
.
log
(
'
change
'
);
styler_saveAndUpdate
();
});
}
);
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment