[IMP] improved code to pass tooltip delay in option and added function so we can set requred help in inherited modules.

bzr revid: tpa@tinyerp.com-20130916130825-pciwsn0doshstrp2
This commit is contained in:
Turkesh Patel (Open ERP) 2013-09-16 18:38:25 +05:30
parent 5a2ac400d7
commit 3cdc986c0c
2 changed files with 25 additions and 10 deletions

View File

@ -4,7 +4,8 @@ openerp.web_kanban_gauge = function (instance) {
* Kanban widgets: GaugeWidget
*
*/
var _t = instance.web._t,
_lt = instance.web._lt;
instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
className: "oe_gauge",
start: function() {
@ -77,13 +78,19 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
$input.focus()
.keydown(function (event) {
event.stopPropagation();
if (event.keyCode == 13 || event.keyCode == 9) {
if ($input.val() != value) {
parent.view.dataset.call(self.options.action_change, [parent.id, $input.val()]).then(function () {
parent.do_reload();
});
} else {
$div.remove();
if(isNaN($input.val())){
self.do_warn(_t("Wrong value entered!"), _t("Only Integer Value should be valid."));
$div.remove();
} else {
if (event.keyCode == 13 || event.keyCode == 9) {
var val = self.parse_client($input.val());
if ($input.val() != value) {
parent.view.dataset.call(self.options.action_change, [parent.id, $input.val()]).then(function () {
parent.do_reload();
});
} else {
$div.remove();
}
}
}
})
@ -112,6 +119,11 @@ instance.web_kanban.GaugeWidget = instance.web_kanban.AbstractField.extend({
}
}
},
parse_client: function(value) {
return openerp.web.parse_value(value, { type:"integer" });
},
});
instance.web_kanban.fields_registry.add("gauge", "instance.web_kanban.GaugeWidget");

View File

@ -20,15 +20,18 @@ instance.web_kanban.SparklineBarWidget = instance.web_kanban.AbstractField.exten
barWidth: 4,
barSpacing: 1,
barColor: '#96d854',
tooltipFormat: '{{offset:offset}} {{value}}',
tooltipFormat: self.set_offset(),
tooltipValueLookups: {
'offset': tooltips
}
}, self.options);
self.$el.sparkline(value, sparkline_options);
self.$el.tipsy({'delayIn': 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
self.$el.tipsy({'delayIn': self.options.delayIn || 0, 'html': true, 'title': function(){return title}, 'gravity': 'n'});
}, 0);
},
set_offset: function(){
return '{{offset:offset}} {{value}}';
}
});
instance.web_kanban.fields_registry.add("sparkline_bar", "instance.web_kanban.SparklineBarWidget");