Save note colors on HEX with upper case

This commit is contained in:
Matias De lellis
2016-05-22 14:43:02 -03:00
parent 42dbc2a51b
commit b13b148395

View File

@@ -202,6 +202,20 @@ View.prototype = {
modaltitle.html("");
modalcontent.html("");
},
colorToHex: function(color) {
if (color.substr(0, 1) === '#') {
return color.toUpperCase();;
}
var digits = /(.*?)rgb\((\d+), (\d+), (\d+)\)/.exec(color);
var red = parseInt(digits[2]);
var green = parseInt(digits[3]);
var blue = parseInt(digits[4]);
var rgb = blue | (green << 8) | (red << 16);
return digits[1] + '#' + rgb.toString(16).toUpperCase();
},
renderContent: function () {
var source = $('#content-tpl').html();
var template = Handlebars.compile(source);
@@ -301,7 +315,7 @@ View.prototype = {
var id = modalnote.data('id');
var title = modaltitle.html();
var content = modalcontent.html();
var color = modalnote.css("background-color");
var color = self.colorToHex(modalnote.css("background-color"));
self._notes.updateId(id, title, content, color).done(function () {
self._notes.unsetActive();