1 openerp.crm = function(openerp) {
2 openerp.web_kanban.KanbanRecord.include({
3 renderElement: function () {
4 var rendering = this._super();
6 if (this.view.dataset.model === 'crm.case.section') {
8 $.when(rendering).done(function() {
9 self.$(".oe_justgage").each(function () {
11 var title = $el.html();
12 var unique_id = _.uniqueId("JustGage");
13 $el.empty().css("position", "relative").attr('id', unique_id);
19 value: +$el.data('value'),
21 max: +$el.data('max'),
22 relativeGaugeSize: true,
24 titleFontColor: '#333333',
25 valueFontColor: '#333333',
26 labelFontColor: '#000',
27 label: $el.data('label'),
35 var flag_open = false;
36 if ($el.data('action')) {
37 $el.click(function (event) {
38 event.stopPropagation();
40 if (!self.view.is_action_enabled('edit')) {
43 if (!$el.find(".oe_justgage_edit").size()) {
44 var $svg = $el.find('svg');
45 $div = $('<div class="oe_justgage_edit" style="text-align: center; z-index: 1; position: absolute; width: ' + $svg.outerWidth() + 'px; top: ' + ($svg.outerHeight()/2-5) + 'px;"/>');
46 $input = $('<input style="text-align: center; width: ' + ($svg.outerWidth()-40) + 'px; margin: auto;"/>').val($el.data('value'));
50 .keydown(function (event) {
51 event.stopPropagation();
52 if (event.keyCode == 13 || event.keyCode == 9) {
53 if ($input.val() != $el.data('value')) {
54 self.view.dataset.call($el.data('action'), [self.id, $input.val()]).then(function () {
62 .click(function (event) {
63 event.stopPropagation();
66 .blur(function (event) {
68 $el.find(".oe_justgage_edit").remove();
71 setTimeout(function () {$input.focus();}, 0);
75 }).mousedown(function () {
80 setTimeout(function () {
81 self.$(".oe_sparkline_bar").each(function () {
83 $el.data("title", $el.html());
84 $el.sparkline($el.data("value").split(','), {type: 'bar', barWidth: 5} );
85 $el.tipsy({'delayIn': 0, 'html': true, 'title': function(){return $(this).data("title")}, 'gravity': 'n'});
91 on_card_clicked: function() {
92 if (this.view.dataset.model === 'crm.case.section') {
93 this.$('.oe_kanban_crm_salesteams_list a').first().click();
95 this._super.apply(this, arguments);