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
0ace7708
Commit
0ace7708
authored
Mar 24, 2011
by
Stephan Eckardt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Backported changes to encloseSelection from latest DotClear release, less bugs in IE8
parent
5592794d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
102 deletions
+79
-102
jstoolbar.js
public/javascripts/jstoolbar/jstoolbar.js
+79
-102
No files found.
public/javascripts/jstoolbar/jstoolbar.js
View file @
0ace7708
...
...
@@ -242,108 +242,85 @@ 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"
)
{
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
(
/ $/
))
{
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
;
}
},
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
);
...
...
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