~openerp-dev/openerp-web/6.1-web-custo-mmu-access-denied-email

« back to all changes in this revision

Viewing changes to addons/web/static/src/js/view_form.js

  • Committer: tfr at openerp
  • Date: 2012-08-21 16:25:06 UTC
  • mfrom: (2365.6.29 6.1)
  • Revision ID: tfr@openerp.com-20120821162506-1a41st9l3cz22a8e
[MERGE] from stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1743
1743
        this.datewidget = this.build_widget();
1744
1744
        this.datewidget.on_change.add_last(this.on_ui_change);
1745
1745
        this.datewidget.appendTo(this.$element);
1746
 
        this.setupFocus(this.datewidget.$input);
 
1746
 
 
1747
        var in_picker = false;
 
1748
        this.datewidget.picker('option', 'beforeShow', function () {
 
1749
            in_picker = true;
 
1750
        });
 
1751
        this.datewidget.picker('option', 'onClose', function () {
 
1752
            in_picker = false;
 
1753
        });
 
1754
        this.datewidget.$input.bind({
 
1755
            focus: function () {
 
1756
                if (!in_picker) {
 
1757
                    $(self).trigger('widget-focus');
 
1758
                }
 
1759
            },
 
1760
            blur: function () {
 
1761
                if (!in_picker) {
 
1762
                    $(self).trigger('widget-blur');
 
1763
                }
 
1764
            }
 
1765
        });
1747
1766
    },
1748
1767
    set_value: function(value) {
1749
1768
        this._super(value);
2114
2133
                }
2115
2134
            }
2116
2135
        };
2117
 
        this.$input.focusout(anyoneLoosesFocus);
 
2136
        var $self = $(self), ignore_blur = false;
 
2137
        this.$input.bind({
 
2138
            focusout: anyoneLoosesFocus,
 
2139
            focus: function () { $self.trigger('widget-focus'); },
 
2140
            autocompleteopen: function () { ignore_blur = true; },
 
2141
            autocompleteclose: function () { ignore_blur = false; },
 
2142
            blur: function () {
 
2143
                // autocomplete open
 
2144
                if (ignore_blur) { return; }
 
2145
                var child_popup_open = _(self.widget_children).any(function (child) {
 
2146
                    return child instanceof openerp.web.form.SelectCreatePopup
 
2147
                        || child instanceof openerp.web.form.FormOpenPopup;
 
2148
                });
 
2149
                if (child_popup_open) {
 
2150
                    return;
 
2151
                }
 
2152
                $self.trigger('widget-blur');
 
2153
            },
 
2154
        });
2118
2155
 
2119
 
        var isSelecting = false;
2120
2156
        // autocomplete
2121
2157
        this.$input.autocomplete({
2122
2158
            source: function(req, resp) { self.get_search_result(req, resp); },
2123
2159
            select: function(event, ui) {
2124
 
                isSelecting = true;
2125
2160
                var item = ui.item;
2126
2161
                if (item.id) {
2127
2162
                    self._change_int_value([item.id, item.name]);
2143
2178
        // used to correct a bug when selecting an element by pushing 'enter' in an editable list
2144
2179
        this.$input.keyup(function(e) {
2145
2180
            if (e.which === 13) {
2146
 
                if (isSelecting)
 
2181
                if (ignore_blur) {
2147
2182
                    e.stopPropagation();
 
2183
                }
2148
2184
            }
2149
 
            isSelecting = false;
2150
2185
        });
2151
2186
 
2152
2187
        this.setupFocus(this.$menu_btn);
2153
 
        this.$input.bind({
2154
 
            focus: function () {
2155
 
                $(self).trigger('widget-focus')
2156
 
            },
2157
 
            blur: function () {
2158
 
                if (!isSelecting) {
2159
 
                    $(self).trigger('widget-blur');
2160
 
                }
2161
 
                isSelecting = false;
2162
 
            }
2163
 
        })
2164
2188
    },
2165
2189
    // autocomplete component content handling
2166
2190
    get_search_result: function(request, response) {
2279
2303
        if (back_orig_value === undefined) { // first use after a set_value()
2280
2304
            return;
2281
2305
        }
2282
 
        if (this.value != undefined && ((back_orig_value ? back_orig_value[0] : null)
 
2306
        if (this.value !== undefined && ((back_orig_value ? back_orig_value[0] : null)
2283
2307
                !== (this.value ? this.value[0] : null))) {
2284
2308
            this.on_ui_change();
2285
2309
        }