From 2430f52bb97fa9d682e5f028c977c5bf94c5ec38 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 23 Mar 2012 14:03:24 -0700 Subject: chore(module): move files around in preparation for more modules --- src/directive/ngSwitch.js | 112 ---------------------------------------------- 1 file changed, 112 deletions(-) delete mode 100644 src/directive/ngSwitch.js (limited to 'src/directive/ngSwitch.js') diff --git a/src/directive/ngSwitch.js b/src/directive/ngSwitch.js deleted file mode 100644 index 16b0c4d4..00000000 --- a/src/directive/ngSwitch.js +++ /dev/null @@ -1,112 +0,0 @@ -'use strict'; - -/** - * @ngdoc directive - * @name angular.module.ng.$compileProvider.directive.ng-switch - * @restrict EA - * - * @description - * Conditionally change the DOM structure. - * - * @usageContent - * ... - * ... - * ... - * ... - * - * @scope - * @param {*} ng-switch|on expression to match against ng-switch-when. - * @paramDescription - * On child elments add: - * - * * `ng-switch-when`: the case statement to match against. If match then this - * case will be displayed. - * * `ng-switch-default`: the default case when no other casses match. - * - * @example - - - -
- - selection={{selection}} -
-
-
Settings Div
- Home Span - default -
-
-
- - it('should start in settings', function() { - expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Settings Div/); - }); - it('should change to home', function() { - select('selection').option('home'); - expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Home Span/); - }); - it('should select deafault', function() { - select('selection').option('other'); - expect(element('.doc-example-live [ng-switch]').text()).toMatch(/default/); - }); - -
- */ -var NG_SWITCH = 'ng-switch'; -var ngSwitchDirective = valueFn({ - restrict: 'EA', - compile: function(element, attr) { - var watchExpr = attr.ngSwitch || attr.on, - cases = {}; - - element.data(NG_SWITCH, cases); - return function(scope, element){ - var selectedTransclude, - selectedElement, - selectedScope; - - scope.$watch(watchExpr, function(value) { - if (selectedElement) { - selectedScope.$destroy(); - selectedElement.remove(); - selectedElement = selectedScope = null; - } - if ((selectedTransclude = cases['!' + value] || cases['?'])) { - scope.$eval(attr.change); - selectedScope = scope.$new(); - selectedTransclude(selectedScope, function(caseElement) { - selectedElement = caseElement; - element.append(caseElement); - }); - } - }); - }; - } -}); - -var ngSwitchWhenDirective = ngDirective({ - transclude: 'element', - priority: 500, - compile: function(element, attrs, transclude) { - var cases = element.inheritedData(NG_SWITCH); - assertArg(cases); - cases['!' + attrs.ngSwitchWhen] = transclude; - } -}); - -var ngSwitchDefaultDirective = ngDirective({ - transclude: 'element', - priority: 500, - compile: function(element, attrs, transclude) { - var cases = element.inheritedData(NG_SWITCH); - assertArg(cases); - cases['?'] = transclude; - } -}); -- cgit v1.2.3