From 8181772025005c8a3ac41d5c4362a1f35bf7a2be Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 25 Feb 2014 16:02:46 +0000 Subject: [PATCH] do NOT initialise imediatly, as DOM is not yet ready (at least in IE11) --- phpgwapi/js/jsapi/egw_calendar.js | 9 +++------ phpgwapi/js/jsapi/egw_css.js | 29 +++++++++++++++++------------ 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/phpgwapi/js/jsapi/egw_calendar.js b/phpgwapi/js/jsapi/egw_calendar.js index e39fb1ee53..edca1f3e9f 100644 --- a/phpgwapi/js/jsapi/egw_calendar.js +++ b/phpgwapi/js/jsapi/egw_calendar.js @@ -68,6 +68,9 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) { if (!calendar_translated) { + // Set template's icon for date popup - could probably use jquery-ui icons + this.css(".et2_date input.hasDatepicker:hover", "background-image: url(" + egw().image('datepopup') + ")"); + translateCalendar(); calendar_translated = true; } @@ -218,12 +221,6 @@ egw.extend('calendar', egw.MODULE_WND_LOCAL, function(_app, _wnd) _wnd.jQuery.timepicker.setDefaults(regional); }; - // Static initialization - - // Set template's icon for date popup - could probably use jquery-ui icons - var css = this.module('css',_wnd); - css.css(".et2_date input.hasDatepicker:hover", "background-image: url(" + egw().image('datepopup') + ")"); - return { /** * setup a calendar / date-selection diff --git a/phpgwapi/js/jsapi/egw_css.js b/phpgwapi/js/jsapi/egw_css.js index f255b620c4..590f8eb6c0 100644 --- a/phpgwapi/js/jsapi/egw_css.js +++ b/phpgwapi/js/jsapi/egw_css.js @@ -10,7 +10,7 @@ * @version $Id$ */ -"use strict" +"use strict"; /*egw:uses egw_core; @@ -20,8 +20,10 @@ * Module which allows to add stylesheet rules at runtime. Exports the following * functions: * - css + * @param {string} _app application name object is instanciated for + * @param {object} _wnd window object is instanciated for */ -egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) { +egw.extend('css', egw.MODULE_WND_LOCAL, function(_app, _wnd) { /** * Assoziative array which stores the current css rule for a given selector. @@ -32,14 +34,7 @@ egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) { * Variable used to calculate unique id for the selectors. */ var selectorCount = 0; - - // Generate a style tag, which will be used to hold the newly generated css - // rules. - var style = _wnd.document.createElement('style'); - _wnd.document.getElementsByTagName('head')[0].appendChild(style); - - // Obtain the reference to the styleSheet object of the generated style tag - var sheet = style.sheet ? style.sheet : style.styleSheet; + var sheet; return { /** @@ -56,6 +51,17 @@ egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) { // Set the current index to the maximum index var index = selectorCount; + if (!sheet) + { + // Generate a style tag, which will be used to hold the newly generated css + // rules. + var style = _wnd.document.createElement('style'); + _wnd.document.getElementsByTagName('head')[0].appendChild(style); + + // Obtain the reference to the styleSheet object of the generated style tag + sheet = style.sheet ? style.sheet : style.styleSheet; + } + // Remove any existing rule first, of no rule exists for the if (typeof selectors[_selector] !== "undefined") { @@ -93,7 +99,6 @@ egw.extend('css', egw.MODULE_WND_LOCAL, function(_egw, _wnd) { selectors[_selector] = index; } } - } - + }; });