sublime_video_layout 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +21 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/fonts/SublimeIcons.eot +0 -0
  6. data/app/assets/fonts/SublimeIcons.svg +34 -0
  7. data/app/assets/fonts/SublimeIcons.ttf +0 -0
  8. data/app/assets/fonts/SublimeIcons.woff +0 -0
  9. data/app/assets/images/back_texture_my.png +0 -0
  10. data/app/assets/images/close_popup.png +0 -0
  11. data/app/assets/images/custom_checkbox.png +0 -0
  12. data/app/assets/images/custom_radio.png +0 -0
  13. data/app/assets/images/custom_select.png +0 -0
  14. data/app/assets/images/dm_banner.png +0 -0
  15. data/app/assets/images/dm_banner_bg.png +0 -0
  16. data/app/assets/images/fields/card_icon.png +0 -0
  17. data/app/assets/images/fields/domain_icon.png +0 -0
  18. data/app/assets/images/fields/email_icon.png +0 -0
  19. data/app/assets/images/fields/password_icon.png +0 -0
  20. data/app/assets/images/fields/path_icon.png +0 -0
  21. data/app/assets/images/fields/ticket_icon.png +0 -0
  22. data/app/assets/images/fields/user_icon.png +0 -0
  23. data/app/assets/images/fields/valid_icon.png +0 -0
  24. data/app/assets/images/footer_break.png +0 -0
  25. data/app/assets/images/footer_texture.png +0 -0
  26. data/app/assets/images/header_back_light.png +0 -0
  27. data/app/assets/images/header_inner_shadow.png +0 -0
  28. data/app/assets/images/header_repeat.jpg +0 -0
  29. data/app/assets/images/header_repeat.png +0 -0
  30. data/app/assets/images/header_repeat_max.jpg +0 -0
  31. data/app/assets/images/header_repeat_old.png +0 -0
  32. data/app/assets/images/header_signup_btn.png +0 -0
  33. data/app/assets/images/header_stars.png +0 -0
  34. data/app/assets/images/info_icon.png +0 -0
  35. data/app/assets/images/jilion.png +0 -0
  36. data/app/assets/images/jobs_highlight_note.png +0 -0
  37. data/app/assets/images/logout.png +0 -0
  38. data/app/assets/images/menu_bullet.png +0 -0
  39. data/app/assets/images/menu_bullet_active.png +0 -0
  40. data/app/assets/images/newsletter_btn_arrow.png +0 -0
  41. data/app/assets/images/plans/plays_icon.png +0 -0
  42. data/app/assets/images/plans/ssl_icon.png +0 -0
  43. data/app/assets/images/plans/stats_icon.png +0 -0
  44. data/app/assets/images/plans/support_icon.png +0 -0
  45. data/app/assets/images/popup_break.png +0 -0
  46. data/app/assets/images/popup_sign_up_btn.png +0 -0
  47. data/app/assets/images/sublimevideo_logo.png +0 -0
  48. data/app/assets/images/sublimevideo_logo@2x.png +0 -0
  49. data/app/assets/images/sublimevideo_maintenance.png +0 -0
  50. data/app/assets/images/twitter.png +0 -0
  51. data/app/assets/images/user_header_icon.png +0 -0
  52. data/app/assets/images/user_header_icon_active.png +0 -0
  53. data/app/assets/javascripts/form/password_checker.js.coffee +18 -0
  54. data/app/assets/javascripts/form/pseudo_placeholder.js.coffee +91 -0
  55. data/app/assets/javascripts/form/show_password.js.coffee +91 -0
  56. data/app/assets/javascripts/form/submit_manager.js.coffee +53 -0
  57. data/app/assets/javascripts/media/preloader.js.coffee +30 -0
  58. data/app/assets/javascripts/misc/browser_bugs_fixer.js.coffee +12 -0
  59. data/app/assets/javascripts/misc/cookie.js.coffee +42 -0
  60. data/app/assets/javascripts/misc/utils.js.coffee +17 -0
  61. data/app/assets/javascripts/sublimevideo.js.coffee +66 -0
  62. data/app/assets/javascripts/ui/link.js.coffee +24 -0
  63. data/app/assets/javascripts/ui/menu.js.coffee +36 -0
  64. data/app/assets/javascripts/ui/popup.js.coffee +121 -0
  65. data/app/assets/javascripts/ui/table.js.coffee +8 -0
  66. data/app/assets/javascripts/ui/utils.js.coffee +41 -0
  67. data/app/assets/stylesheets/_css3.scss +41 -0
  68. data/app/assets/stylesheets/ie.css.scss +2 -0
  69. data/app/assets/stylesheets/sublime_icons.css.scss.erb +46 -0
  70. data/app/assets/stylesheets/sublimevideo.css.scss.erb +947 -0
  71. data/app/controllers/maintenance_controller.rb +12 -0
  72. data/app/helpers/sublime_video_layout/engine_helper.rb +111 -0
  73. data/app/views/layouts/_facebook.html.haml +1 -0
  74. data/app/views/layouts/_footer.html.haml +54 -0
  75. data/app/views/layouts/_googleplus.html.haml +7 -0
  76. data/app/views/layouts/_gosquared.html.haml +11 -0
  77. data/app/views/layouts/_header_menu.html.haml +44 -0
  78. data/app/views/layouts/_ie.html.haml +14 -0
  79. data/app/views/layouts/_twitter.html.haml +2 -0
  80. data/app/views/layouts/maintenance.html.erb +79 -0
  81. data/app/views/layouts/sublimevideo.html.haml +61 -0
  82. data/app/views/users/new.html.haml +24 -0
  83. data/app/views/users/sessions/new.html.haml +25 -0
  84. data/config/locales/en.yml +14 -0
  85. data/config/routes.rb +5 -0
  86. data/lib/heroku-pages/error.html +82 -0
  87. data/lib/heroku-pages/maintenance.html +77 -0
  88. data/lib/heroku-pages/sublimevideo_maintenance.png +0 -0
  89. data/lib/rack/maintenance.rb +32 -0
  90. data/lib/site_token.rb +22 -0
  91. data/lib/sublime_video_layout.rb +18 -0
  92. data/lib/sublime_video_layout/version.rb +3 -0
  93. data/lib/tasks/sublime_video_layout_tasks.rake +4 -0
  94. data/public/404.html +28 -0
  95. data/public/404.png +0 -0
  96. data/public/422.html +29 -0
  97. data/public/500.html +28 -0
  98. data/public/500.png +0 -0
  99. data/public/apple-touch-icon-precomposed.png +0 -0
  100. data/public/error.png +0 -0
  101. data/public/errors.css +60 -0
  102. data/public/favicon.ico +0 -0
  103. data/public/robots.txt +5 -0
  104. data/public/sublimevideo.png +0 -0
  105. data/vendor/assets/javascripts/modernizr.js +1265 -0
  106. metadata +203 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ac83f35320ad7b0b33475563e8c1961661c2d223
4
+ data.tar.gz: d7913d23129423bee488bb271b50f239a347f7e7
5
+ SHA512:
6
+ metadata.gz: 025dbd6766741d5a9b8ca495d2c23993526fa857b0fa12582d82bcb5f5e1407e3e71a90fca9fb9bcb1f6844562a26270832001db1d6c651b00dfdcee6ec3025b
7
+ data.tar.gz: d2503ed03bc1758ad2b9ed013c96635732f2133909fa7d62a4f0de4262710a963ffba8d97b4f59c400510d476537b5c57315758775dbf8b92006471bed4393e6
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,21 @@
1
+ # SublimeVideoLayout
2
+
3
+ This engine provides a common layout (HTML, CSS) and utility JavaScript classes for all SublimeVideo apps.
4
+
5
+ ### Deployement to http://gemfury.com/
6
+
7
+ Update `VERSION` in `lib/sublime_video_layout/version.rb` to `X.Y.Z` and then run the following commands:
8
+
9
+ ``` bash
10
+ > bundle install
11
+ > rake build
12
+ sublime_video_layout X.Y.Z built to pkg/sublime_video_layout-X.Y.Z.gem
13
+ > bundle exec fury push pkg/sublime_video_layout-X.Y.Z.gem
14
+ ```
15
+
16
+ ### JS documentation
17
+
18
+ To generate the JS docs, run `gem install codo && codo ./app/assets/javascripts`
19
+
20
+ ------------
21
+ Copyright (c) 2010 - 2012 Jilion(r) - SublimeVideo and Jilion are registered trademarks
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'SublimeVideoLayout'
18
+ rdoc.options << '--line-numbers'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ Bundler::GemHelper.install_tasks
24
+
25
+ require 'rspec/core/rake_task'
26
+
27
+ RSpec::Core::RakeTask.new(:spec)
28
+
29
+ task :default => :spec
Binary file
@@ -0,0 +1,34 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>
5
+ This is a custom SVG font generated by IcoMoon.
6
+ <iconset grid="16"></iconset>
7
+ </metadata>
8
+ <defs>
9
+ <font id="SublimeIcons" horiz-adv-x="512" >
10
+ <font-face units-per-em="512" ascent="480" descent="-32" />
11
+ <missing-glyph horiz-adv-x="512" />
12
+ <glyph unicode="&#x5b;" d="M 260.352-40.667C 116.59-40.667,0.00,75.886,0.00,219.648C0.00,363.447, 116.59,480.00, 260.352,480.00
13
+ s 260.352-116.553, 260.352-260.352C 520.704,75.886, 404.151-40.667, 260.352-40.667z M 185.088,326.51l0.00-219.758 L 364.251,216.649L 185.088,326.51z" />
14
+ <glyph unicode="&#x21;" d="M 384.00-32.00 L 0.00,480.00 L 768.00,480.00 L 384.00-32.00 Z" horiz-adv-x="768" />
15
+ <glyph unicode="&#x22;" d="M 256.00,480.00C 114.618,480.00,0.00,365.382,0.00,224.00s 114.618-256.00, 256.00-256.00s 256.00,114.618, 256.00,256.00S 397.382,480.00, 256.00,480.00z
16
+ M 114.292,332.451L 397.731,332.451 c 1.885,0.00, 3.677-0.349, 5.399-0.861l-105.449-90.275l-14.033-11.404L 256.00,207.407l-27.601,22.458l-14.01,11.38L 108.87,331.59
17
+ C 110.615,332.125, 112.407,332.451, 114.292,332.451z M 95.023,134.40L 95.023,313.181 c0.00,2.048, 0.419,4.003, 1.001,5.841l 105.10-89.949L 96.116,128.256
18
+ C 95.465,130.211, 95.023,132.259, 95.023,134.40z M 397.731,115.13L 114.292,115.13 c-1.792,0.00-3.514,0.326-5.19,0.791l 106.007,101.725L 256.00,184.39l 40.96,33.327
19
+ l 105.984-101.772C 401.245,115.456, 399.546,115.13, 397.731,115.13z M 417.001,134.40c0.00-2.164-0.442-4.212-1.094-6.167l-104.96,100.864l 105.053,89.903
20
+ c 0.582-1.839, 1.001-3.793, 1.001-5.841L 417.001,134.40 z" />
21
+ <glyph unicode="&#x23;" d="M 432.00,432.00L 192.00,192.00L 80.00,304.00L0.00,224.00L 192.00,32.00L 512.00,352.00 z" />
22
+ <glyph unicode="&#x24;" d="M 507.331,68.67c-0.002,0.002-0.004,0.004-0.006,0.005L 352.003,224.00l 155.322,155.325c 0.002,0.002, 0.004,0.003, 0.006,0.005
23
+ c 1.672,1.673, 2.881,3.627, 3.656,5.708c 2.123,5.688, 0.912,12.341-3.662,16.915L 433.952,475.326c-4.574,4.573-11.225,5.783-16.914,3.66
24
+ c-2.08-0.775-4.035-1.984-5.709-3.655c0.00-0.002-0.002-0.003-0.004-0.005L 256.001,320.00L 100.677,475.325
25
+ c-0.002,0.002-0.003,0.003-0.005,0.005c-1.673,1.671-3.627,2.88-5.707,3.655c-5.69,2.124-12.341,0.913-16.915-3.66L 4.676,401.951
26
+ c-4.574-4.574-5.784-11.226-3.661-16.914c 0.776-2.08, 1.985-4.036, 3.656-5.708c 0.002-0.001, 0.003-0.003, 0.005-0.005L 160.001,224.00
27
+ L 4.676,68.674c-0.001-0.002-0.003-0.003-0.004-0.005c-1.671-1.673-2.88-3.627-3.657-5.707c-2.124-5.688-0.913-12.341, 3.661-16.915
28
+ l 73.374-73.373c 4.575-4.574, 11.226-5.784, 16.915-3.661c 2.08,0.776, 4.035,1.985, 5.708,3.656c 0.001,0.002, 0.003,0.003, 0.005,0.005
29
+ l 155.324,155.325l 155.324-155.325c 0.002-0.001, 0.004-0.003, 0.006-0.004c 1.674-1.672, 3.627-2.881, 5.707-3.657
30
+ c 5.689-2.123, 12.342-0.913, 16.914,3.661l 73.373,73.374c 4.574,4.574, 5.785,11.227, 3.662,16.915
31
+ C 510.212,65.043, 509.003,66.997, 507.331,68.67z" />
32
+ <glyph unicode="&#x20;" horiz-adv-x="256" />
33
+ <glyph class="hidden" unicode="&#xf000;" d="M0,480L 512 -32L0 -32 z" horiz-adv-x="0" />
34
+ </font></defs></svg>
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ # This class provides a "current password checker" popup.
2
+ #
3
+ class SublimeVideo.Form.PasswordChecker
4
+ # Creates a new "current password checker" popup using {SublimeVideo.UI.Utils.openPopup}.
5
+ #
6
+ constructor: (@originForm) ->
7
+ passwordState = if @originForm.data('password-state') then " #{@originForm.data('password-state')}" else ''
8
+ passwordCheckerForm = $('<form>', id: 'password_checker_form', action: '/password/validate', method: 'post', 'data-remote': 'true')
9
+ passwordCheckerForm.html("<p class='desc'>Your#{passwordState} password is needed to perform this action:</p>" +
10
+ "<div class='entry password'>" +
11
+ "<label for='password_check' class='icon'>#{passwordState} Password</label>" +
12
+ "<input type='password' id='password_check' name='password' placeholder='Your#{passwordState} password' class='text' />" +
13
+ "<div class='actions'><input type='submit' class='blue_button' value='Done' /></div>" +
14
+ "<div class='spacer'></div>" +
15
+ "</div>")
16
+
17
+ SublimeVideo.UI.Utils.openPopup(id: 'password_checker', class: 'popup', form: @originForm, content: passwordCheckerForm)
18
+ $('#password_check').focus()
@@ -0,0 +1,91 @@
1
+ # Manages pseudo-placeholders essentially for:
2
+ #
3
+ # - IE < 10
4
+ # - Firefox < 4
5
+ # - Safari < 4
6
+ # - iOS/Safari < 4
7
+ # - Opera Mini
8
+ # - Android
9
+ #
10
+ # More info on compatibility here: http://caniuse.com/#search=placeholder
11
+ #
12
+ # What it does is setting the value of the field from its placeholder attribute
13
+ # and adding a class to reproduce the placeholder style.
14
+ #
15
+ class SublimeVideo.Form.PseudoPlaceholder
16
+
17
+ # Construct a pseudo placeholder.
18
+ #
19
+ # @todo Clarify how this shit works
20
+ # @param [jQuery Element] field an input or a textarea DOM element
21
+ #
22
+ constructor: (@field) ->
23
+ this.fieldDidChange(@field)
24
+
25
+ # This is a public API method that updates `@field`, resets its value if needed
26
+ # before setuping the pseudo placeholder.
27
+ #
28
+ # @param [jQuery Element] field the new input field to which is applied the pseudo placeholder
29
+ #
30
+ fieldDidChange: (field) ->
31
+ @field = field
32
+ # Firefox set the value with the placeholder when reloading the page, so clear this shit!
33
+ if @field.val() is @field.attr('placeholder')
34
+ @field.val('')
35
+ this.setupPseudoPlaceholder()
36
+
37
+ #
38
+ # @private
39
+ #
40
+ # @param [String] value the new value for the 'value' attribute
41
+ #
42
+ setValueAndToggleClass: (value) ->
43
+ @field.val(value)
44
+ if value is ''
45
+ @field.removeClass('placeholder')
46
+ else
47
+ @field.addClass('placeholder')
48
+
49
+ # Copy 'placeholder' attribute to 'value' attribute if it's empty.
50
+ #
51
+ # @note If it's a password field this will also take care to initially
52
+ # replace it with a regular text field (until it receives focus).
53
+ #
54
+ # @private
55
+ #
56
+ setupPseudoPlaceholder: =>
57
+ this.storeSelfReferenceAndObservers()
58
+
59
+ if @field.val() is ''
60
+ if @field.data('showPasswordObject') and @field.attr('type') is 'password'
61
+ @field.data('showPasswordObject').toggleField(type: 'text')
62
+ else
63
+ this.setValueAndToggleClass(@field.attr('placeholder'))
64
+
65
+ # This stores a reference to this object into `@field` and register observers on focus & blur.
66
+ #
67
+ # @private
68
+ #
69
+ storeSelfReferenceAndObservers: ->
70
+ @field.data('pseudoPlaceholderObject', this)
71
+ @field.on('focus', this.clearPseudoPlaceholder)
72
+ @field.on('blur', this.setupPseudoPlaceholder)
73
+
74
+ # This method clear the value and class of the field if its value is equal to the placeholder.
75
+ #
76
+ # @note It automatically replaces the field with a password field if needed.
77
+ #
78
+ # @private
79
+ #
80
+ clearPseudoPlaceholder: =>
81
+ if @field.val() is @field.attr('placeholder')
82
+ this.setValueAndToggleClass('')
83
+
84
+ if @field.data('showPasswordObject')
85
+ showPasswordObject = @field.data('showPasswordObject')
86
+ @field.removeData() # ensure the #fieldDidChange callback won't be called
87
+ @field = showPasswordObject.toggleField()
88
+ this.storeSelfReferenceAndObservers() # since we have a new field
89
+
90
+ # refocus (the newly create field)
91
+ setTimeout((=> @field.focus()), 0) # msie hack
@@ -0,0 +1,91 @@
1
+ # Manages the showing/hiding in clear text of the entered password
2
+ #
3
+ class SublimeVideo.Form.ShowPassword
4
+ constructor: (@field, @index) ->
5
+ @showPasswordCheckbox = $('<input />', type: 'checkbox', id: "show_password_#{@index}")
6
+
7
+ this.storeThisInData()
8
+ this.insertShowPasswordCheckbox()
9
+
10
+ #
11
+ # @private
12
+ #
13
+ storeThisInData: ->
14
+ @field.data('showPasswordObject', this) # so that the placeholderManager can eventually pick this up
15
+
16
+ #
17
+ # @private
18
+ #
19
+ insertShowPasswordCheckbox: ->
20
+ showPasswordWrap = $('<div>', class: 'checkbox_wrap')
21
+ showPasswordLabel = $('<label />', for: "show_password_#{@index}").text('Show password')
22
+ showPasswordWrap.append(@showPasswordCheckbox).append(showPasswordLabel)
23
+
24
+ this.injectShowPasswordCheckboxInDom(showPasswordWrap)
25
+ this.attachEventHandlerToCheckbox()
26
+
27
+ #
28
+ # @private
29
+ #
30
+ attachEventHandlerToCheckbox: ->
31
+ @showPasswordCheckbox.on('click', this.togglePasswordVisibility)
32
+
33
+ #
34
+ # @private
35
+ #
36
+ injectShowPasswordCheckboxInDom: (showPasswordWrap) ->
37
+ errorMessage = @field.parent('form').find('.inline_errors').first()
38
+ if errorMessage.length
39
+ errorMessage.after(showPasswordWrap)
40
+ else
41
+ @field.after(showPasswordWrap)
42
+ @showPasswordCheckbox.checked = false # Firefox reload ;-)
43
+
44
+ #
45
+ # @private
46
+ #
47
+ showPassword: ->
48
+ @showPasswordCheckbox and @showPasswordCheckbox.prop('checked')
49
+
50
+ #
51
+ # @private
52
+ #
53
+ togglePasswordVisibility: (event) =>
54
+ this.toggleField()
55
+
56
+ #
57
+ # @private
58
+ #
59
+ # @param [Object] options allow customizing the generated field
60
+ # @option options [Boolean] type force the type of the generated field
61
+ #
62
+ toggleField: (options = {}) ->
63
+ fieldType = if options['type']?
64
+ options['type']
65
+ else if this.showPassword() then 'text' else 'password'
66
+
67
+ # We can't simply modify the type attribute of the field (from 'password' to 'text'), because IE doesn't support this
68
+ # cf: http://www.alistapart.com/articles/the-problem-with-passwords
69
+ newField = $('<input />',
70
+ id: @field.attr 'id'
71
+ name: @field.attr 'name'
72
+ value: @field.val()
73
+ size: @field.size()
74
+ placeholder: @field.attr 'placeholder'
75
+ required: @field.attr 'required'
76
+ class: @field.attr 'class'
77
+ type: fieldType)
78
+
79
+ if @field.data 'pseudoPlaceholderObject'
80
+ pseudoPlaceholderObject = @field.data('pseudoPlaceholderObject')
81
+
82
+ @field.removeData() # Removes eventual observers and storage keys
83
+ @field.replaceWith newField
84
+ @field = newField
85
+ this.storeThisInData() # store this in the new field
86
+ pseudoPlaceholderObject.fieldDidChange(newField) if pseudoPlaceholderObject
87
+
88
+ if @field.attr('id') is 'user_password' and $('current_password_wrap').exists()
89
+ SublimeVideo.currentPasswordHandler.setupField(@field)
90
+
91
+ @field
@@ -0,0 +1,53 @@
1
+ # SubmitManager manages several automation on form submit:
2
+ #
3
+ # - disabling of submit button
4
+ # - asking for current password
5
+ # - cleaning of pseudo-placeholders
6
+ # - cleaning HTML5 errors that are not present anymore but there still are errors (on other fields)
7
+ #
8
+ class SublimeVideo.Form.SubmitManager
9
+ constructor: (@form) ->
10
+ this.setupOnSubmitObservers()
11
+ this.setupOnClickObservers()
12
+
13
+ setupOnSubmitObservers: ->
14
+ submitEvent = if Modernizr.hasEvent('submit') then 'submit' else 'emulated:submit'
15
+ @form.on submitEvent, (event) =>
16
+ if @form.data('remote') is 'true' or @form.hasClass('disableable')
17
+ this.disableSubmitButton()
18
+ this.resetPseudoPlaceholders()
19
+
20
+ if @form.data('password-protected') is 'true'
21
+ this.instanciatePasswordChecker(event)
22
+
23
+ setupOnClickObservers: ->
24
+ @form.find('input[type=submit]').each (index, input) =>
25
+ # when HTML5 form validation doesn't pass, the submit event is not fired
26
+ $(input).on 'click', (event) =>
27
+ @form.find('input,textarea').each (index, input) ->
28
+ $input = $(input)
29
+ if $input[0].validity
30
+ if $input[0].validity.valid
31
+ $input.removeClass('errors')
32
+ $input.siblings('.inline_errors').remove()
33
+ else
34
+ event.preventDefault()
35
+ $input.addClass('errors')
36
+
37
+ # Disable submit button for ajax forms to prevent double submissions (quickly click muliple times the form submit button)
38
+ #
39
+ # (PAY ATTENTION: this considers that the ajax call will re-render the entire form hence re-enabling the submit button.
40
+ # If we'll have some ajax forms that won't reload themselves, the code below must be updated)
41
+ disableSubmitButton: ->
42
+ @form.find('input[type=submit], button[type=submit]').each ->
43
+ $(this).prop('disabled', true)
44
+
45
+ instanciatePasswordChecker: (event) ->
46
+ event.preventDefault()
47
+ SublimeVideo.Form.passwordChecker = new SublimeVideo.Form.PasswordChecker $(event.target)
48
+
49
+ # Reset pseudo-placeholders values (for browsers who don't support HTML5 placeholders)
50
+ #
51
+ resetPseudoPlaceholders: ->
52
+ @form.find('input.placeholder').each ->
53
+ $(this).val('')