Fixed JavaScript error in options menu
@@ -14,30 +14,29 @@ define(['angular','common/module-name'], function (angular,moduleName) {
showViewType: '=',
showPagination: '=',
additionalOptions: '=?',
- selectedAdditionalOption: "&?",
+ selectedAdditionalOption: "&?"
},
templateUrl: 'js/common/options-menu/options-menu-template.html',
- link: function ($scope, element, attrs) {
+ link: function ($scope) {
if ($scope.showViewType) {
$scope.viewType = {label: 'List View', icon: 'list', value: 'list', type: 'viewType'};
}
$scope.getPaginationId = function (tab) {
return PaginationDataService.paginationId($scope.menuKey, tab.title);
- }
+ };
$scope.getCurrentPage = function (tab) {
return PaginationDataService.currentPage($scope.menuKey, tab.title);
- }
-
+ };
function setViewTypeOption(toggle) {
$scope.viewType.value = PaginationDataService.viewType($scope.menuKey);
- if(toggle == true) {
- $scope.viewType.value = $scope.viewType.value == 'list' ? 'table' : 'list';
+ if (toggle === true) {
+ $scope.viewType.value = $scope.viewType.value === 'list' ? 'table' : 'list';
}
- if( $scope.viewType.value == 'list'){
+ if ($scope.viewType.value === 'list') {
$scope.viewType.label = 'List View';
$scope.viewType.icon = 'list';
}
@@ -46,22 +45,23 @@ define(['angular','common/module-name'], function (angular,moduleName) {
$scope.viewType.icon = 'grid_on';
}
}
+
if ($scope.showViewType) {
//toggle the view Type so its opposite the current view type
setViewTypeOption(true);
}
-
-
-
$scope.rowsPerPage = 5;
$scope.paginationData = PaginationDataService.paginationData($scope.menuKey);
var originatorEv;
$scope.openMenu = function ($mdOpenMenu, ev) {
originatorEv = ev;
- if($scope.openedMenu) {
- $scope.openedMenu()({sortOptions: $scope.sortOptions, additionalOptions: $scope.additionalOptions});
+ if (angular.isFunction($scope.openedMenu)) {
+ var openedMenuFn = $scope.openedMenu();
+ if (angular.isFunction(openedMenuFn)) {
+ openedMenuFn({sortOptions: $scope.sortOptions, additionalOptions: $scope.additionalOptions});
+ }
}
if ($scope.showPagination) {
var tabData = PaginationDataService.getActiveTabData($scope.menuKey);
@@ -82,7 +82,7 @@ define(['angular','common/module-name'], function (angular,moduleName) {
if ($scope.selectedAdditionalOption) {
$scope.selectedAdditionalOption()(itemCopy);
}
- }
+ };
/**
* Selected a Sort Option
@@ -92,7 +92,7 @@ define(['angular','common/module-name'], function (angular,moduleName) {
var itemCopy = {};
angular.extend(itemCopy, item);
- if(item.type == 'viewType'){
+ if (item.type === 'viewType') {
PaginationDataService.toggleViewType($scope.menuKey);
setViewTypeOption(true);
}
@@ -102,24 +102,16 @@ define(['angular','common/module-name'], function (angular,moduleName) {
}
originatorEv = null;
- }
+ };
$scope.$on('$destroy', function () {
});
-
-
-
-
-
}
}
};
-
- angular.module(moduleName)
- .directive('tbaOptionsMenu', ['$mdDialog','PaginationDataService',directive]);
-
+ angular.module(moduleName).directive('tbaOptionsMenu', ['$mdDialog', 'PaginationDataService', directive]);
});
