File manager - Edit - /usr/local/cpanel/whostmgr/docroot/templates/mail_blocked_countries/directives/countryCodesTableDirective.min.js
Back
define(["angular","lodash","cjt/util/locale","app/services/countriesService","uiBootstrap","cjt/modules","cjt/directives/toggleSortDirective","cjt/directives/spinnerDirective","cjt/directives/searchDirective","cjt/directives/pageSizeDirective","cjt/filters/startFromFilter","cjt/decorators/paginationDecorator","cjt/directives/quickFiltersDirective","cjt/directives/toggleSwitchDirective"],(function(angular,_,LOCALE,CountriesService){"use strict";var TEMPLATE_PATH="directives/countryCodesTable.ptt";var DIRECTIVE_NAME="countryCodesTable";var MODULE_NAMESPACE="whm.eximBlockCountries.directives.countryCodesTable";var MODULE_REQUIREMENTS=["cjt2.services.alert","cjt2.directives.spinner",CountriesService.namespace];var COUNTRIES_MESSAGE_MAX=10;var CONTROLLER_INJECTABLES=["$scope","$filter",CountriesService.serviceName,"alertService"];var CONTROLLER=function($scope,$filter,$service,$alertService){var filters={filter:$filter("filter"),orderBy:$filter("orderBy")};var countriesMap={};var items=$scope.items?$scope.items:[];items.forEach((function(item){countriesMap[item.code]=item;item.searchableCode="("+item.code+")"}));_.assign($scope,{filteredList:$scope.items,selectedAllowed:[],selectedBlocked:[],selectedItems:[],items:items,loading:false,meta:{filterValue:"",sortBy:"name",sortDirection:"asc",quickFilterValue:"all"},toggleSelect:function toggleSelect(itemCode,list){var idx=list.indexOf(itemCode);if(idx>-1){list.splice(idx,1)}else{list.push(itemCode)}$scope.updateSelectedBlocked()},updateSelectedBlocked:function updateSelectedBlocked(){var allowed=[];var blocked=[];$scope.selectedItems.forEach((function(code){if(countriesMap[code].allowed){allowed.push(code)}else{blocked.push(code)}}));$scope.selectedBlocked=blocked;$scope.selectedAllowed=allowed},toggleSelectAll:function toggleSelectAll(){if($scope.allAreSelected()){$scope.deselectAll()}else{$scope.selectAll()}},selectAll:function selectAll(){$scope.selectedItems=$scope.filteredList.map((function(item){return item.code}));$scope.updateSelectedBlocked()},deselectAll:function deselectAll(){$scope.selectedItems=[];$scope.updateSelectedBlocked()},allAreSelected:function allAreSelected(){return $scope.selectedItems.length&&$scope.selectedItems.length===$scope.filteredList.length},exists:function exists(item,list){return list.indexOf(item)>-1},getCountriesFromCodes:function getCountriesFromCodes(countryCodes){return countryCodes.map((function(countryCode){return countriesMap[countryCode]}))},_showBlockSuccessMessage:function _showBlockSuccessMessage(countryCodes){var countryNames=this.getCountriesFromCodes(countryCodes).map((function(country){return country.name}));var msg;if(countryNames.length>COUNTRIES_MESSAGE_MAX){var shortList=countryNames.slice(0,COUNTRIES_MESSAGE_MAX);var localeMsg=LOCALE.translatable("Your server will now block messages that originate in “[_1]”, “[_2]”, “[_3]”, “[_4]”, “[_5]”, “[_6]”, “[_7]”, “[_8]”, “[_9]”, “[_10]”, and [quant,_11,other country,other countries].");msg=LOCALE.makevar.apply(LOCALE,[localeMsg].concat(shortList,countryNames.length-shortList.length))}else{msg=LOCALE.maketext("Your server will now block messages that originate in [list_or_quoted,_1].",countryNames)}$alertService.success(msg)},_showUnblockSuccessMessage:function _showUnblockSuccessMessage(countryCodes){var countryNames=this.getCountriesFromCodes(countryCodes).map((function(country){return country.name}));var msg;if(countryNames.length>COUNTRIES_MESSAGE_MAX){var shortList=countryNames.slice(0,COUNTRIES_MESSAGE_MAX);var localeMsg=LOCALE.translatable("Your server will no longer block messages that originate in “[_1]”, “[_2]”, “[_3]”, “[_4]”, “[_5]”, “[_6]”, “[_7]”, “[_8]”, “[_9]”, “[_10]”, and [quant,_11,other country,other countries].");msg=LOCALE.makevar.apply(LOCALE,[localeMsg].concat(shortList,countryNames.length-shortList.length))}else{msg=LOCALE.maketext("Your server will no longer block messages that originate in [list_or_quoted,_1].",countryNames)}$alertService.success(msg)},blockCountries:function blockCountries(countries){var allowedCountries=countries.filter((function(countryCode){return countriesMap[countryCode].allowed}));var countryObjs=$scope.getCountriesFromCodes(allowedCountries);return $service.blockIncomingEmailFromCountries(allowedCountries).then($scope._showBlockSuccessMessage.bind($scope,allowedCountries)).then((function(){countryObjs.forEach((function(country){country.allowed=false}))})).finally($scope.deselectAll).finally($scope.fetch)},unblockCountries:function unblockCountries(countries){var blockedCountries=countries.filter((function(countryCode){return!countriesMap[countryCode].allowed}));var countryObjs=$scope.getCountriesFromCodes(blockedCountries);return $service.unblockIncomingEmailFromCountries(blockedCountries).then($scope._showUnblockSuccessMessage.bind($scope,blockedCountries)).then((function(){countryObjs.forEach((function(country){country.allowed=true}))})).finally($scope.deselectAll).finally($scope.fetch)},getToggleSelectTitle:function getToggleSelectTitle(countryObj){if(this.exists(countryObj.code,this.selectedItems)){return LOCALE.maketext("Click to deselect “[_1]”.",countryObj.name)}return LOCALE.maketext("Click to select “[_1]”.",countryObj.name)},getSelectAllToggleTitle:function getSelectAllToggleTitle(){return this.allAreSelected()?LOCALE.maketext("Click to deselect all countries."):LOCALE.maketext("Click to select all countries.")},toggleBlocked:function toggleBlocked(countryObject){if(countryObject.allowed){return $service.blockIncomingEmailFromCountries([countryObject.code]).then($scope._showBlockSuccessMessage.bind($scope,[countryObject.code])).then((function(){countryObject.allowed=false})).finally($scope.deselectAll).finally($scope.fetch)}else{return $service.unblockIncomingEmailFromCountries([countryObject.code]).then($scope._showUnblockSuccessMessage.bind($scope,[countryObject.code])).then((function(){countryObject.allowed=true})).finally($scope.deselectAll).finally($scope.fetch)}},getAriaLabel:function getAriaLabel(name,allowed){if(allowed){return LOCALE.maketext("Block email from “[_1]”.",name)}else{return LOCALE.maketext("Allow email from “[_1]”.",name)}},getTitleLabel:function getTitleLabel(name,allowed){if(allowed){return LOCALE.maketext("Your server currently accepts messages that originate from servers in [_1].",name)}else{return LOCALE.maketext("Your server currently blocks messages that originate from servers in [_1].",name)}},fetch:function fetch(){var filteredList=[];if($scope.meta.filterValue!==""){filteredList=filters.filter($scope.items,$scope.meta.filterValue,false)}else{filteredList=$scope.items}if($scope.meta.quickFilterValue!=="all"){filteredList=filters.filter(filteredList,{allowed:$scope.meta.quickFilterValue},false)}if($scope.meta.sortDirection!==""&&$scope.meta.sortBy!==""){filteredList=filters.orderBy(filteredList,$scope.meta.sortBy,$scope.meta.sortDirection==="asc"?false:true)}$scope.meta.totalItems=filteredList.length;$scope.filteredList=filteredList;return filteredList}});$scope.fetch()};var module=angular.module(MODULE_NAMESPACE,MODULE_REQUIREMENTS);module.directive(DIRECTIVE_NAME,(function directiveFactory(){return{templateUrl:TEMPLATE_PATH,restrict:"EA",scope:{items:"=",onChange:"&onChange"},replace:true,controller:CONTROLLER_INJECTABLES.concat(CONTROLLER)}}));return{class:CONTROLLER,namespace:MODULE_NAMESPACE,template:TEMPLATE_PATH}}));
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Generation time: 0.02 |
proxy
|
phpinfo
|
Settings