workarea-super_hero 2.2.1

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 (97) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +15 -0
  3. data/.eslintrc +26 -0
  4. data/.gitignore +11 -0
  5. data/.jshintrc +37 -0
  6. data/.rails-rubocop.yml +119 -0
  7. data/.rubocop.yml +12 -0
  8. data/.scss-lint.yml +188 -0
  9. data/CHANGELOG.md +334 -0
  10. data/Gemfile +5 -0
  11. data/README.md +120 -0
  12. data/Rakefile +60 -0
  13. data/app/assets/images/workarea/admin/content_block_types/super_hero.svg +1 -0
  14. data/app/assets/images/workarea/svg/position_grid.svg +38 -0
  15. data/app/assets/javascripts/workarea/admin/super_hero/modules/media_modes.js +54 -0
  16. data/app/assets/javascripts/workarea/admin/super_hero/modules/position_input.js +59 -0
  17. data/app/assets/javascripts/workarea/storefront/super_hero/modules/vimeo_api.js +85 -0
  18. data/app/assets/javascripts/workarea/storefront/super_hero/modules/youtube_api.js +122 -0
  19. data/app/assets/stylesheets/workarea/admin/super_hero/components/_position_grid.scss +27 -0
  20. data/app/assets/stylesheets/workarea/storefront/super_hero/components/_content_position.scss +46 -0
  21. data/app/assets/stylesheets/workarea/storefront/super_hero/components/_super_hero_content_block.scss +69 -0
  22. data/app/models/workarea/content/fields/media_mode.rb +8 -0
  23. data/app/models/workarea/content/fields/video_advanced.rb +8 -0
  24. data/app/services/workarea/storefront/color_tools.rb +24 -0
  25. data/app/services/workarea/storefront/video_embedder/vimeo.rb +50 -0
  26. data/app/services/workarea/storefront/video_embedder/youtube.rb +56 -0
  27. data/app/services/workarea/storefront/video_embedder.rb +59 -0
  28. data/app/view_models/workarea/storefront/content_blocks/super_hero_view_model.rb +79 -0
  29. data/app/views/workarea/admin/content_blocks/_media_mode.html.haml +3 -0
  30. data/app/views/workarea/admin/content_blocks/_video_advanced.html.haml +12 -0
  31. data/app/views/workarea/admin/content_blocks/types/_super_hero.html.haml +106 -0
  32. data/app/views/workarea/storefront/content_blocks/_super_hero.html.haml +27 -0
  33. data/bin/rails +18 -0
  34. data/config/initializers/appends.rb +42 -0
  35. data/config/initializers/content_block_types.rb +49 -0
  36. data/config/locales/en.yml +23 -0
  37. data/config/routes.rb +2 -0
  38. data/lib/workarea/super_hero/engine.rb +8 -0
  39. data/lib/workarea/super_hero/version.rb +5 -0
  40. data/lib/workarea/super_hero.rb +11 -0
  41. data/script/admin_ci +9 -0
  42. data/script/ci +11 -0
  43. data/script/core_ci +9 -0
  44. data/script/plugins_ci +9 -0
  45. data/script/storefront_ci +9 -0
  46. data/super_hero_logo.svg +15 -0
  47. data/test/dummy/Rakefile +6 -0
  48. data/test/dummy/app/assets/config/manifest.js +4 -0
  49. data/test/dummy/app/assets/images/.keep +0 -0
  50. data/test/dummy/app/assets/javascripts/application.js +13 -0
  51. data/test/dummy/app/assets/stylesheets/application.css +15 -0
  52. data/test/dummy/app/controllers/application_controller.rb +3 -0
  53. data/test/dummy/app/controllers/concerns/.keep +0 -0
  54. data/test/dummy/app/helpers/application_helper.rb +2 -0
  55. data/test/dummy/app/jobs/application_job.rb +2 -0
  56. data/test/dummy/app/mailers/application_mailer.rb +4 -0
  57. data/test/dummy/app/models/concerns/.keep +0 -0
  58. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  59. data/test/dummy/app/views/layouts/mailer.html.erb +13 -0
  60. data/test/dummy/app/views/layouts/mailer.text.erb +1 -0
  61. data/test/dummy/bin/bundle +3 -0
  62. data/test/dummy/bin/rails +4 -0
  63. data/test/dummy/bin/rake +4 -0
  64. data/test/dummy/bin/setup +34 -0
  65. data/test/dummy/bin/update +29 -0
  66. data/test/dummy/config/application.rb +23 -0
  67. data/test/dummy/config/boot.rb +5 -0
  68. data/test/dummy/config/cable.yml +9 -0
  69. data/test/dummy/config/environment.rb +5 -0
  70. data/test/dummy/config/environments/development.rb +54 -0
  71. data/test/dummy/config/environments/production.rb +86 -0
  72. data/test/dummy/config/environments/test.rb +43 -0
  73. data/test/dummy/config/initializers/application_controller_renderer.rb +6 -0
  74. data/test/dummy/config/initializers/assets.rb +11 -0
  75. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  76. data/test/dummy/config/initializers/cookies_serializer.rb +5 -0
  77. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  78. data/test/dummy/config/initializers/inflections.rb +16 -0
  79. data/test/dummy/config/initializers/mime_types.rb +4 -0
  80. data/test/dummy/config/initializers/new_framework_defaults.rb +18 -0
  81. data/test/dummy/config/initializers/session_store.rb +3 -0
  82. data/test/dummy/config/initializers/workarea.rb +5 -0
  83. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  84. data/test/dummy/config/locales/en.yml +23 -0
  85. data/test/dummy/config/puma.rb +47 -0
  86. data/test/dummy/config/routes.rb +5 -0
  87. data/test/dummy/config/secrets.yml +22 -0
  88. data/test/dummy/config/spring.rb +6 -0
  89. data/test/dummy/config.ru +5 -0
  90. data/test/dummy/lib/assets/.keep +0 -0
  91. data/test/dummy/log/.keep +0 -0
  92. data/test/services/workarea/storefront/color_tools_test.rb +32 -0
  93. data/test/services/workarea/storefront/video_embedder_test.rb +52 -0
  94. data/test/test_helper.rb +10 -0
  95. data/test/view_models/workarea/storefront/super_hero_view_model_test.rb +38 -0
  96. data/workarea-super_hero.gemspec +18 -0
  97. metadata +158 -0
data/CHANGELOG.md ADDED
@@ -0,0 +1,334 @@
1
+ Workarea Super Hero 2.2.1 (2019-08-21)
2
+ --------------------------------------------------------------------------------
3
+
4
+ * Open Source!
5
+
6
+
7
+
8
+ Workarea Super Hero 2.2.0 (2019-06-11)
9
+ --------------------------------------------------------------------------------
10
+
11
+ * Make image clickable when link is present
12
+
13
+ Uses the new link_to_if_with_block helper from Workarea v3.4 to make the background image clickable if a link URL is provided
14
+
15
+ WLSUPERHRO-21
16
+ Jake Beresford
17
+
18
+
19
+
20
+ Workarea Super Hero 2.1.1 (2018-10-02)
21
+ --------------------------------------------------------------------------------
22
+
23
+ * Add alt text to super hero when using 'switch' media mode
24
+
25
+ WLSUPERHRO-28
26
+ Jake Beresford
27
+
28
+
29
+
30
+ Workarea Super Hero 2.1.0 (2018-05-31)
31
+ --------------------------------------------------------------------------------
32
+
33
+ * Remove range field
34
+
35
+ The Range field was added to the Workarea platform in v3.3, this functionality has been removed from super hero to prevent conflicts and ensure compatibility.
36
+
37
+ WLSUPERHRO-26
38
+ Jake Beresford
39
+
40
+
41
+
42
+ Workarea Super Hero 2.0.5 (2018-05-24)
43
+ --------------------------------------------------------------------------------
44
+
45
+ * WLSUPERHRO-25: Add guard for if video APIs have already been added
46
+
47
+ Steve Perks
48
+
49
+
50
+
51
+ Workarea Super Hero v2.0.4 (2018-02-12)
52
+ --------------------------------------------------------------------------------
53
+
54
+ * Fix admin duplicate IDs in SVG icon
55
+
56
+ Jake Beresford
57
+
58
+
59
+
60
+ Workarea Super Hero v2.0.3 (2018-02-08)
61
+ --------------------------------------------------------------------------------
62
+
63
+ * Fix appends lambda
64
+
65
+ Jake Beresford
66
+
67
+
68
+
69
+ Workarea Super Hero v2.0.2 (2018-01-11)
70
+ --------------------------------------------------------------------------------
71
+
72
+ * Add missing methods to range.rb
73
+
74
+ Jake Beresford
75
+
76
+ * Add condition around range_field.js append
77
+
78
+ This module is also defined in the slider_block plugin, causing an error if both plugins are loaded in a host application. This condition helps prevent JS errors in the admin due to registering 2 modules with the same name.
79
+
80
+ WLSUPERHRO-22
81
+ Jake Beresford
82
+
83
+ * Add step attribute to range input
84
+
85
+ * Update range input for compatibility with workarea-slider_block
86
+ * Set default step value to 1, since we're dealing with % I doubt this will ever need to change
87
+
88
+ WLSUPERHRO-22
89
+ Jake Beresford
90
+
91
+
92
+
93
+ Workarea Super Hero v2.0.1 (2017-06-06)
94
+ --------------------------------------------------------------------------------
95
+
96
+ * Updates for CI
97
+
98
+ * Remove bundler gem tasks to prevent pushing to rubygems
99
+ * Rubocop passing
100
+ * add bundle-audit for CI
101
+ Beresford, Jake
102
+
103
+
104
+
105
+ Workarea Super Hero v2.0.0 (2017-05-19)
106
+ --------------------------------------------------------------------------------
107
+
108
+ * Fixes mute functionality for vimeo
109
+
110
+ * Upgrade to the latest vimeo player API, remove froogaloop.
111
+ * Fix vimeo event implementation
112
+ * refactor video embedder nokogiri traversal
113
+ * Fix some tests that were broken on another ticket
114
+ * Move logic for adding video service api data binding into the video embedder.
115
+ * Split video embedder logic by service
116
+ * Request vimeo and youtube SDK as necessary using getScript
117
+ * Implement youtube_api.js module
118
+ * Move append points to initializer
119
+ * Updated readme
120
+
121
+ WLSUPERHRO-15
122
+ Beresford, Jake
123
+
124
+ * Responsive images fall back to asset if undefined by admin user.
125
+
126
+ * updated view_model syntax to be same as base content blocks
127
+
128
+ WLSUPERHRO-17
129
+ Beresford, Jake
130
+
131
+ * Translate admin views
132
+
133
+ WLSUPERHRO-16
134
+ Dave Barnow
135
+
136
+ * Upgrade plugin for v3 compatability
137
+
138
+ Many things were changed to get this working, however
139
+ functionality is almost identical to v2. Key changes:
140
+
141
+ * Re-write blocktype using DSL
142
+ * Re-name workarea & storefront
143
+ * Asset lookup for size & ratio removed, use base asset lookup
144
+ * Removed color input styles, use base color input
145
+ * Tests converted to minitest
146
+
147
+ WLSUPERHRO-14
148
+ Beresford, Jake
149
+
150
+
151
+
152
+ Workarea Super Hero v1.0.7 (2016-12-15)
153
+ --------------------------------------------------------------------------------
154
+
155
+ * WLSUPERHRO-13: Add require version file to super_hero.rb add metadata to gemspec
156
+
157
+ Beresford, Jake
158
+
159
+
160
+
161
+ Workarea Super Hero v1.0.6 (2016-07-20)
162
+ --------------------------------------------------------------------------------
163
+
164
+ * WLSUPERHRO-10: Adds another blank line for code style
165
+
166
+ Dave Barnow
167
+
168
+ * WLSUPERHRO-10: Adds back in blank lines to conform to cssguidelin.es
169
+
170
+ Dave Barnow
171
+
172
+ * WLSUPERHRO-10: Fixes center positioning, readme markdown formatting
173
+
174
+ Dave Barnow
175
+
176
+
177
+
178
+ Workarea Super Hero v1.0.5 (2016-06-30)
179
+ --------------------------------------------------------------------------------
180
+
181
+ * WLSUPERHRO-9: Adds preset for media to prevent admin errors
182
+
183
+ Beresford, Jake
184
+
185
+ * WLSUPERHRO-9: Change logic when checking for embed codes to cover nil? and empty?
186
+
187
+ Beresford, Jake
188
+
189
+
190
+
191
+ Workarea Super Hero v1.0.4 (2016-06-29)
192
+ --------------------------------------------------------------------------------
193
+
194
+ * WLSUPERHRO-8: Fix range slider
195
+
196
+ Beresford, Jake
197
+
198
+
199
+
200
+ Workarea Super Hero v1.0.3 (2016-06-15)
201
+ --------------------------------------------------------------------------------
202
+
203
+ * WLSUPERHRO-7: Add test for youtube embed codes
204
+
205
+ Beresford, Jake
206
+
207
+ * WLSUPERHRO-7: change vimeo conditional to guard clause
208
+
209
+ Beresford, Jake
210
+
211
+ * WLSUPERHRO-7: return iframe attrs in video embedder to fix issue with youtube videos having nil attrs
212
+
213
+ Beresford, Jake
214
+
215
+
216
+
217
+ Workarea Super Hero v1.0.1 (2016-05-31)
218
+ --------------------------------------------------------------------------------
219
+
220
+ * WLSUPERHRO-6: Explicitly require froogaloop
221
+
222
+ bberg
223
+
224
+
225
+
226
+ Workarea Super Hero v1.0.0 (2016-05-26)
227
+ --------------------------------------------------------------------------------
228
+
229
+ * WLSUPERHRO-4: Remove logic for ga tracker detection
230
+
231
+ Beresford, Jake
232
+
233
+ * WLSUPERHRO-4: Fix pause event data and player_id
234
+
235
+ Beresford, Jake
236
+
237
+ * WLSUPERHRO-4: Add jsdoc comment
238
+
239
+ Beresford, Jake
240
+
241
+ * WLSUPERHRO-4: change implementation to use WEBLINC.analytics
242
+
243
+ Beresford, Jake
244
+
245
+ * WLSUPERHRO-4: Add vimeo event tracking for video interactions
246
+
247
+ Beresford, Jake
248
+
249
+ * WLSUPERHRO-4: move color and video embed classes out of view models and in to services, fix up tests accordingly
250
+
251
+ Beresford, Jake
252
+
253
+ * WLSUPERHRO-4: Fixes froogaloop integration, makes things work properly.
254
+
255
+ Beresford, Jake
256
+
257
+ * WLSUPERHRO-4: Adds vimeo api integration using froogaloop JS
258
+
259
+ Beresford, Jake
260
+
261
+ * WLSUPERHRO-2: Removes debugging statements and cleanup ruby style
262
+
263
+ Beresford, Jake
264
+
265
+ * WLSUPERHERO-2: Adds tests and refactor for video_embed_view_model
266
+
267
+ Beresford, Jake
268
+
269
+ * Complete color view model unit tests, refactor view model to remove args
270
+
271
+ Beresford, Jake
272
+
273
+ * WLSUPERHRO-2: Update spec tests, add tests for color view model
274
+
275
+ Beresford, Jake
276
+
277
+ * WLSUPERHRO-2: Break out color and video embed methods into classes, start writing unit tests
278
+
279
+ Beresford, Jake
280
+
281
+ * Update aspect ratio calculation, remove dummy hero image
282
+
283
+ Beresford, Jake
284
+
285
+ * Cleanup haml file dynamic classes and symbol syntax
286
+
287
+ Beresford, Jake
288
+
289
+ * Improve some JS logic, cleanup some sass spacing, get everything looking groovy
290
+
291
+ Beresford, Jake
292
+
293
+ * Decorate Content::Asset with dragonfly magic attributes, cleanup viewmodel and remove call to S3 for each view of the blocktype
294
+
295
+ Beresford, Jake
296
+
297
+ * Cleanup rake task and JS
298
+
299
+ Beresford, Jake
300
+
301
+ * Clean up the turtle's cape
302
+
303
+ Beresford, Jake
304
+
305
+ * Add necessary files for content block plugin
306
+
307
+ Clean up the filez
308
+ updates to view model and add range for bg alpha channel
309
+ add basic styles, fixup the view model, add some sweet color pickers, add markup for responsive images and media modes
310
+ Adds color picker styles, additional config options, position input SVG, SVg helper, media modes and toggle groups.
311
+ Some fixes and placeholders and other things I needed to fix before the demo. Position input is a POS and doesnt work yet.
312
+ Adds image attribute detection using dragonfly analysers
313
+ Get the content position input working, rename some things, shuffle things about
314
+ Simplify filename regex, remove extraneous styles
315
+ Clean up content position styles
316
+ Simplify content class in view model
317
+ Pulls responsive images out of maintain aspect ratio, clen up the view model some more, rename some local_assigns
318
+ Bring content area controls into admin view
319
+ Modify media-mode groups to use array.includes to give more flexibility in the UI
320
+ Get video embeds working for youtube and vimeo. Code needs TLC but it works for now.
321
+ Fixes logic around video vs. image
322
+ Clean up content position scss component
323
+ Fixes nesting of position input
324
+ Refactor content position logic and styles for less CSS
325
+ Js changes to position input
326
+ Remove use of this in js
327
+ Clean up media_modes js
328
+ Add lintier config dotfiles
329
+ Remove generic content-block classes
330
+
331
+ Beresford, Jake
332
+
333
+
334
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'workarea', source: 'https://gems.weblinc.com'
data/README.md ADDED
@@ -0,0 +1,120 @@
1
+ Workarea Super Hero
2
+ ================================================================================
3
+
4
+ >Give your content super powers!
5
+
6
+ Super Hero plugin for the Workarea platform.
7
+
8
+ Configuring Super Hero for your app
9
+ --------------------------------------------------------------------------------
10
+
11
+ Superhero implements a content block type which no longer requires any initial
12
+ configuration. You may wish to override the config for the block type in order
13
+ to change the preset colors for background and text color pickers.
14
+
15
+ What Super Hero Does
16
+ --------------------------------------------------------------------------------
17
+ Super hero provides a fleshed out set of content tools that allows admin users to deliver beautiful content easily.
18
+
19
+ ## Media Modes
20
+
21
+ Media Modes offers a set of options that dictate how media will be rendered
22
+
23
+ ### Resize mode
24
+
25
+ Stretches/squishes media to fit the viewport or container.
26
+
27
+ automatically deteects and retains the aspect ratio of the chosen media
28
+
29
+ ### Crop Mode
30
+
31
+ Allows the admin to select a 'crop to' location (left, center, right)
32
+
33
+ The image will maintain it's original height and crop to the designated location as the browser is resized
34
+
35
+ ### Switch Mode
36
+
37
+ Allows the user to select up to 3 images which are rendered as a <picture> element
38
+
39
+ ### Video Mode
40
+
41
+ Provides the Admin user with a text area input to paste in a full embed code from Vimeo or Youtube
42
+
43
+ The full iframe embed code must be provided, this will be parsed in the view model and constructed into a responsive iframe on the store front.
44
+
45
+ ## Color Pickers
46
+
47
+ Super hero provides a full color picker for both text and background colors. Brand colors can be configured on a per-installation basis inside the super_hero_tasks.rake file.
48
+
49
+ The background color picker also provides a range slider and text input to control opacity. This accepts values between 0 - 100 and is converted to an alpha channel in the view model.
50
+
51
+ >Currently browser support for input type='color' is patchy, a polyfill is in the works to allow users on unsupported browsers to use this functionality.
52
+
53
+ ## Content Positioning
54
+
55
+ The admin user is able to select from 9 content positions using a sweet SVG UI element. By default a position offset of 5% is defined, you can override the $positioning-offset scss variable in your host application to customize the space between content and the edge of the block.
56
+
57
+
58
+ Video Embedder
59
+ --------------------------------------------------------------------------------
60
+
61
+ Super hero includes a VideoEmbedder service which parses youtube and vimeo iframes
62
+ and generates iframe parameters.
63
+ The embedder accepts the iframe embed code and a set of options.
64
+ Options are part of the advanced_video Content::Field and include: loop, autoplay,
65
+ and mute functionality.
66
+
67
+ The plugin also includes js player API integrations for youtube and vimeo.
68
+ This enables the mute functionality and fires events to Workarea analytics.js.
69
+ In order to use those analytics events in your host application you will need
70
+ to write analytics adapter callbacks for the service you wish to send the data to.
71
+
72
+ Example callbacks:
73
+ ```
74
+ 'vimeo': function (payload) {
75
+ send('send', payload.eventCategory, payload.eventAction, payload.eventLabel, payload.eventValue);
76
+ },
77
+
78
+ 'youtube': function (payload) {
79
+ send('send', payload.eventCategory, payload.eventAction, payload.eventLabel, payload.eventValue);
80
+ },
81
+ ```
82
+
83
+ Getting Started
84
+ --------------------------------------------------------------------------------
85
+
86
+ This gem contains a rails engine that must be mounted onto a host Rails application.
87
+
88
+ You must have access to a WebLinc gems server to use this gem. Add your gems server credentials to Bundler:
89
+
90
+ bundle config gems.weblinc.com my_username:my_password
91
+
92
+ Or set the appropriate environment variable in a shell startup file:
93
+
94
+ export BUNDLE_GEMS__WEBLINC__COM='my_username:my_password'
95
+
96
+ Then add the gem to your application's Gemfile specifying the source:
97
+
98
+ # ...
99
+ gem 'workarea-super_hero', source: 'https://gems.weblinc.com'
100
+ # ...
101
+
102
+ Or use a source block:
103
+
104
+ # ...
105
+ source 'https://gems.weblinc.com' do
106
+ gem 'workarea-super_hero'
107
+ end
108
+ # ...
109
+
110
+ Update your application's bundle.
111
+
112
+ cd path/to/application
113
+ bundle
114
+
115
+ Copyright & Licensing
116
+ --------------------------------------------------------------------------------
117
+
118
+ Copyright WebLinc 2015. All rights reserved.
119
+
120
+ For licensing, contact sales@workarea.com.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+ RDoc::Task.new(:rdoc) do |rdoc|
9
+ rdoc.rdoc_dir = 'rdoc'
10
+ rdoc.title = 'SuperHero'
11
+ rdoc.options << '--line-numbers'
12
+ rdoc.rdoc_files.include('README.md')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ end
15
+
16
+ APP_RAKEFILE = File.expand_path('../test/dummy/Rakefile', __FILE__)
17
+ load 'rails/tasks/engine.rake'
18
+ load 'rails/tasks/statistics.rake'
19
+ load 'workarea/changelog.rake'
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |t|
23
+ t.libs << 'lib'
24
+ t.libs << 'test'
25
+ t.pattern = 'test/**/*_test.rb'
26
+ t.verbose = false
27
+ end
28
+ task default: :test
29
+
30
+ $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
31
+ require 'workarea/super_hero/version'
32
+
33
+ desc "Release version #{Workarea::SuperHero::VERSION} of the gem"
34
+ task :release do
35
+ host = "https://#{ENV['BUNDLE_GEMS__WEBLINC__COM']}@gems.weblinc.com"
36
+
37
+ #Rake::Task['workarea:changelog'].execute
38
+ #system 'git add CHANGELOG.md'
39
+ #system 'git commit -m "Update CHANGELOG"'
40
+ #system 'git push origin HEAD'
41
+
42
+ system "git tag -a v#{Workarea::SuperHero::VERSION} -m 'Tagging #{Workarea::SuperHero::VERSION}'"
43
+ system 'git push --tags'
44
+
45
+ system 'gem build workarea-super_hero.gemspec'
46
+ system "gem push workarea-super_hero-#{Workarea::SuperHero::VERSION}.gem"
47
+ system "gem push workarea-super_hero-#{Workarea::SuperHero::VERSION}.gem --host #{host}"
48
+ system "rm workarea-super_hero-#{Workarea::SuperHero::VERSION}.gem"
49
+ end
50
+
51
+ desc 'Run the JavaScript tests'
52
+ ENV['TEASPOON_RAILS_ENV'] = File.expand_path('../test/dummy/config/environment', __FILE__)
53
+ task teaspoon: 'app:teaspoon'
54
+
55
+ desc 'Start a server at http://localhost:3000/teaspoon for JavaScript tests'
56
+ task :teaspoon_server do
57
+ Dir.chdir('test/dummy')
58
+ teaspoon_env = File.expand_path('../test/teaspoon_env.rb', __FILE__)
59
+ system "RAILS_ENV=test TEASPOON_ENV=#{teaspoon_env} rails s"
60
+ end
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 40.93"><defs><style>.super-hero-icon__path{fill:#fff;}</style></defs><title>Super hero</title><path d="M58.75,35.93a5,5,0,0,1-5,5H10.25a5,5,0,0,1-5-5V5a5,5,0,0,1,5-5h43.5a5,5,0,0,1,5,5Z"/><path class="super-hero-icon__path" d="M46.76,4.3H17.24l-5.16,9.38L32,36.63,51.92,13.68ZM32,33.23,19.46,18.51l-3.28-3.78h.06L15,13.3l1.67-3L18.6,6.83v0l.08-.15h26.8L49,13.33l-1.19,1.4h.05l-3,3.41Z"/><path class="super-hero-icon__path" d="M32.54,11.09a.76.76,0,0,1,.22.55,1,1,0,0,1-.09.35l-2.93,7a1.05,1.05,0,0,1-.37.45,1,1,0,0,1-.56.18h-.15a1,1,0,0,1-.56-.18,1,1,0,0,1-.37-.45l-2.95-7a.94.94,0,0,1-.09-.35.76.76,0,0,1,.22-.54.72.72,0,0,1,.54-.23.74.74,0,0,1,.41.13.74.74,0,0,1,.28.31l2.58,6.52,2.58-6.54a.73.73,0,0,1,.28-.31.74.74,0,0,1,.41-.13A.72.72,0,0,1,32.54,11.09Z"/><path class="super-hero-icon__path" d="M39.08,11.09a.72.72,0,0,0-.54-.24.74.74,0,0,0-.41.13.73.73,0,0,0-.28.31l-2.57,6.54L33.6,13.59l-.81,1.92L34.25,19a1,1,0,0,0,.37.45,1,1,0,0,0,.56.18h.17a1,1,0,0,0,.56-.18,1.05,1.05,0,0,0,.37-.45l2.93-7a1,1,0,0,0,.09-.35A.76.76,0,0,0,39.08,11.09Z"/></svg>
@@ -0,0 +1,38 @@
1
+ <svg id="position_grid" class="position-grid" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 150 150">
2
+ <g id="top-left">
3
+ <path class="position-grid__cell" d="M1 1h49.9v50.2H1z"/>
4
+ <path class="position-grid__cell-path" d="M49.4 2.5v47.2H2.5V2.5h46.9m3-3H-.5v53.2h52.9V-.5z"/>
5
+ </g>
6
+ <g id="top-center">
7
+ <path class="position-grid__cell" d="M50.1 1H100v50.2H50.1z"/>
8
+ <path class="position-grid__cell-path" d="M98.4 2.5v47.2H51.6V2.5h46.8m3-3H48.6v53.2h52.9V-.5h-.1z"/>
9
+ </g>
10
+ <g id="top-right">
11
+ <path class="position-grid__cell" d="M99.1 1H149v50.2H99.1z"/>
12
+ <path class="position-grid__cell-path" d="M147.5 2.5v47.2h-46.9V2.5h46.9m3-3H97.6v53.2h52.9V-.5z"/>
13
+ </g>
14
+ <g id="middle-left">
15
+ <path class="position-grid__cell" d="M1 49.9h49.9v50.2H1z"/>
16
+ <path class="position-grid__cell-path" d="M49.4 51.4v47.2H2.5V51.4h46.9m3-3H-.5v53.2h52.9V48.4z"/>
17
+ </g>
18
+ <g id="middle-center">
19
+ <path class="position-grid__cell" d="M50.1 49.9H100v50.2H50.1z"/>
20
+ <path class="position-grid__cell-path" d="M98.4 51.4v47.2H51.6V51.4h46.8m3-3H48.6v53.2h52.9V48.4h-.1z"/>
21
+ </g>
22
+ <g id="middle-right">
23
+ <path class="position-grid__cell" d="M99.1 49.9H149v50.2H99.1z"/>
24
+ <path class="position-grid__cell-path" d="M147.5 51.4v47.2h-46.9V51.4h46.9m3-3H97.6v53.2h52.9V48.4z"/>
25
+ </g>
26
+ <g id="bottom-left">
27
+ <path class="position-grid__cell" d="M1 98.8h49.9V149H1z"/>
28
+ <path class="position-grid__cell-path" d="M49.4 100.3v47.2H2.5v-47.2h46.9m3-3H-.5v53.2h52.9V97.3z"/>
29
+ </g>
30
+ <g id="bottom-center">
31
+ <path class="position-grid__cell" d="M50.1 98.8H100V149H50.1z"/>
32
+ <path class="position-grid__cell-path" d="M98.4 100.3v47.2H51.6v-47.2h46.8m3-3H48.6v53.2h52.9V97.3h-.1z"/>
33
+ </g>
34
+ <g id="bottom-right">
35
+ <path class="position-grid__cell" d="M99.1 98.8H149V149H99.1z"/>
36
+ <path class="position-grid__cell-path" d="M147.5 100.3v47.2h-46.9v-47.2h46.9m3-3H97.6v53.2h52.9V97.3z"/>
37
+ </g>
38
+ </svg>
@@ -0,0 +1,54 @@
1
+ /**
2
+ * @namespace WORKAREA.mediaModes
3
+ */
4
+ WORKAREA.registerModule('mediaModes', (function () {
5
+ 'use strict';
6
+
7
+ var activateOptionGroup = function($group) {
8
+ $group.removeClass('hidden');
9
+ },
10
+
11
+ deactivateOptionGroup = function ($group) {
12
+ $group.addClass('hidden');
13
+ },
14
+
15
+ triggerMediaModeChange = function ($optionGroups, mode) {
16
+ $optionGroups.each(function(index, option) {
17
+ var $option = $(option);
18
+
19
+ if ($option.data('mediaMode').includes(mode)) {
20
+ activateOptionGroup($option);
21
+ } else {
22
+ deactivateOptionGroup($option);
23
+ }
24
+ });
25
+ },
26
+
27
+ setInitialState = function($optionGroups, $control) {
28
+ var selectedOption = $control.val();
29
+ triggerMediaModeChange($optionGroups, selectedOption);
30
+ },
31
+
32
+ /**
33
+ * @method
34
+ * @name init
35
+ * @memberof WORKAREA.mediaModes
36
+ */
37
+ init = function ($scope) {
38
+ var $control = $('[data-media-mode="control"]', $scope),
39
+ $optionGroups = $('[data-media-mode]', $scope).not($control);
40
+
41
+ if (_.isEmpty($control) ||
42
+ _.isEmpty($optionGroups)) { return; }
43
+
44
+ setInitialState($optionGroups, $control);
45
+
46
+ $control.on('change', function(event) {
47
+ triggerMediaModeChange($optionGroups, $(event.currentTarget).val());
48
+ });
49
+ };
50
+
51
+ return {
52
+ init: init
53
+ };
54
+ }()));
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @namespace WORKAREA.positionInput
3
+ */
4
+ WORKAREA.registerModule('positionInput', (function () {
5
+ 'use strict';
6
+
7
+ var setSelected = function ($svgInput, $selectInput, position) {
8
+ $svgInput
9
+ .find('#'+position+' .position-grid__cell')
10
+ .attr('style', 'fill:#000000');
11
+
12
+ $selectInput.val(position).trigger('change');
13
+ },
14
+
15
+ updateSelected = function($svgInput, $selectInput, newPosition) {
16
+ clearSelected($svgInput);
17
+ setSelected($svgInput, $selectInput, newPosition);
18
+ },
19
+
20
+ clearSelected = function($svgInput) {
21
+ $('g .position-grid__cell', $svgInput).each(function(index, cell) {
22
+ $(cell).attr('style', 'fill: #ffffff');
23
+ }
24
+ );
25
+ },
26
+
27
+ bindSVGEvents = function ($svgInput, $selectInput) {
28
+ $('g', $svgInput).each(function(index, cell) {
29
+ $(cell).on('click', function(event) {
30
+ event.preventDefault();
31
+ var newPosition = $(event.currentTarget).attr('id');
32
+ updateSelected($svgInput, $selectInput, newPosition);
33
+ });
34
+ });
35
+ },
36
+
37
+ setupField = function (index, el) {
38
+ var $positionInput = $(el),
39
+ $selectInput = $positionInput.find('select'),
40
+ $svgInput = $positionInput.find('.position-grid'),
41
+ position = $selectInput.val();
42
+
43
+ setSelected($svgInput, $selectInput, position);
44
+ bindSVGEvents($svgInput, $selectInput);
45
+ },
46
+
47
+ /**
48
+ * @method
49
+ * @name init
50
+ * @memberof WORKAREA.positionInput
51
+ */
52
+ init = function ($scope) {
53
+ $('[data-position-input]', $scope).each(setupField);
54
+ };
55
+
56
+ return {
57
+ init: init
58
+ };
59
+ }()));