diff options
| author | Fabien Meghazi <fme@openerp.com> | 2013-07-02 14:32:28 +0200 |
|---|---|---|
| committer | Fabien Meghazi <fme@openerp.com> | 2013-07-02 14:32:28 +0200 |
| commit | fec0b5e39146701558a3124efd6ffb66f5ff67bf (patch) | |
| tree | a168ce89856582cab13a6796f7dc7603c0addcf8 /addons/website/static/src/js | |
| parent | fe954304511203981e819b3265679b487a5c316e (diff) | |
[FIX] stuff
bzr revid: fme@openerp.com-20130702123228-2dzs7g9dm6gpldw3
Diffstat (limited to 'addons/website/static/src/js')
| -rw-r--r-- | addons/website/static/src/js/website.js | 43 | ||||
| -rw-r--r-- | addons/website/static/src/js/website_bootstrap.js | 12 |
2 files changed, 12 insertions, 43 deletions
diff --git a/addons/website/static/src/js/website.js b/addons/website/static/src/js/website.js index 7e8b45e1a81..73943f10171 100644 --- a/addons/website/static/src/js/website.js +++ b/addons/website/static/src/js/website.js @@ -10,43 +10,31 @@ instance.website.EditorBar = instance.web.Widget.extend({ start: function() { var self = this; var r = this._super.apply(this, arguments); - // this.$container.addClass('oe_website_editor_container'); Aloha.ready(function() { Aloha.jQuery('[data-oe-model]').aloha(); //.attr('contentEditable', 'true').addClass('oe_editable'); self.$('button').prop('disabled', true); Aloha.bind('aloha-editable-activated', function (ev, args) { - console.log(ev, args); + var $e = args.editable.obj; + if (!$e.is('.oe_dirty')) { + $e.addClass('oe_dirty'); + self.$('button').prop('disabled', false); + // TODO: Are we going to use a meta-data flag in order to know if the field shall be text or html ? + $e.data('original', $e.html()); + } }); }); - // .click(function (e) { - // e.stopPropagation(); - // e.preventDefault(); - // }); - //$('body').on("keypress.oe_webeditor", ".oe_editable", function(e) { - // var $e = $(e.currentTarget); - // if (!$e.is('.oe_dirty')) { - // $e.addClass('oe_dirty'); - // self.$('button').prop('disabled', false); - // // TODO: Are we going to use a meta-data flag in order to know if the field shall be text or html ? - // $e.data('original', $e.text()); - // } - // if (e.which == 13) { - // $e.blur(); - // e.preventDefault(); - // } - //}); return r; }, save: function () { var self = this; var defs = []; - this.$container.find('.oe_dirty').each(function () { + $('.oe_dirty').each(function () { var $el = $(this); var def = self.saveElement($el).then(function () { $el.removeClass('oe_dirty'); }).fail(function () { var data = $el.data(); - self.do_warn('Error', _.str.sprintf('Could not save %s#%d#%s', data.model, data.id, data.field)); + console.error(_.str.sprintf('Could not save %s#%d#%s', data.oeModel, data.oeId, data.oeField)); }); defs.push(def); }); @@ -56,20 +44,13 @@ instance.website.EditorBar = instance.web.Widget.extend({ }, saveElement: function ($el) { var data = $el.data(); - var update = {}; - update[data.field] = $el.text(); - return (new instance.web.DataSet(this, data.model)).write(data.id, update); + return (new instance.web.DataSet(this, 'ir.ui.view')).call('save', [data.oeModel, data.oeId, data.oeField, $el.html(), data.oeXpath]); }, cancel: function () { - this.$container.find('.oe_dirty').each(function () { - $(this).removeClass('oe_dirty').text($(this).data('original')); + $('.oe_dirty').each(function () { + $(this).removeClass('oe_dirty').html($(this).data('original')); }); this.$('button').prop('disabled', true); - }, - destroy: function () { - this._super.apply(this, arguments); - this.$container.removeClass('oe_website_editor_container'); - this.$container.find('.oe_editable').removeAttr('contentEditable'); } }); diff --git a/addons/website/static/src/js/website_bootstrap.js b/addons/website/static/src/js/website_bootstrap.js index 012c39b38b7..e70183fe767 100644 --- a/addons/website/static/src/js/website_bootstrap.js +++ b/addons/website/static/src/js/website_bootstrap.js @@ -12,18 +12,6 @@ Aloha.ready(function() { // Another hack since we have no callback when webclient has loaded modules. instance.web.qweb.add_template('/website/static/src/xml/website.xml'); - setTimeout(function () { - // HACKY HACK YUCK YUCK !! - // TODO: Need modification to webclient. Webclient shall trigger an event when it's ready. - // Maybe notification shall trigger event too, so the host can bind on it and use - // it's own means in order to trigger it's own notification !? - if (instance.web.notification) { - instance.web.notification.$el.appendTo('body'); - } else { - console.log("too late"); - } - }, 2000); - $(function() { var editor = new instance.website.EditorBar(instance.webclient); editor.prependTo($('body')); |
