1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
odoo.define('wysiwyg.widgets.AltDialog', function (require) {
'use strict';
var core = require('web.core');
var Dialog = require('wysiwyg.widgets.Dialog');
var _t = core._t;
/**
* Let users change the alt & title of a media.
*/
var AltDialog = Dialog.extend({
template: 'wysiwyg.widgets.alt',
xmlDependencies: Dialog.prototype.xmlDependencies.concat(
['/web_editor/static/src/xml/wysiwyg.xml']
),
/**
* @constructor
*/
init: function (parent, options, media) {
options = options || {};
this._super(parent, _.extend({}, {
title: _t("Change media description and tooltip")
}, options));
this.trigger_up('getRecordInfo', {
recordInfo: options,
callback: function (recordInfo) {
_.defaults(options, recordInfo);
},
});
this.media = media;
var allEscQuots = /"/g;
this.alt = ($(this.media).attr('alt') || "").replace(allEscQuots, '"');
var title = $(this.media).attr('title') || $(this.media).data('original-title') || "";
this.tag_title = (title).replace(allEscQuots, '"');
},
//--------------------------------------------------------------------------
// Public
//--------------------------------------------------------------------------
/**
* @override
*/
save: function () {
var alt = this.$('#alt').val();
var title = this.$('#title').val();
var allNonEscQuots = /"/g;
$(this.media).attr('alt', alt ? alt.replace(allNonEscQuots, """) : null)
.attr('title', title ? title.replace(allNonEscQuots, """) : null);
$(this.media).trigger('content_changed');
this.final_data = this.media;
return this._super.apply(this, arguments);
},
});
return AltDialog;
});
|