Skip to content

Commit 930feec

Browse files
committed
added color to projects. fix mtierltd#45
1 parent 672b5bd commit 930feec

File tree

12 files changed

+428
-37
lines changed

12 files changed

+428
-37
lines changed

appinfo/database.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@
5050
<notnull>true</notnull>
5151
<length>64</length>
5252
</field>
53+
<field>
54+
<name>color</name>
55+
<type>text</type>
56+
<notnull>true</notnull>
57+
<default>#ffffff</default>
58+
<length>7</length>
59+
</field>
5360
<field>
5461
<name>client_id</name>
5562
<type>integer</type>

css/daterangepicker.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,3 +386,36 @@
386386
float: right; }
387387
.daterangepicker .drp-calendar.left {
388388
clear: none !important; } }
389+
.daterangepicker {
390+
background-color: var(--color-main-background);
391+
}
392+
.daterangepicker .calendar-table {
393+
border: 1px solid var(--color-main-background);
394+
border-radius: 4px;
395+
background-color: var(--color-main-background);
396+
}
397+
.daterangepicker select.hourselect, .daterangepicker select.minuteselect, .daterangepicker select.secondselect, .daterangepicker select.ampmselect {
398+
width: 50px;
399+
margin: 0 auto;
400+
background:var(--color-background-dark);
401+
border: 1px solid var(--color-background-dark);
402+
padding: 2px;
403+
outline: 0;
404+
font-size: 12px;
405+
}
406+
407+
.daterangepicker td.off, .daterangepicker td.off.in-range, .daterangepicker td.off.start-date, .daterangepicker td.off.end-date {
408+
background-color:var(--color-main-background);
409+
border-color: transparent;
410+
color: var(--color-background-darker);
411+
}
412+
413+
.daterangepicker td.available:hover, .daterangepicker th.available:hover {
414+
background-color: var(--color-background-darker);
415+
border-color: transparent;
416+
color: inherit;
417+
}
418+
.daterangepicker .ranges li:hover {
419+
background-color: var(--color-background-darker);
420+
}
421+

css/piklor.css

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
header, footer {
3+
color: white;
4+
background: #303F9F;
5+
box-shadow: 0 0 10px rgba(0, 0, 0, 0.51);
6+
}
7+
8+
h1.title {
9+
font-size: 4em;
10+
font-weight: bold;
11+
}
12+
13+
pre {
14+
background: #212121;
15+
color: white;
16+
}
17+
18+
header p {
19+
font-size: 1.4em;
20+
}
21+
22+
footer {
23+
padding: 50px 0;
24+
text-align: center;
25+
font-size: 1.1em;
26+
margin-top: 3em;
27+
}
28+
29+
footer a {
30+
color: white;
31+
}
32+
33+
footer a:hover {
34+
color: white;
35+
}
36+
*/
37+
/* picker */
38+
.color-picker {
39+
background: rgba(255, 255, 255, 0.75);
40+
padding: 10px;
41+
border: 1px solid rgba(203, 203, 203, 0.6);
42+
border-radius: 2px;
43+
position: absolute;
44+
margin-left: -120px;
45+
width: 300px;
46+
z-index: 10;
47+
margin-top: 35px;
48+
}
49+
50+
.color-picker > div {
51+
width: 20px;
52+
display: inline-block;
53+
height: 20px;
54+
margin: 3px;
55+
border-radius: 100%;
56+
opacity: 0.7;
57+
58+
}
59+
60+
.picker-wrapper {
61+
padding: 20px;
62+
display: inline;
63+
}
64+
65+
.color-picker > div:hover {
66+
opacity: 1;
67+
}

css/style.css

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,4 +501,15 @@ td.ε_row {
501501
.ui-widget-content {
502502
background-color: var(--color-main-background);
503503
color: var(--color-text-normal);
504+
}
505+
.select-project-color {
506+
display: inline-block;
507+
width: 9px;
508+
height: 5px;
509+
margin: 3px;
510+
border-radius: 100%;
511+
}
512+
513+
.select-project {
514+
/*font-size: 24px;*/
504515
}

js/src/piklor.js

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
(function (root) {
2+
3+
/**
4+
* Piklor
5+
* Creates a new `Piklor` instance.
6+
*
7+
* @name Piklor
8+
* @function
9+
* @param {String|Element} sel The element where the color picker will live.
10+
* @param {Array} colors An array of strings representing colors.
11+
* @param {Object} options An object containing the following fields:
12+
*
13+
* - `open` (String|Element): The HTML element or query selector which will open the picker.
14+
* - `openEvent` (String): The open event (default: `"click"`).
15+
* - `style` (Object): Some style options:
16+
* - `display` (String): The display value when the picker is opened (default: `"block"`).
17+
* - `template` (String): The color item template. The `{color}` snippet will be replaced
18+
* with the color value (default: `"<div data-col=\"{color}\" style=\"background-color: {color}\"></div>"`).
19+
* - `autoclose` (Boolean): If `false`, the color picker will not be hided by default (default: `true`).
20+
* - `closeOnBlur` (Boolean): If `true`, the color picker will be closed when clicked outside of it (default: `false`).
21+
*
22+
* @return {Piklor} The `Piklor` instance.
23+
*/
24+
function Piklor(sel, colors, options) {
25+
var self = this;
26+
options = options || {};
27+
options.open = self.getElm(options.open);
28+
options.openEvent = options.openEvent || "click";
29+
options.style = Object(options.style);
30+
options.style.display = options.style.display || "inline-block";
31+
options.closeOnBlur = options.closeOnBlur || false;
32+
options.template = options.template || "<div data-col=\"{color}\" style=\"background-color: {color}\"></div>";
33+
self.elm = self.getElm(sel);
34+
self.cbs = [];
35+
self.isOpen = true;
36+
self.colors = colors;
37+
self.options = options;
38+
self.render();
39+
40+
// Handle the open element and event.
41+
if (options.open) {
42+
options.open.addEventListener(options.openEvent, function (ev) {
43+
self.isOpen ? self.close() : self.open();
44+
ev.preventDefault();
45+
return false;
46+
});
47+
}
48+
49+
// Click on colors
50+
self.elm.addEventListener("click", function (ev) {
51+
var col = ev.target.getAttribute("data-col");
52+
if (!col) { return; }
53+
self.close();
54+
self.set(col);
55+
});
56+
57+
if (options.closeOnBlur) {
58+
window.addEventListener("click", function (ev) {
59+
// check if we didn't click 'open' and 'color pallete' elements
60+
if (ev.target != options.open && ev.target != self.elm && self.isOpen) {
61+
self.close();
62+
}
63+
});
64+
}
65+
66+
if (options.autoclose !== false) {
67+
self.close();
68+
}
69+
}
70+
71+
/**
72+
* getElm
73+
* Finds the HTML element.
74+
*
75+
* @name getElm
76+
* @function
77+
* @param {String|Element} el The HTML element or query selector.
78+
* @return {HTMLElement} The selected HTML element.
79+
*/
80+
Piklor.prototype.getElm = function (el) {
81+
if (typeof el === "string") {
82+
return document.querySelector(el);
83+
}
84+
return el;
85+
};
86+
87+
/**
88+
* render
89+
* Renders the colors.
90+
*
91+
* @name render
92+
* @function
93+
*/
94+
Piklor.prototype.render = function () {
95+
var self = this
96+
, html = ""
97+
;
98+
99+
self.colors.forEach(function (c) {
100+
html += self.options.template.replace(/\{color\}/g, c);
101+
});
102+
103+
self.elm.innerHTML = html;
104+
};
105+
106+
/**
107+
* close
108+
* Closes the color picker.
109+
*
110+
* @name close
111+
* @function
112+
*/
113+
Piklor.prototype.close = function () {
114+
this.elm.style.display = "none";
115+
this.isOpen = false;
116+
};
117+
118+
/**
119+
* open
120+
* Opens the color picker.
121+
*
122+
* @name open
123+
* @function
124+
*/
125+
Piklor.prototype.open = function () {
126+
this.elm.style.display = this.options.style.display;
127+
this.isOpen = true;
128+
};
129+
130+
/**
131+
* colorChosen
132+
* Adds a new callback in the colorChosen callback buffer.
133+
*
134+
* @name colorChosen
135+
* @function
136+
* @param {Function} cb The callback function called with the selected color.
137+
*/
138+
Piklor.prototype.colorChosen = function (cb) {
139+
this.cbs.push(cb);
140+
};
141+
142+
/**
143+
* set
144+
* Sets the color picker color.
145+
*
146+
* @name set
147+
* @function
148+
* @param {String} c The color to set.
149+
* @param {Boolean} p If `false`, the `colorChosen` callbacks will not be called.
150+
*/
151+
Piklor.prototype.set = function (c, p) {
152+
var self = this;
153+
self.color = c;
154+
if (p === false) { return; }
155+
self.cbs.forEach(function (cb) {
156+
cb.call(self, c);
157+
});
158+
};
159+
160+
root.Piklor = Piklor;
161+
})(this);

0 commit comments

Comments
 (0)