summaryrefslogtreecommitdiff
path: root/plugins/legacy_browser/js/iehacks.js
diff options
context:
space:
mode:
authorHugues Hiegel <root@paranoid>2015-04-21 12:49:44 +0200
committerHugues Hiegel <root@paranoid>2015-04-21 12:49:44 +0200
commit733f8e8d0ce6217d906d06dc4fb08e36d48ed794 (patch)
treecff28366ff63ea6596f8026e1698090bd0b9405c /plugins/legacy_browser/js/iehacks.js
parentef2e7b3f9d264ec146d4dae257b1e295ab3b462a (diff)
parenta4ba3df54834ee90fb2c9930669f1229dc80261a (diff)
Merge remote-tracking branch 'origin/master'HEADmaster
Conflicts: composer.json-dist config/defaults.inc.php plugins plugins/acl/acl.js plugins/acl/acl.php plugins/acl/skins/classic/templates/table.html plugins/acl/skins/larry/templates/table.html plugins/enigma/README plugins/enigma/config.inc.php.dist plugins/enigma/enigma.js plugins/enigma/enigma.php plugins/enigma/lib/enigma_driver.php plugins/enigma/lib/enigma_driver_gnupg.php plugins/enigma/lib/enigma_driver_phpssl.php plugins/enigma/lib/enigma_engine.php plugins/enigma/lib/enigma_error.php plugins/enigma/lib/enigma_key.php plugins/enigma/lib/enigma_signature.php plugins/enigma/lib/enigma_subkey.php plugins/enigma/lib/enigma_ui.php plugins/enigma/lib/enigma_userid.php plugins/enigma/localization/en_US.inc plugins/enigma/localization/ja_JP.inc plugins/enigma/localization/ru_RU.inc plugins/enigma/skins/classic/enigma.css plugins/enigma/skins/classic/templates/keys.html plugins/help/config.inc.php.dist plugins/help/help.php plugins/help/localization/en_US.inc plugins/jqueryui/jqueryui.php plugins/managesieve/Changelog plugins/managesieve/composer.json plugins/managesieve/config.inc.php.dist plugins/managesieve/lib/Roundcube/rcube_sieve.php plugins/managesieve/lib/Roundcube/rcube_sieve_engine.php plugins/managesieve/lib/Roundcube/rcube_sieve_vacation.php plugins/managesieve/localization/en_US.inc plugins/managesieve/managesieve.js plugins/managesieve/skins/classic/managesieve.css plugins/managesieve/skins/larry/managesieve.css plugins/password/README plugins/password/config.inc.php.dist plugins/password/drivers/ldap.php plugins/password/drivers/poppassd.php plugins/password/drivers/vpopmaild.php plugins/vcard_attachments/vcardattach.js plugins/zipdownload/zipdownload.php
Diffstat (limited to 'plugins/legacy_browser/js/iehacks.js')
-rw-r--r--plugins/legacy_browser/js/iehacks.js108
1 files changed, 108 insertions, 0 deletions
diff --git a/plugins/legacy_browser/js/iehacks.js b/plugins/legacy_browser/js/iehacks.js
new file mode 100644
index 000000000..105b7dabc
--- /dev/null
+++ b/plugins/legacy_browser/js/iehacks.js
@@ -0,0 +1,108 @@
+
+// Make getElementById() case-sensitive on IE7
+document._getElementById = document.getElementById;
+document.getElementById = function(id)
+{
+ var i = 0, obj = document._getElementById(id);
+
+ if (obj && obj.id != id)
+ while ((obj = document.all[i]) && obj.id != id)
+ i++;
+
+ return obj;
+}
+
+// fix missing :last-child selectors
+$(document).ready(function() {
+ if (rcmail && rcmail.env.skin != 'classic')
+ $('ul.treelist ul').each(function(i, ul) {
+ $('li:last-child', ul).css('border-bottom', 0);
+ });
+});
+
+// gets cursor position (IE<9)
+rcube_webmail.prototype.get_caret_pos = function(obj)
+{
+ if (document.selection && document.selection.createRange) {
+ var range = document.selection.createRange();
+ if (range.parentElement() != obj)
+ return 0;
+
+ var gm = range.duplicate();
+ if (obj.tagName == 'TEXTAREA')
+ gm.moveToElementText(obj);
+ else
+ gm.expand('textedit');
+
+ gm.setEndPoint('EndToStart', range);
+ var p = gm.text.length;
+
+ return p <= obj.value.length ? p : -1;
+ }
+
+ return obj.value.length;
+};
+
+// moves cursor to specified position (IE<9)
+rcube_webmail.prototype.set_caret_pos = function(obj, pos)
+{
+ if (obj.createTextRange) {
+ var range = obj.createTextRange();
+ range.collapse(true);
+ range.moveEnd('character', pos);
+ range.moveStart('character', pos);
+ range.select();
+ }
+};
+
+// get selected text from an input field (IE<9)
+// http://stackoverflow.com/questions/7186586/how-to-get-the-selected-text-in-textarea-using-jquery-in-internet-explorer-7
+rcube_webmail.prototype.get_input_selection = function(obj)
+{
+ var start = 0, end = 0, len,
+ normalizedValue, textInputRange, endRange,
+ range = document.selection.createRange();
+
+ if (range && range.parentElement() == obj) {
+ len = obj.value.length;
+ normalizedValue = obj.value; //.replace(/\r\n/g, "\n");
+
+ // create a working TextRange that lives only in the input
+ textInputRange = obj.createTextRange();
+ textInputRange.moveToBookmark(range.getBookmark());
+
+ // Check if the start and end of the selection are at the very end
+ // of the input, since moveStart/moveEnd doesn't return what we want
+ // in those cases
+ endRange = obj.createTextRange();
+ endRange.collapse(false);
+
+ if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) {
+ start = end = len;
+ }
+ else {
+ start = -textInputRange.moveStart("character", -len);
+ start += normalizedValue.slice(0, start).split("\n").length - 1;
+
+ if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) {
+ end = len;
+ }
+ else {
+ end = -textInputRange.moveEnd("character", -len);
+ end += normalizedValue.slice(0, end).split("\n").length - 1;
+ }
+ }
+ }
+
+ return {start: start, end: end, text: normalizedValue.substr(start, end-start)};
+};
+
+// For IE<9 we have to do it this way
+// otherwise the form will be posted to a new window
+rcube_webmail.prototype.async_upload_form_frame = function(name)
+{
+ document.body.insertAdjacentHTML('BeforeEnd', '<iframe name="' + name + '"'
+ + ' src="' + rcmail.assets_path('program/resources/blank.gif') + '" style="width:0; height:0; visibility:hidden"></iframe>');
+
+ return $('iframe[name="' + name + '"]');
+};