/**
 * Created by zhuyan6 on 16/4/21.
 */
/*基础公共库
*使用 @import "../modules/base-mixins";
*div {
*   rxr-linear-gradient(to bottom, #fff, #666);
*}
*/
/*
Description：css3 animation
example:
div {
    rxr-animation(test 3s ease);
}
*/
rxr-animation($value) {
	-webkit-animation: $value;
	-moz-animation: $value;
	-o-animation: $value;
	animation: $value;
}
/*
Description：css3 appearance
example:
div {
    rxr-appearance(button);
}
*/
rxr-appearance($value) {
	-webkit-appearance: $value;
	-moz-appearance: $value;
	appearance: $value;	
}
/*
Description：Description：Hidden the back of the rotating element
example:
div {
    rxr-backface-visibility(hidden);
}
*/
rxr-backface-visibility($value=visible) {
	-webkit-backface-visibility: $value;;
	-moz-backface-visibility: $value;;
	-ms-backface-visibility: $value;;	
	backface-visibility: $value;	
}
/*
Description：css3 background-clip
example:
div {
    rxr-background-clip(content-box);
}
*/
rxr-background-clip($mode=border-box) {
	$xmode=null;

	if ($mode == border-box) {
		$xmode=border;
	}

	if ($mode == padding-box) {
		$xmode=padding;
	}

	if ($mode == content-box) {
		$xmode=content;
	}

	-moz-background-clip: $xmode;
	-webkit-background-clip: $xmode;
	background-clip: $mode; 	
}
/*
Description：css3 background-origin
example:
div {
    rxr-background-origin(content-box);
}
*/
rxr-background-origin($mode=border-box) {
	$xmode=null;

	if ($mode == border-box) {
		$xmode=border;
	}

	if ($mode == padding-box) {
		$xmode=padding;
	}

	if ($mode == content-box) {
		$xmode=content;
	}

	-moz-background-origin: $xmode;
	-webkit-background-origin: $xmode;
	background-origin: $mode; 	
}
/*
Description：background image support retina screen .
example:
div {
    rxr-background-retina("1x.png", "2x.png", 24px, 24px);
}
*/
rxr-background-retina($img_1x, $img_2x, $width_1x, $height_1x) {
	background-image: url($img_1x);

	@media only screen and (-webkit-min-device-pixel-ratio: 2),
	only screen and (min--moz-device-pixel-ratio: 2),
	only screen and (-o-min-device-pixel-ratio: 2/1),
	only screen and (min-device-pixel-ratio: 2),
	only screen and (min-resolution: 192dpi),
	only screen and (min-resolution: 2dppx) {
		background-image: url($img_2x);
		rxr-background-size($width_1x $height_1x);
	}
}
/*
Description：css3 background-size
example:
div {
    rxr-background-size(50% 50%);
}
*/
rxr-background-size($size) {
	-webkit-background-size: $size;
	-moz-background-size: $size;
	-o-background-size: $size;
	background-size: $size;
}
/*
Description：css3 border-radius
example:
div { rxr-border-radius(3px);  // set all corners }
div { rxr-border-radius(3px, top);  // set topleft and topright corners }
div { rxr-border-radius(3px, right);  // set topright and bottomright corners }
div { rxr-border-radius(3px, bottom);  // set bottomleft and bottomright corners }
div { rxr-border-radius(3px, left);  // set topleft and bottomleft corners }
*/
rxr-border-radius($radius, $direction=all) {
	if ($direction == all) {
	    -moz-border-radius: $radius;
	    -webkit-border-radius: $radius;
	    border-radius: $radius;
	}

	if ($direction == top) {
	    -moz-border-radius: $radius $radius 0 0;
	    -webkit-border-radius: $radius $radius 0 0;
	    border-radius: $radius $radius 0 0;
	}

	if ($direction == right) {
	    -moz-border-radius: 0 $radius $radius 0;
	    -webkit-border-radius: 0 $radius $radius 0;
	    border-radius: 0 $radius $radius 0;
	}

	if ($direction == bottom) {
	    -moz-border-radius: 0 0 $radius $radius;
	    -webkit-border-radius: 0 0 $radius $radius;
	    border-radius: 0 0 $radius $radius;
	}

	if ($direction == left) {
	    -moz-border-radius: $radius 0 0 $radius;
	    -webkit-border-radius: $radius 0 0 $radius;
	    border-radius: $radius 0 0 $radius;
	}
}
/*
Description：border triangle
example:
div {
    rxr-border-triangle(5px, #666, top);
}
*/
rxr-border-triangle($borderWidth, $borderColor, $direction) {
	$default-border-style = solid;

	width: 0;
	height: 0;
	overflow: hidden;
	border-width: $borderWidth;
	border-style: $default-border-style;
	_border-style: dashed;
	border-color: transparent;

	if ($direction == top) {
		border-bottom-color: $borderColor;
		_border-bottom-style: $default-border-style;
	}

	if ($direction == right) {
		border-left-color: $borderColor;
		_border-left-style: $default-border-style;
	}

	if ($direction == bottom) {
		border-top-color: $borderColor;
		_border-top-style: $default-border-style;
	}

	if ($direction == left) {
		border-right-color: $borderColor;
		_border-right-style: $default-border-style;
	}

	if ($direction == topleft) {
		border-top-color: $borderColor;
		border-left-color: $borderColor;
		_border-top-style: $default-border-style;
		_border-left-style: $default-border-style;
	}

	if ($direction == topright) {
		border-top-color: $borderColor;
		border-right-color: $borderColor;
		_border-top-style: $default-border-style;
		_border-right-style: $default-border-style;
	}

	if ($direction == bottomleft) {
		border-bottom-color: $borderColor;
		border-left-color: $borderColor;
		_border-bottom-style: $default-border-style;
		_border-left-style: $default-border-style;
	}

	if ($direction == bottomright) {
		border-bottom-color: $borderColor;
		border-right-color: $borderColor;
		_border-bottom-style: $default-border-style;
		_border-right-style: $default-border-style;
	}
}
/*
Description：css3 borxr-shadow
example:
div {
    rxr-borxr-shadow(5px 5px 3px #000);
}
*/
rxr-borxr-shadow($params) {
 	   -moz-box-shadow: $params;
 	-webkit-box-shadow: $params;
  	        box-shadow: $params;
}
/*
Description：css3 borxr-sizing
example:
div {
    rxr-borxr-sizing(border-box);
}
*/
rxr-borxr-sizing($model) {
	-webkit-box-sizing: $model;
	   -moz-box-sizing: $model;
	        box-sizing: $model;
}
/*
Description：clear float
example:
div {
    rxr-clearfix();
}
*/
rxr-clearfix() {
	&:before,
	&:after {
		content: " ";
		display: table;
	}
	&:after {
		clear: both;
	}
	*zoom: 1;
}
/*
Description：css3 @font-face
example:
rxr-font-face('iconfont', 'http://x.cdn.com/iconfont');

div {
    font-family: 'iconfont';
}
*/
rxr-font-face($fontName, $noSuffixFontUrl) {
	@font-face {
	  font-family: $fontName + "";
	  src: url($noSuffixFontUrl + ".eot");
	  src: url($noSuffixFontUrl + ".eot?#iefix") format("embedded-opentype"),
	       url($noSuffixFontUrl + ".woff") format("woff"),
	       url($noSuffixFontUrl + ".ttf")  format("truetype"),
	       url($noSuffixFontUrl + ".svg#svgFontName") format("svg");
	}	
}
/*
Description：Description：turn colour image into gray .(把彩色图像变成灰色)
example:
img {
    rxr-grayscale();  // colour image into a gray image
}
*/
rxr-grayscale() {
	-moz-filter: grayscale(100%);
	-ms-filter: grayscale(100%);
	-o-filter: grayscale(100%);
	/* for Chrome, Safari, Opera */
	-webkit-filter: grayscale(100%);
	/* CSS3 standard usage */
    filter: grayscale(100%);
    /* for FF, data-uri generate from gray.svg */
    //filter: url('data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CiAgICA8ZmlsdGVyIGlkPSJncmF5c2NhbGUiPgogICAgICAgIDxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwLjMzMzMgMC4zMzMzIDAuMzMzMyAwIDAgMC4zMzMzIDAuMzMzMyAwLjMzMzMgMCAwIDAuMzMzMyAwLjMzMzMgMC4zMzMzIDAgMCAwIDAgMCAxIDAiLz4KICAgIDwvZmlsdGVyPgo8L3N2Zz4=#grayscale');
    /* for IE6~9, disable stylus convert gray to #808080 by stylus's unquote method */
	filter: unquote("gray");
}
/*
Description：css3 hyphens(连字符,分割单词)
example:
div {
    rxr-hyphens();
}
*/
rxr-hyphens($mode=auto) {
	-ms-word-break: break-all;
	word-break: break-all;
	word-break: break-word;
	-webkit-hyphens: $mode;
	-moz-hyphens: $mode;
	-ms-hyphens: $mode;
	hyphens: $mode;	
}
/*
Description：inline-block
example:
div {
    rxr-inline-block();
}
*/
rxr-inline-block() {
    display: inline-block
    *display: inline
    *zoom: 1
}
/*
Description：CSS3 linear-gradient
example:
div {
    rxr-linear-gradient(to bottom, #000, #fff);
}
div {
    rxr-linear-gradient(90deg, #000 30%, #fff 60%);
}
*/
rxr-linear-gradient($direction, $startColor, $endColor) {
	$xdirection=null;
	$ie-direction=null;

	if (join(",", $direction) == "to,bottom") {
		$xdirection=top;
		$ie-direction=0;		
	}
	if (join(",", $direction) == "to,right") {
		$xdirection=left;
		$ie-direction=1;		
	}
	
    background: -webkit-linear-gradient($xdirection, $startColor, $endColor);
    background: -moz-linear-gradient($xdirection, $startColor, $endColor);
    background: -ms-linear-gradient($xdirection, $startColor, $endColor);
    background: -o-linear-gradient($xdirection, $startColor, $endColor);
    background: linear-gradient($direction, $startColor, $endColor);
    filter unquote("progid:DXImageTransform.Microsoft.gradient(startcolorstr=" + $startColor + ",endcolorstr=" + $endColor + ",gradientType=" + $ie-direction + ")");
}
/*
Description：min-height
example:
div {
    rxr-min-height(100px);
}
*/
rxr-min-height($height) {
	min-height: $height;
	_height: $height;
}
/*
Description：opacity
example:
div {
    rxr-opacity(0.5);
}
*/
rxr-opacity($opacity) {
	$opacityIE = $opacity * 100;
	-ms-filter unquote('progid=DXImageTransform.Microsoft.Alpha(Opacity=' + $opacityIE + ')'); // IE 8 & 9
	filter unquote('alpha(opacity=' + $opacityIE + ')'); // IE 6 & 7
	opacity: $opacity;
}
/*
Description：Determines the origin for the perspective property（Actually set the X axis and Y axis position）
确定的起源角度属性(实际上设置X轴和Y轴的位置)
example:
div {
    rxr-perspective(100px);
    rxr-perspective-origin(top left);
}
*/
rxr-perspective-origin($origin=50% 50%) {
	-webkit-perspective-origin: $origin;
	-moz-perspective-origin: $origin;
	perspective-origin: $origin;
}
/*
Description：Gives an element a 3D-space by affecting the distance between the Z plane and the user.
给一个元素一个3 d空间影响Z平面和用户之间的距离。
example:
div {
    rxr-animation(test 3s ease);
}
*/
rxr-perspective($value=none) {
	-webkit-perspective: $value;
	-moz-perspective: $value;	
	perspective: $value;
}
/*
Description：set placeholder text color .（设置占位符文本颜色。）
example:
div {
    rxr-placeholder(red);
}
*/
rxr-placeholder($color) {
	&::-moz-placeholder {
		color: $color;
		opacity: 1;
	}
	&:-moz-placeholder {
		color: $color;
	}
	&:-ms-input-placeholder {
		color: $color; 
	}
	&::-webkit-input-placeholder {
		color: $color; 
	}	
}
/*
Description：CSS3 radial gradient
example:
div {
    rxr-radial-gradient(circle, red, green);
}
*/
rxr-radial-gradient() {
	$param = unquote(join(',', arguments));
    background: -webkit-radial-gradient($param);
    background: -moz-radial-gradient($param);
    background: -ms-radial-gradient($param);
    background: radial-gradient($param);	
}
/*
Description：text-overflow
params:ellipsis
example:
div {
    rxr-text-overflow(ellipsis);
}
*/
rxr-text-overflow($cutway=clip) {
	overflow: hidden;
  	text-overflow: $cutway;
  	white-space: nowrap;
}
/*
Description：lets you modify the origin for transformations of an element.
example:
div {
    rxr-transform-origin(top left);
}
}
*/
rxr-transform-origin($value=50% 50% 0) {
	-webkit-transform-origin: $value;
	-moz-transform-origin: $value;
	-ms-transform-origin: $value;
	transform-origin: $value;
}
/*
Description：determines the element's children are positioned in 3D space, or flattened.
example:
div {
    rxr-transform-style(preserve-3d);
}
*/
rxr-transform-style($value=flat) {
	-webkit-transform-style: $value;	
	-moz-transform-style: $value;	
	transform-style: $value;
}
/*
Description：css3 transform
example:
div {
    rxr-transform(rotate(20deg));
}
*/
rxr-transform($value) {
	-webkit-transform: $value;
	-moz-transform: $value;
	-ms-transform: $value;
	-o-transform: $value;
	transform: $value;	
}
/*
Description：css3 transition
example:
div {
    height: 100px;
    rxr-transition(height 2s ease);
}
div:hover {
    height: 300px;
}
*/
rxr-transition($value) {
    -webkit-transition: $value;
    -moz-transition: $value;
    -o-transition: $value;
    transition: $value;	
}
/*
Description：css3 user-select
none：
文本不能被选择
text：
可以选择文本
all：
当所有内容作为一个整体时可以被选择。如果双击或者在上下文上点击子元素，那么被选择的部分将是以该子元素向上回溯的最高祖先元素。
element：
可以选择文本，但选择范围受元素边界的约束
example:
div {
    rxr-user-select();
}
*/
rxr-user-select($mode=text) {
	-webkit-user-select: $mode;
	-moz-user-select: $mode;
	-ms-user-select: $mode;
  	-khtml-user-select $mode;
	user-select: $mode;

	if ($mode == "none") {
	  //pointer-events: none
	  cursor: pointer;
	}
}
/*修改字体*/
rxr-font-style($family="'MicrosoftYaHei', 'Microsoft YaHei'") {
  font-family: $family;
  font-weight: 400;
  font-style: normal;
}
/*垂直剧中
	$parent:父级容器
	$children:子级容器
	此方法比table等其他垂直居中方法兼容性更好
*/
rxr-vertical-align($parent, $children) {
	.{$parent} {
	  	text-align: center;
	  	&:after {
		  display inline-block
		  vertical-align middle
		  height 100%
		  content ''
		  margin-left -0.25em
		  width 0
		  max-height 0
		}
	  	.{$children} {
		  display inline-block
		  vertical-align middle
		  max-width 99%
		}
	}
}
/*
字体清晰度
none                 ------ 对低像素的文本比较好
subpixel-antialiased ------默认值
antialiased          ------抗锯齿很好
*/
rxr-font-smooth($mode=antialiased) {
  -webkit-font-smoothing:$mode
  if ($mode == antialiased){
	-moz-osx-font-smoothing:grayscale
  }else {
	-moz-osx-font-smoothing:inherit
  }

}

/*
最小屏幕尺寸
*/
rxr-min-screen($width=1024px) {
  min-width $width
}

/*
阴影效果
*/
rxr-box-shadow($value=0 0 10px #f2f2f2) {
  -webkit-box-shadow:$value;
  -moz-box-shadow:$value;
  box-shadow:$value;
}

/*
缩放
*/
rxr-box-scale(scaleX,scaleY) {
  -webkit-transform: scale(scaleX,scaleY);    /* for Chrome || Safari */
  -moz-transform: scale(scaleX,scaleY);       /* for Firefox */
  -ms-transform: scale(scaleX,scaleY);        /* for IE */
  -o-transform: scale(scaleX,scaleY);         /* for Opera */
}

/*
模糊效果
*/
rxr-filter(blur=2px) {
  -webkit-filter: blur(blur);
  -moz-filter: blur(blur);
  -ms-filter: blur(blur);
  -o-filter: blur(blur);
  filter: blur(blur);
}