The insert in the text does not work in Opera.
ivcons - August 28, 2009 - 19:01
| Project: | Image Picker |
| Version: | 6.x-2.x-dev |
| Component: | User interface |
| Category: | bug report |
| Priority: | normal |
| Assigned: | ivcons |
| Status: | reviewed & tested by the community |
Jump to:
Description
The insert in the text does not work in Opera.

#1
That's right, it did work in earlier versions of Opera, very annoying ;-(
#2
is any solution known already? or coming...
#3
This is AFAIK beyond the control of imagepicker, unless anyone knows of a javascript fix/hack for Opera
#4
in imagepicker.module, function isertAtCursor (line 976) insert code for opera before final else:
if (window.selection){sel=window.selection.createRange();
sel.text=myValue;
}
#5
Doesn't work for me ;-(
I stuck some alerts in to see which method Opera is using, it's using document.selection mode
I put window.selection at the top so it was tested first, no joy.
Now, I have just tried moving the netscape method to the top, bingo!
function insertAtCursor(myField, myValue) {//Mozilla/Firefox/Netscape 7+ support
if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);
}
//IE support
else if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
else {
myField.value += myValue;
}
}
Can anyone replace function insertAtCursor at line 976 in imagepicker.module and test in Opera as well as IE.
I don't have easy access to IE and it needs to be supported.
#6
opera 10.00, 10.01, 10.10 (linux buids)
IE7
it works.
#7
Good news, so far. I would still like a confirmation for IE8
I am also thinking that the insertAtCursor function is asking the wrong question, surely it should be detecting the browser and deciding which method to use on that basis.
more later.....
#8
Here is another version of insertAtCursor()
it uses Jquery browser detection function
function insertAtCursor(myField, myValue) {
browser = imagepicker_browser_detect();
if (browser == 'msie') {
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
}
else if (browser == 'opera' || browser == 'mozilla' || browser == 'safari' ) {
if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)+ myValue + myField.value.substring(endPos, myField.value.length);
}
}
else {
myField.value += myValue;
}
}
function imagepicker_browser_detect() {
if ($.browser.msie) {
return 'msie';
}
else if ($.browser.safari) {
return 'safari';
}
else if ($.browser.opera) {
return 'opera';
}
else if ($.browser.mozilla) {
return 'mozilla';
}
else {
return 'unknown';
}
}
I have tested this with firefox 2 and 3, Opera 9 and 10 and safari version 4.
Please test and report back folks!
#9
Please try the latest development snapshot for this issue.