Skip to content

Commit 4228ec0

Browse files
committed
feat: TED support added #7
1 parent e7aa9c1 commit 4228ec0

5 files changed

Lines changed: 52 additions & 10 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Features
1515
* Twitter tweet embedding supported
1616
* Codepen, jsbin, jsfiddle embed supported
1717
* soundcloud support
18-
* Twitch tv, dotSub, dailymotion, vine support.
18+
* Twitch tv, dotSub, dailymotion, vine,TED support.
1919

2020
Dependencies
2121
------------
@@ -147,6 +147,7 @@ $('#element').emoticons({
147147
vineEmbed : true,
148148
vineWidth : 500,
149149
vineType : 'postcard', //'postcard' or 'simple' embedding
150+
tedEmbed :true,
150151
//callback before pdf preview
151152
beforePdfPreview : function(){},
152153
//callback after pdf preview

demo/index.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,18 @@
3030
<h1>emoticons-js</h1>
3131

3232
<div id="element">
33+
<h3>TED support</h3>
34+
35+
<div>Ubi est teres palus?Secundus lacteas ducunt ad valebat.Speciess assimilant in magnum hortus!
36+
http://www.ted.com/talks/monica_lewinsky_the_price_of_shame Ubi est fidelis exsul?Peritus axonas ducunt ad
37+
deus.Silva accelerares, tanquam fidelis ausus.Est castus mons, cesaris.
38+
</div>
3339
<h3>Vine Support</h3>
40+
3441
<div>
35-
Cur tabes unda?Silvas sunt cedriums de audax habitio.Observare solite ducunt ad salvus cobaltum.Nutrix, zeta, et absolutio.Cum era ire, omnes finises carpseris varius, flavum homoes.Sunt eleateses examinare alter, emeritis advenaes.Sunt detriuses perdere mirabilis, rusticus lacteaes.
42+
Cur tabes unda?Silvas sunt cedriums de audax habitio.Observare solite ducunt ad salvus cobaltum.Nutrix, zeta, et
43+
absolutio.Cum era ire, omnes finises carpseris varius, flavum homoes.Sunt eleateses examinare alter, emeritis
44+
advenaes.Sunt detriuses perdere mirabilis, rusticus lacteaes.
3645
https://vine.co/v/bjHh0zHdgZT Persuadere unus ducunt ad talis lumen.Ubi est secundus tabes? :smile:
3746
</div>
3847
<h3>Dailymotion Support</h3>
@@ -143,11 +152,11 @@ <h3>Media file support</h3>
143152
<script>
144153
$(function () {
145154
$("#element").emoticons({
146-
link : true,
147-
linkTarget : '_blank',
148-
ytAuthKey : 'AIzaSyCqFouT8h5DKAbxlrTZmjXEmNBjC69f0ts',
149-
videoWidth : 800,
150-
audioEmbed : true
155+
link : true,
156+
linkTarget: '_blank',
157+
ytAuthKey : 'AIzaSyCqFouT8h5DKAbxlrTZmjXEmNBjC69f0ts',
158+
videoWidth: 800,
159+
audioEmbed: true
151160
});
152161
});
153162
</script>

dist/jquery.emoticons.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
vineEmbed : true,
141141
vineWidth : 500,
142142
vineType : 'postcard', //'postcard' or 'simple' embedding
143+
tedEmbed : true,
143144
beforePdfPreview : function () { //callback before pdf preview
144145
},
145146
afterPdfPreview : function () { //callback after pdf preview
@@ -420,7 +421,21 @@
420421
if (matches) {
421422
var i = 0;
422423
while (i < matches.length) {
423-
str = str + '<div class="ejs-vine"><iframe src="https://vine.co/v/' + matches[i].split('/')[2] + '/embed/'+opts.vineType+'" height="' + (opts.vineType=='postcard'?(opts.vineWidth + 158):opts.vineWidth) + '" width="' + opts.vineWidth + '"></iframe></div>'
424+
str = str + '<div class="ejs-vine"><iframe src="https://vine.co/v/' + matches[i].split('/')[2] + '/embed/' + opts.vineType + '" height="' + (opts.vineType == 'postcard' ? (opts.vineWidth + 158) : opts.vineWidth) + '" width="' + opts.vineWidth + '"></iframe></div>'
425+
i++;
426+
}
427+
}
428+
return str;
429+
},
430+
431+
tedEmbed: function (rawStr, str, opts) {
432+
var tedRegex=/ted.com\/talks\/[a-zA-Z0-9_]+/gi;
433+
var matches=rawStr.match(tedRegex)?rawStr.match(tedRegex).getUnique():null;
434+
var videoDimensions=this.dimensions(opts);
435+
if(matches){
436+
var i=0;
437+
while(i<matches.length){
438+
str=str+'<div class="ejs-embed"><iframe src="http://embed.ted.com/talks/'+matches[i].split('/')[2]+'.html" height="' + videoDimensions.height + '" width="' + videoDimensions.width + '"></iframe></div>'
424439
i++;
425440
}
426441
}
@@ -685,6 +700,7 @@
685700
input = (settings.dotsubEmbed) ? videoProcess.dotsubEmbed(rawInput, input, settings) : input;
686701
input = (settings.dailymotionEmbed) ? videoProcess.dailymotionEmbed(rawInput, input, settings) : input;
687702
input = (settings.vineEmbed) ? videoProcess.vineEmbed(rawInput, input, settings) : input;
703+
input = (settings.tedEmbed) ? videoProcess.tedEmbed(rawInput, input, settings) : input;
688704

689705
videoProcess.embed(input, settings).then(function (d) {
690706
if (tweetProcess.getMatches(d)) {

dist/jquery.emoticons.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/jquery.emoticons.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@
132132
vineEmbed : true,
133133
vineWidth : 500,
134134
vineType : 'postcard', //'postcard' or 'simple' embedding
135+
tedEmbed : true,
135136
beforePdfPreview : function () { //callback before pdf preview
136137
},
137138
afterPdfPreview : function () { //callback after pdf preview
@@ -412,7 +413,21 @@
412413
if (matches) {
413414
var i = 0;
414415
while (i < matches.length) {
415-
str = str + '<div class="ejs-vine"><iframe src="https://vine.co/v/' + matches[i].split('/')[2] + '/embed/'+opts.vineType+'" height="' + (opts.vineType=='postcard'?(opts.vineWidth + 158):opts.vineWidth) + '" width="' + opts.vineWidth + '"></iframe></div>'
416+
str = str + '<div class="ejs-vine"><iframe src="https://vine.co/v/' + matches[i].split('/')[2] + '/embed/' + opts.vineType + '" height="' + (opts.vineType == 'postcard' ? (opts.vineWidth + 158) : opts.vineWidth) + '" width="' + opts.vineWidth + '"></iframe></div>'
417+
i++;
418+
}
419+
}
420+
return str;
421+
},
422+
423+
tedEmbed: function (rawStr, str, opts) {
424+
var tedRegex=/ted.com\/talks\/[a-zA-Z0-9_]+/gi;
425+
var matches=rawStr.match(tedRegex)?rawStr.match(tedRegex).getUnique():null;
426+
var videoDimensions=this.dimensions(opts);
427+
if(matches){
428+
var i=0;
429+
while(i<matches.length){
430+
str=str+'<div class="ejs-embed"><iframe src="http://embed.ted.com/talks/'+matches[i].split('/')[2]+'.html" height="' + videoDimensions.height + '" width="' + videoDimensions.width + '"></iframe></div>'
416431
i++;
417432
}
418433
}
@@ -677,6 +692,7 @@
677692
input = (settings.dotsubEmbed) ? videoProcess.dotsubEmbed(rawInput, input, settings) : input;
678693
input = (settings.dailymotionEmbed) ? videoProcess.dailymotionEmbed(rawInput, input, settings) : input;
679694
input = (settings.vineEmbed) ? videoProcess.vineEmbed(rawInput, input, settings) : input;
695+
input = (settings.tedEmbed) ? videoProcess.tedEmbed(rawInput, input, settings) : input;
680696

681697
videoProcess.embed(input, settings).then(function (d) {
682698
if (tweetProcess.getMatches(d)) {

0 commit comments

Comments
 (0)