mirror of
https://github.com/OCA/web.git
synced 2025-02-22 13:21:25 +02:00
[IMP] : - Rename the module to web_widget_color
- Remove special type (Color) and use (Char) instead of.
This commit is contained in:
committed by
Enric Tobella
parent
44a51e97cf
commit
b8d7a5cbb9
BIN
web_widget_color/static/description/icon.png
Normal file
BIN
web_widget_color/static/description/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.4 KiB |
BIN
web_widget_color/static/lib/jscolor/arrow.gif
Normal file
BIN
web_widget_color/static/lib/jscolor/arrow.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 66 B |
BIN
web_widget_color/static/lib/jscolor/cross.gif
Normal file
BIN
web_widget_color/static/lib/jscolor/cross.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 83 B |
12
web_widget_color/static/lib/jscolor/demo.html
Normal file
12
web_widget_color/static/lib/jscolor/demo.html
Normal 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>
|
||||
BIN
web_widget_color/static/lib/jscolor/hs.png
Normal file
BIN
web_widget_color/static/lib/jscolor/hs.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
web_widget_color/static/lib/jscolor/hv.png
Normal file
BIN
web_widget_color/static/lib/jscolor/hv.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
1010
web_widget_color/static/lib/jscolor/jscolor.js
Normal file
1010
web_widget_color/static/lib/jscolor/jscolor.js
Normal file
File diff suppressed because it is too large
Load Diff
23
web_widget_color/static/src/css/widget.css
Normal file
23
web_widget_color/static/src/css/widget.css
Normal 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;
|
||||
}
|
||||
50
web_widget_color/static/src/js/widget.js
Normal file
50
web_widget_color/static/src/js/widget.js
Normal 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]);
|
||||
}
|
||||
});
|
||||
};
|
||||
24
web_widget_color/static/src/xml/widget.xml
Normal file
24
web_widget_color/static/src/xml/widget.xml
Normal 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>
|
||||
Reference in New Issue
Block a user