_frame.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. @function pad($radius) {
  2. $radius: boxmax($radius);
  3. $radius: parseint($radius);
  4. @if $radius >= 10 {
  5. @return $radius;
  6. }
  7. @else {
  8. @return "0" + $radius;
  9. }
  10. }
  11. @mixin x-frame(
  12. $cls,
  13. $ui: null,
  14. $border-radius: 0px,
  15. $border-width: 0px,
  16. $padding: null,
  17. $background-color: null,
  18. $background-gradient: null,
  19. $table: false,
  20. $background-direction: top
  21. ) {
  22. $cls-ui: $cls;
  23. @if $ui != null {
  24. $cls-ui: $cls + '-' + $ui;
  25. }
  26. $vertical: false;
  27. @if $background-direction == left or $background-direction == right {
  28. $vertical: true;
  29. }
  30. $frame-top: max(top($border-radius), right($border-radius));
  31. $frame-right: max(right($border-radius), bottom($border-radius));
  32. $frame-bottom: max(bottom($border-radius), left($border-radius));
  33. $frame-left: max(left($border-radius), top($border-radius));
  34. $padding-top: 0;
  35. $padding-right: 0;
  36. $padding-bottom: 0;
  37. $padding-left: 0;
  38. @if $padding == null {
  39. $padding-top: $frame-top - top($border-width);
  40. $padding-right: $frame-right - right($border-width);
  41. $padding-bottom: $frame-bottom - bottom($border-width);
  42. $padding-left: $frame-left - left($border-width);
  43. }
  44. @else {
  45. $padding-top: top($padding);
  46. $padding-right: right($padding);
  47. $padding-bottom: bottom($padding);
  48. $padding-left: left($padding);
  49. }
  50. @if $padding-top < $frame-top {
  51. $padding-top: $frame-top - top($border-width);
  52. }
  53. @if $padding-right < $frame-right {
  54. $padding-right: $frame-right - right($border-width);
  55. }
  56. @if $padding-bottom < $frame-bottom {
  57. $padding-bottom: $frame-bottom - bottom($border-width);
  58. }
  59. @if $padding-left < $frame-left {
  60. $padding-left: $frame-left - left($border-width);
  61. }
  62. .#{$prefix}#{$cls-ui} {
  63. @if $supports-border-radius {
  64. @if length($border-radius) == 2 {
  65. @include border-top-left-radius(nth($border-radius, 1));
  66. @include border-top-right-radius(nth($border-radius, 2));
  67. } @else if length($border-radius) == 3 {
  68. @include border-top-left-radius(nth($border-radius, 1));
  69. @include border-top-right-radius(nth($border-radius, 2));
  70. @include border-bottom-right-radius(nth($border-radius, 3));
  71. } @else if length($border-radius) == 4 {
  72. @include border-top-left-radius(nth($border-radius, 1));
  73. @include border-top-right-radius(nth($border-radius, 2));
  74. @include border-bottom-right-radius(nth($border-radius, 3));
  75. @include border-bottom-left-radius(nth($border-radius, 4));
  76. } @else {
  77. @include border-radius($border-radius);
  78. }
  79. }
  80. padding: $padding-top $padding-right $padding-bottom $padding-left;
  81. border-width: $border-width;
  82. border-style: solid;
  83. @if $background-color != null {
  84. @if $supports-gradients and $background-gradient != null {
  85. @include background-gradient($background-color, $background-gradient, $background-direction);
  86. }
  87. @else {
  88. background-color: $background-color;
  89. }
  90. }
  91. }
  92. @if not $supports-gradients or $compile-all {
  93. .#{$prefix}nlg {
  94. .#{$prefix}#{$cls-ui}-mc {
  95. @if $background-gradient != null {
  96. background-image: theme-background-image($theme-name, '#{$cls}/#{$cls-ui}-bg.gif', false, $relative-image-path-for-uis);
  97. }
  98. @if $background-color != null {
  99. background-color: $background-color;
  100. }
  101. }
  102. }
  103. }
  104. @if not $supports-border-radius or $compile-all {
  105. .#{$prefix}nbr {
  106. .#{$prefix}#{$cls-ui} {
  107. padding: 0 !important;
  108. border-width: 0 !important;
  109. @include border-radius(0px);
  110. @if $background-color != null {
  111. background-color: transparent;
  112. }
  113. @else {
  114. background: #fff;
  115. }
  116. $type: '100';
  117. @if $table == true {
  118. $type: '110';
  119. }
  120. $direction: '100';
  121. @if $vertical == true {
  122. $direction: '110';
  123. }
  124. $left: $type + pad(top($border-radius)) + pad(right($border-radius)) + 'px';
  125. $top: $direction + pad(bottom($border-radius)) + pad(left($border-radius)) + 'px';
  126. background-position: unquote($left) unquote($top);
  127. }
  128. .#{$prefix}#{$cls-ui}-tl,
  129. .#{$prefix}#{$cls-ui}-bl,
  130. .#{$prefix}#{$cls-ui}-tr,
  131. .#{$prefix}#{$cls-ui}-br,
  132. .#{$prefix}#{$cls-ui}-tc,
  133. .#{$prefix}#{$cls-ui}-bc,
  134. .#{$prefix}#{$cls-ui}-ml,
  135. .#{$prefix}#{$cls-ui}-mr {
  136. zoom:1;
  137. @if $background-color != transparent {
  138. background-image: theme-background-image($theme-name, '#{$cls}/#{$cls-ui}-corners.gif', false, $relative-image-path-for-uis);
  139. }
  140. }
  141. @if $vertical == true {
  142. .#{$prefix}#{$cls-ui}-tc,
  143. .#{$prefix}#{$cls-ui}-bc {
  144. zoom:1;
  145. @if $background-color != transparent {
  146. background-image: theme-background-image($theme-name, '#{$cls}/#{$cls-ui}-sides.gif', false, $relative-image-path-for-uis);
  147. background-position: 0 0;
  148. background-repeat: repeat-x;
  149. }
  150. }
  151. } @else {
  152. .#{$prefix}#{$cls-ui}-ml,
  153. .#{$prefix}#{$cls-ui}-mr {
  154. zoom:1;
  155. @if $background-color != transparent {
  156. background-image: theme-background-image($theme-name, '#{$cls}/#{$cls-ui}-sides.gif', false, $relative-image-path-for-uis);
  157. background-position: 0 0;
  158. @if $background-gradient == null {
  159. background-repeat: repeat-y;
  160. }
  161. }
  162. }
  163. }
  164. $padding-top: $padding-top - $frame-top + top($border-width);
  165. $padding-right: $padding-right - $frame-right + right($border-width);
  166. $padding-bottom: $padding-bottom - $frame-bottom + bottom($border-width);
  167. $padding-left: $padding-left - $frame-left + left($border-width);
  168. @if $padding-top < 0 {
  169. $padding-top: 0;
  170. }
  171. @if $padding-right < 0 {
  172. $padding-right: 0;
  173. }
  174. @if $padding-bottom < 0 {
  175. $padding-bottom: 0;
  176. }
  177. @if $padding-left < 0 {
  178. $padding-left: 0;
  179. }
  180. .#{$prefix}#{$cls-ui}-mc {
  181. padding: $padding-top $padding-right $padding-bottom $padding-left;
  182. }
  183. }
  184. @if $include-ie {
  185. // framed components in ie7 strict mode suffer from an obscure bug that causes the tl and bl framing elements to
  186. // be shrink-wrapped to the width of their contents. This hack forces the elements' widths to fit to their parent
  187. .#{$prefix}strict .#{$prefix}ie7 {
  188. .#{$prefix}#{$cls-ui}-tl,
  189. .#{$prefix}#{$cls-ui}-bl {
  190. position: relative;
  191. right: 0;
  192. }
  193. }
  194. }
  195. }
  196. }