~txerpa-openerp/openobject-client-web/txerpa

« back to all changes in this revision

Viewing changes to addons/openerp/static/javascript/m2o.js

  • Committer: Biel - txerpa.com
  • Date: 2013-08-09 12:30:58 UTC
  • mfrom: (4670.2.245 openobject-client-web)
  • Revision ID: biel.massot@txerpa.com-20130809123058-892zu673ti1j8yjd
Actualizo a la ultima revision de trunk. Hay muchos bugs correjidos desde 2012. Elimino la revision 4873 por problemas de rendimiento en el dashboard de Contabilidad

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    }
32
32
 
33
33
    this.__init__(name);
 
34
    self = this;
34
35
};
35
36
 
36
37
ManyToOne.prototype.__init__ = function(name) {
65
66
    jQuery(this.text).attr('autocomplete', 'OFF');
66
67
 
67
68
    if(this.editable) {
68
 
        jQuery(this.field).change(jQuery.proxy(this, 'on_change'));
69
69
        jQuery(this.text).bind({
70
70
            keydown: jQuery.proxy(this, 'on_keydown'),
71
71
            keypress: jQuery.proxy(this, 'on_keypress'),
72
72
            keyup: jQuery.proxy(this, 'on_keyup'),
73
73
            focus: jQuery.proxy(this, 'gotFocus'),
74
74
            blur: jQuery.proxy(this, 'lostFocus')
75
 
        }).removeAttr('callback');
 
75
        });
76
76
 
77
77
        this.lastTextResult = this.text.value;
78
78
 
96
96
};
97
97
 
98
98
ManyToOne.prototype.gotFocus = function(evt) {
 
99
    jQuery(this.text).removeAttr('callback');
99
100
    this.hasFocus = true;
100
101
};
101
102
 
102
103
ManyToOne.prototype.lostFocus = function() {
 
104
    jQuery(this.text).removeAttr('callback');
103
105
    this.hasFocus = false;
104
106
    if(this.selectedResult || this.lastKey == 9) {
105
107
        this.lastKey = null;
233
235
};
234
236
 
235
237
ManyToOne.prototype.on_keyup = function() {
 
238
    jQuery(this.text).removeAttr('callback');
236
239
    // Stop processing if a special key has been pressed. Or if the last search requested the same string
237
240
    if(this.specialKeyPressed || (this.text.value == this.lastSearch)) return false;
238
241
 
266
269
};
267
270
 
268
271
ManyToOne.prototype.on_keydown = function(evt) {
 
272
    jQuery(this.text).removeAttr('callback');
269
273
    this.lastKey = evt.which;
270
274
    // Used to stop processing of further key functions
271
275
    this.specialKeyPressed = false;
291
295
 
292
296
                this.setCompletionText($selectedRow);
293
297
 
294
 
                if(this.callback) {
295
 
                    onChange(this.name);
296
 
                }
 
298
                $(this.field).change();
297
299
                this.change_icon();
298
300
                this.clearResults();
299
301
                break;
332
334
    if((evt.which == 8 || evt.which == 46) && this.field.value) {
333
335
        this.text.value = '';
334
336
        this.field.value = '';
335
 
        this.on_change(evt);
 
337
        $(this.field).change();
336
338
    }
337
339
 
338
340
    //Tab
358
360
};
359
361
 
360
362
ManyToOne.prototype.on_keypress = function(evt) {
 
363
    jQuery(this.text).removeAttr('callback');
361
364
    // We use 'keyCode' instead if 'which' because keypress is only triggered on 'character' keys except in firefox.
362
365
    if (evt.keyCode == 9 || evt.ctrlKey) {
363
366
        return true;
392
395
    var domain = jQuery(this.field).attr('domain');
393
396
    var context = this.get_context();
394
397
 
 
398
    // clear and hide autoComplete results box before getting matched
 
399
    // datas
 
400
    m2o.clearResults();
 
401
 
395
402
    eval_domain_context_request({
396
403
        source: this.name,
397
404
        domain: domain,
624
631
 
625
632
            if($m2o_field[0].onchange) {
626
633
                $m2o_field[0].onchange();
 
634
            } else if ($m2o_field[0]._m2o) {
 
635
                $m2o_field[0]._m2o.on_change();
627
636
            } else {
628
637
                $m2o_field.change();
629
638
            }
655
664
        var $this;
656
665
        if(this == $) $this = $(window);
657
666
        else $this = $(this);
658
 
        if(window != window.top) {
659
 
            return window.top.jQuery.m2o.apply($this[0], arguments);
 
667
        if(window != window.parent) {
 
668
            return window.parent.jQuery.m2o.apply($this[0], arguments);
660
669
        }
661
670
        // We're at the top-level window, $this is the window from which the
662
671
        // original $.m2o call was performed, window being the current window