@@ -2793,65 +2793,15 @@ MdPanelPosition.prototype.addPanelPosition = function(xPosition, yPosition) {
2793
2793
'relative positioning. Set relativeTo first.' ) ;
2794
2794
}
2795
2795
2796
- this . _validateXPosition ( xPosition ) ;
2797
- this . _validateYPosition ( yPosition ) ;
2796
+ validatePosition ( MdPanelPosition . xPosition , xPosition ) ;
2797
+ validatePosition ( MdPanelPosition . yPosition , yPosition ) ;
2798
2798
2799
2799
this . _positions . push ( {
2800
- x : xPosition ,
2801
- y : yPosition ,
2800
+ x : xPosition ,
2801
+ y : yPosition
2802
2802
} ) ;
2803
- return this ;
2804
- } ;
2805
-
2806
-
2807
- /**
2808
- * Ensures that yPosition is a valid position name. Throw an exception if not.
2809
- * @param {string } yPosition
2810
- */
2811
- MdPanelPosition . prototype . _validateYPosition = function ( yPosition ) {
2812
- // empty is ok
2813
- if ( yPosition == null ) {
2814
- return ;
2815
- }
2816
-
2817
- var positionKeys = Object . keys ( MdPanelPosition . yPosition ) ;
2818
- var positionValues = [ ] ;
2819
- for ( var key , i = 0 ; key = positionKeys [ i ] ; i ++ ) {
2820
- var position = MdPanelPosition . yPosition [ key ] ;
2821
- positionValues . push ( position ) ;
2822
-
2823
- if ( position === yPosition ) {
2824
- return ;
2825
- }
2826
- }
2827
-
2828
- throw new Error ( 'mdPanel: Panel y position only accepts the following ' +
2829
- 'values:\n' + positionValues . join ( ' | ' ) ) ;
2830
- } ;
2831
-
2832
-
2833
- /**
2834
- * Ensures that xPosition is a valid position name. Throw an exception if not.
2835
- * @param {string } xPosition
2836
- */
2837
- MdPanelPosition . prototype . _validateXPosition = function ( xPosition ) {
2838
- // empty is ok
2839
- if ( xPosition == null ) {
2840
- return ;
2841
- }
2842
2803
2843
- var positionKeys = Object . keys ( MdPanelPosition . xPosition ) ;
2844
- var positionValues = [ ] ;
2845
- for ( var key , i = 0 ; key = positionKeys [ i ] ; i ++ ) {
2846
- var position = MdPanelPosition . xPosition [ key ] ;
2847
- positionValues . push ( position ) ;
2848
- if ( position === xPosition ) {
2849
- return ;
2850
- }
2851
- }
2852
-
2853
- throw new Error ( 'mdPanel: Panel x Position only accepts the following ' +
2854
- 'values:\n' + positionValues . join ( ' | ' ) ) ;
2804
+ return this ;
2855
2805
} ;
2856
2806
2857
2807
@@ -3553,6 +3503,33 @@ function getComputedTranslations(el, property) {
3553
3503
return output ;
3554
3504
}
3555
3505
3506
+ /*
3507
+ * Ensures that a value is a valid position name. Throw an exception if not.
3508
+ * @param {Object } positionMap Object against which the value will be checked.
3509
+ * @param {string } value
3510
+ */
3511
+ function validatePosition ( positionMap , value ) {
3512
+ // empty is ok
3513
+ if ( value === null || angular . isUndefined ( value ) ) {
3514
+ return ;
3515
+ }
3516
+
3517
+ var positionKeys = Object . keys ( positionMap ) ;
3518
+ var positionValues = [ ] ;
3519
+
3520
+ for ( var key , i = 0 ; key = positionKeys [ i ] ; i ++ ) {
3521
+ var position = positionMap [ key ] ;
3522
+ positionValues . push ( position ) ;
3523
+
3524
+ if ( position === value ) {
3525
+ return ;
3526
+ }
3527
+ }
3528
+
3529
+ throw new Error ( 'Panel position only accepts the following values:\n' +
3530
+ positionValues . join ( ' | ' ) ) ;
3531
+ }
3532
+
3556
3533
/**
3557
3534
* Adds units to a number value.
3558
3535
* @param {string|number } value
0 commit comments