123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- @function pad($radius) {
- $radius: boxmax($radius);
- $radius: parseint($radius);
- @if $radius >= 10 {
- @return $radius;
- }
- @else {
- @return "0" + $radius;
- }
- }
- @function frame-size($border-width, $inner-border-width, $border-radius) {
- // We use the border-radius of the two corners on each edge to determine the "edge's
- // border-radius". For IE, the framing elements need to be as large as the larger of
- // the border-radius and the border-width on each edge. These values are passed on to
- // JavaScript using an encoded background-image url and the equivalent operations are
- // handled by Renderable.js.
- $frame-top: max(top($border-width) + top($inner-border-width), max(top($border-radius), right($border-radius)));
- $frame-right: max(right($border-width) + right($inner-border-width), max(right($border-radius), bottom($border-radius)));
- $frame-bottom: max(bottom($border-width) + bottom($inner-border-width), max(bottom($border-radius), left($border-radius)));
- $frame-left: max(left($border-width) + left($inner-border-width), max(left($border-radius), top($border-radius)));
- $frame-max: max($frame-top $frame-right $frame-bottom $frame-left);
- // Slices produced by the slicer are always equally sized so that
- // they can be sprited. This means that all sides that have frames
- // must be the same size
- @if $frame-top != 0 {
- $frame-top: $frame-max;
- }
- @if $frame-right != 0 {
- $frame-right: $frame-max;
- }
- @if $frame-bottom != 0 {
- $frame-bottom: $frame-max;
- }
- @if $frame-left != 0 {
- $frame-left: $frame-max;
- }
- @return $frame-top $frame-right $frame-bottom $frame-left
- }
- @mixin x-frame(
- $cls,
- $ui: null,
- $border-radius: 0px,
- $border-width: 0px,
- $padding: null,
- $background-color: null,
- $background-gradient: null,
- $table: false,
- $background-direction: top,
- $include-frame-rtl: false,
- $background-stretch: null,
- $ignore-frame-padding: false,
- $inner-border-width: 0
- ) {
- $cls-ui: $cls;
- $cls-ui: null;
- @if $ui != null {
- $cls-ui: $cls + '-' + $ui;
- }
- @if is-null($inner-border-width) {
- // default inner border width to 0 if the caller passed null or 'none' (e.g. buttons do this)
- $inner-border-width: 0;
- }
- $vertical: false;
- @if not is-null($background-gradient) and ($background-direction == left or $background-direction == right) {
- $vertical: true;
- }
- $background-stretch-position: null;
- @if is-null($background-stretch) {
- @if $background-direction == top {
- $background-stretch: bottom;
- } @else if $background-direction == right {
- $background-stretch: left;
- } @else if $background-direction == bottom {
- $background-stretch: top;
- } @else if $background-direction == left {
- $background-stretch: right;
- }
- }
- @if $background-stretch == top {
- $background-stretch-position: bottom;
- } @else if $background-stretch == bottom {
- $background-stretch-position: top;
- } @else if $background-stretch == left {
- $background-stretch-position: right;
- } @else if $background-stretch == right {
- $background-stretch-position: left;
- }
- @if not is-null($background-gradient) {
- $stretch: slicer-background-stretch($cls-ui, $background-stretch);
- }
- $frame-size: frame-size($border-width, $inner-border-width, $border-radius);
- $frame-top: nth($frame-size, 1);
- $frame-right: nth($frame-size, 2);
- $frame-bottom: nth($frame-size, 3);
- $frame-left: nth($frame-size, 4);
- $frame-max: max($frame-size);
- $frame: slicer-frame($cls-ui, $frame-size);
- $padding-top: 0;
- $padding-right: 0;
- $padding-bottom: 0;
- $padding-left: 0;
- $frame-info-padding-top: 0;
- $frame-info-padding-right: 0;
- $frame-info-padding-bottom: 0;
- $frame-info-padding-left: 0;
- // For CSS3 browsers, if the border-radius is larger than the border-width, we need to
- // apply padding to inset the content. These values can never be 0 because frame-xxx
- // includes border-xxx in its max.
- //
- @if not $ignore-frame-padding {
- $padding-top: $frame-top - top($border-width);
- $padding-right: $frame-right - right($border-width);
- $padding-bottom: $frame-bottom - bottom($border-width);
- $padding-left: $frame-left - left($border-width);
- } @else {
- // In nocss3 browsers we can never ignore frame padding, because the framing elements
- // cannot be overlapped by the content.
- $frame-info-padding-top: $frame-top - top($border-width);
- $frame-info-padding-right: $frame-right - right($border-width);
- $frame-info-padding-bottom: $frame-bottom - bottom($border-width);
- $frame-info-padding-left: $frame-left - left($border-width);
- }
- // If there is additional padding, this is understood to be a request to ensure that
- // the content is **at least** this far from the inside of the border. If the framing
- // requires more padding, that wins. This is the amount of padding you need in CSS3
- // browsers.
- //
- @if not is-null($padding) {
- $padding-top: max($padding-top, top($padding));
- $padding-right: max($padding-right, right($padding));
- $padding-bottom: max($padding-bottom, bottom($padding));
- $padding-left: max($padding-left, left($padding));
- }
- // For IE, the framing elements are sized by frame-xxx and the "-mc" will carry the
- // extra-padding-xxx.
- //
- $extra-padding-top: max(top($border-width) + $padding-top - $frame-top, 0);
- $extra-padding-right: max(right($border-width) + $padding-right - $frame-right, 0);
- $extra-padding-bottom: max(bottom($border-width) + $padding-bottom - $frame-bottom, 0);
- $extra-padding-left: max(left($border-width) + $padding-left - $frame-left, 0);
- $framing-info: '';
- @if $table == true {
- $framing-info: $framing-info + 't';
- } @else {
- $framing-info: $framing-info + 'd';
- }
- @if $vertical == true {
- $framing-info: $framing-info + 'v';
- } @else {
- $framing-info: $framing-info + 'h';
- }
- $framing-info: $framing-info + '-' +
- nopx($frame-top) + '-' +
- nopx($frame-right) + '-' +
- nopx($frame-bottom) + '-' +
- nopx($frame-left) + '-' +
- nopx(top($border-width)) + '-' +
- nopx(right($border-width)) + '-' +
- nopx(bottom($border-width)) + '-' +
- nopx(left($border-width)) + '-' +
- if($ignore-frame-padding, $frame-info-padding-top, nopx($padding-top)) + '-' +
- if($ignore-frame-padding, $frame-info-padding-right, nopx($padding-right)) + '-' +
- if($ignore-frame-padding, $frame-info-padding-bottom, nopx($padding-bottom)) + '-' +
- if($ignore-frame-padding, $frame-info-padding-left, nopx($padding-left));
- .#{$prefix}#{$cls-ui} {
- @if length($border-radius) == 2 {
- @include border-top-left-radius(nth($border-radius, 1));
- @include border-top-right-radius(nth($border-radius, 2));
- } @else if length($border-radius) == 3 {
- @include border-top-left-radius(nth($border-radius, 1));
- @include border-top-right-radius(nth($border-radius, 2));
- @include border-bottom-right-radius(nth($border-radius, 3));
- } @else if length($border-radius) == 4 {
- @include border-top-left-radius(nth($border-radius, 1));
- @include border-top-right-radius(nth($border-radius, 2));
- @include border-bottom-right-radius(nth($border-radius, 3));
- @include border-bottom-left-radius(nth($border-radius, 4));
- } @else {
- @include border-radius($border-radius);
- }
- padding: $padding-top $padding-right $padding-bottom $padding-left;
- border-width: $border-width;
- border-style: solid;
- @if not is-null($background-color) {
- @if not is-null($background-gradient) {
- @include background-gradient($background-color, $background-gradient, $background-direction);
- }
- @else {
- background-color: $background-color;
- }
- }
- }
- @if $include-frame-rtl {
- @if $background-direction == left {
- $background-direction: right;
- } @else if $background-direction == right {
- $background-direction: left;
- }
- @if $background-direction == left or $background-direction == right {
- .#{$prefix}rtl.#{$prefix}#{$cls-ui} {
- @include background-gradient(
- $background-color,
- $background-gradient,
- $background-direction
- );
- }
- }
- }
- @if $include-slicer-border-radius {
- .#{$prefix}#{$cls-ui}-mc {
- @if not is-null($background-gradient) {
- background-image: slicer-frame-background-image($cls-ui, '#{$cls}/#{$cls-ui}-fbg');
- @if $vertical {
- background-position: $background-stretch-position 0;
- background-repeat: repeat-y;
- } @else {
- background-position: 0 $background-stretch-position;
- }
- }
- @if not is-null($background-color) {
- background-color: $background-color;
- }
- }
- @if $include-frame-rtl and not is-null($background-gradient) {
- .#{$prefix}rtl.#{$prefix}#{$cls-ui}-mc {
- background-image: slicer-frame-background-image-rtl($cls-ui, '#{$cls}/#{$cls-ui}-fbg-rtl');
- background-position: rtl-background-position($background-stretch-position 0);
- }
- }
- }
- @if $include-slicer-border-radius {
- .#{$prefix}nbr {
- // This rule must be in x-nbr to avoid matching on CSS3 browsers.
- .#{$prefix}#{$cls-ui} {
- padding: 0 !important;
- border-width: 0 !important;
- @include border-radius(0px);
- @if not is-null($background-color) {
- background-color: transparent !important;
- } @else {
- background: #fff;
- }
- @if not is-null($background-gradient) {
- background-image: none;
- }
- // it is helpful to suppress box-shadow when debugging nocss3 mode in modern browsers
- box-shadow: none !important;
- }
- }
- .#{$prefix}#{$cls-ui}-frameInfo {
- // Pass along Div/Table, Horz/Vert, border-radius and border-width
- // Here we're encoding the framing information in an arbitrary fashion so
- // it can be parsed by the component and get information about the framing.
- // Originally, this tried to embed the information using a background image
- // pointing to about:blank#info however in IE with SSL, this would trigger
- // the insecure content warning. We also tried encoding the info using a
- // filter as follows (where framing-info is a string containing the encoded data):
- // filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=false, src="ext-frame#{$framing-info}");
- // However the filter property can only be read by IE, making it impossible
- // to debug nocss3 mode in modern browsers. Font-family meets all the
- // requirements for tunneling data to JavaScript. It can contain an
- // arbitrary string value, which can be read in JS in any browser, and it
- // does not trigger any network interactions.
- font-family: #{$framing-info};
- }
- // These rules apply to elements that are not rendered on CSS3 browsers so we do
- // not need to force the browser to walk to the root of the document searching
- // for x-nbr!
- @if $vertical {
- // vertical framing element background positions
- .#{$prefix}#{$cls-ui}-tl {
- background-position: 0 0;
- }
- .#{$prefix}#{$cls-ui}-tr {
- background-position: 0 (-$frame-max);
- }
- .#{$prefix}#{$cls-ui}-bl {
- background-position: 0 (-$frame-max * 2);
- }
- .#{$prefix}#{$cls-ui}-br {
- background-position: 0 (-$frame-max * 3);
- }
- .#{$prefix}#{$cls-ui}-ml {
- background-position: (-$frame-max) 0;
- }
- .#{$prefix}#{$cls-ui}-mr {
- background-position: right 0;
- }
- .#{$prefix}#{$cls-ui}-tc {
- background-position: $background-stretch-position 0;
- }
- .#{$prefix}#{$cls-ui}-bc {
- background-position: $background-stretch-position (-$frame-max);
- }
- @if $include-frame-rtl {
- .#{$prefix}rtl.#{$prefix}#{$cls-ui}-tc {
- background-position: rtl-background-position($background-stretch-position 0);
- }
- .#{$prefix}rtl.#{$prefix}#{$cls-ui}-bc {
- background-position: rtl-background-position($background-stretch-position (-$frame-max));
- }
- }
- } @else {
- // horizontal framing element background positions
- .#{$prefix}#{$cls-ui}-tl {
- background-position: 0 (-$frame-max * 2);
- }
- .#{$prefix}#{$cls-ui}-tr {
- background-position: right (-$frame-max * 3);
- }
- .#{$prefix}#{$cls-ui}-bl {
- background-position: 0 (-$frame-max * 4);
- }
- .#{$prefix}#{$cls-ui}-br {
- background-position: right (-$frame-max * 5);
- }
- .#{$prefix}#{$cls-ui}-ml {
- @if $background-stretch-position == 'right' or $background-stretch-position == 'left' {
- background-position: $background-stretch-position 0;
- } @else {
- background-position: 0 $background-stretch-position;
- }
- }
- .#{$prefix}#{$cls-ui}-mr {
- @if $background-stretch-position == 'right' or $background-stretch-position == 'left' {
- background-position: $background-stretch-position 0;
- } @else {
- background-position: right $background-stretch-position;
- }
- }
- .#{$prefix}#{$cls-ui}-tc {
- background-position: 0 0;
- }
- .#{$prefix}#{$cls-ui}-bc {
- background-position: 0 (-$frame-max);
- }
- }
- .#{$prefix}#{$cls-ui}-tr,
- .#{$prefix}#{$cls-ui}-br,
- .#{$prefix}#{$cls-ui}-mr {
- padding-right: $frame-right;
- }
- .#{$prefix}#{$cls-ui}-tl,
- .#{$prefix}#{$cls-ui}-bl,
- .#{$prefix}#{$cls-ui}-ml {
- padding-left: $frame-left;
- }
- .#{$prefix}#{$cls-ui}-tc {
- height: $frame-top;
- }
- .#{$prefix}#{$cls-ui}-bc {
- height: $frame-bottom;
- }
- .#{$prefix}#{$cls-ui}-tl,
- .#{$prefix}#{$cls-ui}-bl,
- .#{$prefix}#{$cls-ui}-tr,
- .#{$prefix}#{$cls-ui}-br,
- .#{$prefix}#{$cls-ui}-tc,
- .#{$prefix}#{$cls-ui}-bc,
- .#{$prefix}#{$cls-ui}-ml,
- .#{$prefix}#{$cls-ui}-mr {
- @if $background-color != transparent {
- background-image: slicer-corner-sprite($cls-ui, '#{$cls}/#{$cls-ui}-corners');
- }
- }
- @if $background-color != transparent {
- @if $include-frame-rtl {
- .#{$prefix}rtl {
- &.#{$prefix}#{$cls-ui}-tl,
- &.#{$prefix}#{$cls-ui}-ml,
- &.#{$prefix}#{$cls-ui}-bl,
- &.#{$prefix}#{$cls-ui}-tr,
- &.#{$prefix}#{$cls-ui}-mr,
- &.#{$prefix}#{$cls-ui}-br {
- background-image: slicer-corner-sprite-rtl($cls-ui, '#{$cls}/#{$cls-ui}-corners-rtl');
- }
- }
- }
- }
- @if $vertical == true {
- .#{$prefix}#{$cls-ui}-tc,
- .#{$prefix}#{$cls-ui}-bc {
- @if $background-color != transparent {
- background-image: slicer-sides-sprite($cls-ui, '#{$cls}/#{$cls-ui}-sides');
- background-repeat: repeat-x;
- }
- }
- @if $include-frame-rtl and $background-color != transparent {
- .#{$prefix}rtl {
- &.#{$prefix}#{$cls-ui}-tc,
- &.#{$prefix}#{$cls-ui}-bc {
- background-image: slicer-sides-sprite-rtl($cls-ui, '#{$cls}/#{$cls-ui}-sides-rtl');
- }
- }
- }
- } @else {
- .#{$prefix}#{$cls-ui}-ml,
- .#{$prefix}#{$cls-ui}-mr {
- @if $background-color != transparent {
- background-image: slicer-sides-sprite($cls-ui, '#{$cls}/#{$cls-ui}-sides');
- @if is-null($background-gradient) {
- background-repeat: repeat-y;
- }
- }
- }
- }
- .#{$prefix}#{$cls-ui}-mc {
- padding: $extra-padding-top $extra-padding-right $extra-padding-bottom $extra-padding-left;
- }
- }
- @include x-slicer($cls-ui);
- }
|