[IMP] website snippet option: rename data-class into data-value
[odoo/odoo.git] / addons / website / static / src / js / website.editor.newpage.js
1 (function() {
2     "use strict";
3
4     var website = openerp.website;
5     var _t = openerp._t;
6     website.is_editable = true;
7     website.is_editable_button = true;
8     
9     website.EditorBar.include({
10         start: function() {
11             var res = this._super();
12             this.$("a[data-action=new_page]").parents("li").removeClass("hidden");
13             this.$(".oe_content_menu li.divider").removeClass("hidden");
14             return res;
15         },
16         edit: function () {
17             this.on('rte:ready', this, function () {
18                 $('a:has(span[data-oe-model="website.menu"])').tooltip({
19                     title: _t('Save this page and use the top "Content" menu to edit the menu.'),
20                     placement: "bottom",
21                     trigger: "hover",
22                     show: 50,
23                     hide: 100,
24                     container: 'body'
25                 });
26             });
27             return this._super();
28         },
29         events: _.extend({}, website.EditorBar.prototype.events, {
30             'click a[data-action=new_page]': function (ev) {
31                 ev.preventDefault();
32                 website.prompt({
33                     id: "editor_new_page",
34                     window_title: _t("New Page"),
35                     input: _t("Page Title"),
36                     init: function () {
37                         var $group = this.$dialog.find("div.form-group");
38                         $group.removeClass("mb0");
39
40                         var $add = $(
41                             '<div class="form-group mb0">'+
42                                 '<label class="col-sm-offset-3 col-sm-9 text-left">'+
43                                 '    <input type="checkbox" checked="checked" required="required"/> '+
44                                 '</label>'+
45                             '</div>');
46                         $add.find('label').append(_t("Add page in menu"));
47                         $group.after($add);
48                     }
49                 }).then(function (val, field, $dialog) {
50                     if (val) {
51                         var url = '/website/add/' + encodeURI(val);
52                         if ($dialog.find('input[type="checkbox"]').is(':checked')) url +="?add_menu=1";
53                         document.location = url;
54                     }
55                 });
56             }
57         }),
58     });
59 })();