[MERGE] from trunk
authorchm@openerp.com <>
Mon, 31 Mar 2014 12:16:54 +0000 (14:16 +0200)
committerchm@openerp.com <>
Mon, 31 Mar 2014 12:16:54 +0000 (14:16 +0200)
bzr revid: chm@openerp.com-20140331121654-jsdotezdyi9qwmeb

1  2 
addons/website/static/src/css/website.css
addons/website/static/src/css/website.sass
addons/website/static/src/js/website.editor.js
addons/website/views/snippets.xml
addons/website/views/website_templates.xml

              }
              this.set_image(url, error);
          },
 -        preview_image: function () {
 -            var loaded = function () {
 -                this.$el.removeClass('nosave');
 -            }.bind(this);
 -            var image = this.$('input.url').val();
 -            if (!image) { loaded(); return; }
 -
 -            var $img = this.$('img.image-preview')
 -                .attr('src', image)
 -                .removeClass(this.image_styles.join(' '))
 -                .addClass(this.$('select.image-style').val());
 -
 -            if ($img.prop('complete')) {
 -                loaded();
 -            } else {
 -                $img.load(loaded)
 -            }
 -        },
 -        browse_existing: function (e) {
 -            e.preventDefault();
 -            this.$('form').removeClass('has-error').find('.help-block').empty();
 -            this.$('button.filepicker').removeClass('btn-danger btn-success');
 -            new website.editor.ExistingImageDialog(this).appendTo(document.body);
 -        },
 -    });
 -    website.editor.RTEImageDialog = website.editor.ImageDialog.extend({
 -        init: function (editor, image) {
 -            this._super(editor);
 -
 -            this.element = image;
 -
 -            this.on('start', this, this.proxy('started'));
 -            this.on('save', this, this.proxy('saved'));
 -        },
 -        started: function (holder) {
 -            if (!this.element) {
 -                var selection = this.editor.getSelection();
 -                this.element = selection && selection.getSelectedElement();
 -            }
  
 -            var el = this.element;
 -            if (!el || !el.is('img')) {
 -                return;
 -            }
 -            _(this.image_styles).each(function (style) {
 -                if (el.hasClass(style)) {
 -                    holder.style = style;
 -                }
 -            });
 -            holder.url = el.getAttribute('src');
 -        },
 -        saved: function (data) {
 -            var element, editor = this.editor;
 -            if (!(element = this.element)) {
 -                element = editor.document.createElement('img');
 -                element.addClass('img');
 -                element.addClass('img-responsive');
 -                // focus event handler interactions between bootstrap (modal)
 -                // and ckeditor (RTE) lead to blowing the stack in Safari and
 -                // Chrome (but not FF) when this is done synchronously =>
 -                // defer insertion so modal has been hidden & destroyed before
 -                // it happens
 -                setTimeout(function () {
 -                    editor.insertElement(element);
 -                }, 0);
 +        fetch_existing: function (needle) {
-             var domain = [['res_model', '=', 'ir.ui.view']];
++            var domain = [['res_model', '=', 'ir.ui.view'], '|',
++                        ['mimetype', '=', false], ['mimetype', '=like', 'image/%']];
 +            if (needle && needle.length) {
 +                domain.push('|', ['datas_fname', 'ilike', needle], ['name', 'ilike', needle]);
              }
 -
 -            var style = data.style;
 -            element.setAttribute('src', data.url);
 -            element.removeAttribute('data-cke-saved-src');
 -            $(element.$).removeClass(this.image_styles.join(' '));
 -            if (style) { element.addClass(style); }
 -        },
 -    });
 -
 -    var IMAGES_PER_ROW = 6;
 -    var IMAGES_ROWS = 4;
 -    website.editor.ExistingImageDialog = website.editor.Dialog.extend({
 -        template: 'website.editor.dialog.image.existing',
 -        events: _.extend({}, website.editor.Dialog.prototype.events, {
 -            'click .existing-attachments img': 'select_existing',
 -            'click .pager > li': function (e) {
 -                e.preventDefault();
 -                var $target = $(e.currentTarget);
 -                if ($target.hasClass('disabled')) {
 -                    return;
 -                }
 -                this.page += $target.hasClass('previous') ? -1 : 1;
 -                this.display_attachments();
 -            },
 -            'click .existing-attachment-remove': 'try_remove',
 -        }),
 -        init: function (parent) {
 -            this.image = null;
 -            this.page = 0;
 -            this.parent = parent;
 -            this._super(parent.editor);
 -        },
 -
 -        start: function () {
 -            return $.when(
 -                this._super(),
 -                this.fetch_existing().then(this.proxy('fetched_existing')));
 -        },
 -
 -        fetch_existing: function () {
              return openerp.jsonRpc('/web/dataset/call_kw', 'call', {
                  model: 'ir.attachment',
                  method: 'search_read',
Simple merge