Sha256: f0129f2c37470d6a86fc4fdf4df9617eb1633a410ac6fe8b581facd94ce928c6

Contents?: true

Size: 1.92 KB

Versions: 29

Compression:

Stored size: 1.92 KB

Contents

(function($){
  elRTE.prototype.ui.prototype.buttons.sofa_link = function(rte, name){
    this.constructor.prototype.constructor.call(this, rte, name);
    
    var self      = this;
    self.link_url = null;
    
    // attaching event handler to the image insertion form
    $(document).on('submit', '#cms_dialog form.link_url', function(){
      self.link_url = $(this).find('input[name=link_url]').val();
      self.set();
      return false;
    });
    
    this.set = function(){
      self.rte.history.add();
      self.rte.doc.execCommand('createLink', false, self.link_url);
      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('Link'),
        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/link',
        success: function(data){
          self.dialog.html(data);
          self.dialog.dialog('open');
        }
      })
    }
    
    this.update = function(){
      var n = this.rte.selection.getNode();
      if (this.rte.dom.selfOrParentLink(n)) {
        this.domElem.removeClass('disabled').addClass('active');
      } else if (this.rte.dom.selectionHas(function(n) { return n.nodeName == 'A' && n.href; })) {
        this.domElem.removeClass('disabled').addClass('active');
      } else if (!this.rte.selection.collapsed() || n.nodeName == 'IMG') {
        this.domElem.removeClass('disabled active');
      } else {
        this.domElem.addClass('disabled').removeClass('active');
      }
    }
  }
  
  elRTE.prototype.options.buttons.sofa_link = 'Link';
  
})(jQuery)

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
comfortable_mexican_sofa-1.6.31 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.30 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.26 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.25 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.24 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.23 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.22 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.21 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.20 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.19 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.18 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.17 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.16 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.15 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.14 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.13 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.12 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.11 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.10 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js
comfortable_mexican_sofa-1.6.9 app/assets/javascripts/comfortable_mexican_sofa/elrte/elrte.sofa_link.js