docks_theme_api 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (237) hide show
  1. checksums.yaml +15 -0
  2. data/.babelrc +4 -0
  3. data/.editorconfig +8 -0
  4. data/.eslintrc +115 -0
  5. data/.gitignore +24 -0
  6. data/.rubocop.yml +20 -0
  7. data/.travis.yml +16 -0
  8. data/Gemfile +4 -0
  9. data/README.md +5 -0
  10. data/Rakefile +3 -0
  11. data/assets/images/icons.svg +63 -0
  12. data/assets/scripts/coffeescript/pattern_library_helpers.coffee +8 -0
  13. data/assets/scripts/javascript/pattern_library_helpers.js +11 -0
  14. data/assets/scripts/pattern_library.js +10380 -0
  15. data/assets/scripts/pattern_library_demo.js +0 -0
  16. data/assets/styles/less/pattern-library-helpers.less +103 -0
  17. data/assets/styles/pattern-library-demo.css +1882 -0
  18. data/assets/styles/pattern-library.css +1882 -0
  19. data/assets/styles/sass/pattern-library-helpers.sass +90 -0
  20. data/assets/styles/scss/pattern-library-helpers.scss +99 -0
  21. data/assets/styles/stylus/pattern-library-helpers.styl +90 -0
  22. data/assets/templates/erb/demo.erb +26 -0
  23. data/assets/templates/erb/layouts/demo.erb +17 -0
  24. data/assets/templates/erb/layouts/pattern.erb +76 -0
  25. data/assets/templates/erb/partials/sidebar.erb +124 -0
  26. data/assets/templates/erb/partials/symbols/class.erb +1 -0
  27. data/assets/templates/erb/partials/symbols/demo.erb +40 -0
  28. data/assets/templates/erb/partials/symbols/factory.erb +70 -0
  29. data/assets/templates/erb/partials/symbols/function.erb +103 -0
  30. data/assets/templates/erb/partials/symbols/mixin.erb +62 -0
  31. data/assets/templates/erb/partials/symbols/variable.erb +59 -0
  32. data/assets/templates/erb/pattern.erb +102 -0
  33. data/assets/templates/haml/demo.haml +14 -0
  34. data/assets/templates/haml/layouts/demo.haml +6 -0
  35. data/assets/templates/haml/layouts/pattern.haml +38 -0
  36. data/assets/templates/haml/partials/sidebar.haml +68 -0
  37. data/assets/templates/haml/partials/symbols/class.haml +1 -0
  38. data/assets/templates/haml/partials/symbols/demo.haml +23 -0
  39. data/assets/templates/haml/partials/symbols/factory.haml +38 -0
  40. data/assets/templates/haml/partials/symbols/function.haml +54 -0
  41. data/assets/templates/haml/partials/symbols/mixin.haml +31 -0
  42. data/assets/templates/haml/partials/symbols/variable.haml +22 -0
  43. data/assets/templates/haml/pattern.haml +54 -0
  44. data/assets/templates/slim/demo.slim +24 -0
  45. data/assets/templates/slim/layouts/demo.slim +5 -0
  46. data/assets/templates/slim/layouts/pattern.slim +48 -0
  47. data/assets/templates/slim/partials/sidebar.slim +112 -0
  48. data/assets/templates/slim/partials/symbols/class.slim +1 -0
  49. data/assets/templates/slim/partials/symbols/demo.slim +30 -0
  50. data/assets/templates/slim/partials/symbols/factory.slim +57 -0
  51. data/assets/templates/slim/partials/symbols/function.slim +81 -0
  52. data/assets/templates/slim/partials/symbols/mixin.slim +45 -0
  53. data/assets/templates/slim/partials/symbols/variable.slim +35 -0
  54. data/assets/templates/slim/pattern.slim +63 -0
  55. data/docks_config.rb +32 -0
  56. data/docks_theme_api.gemspec +37 -0
  57. data/gulpfile.js +88 -0
  58. data/karma.conf.js +6 -0
  59. data/lib/docks_theme_api/components/base_component.rb +99 -0
  60. data/lib/docks_theme_api/components/code_block_component.rb +10 -0
  61. data/lib/docks_theme_api/components/popover_component.rb +15 -0
  62. data/lib/docks_theme_api/components/table_component.rb +34 -0
  63. data/lib/docks_theme_api/components/tablist_component.rb +11 -0
  64. data/lib/docks_theme_api/components.rb +21 -0
  65. data/lib/docks_theme_api/helpers/ui_helper.rb +69 -0
  66. data/lib/docks_theme_api/theme.rb +21 -0
  67. data/lib/docks_theme_api.rb +1 -0
  68. data/package.json +60 -0
  69. data/source/behaviors/filterable/filterable.coffee +353 -0
  70. data/source/behaviors/filterable/filterable.js +0 -0
  71. data/source/behaviors/filterable/filterable.scss +34 -0
  72. data/source/behaviors/filterable/package.json +3 -0
  73. data/source/behaviors/index.js +0 -0
  74. data/source/components/avatar/avatar.erb +20 -0
  75. data/source/components/avatar/avatar.js +142 -0
  76. data/source/components/avatar/avatar.scss +200 -0
  77. data/source/components/avatar/avatar_container.erb +13 -0
  78. data/source/components/avatar/package.json +3 -0
  79. data/source/components/avatar/spec/avatar_spec.js +81 -0
  80. data/source/components/badge/badge.scss +158 -0
  81. data/source/components/button/button.scss +213 -0
  82. data/source/components/card/card.scss +32 -0
  83. data/source/components/code_block/code-block.scss +353 -0
  84. data/source/components/code_block/code_block.erb +95 -0
  85. data/source/components/code_block/code_block.js +444 -0
  86. data/source/components/code_block/package.json +3 -0
  87. data/source/components/code_block/spec/code_block_spec.js +10 -0
  88. data/source/components/demo/demo.js +244 -0
  89. data/source/components/demo/demo.scss +90 -0
  90. data/source/components/demo/package.json +3 -0
  91. data/source/components/exploded/exploded.erb +25 -0
  92. data/source/components/exploded/exploded.js +694 -0
  93. data/source/components/exploded/exploded.scss +166 -0
  94. data/source/components/exploded/package.json +3 -0
  95. data/source/components/field/field.js +24 -0
  96. data/source/components/field/field.scss +101 -0
  97. data/source/components/field/package.json +3 -0
  98. data/source/components/header/header.scss +33 -0
  99. data/source/components/iframe/iframe.erb +12 -0
  100. data/source/components/iframe/iframe.js +381 -0
  101. data/source/components/iframe/package.json +3 -0
  102. data/source/components/index.js +37 -0
  103. data/source/components/inline_group/inline-group.scss +14 -0
  104. data/source/components/internal_link/internal_link.js +49 -0
  105. data/source/components/internal_link/package.json +3 -0
  106. data/source/components/list/list.scss +230 -0
  107. data/source/components/modal/modal.coffee +84 -0
  108. data/source/components/modal/modal.erb +19 -0
  109. data/source/components/modal/modal.js +0 -0
  110. data/source/components/modal/modal.scss +57 -0
  111. data/source/components/modal/package.json +3 -0
  112. data/source/components/notice/notice.scss +48 -0
  113. data/source/components/popover/package.json +3 -0
  114. data/source/components/popover/popover.coffee +562 -0
  115. data/source/components/popover/popover.erb +21 -0
  116. data/source/components/popover/popover.js +0 -0
  117. data/source/components/popover/popover.scss +139 -0
  118. data/source/components/range/range.scss +78 -0
  119. data/source/components/resizable/package.json +3 -0
  120. data/source/components/resizable/resizable.erb +30 -0
  121. data/source/components/resizable/resizable.js +250 -0
  122. data/source/components/resizable/resizable.scss +245 -0
  123. data/source/components/resizable/size_buttons.js +249 -0
  124. data/source/components/scroll_container/package.json +3 -0
  125. data/source/components/scroll_container/scroll-container.scss +4 -0
  126. data/source/components/scroll_container/scroll_container.js +24 -0
  127. data/source/components/section/section.scss +99 -0
  128. data/source/components/select/package.json +3 -0
  129. data/source/components/select/select.erb +21 -0
  130. data/source/components/select/select.js +35 -0
  131. data/source/components/select/select.scss +163 -0
  132. data/source/components/table/package.json +3 -0
  133. data/source/components/table/table.erb +16 -0
  134. data/source/components/table/table.js +351 -0
  135. data/source/components/table/table.scss +236 -0
  136. data/source/components/tablist/package.json +3 -0
  137. data/source/components/tablist/tablist.erb +13 -0
  138. data/source/components/tablist/tablist.js +246 -0
  139. data/source/components/tablist/tablist.scss +191 -0
  140. data/source/components/tablist/tablist_panel.erb +14 -0
  141. data/source/components/tablist/tablist_tab.erb +20 -0
  142. data/source/components/toggle/package.json +3 -0
  143. data/source/components/toggle/toggle.erb +11 -0
  144. data/source/components/toggle/toggle.js +211 -0
  145. data/source/components/toggle/toggle_container.erb +30 -0
  146. data/source/components/vertical_spacer/vertical-spacer.scss +3 -0
  147. data/source/components/vertical_stack/vertical-stack.scss +19 -0
  148. data/source/components/xray/package.json +3 -0
  149. data/source/components/xray/xray.erb +50 -0
  150. data/source/components/xray/xray.js +123 -0
  151. data/source/components/xray/xray.scss +79 -0
  152. data/source/foundation/app/app.js +15 -0
  153. data/source/foundation/app/package.json +3 -0
  154. data/source/pattern-library-demo.scss +13 -0
  155. data/source/pattern-library.scss +13 -0
  156. data/source/pattern_library.js +8 -0
  157. data/source/pattern_library_demo.js +8 -0
  158. data/source/structures/index.js +11 -0
  159. data/source/structures/sidebar/package.json +3 -0
  160. data/source/structures/sidebar/sidebar.js +69 -0
  161. data/source/structures/sidebar/sidebar.scss +79 -0
  162. data/source/utilities/builder/builder.js +138 -0
  163. data/source/utilities/builder/package.json +3 -0
  164. data/source/utilities/client/client.js +7 -0
  165. data/source/utilities/client/package.json +3 -0
  166. data/source/utilities/colors/colors.scss +112 -0
  167. data/source/utilities/defaults/defaults.scss +38 -0
  168. data/source/utilities/dom_cache/dom_cache.js +24 -0
  169. data/source/utilities/dom_cache/package.json +3 -0
  170. data/source/utilities/events/events.js +25 -0
  171. data/source/utilities/events/package.json +3 -0
  172. data/source/utilities/font_sizes/font-sizes.scss +85 -0
  173. data/source/utilities/foundation/a11y.scss +10 -0
  174. data/source/utilities/foundation/base.scss +29 -0
  175. data/source/utilities/foundation/icon.scss +114 -0
  176. data/source/utilities/foundation/layout.scss +67 -0
  177. data/source/utilities/foundation/page.scss +39 -0
  178. data/source/utilities/foundation/type.scss +208 -0
  179. data/source/utilities/functions/functions.scss +127 -0
  180. data/source/utilities/keycodes/keycodes.js +23 -0
  181. data/source/utilities/keycodes/package.json +3 -0
  182. data/source/utilities/markup/markup.js +90 -0
  183. data/source/utilities/markup/package.json +3 -0
  184. data/source/utilities/media/media.scss +172 -0
  185. data/source/utilities/mixins/mixins.scss +89 -0
  186. data/source/utilities/naming_convention/naming_convention.js +3 -0
  187. data/source/utilities/naming_convention/package.json +3 -0
  188. data/source/utilities/numbers/numbers.js +14 -0
  189. data/source/utilities/numbers/package.json +3 -0
  190. data/source/utilities/painting/package.json +3 -0
  191. data/source/utilities/painting/painting.js +7 -0
  192. data/source/utilities/pattern/package.json +3 -0
  193. data/source/utilities/pattern/pattern.js +50 -0
  194. data/source/utilities/query_string/package.json +3 -0
  195. data/source/utilities/query_string/query_string.js +24 -0
  196. data/source/utilities/template/package.json +3 -0
  197. data/source/utilities/template/template.js +10 -0
  198. data/source/utilities/text_range/package.json +3 -0
  199. data/source/utilities/text_range/text_range.js +30 -0
  200. data/source/utilities/ui_events/package.json +3 -0
  201. data/source/utilities/ui_events/ui_events.js +85 -0
  202. data/source/utilities/variables/variables.scss +18 -0
  203. data/source/utilities/z_indexes/z-indexes.scss +88 -0
  204. data/source/vendor/array_includes.js +28 -0
  205. data/source/vendor/highlight.js +1142 -0
  206. data/source/vendor/index.js +1 -0
  207. data/source/vendor/matrix.js +399 -0
  208. data/source/vendor/query_string.js +66 -0
  209. data/spec/assets/.eslintrc +9 -0
  210. data/spec/assets/spec_fixture.js +33 -0
  211. data/spec/assets/spec_helper.js +19 -0
  212. data/spec/lib/components/base_component_spec.rb +156 -0
  213. data/spec/lib/components_spec.rb +30 -0
  214. data/spec/lib/helpers/ui_helper_spec.rb +62 -0
  215. data/spec/lib/theme_spec.rb +25 -0
  216. data/spec/spec_helper.rb +15 -0
  217. data/tasks/gulp/.eslintrc +6 -0
  218. data/tasks/gulp/browser_sync.js +8 -0
  219. data/tasks/gulp/code_quality/scripts.js +10 -0
  220. data/tasks/gulp/config/index.js +116 -0
  221. data/tasks/gulp/minify/scripts.js +13 -0
  222. data/tasks/gulp/minify/styles.js +13 -0
  223. data/tasks/gulp/pattern_library/index.js +5 -0
  224. data/tasks/gulp/pattern_library/scripts.js +10 -0
  225. data/tasks/gulp/pattern_library/styles.js +10 -0
  226. data/tasks/gulp/scripts.js +8 -0
  227. data/tasks/gulp/spec/scripts.js +11 -0
  228. data/tasks/gulp/styles.js +17 -0
  229. data/tasks/gulp/utilities/babel/relative_require.js +22 -0
  230. data/tasks/gulp/utilities/babel/spec_helper.js +20 -0
  231. data/tasks/gulp/utilities/browserify_bundler.js +22 -0
  232. data/tasks/gulp/utilities/handle_errors.js +13 -0
  233. data/tasks/gulp/watch.js +9 -0
  234. data/tasks/rake/rspec.rake +7 -0
  235. data/tasks/rake/rubocop.rake +8 -0
  236. data/tasks/rake/templates.rake +50 -0
  237. metadata +470 -0
@@ -0,0 +1 @@
1
+ import "./array_includes";
@@ -0,0 +1,399 @@
1
+ (function () {
2
+
3
+ "use strict";
4
+
5
+ // a CSSMatrix shim
6
+ // http://www.w3.org/TR/css3-3d-transforms/#cssmatrix-interface
7
+ // http://www.w3.org/TR/css3-2d-transforms/#cssmatrix-interface
8
+
9
+
10
+ // decimal values in WebKitCSSMatrix.prototype.toString are truncated to 6 digits
11
+ var SMALL_NUMBER = 1e-6;
12
+
13
+ /**
14
+ * CSSMatrix Shim
15
+ * @constructor
16
+ */
17
+ function CSSMatrix() {
18
+ var a = [].slice.call(arguments),
19
+ m = this;
20
+ if (a.length) for (var i = a.length; i--;) {
21
+ if (Math.abs(a[i]) < SMALL_NUMBER) a[i] = 0;
22
+ }
23
+ setIdentity(m);
24
+ if (a.length == 16) {
25
+ m.m11 = m.a = a[0]; m.m12 = m.b = a[1]; m.m13 = a[2]; m.m14 = a[3];
26
+ m.m21 = m.c = a[4]; m.m22 = m.d = a[5]; m.m23 = a[6]; m.m24 = a[7];
27
+ m.m31 = a[8]; m.m32 = a[9]; m.m33 = a[10]; m.m34 = a[11];
28
+ m.m41 = m.e = a[12]; m.m42 = m.f = a[13]; m.m43 = a[14]; m.m44 = a[15];
29
+ } else if (a.length == 6) {
30
+ m.m11 = m.a = a[0]; m.m12 = m.b = a[1];
31
+ m.m21 = m.c = a[2]; m.m22 = m.d = a[3];
32
+ m.m41 = m.e = a[4]; m.m42 = m.f = a[5];
33
+ } else if (typeof a[0] == 'string') {
34
+ m.setMatrixValue(a[0]);
35
+ } else if (a.length > 0) {
36
+ throw new TypeError('Invalid Matrix Value');
37
+ }
38
+ }
39
+
40
+ // Transformations
41
+
42
+ // http://en.wikipedia.org/wiki/Rotation_matrix
43
+ function rotate(rx, ry, rz) {
44
+ rx *= Math.PI / 180;
45
+ ry *= Math.PI / 180;
46
+ rz *= Math.PI / 180;
47
+ // minus sin() because of right-handed system
48
+ var cosx = Math.cos(rx), sinx = - Math.sin(rx);
49
+ var cosy = Math.cos(ry), siny = - Math.sin(ry);
50
+ var cosz = Math.cos(rz), sinz = - Math.sin(rz);
51
+ var m = new CSSMatrix();
52
+
53
+ m.m11 = m.a = cosy * cosz;
54
+ m.m12 = m.b = - cosy * sinz;
55
+ m.m13 = siny;
56
+
57
+ m.m21 = m.c = sinx * siny * cosz + cosx * sinz;
58
+ m.m22 = m.d = cosx * cosz - sinx * siny * sinz;
59
+ m.m23 = - sinx * cosy;
60
+
61
+ m.m31 = sinx * sinz - cosx * siny * cosz;
62
+ m.m32 = sinx * cosz + cosx * siny * sinz;
63
+ m.m33 = cosx * cosy;
64
+
65
+ return m;
66
+ }
67
+
68
+
69
+ function rotateAxisAngle(x, y, z, angle) {
70
+ angle *= Math.PI / 360;
71
+
72
+ var sinA = Math.sin(angle), cosA = Math.cos(angle), sinA2 = sinA * sinA;
73
+ var length = Math.sqrt(x * x + y * y + z * z);
74
+
75
+ if (length === 0) {
76
+ // bad vector length, use something reasonable
77
+ x = 0;
78
+ y = 0;
79
+ z = 1;
80
+ } else {
81
+ x /= length;
82
+ y /= length;
83
+ z /= length;
84
+ }
85
+
86
+ var x2 = x * x, y2 = y * y, z2 = z * z;
87
+
88
+ var m = new CSSMatrix();
89
+ m.m11 = m.a = 1 - 2 * (y2 + z2) * sinA2;
90
+ m.m12 = m.b = 2 * (x * y * sinA2 + z * sinA * cosA);
91
+ m.m13 = 2 * (x * z * sinA2 - y * sinA * cosA);
92
+ m.m21 = m.c = 2 * (y * x * sinA2 - z * sinA * cosA);
93
+ m.m22 = m.d = 1 - 2 * (z2 + x2) * sinA2;
94
+ m.m23 = 2 * (y * z * sinA2 + x * sinA * cosA);
95
+ m.m31 = 2 * (z * x * sinA2 + y * sinA * cosA);
96
+ m.m32 = 2 * (z * y * sinA2 - x * sinA * cosA);
97
+ m.m33 = 1 - 2 * (x2 + y2) * sinA2;
98
+ m.m14 = m.m24 = m.m34 = 0;
99
+ m.m41 = m.e = m.m42 = m.f = m.m43 = 0;
100
+ m.m44 = 1;
101
+
102
+ return m;
103
+ }
104
+
105
+
106
+ function scale(x, y, z) {
107
+ var m = new CSSMatrix();
108
+ m.m11 = m.a = x;
109
+ m.m22 = m.d = y;
110
+ m.m33 = z;
111
+ return m;
112
+ }
113
+
114
+
115
+ function skewX(angle) {
116
+ angle *= Math.PI / 180;
117
+ var m = new CSSMatrix();
118
+ m.m21 = m.c = Math.tan(angle);
119
+ return m;
120
+ }
121
+
122
+
123
+ function skewY(angle) {
124
+ angle *= Math.PI / 180;
125
+ var m = new CSSMatrix();
126
+ m.m12 = m.b = Math.tan(angle);
127
+ return m;
128
+ }
129
+
130
+
131
+ function translate(x, y, z) {
132
+ var m = new CSSMatrix();
133
+ m.m41 = m.e = x;
134
+ m.m42 = m.f = y;
135
+ m.m43 = z;
136
+ return m;
137
+ }
138
+
139
+
140
+ function inverse(m) {
141
+ throw new Error('the inverse() method is not implemented (yet).');
142
+ }
143
+
144
+
145
+ function multiply(m1, m2) {
146
+
147
+ var m11 = m2.m11 * m1.m11 + m2.m12 * m1.m21 + m2.m13 * m1.m31 + m2.m14 * m1.m41,
148
+ m12 = m2.m11 * m1.m12 + m2.m12 * m1.m22 + m2.m13 * m1.m32 + m2.m14 * m1.m42,
149
+ m13 = m2.m11 * m1.m13 + m2.m12 * m1.m23 + m2.m13 * m1.m33 + m2.m14 * m1.m43,
150
+ m14 = m2.m11 * m1.m14 + m2.m12 * m1.m24 + m2.m13 * m1.m34 + m2.m14 * m1.m44,
151
+
152
+ m21 = m2.m21 * m1.m11 + m2.m22 * m1.m21 + m2.m23 * m1.m31 + m2.m24 * m1.m41,
153
+ m22 = m2.m21 * m1.m12 + m2.m22 * m1.m22 + m2.m23 * m1.m32 + m2.m24 * m1.m42,
154
+ m23 = m2.m21 * m1.m13 + m2.m22 * m1.m23 + m2.m23 * m1.m33 + m2.m24 * m1.m43,
155
+ m24 = m2.m21 * m1.m14 + m2.m22 * m1.m24 + m2.m23 * m1.m34 + m2.m24 * m1.m44,
156
+
157
+ m31 = m2.m31 * m1.m11 + m2.m32 * m1.m21 + m2.m33 * m1.m31 + m2.m34 * m1.m41,
158
+ m32 = m2.m31 * m1.m12 + m2.m32 * m1.m22 + m2.m33 * m1.m32 + m2.m34 * m1.m42,
159
+ m33 = m2.m31 * m1.m13 + m2.m32 * m1.m23 + m2.m33 * m1.m33 + m2.m34 * m1.m43,
160
+ m34 = m2.m31 * m1.m14 + m2.m32 * m1.m24 + m2.m33 * m1.m34 + m2.m34 * m1.m44,
161
+
162
+ m41 = m2.m41 * m1.m11 + m2.m42 * m1.m21 + m2.m43 * m1.m31 + m2.m44 * m1.m41,
163
+ m42 = m2.m41 * m1.m12 + m2.m42 * m1.m22 + m2.m43 * m1.m32 + m2.m44 * m1.m42,
164
+ m43 = m2.m41 * m1.m13 + m2.m42 * m1.m23 + m2.m43 * m1.m33 + m2.m44 * m1.m43,
165
+ m44 = m2.m41 * m1.m14 + m2.m42 * m1.m24 + m2.m43 * m1.m34 + m2.m44 * m1.m44;
166
+
167
+ return new CSSMatrix(
168
+ m11, m12, m13, m14,
169
+ m21, m22, m23, m24,
170
+ m31, m32, m33, m34,
171
+ m41, m42, m43, m44
172
+ );
173
+ }
174
+
175
+ // Helpers
176
+
177
+ /**
178
+ * Set the specified matrix to the identity form
179
+ *
180
+ * @return {CSSMatrix} the matrix
181
+ */
182
+ function setIdentity(m) {
183
+ m.m11 = m.a = 1; m.m12 = m.b = 0; m.m13 = 0; m.m14 = 0;
184
+ m.m21 = m.c = 0; m.m22 = m.d = 1; m.m23 = 0; m.m24 = 0;
185
+ m.m31 = 0; m.m32 = 0; m.m33 = 1; m.m34 = 0;
186
+ m.m41 = m.e = 0; m.m42 = m.f = 0; m.m43 = 0; m.m44 = 1;
187
+ return m;
188
+ }
189
+
190
+ /**
191
+ * Returns true of the given matrix is affine
192
+ *
193
+ * @return {boolean} affine
194
+ */
195
+ function isAffine(m) {
196
+ if (!(m.m13 || m.m14 ||
197
+ m.m23 || m.m24 ||
198
+ m.m31 || m.m32 || m.m33 !== 1 || m.m34 ||
199
+ m.m43 || m.m44 !== 1)) return true;
200
+ return false;
201
+ }
202
+
203
+
204
+ // w3c defined methods
205
+
206
+ /**
207
+ * The setMatrixValue method replaces the existing matrix with one computed
208
+ * from parsing the passed string as though it had been assigned to the
209
+ * transform property in a CSS style rule.
210
+ * @param {String} string The string to parse.
211
+ */
212
+ CSSMatrix.prototype.setMatrixValue = function(string) {
213
+ var i, m = this,
214
+ parts = [],
215
+ patternNone = /^none$/,
216
+ patternMatrix = /^matrix\((.*)\)/,
217
+ patternMatrix3d = /^matrix3d\((.*)\)/;
218
+
219
+ string = String(string).trim();
220
+ setIdentity(m);
221
+
222
+ if (patternNone.test(string)) return m;
223
+
224
+ parts = string.replace(/^.*\((.*)\)$/g, "$1").split(/\s*,\s*/);
225
+ for (i = parts.length; i--;) parts[i] = parseFloat(parts[i]);
226
+
227
+ if (patternMatrix.test(string) && parts.length === 6) {
228
+ m.m11 = m.a = parts[0]; m.m12 = m.b = parts[2]; m.m41 = m.e = parts[4];
229
+ m.m21 = m.c = parts[1]; m.m22 = m.d = parts[3]; m.m42 = m.f = parts[5];
230
+ } else if (patternMatrix3d.test(string) && parts.length === 16) {
231
+ m.m11 = m.a = parts[0]; m.m12 = m.b = parts[1]; m.m13 = parts[2]; m.m14 = parts[3];
232
+ m.m21 = m.c = parts[4]; m.m22 = m.d = parts[5]; m.m23 = parts[6]; m.m24 = parts[7];
233
+ m.m31 = parts[8]; m.m32 = parts[9]; m.m33 = parts[10]; m.m34 = parts[11];
234
+ m.m41 = m.e = parts[12]; m.m42 = m.f = parts[13]; m.m43 = parts[14]; m.m44 = parts[15];
235
+ } else {
236
+ throw new TypeError('Invalid Matrix Value');
237
+ }
238
+ return m;
239
+ };
240
+
241
+
242
+ /**
243
+ * The multiply method returns a new CSSMatrix which is the result of this
244
+ * matrix multiplied by the passed matrix, with the passed matrix to the right.
245
+ * This matrix is not modified.
246
+ *
247
+ * @param {CSSMatrix} m2
248
+ * @return {CSSMatrix} The result matrix.
249
+ */
250
+ CSSMatrix.prototype.multiply = function(m2) {
251
+ return multiply(this, m2);
252
+ };
253
+
254
+
255
+ /**
256
+ * The inverse method returns a new matrix which is the inverse of this matrix.
257
+ * This matrix is not modified.
258
+ *
259
+ * method not implemented yet
260
+ */
261
+ CSSMatrix.prototype.inverse = function() {
262
+ return inverse(this);
263
+ };
264
+
265
+
266
+ /**
267
+ * The translate method returns a new matrix which is this matrix post
268
+ * multiplied by a translation matrix containing the passed values. If the z
269
+ * component is undefined, a 0 value is used in its place. This matrix is not
270
+ * modified.
271
+ *
272
+ * @param {number} x X component of the translation value.
273
+ * @param {number} y Y component of the translation value.
274
+ * @param {number=} z Z component of the translation value.
275
+ * @return {CSSMatrix} The result matrix
276
+ */
277
+ CSSMatrix.prototype.translate = function(x, y, z) {
278
+ if (typeof z == 'undefined') z = 0;
279
+ return multiply(this, translate(x, y, z));
280
+ };
281
+
282
+
283
+ /**
284
+ * The scale method returns a new matrix which is this matrix post multiplied by
285
+ * a scale matrix containing the passed values. If the z component is undefined,
286
+ * a 1 value is used in its place. If the y component is undefined, the x
287
+ * component value is used in its place. This matrix is not modified.
288
+ *
289
+ * @param {number} x The X component of the scale value.
290
+ * @param {number=} y The Y component of the scale value.
291
+ * @param {number=} z The Z component of the scale value.
292
+ * @return {CSSMatrix} The result matrix
293
+ */
294
+ CSSMatrix.prototype.scale = function(x, y, z) {
295
+ if (typeof y == 'undefined') y = x;
296
+ if (typeof z == 'undefined') z = 1;
297
+ return multiply(this, scale(x, y, z));
298
+ };
299
+
300
+
301
+ /**
302
+ * The rotate method returns a new matrix which is this matrix post multiplied
303
+ * by each of 3 rotation matrices about the major axes, first X, then Y, then Z.
304
+ * If the y and z components are undefined, the x value is used to rotate the
305
+ * object about the z axis, as though the vector (0,0,x) were passed. All
306
+ * rotation values are in degrees. This matrix is not modified.
307
+ *
308
+ * @param {number} rx The X component of the rotation value, or the Z component if the rotY and rotZ parameters are undefined.
309
+ * @param {number=} ry The (optional) Y component of the rotation value.
310
+ * @param {number=} rz The (optional) Z component of the rotation value.
311
+ * @return {CSSMatrix} The result matrix
312
+ */
313
+ CSSMatrix.prototype.rotate = function(rx, ry, rz) {
314
+ if (typeof ry == 'undefined') ry = rx;
315
+ if (typeof rz == 'undefined') rz = rx;
316
+ return multiply(this, rotate(rx, ry, rz));
317
+ };
318
+
319
+
320
+ /**
321
+ * The rotateAxisAngle method returns a new matrix which is this matrix post
322
+ * multiplied by a rotation matrix with the given axis and angle. The right-hand
323
+ * rule is used to determine the direction of rotation. All rotation values are
324
+ * in degrees. This matrix is not modified.
325
+ *
326
+ * @param {number} x The X component of the axis vector.
327
+ * @param {number=} y The Y component of the axis vector.
328
+ * @param {number=} z The Z component of the axis vector.
329
+ * @param {number} angle The angle of rotation about the axis vector, in degrees.
330
+ * @return {CSSMatrix} The result matrix
331
+ */
332
+ CSSMatrix.prototype.rotateAxisAngle = function(x, y, z, angle) {
333
+ if (typeof y == 'undefined') y = x;
334
+ if (typeof z == 'undefined') z = x;
335
+ return multiply(this, rotateAxisAngle(x, y, z, angle));
336
+ };
337
+
338
+
339
+ /**
340
+ * Returns a string representation of the matrix.
341
+ * @return {string}
342
+ */
343
+ CSSMatrix.prototype.toString = function() {
344
+ var affine, m = this,
345
+ fix = function (val) {
346
+ return val.toFixed(6);
347
+ };
348
+
349
+ if (isAffine(m)) affine = true;
350
+
351
+ if (affine) {
352
+ return 'matrix(' + [
353
+ m.a, m.b,
354
+ m.c, m.d,
355
+ m.e, m.f
356
+ ].map(fix).join(', ') + ')';
357
+ }
358
+ // note: the elements here are transposed
359
+ return 'matrix3d(' + [
360
+ m.m11, m.m12, m.m13, m.m14,
361
+ m.m21, m.m22, m.m23, m.m24,
362
+ m.m31, m.m32, m.m33, m.m34,
363
+ m.m41, m.m42, m.m43, m.m44
364
+ ].map(fix).join(', ') + ')';
365
+ };
366
+
367
+
368
+ // Defined in WebKitCSSMatrix, but not in the w3c draft
369
+
370
+ /**
371
+ * Specifies a skew transformation along the x-axis by the given angle.
372
+ *
373
+ * @param {number} angle The angle amount in degrees to skew.
374
+ * @return {CSSMatrix} The result matrix
375
+ */
376
+ CSSMatrix.prototype.skewX = function(angle) {
377
+ return multiply(skewX(angle), this);
378
+ };
379
+
380
+ /**
381
+ * Specifies a skew transformation along the x-axis by the given angle.
382
+ *
383
+ * @param {number} angle The angle amount in degrees to skew.
384
+ * @return {CSSMatrix} The result matrix
385
+ */
386
+ CSSMatrix.prototype.skewY = function(angle) {
387
+ return multiply(skewY(angle), this);
388
+ };
389
+
390
+ if (typeof exports !== 'undefined') {
391
+ if (typeof module !== 'undefined' && module.exports) {
392
+ exports = module.exports = CSSMatrix;
393
+ }
394
+ exports.CSSMatrix = CSSMatrix;
395
+ } else {
396
+ window.CSSMatrix = CSSMatrix;
397
+ }
398
+
399
+ })();
@@ -0,0 +1,66 @@
1
+ /*!
2
+ query-string
3
+ Parse and stringify URL query strings
4
+ https://github.com/sindresorhus/query-string
5
+ by Sindre Sorhus
6
+ MIT License
7
+ */
8
+ (function () {
9
+ 'use strict';
10
+ var queryString = {};
11
+
12
+ queryString.parse = function (str) {
13
+ if (typeof str !== 'string') {
14
+ return {};
15
+ }
16
+
17
+ str = str.trim().replace(/^(\?|#)/, '');
18
+
19
+ if (!str) {
20
+ return {};
21
+ }
22
+
23
+ return str.trim().split('&').reduce(function (ret, param) {
24
+ var parts = param.replace(/\+/g, ' ').split('=');
25
+ var key = parts[0];
26
+ var val = parts[1];
27
+
28
+ key = decodeURIComponent(key);
29
+ // missing `=` should be `null`:
30
+ // http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters
31
+ val = val === undefined ? null : decodeURIComponent(val);
32
+
33
+ if (!ret.hasOwnProperty(key)) {
34
+ ret[key] = val;
35
+ } else if (Array.isArray(ret[key])) {
36
+ ret[key].push(val);
37
+ } else {
38
+ ret[key] = [ret[key], val];
39
+ }
40
+
41
+ return ret;
42
+ }, {});
43
+ };
44
+
45
+ queryString.stringify = function (obj) {
46
+ return obj ? Object.keys(obj).map(function (key) {
47
+ var val = obj[key];
48
+
49
+ if (Array.isArray(val)) {
50
+ return val.map(function (val2) {
51
+ return encodeURIComponent(key) + '=' + encodeURIComponent(val2);
52
+ }).join('&');
53
+ }
54
+
55
+ return encodeURIComponent(key) + '=' + encodeURIComponent(val);
56
+ }).join('&') : '';
57
+ };
58
+
59
+ if (typeof define === 'function' && define.amd) {
60
+ define(function() { return queryString; });
61
+ } else if (typeof module !== 'undefined' && module.exports) {
62
+ module.exports = queryString;
63
+ } else {
64
+ window.queryString = queryString;
65
+ }
66
+ })();
@@ -0,0 +1,9 @@
1
+ {
2
+ "env": {
3
+ "browser": true,
4
+ "jquery": true,
5
+ "mocha": true,
6
+ "node": true,
7
+ "es6": true
8
+ }
9
+ }
@@ -0,0 +1,33 @@
1
+ var Fixture;
2
+
3
+ Fixture = {
4
+ node: null,
5
+
6
+ prepare() {
7
+ var node;
8
+
9
+ this.clean();
10
+
11
+ node = document.createElement("div");
12
+ node.id = "Fixture";
13
+ node.style.visibility = "hidden";
14
+ document.body.appendChild(node);
15
+
16
+ this.node = node;
17
+ },
18
+
19
+ clean() {
20
+ var parent;
21
+
22
+ if(!this.node) { return; }
23
+ parent = this.node.parentNode;
24
+ if(parent) { parent.removeChild(this.node); }
25
+ },
26
+
27
+ load(content) {
28
+ this.node.innerHTML = content;
29
+ return this.node;
30
+ }
31
+ };
32
+
33
+ export default Fixture;
@@ -0,0 +1,19 @@
1
+ import sinon from "sinon";
2
+ import { expect } from "chai";
3
+ import Fixture from "./spec_fixture";
4
+
5
+ global.expect = expect;
6
+ global.sinon = sinon;
7
+ global.Fixture = Fixture;
8
+
9
+ mocha.setup("bdd");
10
+
11
+ beforeEach(() => {
12
+ Fixture.prepare();
13
+ global.sandbox = sinon.sandbox.create();
14
+ });
15
+
16
+ afterEach(() => {
17
+ Fixture.clean();
18
+ global.sandbox.restore();
19
+ });
@@ -0,0 +1,156 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Themes::API::Components::Base do
4
+ subject { described_class }
5
+ let(:view) { OpenStruct.new }
6
+
7
+ describe "#classes" do
8
+ let(:classes) { %w(foo bar baz) }
9
+ let(:other_classes) { %w(qux fuzz) }
10
+ let(:expected_class) { classes.join(" ") }
11
+ let(:expected_other_class) { other_classes.join(" ") }
12
+
13
+ it "allows specifying classes as a hash of strings, hash of arrays, string, or array" do
14
+ expect(subject.new(view, classes: classes).classes).to eq expected_class
15
+ expect(subject.new(view, classes: expected_class).classes).to eq expected_class
16
+ expect(subject.new(view, classes: { base: expected_class }).classes).to eq expected_class
17
+ expect(subject.new(view, classes: { base: classes }).classes).to eq expected_class
18
+ end
19
+
20
+ it "returns classes for the root class by default" do
21
+ expect(subject.new(view, classes: { base: classes, subcomponent: other_classes }).classes).to eq expected_class
22
+ end
23
+
24
+ it "returns classes for the specified component" do
25
+ expect(subject.new(view, classes: { base: classes, subcomponent: other_classes }).classes(:subcomponent)).to eq expected_other_class
26
+ end
27
+
28
+ it "is aliased to #classes_for" do
29
+ component = subject.new(view, classes: { base: classes, subcomponent: other_classes })
30
+ expect(component.classes).to eq component.classes_for
31
+ expect(component.classes(:subcomponent)).to eq component.classes_for(:subcomponent)
32
+ end
33
+ end
34
+
35
+ describe "#block" do
36
+ it "stores the passed block" do
37
+ block = -> { true }
38
+ component = subject.new(view, &block)
39
+ expect(component.block).to be block
40
+ end
41
+ end
42
+
43
+ describe "#method_missing" do
44
+ let(:component) { subject.new(view, name: "foo") }
45
+
46
+ it "returns the value of a configured option" do
47
+ expect(component.name).to eq "foo"
48
+ end
49
+
50
+ it "calls the regular method missing for keys that don't exist" do
51
+ expect { component.foo }.to raise_error(NoMethodError)
52
+ end
53
+ end
54
+ end
55
+
56
+ describe Docks::Themes::API::Components::Config do
57
+ let(:component_class) { Docks::Themes::API::Components::Base }
58
+ let(:view) { OpenStruct.new }
59
+
60
+ describe "#defaults" do
61
+ it "sets the attributes to the passed defaults" do
62
+ component = component_class.new(view, name: "foo")
63
+ component.configure do |config|
64
+ config.defaults name: "bar", something_else: "baz"
65
+ end
66
+
67
+ expect(component.name).to eq "foo"
68
+ expect(component.something_else).to eq "baz"
69
+ end
70
+ end
71
+
72
+ describe "#classes" do
73
+ it "merges the passed and default classes" do
74
+ component = component_class.new(view, classes: { base: "foo", subcomponent_one: "bar" })
75
+ component.configure do |config|
76
+ config.classes base: "fizz", subcomponent_one: %w(bar baz), subcomponent_two: "qux"
77
+ end
78
+
79
+ expect(component.classes_for(:base)).to eq "foo fizz"
80
+ expect(component.classes_for(:subcomponent_one)).to eq "bar baz"
81
+ expect(component.classes_for(:subcomponent_two)).to eq "qux"
82
+ end
83
+ end
84
+
85
+ describe "#conditional_classes" do
86
+ subject { component_class.new(view, foo: true, bar: false, size: :large) }
87
+ let(:klass_one) { "one" }
88
+ let(:klass_two) { "two" }
89
+ let(:klass_three) { "three" }
90
+
91
+ context "when the if option is passed" do
92
+ it "adds the class only when the attribute exists and is true" do
93
+ subject.configure do |config|
94
+ config.conditional_classes if: :foo, base: klass_one
95
+ config.conditional_classes if: :bar, base: klass_two
96
+ config.conditional_classes if: :baz, base: klass_three
97
+ end
98
+
99
+ expect(subject.classes).to eq klass_one
100
+ end
101
+ end
102
+
103
+ context "when the unless option is passed" do
104
+ it "adds the class when the attribute does not exist or is false" do
105
+ subject.configure do |config|
106
+ config.conditional_classes unless: :foo, base: klass_one
107
+ config.conditional_classes unless: :bar, base: klass_two
108
+ config.conditional_classes unless: :baz, base: klass_three
109
+ end
110
+
111
+ expect(subject.classes).to eq "#{klass_two} #{klass_three}"
112
+ end
113
+ end
114
+
115
+ context "when the with option is passed" do
116
+ it "does nothing when no block is passed" do
117
+ subject.configure do |config|
118
+ config.conditional_classes with: :size
119
+ end
120
+
121
+ expect(subject.classes).to eq ""
122
+ end
123
+
124
+ it "yields the value of the passed attribute and uses the returned classes" do
125
+ yielded = nil
126
+ subject.configure do |config|
127
+ config.conditional_classes(with: :size) do |size|
128
+ yielded = size
129
+ { base: klass_two }
130
+ end
131
+ end
132
+
133
+ expect(yielded).to eq subject.size
134
+ expect(subject.classes).to eq klass_two
135
+ end
136
+ end
137
+
138
+ context "when the from option is passed" do
139
+ it "does nothing when the passed attribute does not exist" do
140
+ subject.configure do |config|
141
+ config.conditional_classes from: :type, regular: { base: klass_one }
142
+ end
143
+
144
+ expect(subject.classes).to eq ""
145
+ end
146
+
147
+ it "uses the value of the passed attribute to determine which classes to use" do
148
+ subject.configure do |config|
149
+ config.conditional_classes from: :size, regular: { base: klass_one }, large: { base: klass_two }
150
+ end
151
+
152
+ expect(subject.classes).to eq klass_two
153
+ end
154
+ end
155
+ end
156
+ end