summaryrefslogtreecommitdiffstats
path: root/js/directive/NewsAudio.js
diff options
context:
space:
mode:
authorBernhard Posselt <dev@bernhard-posselt.com>2014-05-30 15:14:07 +0200
committerBernhard Posselt <dev@bernhard-posselt.com>2014-05-30 15:14:07 +0200
commit88279961c5e2f2bd0711fc4200d58b93b425199e (patch)
tree1e07557fdbd6f037b143fd49f454199737d12f45 /js/directive/NewsAudio.js
parentabd5ef4c4c6ad3cf8e879f6c4b9181b077165952 (diff)
fix autopaging and marking read, render items
Diffstat (limited to 'js/directive/NewsAudio.js')
-rw-r--r--js/directive/NewsAudio.js39
1 files changed, 39 insertions, 0 deletions
diff --git a/js/directive/NewsAudio.js b/js/directive/NewsAudio.js
new file mode 100644
index 000000000..efcf5dfec
--- /dev/null
+++ b/js/directive/NewsAudio.js
@@ -0,0 +1,39 @@
+/**
+ * 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', () => {
+ '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: (scope, elm) => {
+ let source = elm.children().children('source')[0];
+ let cantPlay = false;
+ source.addEventListener('error', () => {
+ scope.$apply(() => {
+ cantPlay = true;
+ });
+ });
+
+ scope.cantPlay = () => {
+ return cantPlay;
+ };
+ }
+ };
+}); \ No newline at end of file