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
75c8c6fa
Commit
75c8c6fa
authored
9 years ago
by
Andreas Gohr
Browse files
Options
Downloads
Patches
Plain Diff
readded cookie to styling plugin
parent
147d8f48
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/plugins/styling/script.js
+59
-36
59 additions, 36 deletions
lib/plugins/styling/script.js
with
59 additions
and
36 deletions
lib/plugins/styling/script.js
+
59
−
36
View file @
75c8c6fa
...
...
@@ -2,10 +2,58 @@
jQuery
(
function
()
{
var
doreload
=
1
;
/**
* Function to reload the preview styles in the main window
*
* @param {window} target the main window
*/
function
applyPreview
(
target
)
{
// remove style
var
$style
=
target
.
jQuery
(
'
link[rel=stylesheet][href*="lib/exe/css.php"]
'
);
$style
.
attr
(
'
href
'
,
''
);
// append the loader screen
$loader
=
target
.
jQuery
(
'
#plugin__styling_loader
'
);
if
(
!
$loader
.
length
)
{
$loader
=
jQuery
(
'
<div id="plugin__styling_loader">
'
+
LANG
.
plugins
.
styling
.
loader
+
'
</div>
'
);
$loader
.
css
({
'
position
'
:
'
absolute
'
,
'
width
'
:
'
100%
'
,
'
height
'
:
'
100%
'
,
'
top
'
:
0
,
'
left
'
:
0
,
'
z-index
'
:
5000
,
'
background-color
'
:
'
#fff
'
,
'
opacity
'
:
'
0.7
'
,
'
color
'
:
'
#000
'
,
'
font-size
'
:
'
2.5em
'
,
'
text-align
'
:
'
center
'
,
'
line-height
'
:
1.5
,
'
padding-top
'
:
'
2em
'
});
target
.
jQuery
(
'
body
'
).
append
(
$loader
);
}
// load preview in main window (timeout works around chrome updating CSS weirdness)
target
.
setTimeout
(
function
()
{
var
now
=
new
Date
().
getTime
();
$style
.
attr
(
'
href
'
,
DOKU_BASE
+
'
lib/exe/css.php?preview=1&tseed=
'
+
now
);
},
500
);
}
var
doreload
=
1
;
var
$styling_plugin
=
jQuery
(
'
#plugin__styling
'
);
if
(
!
$styling_plugin
.
length
)
return
;
// if we are not on the plugin page (either main or popup)
if
(
!
$styling_plugin
.
length
)
{
// handle the preview cookie
if
(
DokuCookie
.
getValue
(
'
styling_plugin
'
)
==
1
)
{
applyPreview
(
window
);
}
return
;
// nothing more to do here
}
/* ---- from here on we're in the popup or admin page ---- */
// add the color picker
$styling_plugin
.
find
(
'
.color
'
).
iris
({});
...
...
@@ -18,15 +66,18 @@ jQuery(function () {
$btn
.
click
(
function
(
e
)
{
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
)
window
.
open
(
DOKU_BASE
+
'
lib/plugins/styling/popup.php
'
,
'
styling
_popup
'
,
windowFeatures
)
;
e
.
preventDefault
();
}).
wrap
(
'
<p></p>
'
);
return
;
return
;
// we exit here if this is not the popup
}
/* ---- from here on we're in the popup only ---- */
// reload the main page on close
window
.
onunload
=
function
(
e
)
{
if
(
doreload
)
{
window
.
opener
.
DokuCookie
.
setValue
(
'
styling_plugin
'
,
0
);
window
.
opener
.
document
.
location
.
reload
();
}
return
null
;
...
...
@@ -37,37 +88,9 @@ jQuery(function () {
doreload
=
false
;
});
// remove style
var
$style
=
window
.
opener
.
jQuery
(
'
link[rel=stylesheet][href*="lib/exe/css.php"]
'
);
$style
.
attr
(
'
href
'
,
''
);
// append the loader screen
$loader
=
window
.
opener
.
jQuery
(
'
#plugin__styling_loader
'
);
if
(
!
$loader
.
length
)
{
$loader
=
jQuery
(
'
<div id="plugin__styling_loader">
'
+
LANG
.
plugins
.
styling
.
loader
+
'
</div>
'
);
$loader
.
css
({
'
position
'
:
'
absolute
'
,
'
width
'
:
'
100%
'
,
'
height
'
:
'
100%
'
,
'
top
'
:
0
,
'
left
'
:
0
,
'
z-index
'
:
5000
,
'
background-color
'
:
'
#fff
'
,
'
opacity
'
:
'
0.7
'
,
'
color
'
:
'
#000
'
,
'
font-size
'
:
'
2.5em
'
,
'
text-align
'
:
'
center
'
,
'
line-height
'
:
1.5
,
'
padding-top
'
:
'
2em
'
});
window
.
opener
.
jQuery
(
'
body
'
).
append
(
$loader
);
}
// load preview in main window (timeout works around chrome updating CSS weirdness)
window
.
setTimeout
(
function
()
{
var
now
=
new
Date
().
getTime
();
$style
.
attr
(
'
href
'
,
DOKU_BASE
+
'
lib/exe/css.php?preview=1&tseed=
'
+
now
);
},
500
);
// on first load apply preview
applyPreview
(
window
.
opener
);
// enable the preview cookie
window
.
opener
.
DokuCookie
.
setValue
(
'
styling_plugin
'
,
1
);
});
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