Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / resources / themes / stylesheets / ext4 / default / mixins / _inner-border.scss
1 @function inner-border-spread($width) {
2     $top: top($width);
3     $right: right($width);
4     $bottom: bottom($width);
5     $left: left($width);
6     
7     @return min(($top + $bottom) / 2, ($left + $right) / 2);
8 }
9
10 @function inner-border-hoff($width, $spread) {
11     $left: left($width); 
12     $right: right($width);
13
14     @if $right <= 0 {
15         @return $left - $spread;
16     }
17     @else {
18         @return $spread - $right;
19     }
20 }
21
22 @function inner-border-voff($width, $spread) {
23     $top: top($width);
24     $bottom: bottom($width);
25
26     @if $bottom <= 0 {
27         @return $top - $spread;
28     }
29     @else {
30         @return $spread - $bottom;
31     }
32 }
33
34 @function even($number) {
35     @return ceil($number / 2) == ($number / 2);
36 }
37
38 @function odd($number) {
39     @return ceil($number / 2) != ($number / 2);
40 }
41
42 @function inner-border-usesingle-width($width) {
43     $top: top($width);
44     $right: right($width);
45     $bottom: bottom($width);
46     $left: left($width);
47         
48     @if $top == 0 {
49         @if $left + $right == 0 {
50             @return true;
51         }
52         @if $bottom >= $left + $right {
53             @return true;
54         }
55     }
56     
57     @if $bottom == 0 {
58         @if $left + $right == 0 {
59             @return true;
60         }
61         @if $top >= $left + $right {
62             @return true;
63         }
64     }
65     
66     @if $left == 0 {
67         @if $top + $bottom == 0 {
68             @return true;
69         }
70         @if $right >= $top + $bottom {
71             @return true;
72         }
73     }
74     
75     @if $right == 0 {
76         @if $top + $bottom == 0 {
77             @return true;
78         }
79         @if $left >= $top + $bottom {
80             @return true;
81         }
82     }
83     
84     @if $top + $bottom == $left + $right and even($top) == even($bottom) and even($left) == even($right) {
85         @return true;
86     }
87     
88     @return false;
89 }
90
91 @function inner-border-usesingle-color($color) {
92     $top: top($color);
93     $right: right($color);
94     $bottom: bottom($color);
95     $left: left($color);
96     
97     @if $top == $right == $bottom == $left {
98         @return true;
99     }
100     
101     @return false;
102 }
103
104 @function inner-border-usesingle($width, $color) {
105     @if inner-border-usesingle-color($color) and inner-border-usesingle-width($width) {
106         @return true;
107     }
108     @return false;
109 }
110
111 @mixin inner-border($width: 1px, $color: #fff, $blur: 0px) {
112     @if inner-border-usesingle($width, $color) {
113         $spread: inner-border-spread($width);
114         $hoff: inner-border-hoff($width, $spread);
115         $voff: inner-border-voff($width, $spread);
116         @include single-box-shadow($color-top, $hoff, $voff, $blur, $spread, true);
117     }
118     @else {
119         $width-top: top($width);
120         $width-right: right($width);
121         $width-bottom: bottom($width);
122         $width-left: left($width);
123
124         $color-top: top($color);
125         $color-right: right($color);
126         $color-bottom: bottom($color);
127         $color-left: left($color);
128         
129         $shadow-top: false;
130         $shadow-right: false;
131         $shadow-bottom: false;
132         $shadow-left: false;
133         
134         @if $width-top > 0 {
135             $shadow-top: $color-top 0 $width-top $blur 0 inset;
136         }
137         @if $width-right > 0 {
138             $shadow-right: $color-right (-1 * $width-right) 0 $blur 0 inset;
139         }
140         @if $width-bottom > 0 {
141             $shadow-bottom: $color-bottom 0 (-1 * $width-bottom) $blur 0 inset;
142         }
143         @if $width-left > 0 {
144             $shadow-left: $color-left $width-left 0 $blur 0 inset;
145         }
146                 
147         @include box-shadow($shadow-top, $shadow-bottom, $shadow-right, $shadow-left);
148     }
149 }