You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2020/12/11 07:54:37 UTC
[myfaces-tobago] 22/22: TOBAGO-2061: Window Scope broken
This is an automated email from the ASF dual-hosted git repository.
weber pushed a commit to branch TOBAGO-1999_Select2
in repository https://gitbox.apache.org/repos/asf/myfaces-tobago.git
commit 723c29ff0a6d717aaf969847dd7076c29ef97f3c
Author: Udo Schnurpfeil <ud...@irian.eu>
AuthorDate: Fri Dec 4 17:33:06 2020 +0100
TOBAGO-2061: Window Scope broken
* migrating the script part
---
tobago-theme/tobago-theme-standard/pom.xml | 2 +-
.../src/main/resources/META-INF/tobago-config.xml | 1 +
.../standard/standard/script/tobago-deltaspike.js | 671 +++++++++++++++++++++
.../html/standard/standard/script/tobago.js | 46 --
4 files changed, 673 insertions(+), 47 deletions(-)
diff --git a/tobago-theme/tobago-theme-standard/pom.xml b/tobago-theme/tobago-theme-standard/pom.xml
index 7871f60..b2ca041 100644
--- a/tobago-theme/tobago-theme-standard/pom.xml
+++ b/tobago-theme/tobago-theme-standard/pom.xml
@@ -41,7 +41,7 @@
<target>
<concat destfile="${project.build.directory}/javascript-min/standard/script/tobago.min.js" force="no">
<filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script"
- files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-select2.js,tobago-sheet.js,tobago-suggest.js,tobago-tab.js,tobago-tree.js,tobago-utils.js,tobago-file.js" />
+ files="tobago.js,tobago-calendar.js,tobago-converter.js,tobago-deltaspike.js,tobago-in.js,tobago-menu.js,tobago-overlay.js,tobago-popup.js,tobago-select2.js,tobago-sheet.js,tobago-suggest.js,tobago-tab.js,tobago-tree.js,tobago-utils.js,tobago-file.js" />
</concat>
<concat destfile="${project.build.directory}/javascript-min/msie_6_0/script/tobago.min.js" force="no">
<filelist dir="${basedir}/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/msie_6_0/script" files="tobago.js" />
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
index 4e875e7..bb1a62f 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/META-INF/tobago-config.xml
@@ -420,6 +420,7 @@
<script priority="50" name="script/tobago-calendar.js"/>
<script priority="60" name="script/tobago-console.js"/>
<script priority="70" name="script/tobago-converter.js"/>
+ <script priority="75" name="script/tobago-deltaspike.js"/>
<script priority="80" name="script/tobago-file.js"/>
<script priority="90" name="script/tobago-in.js"/>
<script priority="100" name="script/tobago-menu.js"/>
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-deltaspike.js b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-deltaspike.js
new file mode 100644
index 0000000..876a3c3
--- /dev/null
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago-deltaspike.js
@@ -0,0 +1,671 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+jQuery(document).ready(function() {
+ var dswid = location.search.replace(/.*dswid=(\-?[0-9]+).*/, "$1");
+ if (dswid) {
+ dswh.init(dswid, 'LAZY', 10, {
+ 'tokenizedRedirect': false,
+ 'storeWindowTreeOnLinkClick': true,
+ 'storeWindowTreeOnButtonClick': false
+ });
+ }
+});
+
+// taken from deltaspike 1.9.4
+
+window.dswh = window.dswh || {
+
+ DEBUG_MODE : false,
+ TEMP_WINDOW_NAME : 'tempWindowId',
+ MANAGED_WINDOW_NAME_PREFIX : 'ds-',
+
+ initialized: false,
+ windowId : null,
+ clientWindowRenderMode : null,
+ maxWindowIdLength : 10,
+ cfg : null,
+
+ init : function(windowId, clientWindowRenderMode, maxWindowIdLength, cfg) {
+
+ if (dswh.initialized === true)
+ {
+ return;
+ }
+
+ dswh.initialized = true;
+
+ dswh.utils.log('------- DeltaSpike windowhandler.js -------');
+ dswh.utils.log('--- #init(\'' + windowId + '\', \'' + clientWindowRenderMode + '\',' + maxWindowIdLength + ',' + dswh.utils.stringify(cfg) + ')');
+ dswh.utils.log('window.name: ' + window.name);
+
+ this.windowId = windowId;
+ this.clientWindowRenderMode = clientWindowRenderMode;
+ this.maxWindowIdLength = maxWindowIdLength;
+ if (cfg) {
+ this.cfg = cfg;
+ } else {
+ this.cfg = {};
+ }
+
+ var targetStrategy = this.strategy[clientWindowRenderMode];
+ if (targetStrategy) {
+ dswh.utils.log('--- #validate');
+
+ targetStrategy.validate();
+
+ // early init
+ // this is required if e.g. the onload attr is defined on the body tag and our onload handler won't be called
+ // ATTENTION: the ds:windowId component must be placed as last body tag
+ dswh.utils.log('--- #init(false)');
+ targetStrategy.init(false);
+
+ // XXX jsf.ajax not used in Tobago
+ // JSF ajax callback
+ // jsf.ajax.addOnEvent(function(event) {
+ // if (event.status === "success") {
+ // dswh.utils.log('--- #init(true)');
+ // targetStrategy.init(true);
+ // }
+ // });
+
+
+ // PF ajax callback
+ if (window.$ && window.PrimeFaces) {
+ $(document).on('pfAjaxComplete', function () {
+ dswh.utils.log('--- #init(true)');
+ targetStrategy.init(true);
+ });
+ }
+
+ // init via onload
+ // just as fallback if ds:windowId is not placed at last body tag
+ var oldWindowOnLoad = window.onload;
+ window.onload = function(evt) {
+ try {
+ (oldWindowOnLoad) ? oldWindowOnLoad(evt) : null;
+ } finally {
+ dswh.utils.log('--- #init(false)');
+ targetStrategy.init(false);
+ }
+ };
+ }
+ },
+
+ strategy : {
+
+ 'CLIENTWINDOW' : {
+
+ validate : function() {
+ this.cleanupCookies();
+ this.assertWindowId();
+ },
+
+ init : function(ajax) {
+ this.overwriteLinkOnClickEvents();
+ this.overwriteButtonOnClickEvents();
+
+ dswh.utils.appendHiddenWindowIdToForms();
+ },
+
+ assertWindowId : function() {
+ dswh.utils.log('--- #assertWindowId');
+
+ // ensure that windowIds get checked even if no windowhandler.html is used
+ if (!dswh.utils.isWindowNameDefined() || !dswh.utils.isManagedWindowName()) {
+ dswh.utils.log('window name not defined or unmanaged - request new windowId');
+ dswh.utils.requestNewWindowId();
+ }
+ },
+
+ overwriteLinkOnClickEvents : function() {
+
+ var tokenizedRedirectEnabled = dswh.cfg.tokenizedRedirect;
+ var storeWindowTreeEnabled = dswh.utils.isHtml5() && dswh.cfg.storeWindowTreeOnLinkClick;
+
+ dswh.utils.log('--- #overwriteLinkOnClickEvents');
+ dswh.utils.log('tokenizedRedirect: ' + dswh.cfg.tokenizedRedirect);
+ dswh.utils.log('storeWindowTreeOnLinkClick: ' + dswh.cfg.storeWindowTreeOnLinkClick);
+
+ if (tokenizedRedirectEnabled || storeWindowTreeEnabled) {
+ var links = document.getElementsByTagName("a");
+ for (var i = 0; i < links.length; i++) {
+ var link = links[i];
+
+ var target = link.getAttribute('target');
+
+ if (dswh.strategy.CLIENTWINDOW.isHrefDefined(link) === true && (!target || target === '_self')) {
+ if (!link.onclick) {
+ link.onclick = function(evt) {
+ // IE handling added
+ evt = evt || window.event;
+
+ // skip open in new tab
+ if (!evt.ctrlKey) {
+ if (storeWindowTreeEnabled) {
+ dswh.strategy.CLIENTWINDOW.storeWindowTree();
+ }
+ if (tokenizedRedirectEnabled) {
+ dswh.strategy.CLIENTWINDOW.tokenizedRedirect(this);
+ return false;
+ }
+
+ return true;
+ }
+ };
+ } else {
+ // prevent double decoration
+ if (!("" + link.onclick).match(".*storeWindowTree().*")) {
+ //the function wrapper is important otherwise the
+ //last onclick handler would be assigned to oldonclick
+ (function storeEvent() {
+ var oldonclick = link.onclick;
+ link.onclick = function(evt) {
+ // IE handling added
+ evt = evt || window.event;
+
+ var proceed = oldonclick.bind(this)(evt);
+ if (typeof proceed === 'undefined' || proceed === true) {
+
+ // skip open in new tab
+ if (!evt.ctrlKey) {
+ if (storeWindowTreeEnabled) {
+ dswh.strategy.CLIENTWINDOW.storeWindowTree();
+ }
+
+ if (tokenizedRedirectEnabled) {
+ dswh.strategy.CLIENTWINDOW.tokenizedRedirect(this);
+ return false;
+ }
+ }
+ }
+ return proceed;
+ };
+ })();
+ }
+ }
+ }
+ }
+ }
+ },
+
+ overwriteButtonOnClickEvents : function() {
+
+ var storeWindowTreeEnabled = dswh.utils.isHtml5() && dswh.cfg.storeWindowTreeOnButtonClick;
+
+ dswh.utils.log('--- #overwriteButtonOnClickEvents');
+ dswh.utils.log('storeWindowTreeOnButtonClick: ' + dswh.cfg.storeWindowTreeOnButtonClick);
+
+ if (storeWindowTreeEnabled) {
+ var inputs = document.getElementsByTagName("input");
+ for (var i = 0; i < inputs.length; i++) {
+ var input = inputs[i];
+ if (input.getAttribute("type") === "submit" || input.getAttribute("type") === "button") {
+ if (!input.onclick) {
+ input.onclick = function() {
+ dswh.strategy.CLIENTWINDOW.storeWindowTree();
+ return true;
+ };
+ } else {
+ // prevent double decoration
+ if (!("" + input.onclick).match(".*storeWindowTree().*")) {
+ //the function wrapper is important otherwise the
+ //last onclick handler would be assigned to oldonclick
+ (function storeEvent() {
+ var oldonclick = input.onclick;
+ input.onclick = function(evt) {
+ //ie handling added
+ evt = evt || window.event;
+
+ dswh.strategy.CLIENTWINDOW.storeWindowTree();
+
+ return oldonclick.bind(this)(evt);
+ };
+ })();
+ }
+ }
+ }
+ }
+ }
+ },
+
+ isHrefDefined : function(link) {
+
+ var href = link.getAttribute("href");
+
+ if (!href || href === null) {
+ return false;
+ }
+
+ // trim
+ href = href.replace(/^\s+|\s+$/g, '');
+
+ if (href === '') {
+ return false;
+ }
+
+ if (href.indexOf('#') === 0) {
+ return false;
+ }
+
+ if (href.lastIndexOf('javascript:', 0) === 0) {
+ return false;
+ }
+
+ return true;
+ },
+
+ tokenizedRedirect : function(link) {
+
+ dswh.utils.log('--- #tokenizedRedirect');
+
+ var requestToken = dswh.utils.generateNewRequestToken();
+ dswh.utils.storeCookie('dsrwid-' + requestToken, dswh.windowId, 3);
+ window.location = dswh.utils.setUrlParam(link.href, 'dsrid', requestToken);
+ },
+
+ /**
+ * store the current body in the html5 localstorage
+ */
+ storeWindowTree : function() {
+
+ dswh.utils.log('--- #storeWindowTree');
+
+ // first we store all CSS we also need on the intermediate page
+ var headNodes = document.getElementsByTagName("head")[0].childNodes;
+ var oldSS = new Array();
+ var j = 0;
+ for (var i = 0; i < headNodes.length; i++) {
+ var tagName = headNodes[i].tagName;
+ if (tagName
+ && dswh.utils.equalsIgnoreCase(tagName, "link")
+ && dswh.utils.equalsIgnoreCase(headNodes[i].getAttribute("type"), "text/css")) {
+
+ // sort out media="print" and stuff
+ var media = headNodes[i].getAttribute("media");
+ if (!media
+ || dswh.utils.equalsIgnoreCase(media, "all")
+ || dswh.utils.equalsIgnoreCase(media, 'screen')) {
+ oldSS[j++] = headNodes[i].getAttribute("href");
+ }
+ }
+ }
+ localStorage.setItem(window.name + '_css', dswh.utils.stringify(oldSS));
+
+ var body = document.getElementsByTagName("body")[0];
+ localStorage.setItem(window.name + '_body', body.innerHTML);
+
+ 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() {
+ dswh.utils.log('--- #cleanupCookies');
+
+ var dsrid = dswh.utils.getUrlParameter(window.location.href, 'dsrid');
+ if (dsrid) {
+ dswh.utils.expireCookie('dsrwid-' + dsrid);
+ }
+ }
+ },
+
+ 'LAZY' : {
+
+ validate : function() {
+ this.cleanupCookies();
+ this.assertWindowId();
+ },
+
+ init : function(ajax) {
+ dswh.utils.appendHiddenWindowIdToForms();
+ },
+
+ assertWindowId : function() {
+ var dswid = dswh.utils.getUrlParameter(window.location.href, 'dswid');
+
+ dswh.utils.log('--- #assertWindowId');
+ dswh.utils.log('dswid: ' + dswid);
+
+ // window name is defined -> existing tab
+ if (dswh.utils.isWindowNameDefined()) {
+
+ // is the current window name a already managed by DS?
+ if (dswh.utils.isManagedWindowName()) {
+
+ var windowId = dswh.utils.getWindowIdFromWindowName();
+
+ // we triggered the windowId recreation last request
+ if (windowId === dswh.TEMP_WINDOW_NAME) {
+ // enabled initial redirect
+ // -> use the new windowId from the url
+ if (dswid) {
+ dswh.utils.log('assign window name from request parameter');
+
+ dswh.utils.setWindowIdAsWindowName(dswid);
+ }
+ // disabled initial redirect
+ // -> use the new windowId from the rendered config as no url param is available
+ else {
+ dswh.utils.log('assign window name from server windowId');
+
+ dswh.utils.setWindowIdAsWindowName(dswh.windowId);
+ }
+ }
+ // security check like on the server side
+ else if (windowId.length > dswh.maxWindowIdLength) {
+ dswh.utils.log('window id from window name exeeds maxWindowIdLength - request new windowId');
+
+ dswh.utils.requestNewWindowId();
+ }
+ // window name doesn't match requested windowId
+ // -> redirect to the same view with current windowId from the window name
+ else if (windowId !== dswid) {
+ dswh.utils.log('reload url with window name');
+
+ window.location = dswh.utils.setUrlParam(window.location.href, 'dswid', windowId);
+ }
+ }
+ else {
+ dswh.utils.log('window name is unmanaged - request new windowId');
+
+ dswh.utils.requestNewWindowId();
+ }
+ }
+ // window name is undefined -> "open in new tab/window" was used
+ else {
+ // url param available?
+ if (dswid) {
+ // initial redirect
+ // -> the windowId is valid - we don't need to a second request
+ if (dswh.cfg.initialRedirectWindowId && dswid === dswh.cfg.initialRedirectWindowId) {
+ dswh.utils.log('assign window name from initialRedirectWindowId');
+
+ dswh.utils.setWindowIdAsWindowName(dswh.cfg.initialRedirectWindowId);
+ }
+ // != initial redirect
+ // -> request a new windowId to avoid multiple tabs with the same windowId
+ else {
+ dswh.utils.log('request new windowId');
+
+ dswh.utils.requestNewWindowId();
+ }
+ }
+ // as no url parameter is available, the request is a new tab with disabled initial redirect
+ // -> just use the windowId from the renderer
+ else if (dswh.windowId) {
+ dswh.utils.log('assign window name from server windowId');
+
+ dswh.utils.setWindowIdAsWindowName(dswh.windowId);
+ }
+ }
+ },
+
+ cleanupCookies : function() {
+ dswh.utils.log('--- #cleanupCookies');
+
+ var dswid = dswh.utils.getUrlParameter(window.location.href, 'dswid');
+ if (dswid) {
+ dswh.utils.expireCookie('dsrwid-' + dswid);
+ }
+ }
+ }
+ },
+
+ utils : {
+
+ findRootWindow: function() {
+ var w = window;
+ while(w.frameElement) {
+ var parent = w.parent;
+ if (parent === undefined) {
+ break;
+ }
+ w = parent;
+ };
+
+ return w;
+ },
+
+ isWindowNameDefined : function() {
+ var w = dswh.utils.findRootWindow();
+ return w.name && w.name.length > 0;
+ },
+
+ isManagedWindowName : function() {
+ var w = dswh.utils.findRootWindow();
+ if (!w.name) {
+ return false;
+ }
+
+ return w.name.indexOf(dswh.MANAGED_WINDOW_NAME_PREFIX) === 0;
+ },
+
+ getWindowIdFromWindowName : function() {
+ return dswh.utils.findRootWindow().name.substring(dswh.MANAGED_WINDOW_NAME_PREFIX.length);
+ },
+
+ setWindowIdAsWindowName : function(windowId) {
+ dswh.utils.findRootWindow().name = dswh.MANAGED_WINDOW_NAME_PREFIX + windowId;
+ },
+
+ requestNewWindowId : function() {
+ // set temp window name to remember the current state
+ dswh.utils.setWindowIdAsWindowName(dswh.TEMP_WINDOW_NAME);
+
+ // we remove the dswid if available and redirect to the same url again to create a new windowId
+ window.location = dswh.utils.setUrlParam(window.location.href, 'dswid', null);
+
+ // set temp window name to remember the current state (again - sometimes required for IE!?)
+ dswh.utils.setWindowIdAsWindowName(dswh.TEMP_WINDOW_NAME);
+ },
+
+ isHtml5 : function() {
+ try {
+ return !!localStorage.getItem;
+ } catch(e) {
+ return false;
+ }
+ },
+
+ stringify : function(someArray) {
+ // some browsers don't understand JSON - guess which one ... :(
+ if (JSON) {
+ return JSON.stringify(someArray);
+ }
+ return someArray.join("|||");
+ },
+
+ unstringify : function(serialized) {
+ if (JSON) {
+ return JSON.parse(serialized);
+ }
+
+ return serialized.split("|||");
+ },
+
+ equalsIgnoreCase : function(source, destination) {
+ //either both are not set or null
+ if (!source && !destination) {
+ return true;
+ }
+ //source or dest is set while the other is not
+ if (!source || !destination) return false;
+
+ //in any other case we do a strong string comparison
+ return source.toLowerCase() === destination.toLowerCase();
+ },
+
+ getUrlParameter : function(uri, name) {
+ // create an anchor object with the uri and let the browser parse it
+ var a = document.createElement('a');
+ a.href = uri;
+
+ // check if a query string is available
+ var queryString = a.search;
+ if (queryString && queryString.length > 0) {
+ // create an array of query parameters - substring(1) removes the ? at the beginning of the query
+ var queryParameters = queryString.substring(1).split("&");
+ for (var i = 0; i < queryParameters.length; i++) {
+ var queryParameter = queryParameters[i].split("=");
+ if (queryParameter[0] === name) {
+ return queryParameter.length > 1 ? decodeURIComponent(queryParameter[1]) : "";
+ }
+ }
+ }
+
+ return null;
+ },
+
+ setUrlParam : function(uri, parameterName, parameterValue) {
+ var a = document.createElement('a');
+ a.href = uri;
+
+ // set empty string as value if not defined or empty
+ if (!parameterValue || parameterValue.replace(/^\s+|\s+$/g, '').length === 0) {
+ parameterValue = '';
+ }
+
+ // check if value is empty
+ if (parameterValue.length === 0) {
+
+ // both value and query string is empty (or doesn't contain the param), don't touch the url
+ if (a.search.length === 0 || a.search.indexOf(parameterName + "=") === -1) {
+ return a.href;
+ }
+ }
+
+ // query string is empty, just append our new parameter
+ if (a.search.length === 0) {
+ a.search = '?' + encodeURIComponent(parameterName) + "=" + encodeURIComponent(parameterValue);
+
+ return a.href;
+ }
+
+ var oldParameters = a.search.substring(1).split('&');
+ var newParameters = [];
+ newParameters.push(parameterName + "=" + encodeURIComponent(parameterValue));
+
+ // loop old parameters, remove empty ones and remove the parameter with the same name as the new one
+ for (var i = 0; i < oldParameters.length; i++) {
+ var oldParameterPair = oldParameters[i];
+
+ if (oldParameterPair.length > 0) {
+ var oldParameterName = oldParameterPair.split('=')[0];
+ var oldParameterValue = oldParameterPair.split('=')[1];
+
+ // don't add empty parameters again
+ if (oldParameterValue && oldParameterValue.replace(/^\s+|\s+$/g, '').length > 0) {
+ // skip the the old parameter if it's the same as the new parameter
+ if (oldParameterName !== parameterName) {
+ newParameters.push(oldParameterName + "=" + oldParameterValue);
+ }
+ }
+ }
+ }
+
+ // join new parameters
+ a.search = '?' + newParameters.join('&');
+
+ return a.href;
+ },
+
+ appendHiddenWindowIdToForms : function() {
+ var forms = document.getElementsByTagName("form");
+ for (var i = 0; i < forms.length; i++) {
+ var form = forms[i];
+ var dspwid = form.elements["dspwid"];
+ if (!dspwid) {
+ dspwid = document.createElement("INPUT");
+ dspwid.setAttribute("name", "dspwid");
+ dspwid.setAttribute("type", "hidden");
+ form.appendChild(dspwid);
+ }
+
+ dspwid.setAttribute("value", dswh.windowId);
+ }
+ },
+
+ expireCookie : function(cookieName) {
+ var date = new Date();
+ date.setTime(date.getTime()-(10*24*60*60*1000)); // - 10 day
+ var expires = ";max-age=0;expires=" + date.toGMTString();
+
+ document.cookie = cookieName + "=" + expires + "; path=/";
+ },
+
+ generateNewRequestToken : function() {
+ return "" + Math.floor(Math.random() * 999);
+ },
+
+ generateNewWindowId : function() {
+ return "" + Math.floor((Math.random() * (9999 - 1000)) + 1000);
+ },
+
+ storeCookie : function(name, value, seconds) {
+ var expiresDate = new Date();
+ expiresDate.setTime(expiresDate.getTime() + (seconds * 1000));
+ var expires = "; expires=" + expiresDate.toGMTString();
+
+ document.cookie = name + '=' + value + expires + "; path=/";
+ },
+
+ log : function(message) {
+ if (dswh.DEBUG_MODE === true) {
+ console.log(message);
+ }
+ }
+ }
+ };
+
+// 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
diff --git a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
index c6489b5..a33ca4d 100644
--- a/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
+++ b/tobago-theme/tobago-theme-standard/src/main/resources/org/apache/myfaces/tobago/renderkit/html/standard/standard/script/tobago.js
@@ -2783,52 +2783,6 @@ Tobago.registerListener(Tobago.SelectManyCheckbox.init, Tobago.Phase.AFTER_UPDAT
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-Tobago.Codi = {};
-
-/**
- * If the window has no name set we set the name and request a new view with unset windowId, so that the
- * server will generate a new one for us.
- */
-Tobago.Codi.init = function() {
-
- var form = document.forms[0];
- var windowIdEnabled = Tobago.Codi.hasUrlWindowId(form.action);
- if (windowIdEnabled && window.name == "") {
- form.action = Tobago.Codi.urlWithoutWindowId(form.action);
- window.name = "window";
- Tobago.submitAction();
- }
-};
-
-Tobago.Codi.hasUrlWindowId = function(base) {
- return base.indexOf("?windowId=") > -1 || base.indexOf("&windowId=") > -1;
-};
-
-/**
- * taken from myfaces-extcdi (Codi)
- */
-Tobago.Codi.urlWithoutWindowId = function(base) {
- var query = base;
- var vars = query.split(/&|\?/g);
- var newQuery = "";
- var iParam = 0;
- for (var i=0; vars != null && i < vars.length; i++) {
- var pair = vars[i].split("=");
- if (pair.length == 1) {
- newQuery = pair[0];
- }
- else {
- if (pair[0] != "windowId") {
- var amp = iParam++ > 0 ? "&" : "?";
- newQuery = newQuery + amp + pair[0] + "=" + pair[1];
- }
- }
- }
- return newQuery;
-};
-
-Tobago.registerListener(Tobago.Codi.init, Tobago.Phase.DOCUMENT_READY);
-
Tobago.SplitLayout = {
init: function(elements) {
Tobago.Utils.selectWithJQuery(elements, "[data-tobago-split-layout]").each(Tobago.SplitLayout.initLayout);