Skip to content

Commit

Permalink
Merge pull request #90 from SDKiller/patch-1
Browse files Browse the repository at this point in the history
Counter and video plugins were updated by Imperavi
  • Loading branch information
samdark committed Nov 4, 2014
2 parents 8088b18 + 44b95a0 commit 9c4c936
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
14 changes: 11 additions & 3 deletions assets/plugins/counter/counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,19 @@ RedactorPlugins.counter = function()
this.$editor.on('keyup.redactor-limiter', $.proxy(function(e)
{
var words = 0, characters = 0, spaces = 0;
var text = this.$editor.text();

var html = this.code.get();

var text = html.replace(/<\/(.*?)>/gi, ' ');
text = text.replace(/<(.*?)>/gi, '');
text = text.replace(/\t/gi, '');
text = text.replace(/\n/gi, '');
text = text.replace(/\r/gi, '');
text = $.trim(text);

if (text !== '')
{
var arrWords = text.split(' ');
var arrWords = text.split(/\s+/);
var arrSpaces = text.match(/\s/g);

if (arrWords) words = arrWords.length;
Expand All @@ -30,4 +38,4 @@ RedactorPlugins.counter = function()
}, this));
}
};
};
};
28 changes: 16 additions & 12 deletions assets/plugins/video/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,23 @@ RedactorPlugins.video = function()
insert: function()
{
var data = $('#redactor-insert-video-area').val();
data = this.clean.stripTags(data);

// parse if it is link on youtube & vimeo
var iframeStart = '<iframe style="width: 500px; height: 281px;" src="',
iframeEnd = '" frameborder="0" allowfullscreen></iframe>';

if (data.match(this.video.reUrlYoutube))
{
data = data.replace(this.video.reUrlYoutube, iframeStart + '//www.youtube.com/embed/$1' + iframeEnd);
}
else if (data.match(this.video.reUrlVimeo))
if (!data.match(/<iframe|<video/gi))
{
data = data.replace(this.video.reUrlVimeo, iframeStart + '//player.vimeo.com/video/$2' + iframeEnd);
data = this.clean.stripTags(data);

// parse if it is link on youtube & vimeo
var iframeStart = '<iframe style="width: 500px; height: 281px;" src="',
iframeEnd = '" frameborder="0" allowfullscreen></iframe>';

if (data.match(this.video.reUrlYoutube))
{
data = data.replace(this.video.reUrlYoutube, iframeStart + '//www.youtube.com/embed/$1' + iframeEnd);
}
else if (data.match(this.video.reUrlVimeo))
{
data = data.replace(this.video.reUrlVimeo, iframeStart + '//player.vimeo.com/video/$2' + iframeEnd);
}
}

this.selection.restore();
Expand All @@ -67,4 +71,4 @@ RedactorPlugins.video = function()
}

};
};
};

0 comments on commit 9c4c936

Please sign in to comment.