[MERGE] forward port of branch 7.0 up to e5533d0
[odoo/odoo.git] / addons / web / static / src / js / view_list_editable.js
index 7d2e442..ea2c28d 100644 (file)
@@ -2,7 +2,10 @@
  * handles editability case for lists, because it depends on form and forms already depends on lists it had to be split out
  * @namespace
  */
-openerp.web.list_editable = function (instance) {
+(function() {
+
+    var instance = openerp;
+    openerp.web.list_editable = {};
     var _t = instance.web._t;
 
     // editability status of list rows
@@ -205,7 +208,7 @@ openerp.web.list_editable = function (instance) {
         make_empty_record: function (id) {
             var attrs = {id: id};
             _(this.columns).chain()
-                .filter(function (x) { return x.tag === 'field'})
+                .filter(function (x) { return x.tag === 'field';})
                 .pluck('name')
                 .each(function (field) { attrs[field] = false; });
             return new instance.web.list.Record(attrs);
@@ -270,7 +273,7 @@ openerp.web.list_editable = function (instance) {
         get_cells_for: function ($row) {
             var cells = {};
             $row.children('td').each(function (index, el) {
-                cells[el.getAttribute('data-field')] = el
+                cells[el.getAttribute('data-field')] = el;
             });
             return cells;
         },
@@ -356,7 +359,7 @@ openerp.web.list_editable = function (instance) {
                         var record = self.records.get(attrs.id);
                         if (!record) {
                             // Record removed by third party during edition
-                            return
+                            return;
                         }
                         return self.reload_record(record);
                     }
@@ -532,10 +535,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;
@@ -712,9 +711,9 @@ openerp.web.list_editable = function (instance) {
             var arch = edition_view.arch;
             if (!(arch && arch.children instanceof Array)) {
                 throw new Error("Editor delegate's #edition_view must have a" +
-                                " non-empty arch")
+                                " 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");
             }
@@ -829,4 +828,4 @@ openerp.web.list_editable = function (instance) {
             return null;
         }
     });
-};
+})();