summaryrefslogtreecommitdiffstats
path: root/js/directive
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-09-16 19:42:37 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-09-16 19:42:37 +0200
commit8e0cbf094ea553821697091d69fff9ba59214c4b (patch)
tree61f14f1d11b732405f89e045029a8ce0d58720bb /js/directive
parent9e36ef31f9bf16d43326fd047619ada5ff16e072 (diff)
fix enclosure
Diffstat (limited to 'js/directive')
-rw-r--r--js/directive/NewsAudio.js40
-rw-r--r--js/directive/NewsEnclosure.js53
2 files changed, 53 insertions, 40 deletions
diff --git a/js/directive/NewsAudio.js b/js/directive/NewsAudio.js
deleted file mode 100644
index 422f5ff19..000000000
--- a/js/directive/NewsAudio.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/**
- * ownCloud - News
- *
- * This file is licensed under the Affero General Public License version 3 or
- * later. See the COPYING file.
- *
- * @author Bernhard Posselt <dev@bernhard-posselt.com>
- * @copyright Bernhard Posselt 2014
- */
-app.directive('newsAudio', function () {
- 'use strict';
- return {
- restrict: 'E',
- scope: {
- src: '@',
- type: '@'
- },
- transclude: true,
- template: '' +
- '<audio controls="controls" preload="none" ng-hide="cantPlay()">' +
- '<source ng-src="{{ src|trustUrl }}">' +
- '</audio>' +
- '<a ng-href="{{ src|trustUrl }}" class="button" ng-show="cantPlay()" ' +
- 'ng-transclude></a>',
- link: function (scope, elm) {
- var source = elm.children().children('source')[0];
- var cantPlay = false;
-
- source.addEventListener('error', function () {
- scope.$apply(function () {
- cantPlay = true;
- });
- });
-
- scope.cantPlay = function () {
- return cantPlay;
- };
- }
- };
-}); \ No newline at end of file
diff --git a/js/directive/NewsEnclosure.js b/js/directive/NewsEnclosure.js
new file mode 100644
index 000000000..c424b50c3
--- /dev/null
+++ b/js/directive/NewsEnclosure.js
@@ -0,0 +1,53 @@
+/**
+ * ownCloud - News
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Bernhard Posselt <dev@bernhard-posselt.com>
+ * @copyright Bernhard Posselt 2014
+ */
+app.directive('newsEnclosure', function () {
+ 'use strict';
+ return {
+ restrict: 'E',
+ scope: {
+ link: '@',
+ type: '@'
+ },
+ transclude: true,
+ template: '<div>' +
+ '<video controls preload="none" ' +
+ 'ng-show="mediaType==\'video\' && !cantPlay()">' +
+ '<source ng-src="{{ link|trustUrl }}" type="{{ type }}">' +
+ '</video>' +
+ '<audio controls preload="none" ' +
+ 'ng-show="mediaType==\'audio\' && !cantPlay()">' +
+ '<source ng-src="{{ link|trustUrl }}" type="{{ type }}">' +
+ '</audio>' +
+ '<div ng-transclude ng-show="cantPlay()"></div>' +
+ '</div>',
+ link: function (scope, elem) {
+ if (scope.type.indexOf('audio') === 0) {
+ scope.mediaType = 'audio';
+ } else {
+ scope.mediaType = 'video';
+ }
+ var source = elem.children()
+ .children(scope.mediaType)
+ .children('source')[0];
+
+ var cantPlay = false;
+
+ scope.cantPlay = function () {
+ return cantPlay;
+ };
+
+ source.addEventListener('error', function () {
+ scope.$apply(function () {
+ cantPlay = true;
+ });
+ });
+ }
+ };
+}); \ No newline at end of file