Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
O
OHR Support
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
97
Issues
97
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
OHR Support
Commits
9e04bf83
Commit
9e04bf83
authored
Mar 24, 2011
by
Stephan Eckardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix jstoolbar to make buttons for h1, h2, <pre> etc. work in IE8
parent
0ace7708
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
2 deletions
+24
-2
jstoolbar.js
public/javascripts/jstoolbar/jstoolbar.js
+24
-2
No files found.
public/javascripts/jstoolbar/jstoolbar.js
View file @
9e04bf83
...
...
@@ -249,7 +249,29 @@ jsToolBar.prototype = {
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
sel
=
document
.
selection
.
createRange
().
text
;
// just makes it work in IE8 somehow
var
range
=
document
.
selection
.
createRange
();
var
bookmark
=
range
.
getBookmark
();
var
origParent
=
range
.
parentElement
();
// we move the starting point of the selection to the last newline
try
{
while
(
range
.
text
[
0
]
!=
"
\n
"
&&
range
.
text
[
0
]
!=
"
\
r"
)
{
bookmark
=
range
.
getBookmark
();
range
.
moveStart
(
"character"
,
-
1
);
if
(
origParent
!=
range
.
parentElement
())
{
throw
"Outside of Textarea"
;
}
}
range
.
moveStart
(
"character"
,
1
);
}
catch
(
err
)
{
if
(
err
==
"Outside of Textarea"
)
range
.
moveToBookmark
(
bookmark
);
else
throw
err
;
}
if
(
range
.
text
.
match
(
/ $/
))
range
.
moveEnd
(
"character"
,
-
1
);
sel
=
range
.
text
;
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
start
=
this
.
textarea
.
selectionStart
;
end
=
this
.
textarea
.
selectionEnd
;
...
...
@@ -271,7 +293,7 @@ jsToolBar.prototype = {
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
var
range
=
document
.
selection
.
createRange
()
.
text
=
subst
;
range
.
text
=
subst
;
this
.
textarea
.
caretPos
-=
suffix
.
length
;
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
this
.
textarea
.
value
.
substring
(
end
);
...
...
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