Sha256: 03f836fb6f8dcfa2a64ac44440c917ca91b79e8c3dd8c0a016a52f5dab72b215

Contents?: true

Size: 1.35 KB

Versions: 5

Compression:

Stored size: 1.35 KB

Contents

if (!RedactorPlugins) var RedactorPlugins = {};

(function ($, undefined) {
    $.fn.getCursorPosition = function () {
        var el = $(this).get(0);
        var pos = 0;
        if ('selectionStart' in el) {
            pos = el.selectionStart;
        } else if ('selection' in document) {
            el.focus();
            var Sel = document.selection.createRange();
            var SelLength = document.selection.createRange().text.length;
            Sel.moveStart('character', -el.value.length);
            pos = Sel.text.length - SelLength;
        }
        return pos;
    }
})(jQuery);

// When i come back to it, we'll want to use the plugin above to log the cursor position
// before the modal is triggered and the position is lost.
// $(this).getCursorPosition());

RedactorPlugins.clips = {
	init: function()
	{
		var callback = $.proxy(function()
		{
			$('#redactor_modal').find('.redactor_clip_link').each($.proxy(function(i, s)
			{
				$(s).click($.proxy(function()
				{
					this.insertClip($(s).next().html());
					return false;

				}, this));
			}, this));

			this.selectionSave();
			this.bufferSet();

		}, this );

		this.buttonAdd('clips', 'Clips', function(e)
		{
			this.modalInit('Clips', '#clipsmodal', 500, callback);
		});
	},
	insertClip: function(html)
	{
		this.selectionRestore();
		this.insertHtml($.trim(html));
		this.modalClose();
	}
};

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
annex-cms-0.1.8 app/assets/javascripts/annex/jquery.redactor.clips.js
annex-cms-0.1.7 app/assets/javascripts/annex/jquery.redactor.clips.js
annex-cms-0.1.5 app/assets/javascripts/annex/jquery.redactor.clips.js
annex-cms-0.1.2 app/assets/javascripts/annex/jquery.redactor.clips.js
annex-cms-0.1.0 app/assets/javascripts/annex/jquery.redactor.clips.js