V8: Angular Divorce: isFunction (#7861)
* Bye bye angular.isFunction & use Utilities.isFunction * Utilities.js is not available on first load - replace isFunction detection with underscore equivalent * found a stray isFunction Co-authored-by: Kenn Jacobsen <post@kennjacobsen.dk> Co-authored-by: Nathan Woulfe <nathan@nathanw.com.au>
This commit is contained in:
@@ -91,6 +91,6 @@ angular.module("umbraco.viewcache", [])
|
||||
// be able to configure angular values in the Default.cshtml
|
||||
// view which is much easier to do that configuring values by injecting them in the back office controller
|
||||
// to follow through to the js initialization stuff
|
||||
if (angular.isFunction(document.angularReady)) {
|
||||
if (_.isFunction(document.angularReady)) {
|
||||
document.angularReady.apply(this, [app]);
|
||||
}
|
||||
|
||||
@@ -409,8 +409,8 @@ function umbTreeDirective($q, $rootScope, treeService, notificationsService, use
|
||||
//load the tree
|
||||
loadTree().then(function () {
|
||||
//because angular doesn't return a promise for the resolve method, we need to resort to some hackery, else
|
||||
//like normal JS promises we could do resolve(...).then()
|
||||
if (args && args.onLoaded && angular.isFunction(args.onLoaded)) {
|
||||
//like normal JS promises we could do resolve(...).then()
|
||||
if (args && args.onLoaded && Utilities.isFunction(args.onLoaded)) {
|
||||
args.onLoaded();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -82,7 +82,7 @@
|
||||
if (Utilities.isDefined(opts.firstLineNumber)) {
|
||||
if (Utilities.isNumber(opts.firstLineNumber)) {
|
||||
session.setOption('firstLineNumber', opts.firstLineNumber);
|
||||
} else if (angular.isFunction(opts.firstLineNumber)) {
|
||||
} else if (Utilities.isFunction(opts.firstLineNumber)) {
|
||||
session.setOption('firstLineNumber', opts.firstLineNumber());
|
||||
}
|
||||
}
|
||||
@@ -116,7 +116,7 @@
|
||||
|
||||
// onLoad callbacks
|
||||
angular.forEach(opts.callbacks, function(cb) {
|
||||
if (angular.isFunction(cb)) {
|
||||
if (Utilities.isFunction(cb)) {
|
||||
cb(acee);
|
||||
}
|
||||
});
|
||||
@@ -208,7 +208,7 @@
|
||||
|
||||
if (Utilities.isDefined(callback)) {
|
||||
scope.$evalAsync(function() {
|
||||
if (angular.isFunction(callback)) {
|
||||
if (Utilities.isFunction(callback)) {
|
||||
callback(args);
|
||||
} else {
|
||||
throw new Error('ui-ace use a function as callback.');
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
|
||||
// advanced item filtering is handled here
|
||||
if (scope.entityTypeFilter && scope.entityTypeFilter.filter && scope.entityTypeFilter.filterAdvanced) {
|
||||
var filtered = angular.isFunction(scope.entityTypeFilter.filter)
|
||||
var filtered = Utilities.isFunction(scope.entityTypeFilter.filter)
|
||||
? _.filter(miniListView.children, scope.entityTypeFilter.filter)
|
||||
: _.where(miniListView.children, scope.entityTypeFilter.filter);
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ function valPropertyValidator(serverValidationManager) {
|
||||
|
||||
var modelCtrl = ctrls[0];
|
||||
var propCtrl = ctrls.length > 1 ? ctrls[1] : null;
|
||||
|
||||
// Check whether the scope has a valPropertyValidator method
|
||||
if (!scope.valPropertyValidator || !angular.isFunction(scope.valPropertyValidator)) {
|
||||
|
||||
// Check whether the scope has a valPropertyValidator method
|
||||
if (!scope.valPropertyValidator || !Utilities.isFunction(scope.valPropertyValidator)) {
|
||||
throw new Error('val-property-validator directive must specify a function to call');
|
||||
}
|
||||
|
||||
|
||||
@@ -147,12 +147,12 @@ function angularHelper($q) {
|
||||
*/
|
||||
safeApply: function (scope, fn) {
|
||||
if (scope.$$phase || (scope.$root && scope.$root.$$phase)) {
|
||||
if (angular.isFunction(fn)) {
|
||||
if (Utilities.isFunction(fn)) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (angular.isFunction(fn)) {
|
||||
if (Utilities.isFunction(fn)) {
|
||||
scope.$apply(fn);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -589,7 +589,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
//instead of having a property editor $watch their expression to check if it has
|
||||
// been updated, instead we'll check for the existence of a special method on their model
|
||||
// and just call it.
|
||||
if (angular.isFunction(origProp.onValueChanged)) {
|
||||
if (Utilities.isFunction(origProp.onValueChanged)) {
|
||||
//send the newVal + oldVal
|
||||
origProp.onValueChanged(origProp.value, origVal);
|
||||
}
|
||||
@@ -643,7 +643,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).
|
||||
|
||||
// In this case we need to detect what properties have changed and re-bind them with the server data.
|
||||
if (args.rebindCallback && angular.isFunction(args.rebindCallback)) {
|
||||
if (args.rebindCallback && Utilities.isFunction(args.rebindCallback)) {
|
||||
args.rebindCallback();
|
||||
}
|
||||
|
||||
@@ -690,7 +690,7 @@ function contentEditingHelper(fileManager, $q, $location, $routeParams, editorSt
|
||||
// soft-redirecting which means the URL will change but the route wont (i.e. creating content).
|
||||
|
||||
// In this case we need to detect what properties have changed and re-bind them with the server data.
|
||||
if (args.rebindCallback && angular.isFunction(args.rebindCallback)) {
|
||||
if (args.rebindCallback && Utilities.isFunction(args.rebindCallback)) {
|
||||
args.rebindCallback();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ function eventsService($q, $rootScope) {
|
||||
|
||||
/** pass in the result of 'on' to this method, or just call the method returned from 'on' to unsubscribe */
|
||||
unsubscribe: function(handle) {
|
||||
if (angular.isFunction(handle)) {
|
||||
if (Utilities.isFunction(handle)) {
|
||||
handle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (args.filter && angular.isFunction(args.filter)) {
|
||||
else if (args.filter && Utilities.isFunction(args.filter)) {
|
||||
//if a filter is supplied a cacheKey must be supplied as well
|
||||
if (!args.cacheKey) {
|
||||
throw "args.cacheKey is required if args.filter is supplied";
|
||||
@@ -315,7 +315,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
args.node.hasChildren = true;
|
||||
|
||||
//Since we've removed the children & reloaded them, we need to refresh the UI now because the tree node UI doesn't operate on normal angular $watch since that will be pretty slow
|
||||
if (angular.isFunction(args.node.updateNodeData)) {
|
||||
if (Utilities.isFunction(args.node.updateNodeData)) {
|
||||
args.node.updateNodeData(args.node);
|
||||
}
|
||||
}
|
||||
@@ -349,7 +349,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
* @param {object} treeNode the node to remove
|
||||
*/
|
||||
removeNode: function (treeNode) {
|
||||
if (!angular.isFunction(treeNode.parent)) {
|
||||
if (!Utilities.isFunction(treeNode.parent)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -509,7 +509,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (current.metaData && current.metaData["treeAlias"]) {
|
||||
root = current;
|
||||
}
|
||||
else if (angular.isFunction(current.parent)) {
|
||||
else if (Utilities.isFunction(current.parent)) {
|
||||
//we can only continue if there is a parent() method which means this
|
||||
// tree node was loaded in as part of a real tree, not just as a single tree
|
||||
// node from the server.
|
||||
@@ -706,7 +706,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
//to fire, instead we're just going to replace all the properties of this node.
|
||||
|
||||
//there should always be a method assigned but we'll check anyways
|
||||
if (angular.isFunction(node.parent().children[index].updateNodeData)) {
|
||||
if (Utilities.isFunction(node.parent().children[index].updateNodeData)) {
|
||||
node.parent().children[index].updateNodeData(found);
|
||||
}
|
||||
else {
|
||||
@@ -741,7 +741,7 @@ function treeService($q, treeResource, iconHelper, notificationsService, eventsS
|
||||
if (!node) {
|
||||
throw "node cannot be null";
|
||||
}
|
||||
if (!angular.isFunction(node.parent)) {
|
||||
if (!Utilities.isFunction(node.parent)) {
|
||||
throw "node.parent is not a function, the path cannot be resolved";
|
||||
}
|
||||
|
||||
|
||||
@@ -85,12 +85,12 @@ angular.module("umbraco.install").factory('installerService', function ($rootSco
|
||||
/** Have put this here because we are not referencing our other modules */
|
||||
function safeApply (scope, fn) {
|
||||
if (scope.$$phase || scope.$root.$$phase) {
|
||||
if (angular.isFunction(fn)) {
|
||||
if (Utilities.isFunction(fn)) {
|
||||
fn();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (angular.isFunction(fn)) {
|
||||
if (Utilities.isFunction(fn)) {
|
||||
scope.$apply(fn);
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -173,7 +173,7 @@ angular.module("umbraco").controller("Umbraco.Editors.TreePickerController",
|
||||
$scope.model.filterAdvanced = false;
|
||||
|
||||
//used advanced filtering
|
||||
if (angular.isFunction($scope.model.filter)) {
|
||||
if (Utilities.isFunction($scope.model.filter)) {
|
||||
$scope.model.filterAdvanced = true;
|
||||
}
|
||||
else if (Utilities.isObject($scope.model.filter)) {
|
||||
@@ -189,9 +189,9 @@ angular.module("umbraco").controller("Umbraco.Editors.TreePickerController",
|
||||
if ($scope.model.filter.startsWith("{")) {
|
||||
$scope.model.filterAdvanced = true;
|
||||
|
||||
if ($scope.model.filterByMetadata && !angular.isFunction($scope.model.filter))
|
||||
if ($scope.model.filterByMetadata && !Utilities.isFunction($scope.model.filter))
|
||||
{
|
||||
var filter = angular.fromJson($scope.model.filter);
|
||||
var filter = Utilities.fromJson($scope.model.filter);
|
||||
$scope.model.filter = function (node){ return _.isMatch(node.metaData, filter);};
|
||||
}
|
||||
else
|
||||
@@ -456,7 +456,7 @@ angular.module("umbraco").controller("Umbraco.Editors.TreePickerController",
|
||||
if ($scope.model.filterAdvanced) {
|
||||
|
||||
//filter either based on a method or an object
|
||||
var filtered = angular.isFunction($scope.model.filter)
|
||||
var filtered = Utilities.isFunction($scope.model.filter)
|
||||
? _.filter(nodes, $scope.model.filter)
|
||||
: _.where(nodes, $scope.model.filter);
|
||||
|
||||
|
||||
@@ -699,7 +699,7 @@ angular.mock.dump = function (object) {
|
||||
});
|
||||
out = '[ ' + out.join(', ') + ' ]';
|
||||
} else if (Utilities.isObject(object)) {
|
||||
if (angular.isFunction(object.$eval) && angular.isFunction(object.$apply)) {
|
||||
if (Utilities.isFunction(object.$eval) && Utilities.isFunction(object.$apply)) {
|
||||
out = serializeScope(object);
|
||||
} else if (object instanceof Error) {
|
||||
out = object.stack || ('' + object.name + ': ' + object.message);
|
||||
@@ -927,7 +927,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
responsesPush = angular.bind(responses, responses.push);
|
||||
|
||||
function createResponse(status, data, headers) {
|
||||
if (angular.isFunction(status)) return status;
|
||||
if (Utilities.isFunction(status)) return status;
|
||||
|
||||
return function () {
|
||||
return angular.isNumber(status)
|
||||
@@ -943,7 +943,7 @@ function createHttpBackendMock($rootScope, $delegate, $browser) {
|
||||
wasExpected = false;
|
||||
|
||||
function prettyPrint(data) {
|
||||
return (Utilities.isString(data) || angular.isFunction(data) || data instanceof RegExp)
|
||||
return (Utilities.isString(data) || Utilities.isFunction(data) || data instanceof RegExp)
|
||||
? data
|
||||
: angular.toJson(data);
|
||||
}
|
||||
@@ -1372,20 +1372,20 @@ function MockHttpExpectation(method, url, data, headers) {
|
||||
|
||||
this.matchUrl = function (u) {
|
||||
if (!url) return true;
|
||||
if (angular.isFunction(url.test)) return url.test(u);
|
||||
if (Utilities.isFunction(url.test)) return url.test(u);
|
||||
return url == u;
|
||||
};
|
||||
|
||||
this.matchHeaders = function (h) {
|
||||
if (Utilities.isUndefined(headers)) return true;
|
||||
if (angular.isFunction(headers)) return headers(h);
|
||||
if (Utilities.isFunction(headers)) return headers(h);
|
||||
return Utilities.equals(headers, h);
|
||||
};
|
||||
|
||||
this.matchData = function (d) {
|
||||
if (Utilities.isUndefined(data)) return true;
|
||||
if (data && angular.isFunction(data.test)) return data.test(d);
|
||||
if (data && !Utilities.isString(data)) return angular.toJson(data) == d;
|
||||
if (data && Utilities.isFunction(data.test)) return data.test(d);
|
||||
if (data && !Utilities.isString(data)) return Utilities.toJson(data) == d;
|
||||
return data == d;
|
||||
};
|
||||
|
||||
@@ -1484,7 +1484,7 @@ angular.mock.$TimeoutDecorator = function ($delegate, $browser) {
|
||||
|
||||
function formatPendingTasksAsString(tasks) {
|
||||
var result = [];
|
||||
angular.forEach(tasks, function (task) {
|
||||
Utilities.forEach(tasks, function (task) {
|
||||
result.push('{id: ' + task.id + ', ' + 'time: ' + task.time + '}');
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user