app/views/promethee/components/video/_edit.move.html.erb in promethee-1.2.31 vs app/views/promethee/components/video/_edit.move.html.erb in promethee-1.3.0

- old
+ new

@@ -1,8 +1,34 @@ <script type="text/ng-template" id="promethee/components/video/edit/move"> - <div ng-controller="VideoController"> - <div class="embed-responsive embed-responsive-16by9"> - <iframe ng-if="embed" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="allowfullscreen" ng-src="{{embed | urlSafe}}"></iframe> - <div class="video-neutralizing-overlay"></div> + <%= render 'promethee/edit/move.header', type: 'video' %> + <div ng-controller="VideoController"> + <div class="embed-responsive embed-responsive-16by9"> + <iframe ng-if="embed" frameborder="0" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="allowfullscreen" ng-src="{{embed | urlSafe}}"></iframe> + <div class="video-neutralizing-overlay"></div> + </div> + </div> </div> </div> +</script> + +<script> + promethee.controller('VideoController', ['$scope', function($scope) { + Object.defineProperty($scope, 'embed', { + get: function() { + var embed = null; + var url = this.component.attributes.url + ''; + + if(url.includes('vimeo')) { + var id = url.replace(/^(?:https?:)?\/\/(?:(?:www|player)\.)?vimeo\.com\/(?:video\/)?(\d+).*?$/, '$1'); + embed = 'https://player.vimeo.com/video/' + id + '?color=ffffff&title=0&byline=0&portrait=0'; + } + else if(url.includes('youtube')) { + var parts = url.split('watch?v='); + var id = parts[parts.length - 1]; + embed = 'http://www.youtube.com/embed/' + id; + } + + return embed; + } + }) + }]); </script>