shibori 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +27 -0
  5. data/Procfile +1 -0
  6. data/README.md +24 -0
  7. data/Rakefile +2 -0
  8. data/app.json +11 -0
  9. data/builder/lineage_hunter.js +80 -0
  10. data/builder/list_item_hunter.js +106 -0
  11. data/builder/media_hunter.js +51 -0
  12. data/builder/object_factory.js +60 -0
  13. data/builder/parameter_hunter.js +69 -0
  14. data/builder/pattern_assembler.js +258 -0
  15. data/builder/pattern_exporter.js +43 -0
  16. data/builder/patternlab.js +365 -0
  17. data/builder/patternlab_grunt.js +38 -0
  18. data/builder/patternlab_gulp.js +26 -0
  19. data/builder/pseudopattern_hunter.js +78 -0
  20. data/config.json +34 -0
  21. data/docs/Pattern Lab Node.md +225 -0
  22. data/favicon.ico +0 -0
  23. data/gulpfile.js +148 -0
  24. data/index.js +20 -0
  25. data/lib/shibori/version.rb +3 -0
  26. data/lib/shibori.rb +11 -0
  27. data/package.json +44 -0
  28. data/public/data/annotations.js +109 -0
  29. data/public/styleguide/css/static.css +458 -0
  30. data/public/styleguide/css/static.scss +404 -0
  31. data/public/styleguide/css/styleguide-specific.css +170 -0
  32. data/public/styleguide/css/styleguide-specific.scss +204 -0
  33. data/public/styleguide/css/styleguide.css +880 -0
  34. data/public/styleguide/css/styleguide.scss +950 -0
  35. data/public/styleguide/css/vendor/prism.css +112 -0
  36. data/public/styleguide/css/vendor/typeahead.css +66 -0
  37. data/public/styleguide/fonts/icomoon.eot +0 -0
  38. data/public/styleguide/fonts/icomoon.svg +22 -0
  39. data/public/styleguide/fonts/icomoon.ttf +0 -0
  40. data/public/styleguide/fonts/icomoon.woff +0 -0
  41. data/public/styleguide/html/README +1 -0
  42. data/public/styleguide/images/spinner.gif +0 -0
  43. data/public/styleguide/js/annotations-pattern.js +308 -0
  44. data/public/styleguide/js/annotations-viewer.js +289 -0
  45. data/public/styleguide/js/code-pattern.js +120 -0
  46. data/public/styleguide/js/code-viewer.js +443 -0
  47. data/public/styleguide/js/data-saver.js +169 -0
  48. data/public/styleguide/js/pattern-finder.js +114 -0
  49. data/public/styleguide/js/postmessage.js +127 -0
  50. data/public/styleguide/js/styleguide.js +600 -0
  51. data/public/styleguide/js/url-handler.js +182 -0
  52. data/public/styleguide/js/vendor/classlist-polyfill.js +176 -0
  53. data/public/styleguide/js/vendor/jquery.js +4 -0
  54. data/public/styleguide/js/vendor/jwerty.js +523 -0
  55. data/public/styleguide/js/vendor/prism.js +7 -0
  56. data/public/styleguide/js/vendor/typeahead.bundle.min.js +7 -0
  57. data/script/bootstrap +58 -0
  58. data/shibori.gemspec +18 -0
  59. data/shibori.jpg +0 -0
  60. data/source/_data/annotations.js +109 -0
  61. data/source/_data/data.json +93 -0
  62. data/source/_data/listitems.json +782 -0
  63. data/source/_patternlab-files/README +1 -0
  64. data/source/_patternlab-files/index.mustache +94 -0
  65. data/source/_patternlab-files/partials/ishControls.mustache +64 -0
  66. data/source/_patternlab-files/partials/patternNav.mustache +17 -0
  67. data/source/_patternlab-files/partials/patternPaths.mustache +3 -0
  68. data/source/_patternlab-files/partials/viewAllPaths.mustache +3 -0
  69. data/source/_patternlab-files/pattern-header-footer/README +1 -0
  70. data/source/_patternlab-files/pattern-header-footer/footer.html +34 -0
  71. data/source/_patternlab-files/pattern-header-footer/header.html +44 -0
  72. data/source/_patternlab-files/styleguide.mustache +75 -0
  73. data/source/_patternlab-files/viewall.mustache +75 -0
  74. data/source/_patterns/00-atoms/00-typography/00-headings.mustache +6 -0
  75. data/source/_patterns/00-atoms/00-typography/01-headings-options.mustache +7 -0
  76. data/source/_patterns/00-atoms/00-typography/02-body.mustache +2 -0
  77. data/source/_patterns/00-atoms/00-typography/03-text-manipulation.mustache +12 -0
  78. data/source/_patterns/00-atoms/00-typography/04-blockquotes.mustache +3 -0
  79. data/source/_patterns/00-atoms/00-typography/05-lists.mustache +64 -0
  80. data/source/_patterns/00-atoms/01-colors/00-colors-monochromatic.mustache +36 -0
  81. data/source/_patterns/00-atoms/01-colors/01-colors-brand.mustache +26 -0
  82. data/source/_patterns/00-atoms/01-colors/02-colors-gradients.mustache +38 -0
  83. data/source/_patterns/00-atoms/02-buttons/00-btn-lg.mustache +7 -0
  84. data/source/_patterns/00-atoms/02-buttons/01-btn-sm.mustache +7 -0
  85. data/source/_patterns/00-atoms/02-buttons/02-btn-xs.mustache +7 -0
  86. data/source/_patterns/00-atoms/02-buttons/03-btn-block.mustache +7 -0
  87. data/source/_patterns/00-atoms/02-buttons/04-btn-deploy.mustache +4 -0
  88. data/source/_patterns/00-atoms/03-forms/00-text-fields.mustache +24 -0
  89. data/source/_patterns/00-atoms/03-forms/01-select-menu.mustache +6 -0
  90. data/source/_patterns/00-atoms/03-forms/02-checkbox.mustache +10 -0
  91. data/source/_patterns/00-atoms/03-forms/03-radios.mustache +10 -0
  92. data/source/_patterns/00-atoms/03-forms/04-validation.mustache +14 -0
  93. data/source/_patterns/00-atoms/04-quote/00-pullquote.mustache +7 -0
  94. data/source/_patterns/00-atoms/04-quote/01-quote-small.mustache +7 -0
  95. data/source/_patterns/00-atoms/05-code/01-pre.mustache +11 -0
  96. data/source/_patterns/00-atoms/06-tooltips/00-text.mustache +3 -0
  97. data/source/_patterns/00-atoms/06-tooltips/01-diagram-callout.mustache +1 -0
  98. data/source/_patterns/00-atoms/07-loader/00-spinner.mustache +5 -0
  99. data/source/_patterns/00-atoms/08-readmore/00-readmore.mustache +3 -0
  100. data/source/_patterns/00-atoms/09-slider/00-dots.mustache +8 -0
  101. data/source/_patterns/00-atoms/10-tables/00-tables.mustache +26 -0
  102. data/source/_patterns/00-atoms/12-modal/00-modal.mustache +14 -0
  103. data/source/_patterns/00-atoms/13-panel/00-panel.mustache +3 -0
  104. data/source/_patterns/00-atoms/14-users/00-avatar.mustache +3 -0
  105. data/source/_patterns/00-atoms/15-icons/00-icons.mustache +333 -0
  106. data/source/_patterns/00-atoms/15-icons/04-icon-colors.mustache +38 -0
  107. data/source/_patterns/00-atoms/15-icons/05-icon-sizes.mustache +31 -0
  108. data/source/_patterns/00-atoms/15-icons/_02-languages.mustache +0 -0
  109. data/source/_patterns/00-atoms/15-icons/_03-social.mustache +0 -0
  110. data/source/_patterns/00-atoms/15-icons/_05-icon-containers.mustache +0 -0
  111. data/source/_patterns/00-atoms/16-video/01-video.mustache +3 -0
  112. data/source/_patterns/00-atoms/16-video/_00-play-button.mustache +0 -0
  113. data/source/_patterns/00-atoms/17-utilities/00-visibility.mustache +8 -0
  114. data/source/_patterns/00-atoms/17-utilities/01-ui-elements.mustache +3 -0
  115. data/source/_patterns/00-atoms/18-grid/_00-grid.mustache +0 -0
  116. data/source/_patterns/01-molecules/00-text/00-header-groups.mustache +4 -0
  117. data/source/_patterns/01-molecules/00-text/01-intro-text.mustache +5 -0
  118. data/source/_patterns/01-molecules/01-layout/00-one-up.mustache +8 -0
  119. data/source/_patterns/01-molecules/01-layout/01-two-up.mustache +9 -0
  120. data/source/_patterns/01-molecules/01-layout/02-three-up.mustache +10 -0
  121. data/source/_patterns/01-molecules/01-layout/03-four-up.mustache +11 -0
  122. data/source/_patterns/01-molecules/01-layout/04-masonary-2.mustache +24 -0
  123. data/source/_patterns/01-molecules/01-layout/05-masonary-3.mustache +24 -0
  124. data/source/_patterns/01-molecules/02-navigation/01-subnav.mustache +21 -0
  125. data/source/_patterns/01-molecules/02-navigation/02-breadcrumbs.mustache +25 -0
  126. data/source/_patterns/01-molecules/02-navigation/03-side-nav.mustache +11 -0
  127. data/source/_patterns/01-molecules/02-navigation/04-side-nav-small.mustache +32 -0
  128. data/source/_patterns/01-molecules/02-navigation/05-pagination.mustache +0 -0
  129. data/source/_patterns/01-molecules/02-navigation/06-tabs.mustache +46 -0
  130. data/source/_patterns/01-molecules/03-forms/_00-search.mustache +0 -0
  131. data/source/_patterns/01-molecules/04-slider/00-slider.mustache +8 -0
  132. data/source/_patterns/01-molecules/05-messages/00-alert.mustache +15 -0
  133. data/source/_patterns/01-molecules/06-components/_00-social-share.mustache +0 -0
  134. data/source/_patterns/01-molecules/07-Elements/01-Addons-Card.mustache +79 -0
  135. data/source/_patterns/01-molecules/07-Elements/02-Buttons-Card.mustache +131 -0
  136. data/source/_patterns/01-molecules/07-Elements/03-Buildpack-Card.mustache +109 -0
  137. data/source/_patterns/01-molecules/08-vertical-tabs/01-vertical-tabs.mustache +30 -0
  138. data/source/_patterns/02-organisms/03-sections/00-purple.mustache +11 -0
  139. data/source/_patterns/02-organisms/03-sections/01-purple-dark.mustache +12 -0
  140. data/source/_patterns/02-organisms/03-sections/03-gray-light.mustache +12 -0
  141. data/source/css/hk-icon-rails.scss +13 -0
  142. data/source/css/scss/base/_base.scss +62 -0
  143. data/source/css/scss/base/_fonts.scss +12 -0
  144. data/source/css/scss/base/_normalize.scss +431 -0
  145. data/source/css/scss/base/_type.scss +128 -0
  146. data/source/css/scss/base/_utilities.scss +78 -0
  147. data/source/css/scss/components/_alert.scss +38 -0
  148. data/source/css/scss/components/_animate.scss +3340 -0
  149. data/source/css/scss/components/_animation.scss +15 -0
  150. data/source/css/scss/components/_buttons.scss +175 -0
  151. data/source/css/scss/components/_code.scss +26 -0
  152. data/source/css/scss/components/_forms.scss +136 -0
  153. data/source/css/scss/components/_hero.scss +18 -0
  154. data/source/css/scss/components/_hr.scss +11 -0
  155. data/source/css/scss/components/_icons.scss +85 -0
  156. data/source/css/scss/components/_lists.scss +45 -0
  157. data/source/css/scss/components/_logos.scss +15 -0
  158. data/source/css/scss/components/_masonary.scss +46 -0
  159. data/source/css/scss/components/_modal.scss +218 -0
  160. data/source/css/scss/components/_owlCarousel.scss +270 -0
  161. data/source/css/scss/components/_panel.scss +11 -0
  162. data/source/css/scss/components/_pill-box.scss +38 -0
  163. data/source/css/scss/components/_quote.scss +96 -0
  164. data/source/css/scss/components/_readmore.scss +11 -0
  165. data/source/css/scss/components/_slider.scss +96 -0
  166. data/source/css/scss/components/_spinner.scss +64 -0
  167. data/source/css/scss/components/_sprites.scss +3 -0
  168. data/source/css/scss/components/_sr-only.scss +10 -0
  169. data/source/css/scss/components/_tables.scss +62 -0
  170. data/source/css/scss/components/_tooltips.scss +93 -0
  171. data/source/css/scss/components/_users.scss +11 -0
  172. data/source/css/scss/components/_vertical-tabs.scss +129 -0
  173. data/source/css/scss/components/_video.scss +7 -0
  174. data/source/css/scss/ecosystem/_addons-card.scss +3 -0
  175. data/source/css/scss/ecosystem/_cards.scss +369 -0
  176. data/source/css/scss/ecosystem/_elements-brand.scss +32 -0
  177. data/source/css/scss/ecosystem/_elements.scss +4 -0
  178. data/source/css/scss/globals/_colors.scss +189 -0
  179. data/source/css/scss/globals/_mixins.scss +45 -0
  180. data/source/css/scss/globals/_variables.scss +87 -0
  181. data/source/css/scss/layout/_grid-settings.scss +13 -0
  182. data/source/css/scss/layout/_layout.scss +95 -0
  183. data/source/css/scss/page-elements/_headers.scss +3 -0
  184. data/source/css/scss/page-elements/_navigation.scss +254 -0
  185. data/source/css/scss/page-elements/_sections.scss +66 -0
  186. data/source/css/scss/page-elements/_sidebar.scss +34 -0
  187. data/source/css/shibori.scss +63 -0
  188. data/source/fonts/bentonsans/bentonsans-book.eot +0 -0
  189. data/source/fonts/bentonsans/bentonsans-book.svg +400 -0
  190. data/source/fonts/bentonsans/bentonsans-book.ttf +0 -0
  191. data/source/fonts/bentonsans/bentonsans-book.woff +0 -0
  192. data/source/fonts/bentonsans/bentonsans-medium.eot +0 -0
  193. data/source/fonts/bentonsans/bentonsans-medium.svg +416 -0
  194. data/source/fonts/bentonsans/bentonsans-medium.ttf +0 -0
  195. data/source/fonts/bentonsans/bentonsans-medium.woff +0 -0
  196. data/source/fonts/bentonsans/bentonsans-regular.eot +0 -0
  197. data/source/fonts/bentonsans/bentonsans-regular.svg +416 -0
  198. data/source/fonts/bentonsans/bentonsans-regular.ttf +0 -0
  199. data/source/fonts/bentonsans/bentonsans-regular.woff +0 -0
  200. data/source/fonts/hk-icon/hk-icon.eot +0 -0
  201. data/source/fonts/hk-icon/hk-icon.svg +261 -0
  202. data/source/fonts/hk-icon/hk-icon.ttf +0 -0
  203. data/source/fonts/hk-icon/hk-icon.woff +0 -0
  204. data/source/fonts/inconsolata/inconsolata-bold.eot +0 -0
  205. data/source/fonts/inconsolata/inconsolata-bold.svg +239 -0
  206. data/source/fonts/inconsolata/inconsolata-bold.ttf +0 -0
  207. data/source/fonts/inconsolata/inconsolata-bold.woff +0 -0
  208. data/source/fonts/inconsolata/inconsolata-regular.eot +0 -0
  209. data/source/fonts/inconsolata/inconsolata-regular.svg +239 -0
  210. data/source/fonts/inconsolata/inconsolata-regular.ttf +0 -0
  211. data/source/fonts/inconsolata/inconsolata-regular.woff +0 -0
  212. data/source/images/blockquote/close-sm.png +0 -0
  213. data/source/images/blockquote/close.png +0 -0
  214. data/source/images/blockquote/close@2x.png +0 -0
  215. data/source/images/blockquote/open-sm.png +0 -0
  216. data/source/images/blockquote/open.png +0 -0
  217. data/source/images/blockquote/open@2x.png +0 -0
  218. data/source/images/elements/heroku_suported.svg +32 -0
  219. data/source/images/forms/select-input-arrows.svg +8 -0
  220. data/source/js/init.js +26 -0
  221. data/source/js/main.js +22 -0
  222. data/source/js/vendor/bourbon-modal.js +17 -0
  223. data/source/js/vendor/fitvids.js +77 -0
  224. data/source/js/vendor/fixto.js +719 -0
  225. data/source/js/vendor/jquery-2.0.0b2.js +8690 -0
  226. data/source/js/vendor/modernizr.js +4 -0
  227. data/source/js/vendor/owl.carousel.js +3069 -0
  228. data/source/js/vendor/readmore.js +11 -0
  229. data/source/js/vendor/unslider.js +1 -0
  230. data/source/js/vendor/vertical-tabs.js +34 -0
  231. data/test/files/test.css +19 -0
  232. data/test/lineage_hunter_tests.js +262 -0
  233. data/test/list_item_hunter_tests.js +167 -0
  234. data/test/media_hunter_tests.js +74 -0
  235. data/test/object_factory_tests.js +62 -0
  236. data/test/parameter_hunter_tests.js +298 -0
  237. data/test/pattern_assembler_tests.js +43 -0
  238. data/test/patternlab_tests.js +8 -0
  239. metadata +320 -0
@@ -0,0 +1,719 @@
1
+ /*! fixto - v0.4.0 - 2015-06-08
2
+ * http://github.com/bbarakaci/fixto/*/
3
+
4
+
5
+ var fixto = (function ($, window, document) {
6
+
7
+ // Start Computed Style. Please do not modify this module here. Modify it from its own repo. See address below.
8
+
9
+ /*! Computed Style - v0.1.0 - 2012-07-19
10
+ * https://github.com/bbarakaci/computed-style
11
+ * Copyright (c) 2012 Burak Barakaci; Licensed MIT */
12
+ var computedStyle = (function() {
13
+ var computedStyle = {
14
+ getAll : function(element){
15
+ return document.defaultView.getComputedStyle(element);
16
+ },
17
+ get : function(element, name){
18
+ return this.getAll(element)[name];
19
+ },
20
+ toFloat : function(value){
21
+ return parseFloat(value, 10) || 0;
22
+ },
23
+ getFloat : function(element,name){
24
+ return this.toFloat(this.get(element, name));
25
+ },
26
+ _getAllCurrentStyle : function(element) {
27
+ return element.currentStyle;
28
+ }
29
+ };
30
+
31
+ if (document.documentElement.currentStyle) {
32
+ computedStyle.getAll = computedStyle._getAllCurrentStyle;
33
+ }
34
+
35
+ return computedStyle;
36
+
37
+ }());
38
+
39
+ // End Computed Style. Modify whatever you want to.
40
+
41
+ var mimicNode = (function(){
42
+ /*
43
+ Class Mimic Node
44
+ Dependency : Computed Style
45
+ Tries to mimick a dom node taking his styles, dimensions. May go to his repo if gets mature.
46
+ */
47
+
48
+ function MimicNode(element) {
49
+ this.element = element;
50
+ this.replacer = document.createElement('div');
51
+ this.replacer.style.visibility = 'hidden';
52
+ this.hide();
53
+ element.parentNode.insertBefore(this.replacer, element);
54
+ }
55
+
56
+ MimicNode.prototype = {
57
+ replace : function(){
58
+ var rst = this.replacer.style;
59
+ var styles = computedStyle.getAll(this.element);
60
+
61
+ // rst.width = computedStyle.width(this.element) + 'px';
62
+ // rst.height = this.element.offsetHeight + 'px';
63
+
64
+ // Setting offsetWidth
65
+ rst.width = this._width();
66
+ rst.height = this._height();
67
+
68
+ // Adopt margins
69
+ rst.marginTop = styles.marginTop;
70
+ rst.marginBottom = styles.marginBottom;
71
+ rst.marginLeft = styles.marginLeft;
72
+ rst.marginRight = styles.marginRight;
73
+
74
+ // Adopt positioning
75
+ rst.cssFloat = styles.cssFloat;
76
+ rst.styleFloat = styles.styleFloat; //ie8;
77
+ rst.position = styles.position;
78
+ rst.top = styles.top;
79
+ rst.right = styles.right;
80
+ rst.bottom = styles.bottom;
81
+ rst.left = styles.left;
82
+ // rst.borderStyle = styles.borderStyle;
83
+
84
+ rst.display = styles.display;
85
+
86
+ },
87
+
88
+ hide: function () {
89
+ this.replacer.style.display = 'none';
90
+ },
91
+
92
+ _width : function(){
93
+ return this.element.getBoundingClientRect().width + 'px';
94
+ },
95
+
96
+ _widthOffset : function(){
97
+ return this.element.offsetWidth + 'px';
98
+ },
99
+
100
+ _height : function(){
101
+ return this.element.getBoundingClientRect().height + 'px';
102
+ },
103
+
104
+ _heightOffset : function(){
105
+ return this.element.offsetHeight + 'px';
106
+ },
107
+
108
+ destroy: function () {
109
+ $(this.replacer).remove();
110
+
111
+ // set properties to null to break references
112
+ for (var prop in this) {
113
+ if (this.hasOwnProperty(prop)) {
114
+ this[prop] = null;
115
+ }
116
+ }
117
+ }
118
+ };
119
+
120
+ var bcr = document.documentElement.getBoundingClientRect();
121
+ if(!bcr.width){
122
+ MimicNode.prototype._width = MimicNode.prototype._widthOffset;
123
+ MimicNode.prototype._height = MimicNode.prototype._heightOffset;
124
+ }
125
+
126
+ return {
127
+ MimicNode:MimicNode,
128
+ computedStyle:computedStyle
129
+ };
130
+ }());
131
+
132
+ // Class handles vendor prefixes
133
+ function Prefix() {
134
+ // Cached vendor will be stored when it is detected
135
+ this._vendor = null;
136
+
137
+ //this._dummy = document.createElement('div');
138
+ }
139
+
140
+ Prefix.prototype = {
141
+
142
+ _vendors: {
143
+ webkit: { cssPrefix: '-webkit-', jsPrefix: 'Webkit'},
144
+ moz: { cssPrefix: '-moz-', jsPrefix: 'Moz'},
145
+ ms: { cssPrefix: '-ms-', jsPrefix: 'ms'},
146
+ opera: { cssPrefix: '-o-', jsPrefix: 'O'}
147
+ },
148
+
149
+ _prefixJsProperty: function(vendor, prop) {
150
+ return vendor.jsPrefix + prop[0].toUpperCase() + prop.substr(1);
151
+ },
152
+
153
+ _prefixValue: function(vendor, value) {
154
+ return vendor.cssPrefix + value;
155
+ },
156
+
157
+ _valueSupported: function(prop, value, dummy) {
158
+ // IE8 will throw Illegal Argument when you attempt to set a not supported value.
159
+ try {
160
+ dummy.style[prop] = value;
161
+ return dummy.style[prop] === value;
162
+ }
163
+ catch(er) {
164
+ return false;
165
+ }
166
+ },
167
+
168
+ /**
169
+ * Returns true if the property is supported
170
+ * @param {string} prop Property name
171
+ * @returns {boolean}
172
+ */
173
+ propertySupported: function(prop) {
174
+ // Supported property will return either inine style value or an empty string.
175
+ // Undefined means property is not supported.
176
+ return document.documentElement.style[prop] !== undefined;
177
+ },
178
+
179
+ /**
180
+ * Returns prefixed property name for js usage
181
+ * @param {string} prop Property name
182
+ * @returns {string|null}
183
+ */
184
+ getJsProperty: function(prop) {
185
+ // Try native property name first.
186
+ if(this.propertySupported(prop)) {
187
+ return prop;
188
+ }
189
+
190
+ // Prefix it if we know the vendor already
191
+ if(this._vendor) {
192
+ return this._prefixJsProperty(this._vendor, prop);
193
+ }
194
+
195
+ // We don't know the vendor, try all the possibilities
196
+ var prefixed;
197
+ for(var vendor in this._vendors) {
198
+ prefixed = this._prefixJsProperty(this._vendors[vendor], prop);
199
+ if(this.propertySupported(prefixed)) {
200
+ // Vendor detected. Cache it.
201
+ this._vendor = this._vendors[vendor];
202
+ return prefixed;
203
+ }
204
+ }
205
+
206
+ // Nothing worked
207
+ return null;
208
+ },
209
+
210
+ /**
211
+ * Returns supported css value for css property. Could be used to check support or get prefixed value string.
212
+ * @param {string} prop Property
213
+ * @param {string} value Value name
214
+ * @returns {string|null}
215
+ */
216
+ getCssValue: function(prop, value) {
217
+ // Create dummy element to test value
218
+ var dummy = document.createElement('div');
219
+
220
+ // Get supported property name
221
+ var jsProperty = this.getJsProperty(prop);
222
+
223
+ // Try unprefixed value
224
+ if(this._valueSupported(jsProperty, value, dummy)) {
225
+ return value;
226
+ }
227
+
228
+ var prefixedValue;
229
+
230
+ // If we know the vendor already try prefixed value
231
+ if(this._vendor) {
232
+ prefixedValue = this._prefixValue(this._vendor, value);
233
+ if(this._valueSupported(jsProperty, prefixedValue, dummy)) {
234
+ return prefixedValue;
235
+ }
236
+ }
237
+
238
+ // Try all vendors
239
+ for(var vendor in this._vendors) {
240
+ prefixedValue = this._prefixValue(this._vendors[vendor], value);
241
+ if(this._valueSupported(jsProperty, prefixedValue, dummy)) {
242
+ // Vendor detected. Cache it.
243
+ this._vendor = this._vendors[vendor];
244
+ return prefixedValue;
245
+ }
246
+ }
247
+ // No support for value
248
+ return null;
249
+ }
250
+ };
251
+
252
+ var prefix = new Prefix();
253
+
254
+ // We will need this frequently. Lets have it as a global until we encapsulate properly.
255
+ var transformJsProperty = prefix.getJsProperty('transform');
256
+
257
+ // Will hold if browser creates a positioning context for fixed elements.
258
+ var fixedPositioningContext;
259
+
260
+ // Checks if browser creates a positioning context for fixed elements.
261
+ // Transform rule will create a positioning context on browsers who follow the spec.
262
+ // Ie for example will fix it according to documentElement
263
+ // TODO: Other css rules also effects. perspective creates at chrome but not in firefox. transform-style preserve3d effects.
264
+ function checkFixedPositioningContextSupport() {
265
+ var support = false;
266
+ var parent = document.createElement('div');
267
+ var child = document.createElement('div');
268
+ parent.appendChild(child);
269
+ parent.style[transformJsProperty] = 'translate(0)';
270
+ // Make sure there is space on top of parent
271
+ parent.style.marginTop = '10px';
272
+ parent.style.visibility = 'hidden';
273
+ child.style.position = 'fixed';
274
+ child.style.top = 0;
275
+ document.body.appendChild(parent);
276
+ var rect = child.getBoundingClientRect();
277
+ // If offset top is greater than 0 meand transformed element created a positioning context.
278
+ if(rect.top > 0) {
279
+ support = true;
280
+ }
281
+ // Remove dummy content
282
+ document.body.removeChild(parent);
283
+ return support;
284
+ }
285
+
286
+ // It will return null if position sticky is not supported
287
+ var nativeStickyValue = prefix.getCssValue('position', 'sticky');
288
+
289
+ // It will return null if position fixed is not supported
290
+ var fixedPositionValue = prefix.getCssValue('position', 'fixed');
291
+
292
+ // Dirty business
293
+ var ie = navigator.appName === 'Microsoft Internet Explorer';
294
+ var ieversion;
295
+
296
+ if(ie){
297
+ ieversion = parseFloat(navigator.appVersion.split("MSIE")[1]);
298
+ }
299
+
300
+ function FixTo(child, parent, options) {
301
+ this.child = child;
302
+ this._$child = $(child);
303
+ this.parent = parent;
304
+ this.options = {
305
+ className: 'fixto-fixed',
306
+ top: 0
307
+ };
308
+ this._setOptions(options);
309
+ }
310
+
311
+ FixTo.prototype = {
312
+ // Returns the total outerHeight of the elements passed to mind option. Will return 0 if none.
313
+ _mindtop: function () {
314
+ var top = 0;
315
+ if(this._$mind) {
316
+ var el;
317
+ var rect;
318
+ var height;
319
+ for(var i=0, l=this._$mind.length; i<l; i++) {
320
+ el = this._$mind[i];
321
+ rect = el.getBoundingClientRect();
322
+ if(rect.height) {
323
+ top += rect.height;
324
+ }
325
+ else {
326
+ var styles = computedStyle.getAll(el);
327
+ top += el.offsetHeight + computedStyle.toFloat(styles.marginTop) + computedStyle.toFloat(styles.marginBottom);
328
+ }
329
+ }
330
+ }
331
+ return top;
332
+ },
333
+
334
+ // Public method to stop the behaviour of this instance.
335
+ stop: function () {
336
+ this._stop();
337
+ this._running = false;
338
+ },
339
+
340
+ // Public method starts the behaviour of this instance.
341
+ start: function () {
342
+
343
+ // Start only if it is not running not to attach event listeners multiple times.
344
+ if(!this._running) {
345
+ this._start();
346
+ this._running = true;
347
+ }
348
+ },
349
+
350
+ //Public method to destroy fixto behaviour
351
+ destroy: function () {
352
+ this.stop();
353
+
354
+ this._destroy();
355
+
356
+ // Remove jquery data from the element
357
+ this._$child.removeData('fixto-instance');
358
+
359
+ // set properties to null to break references
360
+ for (var prop in this) {
361
+ if (this.hasOwnProperty(prop)) {
362
+ this[prop] = null;
363
+ }
364
+ }
365
+ },
366
+
367
+ _setOptions: function(options) {
368
+ $.extend(this.options, options);
369
+ if(this.options.mind) {
370
+ this._$mind = $(this.options.mind);
371
+ }
372
+ if(this.options.zIndex) {
373
+ this.child.style.zIndex = this.options.zIndex;
374
+ }
375
+ },
376
+
377
+ setOptions: function(options) {
378
+ this._setOptions(options);
379
+ this.refresh();
380
+ },
381
+
382
+ // Methods could be implemented by subclasses
383
+
384
+ _stop: function() {
385
+
386
+ },
387
+
388
+ _start: function() {
389
+
390
+ },
391
+
392
+ _destroy: function() {
393
+
394
+ },
395
+
396
+ refresh: function() {
397
+
398
+ }
399
+ };
400
+
401
+ // Class FixToContainer
402
+ function FixToContainer(child, parent, options) {
403
+ FixTo.call(this, child, parent, options);
404
+ this._replacer = new mimicNode.MimicNode(child);
405
+ this._ghostNode = this._replacer.replacer;
406
+
407
+ this._saveStyles();
408
+
409
+ this._saveViewportHeight();
410
+
411
+ // Create anonymous functions and keep references to register and unregister events.
412
+ this._proxied_onscroll = this._bind(this._onscroll, this);
413
+ this._proxied_onresize = this._bind(this._onresize, this);
414
+
415
+ this.start();
416
+ }
417
+
418
+ FixToContainer.prototype = new FixTo();
419
+
420
+ $.extend(FixToContainer.prototype, {
421
+
422
+ // Returns an anonymous function that will call the given function in the given context
423
+ _bind : function (fn, context) {
424
+ return function () {
425
+ return fn.call(context);
426
+ };
427
+ },
428
+
429
+ // at ie8 maybe only in vm window resize event fires everytime an element is resized.
430
+ _toresize : ieversion===8 ? document.documentElement : window,
431
+
432
+ _onscroll: function _onscroll() {
433
+ this._scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
434
+ this._parentBottom = (this.parent.offsetHeight + this._fullOffset('offsetTop', this.parent));
435
+
436
+ if (this.options.mindBottomPadding !== false) {
437
+ this._parentBottom -= computedStyle.getFloat(this.parent, 'paddingBottom');
438
+ }
439
+
440
+ if (!this.fixed) {
441
+
442
+ var childStyles = computedStyle.getAll(this.child);
443
+
444
+ if (
445
+ this._scrollTop < this._parentBottom &&
446
+ this._scrollTop > (this._fullOffset('offsetTop', this.child) - this.options.top - this._mindtop()) &&
447
+ this._viewportHeight > (this.child.offsetHeight + computedStyle.toFloat(childStyles.marginTop) + computedStyle.toFloat(childStyles.marginBottom))
448
+ ) {
449
+
450
+ this._fix();
451
+ this._adjust();
452
+ }
453
+ } else {
454
+ if (this._scrollTop > this._parentBottom || this._scrollTop < (this._fullOffset('offsetTop', this._ghostNode) - this.options.top - this._mindtop())) {
455
+ this._unfix();
456
+ return;
457
+ }
458
+ this._adjust();
459
+ }
460
+ },
461
+
462
+ _adjust: function _adjust() {
463
+ var top = 0;
464
+ var mindTop = this._mindtop();
465
+ var diff = 0;
466
+ var childStyles = computedStyle.getAll(this.child);
467
+ var context = null;
468
+
469
+ if(fixedPositioningContext) {
470
+ // Get positioning context.
471
+ context = this._getContext();
472
+ if(context) {
473
+ // There is a positioning context. Top should be according to the context.
474
+ top = Math.abs(context.getBoundingClientRect().top);
475
+ }
476
+ }
477
+
478
+ diff = (this._parentBottom - this._scrollTop) - (this.child.offsetHeight + computedStyle.toFloat(childStyles.marginBottom) + mindTop + this.options.top);
479
+
480
+ if(diff>0) {
481
+ diff = 0;
482
+ }
483
+
484
+ this.child.style.top = (diff + mindTop + top + this.options.top) - computedStyle.toFloat(childStyles.marginTop) + 'px';
485
+ },
486
+
487
+ // Calculate cumulative offset of the element.
488
+ // Optionally according to context
489
+ _fullOffset: function _fullOffset(offsetName, elm, context) {
490
+ var offset = elm[offsetName];
491
+ var offsetParent = elm.offsetParent;
492
+
493
+ // Add offset of the ascendent tree until we reach to the document root or to the given context
494
+ while (offsetParent !== null && offsetParent !== context) {
495
+ offset = offset + offsetParent[offsetName];
496
+ offsetParent = offsetParent.offsetParent;
497
+ }
498
+
499
+ return offset;
500
+ },
501
+
502
+ // Get positioning context of the element.
503
+ // We know that the closest parent that a transform rule applied will create a positioning context.
504
+ _getContext: function() {
505
+ var parent;
506
+ var element = this.child;
507
+ var context = null;
508
+ var styles;
509
+
510
+ // Climb up the treee until reaching the context
511
+ while(!context) {
512
+ parent = element.parentNode;
513
+ if(parent === document.documentElement) {
514
+ return null;
515
+ }
516
+
517
+ styles = computedStyle.getAll(parent);
518
+ // Element has a transform rule
519
+ if(styles[transformJsProperty] !== 'none') {
520
+ context = parent;
521
+ break;
522
+ }
523
+ element = parent;
524
+ }
525
+ return context;
526
+ },
527
+
528
+ _fix: function _fix() {
529
+ var child = this.child;
530
+ var childStyle = child.style;
531
+ var childStyles = computedStyle.getAll(child);
532
+ var left = child.getBoundingClientRect().left;
533
+ var width = childStyles.width;
534
+
535
+ this._saveStyles();
536
+
537
+ if(document.documentElement.currentStyle){
538
+ // Function for ie<9. When hasLayout is not triggered in ie7, he will report currentStyle as auto, clientWidth as 0. Thus using offsetWidth.
539
+ // Opera also falls here
540
+ width = (child.offsetWidth) - (computedStyle.toFloat(childStyles.paddingLeft) + computedStyle.toFloat(childStyles.paddingRight) + computedStyle.toFloat(childStyles.borderLeftWidth) + computedStyle.toFloat(childStyles.borderRightWidth)) + 'px';
541
+ }
542
+
543
+ // Ie still fixes the container according to the viewport.
544
+ if(fixedPositioningContext) {
545
+ var context = this._getContext();
546
+ if(context) {
547
+ // There is a positioning context. Left should be according to the context.
548
+ left = child.getBoundingClientRect().left - context.getBoundingClientRect().left;
549
+ }
550
+ }
551
+
552
+ this._replacer.replace();
553
+
554
+ childStyle.left = (left - computedStyle.toFloat(childStyles.marginLeft)) + 'px';
555
+ childStyle.width = width;
556
+
557
+ childStyle.position = 'fixed';
558
+ childStyle.top = this._mindtop() + this.options.top - computedStyle.toFloat(childStyles.marginTop) + 'px';
559
+ this._$child.addClass(this.options.className);
560
+ this.fixed = true;
561
+ },
562
+
563
+ _unfix: function _unfix() {
564
+ var childStyle = this.child.style;
565
+ this._replacer.hide();
566
+ childStyle.position = this._childOriginalPosition;
567
+ childStyle.top = this._childOriginalTop;
568
+ childStyle.width = this._childOriginalWidth;
569
+ childStyle.left = this._childOriginalLeft;
570
+ this._$child.removeClass(this.options.className);
571
+ this.fixed = false;
572
+ },
573
+
574
+ _saveStyles: function(){
575
+ var childStyle = this.child.style;
576
+ this._childOriginalPosition = childStyle.position;
577
+ this._childOriginalTop = childStyle.top;
578
+ this._childOriginalWidth = childStyle.width;
579
+ this._childOriginalLeft = childStyle.left;
580
+ },
581
+
582
+ _onresize: function () {
583
+ this.refresh();
584
+ },
585
+
586
+ _saveViewportHeight: function () {
587
+ // ie8 doesn't support innerHeight
588
+ this._viewportHeight = window.innerHeight || document.documentElement.clientHeight;
589
+ },
590
+
591
+ _stop: function() {
592
+ // Unfix the container immediately.
593
+ this._unfix();
594
+ // remove event listeners
595
+ $(window).unbind('scroll', this._proxied_onscroll);
596
+ $(this._toresize).unbind('resize', this._proxied_onresize);
597
+ },
598
+
599
+ _start: function() {
600
+ // Trigger onscroll to have the effect immediately.
601
+ this._onscroll();
602
+
603
+ // Attach event listeners
604
+ $(window).bind('scroll', this._proxied_onscroll);
605
+ $(this._toresize).bind('resize', this._proxied_onresize);
606
+ },
607
+
608
+ _destroy: function() {
609
+ // Destroy mimic node instance
610
+ this._replacer.destroy();
611
+ },
612
+
613
+ refresh: function() {
614
+ this._saveViewportHeight();
615
+ this._unfix();
616
+ this._onscroll();
617
+ }
618
+ });
619
+
620
+ function NativeSticky(child, parent, options) {
621
+ FixTo.call(this, child, parent, options);
622
+ this.start();
623
+ }
624
+
625
+ NativeSticky.prototype = new FixTo();
626
+
627
+ $.extend(NativeSticky.prototype, {
628
+ _start: function() {
629
+
630
+ var childStyles = computedStyle.getAll(this.child);
631
+
632
+ this._childOriginalPosition = childStyles.position;
633
+ this._childOriginalTop = childStyles.top;
634
+
635
+ this.child.style.position = nativeStickyValue;
636
+ this.refresh();
637
+ },
638
+
639
+ _stop: function() {
640
+ this.child.style.position = this._childOriginalPosition;
641
+ this.child.style.top = this._childOriginalTop;
642
+ },
643
+
644
+ refresh: function() {
645
+ this.child.style.top = this._mindtop() + this.options.top + 'px';
646
+ }
647
+ });
648
+
649
+
650
+
651
+ var fixTo = function fixTo(childElement, parentElement, options) {
652
+ if((nativeStickyValue && !options) || (nativeStickyValue && options && options.useNativeSticky !== false)) {
653
+ // Position sticky supported and user did not disabled the usage of it.
654
+ return new NativeSticky(childElement, parentElement, options);
655
+ }
656
+ else if(fixedPositionValue) {
657
+ // Position fixed supported
658
+
659
+ if(fixedPositioningContext===undefined) {
660
+ // We don't know yet if browser creates fixed positioning contexts. Check it.
661
+ fixedPositioningContext = checkFixedPositioningContextSupport();
662
+ }
663
+
664
+ return new FixToContainer(childElement, parentElement, options);
665
+ }
666
+ else {
667
+ return 'Neither fixed nor sticky positioning supported';
668
+ }
669
+ };
670
+
671
+ /*
672
+ No support for ie lt 8
673
+ */
674
+
675
+ if(ieversion<8){
676
+ fixTo = function(){
677
+ return 'not supported';
678
+ };
679
+ }
680
+
681
+ // Let it be a jQuery Plugin
682
+ $.fn.fixTo = function (targetSelector, options) {
683
+
684
+ var $targets = $(targetSelector);
685
+
686
+ var i = 0;
687
+ return this.each(function () {
688
+
689
+ // Check the data of the element.
690
+ var instance = $(this).data('fixto-instance');
691
+
692
+ // If the element is not bound to an instance, create the instance and save it to elements data.
693
+ if(!instance) {
694
+ $(this).data('fixto-instance', fixTo(this, $targets[i], options));
695
+ }
696
+ else {
697
+ // If we already have the instance here, expect that targetSelector parameter will be a string
698
+ // equal to a public methods name. Run the method on the instance without checking if
699
+ // it exists or it is a public method or not. Cause nasty errors when necessary.
700
+ var method = targetSelector;
701
+ instance[method].call(instance, options);
702
+ }
703
+ i++;
704
+ });
705
+ };
706
+
707
+ /*
708
+ Expose
709
+ */
710
+
711
+ return {
712
+ FixToContainer: FixToContainer,
713
+ fixTo: fixTo,
714
+ computedStyle:computedStyle,
715
+ mimicNode:mimicNode
716
+ };
717
+
718
+
719
+ }(window.jQuery, window, document));