Merge remote-tracking branch 'origin/master' into search1093-b
Conflicts: platform/search/res/templates/search.html
This commit is contained in:
@@ -259,7 +259,7 @@ define([
|
||||
"implementation": ClickAwayController,
|
||||
"depends": [
|
||||
"$document",
|
||||
"$scope"
|
||||
"$timeout"
|
||||
]
|
||||
},
|
||||
{
|
||||
@@ -381,7 +381,7 @@ define([
|
||||
{
|
||||
"key": "mctTree",
|
||||
"implementation": MCTTree,
|
||||
"depends": ['$parse', 'gestureService']
|
||||
"depends": ['gestureService']
|
||||
}
|
||||
],
|
||||
"constants": [
|
||||
|
||||
@@ -34,7 +34,7 @@ define(
|
||||
* @param $scope the scope in which this controller is active
|
||||
* @param $document the document element, injected by Angular
|
||||
*/
|
||||
function ClickAwayController($document, $scope) {
|
||||
function ClickAwayController($document, $timeout) {
|
||||
var self = this;
|
||||
|
||||
this.state = false;
|
||||
@@ -44,7 +44,7 @@ define(
|
||||
// `clickaway` action occurs after `toggle` if `toggle` is
|
||||
// triggered by a click/mouseup.
|
||||
this.clickaway = function () {
|
||||
$scope.$apply(function () {
|
||||
$timeout(function () {
|
||||
self.deactivate();
|
||||
});
|
||||
};
|
||||
|
||||
@@ -33,6 +33,8 @@ define(
|
||||
*/
|
||||
function ToggleController() {
|
||||
this.state = false;
|
||||
|
||||
this.setState = this.setState.bind(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,20 +24,17 @@ define([
|
||||
'angular',
|
||||
'../ui/TreeView'
|
||||
], function (angular, TreeView) {
|
||||
function MCTTree($parse, gestureService) {
|
||||
function link(scope, element, attrs) {
|
||||
function MCTTree(gestureService) {
|
||||
function link(scope, element) {
|
||||
var treeView = new TreeView(gestureService),
|
||||
expr = $parse(attrs.mctModel),
|
||||
unobserve = treeView.observe(function (domainObject) {
|
||||
if (domainObject !== expr(scope.$parent)) {
|
||||
expr.assign(scope.$parent, domainObject);
|
||||
scope.$apply();
|
||||
}
|
||||
scope.mctModel = domainObject;
|
||||
scope.$apply();
|
||||
});
|
||||
|
||||
element.append(angular.element(treeView.elements()));
|
||||
|
||||
scope.$parent.$watch(attrs.mctModel, treeView.value.bind(treeView));
|
||||
scope.$watch('mctModel', treeView.value.bind(treeView));
|
||||
scope.$watch('mctObject', treeView.model.bind(treeView));
|
||||
scope.$on('$destroy', unobserve);
|
||||
}
|
||||
@@ -45,7 +42,7 @@ define([
|
||||
return {
|
||||
restrict: "E",
|
||||
link: link,
|
||||
scope: { mctObject: "=" }
|
||||
scope: { mctObject: "=", mctModel: "=" }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ define(
|
||||
|
||||
describe("The click-away controller", function () {
|
||||
var mockDocument,
|
||||
mockScope,
|
||||
mockTimeout,
|
||||
controller;
|
||||
|
||||
beforeEach(function () {
|
||||
@@ -34,11 +34,10 @@ define(
|
||||
"$document",
|
||||
["on", "off"]
|
||||
);
|
||||
mockScope = jasmine.createSpyObj('$scope', ['$apply']);
|
||||
|
||||
mockTimeout = jasmine.createSpy('timeout');
|
||||
controller = new ClickAwayController(
|
||||
mockDocument,
|
||||
mockScope
|
||||
mockTimeout
|
||||
);
|
||||
});
|
||||
|
||||
@@ -78,15 +77,18 @@ define(
|
||||
});
|
||||
|
||||
it("deactivates and detaches listener on document click", function () {
|
||||
var callback, apply;
|
||||
var callback, timeout;
|
||||
controller.setState(true);
|
||||
callback = mockDocument.on.mostRecentCall.args[1];
|
||||
callback();
|
||||
apply = mockScope.$apply.mostRecentCall.args[0];
|
||||
apply();
|
||||
timeout = mockTimeout.mostRecentCall.args[0];
|
||||
timeout();
|
||||
expect(controller.isActive()).toEqual(false);
|
||||
expect(mockDocument.off).toHaveBeenCalledWith("mouseup", callback);
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
@@ -46,8 +46,8 @@ define([
|
||||
expect(mctTree.restrict).toEqual("E");
|
||||
});
|
||||
|
||||
it("two-way binds to mctObject", function () {
|
||||
expect(mctTree.scope).toEqual({ mctObject: "=" });
|
||||
it("two-way binds to mctObject and mctModel", function () {
|
||||
expect(mctTree.scope).toEqual({ mctObject: "=", mctModel: "=" });
|
||||
});
|
||||
|
||||
describe("link", function () {
|
||||
@@ -69,8 +69,8 @@ define([
|
||||
});
|
||||
|
||||
it("watches for mct-model's expression in the parent", function () {
|
||||
expect(mockScope.$parent.$watch).toHaveBeenCalledWith(
|
||||
testAttrs.mctModel,
|
||||
expect(mockScope.$watch).toHaveBeenCalledWith(
|
||||
"mctModel",
|
||||
jasmine.any(Function)
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user