From a03d70209fabbb3d2ae7137a6edde1f0712cd9e1 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 14 Feb 2013 12:06:16 +0100 Subject: [PATCH 1/5] fixing undefined originalEvent --- apps/files/js/jquery-visibility.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/files/js/jquery-visibility.js b/apps/files/js/jquery-visibility.js index a824bf68730..18f57d1f2bd 100644 --- a/apps/files/js/jquery-visibility.js +++ b/apps/files/js/jquery-visibility.js @@ -3,7 +3,7 @@ var prefix, property, -// In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior + // In Opera, `'onfocusin' in document == true`, hence the extra `hasFocus` check to detect IE-like behavior eventName = 'onfocusin' in document && 'hasFocus' in document ? 'focusin focusout' : 'focus blur', prefixes = ['', 'moz', 'ms', 'o', 'webkit'], $support = $.support, @@ -19,12 +19,11 @@ $(/blur$/.test(eventName) ? window : document).on(eventName, function (event) { var type = event.type, - originalEvent = event.originalEvent, - toElement = originalEvent.toElement; -// If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`; -// else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc. -// In IE9, we need to check the `relatedTarget` property instead. - if (!/^focus./.test(type) || (toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) { + originalEvent = event.originalEvent; + // If it’s a `{focusin,focusout}` event (IE), `fromElement` and `toElement` should both be `null` or `undefined`; + // else, the page visibility hasn’t changed, but the user just clicked somewhere in the doc. + // In IE9, we need to check the `relatedTarget` property instead. + if (!/^focus./.test(type) || originalEvent == undefined || (originalEvent.toElement == undefined && originalEvent.fromElement == undefined && originalEvent.relatedTarget == undefined)) { $event.trigger((property && document[property] || /^(?:blur|focusout)$/.test(type) ? 'hide' : 'show') + '.visibility'); } }); From 8877087b5716fde078bab4d303240498f02dd48b Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 14 Feb 2013 12:16:51 +0100 Subject: [PATCH 2/5] adding a compatibility.js as a single source to define all fallback function declarations --- core/js/compatibility.js | 25 +++++++++++++++++++++++++ lib/base.php | 1 + 2 files changed, 26 insertions(+) create mode 100644 core/js/compatibility.js diff --git a/core/js/compatibility.js b/core/js/compatibility.js new file mode 100644 index 00000000000..3e9178f3200 --- /dev/null +++ b/core/js/compatibility.js @@ -0,0 +1,25 @@ + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Function/bind +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + + return fBound; + }; +} diff --git a/lib/base.php b/lib/base.php index c60a97100f4..fd9a1d41121 100644 --- a/lib/base.php +++ b/lib/base.php @@ -278,6 +278,7 @@ class OC { OC_Util::addScript("jquery-showpassword"); OC_Util::addScript("jquery.infieldlabel"); OC_Util::addScript("jquery-tipsy"); + OC_Util::addScript("compatibility"); OC_Util::addScript("oc-dialogs"); OC_Util::addScript("js"); OC_Util::addScript("eventsource"); From 8065c73339fe624a2b833cbb283887d4e2e58bdf Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 14 Feb 2013 12:17:14 +0100 Subject: [PATCH 3/5] fixing eventsource.js for IE8 --- core/js/eventsource.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/js/eventsource.js b/core/js/eventsource.js index f783ade7ae9..ce8c8387c8e 100644 --- a/core/js/eventsource.js +++ b/core/js/eventsource.js @@ -87,8 +87,10 @@ OC.EventSource.prototype={ useFallBack:false, fallBackCallBack:function(type,data){ if(type){ - for(var i=0;i Date: Thu, 14 Feb 2013 12:59:26 +0100 Subject: [PATCH 4/5] adding prototype trim as fallback for IE8 --- core/js/compatibility.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/js/compatibility.js b/core/js/compatibility.js index 3e9178f3200..0cfeefab871 100644 --- a/core/js/compatibility.js +++ b/core/js/compatibility.js @@ -23,3 +23,10 @@ if (!Function.prototype.bind) { return fBound; }; } + +//https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/String/Trim +if(!String.prototype.trim) { + String.prototype.trim = function () { + return this.replace(/^\s+|\s+$/g,''); + }; +} \ No newline at end of file From 022993c09865b90993c869053a3217e2700a6f22 Mon Sep 17 00:00:00 2001 From: Thomas Mueller Date: Thu, 14 Feb 2013 12:59:59 +0100 Subject: [PATCH 5/5] fixing javascript errors IE8 in user management --- settings/js/users.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/settings/js/users.js b/settings/js/users.js index a70cf18ead3..da18b4be836 100644 --- a/settings/js/users.js +++ b/settings/js/users.js @@ -92,11 +92,12 @@ var UserList = { UserList.applyMultiplySelect(subadminSelect); } if (tr.find('td.remove img').length == 0 && OC.currentUser != username) { - var rm_img = $('', { - class: 'svg action', + var rm_img = $('').attr({ src: OC.imagePath('core', 'actions/delete') }); - var rm_link = $('', { class: 'action delete', href: '#', 'original-title': t('settings', 'Delete')}).append(rm_img); + var rm_link = $('') + .attr({ href: '#', 'original-title': t('settings', 'Delete')}) + .append(rm_img); tr.find('td.remove').append(rm_link); } else if (OC.currentUser == username) { tr.find('td.remove a').remove();