Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
OHR Support
Manage
Activity
Members
Labels
Plan
Issues
97
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Projects
OHR Support
Commits
8d6133f6
Commit
8d6133f6
authored
14 years ago
by
Felix Schäfer
Browse files
Options
Downloads
Plain Diff
Merge branch 'finnlabs-305_jstoolbar_fix_for_ie8'
parents
1aa20b17
c7bd3788
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
public/javascripts/jstoolbar/jstoolbar.js
+101
-102
101 additions, 102 deletions
public/javascripts/jstoolbar/jstoolbar.js
with
101 additions
and
102 deletions
public/javascripts/jstoolbar/jstoolbar.js
+
101
−
102
View file @
8d6133f6
...
...
@@ -242,108 +242,107 @@ jsToolBar.prototype = {
this
.
encloseSelection
(
stag
,
etag
);
},
encloseLineSelection
:
function
(
prefix
,
suffix
,
fn
)
{
this
.
textarea
.
focus
();
prefix
=
prefix
||
''
;
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
sel
=
document
.
selection
.
createRange
().
text
;
}
else
if
(
typeof
(
this
.
textarea
[
"
setSelectionRange
"
])
!=
"
undefined
"
)
{
start
=
this
.
textarea
.
selectionStart
;
end
=
this
.
textarea
.
selectionEnd
;
scrollPos
=
this
.
textarea
.
scrollTop
;
// go to the start of the line
start
=
this
.
textarea
.
value
.
substring
(
0
,
start
).
replace
(
/
[^\r\n]
*$/g
,
''
).
length
;
// go to the end of the line
end
=
this
.
textarea
.
value
.
length
-
this
.
textarea
.
value
.
substring
(
end
,
this
.
textarea
.
value
.
length
).
replace
(
/^
[^\r\n]
*/
,
''
).
length
;
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
}
if
(
sel
.
match
(
/ $/
))
{
// exclude ending space char, if any
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
suffix
=
suffix
+
"
"
;
}
if
(
typeof
(
fn
)
==
'
function
'
)
{
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
else
{
res
=
(
sel
)
?
sel
:
''
;
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
document
.
selection
.
createRange
().
text
=
subst
;
var
range
=
this
.
textarea
.
createTextRange
();
range
.
collapse
(
false
);
range
.
move
(
'
character
'
,
-
suffix
.
length
);
range
.
select
();
}
else
if
(
typeof
(
this
.
textarea
[
"
setSelectionRange
"
])
!=
"
undefined
"
)
{
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
this
.
textarea
.
value
.
substring
(
end
);
if
(
sel
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
}
this
.
textarea
.
scrollTop
=
scrollPos
;
}
},
encloseSelection
:
function
(
prefix
,
suffix
,
fn
)
{
this
.
textarea
.
focus
();
prefix
=
prefix
||
''
;
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
sel
=
document
.
selection
.
createRange
().
text
;
}
else
if
(
typeof
(
this
.
textarea
[
"
setSelectionRange
"
])
!=
"
undefined
"
)
{
start
=
this
.
textarea
.
selectionStart
;
end
=
this
.
textarea
.
selectionEnd
;
scrollPos
=
this
.
textarea
.
scrollTop
;
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
}
if
(
sel
.
match
(
/ $/
))
{
// exclude ending space char, if any
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
suffix
=
suffix
+
"
"
;
}
if
(
typeof
(
fn
)
==
'
function
'
)
{
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
else
{
res
=
(
sel
)
?
sel
:
''
;
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
document
.
selection
.
createRange
().
text
=
subst
;
var
range
=
this
.
textarea
.
createTextRange
();
range
.
collapse
(
false
);
range
.
move
(
'
character
'
,
-
suffix
.
length
);
range
.
select
();
// 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
);
if
(
sel
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
}
this
.
textarea
.
scrollTop
=
scrollPos
;
}
},
encloseLineSelection
:
function
(
prefix
,
suffix
,
fn
)
{
this
.
textarea
.
focus
();
prefix
=
prefix
||
''
;
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
// 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
;
scrollPos
=
this
.
textarea
.
scrollTop
;
// go to the start of the line
start
=
this
.
textarea
.
value
.
substring
(
0
,
start
).
replace
(
/
[^\r\n]
*$/g
,
''
).
length
;
// go to the end of the line
end
=
this
.
textarea
.
value
.
length
-
this
.
textarea
.
value
.
substring
(
end
,
this
.
textarea
.
value
.
length
).
replace
(
/^
[^\r\n]
*/
,
''
).
length
;
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
}
if
(
sel
.
match
(
/ $/
))
{
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
suffix
=
suffix
+
"
"
;
}
if
(
typeof
(
fn
)
==
'
function
'
)
{
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
else
{
res
=
(
sel
)
?
sel
:
''
;
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
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
);
if
(
sel
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
}
this
.
textarea
.
scrollTop
=
scrollPos
;
}
},
encloseSelection
:
function
(
prefix
,
suffix
,
fn
)
{
this
.
textarea
.
focus
();
prefix
=
prefix
||
''
;
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
sel
=
document
.
selection
.
createRange
().
text
;
}
else
if
(
typeof
(
this
.
textarea
[
"
setSelectionRange
"
])
!=
"
undefined
"
)
{
start
=
this
.
textarea
.
selectionStart
;
end
=
this
.
textarea
.
selectionEnd
;
scrollPos
=
this
.
textarea
.
scrollTop
;
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
}
if
(
sel
.
match
(
/ $/
))
{
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
suffix
=
suffix
+
"
"
;
}
if
(
typeof
(
fn
)
==
'
function
'
)
{
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
else
{
res
=
(
sel
)
?
sel
:
''
;
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
document
[
"
selection
"
])
!=
"
undefined
"
)
{
var
range
=
document
.
selection
.
createRange
().
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
);
if
(
sel
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
}
this
.
textarea
.
scrollTop
=
scrollPos
;
}
},
stripBaseURL
:
function
(
url
)
{
if
(
this
.
base_url
!=
''
)
{
var
pos
=
url
.
indexOf
(
this
.
base_url
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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