cambium 0.0.0 → 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (111) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +5 -1
  3. data/Rakefile +0 -1
  4. data/bin/cambium +20 -0
  5. data/cambium.gemspec +24 -1
  6. data/lib/cambium/engine.rb +6 -0
  7. data/lib/cambium/version.rb +1 -1
  8. data/lib/cambium.rb +1 -1
  9. data/lib/docs/notes.md +4 -0
  10. data/lib/generators/cambium/setup/config_generator.rb +185 -0
  11. data/lib/generators/cambium/setup/controllers_generator.rb +95 -0
  12. data/lib/generators/cambium/setup/devise_generator.rb +78 -0
  13. data/lib/generators/cambium/setup/helpers_generator.rb +71 -0
  14. data/lib/generators/cambium/setup/javascripts_generator.rb +111 -0
  15. data/lib/generators/cambium/setup/models_generator.rb +116 -0
  16. data/lib/generators/cambium/setup/stylesheets_generator.rb +86 -0
  17. data/lib/generators/cambium/setup/utilities_generator.rb +87 -0
  18. data/lib/generators/cambium/setup/views_generator.rb +86 -0
  19. data/lib/generators/cambium/templates/Gemfile.erb +41 -0
  20. data/lib/generators/cambium/templates/app/assets/javascripts/.DS_Store +0 -0
  21. data/lib/generators/cambium/templates/app/assets/javascripts/admin/admin.js +12 -0
  22. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/admin.js.coffee +22 -0
  23. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/models/.gitkeep +0 -0
  24. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/routers/router.js.coffee +12 -0
  25. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/templates/paginator_controls.jst.ejs +8 -0
  26. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/templates/paginator_nav.jst.ejs +11 -0
  27. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/accordion.js.coffee +33 -0
  28. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/counter.js.coffee +25 -0
  29. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/dropdown_toggle.js.coffee +16 -0
  30. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/init_counter.js.coffee +13 -0
  31. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/paginator.js.coffee +86 -0
  32. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/publishable.js.coffee +12 -0
  33. data/lib/generators/cambium/templates/app/assets/javascripts/admin/backbone/views/wysiwyg.js.coffee +10 -0
  34. data/lib/generators/cambium/templates/app/assets/javascripts/admin/wysihtml5.js +9521 -0
  35. data/lib/generators/cambium/templates/app/assets/javascripts/application.js +7 -0
  36. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/app.js.coffee +22 -0
  37. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/routers/router.js.coffee +23 -0
  38. data/lib/generators/cambium/templates/app/assets/javascripts/backbone/views/default_helpers.js.coffee +16 -0
  39. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/admin.scss +14 -0
  40. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/__default.scss +14 -0
  41. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_buttons.scss +21 -0
  42. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_colors.scss +93 -0
  43. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_components.scss +4 -0
  44. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_forms.scss +28 -0
  45. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_helpers.scss +31 -0
  46. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_images.scss +23 -0
  47. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_nav.scss +117 -0
  48. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_tables.scss +12 -0
  49. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_typography.scss +83 -0
  50. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones-config/_wireframe.scss +18 -0
  51. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/bones/bones.scss +68 -0
  52. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_content.scss +88 -0
  53. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_form.scss +470 -0
  54. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_globals.scss +39 -0
  55. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_header.scss +121 -0
  56. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_icons.scss +5194 -0
  57. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_nav.scss +45 -0
  58. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/partials/_wireframe.scss +24 -0
  59. data/lib/generators/cambium/templates/app/assets/stylesheets/admin/wysihtml5.css +7 -0
  60. data/lib/generators/cambium/templates/app/assets/stylesheets/application.scss +9 -0
  61. data/lib/generators/cambium/templates/app/controllers/admin/users_controller.rb +13 -0
  62. data/lib/generators/cambium/templates/app/controllers/admin_controller.rb +88 -0
  63. data/lib/generators/cambium/templates/app/controllers/application_controller.rb +15 -0
  64. data/lib/generators/cambium/templates/app/helpers/admin_helper.rb +120 -0
  65. data/lib/generators/cambium/templates/app/models/concerns/idx.rb +28 -0
  66. data/lib/generators/cambium/templates/app/models/concerns/name.rb +7 -0
  67. data/lib/generators/cambium/templates/app/models/concerns/publishable.rb +50 -0
  68. data/lib/generators/cambium/templates/app/models/concerns/slug.rb +52 -0
  69. data/lib/generators/cambium/templates/app/models/concerns/tags.rb +28 -0
  70. data/lib/generators/cambium/templates/app/models/concerns/title.rb +7 -0
  71. data/lib/generators/cambium/templates/app/models/user.rb +14 -0
  72. data/lib/generators/cambium/templates/app/views/admin/_buttons.html.erb +5 -0
  73. data/lib/generators/cambium/templates/app/views/admin/_form.html.erb +11 -0
  74. data/lib/generators/cambium/templates/app/views/admin/_title.html.erb +1 -0
  75. data/lib/generators/cambium/templates/app/views/admin/edit.html.erb +2 -0
  76. data/lib/generators/cambium/templates/app/views/admin/index.html.erb +50 -0
  77. data/lib/generators/cambium/templates/app/views/admin/new.html.erb +2 -0
  78. data/lib/generators/cambium/templates/app/views/admin/shared/_footer.html.erb +2 -0
  79. data/lib/generators/cambium/templates/app/views/admin/shared/_header.html.erb +2 -0
  80. data/lib/generators/cambium/templates/app/views/admin/shared/_nav.html.erb +12 -0
  81. data/lib/generators/cambium/templates/app/views/admin/shared/_status.html.erb +3 -0
  82. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_editor.html.erb +54 -0
  83. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_left.html.erb +9 -0
  84. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_column_right.html.erb +9 -0
  85. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_page.html.erb +18 -0
  86. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_form_section.html.erb +8 -0
  87. data/lib/generators/cambium/templates/app/views/admin/shared/forms/_publishable.html.erb +33 -0
  88. data/lib/generators/cambium/templates/app/views/admin/users/_form.html.erb +11 -0
  89. data/lib/generators/cambium/templates/app/views/application/_status.html.erb +3 -0
  90. data/lib/generators/cambium/templates/app/views/layouts/.DS_Store +0 -0
  91. data/lib/generators/cambium/templates/app/views/layouts/admin.html.erb +44 -0
  92. data/lib/generators/cambium/templates/app/views/layouts/application.html.erb +24 -0
  93. data/lib/generators/cambium/templates/config/application.rb +15 -0
  94. data/lib/generators/cambium/templates/config/database.mysql2.yml.erb +15 -0
  95. data/lib/generators/cambium/templates/config/database.pg.yml.erb +14 -0
  96. data/lib/generators/cambium/templates/config/database.sqlite3.yml.erb +18 -0
  97. data/lib/generators/cambium/templates/config/initializers/_settings.rb +11 -0
  98. data/lib/generators/cambium/templates/config/initializers/assets.rb +1 -0
  99. data/lib/generators/cambium/templates/config/routes.rb.erb +33 -0
  100. data/lib/generators/cambium/templates/config/settings.yml +15 -0
  101. data/lib/generators/cambium/templates/config/settings_private.sample.yml +15 -0
  102. data/lib/generators/cambium/templates/config/settings_private.yml +13 -0
  103. data/lib/generators/cambium/templates/db/seeds.rb +25 -0
  104. data/lib/generators/cambium/templates/gitignore +29 -0
  105. data/lib/generators/cambium/templates/lib/.DS_Store +0 -0
  106. data/lib/generators/cambium/templates/lib/tasks/db.rake +22 -0
  107. data/lib/generators/cambium/templates/lib/tasks/rename.rake +28 -0
  108. data/lib/generators/cambium/templates/vendor/assets/javascripts/modernizr.js +4 -0
  109. data/lib/generators/cambium/templates/vendor/assets/stylesheets/normalize.scss +406 -0
  110. data/lib/help/cambium +7 -0
  111. metadata +375 -4
@@ -0,0 +1,116 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class ModelsGenerator < Rails::Generators::Base
7
+ desc "Setup models for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ User Model
14
+
15
+ def add_admin_column_to_users
16
+ unless User.column_names.include?('is_admin')
17
+ run_cmd "#{g} migration add_is_admin_to_users is_admin:boolean"
18
+ run_cmd "#{rake} db:migrate"
19
+ end
20
+ end
21
+
22
+ def add_user_model_file
23
+ remove_file "app/models/user.rb"
24
+ template "app/models/user.rb", "app/models/user.rb"
25
+ run_cmd "#{be} annotate"
26
+ end
27
+
28
+ def add_default_user
29
+ User.reset_column_information
30
+ create_user
31
+ end
32
+
33
+ # ------------------------------------------ Model Concerns
34
+
35
+ def add_model_concerns
36
+ [
37
+ 'idx',
38
+ 'name',
39
+ 'publishable',
40
+ 'slug',
41
+ 'tags',
42
+ 'title',
43
+ ].each do |concern|
44
+ copy_file "app/models/concerns/#{concern}.rb",
45
+ "app/models/concerns/#{concern}.rb"
46
+ end
47
+ end
48
+
49
+ # ------------------------------------------ Private Methods
50
+
51
+ private
52
+
53
+ def run_cmd(cmd, options = {})
54
+ print_table(
55
+ [
56
+ [set_color("run", :green, :bold), cmd]
57
+ ],
58
+ :indent => 9
59
+ )
60
+ if options[:quiet] == true
61
+ `#{cmd}`
62
+ else
63
+ system(cmd)
64
+ end
65
+ end
66
+
67
+ def template_file(name)
68
+ File.expand_path("../../templates/#{name}", __FILE__)
69
+ end
70
+
71
+ def file_contents(template)
72
+ File.read(template_file(template))
73
+ end
74
+
75
+ def be
76
+ "bundle exec"
77
+ end
78
+
79
+ def g
80
+ "#{be} rails g"
81
+ end
82
+
83
+ def rake
84
+ "#{be} rake"
85
+ end
86
+
87
+ def confirm_ask(question)
88
+ answer = ask("\n#{question}")
89
+ match = ask("CONFIRM #{question}")
90
+ if answer == match
91
+ answer
92
+ else
93
+ say set_color("Did not match.", :red)
94
+ confirm_ask(question)
95
+ end
96
+ end
97
+
98
+ def create_user
99
+ email = confirm_ask "#{set_color('Default User Email', :green, :bold)}:"
100
+ password = confirm_ask "#{set_color('Default User Password', :green, :bold)}:"
101
+ u = User.new(
102
+ :email => email,
103
+ :password => password,
104
+ :password_confirmation => password,
105
+ :is_admin => true
106
+ )
107
+ if u.save
108
+ say "User created successfully!"
109
+ else
110
+ create_user
111
+ end
112
+ end
113
+
114
+ end
115
+ end
116
+ end
@@ -0,0 +1,86 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class StylesheetsGenerator < Rails::Generators::Base
7
+ desc "Setup stylesheets for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Public Styles
14
+
15
+ def add_public_manifest
16
+ ['css','scss','scss.css'].each { |ext| remove_file "app/assets/stylesheets/application.#{ext}" }
17
+ template "app/assets/stylesheets/application.scss",
18
+ "app/assets/stylesheets/application.scss"
19
+ end
20
+
21
+ # ------------------------------------------ Admin Styles
22
+
23
+ def add_admin_styles
24
+ directory "app/assets/stylesheets/admin",
25
+ "app/assets/stylesheets/admin"
26
+ end
27
+
28
+ # ------------------------------------------ Add Modernizr
29
+
30
+ def add_normalize
31
+ normalize = "vendor/assets/stylesheets/normalize.scss"
32
+ template normalize, normalize
33
+ end
34
+
35
+ # ------------------------------------------ Private Methods
36
+
37
+ private
38
+
39
+ def run_cmd(cmd, options = {})
40
+ print_table(
41
+ [
42
+ [set_color("run", :green, :bold), cmd]
43
+ ],
44
+ :indent => 9
45
+ )
46
+ if options[:quiet] == true
47
+ `#{cmd}`
48
+ else
49
+ system(cmd)
50
+ end
51
+ end
52
+
53
+ def template_file(name)
54
+ File.expand_path("../../templates/#{name}", __FILE__)
55
+ end
56
+
57
+ def file_contents(template)
58
+ File.read(template_file(template))
59
+ end
60
+
61
+ def be
62
+ "bundle exec"
63
+ end
64
+
65
+ def g
66
+ "#{be} rails g"
67
+ end
68
+
69
+ def rake
70
+ "#{be} rake"
71
+ end
72
+
73
+ def confirm_ask(question)
74
+ answer = ask("\n#{question}")
75
+ match = ask("Confirm: #{question}")
76
+ if answer == match
77
+ answer
78
+ else
79
+ say set_color("Did not match.", :red)
80
+ confirm_ask(question)
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,87 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class UtilitiesGenerator < Rails::Generators::Base
7
+ desc "Setup utilities for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Settings Files
14
+
15
+ def add_settings_files
16
+ ['settings','settings_private','settings_private.sample'].each do |s|
17
+ template "config/#{s}.yml", "config/#{s}.yml"
18
+ end
19
+ end
20
+
21
+ # ------------------------------------------ Seeds
22
+
23
+ def add_seed_generator
24
+ remove_file "db/seeds.rb"
25
+ template "db/seeds.rb", "db/seeds.rb"
26
+ end
27
+
28
+ # ------------------------------------------ Rake Tasks
29
+
30
+ def add_rake_tasks
31
+ ['db','rename'].each do |task|
32
+ template "lib/tasks/#{task}.rake", "lib/tasks/#{task}.rake"
33
+ end
34
+ end
35
+
36
+ # ------------------------------------------ Private Methods
37
+
38
+ private
39
+
40
+ def run_cmd(cmd, options = {})
41
+ print_table(
42
+ [
43
+ [set_color("run", :green, :bold), cmd]
44
+ ],
45
+ :indent => 9
46
+ )
47
+ if options[:quiet] == true
48
+ `#{cmd}`
49
+ else
50
+ system(cmd)
51
+ end
52
+ end
53
+
54
+ def template_file(name)
55
+ File.expand_path("../../templates/#{name}", __FILE__)
56
+ end
57
+
58
+ def file_contents(template)
59
+ File.read(template_file(template))
60
+ end
61
+
62
+ def be
63
+ "bundle exec"
64
+ end
65
+
66
+ def g
67
+ "#{be} rails g"
68
+ end
69
+
70
+ def rake
71
+ "#{be} rake"
72
+ end
73
+
74
+ def confirm_ask(question)
75
+ answer = ask("\n#{question}")
76
+ match = ask("Confirm: #{question}")
77
+ if answer == match
78
+ answer
79
+ else
80
+ say set_color("Did not match.", :red)
81
+ confirm_ask(question)
82
+ end
83
+ end
84
+
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,86 @@
1
+ require 'rake'
2
+ require 'rails/generators'
3
+
4
+ module Cambium
5
+ module Setup
6
+ class ViewsGenerator < Rails::Generators::Base
7
+ desc "Setup views for new rails project"
8
+
9
+ # ------------------------------------------ Class Methods
10
+
11
+ source_root File.expand_path('../../templates', __FILE__)
12
+
13
+ # ------------------------------------------ Admin Views
14
+
15
+ def add_admin_views
16
+ directory "app/views/admin", "app/views/admin"
17
+ end
18
+
19
+ # ------------------------------------------ Layouts
20
+
21
+ def add_layouts
22
+ app = "app/views/layouts/application.html.erb"
23
+ admin = "app/views/layouts/admin.html.erb"
24
+ remove_file app
25
+ template app, app
26
+ template admin, admin
27
+ end
28
+
29
+ # ------------------------------------------ Public Views
30
+
31
+ def add_public_views
32
+ directory "app/views/application", "app/views/application"
33
+ end
34
+
35
+ # ------------------------------------------ Private Methods
36
+
37
+ private
38
+
39
+ def run_cmd(cmd, options = {})
40
+ print_table(
41
+ [
42
+ [set_color("run", :green, :bold), cmd]
43
+ ],
44
+ :indent => 9
45
+ )
46
+ if options[:quiet] == true
47
+ `#{cmd}`
48
+ else
49
+ system(cmd)
50
+ end
51
+ end
52
+
53
+ def template_file(name)
54
+ File.expand_path("../../templates/#{name}", __FILE__)
55
+ end
56
+
57
+ def file_contents(template)
58
+ File.read(template_file(template))
59
+ end
60
+
61
+ def be
62
+ "bundle exec"
63
+ end
64
+
65
+ def g
66
+ "#{be} rails g"
67
+ end
68
+
69
+ def rake
70
+ "#{be} rake"
71
+ end
72
+
73
+ def confirm_ask(question)
74
+ answer = ask("\n#{question}")
75
+ match = ask("Confirm: #{question}")
76
+ if answer == match
77
+ answer
78
+ else
79
+ say set_color("Did not match.", :red)
80
+ confirm_ask(question)
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+ end
@@ -0,0 +1,41 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # ------------------------------------------ Base
4
+
5
+ gem 'rails', '<%= @config[:app][:version] %>'
6
+ gem 'unicorn-rails'
7
+ gem '<%= @config[:db][:adapter] %>'
8
+ # gem 'cambium', :git => 'git@github.com:seancdavis/cambium.git'
9
+ gem 'cambium', :path => "/Users/sean/www/rt/rt/cambium"
10
+
11
+ # ------------------------------------------ Assets
12
+
13
+ gem 'sass-rails'
14
+ gem 'uglifier'
15
+ gem 'coffee-rails'
16
+ gem 'jquery-rails'
17
+ gem 'bones-rails'
18
+ gem 'bourbon'
19
+ gem 'rails-backbone'
20
+
21
+ # ------------------------------------------ View Helpers
22
+
23
+ gem 'jbuilder'
24
+ gem 'simple_form'
25
+ gem 'wysihtml5-rails'
26
+ gem 'pickadate-rails'
27
+
28
+ # ------------------------------------------ Utilities
29
+
30
+ gem 'devise'
31
+ gem 'carrierwave'
32
+ gem 'hirb'
33
+
34
+ # ------------------------------------------ Development/Test
35
+
36
+ group :development do
37
+ gem 'annotate'
38
+ end
39
+
40
+ gem 'factory_girl_rails'
41
+ gem 'faker'
@@ -0,0 +1,12 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require pickadate/picker
4
+ //= require pickadate/picker.date
5
+ //= require pickadate/picker.time
6
+ //= require admin/wysihtml5
7
+ //= require parser_rules/advanced
8
+ //= require underscore
9
+ //= require backbone
10
+ //= require backbone_rails_sync
11
+ //= require backbone_datalink
12
+ //= require admin/backbone/admin
@@ -0,0 +1,22 @@
1
+ #= require_self
2
+ #= require_tree ./templates
3
+ #= require_tree ./models
4
+ #= require_tree ./views
5
+ #= require_tree ./routers
6
+
7
+ window.Admin =
8
+ Models: {}
9
+ Collections: {}
10
+ Routers: {}
11
+ Views: {}
12
+
13
+ $(document).ready ->
14
+ new Admin.Routers.Router
15
+
16
+ # Enable pushState for compatible browsers
17
+ enablePushState = true
18
+
19
+ # Disable for older browsers
20
+ pushState = !!(enablePushState && window.history && window.history.pushState)
21
+
22
+ Backbone.history.start({ pushState: pushState })
@@ -0,0 +1,12 @@
1
+ class Admin.Routers.Router extends Backbone.Router
2
+
3
+ initialize: =>
4
+ @autoLoad()
5
+
6
+ autoLoad: =>
7
+ new Admin.Views.Wysiwyg if $(".wysihtml5").length > 0
8
+ new Admin.Views.Publishable if $("[class*=_active_date]").length > 0
9
+ new Admin.Views.InitCounter if $('input').length > 0
10
+ new Admin.Views.Paginator if $('table').length > 0
11
+ new Admin.Views.DropdownToggle if $('.dropdown-toggle').length > 0
12
+ new Admin.Views.Accordion if $('.accordion').length > 0
@@ -0,0 +1,8 @@
1
+ <div class="controls">
2
+ <a href="#" class="prev button-color-1">
3
+ <i class="icon-arrow-left"></i>&nbsp;Previous
4
+ </a>
5
+ <a href="#" class="next button-color-1 float-right">
6
+ Next&nbsp;<i class="icon-arrow-right2"></i>
7
+ </a>
8
+ </div>
@@ -0,0 +1,11 @@
1
+ <div class="paginav">
2
+ <div class="jump-to">
3
+ <input type="submit" id="jump-to" value="Jump!">
4
+ <input type="text" placeholder="Jump To..." id="jump-to-val">
5
+ </div>
6
+ <div class="location">
7
+ (Page <span class="current">1</span>
8
+ of
9
+ <span class="total">?</span>)
10
+ </div>
11
+ </div>
@@ -0,0 +1,33 @@
1
+ class Admin.Views.Accordion extends Backbone.View
2
+
3
+ el: '.accordion'
4
+
5
+ events:
6
+ "click a.arrow": "toggleSlide"
7
+
8
+ initialize: =>
9
+ for el in $('.accordion')
10
+ $(el).children('header').append """
11
+ <a class="arrow" href="#">
12
+ <i class="icon icon-arrow-up"></i>
13
+ </a>
14
+ """
15
+ if $(el).hasClass('closed')
16
+ $(el).find('.arrow i').toggleClass "icon-arrow-up"
17
+ $(el).find('.arrow i').toggleClass "icon-arrow-down"
18
+ $(el).find('.fields').hide()
19
+
20
+ toggleSlide: (e) =>
21
+ e.preventDefault()
22
+ acc = $(e.target).parents('.accordion')
23
+ acc.toggleClass "closed"
24
+ if acc.hasClass "closed"
25
+ acc.children('.fields').slideUp()
26
+ else
27
+ acc.children('.fields').slideDown()
28
+ if $(e.target).children('.icon').length == 0
29
+ $(e.target).toggleClass "icon-arrow-up"
30
+ $(e.target).toggleClass "icon-arrow-down"
31
+ else
32
+ $(e.target).children('.icon').toggleClass "icon-arrow-up"
33
+ $(e.target).children('.icon').toggleClass "icon-arrow-down"
@@ -0,0 +1,25 @@
1
+ class Admin.Views.Counter extends Backbone.View
2
+
3
+ el: 'body'
4
+
5
+ initialize: (options) =>
6
+ @max = options.max
7
+ @target = "##{options.target}"
8
+ @setupCounter()
9
+ @updateCounter()
10
+ $(@target).keyup =>
11
+ @updateCounter()
12
+
13
+ setupCounter: =>
14
+ $(@target).siblings('label').append """
15
+ &nbsp;(<span class="maxlength">#{@max}</span>)
16
+ """
17
+ @counter = $(@target).siblings('label').children('.maxlength')
18
+
19
+ updateCounter: =>
20
+ charsRemaining = @max - $(@target).val().length
21
+ $(@counter).html charsRemaining
22
+ if charsRemaining > 10
23
+ $(@counter).removeClass('warning')
24
+ else
25
+ $(@counter).addClass('warning')
@@ -0,0 +1,16 @@
1
+ class Admin.Views.DropdownToggle extends Backbone.View
2
+
3
+ el: '.dropdown-toggle'
4
+
5
+ events:
6
+ 'click .trigger': 'initClick'
7
+
8
+ initClick: (e) =>
9
+ e.preventDefault()
10
+ if $(e.target).hasClass('trigger')
11
+ trigger = $(e.target)
12
+ else
13
+ trigger = $(e.target).parents('.trigger')
14
+ trigger.toggleClass('active')
15
+ trigger.children('i').toggleClass('icon-arrow-down icon-arrow-up')
16
+ trigger.siblings('ul').toggle()
@@ -0,0 +1,13 @@
1
+ class Admin.Views.InitCounter extends Backbone.View
2
+
3
+ el: 'form'
4
+
5
+ initialize: =>
6
+ @findMaxLengths()
7
+
8
+ findMaxLengths: =>
9
+ for input in $('input')
10
+ if $(input).attr('maxlength')?
11
+ new Admin.Views.Counter
12
+ target: $(input).attr('id')
13
+ max: $(input).attr('maxlength')
@@ -0,0 +1,86 @@
1
+ class Admin.Views.Paginator extends Backbone.View
2
+
3
+ el: 'table'
4
+ group: 15
5
+ current: 1
6
+ next: 2
7
+
8
+ controls: JST['admin/backbone/templates/paginator_controls']
9
+ paginav: JST['admin/backbone/templates/paginator_nav']
10
+
11
+ initialize: =>
12
+ @setup()
13
+ @bindEvents()
14
+
15
+ setup: =>
16
+ for submission, i in $('tbody tr') by @group
17
+ $('tbody tr').slice(i, i + @group).attr('data-group', Math.floor(i / @group) + 1)
18
+ $("tbody tr[data-group='1']").show()
19
+ @max = $('tbody tr').last().data('group')
20
+ @prev = @max
21
+ if $("tbody tr[data-group='2']").length > 0
22
+ $(@el).before @controls
23
+ $(@el).after @paginav
24
+ $('.paginav .total').html @max
25
+ $(@el).addClass('active')
26
+
27
+ bindEvents: =>
28
+ @previousButton = $('.controls .prev').first()
29
+ @previousButton.hide()
30
+ @nextButton = $('.controls .next').first()
31
+ @previousButton.click (e) =>
32
+ e.preventDefault()
33
+ @goBack()
34
+ @nextButton.click (e) =>
35
+ e.preventDefault()
36
+ @goForward()
37
+ if $("tbody tr[data-group='2']").length > 0
38
+ $('#jump-to').click (e) =>
39
+ e.preventDefault()
40
+ page = $('#jump-to-val').val()
41
+ @jumpTo(page) if page != '' and page <= @max
42
+ $('#jump-to-val').keyup (e) =>
43
+ e.preventDefault()
44
+ $("#jump-to").click() if e.keyCode == 13
45
+
46
+ goForward: =>
47
+ $("tbody tr[data-group='#{@current}']").hide()
48
+ $("tbody tr[data-group='#{@next}']").show()
49
+ @prev = @current
50
+ @current = @next
51
+ if @next == @max
52
+ @next = 1
53
+ else
54
+ @next++
55
+ @updatePaginav()
56
+
57
+ goBack: =>
58
+ $("tbody tr[data-group='#{@current}']").hide()
59
+ $("tbody tr[data-group='#{@prev}']").show()
60
+ @next = @current
61
+ @current = @prev
62
+ if @prev == 1
63
+ @prev = @max
64
+ else
65
+ @prev--
66
+ @updatePaginav()
67
+
68
+ updatePaginav: =>
69
+ $('.paginav .current').html @current
70
+ @previousButton.hide() if @current == 1
71
+ @previousButton.fadeIn() if @current == 2
72
+ @nextButton.hide() if @current == @max
73
+ @nextButton.fadeIn() if @next == @max
74
+
75
+ jumpTo: (page) =>
76
+ $('#jump-to-val').val('')
77
+ $("tbody tr[data-group='#{@current}']").hide()
78
+ $("tbody tr[data-group='#{page}']").show()
79
+ @current = page
80
+ if @current == @max
81
+ @next = 1
82
+ @prev = @current - 1
83
+ else if @current == 1
84
+ @prev = @max
85
+ @next = 2
86
+ @updatePaginav()
@@ -0,0 +1,12 @@
1
+ class Admin.Views.Publishable extends Backbone.View
2
+
3
+ el: 'body'
4
+
5
+ initialize: =>
6
+ @setupPickadate()
7
+
8
+ setupPickadate: =>
9
+ $('.active-date').pickadate()
10
+ $('.inactive-date').pickadate()
11
+ $('.active-time').pickatime()
12
+ $('.inactive-time').pickatime()