Sha256: e610fc1bc28a2ad991c7d639103e1626b93431fa65937d722332000d1c6e285f

Contents?: true

Size: 1.78 KB

Versions: 4

Compression:

Stored size: 1.78 KB

Contents

if (!RedactorPlugins) var RedactorPlugins = {};

RedactorPlugins.clips = function()
{
	return {
		init: function()
		{
			var items = [
				['Lorem ipsum...', 'Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.'],
				['Red label', '<span class="label-red">Label</span>']
			];

			this.clips.template = $('<ul id="redactor-modal-list">');

			for (var i = 0; i < items.length; i++)
			{
				var li = $('<li>');
				var a = $('<a href="#" class="redactor-clip-link">').text(items[i][0]);
				var div = $('<div class="redactor-clip">').hide().html(items[i][1]);

				li.append(a);
				li.append(div);
				this.clips.template.append(li);
			}

			this.modal.addTemplate('clips', '<section>' + this.utils.getOuterHtml(this.clips.template) + '</section>');

			var button = this.button.add('clips', 'Clips');
			this.button.addCallback(button, this.clips.show);

		},
		show: function()
		{
			this.modal.load('clips', 'Insert Clips', 400);

			this.modal.createCancelButton();

			$('#redactor-modal-list').find('.redactor-clip-link').each($.proxy(this.clips.load, this));

			this.selection.save();
			this.modal.show();
		},
		load: function(i,s)
		{
			$(s).on('click', $.proxy(function(e)
			{
				e.preventDefault();
				this.clips.insert($(s).next().html());

			}, this));
		},
		insert: function(html)
		{
			this.selection.restore();
			this.insert.html(html);
			this.modal.close();
			this.observe.load();
		}
	};
};

Version data entries

4 entries across 4 versions & 4 rubygems

Version Path
redactor-rails-fixes-0.5.0.1 vendor/assets/javascripts/redactor-rails/plugins/clips.js
rdrails5-0.5.1 vendor/assets/javascripts/redactor-rails/plugins/clips.js
redactor-rails4-0.5.0 vendor/assets/javascripts/redactor-rails/plugins/clips.js
redactor-rails-0.5.0 vendor/assets/javascripts/redactor-rails/plugins/clips.js