Browse Source

Merged youtube embed

master
Igor Zhukov 11 years ago
parent
commit
78d855cc1b
  1. 3
      app/css/app.css
  2. 14
      app/js/services.js

3
app/css/app.css

@ -1072,8 +1072,9 @@ div.im_message_video_thumb {
padding-bottom: 56.25%; // 16/9 ratio padding-bottom: 56.25%; // 16/9 ratio
height: 0; height: 0;
overflow: hidden; overflow: hidden;
margin-top: 5px;
} }
.im_message_iframe_video iframe, object, embed { .im_message_iframe_video iframe {
position: absolute; position: absolute;
top: 0; top: 0;
left: 0; left: 0;

14
app/js/services.js

@ -2427,6 +2427,7 @@ angular.module('myApp.services', [])
} }
var regExp = new RegExp('((?:(ftp|https?)://|(?:mailto:)?([A-Za-z0-9._%+-]+@))(\\S*\\.\\S*[^\\s.;,(){}<>"\']))|(\\n)|(' + emojiUtf.join('|') + ')', 'i'); var regExp = new RegExp('((?:(ftp|https?)://|(?:mailto:)?([A-Za-z0-9._%+-]+@))(\\S*\\.\\S*[^\\s.;,(){}<>"\']))|(\\n)|(' + emojiUtf.join('|') + ')', 'i');
var youtubeRegex = /(?:https?:\/\/)?(?:www\.)?youtu(?:|.be|be.com|.b)(?:\/v\/|\/watch\\?v=|e\/|\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/;
return { return {
wrapRichText: wrapRichText wrapRichText: wrapRichText
@ -2545,12 +2546,15 @@ angular.module('myApp.services', [])
} }
// console.log(4, text, html); // console.log(4, text, html);
var youtubeRegex = /(?:https?:\/\/)?(?:www\.)?youtu(?:|.be|be.com|.b)(?:\/v\/|\/watch\\?v=|e\/|\/watch(?:.+)v=)(.{11})(?:\&[^\s]*)?/; if (!options.noLinks) {
if (!options.noLinks && youtubeRegex.test(text)) { var youtubeMatches = text.match(youtubeRegex),
var videoID = youtubeRegex.exec(text)[1]; videoID = youtubeMatches && youtubeMatches[1];
if (videoID) {
text = text + '<div class="im_message_iframe_video"><iframe type="text/html" frameborder="0" ' + text = text + '<div class="im_message_iframe_video"><iframe type="text/html" frameborder="0" ' +
'src="http://www.youtube.com/embed/' + videoID + 'src="http://www.youtube.com/embed/' + videoID +
'?autoplay=0&amp;"></iframe></div>'; '?autoplay=0&amp;controls=2"></iframe></div>'
}
} }
return $sce.trustAs('html', text); return $sce.trustAs('html', text);

Loading…
Cancel
Save