From b176bd33e1df9ca283ce7df5c84025d0080b245c Mon Sep 17 00:00:00 2001 From: Vladimir Lugovsky Date: Wed, 16 Dec 2015 02:00:43 +0300 Subject: [PATCH] refactor(common): common folder completely remove --- src/app/common/directives/animatedChange.js | 35 ---------------- src/app/common/directives/autoExpand.js | 28 ------------- src/app/common/directives/autoFocus.js | 20 --------- src/app/common/directives/ngFileSelect.js | 10 ----- src/app/common/directives/zoomIn.js | 23 ----------- src/app/theme/directives/animatedChange.js | 41 +++++++++++++++++++ src/app/theme/directives/autoExpand.js | 35 ++++++++++++++++ src/app/theme/directives/autoFocus.js | 27 ++++++++++++ src/app/theme/directives/ngFileSelect.js | 19 +++++++++ .../directives/scrollPosition.js | 15 ++++--- .../directives/trackWidth.js | 13 ++++-- src/app/theme/directives/zoomIn.js | 29 +++++++++++++ .../services/fileReader.js} | 17 +++++--- 13 files changed, 181 insertions(+), 131 deletions(-) delete mode 100644 src/app/common/directives/animatedChange.js delete mode 100644 src/app/common/directives/autoExpand.js delete mode 100644 src/app/common/directives/autoFocus.js delete mode 100644 src/app/common/directives/ngFileSelect.js delete mode 100644 src/app/common/directives/zoomIn.js create mode 100644 src/app/theme/directives/animatedChange.js create mode 100644 src/app/theme/directives/autoExpand.js create mode 100644 src/app/theme/directives/autoFocus.js create mode 100644 src/app/theme/directives/ngFileSelect.js rename src/app/{common => theme}/directives/scrollPosition.js (71%) rename src/app/{common => theme}/directives/trackWidth.js (79%) create mode 100644 src/app/theme/directives/zoomIn.js rename src/app/{common/modules/upload.js => theme/services/fileReader.js} (84%) diff --git a/src/app/common/directives/animatedChange.js b/src/app/common/directives/animatedChange.js deleted file mode 100644 index 4cf8129..0000000 --- a/src/app/common/directives/animatedChange.js +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Change top "Daily Downloads", "Active Users" values with animation effect - */ - -'use strict'; - -blurAdminApp.directive('animatedChange', ['$timeout', function ($timeout) { - return { - link: function (scope, element) { - $timeout(function () { - var newValue = element.attr('new-value'); - var oldvalue = parseInt(element.html()); - - function changeValue(val) { - $timeout(function () { - element.html(val); - }, 30); - } - - if (newValue > oldvalue) { - for (var i = oldvalue; i <= newValue; i++) { - changeValue(i); - } - } else { - for (var j = oldvalue; j >= newValue; j--) { - changeValue(j); - } - } - $timeout(function () { - element.next().find('i').addClass('show-arr'); - }, 500); - }, 3500); - } - }; -}]); \ No newline at end of file diff --git a/src/app/common/directives/autoExpand.js b/src/app/common/directives/autoExpand.js deleted file mode 100644 index 6bd28c6..0000000 --- a/src/app/common/directives/autoExpand.js +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Auto expand textarea field - */ -'use strict'; - -blurAdminApp.directive('autoExpand', function () { - return { - restrict: 'A', - link: function ($scope, elem) { - elem.bind('keydown', function ($event) { - var element = $event.target; - $(element).height(0); - var height = $(element)[0].scrollHeight; - height = (height < 16) ? 16 : height; - $(element).height(height); - }); - - // Expand the textarea as soon as it is added to the DOM - setTimeout(function () { - var element = elem; - $(element).height(0); - var height = $(element)[0].scrollHeight; - height = (height < 16) ? 16 : height; - $(element).height(height); - }, 0) - } - }; -}); \ No newline at end of file diff --git a/src/app/common/directives/autoFocus.js b/src/app/common/directives/autoFocus.js deleted file mode 100644 index e15104e..0000000 --- a/src/app/common/directives/autoFocus.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -blurAdminApp.directive('autoFocus', ['$timeout', '$parse', function ($timeout, $parse) { - return { - link: function (scope, element, attrs) { - var model = $parse(attrs.autoFocus); - scope.$watch(model, function (value) { - if (value === true) { - $timeout(function () { - element[0].focus(); - element[0].select(); - }); - } - }); - element.bind('blur', function () { - scope.$apply(model.assign(scope, false)); - }); - } - }; -}]); \ No newline at end of file diff --git a/src/app/common/directives/ngFileSelect.js b/src/app/common/directives/ngFileSelect.js deleted file mode 100644 index c165de4..0000000 --- a/src/app/common/directives/ngFileSelect.js +++ /dev/null @@ -1,10 +0,0 @@ -blurAdminApp.directive('ngFileSelect', function () { - return { - link: function ($scope, el) { - el.bind('change', function (e) { - $scope.file = (e.srcElement || e.target).files[0]; - $scope.getFile(); - }) - } - } -}); \ No newline at end of file diff --git a/src/app/common/directives/zoomIn.js b/src/app/common/directives/zoomIn.js deleted file mode 100644 index d0eff67..0000000 --- a/src/app/common/directives/zoomIn.js +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Animated load block - */ - -'use strict'; - -blurAdminApp.directive('zoomIn', ['$timeout', '$rootScope', function ($timeout, $rootScope) { - return { - restrict: 'A', - link: function ($scope, elem) { - var delay = 1000; - - if ($rootScope.$pageLoaded) { - delay = 100; - } - - $timeout(function () { - elem.removeClass('invisible'); - elem.addClass('animated zoomIn'); - }, delay); - } - }; -}]); \ No newline at end of file diff --git a/src/app/theme/directives/animatedChange.js b/src/app/theme/directives/animatedChange.js new file mode 100644 index 0000000..ab6c408 --- /dev/null +++ b/src/app/theme/directives/animatedChange.js @@ -0,0 +1,41 @@ +/** + * Change top "Daily Downloads", "Active Users" values with animation effect + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .directive('animatedChange', animatedChange); + + /** @ngInject */ + function animatedChange($timeout) { + return { + link: function (scope, element) { + $timeout(function () { + var newValue = element.attr('new-value'); + var oldvalue = parseInt(element.html()); + + function changeValue(val) { + $timeout(function () { + element.html(val); + }, 30); + } + + if (newValue > oldvalue) { + for (var i = oldvalue; i <= newValue; i++) { + changeValue(i); + } + } else { + for (var j = oldvalue; j >= newValue; j--) { + changeValue(j); + } + } + $timeout(function () { + element.next().find('i').addClass('show-arr'); + }, 500); + }, 3500); + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/theme/directives/autoExpand.js b/src/app/theme/directives/autoExpand.js new file mode 100644 index 0000000..e7eb21c --- /dev/null +++ b/src/app/theme/directives/autoExpand.js @@ -0,0 +1,35 @@ +/** + * Auto expand textarea field + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .directive('autoExpand', autoExpand); + + /** @ngInject */ + function autoExpand() { + return { + restrict: 'A', + link: function ($scope, elem) { + elem.bind('keydown', function ($event) { + var element = $event.target; + $(element).height(0); + var height = $(element)[0].scrollHeight; + height = (height < 16) ? 16 : height; + $(element).height(height); + }); + + // Expand the textarea as soon as it is added to the DOM + setTimeout(function () { + var element = elem; + $(element).height(0); + var height = $(element)[0].scrollHeight; + height = (height < 16) ? 16 : height; + $(element).height(height); + }, 0) + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/theme/directives/autoFocus.js b/src/app/theme/directives/autoFocus.js new file mode 100644 index 0000000..4230d8b --- /dev/null +++ b/src/app/theme/directives/autoFocus.js @@ -0,0 +1,27 @@ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .directive('autoFocus', autoFocus); + + /** @ngInject */ + function autoFocus($timeout, $parse) { + return { + link: function (scope, element, attrs) { + var model = $parse(attrs.autoFocus); + scope.$watch(model, function (value) { + if (value === true) { + $timeout(function () { + element[0].focus(); + element[0].select(); + }); + } + }); + element.bind('blur', function () { + scope.$apply(model.assign(scope, false)); + }); + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/theme/directives/ngFileSelect.js b/src/app/theme/directives/ngFileSelect.js new file mode 100644 index 0000000..a255d60 --- /dev/null +++ b/src/app/theme/directives/ngFileSelect.js @@ -0,0 +1,19 @@ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .directive('ngFileSelect', ngFileSelect); + + /** @ngInject */ + function ngFileSelect() { + return { + link: function ($scope, el) { + el.bind('change', function (e) { + $scope.file = (e.srcElement || e.target).files[0]; + $scope.getFile(); + }) + } + } + } + +})(); \ No newline at end of file diff --git a/src/app/common/directives/scrollPosition.js b/src/app/theme/directives/scrollPosition.js similarity index 71% rename from src/app/common/directives/scrollPosition.js rename to src/app/theme/directives/scrollPosition.js index 6a54d76..8b5bbca 100644 --- a/src/app/common/directives/scrollPosition.js +++ b/src/app/theme/directives/scrollPosition.js @@ -1,11 +1,15 @@ -(function(blurAdminApp) { +(function () { 'use strict'; - blurAdminApp.directive('scrollPosition', [function () { + angular.module('BlurAdmin.theme') + .directive('scrollPosition', scrollPosition); + + /** @ngInject */ + function scrollPosition() { return { scope: { scrollPosition: '=', - maxHeight: '=', + maxHeight: '=' }, link: function (scope) { $(window).on('scroll', function() { @@ -19,5 +23,6 @@ }); } }; - }]); -})(blurAdminApp); \ No newline at end of file + } + +})(); \ No newline at end of file diff --git a/src/app/common/directives/trackWidth.js b/src/app/theme/directives/trackWidth.js similarity index 79% rename from src/app/common/directives/trackWidth.js rename to src/app/theme/directives/trackWidth.js index 134812e..906d1fc 100644 --- a/src/app/common/directives/trackWidth.js +++ b/src/app/theme/directives/trackWidth.js @@ -1,7 +1,11 @@ -(function(blurAdminApp) { +(function () { 'use strict'; - blurAdminApp.directive('trackWidth', [function () { + angular.module('BlurAdmin.theme') + .directive('trackWidth', trackWidth); + + /** @ngInject */ + function trackWidth() { return { scope: { trackWidth: '=', @@ -22,5 +26,6 @@ }); } }; - }]); -})(blurAdminApp); \ No newline at end of file + } + +})(); \ No newline at end of file diff --git a/src/app/theme/directives/zoomIn.js b/src/app/theme/directives/zoomIn.js new file mode 100644 index 0000000..1371628 --- /dev/null +++ b/src/app/theme/directives/zoomIn.js @@ -0,0 +1,29 @@ +/** + * Animated load block + */ +(function () { + 'use strict'; + + angular.module('BlurAdmin.theme') + .directive('zoomIn', zoomIn); + + /** @ngInject */ + function zoomIn($timeout, $rootScope) { + return { + restrict: 'A', + link: function ($scope, elem) { + var delay = 1000; + + if ($rootScope.$pageLoaded) { + delay = 100; + } + + $timeout(function () { + elem.removeClass('invisible'); + elem.addClass('animated zoomIn'); + }, delay); + } + }; + } + +})(); \ No newline at end of file diff --git a/src/app/common/modules/upload.js b/src/app/theme/services/fileReader.js similarity index 84% rename from src/app/common/modules/upload.js rename to src/app/theme/services/fileReader.js index dc24c67..9882c52 100644 --- a/src/app/common/modules/upload.js +++ b/src/app/theme/services/fileReader.js @@ -1,9 +1,15 @@ -(function (blurAdminApp) { +/** + * @author v.lugovksy + * created on 16.12.2015 + */ +(function () { + 'use strict'; - blurAdminApp.factory('fileReader', fileReader); - fileReader.$inject = ['$q']; + angular.module('BlurAdmin.theme') + .service('fileReader', fileReader); - function fileReader ($q) { + /** @ngInject */ + function fileReader($q) { var onLoad = function(reader, deferred, scope) { return function () { scope.$apply(function () { @@ -51,5 +57,4 @@ readAsDataUrl: readAsDataURL }; } - -}(blurAdminApp)); \ No newline at end of file +})(); \ No newline at end of file