Sha256: 1693780024cfb37d67b08254063d4d4075be7726b364541efaad465564820bc9

Contents?: true

Size: 1.85 KB

Versions: 18

Compression:

Stored size: 1.85 KB

Contents

(function($){
  
  elRTE.prototype.ui.prototype.buttons.sofa_image = function(rte, name) {
    this.constructor.prototype.constructor.call(this, rte, name);
    
    var self      = this;
    self.img_src  = null;
    self.dialog   = null;
    
    // attaching event handler to the image insertion form
    $(document).on('submit', '#cms_dialog form.image_url', function(){
      self.img_src = $(this).find('input[name=image_url]').val();
      self.set();
      return false;
    });
    
    // attaching event handlers to images
    $(document).on('click', '#cms_dialog .uploaded_files .file_info', function(){
      self.img_src = $(this).data('url');
      self.set();
      return false;
    });
    
    this.set = function(){
      self.rte.history.add();
      var img = $(self.rte.doc.createElement('img'));
      img.attr('src', self.img_src);
      self.rte.selection.insertNode(img[0]);
      self.rte.ui.update();
      self.dialog.dialog('close');
    }
    
    this.command = function(){
      self.dialog = jQuery(jQuery('#cms_dialog').get(0) || jQuery('<div id="cms_dialog"></div>'));
      self.dialog.dialog({
        title         : rte.i18n('Image'),
        modal         : true,
        resizable     : false,
        width         : 800,
        closeOnEscape : true,
        autoOpen      : false
      });
      
      jQuery.ajax({
        url: '/' + $('meta[name="cms-admin-path"]').attr('content') + '/sites/' + $('meta[name="cms-site-id"]').attr('content') + '/dialog/image',
        success: function(data){
          self.dialog.html(data);
          self.dialog.dialog('open');
          $.CMS.enable_uploader();
        }
      })
    }
    
    this.update = function(){
      this.domElem.removeClass('disabled');
    }
  }
  elRTE.prototype.options.buttons.sofa_image = 'Image';
  elRTE.prototype.options.panels.sofa_image = ['sofa_image'];
  
})(jQuery);

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.17 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.16 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.15 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.14 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.13 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.12 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.11 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.10 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.9 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.8 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.7 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.6 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.5 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.4 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.3 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.2 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.1 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js
comfortable_mexican_sofa-1.6.0 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_image.js