* @returns {jQuery}
*/
make_hover_button_image: function (editfn, stylefn) {
- var $div = $(openerp.qweb.render('website.editor.hoverbutton.image', {}))
+ var $div = $(openerp.qweb.render('website.editor.hoverbutton.media', {}))
.hide()
.appendTo(document.body);
});
website.editor.Media = openerp.Widget.extend({
- init: function (editor, media) {
+ init: function (parent, editor, media) {
this._super();
+ this.parent = parent;
this.editor = editor;
this.media = media;
},
this.$preview = this.$('.preview-container').detach();
return this._super();
},
+ search: function (needle) {
+ },
save: function () {
},
cancel: function () {
});
website.editor.MediaDialog = website.editor.Dialog.extend({
template: 'website.editor.dialog.media',
+ events : _.extend({}, website.editor.Dialog.prototype.events, {
+ 'input input#icon-search': 'search',
+ }),
init: function (editor, media) {
this.media = media;
},
start: function (editor, media) {
var self = this;
- this.imageDialog = new website.editor.RTEImageDialog(this.editor, this.media);
+ this.imageDialog = new website.editor.RTEImageDialog(this, this.editor, this.media);
this.imageDialog.appendTo(this.$("#editor-media-image"));
- this.iconDialog = new website.editor.FontIconsDialog(this.editor, this.media);
+ this.iconDialog = new website.editor.FontIconsDialog(this, this.editor, this.media);
this.iconDialog.appendTo(this.$("#editor-media-icon"));
this.videoDialog = {};
//this.videoDialog.appendTo(this.$("#editor-media-video"));
return this._super();
},
save: function () {
- if (this.active) {
- this.active.save();
+ this.active.save();
+ if (this.active === this.imageDialog) {
+ this.media.$.className = this.media.$.className.replace(/(^|\s)fa[^\s]+/g, '');
+ $(this.media.$).addClass("img img-responsive");
+ }
+ if (this.active === this.iconDialog) {
+ this.media.$.className = this.media.$.className.replace(/(^|\s)img[^\s]+/g, '');
+ }
+ if (this.active === this.videoDialog) {
+ this.media.$.className = this.media.$.className.replace(/(^|\s)(img|fa)[^\s]+/g, '');
}
return this._super();
},
+ search: function () {
+ var needle = this.$("input#icon-search").val();
+ this.active.search(needle || "");
+ }
});
/**
});
website.editor.RTEImageDialog = website.editor.ImageDialog.extend({
- init: function (editor, media) {
- this._super(editor, media);
+ init: function (parent, editor, media) {
+ this._super(parent, editor, media);
this.on('start', this, this.proxy('started'));
this.on('save', this, this.proxy('saved'));
this.$('#fa-size').val(e.target.getAttribute('data-size'));
this.update_preview();
},
- 'input input#icon-search': function () {
- var needle = this.$('#icon-search').val();
- var icons = this.icons;
- if (needle) {
- icons = _(icons).filter(function (icon) {
- return icon.id.substring(3).indexOf(needle) !== -1;
- });
- }
-
- this.$('div.font-icons-icons').html(
- openerp.qweb.render(
- 'website.editor.dialog.font-icons.icons',
- {icons: icons}));
- },
}),
// List of FontAwesome icons in 4.0.3, extracted from the cheatsheet.
start: function () {
return this._super().then(this.proxy('load_data'));
},
+ search: function (needle) {
+ var icons = this.icons;
+ if (needle) {
+ icons = _(icons).filter(function (icon) {
+ return icon.id.substring(3).indexOf(needle) !== -1;
+ });
+ }
+
+ this.$('div.font-icons-icons').html(
+ openerp.qweb.render(
+ 'website.editor.dialog.font-icons.icons',
+ {icons: icons}));
+ },
/**
* Removes existing FontAwesome classes on the bound element, and sets
* all the new ones if necessary.
this.$('#fa-icon').val(cls);
}
}
- if (this.$('#fa-icon').val() === "") {
- this.$('#fa-icon').val("fa-glass");
- }
this.update_preview();
},
/**
</ul>
</li>
<li style="float: right;">
- <form>
+ <form action="#">
<div class="form-group font-icons fa fa-search mb0">
- <input type="hidden" id="fa-icon" class="form-control"/>
- <input type="hidden" id="fa-size" class="form-control"/>
<input type="search" class="form-control" id="icon-search"/>
</div>
</form>
<button contentEditable="false" type="button" class="btn btn-primary hover-edition-button btn-xs">Change</button>
</t>
- <t t-name="website.editor.hoverbutton.image">
+ <t t-name="website.editor.hoverbutton.media">
<div contentEditable="false" class="hover-edition dropdown">
<a class="btn btn-primary btn-sm" data-toggle="dropdown" href="#">Customize</a>
<ul class="dropdown-menu" role="menu" aria-labelledby="dLabel">
<li><a href="#" class="hover-edition-button">Change Media</a></li>
<li><a href="#" class="hover-style-button">Style</a></li>
+ <li class="dropdown-submenu">
+ <a href="#" tabindex="-1">Rotation</a>
+ <ul class="dropdown-menu">
+ <li data-value="fa-spin"><a>Spin</a></li>
+ <li data-value="fa-flip-horizontal"><a>Horizontal flip</a></li>
+ <li data-value="fa-flip-vertical"><a>Vertical flip</a></li>
+ </ul>
+ </li>
+ <li><a href="#" data-value="fa-border">border</a></li>
</ul>
</div>
</t>
<t t-name="website.editor.dialog.font-icons">
<form>
- <div class="form-group hidden font-icons fa fa-search">
- <input type="hidden" id="fa-icon" class="form-control"/>
- <input type="hidden" id="fa-size" class="form-control"/>
- <input type="search" class="form-control" id="icon-search"/>
- </div>
+ <input type="hidden" id="fa-icon" class="form-control"/>
+ <input type="hidden" id="fa-size" class="form-control"/>
<div class="font-icons-icons">
<t t-call="website.editor.dialog.font-icons.icons">
<t t-set="icons" t-value="widget.icons"/>
<div class="form-group mt32" id="fa-preview">
</div>
- <div class="form-group">
- <label for="fa-rotation">Rotation</label>
- <select id="fa-rotation" class="form-control">
- <option value="">None</option>
- <option value="fa-spin">Spin</option>
- <option value="fa-rotate-90">Rotate 90º</option>
- <option value="fa-rotate-180">Rotate 180º</option>
- <option value="fa-rotate-270">Rotate 270º</option>
- <option value="fa-flip-horizontal">Horizontal flip</option>
- <option value="fa-flip-vertical">Vertical flip</option>
- </select>
- </div>
- <div class="form-group">
- <label>
- <input type="checkbox" id="fa-border"/> border
- </label>
- </div>
</form>
</t>
<t t-name="website.editor.dialog.font-icons.icons">