Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427690
init.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
init.js
View Options
/*!
* TemplateData Generator edit template page init
*
* @author Moriel Schottlender
* @author Ed Sanders
*/
/* global ve */
/* eslint-disable no-jquery/no-global-selector */
'use strict'
;
new
mw
.
Api
().
loadMessages
(
'templatedata-doc-subpage'
,
{
amlang
:
mw
.
config
.
get
(
'wgContentLanguage'
)
}
).
then
(
()
=>
{
const
Target
=
require
(
'./Target.js'
),
pageName
=
mw
.
config
.
get
(
'wgPageName'
),
docSubpage
=
mw
.
msg
(
'templatedata-doc-subpage'
);
let
$textbox
=
$
(
'#wpTextbox1'
);
const
pieces
=
pageName
.
split
(
'/'
);
const
isDocPage
=
pieces
.
length
>
1
&&
pieces
[
pieces
.
length
-
1
]
===
docSubpage
;
const
openTDG
=
new
URL
(
location
.
href
).
searchParams
.
get
(
'templatedata'
)
===
'edit'
;
const
config
=
{
pageName
:
pageName
,
isPageSubLevel
:
pieces
.
length
>
1
,
parentPage
:
pageName
,
isDocPage
:
isDocPage
,
docSubpage
:
docSubpage
};
// Only if we are in a doc page do we set the parent page to
// the one above. Otherwise, all parent pages are current pages
if
(
isDocPage
)
{
pieces
.
pop
();
config
.
parentPage
=
pieces
.
join
(
'/'
);
}
// Textbox wikitext editor
if
(
$textbox
.
length
)
{
// Prepare the editor
const
wtTarget
=
new
Target
(
$textbox
,
config
);
$
(
'.tdg-editscreen-placeholder'
).
replaceWith
(
wtTarget
.
$element
);
if
(
openTDG
)
{
wtTarget
.
onEditOpenDialogButton
();
}
}
let
veTarget
;
// Visual editor source mode
mw
.
hook
(
've.activationComplete'
).
add
(
()
=>
{
const
surface
=
ve
.
init
.
target
.
getSurface
();
if
(
surface
.
getMode
()
===
'source'
)
{
// Source mode will have created a dummy textbox
$textbox
=
$
(
'#wpTextbox1'
);
veTarget
=
new
Target
(
$textbox
,
config
);
// Use the same font size as main content text
veTarget
.
$element
.
addClass
(
'mw-body-content'
);
$
(
'.ve-init-mw-desktopArticleTarget-originalContent'
).
prepend
(
veTarget
.
$element
);
if
(
openTDG
)
{
veTarget
.
onEditOpenDialogButton
();
}
}
}
);
mw
.
hook
(
've.deactivationComplete'
).
add
(
()
=>
{
if
(
veTarget
)
{
veTarget
.
destroy
();
veTarget
=
null
;
}
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, May 16, 14:58 (23 h, 40 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
bf/60/b3149e011a70b148588f85e90b9e
Default Alt Text
init.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment