Commit 7ee9acc0 authored by Yusei Tahara's avatar Yusei Tahara

[erp5_web_renderjs_ui] Firefox wallpaper URL changer must be implemented as a declareService.

parent 8dcc7d23
/*globals window, document, RSVP, rJS,
URI, location, XMLHttpRequest, console, navigator, Event*/
URI, location, XMLHttpRequest, console, navigator, Event,
URL*/
/*jslint indent: 2, maxlen: 80*/
(function (window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator, Event) {
XMLHttpRequest, location, console, navigator, Event,
URL) {
"use strict";
var MAIN_SCOPE = "m",
......@@ -11,11 +13,7 @@
setting_id: "setting/" + document.head.querySelector(
'script[data-renderjs-configuration="application_title"]'
).textContent
}),
index,
styleSheet,
wallpaper_url,
a_element;
});
function renderMainGadget(gadget, url, options) {
var page_gadget;
......@@ -827,29 +825,34 @@
.onEvent('submit', function submit() {
return displayError(this, new Error("Unexpected form submit"));
});
})
//
// For Firefox, Wallpaper URL must be absolute one.
//
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
for (index = 0; index < document.styleSheets.length; index += 1) {
styleSheet = document.styleSheets[index];
if (styleSheet.href.startsWith('data:text/css;')) {
wallpaper_url = styleSheet.cssRules[0].style
.backgroundImage.slice(4, -1).replace(/["']/g, '');
a_element = document.createElement('a');
a_element.href = wallpaper_url;
styleSheet.cssRules[0].style.backgroundImage =
'url("' + a_element.href + '")';
break;
/////////////////////////////////////////////////////////////////
// For Firefox, Wallpaper URL must be absolute one.
/////////////////////////////////////////////////////////////////
.declareService(function () {
var index, styleSheet, wallpaper_url, wallpaper_absolute_url;
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
for (index = 0; index < document.styleSheets.length; index += 1) {
styleSheet = document.styleSheets[index];
if (styleSheet.href.startsWith('data:text/css;')) {
wallpaper_url = styleSheet.cssRules[0].style
.backgroundImage.slice(4, -1).replace(/["']/g, '');
wallpaper_absolute_url = new URL(
wallpaper_url,
window.location.toString()
);
styleSheet.cssRules[0].style.backgroundImage =
'url("' + wallpaper_absolute_url.href + '")';
break;
}
}
index = null;
styleSheet = null;
wallpaper_url = null;
wallpaper_absolute_url = null;
}
}
index = null;
styleSheet = null;
wallpaper_url = null;
a_element = null;
}
});
}(window, document, RSVP, rJS,
XMLHttpRequest, location, console, navigator, Event));
\ No newline at end of file
XMLHttpRequest, location, console, navigator, Event, URL));
\ No newline at end of file
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.15396.60577.50107</string> </value>
<value> <string>978.15454.53878.14950</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1567690058.72</float>
<float>1567693410.93</float>
<string>UTC</string>
</tuple>
</state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment