...
 
Commits (6)
......@@ -39,6 +39,7 @@ if ($Avatar) {
<!--[if (gte IE 9)|!(IE)]><!-->
<html lang="<?php echo $User->getLang(); ?>"> <!--<![endif]-->
<head>
<title>QUIQQER - <?php echo HOST ?></title>
<link
href="//fonts.googleapis.com/css?family=Open+Sans:400,700,400italic"
......@@ -50,12 +51,11 @@ if ($Avatar) {
content="width=device-width, initial-scale=1, minimum-scale=1,maximum-scale=1"
/>
<meta name="robots" content="noindex,nofollow"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<!-- HTML5
================================================== -->
<title>QUIQQER - <?php echo HOST ?></title>
<meta name="description"
content="Modular design. Convenient backend Fast implementation. The all around carefree Enterprise Content Management System."
/>
<link href="<?php echo URL_BIN_DIR; ?>images/Q.png" rel="shortcut icon" type="image/x-icon"/>
......
......@@ -31,9 +31,10 @@ define('controls/projects/Select', [
Type : 'controls/projects/Select',
options: {
langSelect : true,
emptyselect: true,
icon : 'fa fa-home'
langSelect : true,
emptyselect : true,
icon : 'fa fa-home',
localeStorage: false // name for the locale storage, if this is set, the value is stored in the locale storage
},
initialize: function (options) {
......@@ -50,13 +51,16 @@ define('controls/projects/Select', [
this.$Elm = new Element('div');
var localStorageValue = QUI.Storage.get('dashboard-media-info-card-project-select');
this.$Select = new QUISelect({
name : 'projects-select',
events: {
name : 'projects-select',
events : {
onChange: function (value) {
self.fireEvent('change', [value, self]);
}
}
},
localeStorage: this.getAttribute('localeStorage')
});
this.$Select.inject(this.$Elm);
......@@ -102,9 +106,17 @@ define('controls/projects/Select', [
}
}
self.$Select.setValue(
self.$Select.firstChild().getAttribute('value')
);
var value = self.$Select.firstChild().getAttribute('value');
if (localStorageValue) {
try {
value = JSON.decode(localStorageValue);
} catch (e) {
value = self.$Select.firstChild().getAttribute('value');
}
}
self.$Select.setValue(value);
self.fireEvent('load', [self]);
self.Loader.hide();
......
......@@ -249,6 +249,44 @@ define('utils/Color', [], function () {
}
return {r: r, g: g, b: b};
},
/**
* Uses a string as an input, hashes it and calculates a hex color (#ABC123) from it.
*
* This is especially useful for charts.
* This makes it possible to generate a different color for each value which result is also repeatable.
* So the same values will always have the same colors.
*
* Adapted from Christian Sanchez on StackOverflow:
* @link https://stackoverflow.com/a/3426956/3002417
*
* @example Passing 'text/plain' as an input returns '#FF9436'.
*
* @param {string} string
*
* @return {string} Color in hex format with a prepended '#' (e.g. '#ABC123')
*/
getHexColorByHashingString: function (string) {
function generateHash(str) {
var hash = 0;
for (var i = 0; i < str.length; i++) {
hash = str.charCodeAt(i) + ((hash << 5) - hash);
}
return hash;
}
function hashToRgb(i){
var c = (i & 0x00FFFFFF)
.toString(16)
.toUpperCase();
return "00000".substring(0, 6 - c.length) + c;
}
return '#' + hashToRgb(generateHash(string));
}
};
});
\ No newline at end of file
......@@ -71,7 +71,7 @@
"npm-asset\/urijs": "1.*"
},
"require-dev": {
"mikey179\/vfsStream": "1.*",
"mikey179\/vfsstream": "1.*",
"phpstan\/phpstan": ">=0.5"
},
"scripts": {
......