susy 1.0.9 → 2.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (195) hide show
  1. data/CHANGELOG.mkdn +0 -27
  2. data/README.md +4 -87
  3. data/docs/BUGS.md +2 -0
  4. data/docs/Gemfile.lock +142 -0
  5. data/docs/README.md +54 -0
  6. data/docs/config.rb +120 -0
  7. data/docs/lib/guide_helpers.rb +19 -0
  8. data/docs/source/apple-touch-icon-114x114-precomposed.png +0 -0
  9. data/docs/source/apple-touch-icon-144x144-precomposed.png +0 -0
  10. data/docs/source/apple-touch-icon-72x72-precomposed.png +0 -0
  11. data/docs/source/apple-touch-icon-precomposed.png +0 -0
  12. data/docs/source/demos/grid-types.html.md +263 -0
  13. data/docs/source/demos/index.html.md +23 -0
  14. data/docs/source/demos/magic.html.md +320 -0
  15. data/docs/source/favicon.ico +0 -0
  16. data/docs/source/fonts/@Font-Face License.txt +18 -0
  17. data/docs/source/fonts/Baskerville-amp-webfont.eot +0 -0
  18. data/docs/source/fonts/Baskerville-amp-webfont.svg +241 -0
  19. data/docs/source/fonts/Baskerville-amp-webfont.ttf +0 -0
  20. data/docs/source/fonts/Baskerville-amp-webfont.woff +0 -0
  21. data/docs/source/fonts/CenturyOldStyle-Bold-webfont.eot +0 -0
  22. data/docs/source/fonts/CenturyOldStyle-Bold-webfont.svg +240 -0
  23. data/docs/source/fonts/CenturyOldStyle-Bold-webfont.ttf +0 -0
  24. data/docs/source/fonts/CenturyOldStyle-Bold-webfont.woff +0 -0
  25. data/docs/source/fonts/CenturyOldStyle-Italic-webfont.eot +0 -0
  26. data/docs/source/fonts/CenturyOldStyle-Italic-webfont.svg +240 -0
  27. data/docs/source/fonts/CenturyOldStyle-Italic-webfont.ttf +0 -0
  28. data/docs/source/fonts/CenturyOldStyle-Italic-webfont.woff +0 -0
  29. data/docs/source/fonts/CenturyOldStyle-Regular-webfont.eot +0 -0
  30. data/docs/source/fonts/CenturyOldStyle-Regular-webfont.svg +240 -0
  31. data/docs/source/fonts/CenturyOldStyle-Regular-webfont.ttf +0 -0
  32. data/docs/source/fonts/CenturyOldStyle-Regular-webfont.woff +0 -0
  33. data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.eot +0 -0
  34. data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.svg +240 -0
  35. data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.ttf +0 -0
  36. data/docs/source/fonts/CenturyOldStyleCaps-Regular-webfont.woff +0 -0
  37. data/docs/source/fonts/FranklinGothic-Book-webfont.eot +0 -0
  38. data/docs/source/fonts/FranklinGothic-Book-webfont.svg +240 -0
  39. data/docs/source/fonts/FranklinGothic-Book-webfont.ttf +0 -0
  40. data/docs/source/fonts/FranklinGothic-Book-webfont.woff +0 -0
  41. data/docs/source/fonts/FranklinGothic-BookIt-webfont.eot +0 -0
  42. data/docs/source/fonts/FranklinGothic-BookIt-webfont.svg +240 -0
  43. data/docs/source/fonts/FranklinGothic-BookIt-webfont.ttf +0 -0
  44. data/docs/source/fonts/FranklinGothic-BookIt-webfont.woff +0 -0
  45. data/docs/source/fonts/FranklinGothic-Cd-webfont.eot +0 -0
  46. data/docs/source/fonts/FranklinGothic-Cd-webfont.svg +240 -0
  47. data/docs/source/fonts/FranklinGothic-Cd-webfont.ttf +0 -0
  48. data/docs/source/fonts/FranklinGothic-Cd-webfont.woff +0 -0
  49. data/docs/source/fonts/FranklinGothic-CdIt-webfont.eot +0 -0
  50. data/docs/source/fonts/FranklinGothic-CdIt-webfont.svg +240 -0
  51. data/docs/source/fonts/FranklinGothic-CdIt-webfont.ttf +0 -0
  52. data/docs/source/fonts/FranklinGothic-CdIt-webfont.woff +0 -0
  53. data/docs/source/fonts/FranklinGothic-Med-webfont.eot +0 -0
  54. data/docs/source/fonts/FranklinGothic-Med-webfont.svg +240 -0
  55. data/docs/source/fonts/FranklinGothic-Med-webfont.ttf +0 -0
  56. data/docs/source/fonts/FranklinGothic-Med-webfont.woff +0 -0
  57. data/docs/source/fonts/FranklinGothic-MedCd-webfont.eot +0 -0
  58. data/docs/source/fonts/FranklinGothic-MedCd-webfont.svg +240 -0
  59. data/docs/source/fonts/FranklinGothic-MedCd-webfont.ttf +0 -0
  60. data/docs/source/fonts/FranklinGothic-MedCd-webfont.woff +0 -0
  61. data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.eot +0 -0
  62. data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.svg +240 -0
  63. data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.ttf +0 -0
  64. data/docs/source/fonts/FranklinGothic-MedCdIt-webfont.woff +0 -0
  65. data/docs/source/fonts/FranklinGothic-MedIt-webfont.eot +0 -0
  66. data/docs/source/fonts/FranklinGothic-MedIt-webfont.svg +240 -0
  67. data/docs/source/fonts/FranklinGothic-MedIt-webfont.ttf +0 -0
  68. data/docs/source/fonts/FranklinGothic-MedIt-webfont.woff +0 -0
  69. data/docs/source/fonts/License.txt +77 -0
  70. data/docs/source/fonts/susy.eot +0 -0
  71. data/docs/source/fonts/susy.svg +69 -0
  72. data/docs/source/fonts/susy.ttf +0 -0
  73. data/docs/source/fonts/susy.woff +0 -0
  74. data/docs/source/guides/getting-started.html.md +277 -0
  75. data/docs/source/guides/reference.html.md +658 -0
  76. data/docs/source/guides/upgrade-1-0.html.md +286 -0
  77. data/docs/source/humans.txt +45 -0
  78. data/docs/source/images/splash-iphone.png +0 -0
  79. data/docs/source/images/splash-iphone4.png +0 -0
  80. data/docs/source/images/splash-landscape.png +0 -0
  81. data/docs/source/images/splash-portrait.png +0 -0
  82. data/docs/source/index.html.md +87 -0
  83. data/docs/source/javascripts/jquery-1.7.1.min.js +4 -0
  84. data/docs/source/javascripts/jqwidont.js +5 -0
  85. data/docs/source/javascripts/modernizr-2.5.3.min.js +4 -0
  86. data/docs/source/javascripts/modernizr.selectors.js +55 -0
  87. data/docs/source/javascripts/viewport.js +9 -0
  88. data/docs/source/layouts/grid-types.haml +22 -0
  89. data/docs/source/layouts/layout.haml +34 -0
  90. data/docs/source/layouts/magic.haml +28 -0
  91. data/docs/source/partials/_contentinfo.haml +47 -0
  92. data/docs/source/partials/_demonav.haml +2 -0
  93. data/docs/source/partials/_google_analytics.haml +5 -0
  94. data/docs/source/partials/_head.haml +22 -0
  95. data/docs/source/partials/_javascripts.haml +4 -0
  96. data/docs/source/partials/_navigation.haml +15 -0
  97. data/docs/source/sites-using-susy.html.md +29 -0
  98. data/docs/source/stylesheets/_base/_base.scss +23 -0
  99. data/docs/source/stylesheets/_base/_colors.scss +47 -0
  100. data/docs/source/stylesheets/_base/_size.scss +49 -0
  101. data/docs/source/stylesheets/_base/_type.scss +19 -0
  102. data/docs/source/stylesheets/_demos/_demo.scss +28 -0
  103. data/docs/source/stylesheets/_demos/magic/_layout.scss +39 -0
  104. data/docs/source/stylesheets/_demos/magic/_style.scss +104 -0
  105. data/docs/source/stylesheets/_demos/types/_layouts.scss +88 -0
  106. data/docs/source/stylesheets/_demos/types/_template.scss +57 -0
  107. data/docs/source/stylesheets/_general/_century-oldstyle.scss +70 -0
  108. data/docs/source/stylesheets/_general/_font-license.scss +23 -0
  109. data/docs/source/stylesheets/_general/_fonts.scss +26 -0
  110. data/docs/source/stylesheets/_general/_franklin-gothic.scss +112 -0
  111. data/docs/source/stylesheets/_general/_icons.scss +86 -0
  112. data/docs/source/stylesheets/_general/_root.scss +79 -0
  113. data/docs/source/stylesheets/_general/_type.scss +114 -0
  114. data/docs/source/stylesheets/_layout.scss +48 -0
  115. data/docs/source/stylesheets/_modules/_ag-test.scss +59 -0
  116. data/docs/source/stylesheets/_modules/_banner.scss +61 -0
  117. data/docs/source/stylesheets/_modules/_contentinfo.scss +41 -0
  118. data/docs/source/stylesheets/_modules/_intro.scss +53 -0
  119. data/docs/source/stylesheets/_modules/_nav.scss +44 -0
  120. data/docs/source/stylesheets/_modules/_pages.scss +5 -0
  121. data/docs/source/stylesheets/_modules/_secondary.scss +22 -0
  122. data/docs/source/stylesheets/_modules/_toggle.scss +40 -0
  123. data/docs/source/stylesheets/_vendor/pygments/solarized.scss +65 -0
  124. data/docs/source/stylesheets/grid-types.css.scss +6 -0
  125. data/docs/source/stylesheets/magic.css.scss +6 -0
  126. data/docs/source/stylesheets/site.css.scss +27 -0
  127. data/lib/susy.rb +12 -1
  128. data/sass/README.md +33 -0
  129. data/sass/_susy.scss +55 -16
  130. data/sass/susy/_api.scss +39 -0
  131. data/sass/susy/_grids.scss +2 -0
  132. data/sass/susy/_gutters.scss +2 -0
  133. data/sass/susy/_helpers.scss +14 -0
  134. data/sass/susy/_language.scss +3 -0
  135. data/sass/susy/_math.scss +3 -0
  136. data/sass/susy/api/_float.scss +72 -0
  137. data/sass/susy/api/_isolation.scss +16 -0
  138. data/sass/susy/grids/_add.scss +10 -0
  139. data/sass/susy/grids/_find.scss +10 -0
  140. data/sass/susy/gutters/_add.scss +10 -0
  141. data/sass/susy/gutters/_find.scss +10 -0
  142. data/sass/susy/helpers/_background-grid.scss +65 -0
  143. data/sass/susy/helpers/_box-sizing.scss +25 -0
  144. data/sass/susy/helpers/_clearfix.scss +51 -0
  145. data/sass/susy/helpers/_columns.scss +15 -0
  146. data/sass/susy/helpers/_find.scss +63 -0
  147. data/sass/susy/helpers/_sass-lists.scss +71 -0
  148. data/sass/susy/helpers/_span-shared.scss +9 -0
  149. data/sass/susy/language/_parse-add.scss +19 -0
  150. data/sass/susy/language/_parse-list.scss +53 -0
  151. data/sass/susy/language/_span.scss +20 -0
  152. data/sass/susy/math/_columns.scss +70 -0
  153. data/sass/susy/math/_context.scss +3 -0
  154. data/sass/susy/math/_gutters.scss +11 -0
  155. data/templates/box-sizing/behaviors/box-sizing/boxsizing.htc +399 -0
  156. data/templates/box-sizing/behaviors/box-sizing/boxsizing.php +23 -0
  157. data/templates/box-sizing/manifest.rb +4 -0
  158. data/templates/project/README.md +59 -0
  159. data/templates/project/_base.scss +0 -10
  160. data/templates/project/behaviors/box-sizing/boxsizing.htc +399 -0
  161. data/templates/project/behaviors/box-sizing/boxsizing.php +23 -0
  162. data/templates/project/manifest.rb +3 -0
  163. data/templates/project/screen.scss +0 -8
  164. metadata +200 -43
  165. data/Manifest +0 -39
  166. data/Rakefile +0 -19
  167. data/VERSION +0 -1
  168. data/sass/susy/_background.scss +0 -18
  169. data/sass/susy/_functions.scss +0 -376
  170. data/sass/susy/_grid.scss +0 -286
  171. data/sass/susy/_isolation.scss +0 -51
  172. data/sass/susy/_margin.scss +0 -93
  173. data/sass/susy/_media.scss +0 -112
  174. data/sass/susy/_padding.scss +0 -92
  175. data/sass/susy/_settings.scss +0 -56
  176. data/sass/susy/_support.scss +0 -198
  177. data/sass/susy/_units.scss +0 -159
  178. data/susy.gemspec +0 -35
  179. data/test/config.rb +0 -10
  180. data/test/css/background.css +0 -16
  181. data/test/css/bleed.css +0 -20
  182. data/test/css/functions.css +0 -7
  183. data/test/css/grid.css +0 -134
  184. data/test/css/isolation.css +0 -46
  185. data/test/css/margin.css +0 -20
  186. data/test/css/media.css +0 -101
  187. data/test/css/padding.css +0 -12
  188. data/test/scss/background.scss +0 -11
  189. data/test/scss/bleed.scss +0 -19
  190. data/test/scss/functions.scss +0 -15
  191. data/test/scss/grid.scss +0 -77
  192. data/test/scss/isolation.scss +0 -19
  193. data/test/scss/margin.scss +0 -27
  194. data/test/scss/media.scss +0 -50
  195. data/test/scss/padding.scss +0 -19
@@ -0,0 +1,9 @@
1
+ @mixin span-shared {
2
+ @if $include-border-box {
3
+ @include box-sizing('border-box');
4
+ }
5
+
6
+ @if $include-clearfix {
7
+ @include clearfix;
8
+ }
9
+ }
@@ -0,0 +1,19 @@
1
+ @function parse-add($definition) {
2
+ $grid: ();
3
+ $mq: false;
4
+ $mq-find: false;
5
+
6
+ @each $item in $definition {
7
+ @if $item != 'at' and $mq-find != true {
8
+ $grid: append($grid, $item, 'space');
9
+ }
10
+ @else if $item == 'at' {
11
+ $mq-find: true;
12
+ }
13
+ @else {
14
+ $mq: $item;
15
+ }
16
+ }
17
+
18
+ @return ($grid $mq);
19
+ }
@@ -0,0 +1,53 @@
1
+ //////////////////////////////
2
+ // Parse natural language string
3
+ //
4
+ // Retrieve values from the natural language string.
5
+ // parse-string($var, $list)
6
+ // $var : <string>
7
+ // - at/span/of or any other keywords.
8
+ // - 'span' queries the unprefixed span declaration.
9
+ // - 'at' can also query first, last, alpha, and omega.
10
+ // $list : <list>
11
+ // - A list like this: last 2 of (1 1 2) push 1
12
+ //
13
+ //////////////////////////////
14
+ @function parse-span-list($var, $list) {
15
+
16
+ $found: false;
17
+
18
+ $grid: ();
19
+
20
+ // Loop through list.
21
+ @each $item in $list {
22
+
23
+ // if 'span' - return the first numeric.
24
+ // if keyword was found - return the following item.
25
+ @if (type-of($item) == number and $var == span and $found != 'grid') or $found == true {
26
+
27
+ // @if $found == true
28
+ @return $item;
29
+ }
30
+
31
+ // Special handling for Grids
32
+ @else if $item == $var and $var == 'of' {
33
+ $found: 'grid';
34
+ }
35
+
36
+ @else if $found == 'grid' {
37
+ @if type-of($item) == number {
38
+ $grid: append($grid, $item, 'space');
39
+ }
40
+ @else {
41
+ @return $grid;
42
+ }
43
+ }
44
+
45
+ // Any keyword - return the following value.
46
+ @else if $item == $var {
47
+ $found: true;
48
+ }
49
+ }
50
+
51
+ // Wasn't found.
52
+ @return false;
53
+ }
@@ -0,0 +1,20 @@
1
+ //////////////////////////////
2
+ // "Natural Language" Parsing
3
+ //
4
+ // Keywords:
5
+ // span: Column Span
6
+ // at: Column Location
7
+ // of: Context
8
+ // gutters: Gutters
9
+ // output: Output
10
+ //////////////////////////////
11
+ @mixin span($input) {
12
+ $span: nth($input, 1);
13
+
14
+ $location: parse-span-list('at', $input);
15
+ $context: parse-span-list('of', $input);
16
+ $gutter: parse-span-list('gutters', $input);
17
+ $output: parse-span-list('output', $input);
18
+
19
+ @include grid-span($span, $location, $context, $gutter, $output)
20
+ }
@@ -0,0 +1,70 @@
1
+ //////////////////////////////
2
+ // Find width, in percentages, of the column span
3
+ //////////////////////////////
4
+ @function column-span($span, $location, $columns: false, $gutter: false) {
5
+
6
+ // Find the columns and gutters
7
+ $columns: find-grid($columns);
8
+ $gutter: find-gutter($gutter);
9
+
10
+ // Combine the columns and gutters
11
+ $columns-and-gutters: column-sum($columns, $gutter);
12
+
13
+ // Equal width columns are easy! Deal with them!
14
+ @if type-of($columns) == 'number' or length($columns) == 1 {
15
+ $span-and-gutters: $span + (($span - 1) * nth($gutter, 1));
16
+ @return $span-and-gutters / $columns-and-gutters * 100%;
17
+ }
18
+ // Asymmetric lists are harder, so we're going to treat them as their own columns
19
+ @else if type-of($columns) == 'list' or length($columns) > 1 {
20
+ // Build a fake column set
21
+ $sum: 0;
22
+ $holder: ();
23
+
24
+ @for $i from $location to ($location + $span) {
25
+ $holder: append($holder, nth(nth($columns, $i), 1), comma);
26
+ }
27
+
28
+ // Get sub-column sum
29
+ $span-and-gutters: column-sum($holder, $gutter);
30
+ @return $span-and-gutters / $columns-and-gutters * 100%;
31
+ }
32
+ @else {
33
+ @warn "Can't find a working set of columns! That's terrible!";
34
+ @return false;
35
+ }
36
+ }
37
+
38
+ //////////////////////////////
39
+ // Find the total sum of the columns
40
+ //////////////////////////////
41
+ @function column-sum($columns, $gutter) {
42
+ @if type-of($columns) == 'number' or length($columns) == 1 {
43
+ @return nth($columns, 1) + ((column-count(nth($columns, 1)) - 1) * nth($gutter, 1));
44
+ }
45
+ @else if type-of($columns) == 'list' {
46
+ $sum: 0;
47
+ @each $column in $columns {
48
+ $sum: $sum + nth($column, 1);
49
+ }
50
+ $sum: $sum + (column-count($columns) - 1) * nth($gutter, 1);
51
+ @return $sum;
52
+ }
53
+ }
54
+
55
+ //////////////////////////////
56
+ // Find the number of columns
57
+ //////////////////////////////
58
+ @function column-count($columns) {
59
+ @if type-of($columns) == 'number' {
60
+ @return $columns;
61
+ }
62
+ @if type-of($columns) == 'list' {
63
+ @if length($columns) == 1 {
64
+ @return nth($columns, 1);
65
+ }
66
+ @else {
67
+ @return length($columns);
68
+ }
69
+ }
70
+ }
@@ -0,0 +1,3 @@
1
+ @function context($primary, $secondary) {
2
+ @return ($primary * $secondary) / 100%;;
3
+ }
@@ -0,0 +1,11 @@
1
+ @function gutter-span($gutter: false, $columns: false) {
2
+
3
+ // Find the columns and gutters
4
+ $columns: find-grid($columns);
5
+ $gutter: find-gutter($gutter);
6
+
7
+ // Combine the columns and gutters
8
+ $columns-and-gutters: column-sum($columns, $gutter);
9
+
10
+ @return (nth($gutter, 1) / $columns-and-gutters) * 100%
11
+ }
@@ -0,0 +1,399 @@
1
+ /**
2
+ * box-sizing Polyfill
3
+ *
4
+ * A polyfill for box-sizing: border-box for IE6 & IE7.
5
+ *
6
+ * JScript
7
+ *
8
+ * This program is free software: you can redistribute it and/or modify
9
+ * it under the terms of the GNU Lesser General Public License as published
10
+ * by the Free Software Foundation, either version 3 of the License, or
11
+ * (at your option) any later version.
12
+ *
13
+ * This program is distributed in the hope that it will be useful,
14
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
+ * GNU Lesser General Public License for more details.
17
+ *
18
+ * See <http://www.gnu.org/licenses/lgpl-3.0.txt>
19
+ *
20
+ * @category JScript
21
+ * @package box-sizing-polyfill
22
+ * @author Christian Schepp Schaefer <schaepp@gmx.de> <http://twitter.com/derSchepp>
23
+ * @copyright 2012 Christian Schepp Schaefer
24
+ * @license http://www.gnu.org/copyleft/lesser.html The GNU LESSER GENERAL PUBLIC LICENSE, Version 3.0
25
+ * @link http://github.com/Schepp/box-sizing-polyfill
26
+ *
27
+ * PREFACE:
28
+ *
29
+ * This box-sizing polyfill is based on previous work done by Erik Arvidsson,
30
+ * which he published in 2002 on http://webfx.eae.net/dhtml/boxsizing/boxsizing.html.
31
+ *
32
+ * USAGE:
33
+ *
34
+ * Add the behavior/HTC after every `box-sizing: border-box;` that you assign:
35
+ *
36
+ * box-sizing: border-box;
37
+ * *behavior: url(/scripts/boxsizing.htc);`
38
+ *
39
+ * Prefix the `behavior` property with a star, like seen above, so it will only be seen by
40
+ * IE6 & IE7, not by IE8+ who already implement box-sizing.
41
+ *
42
+ * The URL to the HTC file must be relative to your HTML(!) document, not relative to your CSS.
43
+ * That's why I'd advise you to use absolute paths like in the example.
44
+ *
45
+ */
46
+ <component lightWeight="true">
47
+ <attach event="onpropertychange" onevent="checkPropertyChange()" />
48
+ <attach event="ondetach" onevent="restore()" />
49
+ <attach event="onresize" for="window" onevent="update()" />
50
+ <script type="text/javascript">
51
+ //<![CDATA[
52
+
53
+ var viewportwidth = (typeof window.innerWidth != 'undefined' ? window.innerWidth : element.document.documentElement.clientWidth);
54
+
55
+ // Shortcut for the document object
56
+ var doc = element.document;
57
+
58
+ // Buffer for multiple resize events
59
+ var resizetimeout = null;
60
+
61
+ // Don't apply box-sizing to certain elements
62
+ var apply = false;
63
+ switch(element.nodeName){
64
+ case '#comment':
65
+ case 'HTML':
66
+ case 'HEAD':
67
+ case 'TITLE':
68
+ case 'SCRIPT':
69
+ case 'STYLE':
70
+ case 'LINK':
71
+ case 'META':
72
+ break;
73
+
74
+ default:
75
+ apply = true;
76
+ break;
77
+ }
78
+
79
+ /*
80
+ * update gets called during resize events, then waits until there are no further resize events, and finally triggers a recalculation
81
+ */
82
+ function update(){
83
+ if(resizetimeout !== null){
84
+ window.clearTimeout(resizetimeout);
85
+ }
86
+ resizetimeout = window.setTimeout(function(){
87
+ restore();
88
+ init();
89
+ resizetimeout = null;
90
+ },100);
91
+ }
92
+
93
+ /*
94
+ * restore gets called when the behavior is being detached (see event binding at the top),
95
+ * resets everything like it was before applying the behavior
96
+ */
97
+ function restore(){
98
+ if(apply){
99
+ element.runtimeStyle.removeAttribute("width");
100
+ element.runtimeStyle.removeAttribute("height");
101
+ }
102
+ }
103
+
104
+ /*
105
+ * init gets called once at the start and then never again,
106
+ * triggers box-sizing calculations and updates width and height
107
+ */
108
+ function init(){
109
+ if(apply){
110
+ updateBorderBoxWidth();
111
+ updateBorderBoxHeight();
112
+ }
113
+ }
114
+
115
+ /*
116
+ * checkPropertyChange gets called as soon as an element property changes
117
+ * (see event binding at the top), it then checks if any property influencing its
118
+ * dimensions was changed and if yes recalculates width and height
119
+ */
120
+ function checkPropertyChange(){
121
+ if(apply){
122
+ var pn = event.propertyName;
123
+ if(pn === "style.boxSizing" && element.style.boxSizing === ""){
124
+ element.style.removeAttribute("boxSizing");
125
+ element.runtimeStyle.removeAttribute("boxSizing");
126
+ element.runtimeStyle.removeAttribute("width");
127
+ element.runtimeStyle.removeAttribute("height");
128
+ }
129
+ switch (pn){
130
+ case "style.width":
131
+ case "style.borderLeftWidth":
132
+ case "style.borderLeftStyle":
133
+ case "style.borderRightWidth":
134
+ case "style.borderRightStyle":
135
+ case "style.paddingLeft":
136
+ case "style.paddingRight":
137
+ updateBorderBoxWidth();
138
+ break;
139
+
140
+ case "style.height":
141
+ case "style.borderTopWidth":
142
+ case "style.borderTopStyle":
143
+ case "style.borderBottomWidth":
144
+ case "style.borderBottomStyle":
145
+ case "style.paddingTop":
146
+ case "style.paddingBottom":
147
+ updateBorderBoxHeight();
148
+ break;
149
+
150
+ case "className":
151
+ case "style.boxSizing":
152
+ updateBorderBoxWidth();
153
+ updateBorderBoxHeight();
154
+ break;
155
+ }
156
+ }
157
+ }
158
+
159
+ /*
160
+ * Helper function, taken from Dean Edward's IE7 framework,
161
+ * added by Schepp on 12.06.2010.
162
+ * http://code.google.com/p/ie7-js/
163
+ *
164
+ * Allows us to convert from relative to pixel-values.
165
+ */
166
+ function getPixelValue(value){
167
+ var PIXEL = /^\d+(px)?$/i;
168
+ if (PIXEL.test(value)) return parseInt(value);
169
+ var style = element.style.left;
170
+ var runtimeStyle = element.runtimeStyle.left;
171
+ element.runtimeStyle.left = element.currentStyle.left;
172
+ element.style.left = value || 0;
173
+ value = parseInt(element.style.pixelLeft);
174
+ element.style.left = style;
175
+ element.runtimeStyle.left = runtimeStyle;
176
+
177
+ return value;
178
+ }
179
+
180
+ function getPixelWidth(object, value){
181
+ // For Pixel Values
182
+ var PIXEL = /^\d+(px)?$/i;
183
+ if (PIXEL.test(value)) return parseInt(value);
184
+
185
+ // For Percentage Values
186
+ var PERCENT = /^[\d\.]+%$/i;
187
+ if (PERCENT.test(value)){
188
+ try{
189
+ parentWidth = getPixelWidth(object.parentElement,(object.parentElement.currentStyle.width != "auto" ? object.parentElement.currentStyle.width : "100%"));
190
+ value = (parseFloat(value) / 100) * parentWidth;
191
+ }
192
+ catch(e){
193
+ value = (parseFloat(value) / 100) * element.document.documentElement.clientWidth;
194
+ }
195
+ return parseInt(value);
196
+ }
197
+
198
+ // For EM Values
199
+ var style = object.style.left;
200
+ var runtimeStyle = object.runtimeStyle.left;
201
+ object.runtimeStyle.left = object.currentStyle.left;
202
+ object.style.left = value || 0;
203
+ value = parseInt(object.style.pixelLeft);
204
+ object.style.left = style;
205
+ object.runtimeStyle.left = runtimeStyle;
206
+
207
+ return value;
208
+ }
209
+
210
+ function getPixelHeight(object, value){
211
+ // For Pixel Values
212
+ var PIXEL = /^\d+(px)?$/i;
213
+ if (PIXEL.test(value)) return parseInt(value);
214
+
215
+ // For Percentage Values
216
+ var PERCENT = /^[\d\.]+%$/i;
217
+ if (PERCENT.test(value)){
218
+ try{
219
+ if(object.parentElement.currentStyle.height != "auto"){
220
+ switch(object.parentElement.nodeName){
221
+ default:
222
+ parentHeight = getPixelHeight(object.parentElement,object.parentElement.currentStyle.height);
223
+ if(parentHeight !== "auto"){
224
+ value = (parseFloat(value) / 100) * parentHeight;
225
+ }
226
+ else {
227
+ value = "auto";
228
+ }
229
+ break;
230
+
231
+ case 'HTML':
232
+ parentHeight = element.document.documentElement.clientHeight;
233
+ if(parentHeight !== "auto"){
234
+ value = (parseFloat(value) / 100) * parentHeight;
235
+ }
236
+ else {
237
+ value = "auto";
238
+ }
239
+ break;
240
+ }
241
+ if(value !== "auto") value = parseInt(value);
242
+ }
243
+ else {
244
+ value = "auto";
245
+ }
246
+ }
247
+ catch(e){
248
+ value = "auto";
249
+ }
250
+ return value;
251
+ }
252
+
253
+ // For EM Values
254
+ var style = object.style.left;
255
+ var runtimeStyle = object.runtimeStyle.left;
256
+ object.runtimeStyle.left = object.currentStyle.left;
257
+ object.style.left = value || 0;
258
+ value = parseInt(object.style.pixelLeft);
259
+ object.style.left = style;
260
+ object.runtimeStyle.left = runtimeStyle;
261
+
262
+ return value;
263
+ }
264
+
265
+
266
+ /*
267
+ * getBorderWidth & friends
268
+ * Border width getters
269
+ */
270
+ function getBorderWidth(sSide){
271
+ if(element.currentStyle["border" + sSide + "Style"] == "none"){
272
+ return 0;
273
+ }
274
+ var n = getPixelValue(element.currentStyle["border" + sSide + "Width"]);
275
+ return n || 0;
276
+ }
277
+ function getBorderLeftWidth() { return getBorderWidth("Left"); }
278
+ function getBorderRightWidth() { return getBorderWidth("Right"); }
279
+ function getBorderTopWidth() { return getBorderWidth("Top"); }
280
+ function getBorderBottomWidth() { return getBorderWidth("Bottom"); }
281
+
282
+
283
+ /*
284
+ * getPadding & friends
285
+ * Padding width getters
286
+ */
287
+ function getPadding(sSide) {
288
+ var n = getPixelValue(element.currentStyle["padding" + sSide]);
289
+ return n || 0;
290
+ }
291
+ function getPaddingLeft() { return getPadding("Left"); }
292
+ function getPaddingRight() { return getPadding("Right"); }
293
+ function getPaddingTop() { return getPadding("Top"); }
294
+ function getPaddingBottom() { return getPadding("Bottom"); }
295
+
296
+
297
+
298
+ /*
299
+ * getBoxSizing
300
+ * Get the box-sizing value for the current element
301
+ */
302
+ function getBoxSizing(){
303
+ var s = element.style;
304
+ var cs = element.currentStyle
305
+ if(typeof s.boxSizing != "undefined" && s.boxSizing != ""){
306
+ return s.boxSizing;
307
+ }
308
+ if(typeof s["box-sizing"] != "undefined" && s["box-sizing"] != ""){
309
+ return s["box-sizing"];
310
+ }
311
+ if(typeof cs.boxSizing != "undefined" && cs.boxSizing != ""){
312
+ return cs.boxSizing;
313
+ }
314
+ if(typeof cs["box-sizing"] != "undefined" && cs["box-sizing"] != ""){
315
+ return cs["box-sizing"];
316
+ }
317
+ return getDocumentBoxSizing();
318
+ }
319
+
320
+
321
+ /*
322
+ * getDocumentBoxSizing
323
+ * Get the default document box sizing (check for quirks mode)
324
+ */
325
+ function getDocumentBoxSizing(){
326
+ if(doc.compatMode === null || doc.compatMode === "BackCompat"){
327
+ return "border-box";
328
+ }
329
+ return "content-box"
330
+ }
331
+
332
+
333
+ /*
334
+ * setBorderBoxWidth & friends
335
+ * Width and height setters
336
+ */
337
+ function setBorderBoxWidth(n){
338
+ element.runtimeStyle.width = Math.max(0, n - getBorderLeftWidth() -
339
+ getPaddingLeft() - getPaddingRight() - getBorderRightWidth()) + "px";
340
+ }
341
+ function setBorderBoxHeight(n){
342
+ element.runtimeStyle.height = Math.max(0, n - getBorderTopWidth() -
343
+ getPaddingTop() - getPaddingBottom() - getBorderBottomWidth()) + "px";
344
+ }
345
+ function setContentBoxWidth(n){
346
+ element.runtimeStyle.width = Math.max(0, n + getBorderLeftWidth() +
347
+ getPaddingLeft() + getPaddingRight() + getBorderRightWidth()) + "px";
348
+ }
349
+ function setContentBoxHeight(n){
350
+ element.runtimeStyle.height = Math.max(0, n + getBorderTopWidth() +
351
+ getPaddingTop() + getPaddingBottom() + getBorderBottomWidth()) + "px";
352
+ }
353
+
354
+
355
+ /*
356
+ * updateBorderBoxWidth & updateBorderBoxHeight
357
+ *
358
+ */
359
+ function updateBorderBoxWidth() {
360
+ if(getDocumentBoxSizing() == getBoxSizing()){
361
+ return;
362
+ }
363
+ var csw = element.currentStyle.width;
364
+ if(csw != "auto"){
365
+ csw = getPixelWidth(element,csw);
366
+ if(getBoxSizing() == "border-box"){
367
+ setBorderBoxWidth(parseInt(csw));
368
+ }
369
+ else{
370
+ setContentBoxWidth(parseInt(csw));
371
+ }
372
+ }
373
+ }
374
+
375
+ function updateBorderBoxHeight() {
376
+ if(getDocumentBoxSizing() == getBoxSizing()){
377
+ return;
378
+ }
379
+ var csh = element.currentStyle.height;
380
+ if(csh != "auto"){
381
+ csh = getPixelHeight(element,csh);
382
+ if(csh !== "auto"){
383
+ if(getBoxSizing() == "border-box"){
384
+ setBorderBoxHeight(parseInt(csh));
385
+ }
386
+ else{
387
+ setContentBoxHeight(parseInt(csh));
388
+ }
389
+ }
390
+ }
391
+ }
392
+
393
+
394
+ // Run the calculations
395
+ init();
396
+
397
+ //]]>
398
+ </script>
399
+ </component>