diff options
Diffstat (limited to 'addons/website/static/src/js/website.ace.js')
| -rw-r--r-- | addons/website/static/src/js/website.ace.js | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/addons/website/static/src/js/website.ace.js b/addons/website/static/src/js/website.ace.js deleted file mode 100644 index 2ce486fc1c8..00000000000 --- a/addons/website/static/src/js/website.ace.js +++ /dev/null @@ -1,96 +0,0 @@ -odoo.define('website.ace', function (require) { -'use strict'; - -var Widget = require('web.Widget'); -var website = require('website.website'); -var mixins = require('web.mixins'); - -var ViewEditor = require('web_editor.ace'); - -var hash = "#advanced-view-editor"; - -var Ace = Widget.extend(mixins.ServiceProvider, { - events: { - "click a[data-action=ace]": function (e) { - e.preventDefault(); - this.launchAce(); - }, - }, - init: function () { - mixins.ServiceProvider.init.apply(this, arguments); - this._super.apply(this, arguments); - }, - start: function () { - if (window.location.hash.substr(0, hash.length) === hash) { - this.launchAce(); - } - return this._super.apply(this, arguments); - }, - launchAce: function () { - if (this.globalEditor) { - this.globalEditor.do_show(); - } else { - var currentHash = window.location.hash; - var indexOfView = currentHash.indexOf("?res="); - var initialResID = undefined; - if (indexOfView >= 0) { - initialResID = currentHash.substr(indexOfView + ("?res=".length)); - var parsedResID = parseInt(initialResID, 10); - if (parsedResID) { - initialResID = parsedResID; - } - } - - this.globalEditor = new ViewEditor(this, $(document.documentElement).data('view-xmlid'), { - initialResID: initialResID, - defaultBundlesRestriction: [ - "web.assets_frontend", - "website.assets_frontend", - ], - }); - this.globalEditor.appendTo(document.body); - - $("a[data-action=edit]").on("click", this.globalEditor.do_hide.bind(this.globalEditor)); - } - }, -}); - -/** - * Extend the default view editor so that the URL hash is updated with view id. - */ -ViewEditor = ViewEditor.extend({ - displayResource: function () { - this._super.apply(this, arguments); - this._updateHash(); - }, - saveResources: function () { - return this._super.apply(this, arguments).then((function () { - this._updateHash(); - window.location.reload(); - }).bind(this)); - }, - resetResource: function () { - return this._super.apply(this, arguments).then((function () { - window.location.reload(); - }).bind(this)); - }, - do_hide: function () { - this._super.apply(this, arguments); - window.location.hash = ""; - }, - _updateHash: function () { - window.location.hash = hash + "?res=" + this.selectedResource(); - }, -}); - -website.TopBar.include({ - start: function () { - this.ace = new Ace(); - return $.when( - this._super.apply(this, arguments), - this.ace.attachTo(this.$('#html_editor')) - ); - }, -}); - -}); |
