[IMP] : - Rename the module to web_widget_color

- Remove special type (Color) and use (Char) instead of.
This commit is contained in:
Adil Houmadi
2015-02-19 13:37:34 +01:00
committed by Enric Tobella
parent 44a51e97cf
commit b8d7a5cbb9
18 changed files with 1337 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 B

View File

@@ -0,0 +1,12 @@
<html>
<head>
<title>jscolor demo</title>
</head>
<body>
<script type="text/javascript" src="jscolor.js"></script>
Click here: <input class="color" value="66ff00">
</body>
</html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,23 @@
.openerp .oe_form .oe_form_field_color input {
width: 100%;
}
.openerp .oe_form .oe_form_field_color div {
border: 1px solid;
display: inline-block;
height: 14px;
margin-right: 10px;
position: relative;
top: 3px;
width: 40px;
}
.oe_list_field_color div {
border: 1px solid;
display: inline-block;
height: 14px;
margin-right: 10px;
position: relative;
top: 3px;
width: 40px;
}

View File

@@ -0,0 +1,50 @@
openerp.web_widget_color = function (instance) {
instance.web.form.widgets.add('color', 'instance.web.form.FieldColor');
instance.web.search.fields.add('color', 'instance.web.search.CharField');
instance.web.form.FieldColor = instance.web.form.FieldChar.extend({
template: 'FieldColor',
widget_class: 'oe_form_field_color',
is_syntax_valid: function () {
var $input = this.$('input');
if (!this.get("effective_readonly") && $input.size() > 0) {
var val = $input.val();
var isOk = /^#[0-9A-F]{6}$/i.test(val);
if (!isOk) {
return false;
}
try {
this.parse_value(this.$('input').val(), '');
return true;
} catch (e) {
return false;
}
}
return true;
},
render_value: function () {
var show_value = this.format_value(this.get('value'), '');
if (!this.get("effective_readonly")) {
var $input = this.$el.find('input');
$input.val(show_value);
$input.css("background-color", show_value)
jscolor.init(this.$el[0]);
} else {
this.$(".oe_form_char_content").text(show_value);
this.$('div').css("background-color", show_value)
}
}
});
/*
* Init jscolor for each editable mode on view form
*/
instance.web.FormView.include({
to_edit_mode: function () {
this._super();
jscolor.init(this.$el[0]);
}
});
};

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<templates>
<t t-name="FieldColor">
<span t-att-class="'oe_form_field '+widget.widget_class" t-att-style="widget.node.attrs.style">
<t t-if="!widget.get('effective_readonly')">
<input type="text"
t-att-id="widget.id_for_label"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus"
t-att-placeholder="widget.node.attrs.placeholder"
t-att-maxlength="widget.field.size"
class="color {hash:true}"
/>
</t>
<t t-if="widget.get('effective_readonly')">
<div/>
<span class="oe_form_char_content"></span>
</t>
</span>
</t>
<tr t-extend="ListView.row">
<t t-jquery="t td t" t-operation="replace"><t t-if="column.widget =='color' || column.type == 'color'"><div t-att-style="'background-color:' + render_cell(record, column)"/></t><t t-raw="render_cell(record, column)"/></t>
</tr>
</templates>