Added Gruntfile with jshint and corrected most js errors

bzr revid: nicolas.vanhoren@openerp.com-20130725100749-0i82gf3k3nvt4r44
This commit is contained in:
niv-openerp 2013-07-25 12:07:49 +02:00
parent b105770bbc
commit 42e493e73e
15 changed files with 164 additions and 108 deletions

View File

@ -1,21 +1,15 @@
.*.swp
.bzrignore
.idea
.project
.pydevproject
.ropeproject
.settings
.DS_Store
openerp/addons/*
openerp/filestore*
.Python
*.pyc
*.pyo
bin/*
.*
*.egg-info
*.orig
*.vim
build/
include/
lib/
share/
doc/_build/*
win32/*.bat
win32/meta.py
RE:^bin/
RE:^dist/
RE:^include/
RE:^share/
RE:^man/
RE:^lib/
RE:^addons/\w+/doc/_build/
RE:^.*?/node_modules

22
addons/web/Gruntfile.js Normal file
View File

@ -0,0 +1,22 @@
module.exports = function(grunt) {
grunt.initConfig({
jshint: {
files: ['static/src/**/*.js'],
options: {
sub: true, //[] instead of .
asi: true, //semicolons
evil: true, //eval
laxbreak: true, //unsafe line breaks
loopfunc: true, // functions in loops
},
}
});
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.registerTask('test', ['jshint']);
grunt.registerTask('default', ['jshint']);
};

6
addons/web/package.json Normal file
View File

@ -0,0 +1,6 @@
{
"devDependencies": {
"grunt": "~0.4.1",
"grunt-contrib-jshint": "~0.6.0"
}
}

View File

@ -1108,7 +1108,7 @@ instance.web.Menu = instance.web.Widget.extend({
add_menu_ids(menu);
});
}
};
}
add_menu_ids(menu);
self.do_load_needaction(menu_ids).then(function () {
self.trigger("need_action_reloaded");

View File

@ -73,7 +73,7 @@ openerp.web.corelib = function(instance) {
*/
(function() {
var initializing = false,
fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
fnTest = /xyz/.test(function(){xyz();}) ? /\b_super\b/ : /.*/;
// The web Class implementation (does nothing)
instance.web.Class = function(){};
@ -123,7 +123,6 @@ openerp.web.corelib = function(instance) {
function Class() {
if(this.constructor !== instance.web.Class){
throw new Error("You can only instanciate objects with the 'new' operator");
return null;
}
// All construction is actually done in the init method
if (!initializing && this.init) {
@ -297,7 +296,7 @@ var Events = instance.web.Class.extend({
var ev;
events = events.split(/\s+/);
var calls = this._callbacks || (this._callbacks = {});
while (ev = events.shift()) {
while ((ev = events.shift())) {
var list = calls[ev] || (calls[ev] = {});
var tail = list.tail || (list.tail = list.next = {});
tail.callback = callback;
@ -311,9 +310,9 @@ var Events = instance.web.Class.extend({
var ev, calls, node;
if (!events) {
delete this._callbacks;
} else if (calls = this._callbacks) {
} else if ((calls = this._callbacks)) {
events = events.split(/\s+/);
while (ev = events.shift()) {
while ((ev = events.shift())) {
node = calls[ev];
delete calls[ev];
if (!callback || !node)
@ -347,7 +346,7 @@ var Events = instance.web.Class.extend({
all = calls['all'];
(events = events.split(/\s+/)).push(null);
// Save references to the current heads & tails.
while (event = events.shift()) {
while ((event = events.shift())) {
if (all)
events.push({
next : all.next,
@ -362,7 +361,7 @@ var Events = instance.web.Class.extend({
});
}
rest = Array.prototype.slice.call(arguments, 1);
while (node = events.pop()) {
while ((node = events.pop())) {
tail = node.tail;
args = node.event ? [ node.event ].concat(rest) : rest;
while ((node = node.next) !== tail) {
@ -692,11 +691,6 @@ instance.web.Widget = instance.web.Controller.extend({
insertion(target);
return this.start();
},
/**
* This is the method to implement to render the Widget.
*/
renderElement: function() {
},
/**
* Method called after rendering. Mostly used to bind actions, perform asynchronous
* calls, etc...
@ -966,7 +960,7 @@ instance.web.JsonRPC = instance.web.Class.extend(instance.web.PropertiesMixin, {
init: function() {
instance.web.PropertiesMixin.init.call(this);
this.server = null;
this.debug = ($.deparam($.param.querystring()).debug != undefined);
this.debug = ($.deparam($.param.querystring()).debug !== undefined);
this.override_session = false;
this.session_id = undefined;
},

View File

@ -250,7 +250,7 @@ instance.web.Session = instance.web.JsonRPC.extend( /** @lends instance.web.Sess
continue;
instance[mod] = {};
// init module mod
if(instance._openerp[mod] != undefined) {
if(instance._openerp[mod] !== undefined) {
instance._openerp[mod](instance,instance[mod]);
this.module_loaded[mod] = true;
}
@ -585,7 +585,7 @@ instance.web.qweb.preprocess_node = function() {
case Node.ELEMENT_NODE:
// Element
var attr, attrs = ['label', 'title', 'alt', 'placeholder'];
while (attr = attrs.pop()) {
while ((attr = attrs.pop())) {
if (this.attributes[attr]) {
this.attributes[attr] = instance.web._t(this.attributes[attr]);
}

View File

@ -100,7 +100,7 @@ instance.web.Query = instance.web.Class.extend({
* @returns {jQuery.Deferred<Number>}
*/
count: function () {
if (this._count != undefined) { return $.when(this._count); }
if (this._count !== undefined) { return $.when(this._count); }
return this._model.call(
'search_count', [this._filter], {
context: this._model.context(this._context)});
@ -747,7 +747,7 @@ instance.web.DataSetSearch = instance.web.DataSet.extend({
});
},
size: function () {
if (this._length != null) {
if (this._length !== null) {
return this._length;
}
return this._super();

View File

@ -93,7 +93,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
self.$el.find('#fields_list option').remove();
var export_id = self.$el.find('#saved_export_list option:selected').val();
if (export_id) {
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id)}).done(self.do_load_export_field);
self.rpc('/web/export/namelist', {'model': self.dataset.model, export_id: parseInt(export_id, 10)}).done(self.do_load_export_field);
}
});
self.$el.find('#delete_export_list').click(function() {
@ -215,7 +215,7 @@ instance.web.DataExport = instance.web.Dialog.extend({
self.$el.find("tr[id='treerow-" + record.id + "']").click(function(e) {
if (e.shiftKey) {
var frst_click, scnd_click = '';
if (self.row_index == 0) {
if (self.row_index === 0) {
self.row_index = this.rowIndex;
frst_click = self.$el.find("tr[id^='treerow-']")[self.row_index-1];
$(frst_click).addClass("ui-selected");

View File

@ -141,6 +141,7 @@ instance.web.format_value = function (value, descriptor, value_if_empty) {
return '';
}
console.warn('Field', descriptor, 'had an empty string as value, treating as false...');
return value_if_empty === undefined ? '' : value_if_empty;
case false:
case Infinity:
case -Infinity:
@ -219,9 +220,9 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
case "":
return value_if_empty === undefined ? false : value_if_empty;
}
var tmp;
switch (descriptor.widget || descriptor.type || (descriptor.field && descriptor.field.type)) {
case 'integer':
var tmp;
do {
tmp = value;
value = value.replace(instance.web._t.database.parameters.thousands_sep, "");
@ -231,7 +232,7 @@ instance.web.parse_value = function (value, descriptor, value_if_empty) {
throw new Error(_.str.sprintf(_t("'%s' is not a correct integer"), value));
return tmp;
case 'float':
var tmp = Number(value);
tmp = Number(value);
if (!isNaN(tmp))
return tmp;
@ -314,4 +315,34 @@ instance.web.auto_date_to_str = function(value, type) {
}
};
/**
* performs a half up rounding with arbitrary precision, correcting for float loss of precision
* See the corresponding float_round() in server/tools/float_utils.py for more info
* @param {Number} the value to be rounded
* @param {Number} a non zero precision parameter. eg: 0.01 rounds to two digits.
*/
instance.web.round_precision = function(value, precision){
if(!value){
return 0;
}else if(!precision){
throw new Error('round_precision(...): Cannot round value: '+value+' with a precision of zero (or undefined)');
}
var normalized_value = value / precision;
var epsilon_magnitude = Math.log(Math.abs(normalized_value))/Math.log(2);
var epsilon = Math.pow(2, epsilon_magnitude - 53);
normalized_value += normalized_value >= 0 ? epsilon : -epsilon;
var rounded_value = Math.round(normalized_value);
return rounded_value * precision;
};
/**
* performs a half up rounding with a fixed amount of decimals, correcting for float loss of precision
* See the corresponding float_round() in server/tools/float_utils.py for more info
* @param {Number} the value to be rounded
* @param {Number} the number of decimals. eg: round_decimals(3.141592,2) -> 3.14
*/
instance.web.round_decimals = function(value, decimals){
return instance.web.round_precision(value, Math.pow(10,-decimals));
};
};

View File

@ -795,11 +795,18 @@ openerp.web.pyeval = function (instance) {
//noinspection FallthroughInSwitchStatementJS
switch(type) {
case 'context': object = [object];
case 'contexts': return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context);
case 'domain': object = [object];
case 'domains': return eval_domains(object, context);
case 'groupbys': return eval_groupbys(object, context);
case 'context':
case 'contexts':
if (type === 'context')
object = [object];
return eval_contexts((options.no_user_context ? [] : [instance.session.user_context]).concat(object), context);
case 'domain':
case 'domains':
if (type === 'domain')
object = [object];
return eval_domains(object, context);
case 'groupbys':
return eval_groupbys(object, context);
}
throw new Error("Unknow evaluation type " + type)
};

View File

@ -65,7 +65,7 @@ my.SearchQuery = B.Collection.extend({
}, this);
},
add: function (values, options) {
options || (options = {});
options = options || {};
if (!(values instanceof Array)) {
values = [values];
}
@ -85,7 +85,7 @@ my.SearchQuery = B.Collection.extend({
return this;
},
toggle: function (value, options) {
options || (options = {});
options = options || {};
var facet = this.detect(function (facet) {
return facet.get('category') === value.category
@ -1107,7 +1107,7 @@ instance.web.search.FilterGroup = instance.web.search.Input.extend(/** @lends in
if (!contexts.length) { return; }
if (contexts.length === 1) { return contexts[0]; }
return _.extend(new instance.web.CompoundContext, {
return _.extend(new instance.web.CompoundContext(), {
__contexts: contexts
});
},
@ -1276,7 +1276,7 @@ instance.web.search.Field = instance.web.search.Input.extend( /** @lends instanc
if (contexts.length === 1) { return contexts[0]; }
return _.extend(new instance.web.CompoundContext, {
return _.extend(new instance.web.CompoundContext(), {
__contexts: contexts
});
},
@ -1321,7 +1321,7 @@ instance.web.search.Field = instance.web.search.Input.extend( /** @lends instanc
domains.unshift(['|']);
}
return _.extend(new instance.web.CompoundDomain, {
return _.extend(new instance.web.CompoundDomain(), {
__domains: domains
});
}
@ -1919,7 +1919,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
},
changed: function() {
var nval = this.$(".searchview_extended_prop_field").val();
if(this.attrs.selected == null || nval != this.attrs.selected.name) {
if(this.attrs.selected === null || this.attrs.selected === undefined || nval != this.attrs.selected.name) {
this.select_field(_.detect(this.fields, function(x) {return x.name == nval;}));
}
},
@ -1941,13 +1941,13 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
*/
select_field: function(field) {
var self = this;
if(this.attrs.selected != null) {
if(this.attrs.selected !== null && this.attrs.selected !== undefined) {
this.value.destroy();
this.value = null;
this.$('.searchview_extended_prop_op').html('');
}
this.attrs.selected = field;
if(field == null) {
if(field === null || field === undefined) {
return;
}
@ -1967,7 +1967,7 @@ instance.web.search.ExtendedSearchProposition = instance.web.Widget.extend(/** @
},
get_proposition: function() {
if ( this.attrs.selected == null)
if (this.attrs.selected === null || this.attrs.selected === undefined)
return null;
var field = this.attrs.selected;
var op_select = this.$('.searchview_extended_prop_op')[0];
@ -2097,7 +2097,7 @@ instance.web.search.ExtendedSearchProposition.Integer = instance.web.search.Exte
get_value: function() {
try {
var val =this.$el.val();
return instance.web.parse_value(val == "" ? 0 : val, {'widget': 'integer'});
return instance.web.parse_value(val === "" ? 0 : val, {'widget': 'integer'});
} catch (e) {
return "";
}
@ -2124,7 +2124,7 @@ instance.web.search.ExtendedSearchProposition.Float = instance.web.search.Extend
get_value: function() {
try {
var val =this.$el.val();
return instance.web.parse_value(val == "" ? 0.0 : val, {'widget': 'float'});
return instance.web.parse_value(val === "" ? 0.0 : val, {'widget': 'float'});
} catch (e) {
return "";
}

View File

@ -346,7 +346,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
self.on_form_changed();
self.rendering_engine.init_fields();
self.is_initialized.resolve();
self.do_update_pager(record.id == null);
self.do_update_pager(record.id === null || record.id === undefined);
if (self.sidebar) {
self.sidebar.do_attachement_update(self.dataset, self.datarecord.id);
}
@ -465,7 +465,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
// form field
if (self.fields[field]) {
var value_ = self.fields[field].get_value();
return value_ == null ? false : value_;
return value_ === null || value_ === undefined ? false : value_;
}
// parent field
var splitted = field.split('.');
@ -475,7 +475,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}
var p_val = parent_fields[_.str.trim(splitted[1])];
if (p_val !== undefined) {
return p_val == null ? false : p_val;
return p_val === null || p_val === undefined ? false : p_val;
}
}
// string literal
@ -621,7 +621,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
}
return $.when();
});
};
}
return iterate();
});
},
@ -943,11 +943,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM
reload: function() {
var self = this;
return this.reload_mutex.exec(function() {
if (self.dataset.index == null) {
if (self.dataset.index === null || self.dataset.index === undefined) {
self.trigger("previous_view");
return $.Deferred().reject().promise();
}
if (self.dataset.index == null || self.dataset.index < 0) {
if (self.dataset.index < 0) {
return $.when(self.on_button_new());
} else {
var fields = _.keys(self.fields_view.fields);
@ -1714,7 +1714,7 @@ instance.web.form.compute_domain = function(expr, fields) {
};
instance.web.form.is_bin_size = function(v) {
return /^\d+(\.\d*)? \w+$/.test(v);
return (/^\d+(\.\d*)? \w+$/).test(v);
};
/**
@ -2642,7 +2642,7 @@ instance.web.form.FieldText = instance.web.form.AbstractField.extend(instance.we
if (! this.get("effective_readonly")) {
var show_value = instance.web.format_value(this.get('value'), this, '');
if (show_value === '') {
this.$textarea.css('height', parseInt(this.default_height)+"px");
this.$textarea.css('height', parseInt(this.default_height, 10)+"px");
}
this.$textarea.val(show_value);
if (! this.auto_sized) {
@ -3740,7 +3740,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
},
reload_current_view: function() {
var self = this;
return self.is_loaded = self.is_loaded.then(function() {
self.is_loaded = self.is_loaded.then(function() {
var active_view = self.viewmanager.active_view;
var view = self.viewmanager.views[active_view].controller;
if(active_view === "list") {
@ -3758,13 +3758,15 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
return view.do_search(self.build_domain(), self.dataset.get_context(), []);
}
}, undefined);
return self.is_loaded;
},
set_value: function(value_) {
value_ = value_ || [];
var self = this;
this.dataset.reset_ids([]);
var ids;
if(value_.length >= 1 && value_[0] instanceof Array) {
var ids = [];
ids = [];
_.each(value_, function(command) {
var obj = {values: command[2]};
switch (command[0]) {
@ -3795,7 +3797,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
this._super(ids);
this.dataset.set_ids(ids);
} else if (value_.length >= 1 && typeof(value_[0]) === "object") {
var ids = [];
ids = [];
this.dataset.delete_all = true;
_.each(value_, function(command) {
var obj = {values: command};
@ -3850,7 +3852,7 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
this.viewmanager.views[this.viewmanager.active_view].controller) {
var view = this.viewmanager.views[this.viewmanager.active_view].controller;
if (this.viewmanager.active_view === "form") {
if (!view.is_initialized.state() === 'resolved') {
if (view.is_initialized.state() !== 'resolved') {
return $.when(false);
}
return $.when(view.save());
@ -3870,7 +3872,6 @@ instance.web.form.FieldOne2Many = instance.web.form.AbstractField.extend({
.invoke('is_valid')
.all(_.identity)
.value();
break;
case 'list':
return view.is_valid();
}
@ -4256,7 +4257,7 @@ instance.web.form.FieldMany2ManyTags = instance.web.form.AbstractField.extend(in
},
core: {
onSetInputData: function(e, data) {
if (data == '') {
if (data === '') {
this._plugins.autocomplete._suggestions = null;
}
this.input().val(data);
@ -4578,8 +4579,9 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
if (type !== "form")
return;
var self = this;
var pop;
if (this.dataset.index === null) {
var pop = new instance.web.form.SelectCreatePopup(this);
pop = new instance.web.form.SelectCreatePopup(this);
pop.select_element(
this.field.relation,
{
@ -4599,7 +4601,7 @@ instance.web.form.FieldMany2ManyKanban = instance.web.form.AbstractField.extend(
});
} else {
var id = self.dataset.ids[self.dataset.index];
var pop = new instance.web.form.FormOpenPopup(this);
pop = new instance.web.form.FormOpenPopup(this);
pop.show_element(self.field.relation, id, self.build_context(), {
title: _t("Open: ") + self.string,
write_function: function(id, data, options) {
@ -4935,7 +4937,7 @@ instance.web.form.SelectCreatePopup = instance.web.form.AbstractFormPopup.extend
self.select_elements(self.selected_ids);
self.destroy();
});
var $cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create");
$cbutton = self.$buttonpane.find(".oe_selectcreatepopup-search-create");
$cbutton.click(function() {
self.new_object();
});
@ -5190,18 +5192,18 @@ instance.web.form.FieldBinaryFile = instance.web.form.FieldBinary.extend({
}
},
render_value: function() {
if (!this.get("effective_readonly")) {
var show_value;
if (!this.get("effective_readonly")) {
if (this.node.attrs.filename) {
show_value = this.view.datarecord[this.node.attrs.filename] || '';
} else {
show_value = (this.get('value') != null && this.get('value') !== false) ? this.get('value') : '';
show_value = (this.get('value') !== null && this.get('value') !== undefined && this.get('value') !== false) ? this.get('value') : '';
}
this.$el.find('input').eq(0).val(show_value);
} else {
this.$el.find('a').toggle(!!this.get('value'));
if (this.get('value')) {
var show_value = _t("Download")
show_value = _t("Download")
if (this.view)
show_value += " " + (this.view.datarecord[this.node.attrs.filename] || '');
this.$el.find('a').text(show_value);
@ -5553,11 +5555,12 @@ instance.web.form.FieldStatus = instance.web.form.AbstractField.extend({
on_click_stage: function (ev) {
var self = this;
var $li = $(ev.currentTarget);
var val;
if (this.field.type == "many2one") {
var val = parseInt($li.data("id"));
val = parseInt($li.data("id"), 10);
}
else {
var val = $li.data("id");
val = $li.data("id");
}
if (val != self.get('value')) {
this.view.recursive_save().done(function() {

View File

@ -171,11 +171,13 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
current_date: new Date().toString('yyyy-MM-dd')
// TODO: time, datetime, relativedelta
});
var i;
var pair;
var expression;
if (this.fonts) {
for(var i=0, len=this.fonts.length; i<len; ++i) {
var pair = this.fonts[i],
font = pair[0],
for(i=0, len=this.fonts.length; i<len; ++i) {
pair = this.fonts[i];
var font = pair[0];
expression = pair[1];
if (py.evaluate(expression, context).toJSON()) {
switch(font) {
@ -194,9 +196,9 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
}
if (!this.colors) { return style; }
for(var i=0, len=this.colors.length; i<len; ++i) {
var pair = this.colors[i],
color = pair[0],
for(i=0, len=this.colors.length; i<len; ++i) {
pair = this.colors[i];
var color = pair[0];
expression = pair[1];
if (py.evaluate(expression, context).toJSON()) {
return style += 'color: ' + color + ';';
@ -394,7 +396,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
var total = dataset.size();
var limit = this.limit() || total;
if (total == 0)
if (total === 0)
this.$pager.hide();
else
this.$pager.css("display", "");
@ -454,7 +456,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
* @param {String} [view="page"] the view type to switch to
*/
select_record:function (index, view) {
view = view || index == null ? 'form' : 'form';
view = view || index === null || index === undefined ? 'form' : 'form';
this.dataset.index = index;
_.delay(_.bind(function () {
this.do_switch_view(view);
@ -503,7 +505,7 @@ instance.web.ListView = instance.web.View.extend( /** @lends instance.web.ListVi
var reloaded = $.Deferred();
this.$el.find('.oe_list_content').append(
this.groups.render(function () {
if (self.dataset.index == null && self.records.length ||
if ((self.dataset.index === null || self.dataset.index === undefined) && self.records.length ||
self.dataset.index >= self.records.length) {
self.dataset.index = 0;
}
@ -1517,7 +1519,7 @@ instance.web.ListView.Groups = instance.web.Class.extend( /** @lends instance.we
// if drag to 1st row (to = 0), start sequencing from 0
// (exclusive lower bound)
seq = to ? list.records.at(to - 1).get(seqname) : 0;
while (++seq, record = list.records.at(index++)) {
while (++seq, (record = list.records.at(index++))) {
// write are independent from one another, so we can just
// launch them all at the same time and we don't really
// give a fig about when they're done
@ -1825,7 +1827,7 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{
var instance_ = (records[i] instanceof Record) ? records[i] : new Record(records[i]);
instance_.bind(null, this._onRecordEvent);
this._byId[instance_.get('id')] = instance_;
if (options.at == undefined) {
if (options.at === undefined || options.at === null) {
this.records.push(instance_);
if (!options.silent) {
this.trigger('add', this, instance_, this.records.length-1);
@ -1867,7 +1869,8 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{
if (!_(this._proxies).isEmpty()) {
var record = null;
_(this._proxies).detect(function (proxy) {
return record = proxy.get(id);
record = proxy.get(id);
return record;
});
return record;
}
@ -1881,10 +1884,11 @@ var Collection = instance.web.Class.extend(/** @lends Collection# */{
* @returns {Collection}
*/
proxy: function (section) {
return this._proxies[section] = new Collection(null, {
this._proxies[section] = new Collection(null, {
parent: this,
key: section
}).bind(null, this._onRecordEvent);
return this._proxies[section];
},
/**
* @param {Array} [records]

View File

@ -515,10 +515,6 @@ openerp.web.list_editable = function (instance) {
};
} else if (document.body.createTextRange) {
throw new Error("Implement text range handling for MSIE");
var sel = document.body.createTextRange();
if (sel.parentElement() === el) {
}
}
// Element without selection ranges (select, div/@contenteditable)
return null;
@ -697,7 +693,7 @@ openerp.web.list_editable = function (instance) {
throw new Error("Editor delegate's #edition_view must have a" +
" non-empty arch")
}
if (!(arch.tag === "form")) {
if (arch.tag !== "form") {
throw new Error("Editor delegate's #edition_view must have a" +
" 'form' root node");
}

View File

@ -49,7 +49,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
if (last) {
last.hide();
}
var item = _.extend({
item = _.extend({
show: function(index) {
this.widget.$el.show();
},
@ -423,7 +423,7 @@ instance.web.ActionManager = instance.web.Widget.extend({
if (!(ClientWidget.prototype instanceof instance.web.Widget)) {
var next;
if (next = ClientWidget(this, action)) {
if ((next = ClientWidget(this, action))) {
return this.do_action(next, options);
}
return $.when();
@ -677,7 +677,7 @@ instance.web.ViewManager = instance.web.Widget.extend({
this.$el.find('.oe_view_title_text:first').text(title);
},
add_breadcrumb: function(options) {
var options = options || {};
options = options || {};
var self = this;
var views = [this.active_view || this.views_src[0].view_type];
this.on('switch_mode', self, function(mode) {
@ -958,7 +958,6 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
view_type : 'list',
view_mode : 'list'
});
break;
case 'edit':
this.do_edit_resource($option.data('model'), $option.data('id'), { name : $option.text() });
break;
@ -1000,7 +999,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
evt.currentTarget.selectedIndex = 0;
},
do_edit_resource: function(model, id, action) {
var action = _.extend({
action = _.extend({
res_model : model,
res_id : id,
type : 'ir.actions.act_window',
@ -1038,7 +1037,7 @@ instance.web.ViewManagerAction = instance.web.ViewManager.extend({
},
get_action_manager: function() {
var cur = this;
while (cur = cur.getParent()) {
while ((cur = cur.getParent())) {
if (cur instanceof instance.web.ActionManager) {
return cur;
}
@ -1176,7 +1175,7 @@ instance.web.Sidebar = instance.web.Widget.extend({
var self = this;
self.getParent().sidebar_eval_context().done(function (sidebar_eval_context) {
var ids = self.getParent().get_selected_ids();
if (ids.length == 0) {
if (ids.length === 0) {
instance.web.dialog($("<div />").text(_t("You must choose at least one record.")), { title: _t("Warning"), modal: true });
return false;
}