|
|
@ -1,6 +1,7 @@ |
|
|
|
var EditLineColor = function (parent) { |
|
|
|
this.Parent = parent; |
|
|
|
this.Dialog = $('#edit-line-color-dialog'); |
|
|
|
this.LineColor = {}; |
|
|
|
|
|
|
|
this.Setup = function () { |
|
|
|
$("#color-picker").on("change", this.ColorChange.bind(this)); |
|
|
@ -11,20 +12,51 @@ |
|
|
|
|
|
|
|
this.Show = function (data) { |
|
|
|
this.Dialog.show(); |
|
|
|
console.log(data); |
|
|
|
this.LineColor = data; |
|
|
|
var rgbColor = this.getColor(data.Value); |
|
|
|
$("#color").textbox('setValue', data.Value); |
|
|
|
$('#color-picker').val('#ff0000'); |
|
|
|
$('#color-picker').val(rgbColor); |
|
|
|
}; |
|
|
|
|
|
|
|
this.ColorChange = function () { |
|
|
|
$("#color").textbox('setValue', $('#color-picker').val()); |
|
|
|
var color = this.getHexColor($('#color-picker').val()); |
|
|
|
$("#color").textbox('setValue', color); |
|
|
|
}; |
|
|
|
|
|
|
|
this.OnSureButtonClick = function () { |
|
|
|
this.LineColor.Value = $('#color').textbox('getValue'); |
|
|
|
|
|
|
|
this.UpdateLineWidth(); |
|
|
|
this.Dialog.hide(); |
|
|
|
this.Parent.DisabledEvent(); |
|
|
|
}; |
|
|
|
|
|
|
|
this.UpdateLineWidth = function () { |
|
|
|
$.ajax({ |
|
|
|
type: "POST", |
|
|
|
dataType: 'text', |
|
|
|
url: '/ConfigManagement/Update', |
|
|
|
data: this.LineColor, |
|
|
|
success: function () { |
|
|
|
this.Parent.ReLoadTableData(); |
|
|
|
}.bind(this) |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
this.HideDialog = function () { |
|
|
|
this.Dialog.hide(); |
|
|
|
}; |
|
|
|
|
|
|
|
this.getColor = function (color) { |
|
|
|
var rgb = color.split(','); |
|
|
|
var r = parseInt(rgb[0].split('(')[1]); |
|
|
|
var g = parseInt(rgb[1]); |
|
|
|
var b = parseInt(rgb[2].split(')')[0]); |
|
|
|
var hex = "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); |
|
|
|
return hex; |
|
|
|
}; |
|
|
|
|
|
|
|
this.getHexColor = function (hex) { |
|
|
|
return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + ")" |
|
|
|
} |
|
|
|
}; |