deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tandrasc...@apache.org
Subject deltaspike git commit: DELTASPIKE-1028 WindowHandler: JS error on IE8 DELTASPIKE-1027 WindowHandler: "screenshot" still clickable in IE8 DELTASPIKE-1026 WindowHandler: Loading... not displayed in IE8 DELTASPIKE-1025 WindowHandler: Remember every body att
Date Thu, 19 Nov 2015 15:41:55 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master cf886865c -> d9e7eac3b


DELTASPIKE-1028 WindowHandler: JS error on IE8
DELTASPIKE-1027 WindowHandler: "screenshot" still clickable in IE8
DELTASPIKE-1026 WindowHandler: Loading... not displayed in IE8
DELTASPIKE-1025 WindowHandler: Remember every body attr for the windowhandler.html
DELTASPIKE-1024 WindowHandler: Loading... not displayed in initial request in new tab
DELTASPIKE-1023 WindowHandling: refactor screenshot handling/remember scroll position

Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/d9e7eac3
Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/d9e7eac3
Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/d9e7eac3

Branch: refs/heads/master
Commit: d9e7eac3bc35ce7446505f9673219b14f9166166
Parents: cf88686
Author: tandraschko <tandraschko@apache.org>
Authored: Thu Nov 19 16:41:21 2015 +0100
Committer: tandraschko <tandraschko@apache.org>
Committed: Thu Nov 19 16:41:21 2015 +0100

----------------------------------------------------------------------
 .../resources/deltaspike/windowhandler.js       | 44 +++++++++++++-
 .../main/resources/static/windowhandler.html    | 63 +++++++++-----------
 2 files changed, 70 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d9e7eac3/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
index 923231d..eac5c98 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
+++ b/deltaspike/modules/jsf/impl/src/main/resources/META-INF/resources/deltaspike/windowhandler.js
@@ -235,11 +235,22 @@ window.dswh = window.dswh || {
                     }
                 }
                 localStorage.setItem(window.name + '_css', dswh.utils.stringify(oldSS));
+
                 var body = document.getElementsByTagName("body")[0];
                 localStorage.setItem(window.name + '_body', body.innerHTML);
-                //X TODO: store ALL attributes of the body tag
-                localStorage.setItem(window.name + '_bodyAttrs', body.getAttribute("class"));
-                return true;
+
+                var attributes = {};
+                for (var i = 0; i < body.attributes.length; i++) {
+                    var attribute = body.attributes[i];
+                    attributes[attribute.name] = attribute.value;
+                }
+                localStorage.setItem(window.name + '_bodyAttributes', dswh.utils.stringify(attributes));
+
+                var scrollTop = (window.pageYOffset || document.documentElement.scrollTop)
- (document.documentElement.clientTop || 0);
+                localStorage.setItem(window.name + '_scrollTop', scrollTop);
+
+                var scrollLeft = (window.pageXOffset || document.documentElement.scrollLeft)
- (document.documentElement.clientLeft || 0);
+                localStorage.setItem(window.name + '_scrollLeft', scrollLeft);
             },
 
             cleanupCookies : function() {
@@ -444,3 +455,30 @@ window.dswh = window.dswh || {
         }
     }
 };
+
+// required for IE8
+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;
+    };
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/d9e7eac3/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html b/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
index 48fbb64..c4a956b 100644
--- a/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
+++ b/deltaspike/modules/jsf/impl/src/main/resources/static/windowhandler.html
@@ -45,16 +45,6 @@
 
         <script type="text/javascript">
             //<![CDATA[
-            function getOldBody() {
-                return localStorage.getItem(window.name + '_body');
-            }
-            function getOldBodyAttrs() {
-                return localStorage.getItem(window.name + '_bodyAttrs');
-            }
-            function getOldCss() {
-                return dswh.utils.unstringify(localStorage.getItem(window.name + '_css'));
-            }
-
             function addCss(url) {
                 var newSS = document.createElement("style");
                 newSS.setAttribute("rel", "stylesheet");
@@ -64,15 +54,12 @@
             }
 
             function loadCss(clean) {
-                if (!dswh.utils.isHtml5()) { // only do this stuff on html5 browsers
+                // We don't need to restore the old css on initial requests or if < html5
+                if (!dswh.utils.isHtml5() || !window.name) {
                     return;
                 }
-                
-                if (!window.name || window.name.length === null) {
-                    return;
-                }
-                
-                var oldCss = getOldCss();
+
+                var oldCss = dswh.utils.unstringify(localStorage.getItem(window.name + '_css'));
                 if (oldCss) {
                     for (var i = 0; i < oldCss.length; i++) {
                         addCss(oldCss[i]);
@@ -84,35 +71,43 @@
             }
 
             function replaceContent() {
-                if (!dswh.utils.isHtml5()) { // only do this stuff on html browsers
+                if (document.body.textContent) {
                     document.getElementById('message').textContent = "Loading...";
-                    return;
+                } else {
+                    document.getElementById('message').innerText = "Loading...";
                 }
-                
-                if (!window.name || window.name.length === null) {
+
+                // We don't need to restore the old windowtree on initial requests or if
< html5
+                if (!dswh.utils.isHtml5() || !window.name) {
                     return;
                 }
-                
+
                 loadCss(false);
 
-                var oldBody = getOldBody();
+                var oldBody = localStorage.getItem(window.name + '_body');
                 if (oldBody) {
                     document.body.innerHTML = oldBody;
 
-                    //X TODO should restore all attributes of the body tag
-                    document.body.setAttribute("class", getOldBodyAttrs());
-                    document.body.setAttribute("style", " cursor: wait !important;");
+                    var attributes = dswh.utils.unstringify(localStorage.getItem(window.name
+ '_bodyAttributes'));
+                    for (var attributeName in attributes) {
+                        if (attributes.hasOwnProperty(attributeName)) {
+                            document.body.setAttribute(attributeName, attributes[attributeName]);
+                        }
+                    }
+
+                    window.scrollTo(localStorage.getItem(window.name + '_scrollLeft'),
+                                    localStorage.getItem(window.name + '_scrollTop'));
 
                     localStorage.removeItem(window.name + '_body');
-                    localStorage.removeItem(window.name + '_bodyAttrs');
+                    localStorage.removeItem(window.name + '_bodyAttributes');
+                    localStorage.removeItem(window.name + '_scrollTop');
+                    localStorage.removeItem(window.name + '_scrollLeft');
 
                     // overlay the doc with an un-clickable full-size div
-                    var newDiv = document.createElement("div");
-                    newDiv.setAttribute("style", "position:absolute; z-index:1000; background-color:transparent;
top:0; left:0; width:100%; height: 100%");
-                    newDiv.setAttribute("class", "fulldiv");
-                    document.body.appendChild(newDiv);
-                } else {
-                    document.getElementById('message').textContent = "Loading...";
+                    var overlay = document.createElement("div");
+                    overlay.setAttribute("style", "cursor: wait !important; position:absolute;
z-index:1000; background-color:transparent; top:0; left:0; width:100%; height: 100%; background:
url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7);");
+                    overlay.setAttribute("class", "fulldiv");
+                    document.body.appendChild(overlay);
                 }
             }
 
@@ -120,7 +115,7 @@
 
             window.onload = function() {
                 // uncomment the following line to debug the intermediate page
-                // if (!confirm('reload?')) { return true; }
+                //if (!confirm('reload?')) { return true; }
 
                 loadCss(true);
 


Mime
View raw message