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