Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo
Commits
7cdeb568
Commit
7cdeb568
authored
Nov 08, 2016
by
Van
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#12159
parent
ad2fc448
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
src/main/webapp/js/lib/CodeMirrorEditor/placeholder.js
src/main/webapp/js/lib/CodeMirrorEditor/placeholder.js
+60
-0
No files found.
src/main/webapp/js/lib/CodeMirrorEditor/placeholder.js
0 → 100644
View file @
7cdeb568
// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(
function
(
mod
)
{
if
(
typeof
exports
==
"
object
"
&&
typeof
module
==
"
object
"
)
// CommonJS
mod
(
require
(
"
../../lib/codemirror
"
));
else
if
(
typeof
define
==
"
function
"
&&
define
.
amd
)
// AMD
define
([
"
../../lib/codemirror
"
],
mod
);
else
// Plain browser env
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
CodeMirror
.
defineOption
(
"
placeholder
"
,
""
,
function
(
cm
,
val
,
old
)
{
var
prev
=
old
&&
old
!=
CodeMirror
.
Init
;
if
(
val
&&
!
prev
)
{
cm
.
on
(
"
blur
"
,
onBlur
);
cm
.
on
(
"
change
"
,
onChange
);
onChange
(
cm
);
}
else
if
(
!
val
&&
prev
)
{
cm
.
off
(
"
blur
"
,
onBlur
);
cm
.
off
(
"
change
"
,
onChange
);
clearPlaceholder
(
cm
);
var
wrapper
=
cm
.
getWrapperElement
();
wrapper
.
className
=
wrapper
.
className
.
replace
(
"
CodeMirror-empty
"
,
""
);
}
if
(
val
&&
!
cm
.
hasFocus
())
onBlur
(
cm
);
});
function
clearPlaceholder
(
cm
)
{
if
(
cm
.
state
.
placeholder
)
{
cm
.
state
.
placeholder
.
parentNode
.
removeChild
(
cm
.
state
.
placeholder
);
cm
.
state
.
placeholder
=
null
;
}
}
function
setPlaceholder
(
cm
)
{
clearPlaceholder
(
cm
);
var
elt
=
cm
.
state
.
placeholder
=
document
.
createElement
(
"
pre
"
);
elt
.
style
.
cssText
=
"
height: 0; overflow: visible
"
;
elt
.
className
=
"
CodeMirror-placeholder
"
;
var
placeHolder
=
cm
.
getOption
(
"
placeholder
"
)
if
(
typeof
placeHolder
==
"
string
"
)
placeHolder
=
document
.
createTextNode
(
placeHolder
)
elt
.
appendChild
(
placeHolder
)
cm
.
display
.
lineSpace
.
insertBefore
(
elt
,
cm
.
display
.
lineSpace
.
firstChild
);
}
function
onBlur
(
cm
)
{
if
(
isEmpty
(
cm
))
setPlaceholder
(
cm
);
}
function
onChange
(
cm
)
{
var
wrapper
=
cm
.
getWrapperElement
(),
empty
=
isEmpty
(
cm
);
wrapper
.
className
=
wrapper
.
className
.
replace
(
"
CodeMirror-empty
"
,
""
)
+
(
empty
?
"
CodeMirror-empty
"
:
""
);
if
(
empty
)
setPlaceholder
(
cm
);
else
clearPlaceholder
(
cm
);
}
function
isEmpty
(
cm
)
{
return
(
cm
.
lineCount
()
===
1
)
&&
(
cm
.
getLine
(
0
)
===
""
);
}
});
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment