Advertisement
Guest User

Untitled

a guest
Feb 13th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
CSS 1.37 KB | None | 0 0
  1. @mixin cq-prolyfill($query) {
  2.     &#{cq-prolyfill($query)} {
  3.         @content;
  4.     }
  5. }
  6.  
  7. @function cq-prolyfill($query) {
  8.     @return unquote(".\\:container\\(" + cq-prolyfill-escape(cq-prolyfill-strip-spaces(to-lower-case($query))) + "\\)");
  9. }
  10.  
  11. @function cq-prolyfill-add-backslash($string, $search) {
  12.     $index: str-index($string, $search);
  13.     @while $index {
  14.         $string: str-insert($string, '\\', $index);
  15.         $newIndex: if(
  16.             str-length($string) < $index + 2,
  17.             null,
  18.             str-index(str-slice($string, $index + 2), $search)
  19.         );
  20.         $index: if($newIndex, $index + 1 + $newIndex, null);
  21.     }
  22.     @return $string;
  23. }
  24.  
  25. @function cq-prolyfill-remove($string, $search) {
  26.     $index: str-index($string, $search);
  27.     @while $index {
  28.         $string: str-slice($string, 1, $index - 1) + str-slice($string, $index + 1);
  29.         $index: str-index($string, $search);
  30.     }
  31.     @return $string;
  32. }
  33.  
  34. @function cq-prolyfill-escape($string) {
  35.     @each $char in '[' ']' '!' '"' '#' '$' '%' '&' "'" '(' ')' '*' '+' ',' '.' '/' ':' ';' '<' '=' '>' '?' '@' '^' '`' '{' '|' '}' '~' {
  36.         $string: cq-prolyfill-add-backslash($string, $char);
  37.     }
  38.     @return $string;
  39. }
  40.  
  41. @function cq-prolyfill-strip-spaces($string) {
  42.     // tab, line feed, carriage return and space
  43.     $chars: "\9\a\d\20";
  44.     @for $i from 1 through str-length($chars) {
  45.         $string: cq-prolyfill-remove(
  46.             $string,
  47.             str-slice($chars, $i, $i)
  48.         );
  49.     }
  50.     @return $string;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement