Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

V8: Angular decoupling: isString #7929

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function fixNumber($parse) {

//always try to format the model value as an int
ctrl.$formatters.push(function (value) {
if (angular.isString(value)) {
if (Utilities.isString(value)) {
return parseFloat(value, 10);
}
return value;
Expand All @@ -55,4 +55,4 @@ function fixNumber($parse) {
}
};
}
angular.module('umbraco.directives').directive("fixNumber", fixNumber);
angular.module('umbraco.directives').directive("fixNumber", fixNumber);
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ angular.module("umbraco.directives")
}

var editorConfig = scope.configuration ? scope.configuration : null;
if (!editorConfig || angular.isString(editorConfig)) {
if (!editorConfig || Utilities.isString(editorConfig)) {
editorConfig = tinyMceService.defaultPrevalues();
//for the grid by default, we don't want to include the macro toolbar
editorConfig.toolbar = _.without(editorConfig, "umbmacro");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@

function configureViewModel(isInitLoad) {
if (vm.value) {
if (angular.isString(vm.value) && vm.value.length > 0) {
if (Utilities.isString(vm.value) && vm.value.length > 0) {
if (vm.config.storageType === "Json") {
//json storage
vm.viewModel = JSON.parse(vm.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function umbTreeDirective($q, $rootScope, treeService, notificationsService, use
* @param {any} args either a string representing the 'section' or an object containing: 'section', 'treeAlias', 'customTreeParams', 'cacheKey'
*/
function load(args) {
if (angular.isString(args)) {
if (Utilities.isString(args)) {
$scope.section = args;
}
else if (args) {
Expand Down Expand Up @@ -147,7 +147,7 @@ function umbTreeDirective($q, $rootScope, treeService, notificationsService, use
throw "args.path cannot be null";
}

if (angular.isString(args.path)) {
if (Utilities.isString(args.path)) {
args.path = args.path.replace('"', '').split(',');
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
}

// Basic options
if (angular.isString(opts.theme)) {
if (Utilities.isString(opts.theme)) {
acee.setTheme('ace/theme/' + opts.theme);
}
if (angular.isString(opts.mode)) {
if (Utilities.isString(opts.mode)) {
session.setMode('ace/mode/' + opts.mode);
}
// Advanced options
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
function umbWordLimitFilter() {
return function (collection, property) {

if (!angular.isString(collection)) {
if (!Utilities.isString(collection)) {
return collection;
}

Expand All @@ -35,4 +35,4 @@

angular.module('umbraco.filters').filter('umbWordLimit', umbWordLimitFilter);

})();
})();
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ function contentResource($q, $http, umbDataFormatter, umbRequestHelper) {
if (Utilities.isNumber(v)) {
return v > 0;
}
if (angular.isString(v)) {
if (Utilities.isString(v)) {
return v === "true";
}
if (typeof v === "boolean") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ function mediaResource($q, $http, umbDataFormatter, umbRequestHelper) {
if (Utilities.isNumber(v)) {
return v > 0;
}
if (angular.isString(v)) {
if (Utilities.isString(v)) {
return v === "true";
}
if (typeof v === "boolean") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function memberResource($q, $http, umbDataFormatter, umbRequestHelper) {
if (Utilities.isNumber(v)) {
return v > 0;
}
if (angular.isString(v)) {
if (Utilities.isString(v)) {
return v === "true";
}
if (typeof v === "boolean") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function fileManager($rootScope) {
setFiles: function (args) {

//propertyAlias, files
if (!angular.isString(args.propertyAlias)) {
if (!Utilities.isString(args.propertyAlias)) {
throw "args.propertyAlias must be a non empty string";
}
if (!Utilities.isObject(args.files)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function macroService() {
val = val ? val : "";
//need to detect if the val is a string or an object
var keyVal;
if (angular.isString(val)) {
if (Utilities.isString(val)) {
keyVal = key + "=\"" + (val ? val : "") + "\" ";
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ function mediaHelper(umbRequestHelper, $log) {

//this performs a simple check to see if we have a media file as value
//it doesnt catch everything, but better then nothing
if (angular.isString(item.value) && item.value.indexOf(mediaRoot) === 0) {
if (Utilities.isString(item.value) && item.value.indexOf(mediaRoot) === 0) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
* @param {any} requestPath
*/
function pathToRouteParts(requestPath) {
if (!angular.isString(requestPath)) {
if (!Utilities.isString(requestPath)) {
throw "The value for requestPath is not a string";
}
var pathAndQuery = requestPath.split("#")[1];
Expand Down Expand Up @@ -130,11 +130,11 @@ function navigationService($routeParams, $location, $q, $injector, eventsService
*/
isRouteChangingNavigation: function (currUrlParams, nextUrlParams) {

if (angular.isString(currUrlParams)) {
if (Utilities.isString(currUrlParams)) {
currUrlParams = pathToRouteParts(currUrlParams);
}

if (angular.isString(nextUrlParams)) {
if (Utilities.isString(nextUrlParams)) {
nextUrlParams = pathToRouteParts(nextUrlParams);
}

Expand Down Expand Up @@ -483,14 +483,14 @@ function navigationService($routeParams, $location, $q, $injector, eventsService

appState.setMenuState("currentNode", node);

if (action.metaData && action.metaData["actionRoute"] && angular.isString(action.metaData["actionRoute"])) {
if (action.metaData && action.metaData["actionRoute"] && Utilities.isString(action.metaData["actionRoute"])) {
//first check if the menu item simply navigates to a route
var parts = action.metaData["actionRoute"].split("?");
$location.path(parts[0]).search(parts.length > 1 ? parts[1] : "");
this.hideNavigation();
return;
}
else if (action.metaData && action.metaData["jsAction"] && angular.isString(action.metaData["jsAction"])) {
else if (action.metaData && action.metaData["jsAction"] && Utilities.isString(action.metaData["jsAction"])) {

//we'll try to get the jsAction from the injector
var menuAction = action.metaData["jsAction"].split('.');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function serverValidationManager($timeout) {
}

function getFieldErrors(self, fieldName) {
if (!angular.isString(fieldName)) {
if (!Utilities.isString(fieldName)) {
throw "fieldName must be a string";
}

Expand All @@ -36,10 +36,10 @@ function serverValidationManager($timeout) {
}

function getPropertyErrors(self, propertyAlias, culture, fieldName) {
if (!angular.isString(propertyAlias)) {
if (!Utilities.isString(propertyAlias)) {
throw "propertyAlias must be a string";
}
if (fieldName && !angular.isString(fieldName)) {
if (fieldName && !Utilities.isString(fieldName)) {
throw "fieldName must be a string";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
var currGroups = saveModel.userGroups;
var formattedGroups = [];
for (var i = 0; i < currGroups.length; i++) {
if (!angular.isString(currGroups[i])) {
if (!Utilities.isString(currGroups[i])) {
formattedGroups.push(currGroups[i].alias);
}
else {
Expand Down Expand Up @@ -229,7 +229,7 @@
var currSections = saveModel.sections;
var formattedSections = [];
for (var i = 0; i < currSections.length; i++) {
if (!angular.isString(currSections[i])) {
if (!Utilities.isString(currSections[i])) {
formattedSections.push(currSections[i].alias);
}
else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
}

return Umbraco.Sys.ServerVariables["umbracoUrls"][apiName] + actionName +
(!queryStrings ? "" : "?" + (angular.isString(queryStrings) ? queryStrings : this.dictionaryToQueryString(queryStrings)));
(!queryStrings ? "" : "?" + (Utilities.isString(queryStrings) ? queryStrings : this.dictionaryToQueryString(queryStrings)));

},

Expand Down Expand Up @@ -129,7 +129,7 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe

var err = {
//NOTE: the default error message here should never be used based on the above docs!
errorMsg: (angular.isString(opts) ? opts : 'An error occurred!'),
errorMsg: (Utilities.isString(opts) ? opts : 'An error occurred!'),
data: data,
status: status
};
Expand Down Expand Up @@ -342,11 +342,11 @@ function umbRequestHelper($http, $q, notificationsService, eventsService, formHe
//add the json data
if (angular.isArray(data)) {
_.each(data, function(item) {
formData.append(item.key, !angular.isString(item.value) ? Utilities.toJson(item.value) : item.value);
formData.append(item.key, !Utilities.isString(item.value) ? Utilities.toJson(item.value) : item.value);
});
}
else {
formData.append(data.key, !angular.isString(data.value) ? Utilities.toJson(data.value) : data.value);
formData.append(data.key, !Utilities.isString(data.value) ? Utilities.toJson(data.value) : data.value);
}

//call the callback
Expand Down
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/src/navigation.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ function NavigationController($scope, $rootScope, $location, $log, $q, $routePar
args.event.stopPropagation();
args.event.preventDefault();

if (n.metaData && n.metaData["jsClickCallback"] && angular.isString(n.metaData["jsClickCallback"]) && n.metaData["jsClickCallback"] !== "") {
if (n.metaData && n.metaData["jsClickCallback"] && Utilities.isString(n.metaData["jsClickCallback"]) && n.metaData["jsClickCallback"] !== "") {
//this is a legacy tree node!
var jsPrefix = "javascript:";
var js;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -739,7 +739,7 @@ angular.module("umbraco")
//if nothing is found, set it to 12
if (!$scope.model.config.items.columns) {
$scope.model.config.items.columns = 12;
} else if (angular.isString($scope.model.config.items.columns)) {
} else if (Utilities.isString($scope.model.config.items.columns)) {
$scope.model.config.items.columns = parseInt($scope.model.config.items.columns);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ angular.module('umbraco')
//move previously saved value to the editor
if ($scope.model.value) {
//backwards compat with the old file upload (incase some-one swaps them..)
if (angular.isString($scope.model.value)) {
if (Utilities.isString($scope.model.value)) {
setModelValueWithSrc($scope.model.value);
}
else {
Expand Down Expand Up @@ -232,7 +232,7 @@ angular.module('umbraco')

//this is a fallback in case the cropper has been asssigned a upload field
}
else if (angular.isString(property.value)) {
else if (Utilities.isString(property.value)) {
if (thumbnail) {

if (mediaHelper.detectIfImageByExtension(property.value)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ function listViewController($scope, $interpolate, $routeParams, $injector, $time
}

function isDate(val) {
if (angular.isString(val)) {
if (Utilities.isString(val)) {
return val.match(/^(\d{4})\-(\d{2})\-(\d{2})\ (\d{2})\:(\d{2})\:(\d{2})$/);
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ angular.module("umbraco")
$scope.textAreaHtmlId = $scope.model.alias + "_" + String.CreateGuid();

var editorConfig = $scope.model.config ? $scope.model.config.editor : null;
if (!editorConfig || angular.isString(editorConfig)) {
if (!editorConfig || Utilities.isString(editorConfig)) {
editorConfig = tinyMceService.defaultPrevalues();
}
//make sure there's a max image size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ angular.module("umbraco").controller("Umbraco.PrevalueEditors.RteController",
var cfg = tinyMceService.defaultPrevalues();

if($scope.model.value){
if(angular.isString($scope.model.value)){
if(Utilities.isString($scope.model.value)){
$scope.model.value = cfg;
}
}else{
Expand Down
8 changes: 4 additions & 4 deletions src/Umbraco.Web.UI.Client/test/lib/angular/angular-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ angular.mock.$Browser.prototype = {
if (value == undefined) {
delete this.cookieHash[name];
} else {
if (angular.isString(value) && //strings only
if (Utilities.isString(value) && //strings only
value.length <= 4096) { //strict cookie storage limits
this.cookieHash[name] = value;
}
Expand Down Expand Up @@ -486,7 +486,7 @@ angular.mock.$LogProvider = function () {
*/
angular.mock.TzDate = function (offset, timestamp) {
var self = new Date(0);
if (angular.isString(timestamp)) {
if (Utilities.isString(timestamp)) {
var tsStr = timestamp;

self.origDate = jsonStringToDate(timestamp);
Expand Down Expand Up @@ -943,7 +943,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
wasExpected = false;

function prettyPrint(data) {
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
return (Utilities.isString(data) || angular.isFunction(data) || data instanceof RegExp)
? data
: angular.toJson(data);
}
Expand Down Expand Up @@ -1385,7 +1385,7 @@ function MockHttpExpectation(method, url, data, headers) {
this.matchData = function (d) {
if (angular.isUndefined(data)) return true;
if (data && angular.isFunction(data.test)) return data.test(d);
if (data && !angular.isString(data)) return angular.toJson(data) == d;
if (data && !Utilities.isString(data)) return angular.toJson(data) == d;
return data == d;
};

Expand Down