diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-11 03:55:52 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-11 03:55:52 +0200 |
commit | ea9ebd4826fe9807af5bc17e786b3dc58f163970 (patch) | |
tree | 2894b40614ebe977797cea5745b215e2a2851f61 /js/directive | |
parent | 594b92f649d8ed8a705f1af23639463078170d46 (diff) |
port to es5 and add es6 shims for object prototypes instead
Diffstat (limited to 'js/directive')
-rw-r--r-- | js/directive/AppNavigationEntryUtils.js | 16 | ||||
-rw-r--r-- | js/directive/NewsAudio.js | 15 | ||||
-rw-r--r-- | js/directive/NewsAutoFocus.js | 4 | ||||
-rw-r--r-- | js/directive/NewsBindUnsafeHtml.js | 6 | ||||
-rw-r--r-- | js/directive/NewsDraggable.js | 6 | ||||
-rw-r--r-- | js/directive/NewsDroppable.js | 10 | ||||
-rw-r--r-- | js/directive/NewsFocus.js | 10 | ||||
-rw-r--r-- | js/directive/NewsReadFile.js | 12 | ||||
-rw-r--r-- | js/directive/NewsScroll.js | 45 | ||||
-rw-r--r-- | js/directive/NewsStopPropagation.js | 8 | ||||
-rw-r--r-- | js/directive/NewsTimeout.js | 10 | ||||
-rw-r--r-- | js/directive/NewsTitleUnreadCount.js | 10 | ||||
-rw-r--r-- | js/directive/NewsTriggerClick.js | 6 |
13 files changed, 79 insertions, 79 deletions
diff --git a/js/directive/AppNavigationEntryUtils.js b/js/directive/AppNavigationEntryUtils.js index 146d0f22a..c96589a6a 100644 --- a/js/directive/AppNavigationEntryUtils.js +++ b/js/directive/AppNavigationEntryUtils.js @@ -7,27 +7,27 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.run(($document, $rootScope) => { +app.run(function ($document, $rootScope) { 'use strict'; - $document.click((event) => { + $document.click(function (event) { $rootScope.$broadcast('documentClicked', event); }); }); -app.directive('appNavigationEntryUtils', () => { +app.directive('appNavigationEntryUtils', function () { 'use strict'; return { restrict: 'C', - link: (scope, elm) => { - let menu = elm.siblings('.app-navigation-entry-menu'); - let button = $(elm) + link: function (scope, elm) { + var menu = elm.siblings('.app-navigation-entry-menu'); + var button = $(elm) .find('.app-navigation-entry-utils-menu-button button'); - button.click(() => { + button.click(function () { menu.toggleClass('open'); }); - scope.$on('documentClicked', (scope, event) => { + scope.$on('documentClicked', function (scope, event) { if (event.target !== button[0]) { menu.removeClass('open'); } diff --git a/js/directive/NewsAudio.js b/js/directive/NewsAudio.js index efcf5dfec..422f5ff19 100644 --- a/js/directive/NewsAudio.js +++ b/js/directive/NewsAudio.js @@ -7,7 +7,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsAudio', () => { +app.directive('newsAudio', function () { 'use strict'; return { restrict: 'E', @@ -22,16 +22,17 @@ app.directive('newsAudio', () => { '</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(() => { + 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 = () => { + scope.cantPlay = function () { return cantPlay; }; } diff --git a/js/directive/NewsAutoFocus.js b/js/directive/NewsAutoFocus.js index b73dd2443..87bcab006 100644 --- a/js/directive/NewsAutoFocus.js +++ b/js/directive/NewsAutoFocus.js @@ -7,9 +7,9 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsAutoFocus', () => { +app.directive('newsAutoFocus', function () { 'use strict'; - return (scope, elem, attrs) => { + return function (scope, elem, attrs) { if (attrs.newsAutofocus) { $(attrs.newsAutofocus).focus(); } else { diff --git a/js/directive/NewsBindUnsafeHtml.js b/js/directive/NewsBindUnsafeHtml.js index 7c839d156..5d8cadf85 100644 --- a/js/directive/NewsBindUnsafeHtml.js +++ b/js/directive/NewsBindUnsafeHtml.js @@ -7,11 +7,11 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsBindHtmlUnsafe', () => { +app.directive('newsBindHtmlUnsafe', function () { 'use strict'; - return (scope, elem, attr) => { - scope.$watch(attr.newsBindHtmlUnsafe, () => { + return function (scope, elem, attr) { + scope.$watch(attr.newsBindHtmlUnsafe, function () { elem.html(scope.$eval(attr.newsBindHtmlUnsafe)); }); }; diff --git a/js/directive/NewsDraggable.js b/js/directive/NewsDraggable.js index 76360ecb7..0bd81a78c 100644 --- a/js/directive/NewsDraggable.js +++ b/js/directive/NewsDraggable.js @@ -7,11 +7,11 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsDraggable', () => { +app.directive('newsDraggable', function () { 'use strict'; - return (scope, elem, attr) => { - let options = scope.$eval(attr.newsDraggable); + return function (scope, elem, attr) { + var options = scope.$eval(attr.newsDraggable); if (angular.isDefined(options)) { elem.draggable(options); diff --git a/js/directive/NewsDroppable.js b/js/directive/NewsDroppable.js index a68f26444..2808dc6a4 100644 --- a/js/directive/NewsDroppable.js +++ b/js/directive/NewsDroppable.js @@ -7,19 +7,19 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsDroppable', ($rootScope) => { +app.directive('newsDroppable', function ($rootScope) { 'use strict'; - return (scope, elem, attr) => { - let details = { + return function (scope, elem, attr) { + var details = { accept: '.feed', hoverClass: 'drag-and-drop', greedy: true, - drop: (event, ui) => { + drop: function (event, ui) { $('.drag-and-drop').removeClass('drag-and-drop'); - let data = { + var data = { folderId: parseInt(elem.data('id'), 10), feedId: parseInt($(ui.draggable).data('id'), 10) }; diff --git a/js/directive/NewsFocus.js b/js/directive/NewsFocus.js index f5133fd20..5c83db4f5 100644 --- a/js/directive/NewsFocus.js +++ b/js/directive/NewsFocus.js @@ -7,13 +7,13 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsFocus', ($timeout, $interpolate) => { +app.directive('newsFocus', function ($timeout, $interpolate) { 'use strict'; - return (scope, elem, attrs) => { - elem.click(() => { - let toReadd = $($interpolate(attrs.newsFocus)(scope)); - $timeout(() => { + return function (scope, elem, attrs) { + elem.click(function () { + var toReadd = $($interpolate(attrs.newsFocus)(scope)); + $timeout(function () { toReadd.focus(); }, 500); }); diff --git a/js/directive/NewsReadFile.js b/js/directive/NewsReadFile.js index 89ed0adfc..82bdf477e 100644 --- a/js/directive/NewsReadFile.js +++ b/js/directive/NewsReadFile.js @@ -7,17 +7,17 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsReadFile', () => { +app.directive('newsReadFile', function () { 'use strict'; - return (scope, elem, attr) => { + return function (scope, elem, attr) { - elem.change(() => { + elem.change(function () { - let file = elem[0].files[0]; - let reader = new FileReader(); + var file = elem[0].files[0]; + var reader = new FileReader(); - reader.onload = (event) => { + reader.onload = function (event) { elem[0].value = 0; // FIXME: is there a more flexible solution where we dont have // to bind the file to scope? diff --git a/js/directive/NewsScroll.js b/js/directive/NewsScroll.js index 3d566aebe..26e799da6 100644 --- a/js/directive/NewsScroll.js +++ b/js/directive/NewsScroll.js @@ -7,17 +7,17 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsScroll', ($timeout) => { +app.directive('newsScroll', function ($timeout) { 'use strict'; // autopaging - let autoPage = (enabled, limit, elem, scope) => { + var autoPage = function (enabled, limit, elem, scope) { if (enabled) { - let counter = 0; - let articles = elem.find('.item'); + var counter = 0; + var articles = elem.find('.item'); - for (let i = articles.length - 1; i >= 0; i -= 1) { - let item = $(articles[i]); + for (var i = articles.length - 1; i >= 0; i -= 1) { + var item = $(articles[i]); // if the counter is higher than the size it means @@ -41,21 +41,20 @@ app.directive('newsScroll', ($timeout) => { }; // mark read - let markRead = (enabled, elem, scope) => { + var markRead = function (enabled, elem, scope) { if (enabled) { - let ids = []; + var ids = []; + var articles = elem.find('.item:not(.read)'); - let articles = elem.find('.item:not(.read)'); - - for (let i = 0; i < articles.length; i += 1) { - let item = $(articles[i]); + articles.each(function(index, article) { + var item = $(article); if (item.position().top <= -50) { ids.push(parseInt(item.data('id'), 10)); } else { - break; + return false; } - } + }); scope.itemIds = ids; scope.$apply(scope.newsScrollMarkRead); @@ -73,19 +72,19 @@ app.directive('newsScroll', ($timeout) => { 'newsScrollTimeout': '@', // optional, defaults to 1 second 'newsScrollAutoPageWhenLeft': '@' // optional, defaults to 50 }, - link: (scope, elem) => { - let allowScroll = true; + link: function (scope, elem) { + var allowScroll = true; - let scrollTimeout = scope.newsScrollTimeout || 1; - let markReadTimeout = scope.newsScrollMarkReadTimeout || 1; - let autoPageLimit = scope.newsScrollAutoPageWhenLeft || 50; + var scrollTimeout = scope.newsScrollTimeout || 1; + var markReadTimeout = scope.newsScrollMarkReadTimeout || 1; + var autoPageLimit = scope.newsScrollAutoPageWhenLeft || 50; - let scrollHandler = () => { + var scrollHandler = function () { // allow only one scroll event to trigger at once if (allowScroll) { allowScroll = false; - $timeout(() => { + $timeout(function () { allowScroll = true; }, scrollTimeout*1000); @@ -95,7 +94,7 @@ app.directive('newsScroll', ($timeout) => { scope); // allow user to undo accidental scroll - $timeout(() => { + $timeout(function () { markRead(scope.newsScrollEnabledMarkRead, elem, scope); @@ -107,7 +106,7 @@ app.directive('newsScroll', ($timeout) => { elem.on('scroll', scrollHandler); // remove scroll handler if element is destroyed - scope.$on('$destroy', () => { + scope.$on('$destroy', function () { elem.off('scroll', scrollHandler); }); } diff --git a/js/directive/NewsStopPropagation.js b/js/directive/NewsStopPropagation.js index daa62ae59..48d8ce3c4 100644 --- a/js/directive/NewsStopPropagation.js +++ b/js/directive/NewsStopPropagation.js @@ -7,13 +7,13 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsStopPropagation', () => { +app.directive('newsStopPropagation', function () { 'use strict'; return { restrict: 'A', - link: (scope, element) => { - element.bind('click', (e) => { - e.stopPropagation(); + link: function (scope, element) { + element.bind('click', function (event) { + event.stopPropagation(); }); } }; diff --git a/js/directive/NewsTimeout.js b/js/directive/NewsTimeout.js index dc87dd5aa..37458a61b 100644 --- a/js/directive/NewsTimeout.js +++ b/js/directive/NewsTimeout.js @@ -7,7 +7,7 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsTimeout', ($timeout) => { +app.directive('newsTimeout', function ($timeout) { 'use strict'; return { @@ -15,13 +15,13 @@ app.directive('newsTimeout', ($timeout) => { scope: { 'newsTimeout': '&' }, - link: (scope) => { - let seconds = 7; - let timer = $timeout(scope.newsTimeout, seconds * 1000); + link: function (scope) { + var seconds = 7; + var timer = $timeout(scope.newsTimeout, seconds * 1000); // remove timeout if element is being removed by // for instance clicking on the x button - scope.$on('$destroy', () => { + scope.$on('$destroy', function () { $timeout.cancel(timer); }); } diff --git a/js/directive/NewsTitleUnreadCount.js b/js/directive/NewsTitleUnreadCount.js index 709b910ed..0866b4b72 100644 --- a/js/directive/NewsTitleUnreadCount.js +++ b/js/directive/NewsTitleUnreadCount.js @@ -7,19 +7,19 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsTitleUnreadCount', ($window) => { +app.directive('newsTitleUnreadCount', function ($window) { 'use strict'; - let baseTitle = $window.document.title; + var baseTitle = $window.document.title; return { restrict: 'E', scope: { unreadCount: '@' }, - link: (scope, elem, attrs) => { - attrs.$observe('unreadCount', (value) => { - let titles = baseTitle.split('-'); + link: function (scope, elem, attrs) { + attrs.$observe('unreadCount', function (value) { + var titles = baseTitle.split('-'); if (value !== '0') { $window.document.title = titles[0] + diff --git a/js/directive/NewsTriggerClick.js b/js/directive/NewsTriggerClick.js index d5c43e442..a0a3f2904 100644 --- a/js/directive/NewsTriggerClick.js +++ b/js/directive/NewsTriggerClick.js @@ -7,11 +7,11 @@ * @author Bernhard Posselt <dev@bernhard-posselt.com> * @copyright Bernhard Posselt 2014 */ -app.directive('newsTriggerClick', () => { +app.directive('newsTriggerClick', function () { 'use strict'; - return (scope, elm, attr) => { - elm.click(() => { + return function (scope, elm, attr) { + elm.click(function () { $(attr.newsTriggerClick).trigger('click'); }); }; |