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
8d6133f6
Commit
8d6133f6
authored
Mar 25, 2011
by
Felix Schäfer
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'finnlabs-305_jstoolbar_fix_for_ie8'
parents
1aa20b17
c7bd3788
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
101 additions
and
102 deletions
+101
-102
jstoolbar.js
public/javascripts/jstoolbar/jstoolbar.js
+101
-102
No files found.
public/javascripts/jstoolbar/jstoolbar.js
View file @
8d6133f6
...
@@ -242,108 +242,107 @@ jsToolBar.prototype = {
...
@@ -242,108 +242,107 @@ jsToolBar.prototype = {
this
.
encloseSelection
(
stag
,
etag
);
this
.
encloseSelection
(
stag
,
etag
);
},
},
encloseLineSelection
:
function
(
prefix
,
suffix
,
fn
)
{
encloseLineSelection
:
function
(
prefix
,
suffix
,
fn
)
{
this
.
textarea
.
focus
();
this
.
textarea
.
focus
();
prefix
=
prefix
||
''
;
prefix
=
prefix
||
''
;
suffix
=
suffix
||
''
;
suffix
=
suffix
||
''
;
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
// just makes it work in IE8 somehow
var
range
=
document
.
selection
.
createRange
();
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
var
bookmark
=
range
.
getBookmark
();
sel
=
document
.
selection
.
createRange
().
text
;
var
origParent
=
range
.
parentElement
();
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
// we move the starting point of the selection to the last newline
start
=
this
.
textarea
.
selectionStart
;
try
{
end
=
this
.
textarea
.
selectionEnd
;
while
(
range
.
text
[
0
]
!=
"
\n
"
&&
range
.
text
[
0
]
!=
"
\
r"
)
{
scrollPos
=
this
.
textarea
.
scrollTop
;
bookmark
=
range
.
getBookmark
();
// go to the start of the line
range
.
moveStart
(
"character"
,
-
1
);
start
=
this
.
textarea
.
value
.
substring
(
0
,
start
).
replace
(
/
[^\r\n]
*$/g
,
''
).
length
;
if
(
origParent
!=
range
.
parentElement
())
{
// go to the end of the line
throw
"Outside of Textarea"
;
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
);
}
}
range
.
moveStart
(
"character"
,
1
);
}
catch
(
err
)
{
if
(
sel
.
match
(
/ $/
))
{
// exclude ending space char, if any
if
(
err
==
"Outside of Textarea"
)
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
range
.
moveToBookmark
(
bookmark
);
suffix
=
suffix
+
" "
;
else
}
throw
err
;
}
if
(
typeof
(
fn
)
==
'function'
)
{
if
(
range
.
text
.
match
(
/ $/
))
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
range
.
moveEnd
(
"character"
,
-
1
);
}
else
{
sel
=
range
.
text
;
res
=
(
sel
)
?
sel
:
''
;
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
}
start
=
this
.
textarea
.
selectionStart
;
end
=
this
.
textarea
.
selectionEnd
;
subst
=
prefix
+
res
+
suffix
;
scrollPos
=
this
.
textarea
.
scrollTop
;
// go to the start of the line
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
start
=
this
.
textarea
.
value
.
substring
(
0
,
start
).
replace
(
/
[^\r\n]
*$/g
,
''
).
length
;
document
.
selection
.
createRange
().
text
=
subst
;
// go to the end of the line
var
range
=
this
.
textarea
.
createTextRange
();
end
=
this
.
textarea
.
value
.
length
-
this
.
textarea
.
value
.
substring
(
end
,
this
.
textarea
.
value
.
length
).
replace
(
/^
[^\r\n]
*/
,
''
).
length
;
range
.
collapse
(
false
);
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
range
.
move
(
'character'
,
-
suffix
.
length
);
}
range
.
select
();
if
(
sel
.
match
(
/ $/
))
{
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
suffix
=
suffix
+
" "
;
this
.
textarea
.
value
.
substring
(
end
);
}
if
(
sel
)
{
if
(
typeof
(
fn
)
==
'function'
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
else
{
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
res
=
(
sel
)
?
sel
:
''
;
}
}
this
.
textarea
.
scrollTop
=
scrollPos
;
subst
=
prefix
+
res
+
suffix
;
}
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
},
range
.
text
=
subst
;
this
.
textarea
.
caretPos
-=
suffix
.
length
;
encloseSelection
:
function
(
prefix
,
suffix
,
fn
)
{
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
this
.
textarea
.
focus
();
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
this
.
textarea
.
value
.
substring
(
end
);
if
(
sel
)
{
prefix
=
prefix
||
''
;
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
suffix
=
suffix
||
''
;
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
}
this
.
textarea
.
scrollTop
=
scrollPos
;
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
}
sel
=
document
.
selection
.
createRange
().
text
;
},
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
start
=
this
.
textarea
.
selectionStart
;
encloseSelection
:
function
(
prefix
,
suffix
,
fn
)
{
end
=
this
.
textarea
.
selectionEnd
;
this
.
textarea
.
focus
();
scrollPos
=
this
.
textarea
.
scrollTop
;
prefix
=
prefix
||
''
;
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
suffix
=
suffix
||
''
;
}
var
start
,
end
,
sel
,
scrollPos
,
subst
,
res
;
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
if
(
sel
.
match
(
/ $/
))
{
// exclude ending space char, if any
sel
=
document
.
selection
.
createRange
().
text
;
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
suffix
=
suffix
+
" "
;
start
=
this
.
textarea
.
selectionStart
;
}
end
=
this
.
textarea
.
selectionEnd
;
scrollPos
=
this
.
textarea
.
scrollTop
;
if
(
typeof
(
fn
)
==
'function'
)
{
sel
=
this
.
textarea
.
value
.
substring
(
start
,
end
);
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
}
}
else
{
if
(
sel
.
match
(
/ $/
))
{
res
=
(
sel
)
?
sel
:
''
;
sel
=
sel
.
substring
(
0
,
sel
.
length
-
1
);
}
suffix
=
suffix
+
" "
;
}
subst
=
prefix
+
res
+
suffix
;
if
(
typeof
(
fn
)
==
'function'
)
{
res
=
(
sel
)
?
fn
.
call
(
this
,
sel
)
:
fn
(
''
);
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
}
else
{
document
.
selection
.
createRange
().
text
=
subst
;
res
=
(
sel
)
?
sel
:
''
;
var
range
=
this
.
textarea
.
createTextRange
();
}
range
.
collapse
(
false
);
subst
=
prefix
+
res
+
suffix
;
range
.
move
(
'character'
,
-
suffix
.
length
);
if
(
typeof
(
document
[
"selection"
])
!=
"undefined"
)
{
range
.
select
();
var
range
=
document
.
selection
.
createRange
().
text
=
subst
;
// this.textarea.caretPos -= suffix.length;
this
.
textarea
.
caretPos
-=
suffix
.
length
;
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
}
else
if
(
typeof
(
this
.
textarea
[
"setSelectionRange"
])
!=
"undefined"
)
{
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
this
.
textarea
.
value
=
this
.
textarea
.
value
.
substring
(
0
,
start
)
+
subst
+
this
.
textarea
.
value
.
substring
(
end
);
this
.
textarea
.
value
.
substring
(
end
);
if
(
sel
)
{
if
(
sel
)
{
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
this
.
textarea
.
setSelectionRange
(
start
+
subst
.
length
,
start
+
subst
.
length
);
}
else
{
}
else
{
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
this
.
textarea
.
setSelectionRange
(
start
+
prefix
.
length
,
start
+
prefix
.
length
);
}
}
this
.
textarea
.
scrollTop
=
scrollPos
;
this
.
textarea
.
scrollTop
=
scrollPos
;
}
}
},
},
stripBaseURL
:
function
(
url
)
{
stripBaseURL
:
function
(
url
)
{
if
(
this
.
base_url
!=
''
)
{
if
(
this
.
base_url
!=
''
)
{
var
pos
=
url
.
indexOf
(
this
.
base_url
);
var
pos
=
url
.
indexOf
(
this
.
base_url
);
...
...
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