golden-theme 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -0
  3. data/app/assets/javascripts/golden/theme/bootstrap.js.coffee +7 -0
  4. data/app/assets/javascripts/golden/theme/foundation.js.coffee +7 -0
  5. data/app/assets/javascripts/golden/theme/foundation/ajax-chosen.js.coffee +10 -0
  6. data/app/assets/javascripts/golden/theme/foundation/ajax-tabs.js.coffee +42 -0
  7. data/app/assets/javascripts/golden/theme/foundation/bench-util-jquery.js.coffee +48 -0
  8. data/app/assets/javascripts/golden/theme/foundation/modal.js.coffee +60 -0
  9. data/app/assets/stylesheets/golden/theme/foundation.css.sass +4 -0
  10. data/app/assets/stylesheets/golden/theme/foundation/devise.css.sass +2 -0
  11. data/app/controllers/concerns/golden/theme/foundation/pagination.rb +33 -0
  12. data/app/views/application/{_flash_messages.html.erb → bootstrap/_flash_messages.html.erb} +1 -1
  13. data/app/views/application/bootstrap/_main_navigation.html.erb +1 -1
  14. data/app/views/application/bootstrap/_user_navigation.html.erb +3 -3
  15. data/app/views/application/foundation/_flash_messages.html.erb +10 -0
  16. data/app/views/application/foundation/_header.html.erb +17 -0
  17. data/app/views/application/foundation/_main_navigation.html.erb +5 -0
  18. data/app/views/application/foundation/_pagination.html.erb +9 -0
  19. data/app/views/application/foundation/_user_navigation.html.erb +19 -0
  20. data/config/locales/application.en.yml +16 -0
  21. data/config/locales/application.zh-TW.yml +16 -0
  22. data/golden-theme.gemspec +6 -1
  23. data/lib/golden/theme.rb +7 -0
  24. data/lib/golden/theme/bootstrap/alert_helper.rb +25 -0
  25. data/{app/helpers → lib}/golden/theme/bootstrap/button_helper.rb +1 -1
  26. data/{app/helpers → lib}/golden/theme/bootstrap/common_helper.rb +6 -6
  27. data/lib/golden/theme/bootstrap/deprecated_helper.rb +95 -0
  28. data/{app/helpers → lib}/golden/theme/bootstrap/dropdown_helper.rb +4 -4
  29. data/{app/helpers → lib}/golden/theme/bootstrap/link_helper.rb +10 -10
  30. data/lib/golden/theme/bootstrap/link_renderer.rb +3 -3
  31. data/{app/helpers → lib}/golden/theme/bootstrap/modal_helper.rb +7 -8
  32. data/{app/helpers → lib}/golden/theme/bootstrap/tab_helper.rb +19 -19
  33. data/lib/golden/theme/engine.rb +3 -0
  34. data/lib/golden/theme/foundation/alerts_helper.rb +19 -0
  35. data/lib/golden/theme/foundation/buttons_helper.rb +11 -0
  36. data/lib/golden/theme/foundation/common_helper.rb +66 -0
  37. data/lib/golden/theme/foundation/dropdowns_helper.rb +47 -0
  38. data/lib/golden/theme/foundation/link_helper.rb +56 -0
  39. data/lib/golden/theme/foundation/link_renderer.rb +63 -0
  40. data/lib/golden/theme/foundation/reveal_modal_helper.rb +63 -0
  41. data/lib/golden/theme/foundation/sub_nav_helper.rb +11 -0
  42. data/lib/golden/theme/foundation/tabs_helper.rb +58 -0
  43. data/lib/golden/theme/foundation/top_bar_helper.rb +16 -0
  44. data/lib/golden/theme/helpers.rb +24 -0
  45. data/lib/golden/theme/version.rb +1 -1
  46. metadata +79 -12
  47. data/app/assets/javascripts/golden/theme/bootstrap.js +0 -7
  48. data/app/helpers/golden/theme/bootstrap/alert_helper.rb +0 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 63af6ed8665891c5163c8abf8d385bc32f7b91da
4
- data.tar.gz: 059665596c4cd4b3c33bde9833bbe4769d321107
3
+ metadata.gz: cd5fdd8028f9c69c2c4ecec645dc9a7d067c258f
4
+ data.tar.gz: 3ab216688d497e5066e5cb69e6f2054380e41c02
5
5
  SHA512:
6
- metadata.gz: 6feccdb968f5ccc3f8e695d6e8e9ecbeff5a09e98dd27441864b5959f65422f7b38937a2ba780ccdc34f114f1d5bfac1407c1b220124907336ec0b4241cc49b1
7
- data.tar.gz: 3d5d709973e992ea8328ed8284a4ee0614fbb04156b0af835509afe5b43721759b2f50f64b53aec102be0428bca96b6dc276a5cb5be67fa0e1b6379ec5dff7ee
6
+ metadata.gz: 2288fb74a13f1d5d996987c7d1e18ad5abc0e2e384faf5d2789ce1cd37ac04d56365af4cfcff48fbb26399d972f25d94a442a6a075f07c9bdb929af37a666115
7
+ data.tar.gz: 073de71bebbdbe64a4729bf3e45f24c89a26b3828ccbc38e2da93e29ee3266eb34906ff5702339d65aac52f82fb598acc31a980ac9a9b6b58ee4e11be14acb8b
data/README.md CHANGED
@@ -18,6 +18,14 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
+ Add following to `application_controller.rb` with `:bootstrap` or `:foundation`
22
+
23
+ ```
24
+ before_action do
25
+ golden_theme_framework :bootstrap
26
+ end
27
+ ```
28
+
21
29
  ## Contributing
22
30
 
23
31
  1. Fork it ( https://github.com/[my-github-username]/golden-theme/fork )
@@ -0,0 +1,7 @@
1
+ #= require jquery.ui.effect-highlight
2
+ #= require chosen-jquery
3
+
4
+ #= require golden/theme/bootstrap/bench-util-jquery
5
+ #= require golden/theme/bootstrap/modal
6
+ #= require golden/theme/bootstrap/ajax-tabs
7
+ #= require golden/theme/bootstrap/ajax-chosen
@@ -0,0 +1,7 @@
1
+ #= require jquery.ui.effect-highlight
2
+ #= require chosen-jquery
3
+
4
+ #= require golden/theme/foundation/bench-util-jquery
5
+ #= require golden/theme/foundation/modal
6
+ #= require golden/theme/foundation/ajax-tabs
7
+ #= require golden/theme/foundation/ajax-chosen
@@ -0,0 +1,10 @@
1
+ $ ->
2
+ $('.chosen-select').chosen
3
+ allow_single_deselect: true
4
+ no_results_text: 'No results matched'
5
+ width: '100%'
6
+
7
+ $('.ajax-chosen-select').chosen
8
+ allow_single_deselect: true
9
+ no_results_text: 'No results matched'
10
+ width: '100%'
@@ -0,0 +1,42 @@
1
+ $ ->
2
+ $('.nav-tabs-ajax')
3
+ .on 'ajax:beforeSend', 'a[data-toggle="tab"]', ->
4
+ $.bench.util.replaceDataTarget $(this), 'Loading...'
5
+ .on 'ajax:success', 'a[data-toggle="tab"]', (event, data, status, xhr) ->
6
+ $.bench.util.replaceDataTarget $(this), data
7
+ $.bench.util.enableChosen()
8
+ .on 'ajax:error', 'a[data-toggle="tab"]', (event, xhr, status, error) ->
9
+ if error == 'Unauthorized' or xhr.status == 401
10
+ $.bench.util.replaceDataTarget $(this), ''
11
+ $.bench.util.redirect_to_unauthorized_url
12
+ else
13
+ $.bench.util.replaceDataTarget $(this), status
14
+
15
+ $('.tabs-content')
16
+ .on 'ajax:success', '.pagination a[data-toggle="tab"]', (event, data, status, xhr) ->
17
+ $.bench.util.replaceDataTarget $(this), data
18
+ .on 'ajax:error', '.pagination a[data-toggle="tab"]', (event, xhr, status, error) ->
19
+ if error == 'Unauthorized' or xhr.status == 401
20
+ $.bench.util.replaceDataTarget $(this), ''
21
+ $.bench.util.redirect_to_unauthorized_url
22
+ else
23
+ $.bench.util.replaceDataTarget $(this), status
24
+
25
+ $('.tabs-content .content')
26
+ .on 'ajax:success', '.simple_form', (event, data, status, xhr) ->
27
+ tab_pane = $(this).parent()
28
+ $.bench.util.appendFeedback(tab_pane, data)
29
+ if $.bench.util.hasErrorFeedback(tab_pane)
30
+ $.bench.util.replaceFeedback(tab_pane)
31
+ $.bench.util.enableChosen()
32
+ return true
33
+ tab_pane.html(data)
34
+ $.bench.util.enableChosen()
35
+ tab_pane.effect('highlight', 'slow')
36
+ .on 'ajax:error', '.simple_form', (event, xhr, status, error) ->
37
+ tab_pane = $(this).parent()
38
+ if error == 'Unauthorized' or xhr.status == 401
39
+ tab_pane.html('')
40
+ $.bench.util.redirect_to_unauthorized_url
41
+ else
42
+ tab_pane.html(status)
@@ -0,0 +1,48 @@
1
+ $ ->
2
+ #### namespace ####
3
+
4
+ $.bench ||= {}
5
+ $.bench.util ||= {}
6
+
7
+
8
+ #### util ####
9
+
10
+ $.bench.util.clearSelectOptions = (subject, disabled = true) ->
11
+ blank_option = $('<option>').attr('value', '')
12
+ if disabled
13
+ subject.prop('disabled', true)
14
+ subject.empty().append(blank_option)
15
+
16
+ $.bench.util.appendSelectOptions = (subject, choices, disabled = false) ->
17
+ return unless choices
18
+ $.each choices, (i, hash) ->
19
+ option = $('<option>').attr('value', hash['id']).text(hash['name'])
20
+ subject.append option
21
+ if !disabled
22
+ subject.prop('disabled', false)
23
+ subject.focus().children().first().text('')
24
+
25
+ $.bench.util.appendFeedback = (container, data) ->
26
+ if container.find('.feedback').size() < 1
27
+ $('<div>').addClass('feedback hide').html(data).appendTo(container)
28
+
29
+ $.bench.util.replaceFeedback = (container) ->
30
+ content = container.children('.feedback').html()
31
+ container.html(content)
32
+
33
+ $.bench.util.hasErrorFeedback = (container) ->
34
+ container.find('.feedback .alert-box warning').size() > 0
35
+
36
+ $.bench.util.replaceDataTarget = (subject, data) ->
37
+ target = $(subject.attr('data-target'))
38
+ target.html(data)
39
+
40
+ $.bench.util.enableChosen = () ->
41
+ $('.chosen-select, .ajax-chosen-select').chosen
42
+ allow_single_deselect: true
43
+ no_results_text: 'No results matched'
44
+ width: '100%'
45
+
46
+ $.bench.util.redirect_to_unauthorized_url = () ->
47
+ url = $('#unauthorized_sign_out_url').prop('href')
48
+ window.location.replace(url)
@@ -0,0 +1,60 @@
1
+ $ ->
2
+ #### namespace ####
3
+
4
+ $.modal ||= {}
5
+
6
+ #### modal ####
7
+ $.modal.showErrorModal = (status, error, modal = $(this)) ->
8
+ modal.html($('#error-modal').html())
9
+ .find('.modal-header h3').html(status).end()
10
+ .children('.modal-body').html(error || 'No Connection!')
11
+
12
+ $.modal.appendFeedback = (modal, data) ->
13
+ $('<div>').addClass('feedback hide').html(data).appendTo(modal)
14
+
15
+ $.modal.replaceFeedback = (modal) ->
16
+ modal.html(modal.children('.feedback').html())
17
+ $.modal.enableChosen()
18
+
19
+ $.modal.submitForm = (submit_id, modal = $(this)) ->
20
+ modal.find('.feedback').remove().end()
21
+ .modal('hide')
22
+ $.modal.disableOtherSubmit submit_id
23
+ $.modal.enableSingleSubmit submit_id
24
+ $(submit_id).removeAttr('data-toggle').click()
25
+ return true
26
+
27
+ $.modal.replaceTable = (table_id, modal = $(this)) ->
28
+ feedback_table = modal.find('.table')
29
+ table = $(table_id).find('.table')
30
+ table.html(feedback_table.html())
31
+ modal.find('.feedback').remove().end()
32
+ .modal('hide')
33
+ table.effect('shake')
34
+ return true
35
+
36
+ # $.rails.disableFormElements(form) will disable all disable-with element
37
+ $.modal.disableSingleSubmit = (element_id) ->
38
+ $(element_id).data('modal:enable-with', $(element_id).val())
39
+ $(element_id).val($(element_id).data('disable-with'))
40
+ $(element_id).prop('disabled', true)
41
+
42
+ # $.rails.enableFormElements(form) will enable all disable-with element
43
+ $.modal.enableSingleSubmit = (element_id) ->
44
+ if $(element_id).data('modal:enable-with')
45
+ $(element_id).val($(element_id).data('modal:enable-with'))
46
+ $(element_id).prop('disabled', false)
47
+
48
+ # disable other submit buttons other than the specified one
49
+ $.modal.disableOtherSubmit = (submit_id) ->
50
+ submit_button = $(submit_id)
51
+ submit_button.parents('form').find($.rails.disableSelector).each () ->
52
+ if submit_button.val() != $(this).val()
53
+ $(this).prop('disabled', true)
54
+ $(this).removeAttr('data-disable-with')
55
+
56
+ $.modal.enableChosen = () ->
57
+ $('.chosen-select').chosen
58
+ allow_single_deselect: true
59
+ no_results_text: 'No results matched'
60
+ width: '100%'
@@ -0,0 +1,4 @@
1
+ //= require chosen
2
+ //= require golden/theme/foundation/devise
3
+
4
+ @import 'foundation-icons'
@@ -0,0 +1,2 @@
1
+ body
2
+ padding-top: 45px
@@ -0,0 +1,33 @@
1
+ module Golden::Theme::Foundation
2
+ module Pagination
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ before_action :clear_pagination_options
7
+ end
8
+
9
+ module ClassMethods
10
+ end
11
+
12
+ protected
13
+
14
+ def clear_pagination_options
15
+ Golden::Theme::Foundation::LinkRenderer.link_options = nil
16
+ end
17
+
18
+ def set_ajax_tab_pagination_render_options tab_name
19
+ Golden::Theme::Foundation::LinkRenderer.link_options = {
20
+ 'data-remote' => true,
21
+ 'data-type' => :html,
22
+ 'data-toggle' => 'tab',
23
+ 'data-target' => "##{tab_name}"
24
+ }
25
+ end
26
+
27
+ def last_page_collection query
28
+ last_page = query.paginate(page: 1).total_pages
29
+ params[:page] = last_page
30
+ query.paginate page: last_page
31
+ end
32
+ end
33
+ end
@@ -5,6 +5,6 @@
5
5
  <div class="messages">
6
6
  <% flash.each do |key, value| %>
7
7
  <% next if %w(timedout).include? key.to_s %>
8
- <%= flash_box key, value %>
8
+ <%= bootstrap_alert_box key, value %>
9
9
  <% end %>
10
10
  </div>
@@ -3,6 +3,6 @@
3
3
  </header>
4
4
 
5
5
  <div>
6
- <%= render_list class: 'nav navbar-nav' do |li|
6
+ <%= bootstrap_ul_tag class: 'nav navbar-nav' do |li|
7
7
  end %>
8
8
  </div>
@@ -3,11 +3,11 @@
3
3
  </header>
4
4
 
5
5
  <div id="user-identity">
6
- <%= render_list class: 'nav navbar-nav pull-right' do |li|
6
+ <%= bootstrap_ul_tag class: 'nav navbar-nav pull-right' do |li|
7
7
  if signed_in?
8
8
  li << [
9
- dropdown_toggle(current_user.name),
10
- dropdown_menu do |li2|
9
+ bootstrap_dropdown_toggle(current_user.name),
10
+ bootstrap_dropdown_menu do |li2|
11
11
  li2 << link_to_edit_user_profile
12
12
  li2 << ['', class: 'divider']
13
13
  li2 << link_to_user_sign_out
@@ -0,0 +1,10 @@
1
+ <header class="hide">
2
+ <h5><%= t('.title') %></h5>
3
+ </header>
4
+
5
+ <div class="messages">
6
+ <% flash.each do |key, value| %>
7
+ <% next if %w(timedout).include? key.to_s %>
8
+ <%= foundation_alert_box key, value %>
9
+ <% end %>
10
+ </div>
@@ -0,0 +1,17 @@
1
+ <div class="fixed">
2
+ <nav class="top-bar" data-topbar role="navigation">
3
+ <ul class="title-area">
4
+ <li class="name">
5
+ <h1><%= link_to t('.site_title'), main_app.root_url %></h1>
6
+ </li>
7
+ <li class="toggle-topbar menu-icon">
8
+ <a href="#"><span><%= t('.menu') %></span></a>
9
+ </li>
10
+ </ul>
11
+
12
+ <section class="top-bar-section">
13
+ <%= render 'application/foundation/main_navigation' %>
14
+ <%= render 'application/foundation/user_navigation' %>
15
+ </section>
16
+ </nav>
17
+ </div>
@@ -0,0 +1,5 @@
1
+ <div>
2
+ <h5 class="hide"><%= t('.title') %></h5>
3
+ <%= foundation_ul_tag class: 'left' do |li|
4
+ end %>
5
+ </div>
@@ -0,0 +1,9 @@
1
+ <%= will_paginate(collection, {
2
+ renderer: Golden::Theme::Foundation::LinkRenderer,
3
+ inner_window: 2,
4
+ outer_window: 0,
5
+ class: 'pagination',
6
+ previous_label: t('.previous_label'),
7
+ next_label: t('.next_label'),
8
+ params: params || {}
9
+ }) %>
@@ -0,0 +1,19 @@
1
+ <div id="user-identity">
2
+ <h5 class="hide"><%= t('.title') %></h5>
3
+ <%= foundation_ul_tag class: 'right' do |li|
4
+ if signed_in?
5
+ li << [
6
+ foundation_top_bar_dropdown_link_to(current_user.name),
7
+ foundation_top_bar_dropdown_ul_tag do |li2|
8
+ li2 << link_to_edit_user_profile
9
+ li2 << ['', class: 'divider']
10
+ li2 << link_to_user_sign_out
11
+ end,
12
+ { class: 'has-dropdown' }
13
+ ]
14
+ else
15
+ li << link_to_user_sign_up
16
+ li << link_to_user_sign_in
17
+ end
18
+ end %>
19
+ </div>
@@ -17,3 +17,19 @@ en:
17
17
  pagination:
18
18
  previous_label: '&larr;'
19
19
  next_label: '&rarr;'
20
+ foundation:
21
+ header:
22
+ nav_toggle: 'Toggle navigation'
23
+ site_title: 'GoldenTheme'
24
+ menu: 'Menu'
25
+ main_navigation:
26
+ title: 'Main navigation'
27
+ user_navigation:
28
+ title: 'User navigation'
29
+ sign_up: 'Sign Up'
30
+ sign_in: 'Sign In'
31
+ sign_out: 'Sign Out'
32
+ edit_profile: 'Edit Profile'
33
+ pagination:
34
+ previous_label: '&larr;'
35
+ next_label: '&rarr;'
@@ -17,3 +17,19 @@ zh-TW:
17
17
  pagination:
18
18
  previous_label: '&larr;'
19
19
  next_label: '&rarr;'
20
+ foundation:
21
+ header:
22
+ nav_toggle: '切換導覽列'
23
+ site_title: 'GoldenTheme'
24
+ menu: '選單'
25
+ main_navigation:
26
+ title: '網站導覽'
27
+ user_navigation:
28
+ title: '用戶導覽'
29
+ sign_up: '註冊'
30
+ sign_in: '登入'
31
+ sign_out: '登出'
32
+ edit_profile: '編輯個人資料'
33
+ pagination:
34
+ previous_label: '&larr;'
35
+ next_label: '&rarr;'
data/golden-theme.gemspec CHANGED
@@ -22,9 +22,14 @@ Gem::Specification.new do |spec|
22
22
  spec.add_development_dependency 'rake'
23
23
 
24
24
  spec.add_dependency 'sass-rails'
25
- spec.add_dependency 'bootstrap-sass'
26
25
  spec.add_dependency 'compass-rails'
27
26
 
27
+ spec.add_dependency 'bootstrap-sass'
28
+ spec.add_dependency 'autoprefixer-rails'
29
+
30
+ spec.add_dependency 'foundation-rails'
31
+ spec.add_dependency 'foundation-icons-sass-rails'
32
+
28
33
  spec.add_dependency 'coffee-rails'
29
34
  spec.add_dependency 'jquery-rails'
30
35
  spec.add_dependency 'jquery-ui-rails'
data/lib/golden/theme.rb CHANGED
@@ -1,6 +1,10 @@
1
1
  require 'golden/theme/version'
2
2
 
3
3
  require 'bootstrap-sass'
4
+
5
+ require 'foundation-rails'
6
+ require 'foundation-icons-sass-rails'
7
+
4
8
  require 'compass-rails'
5
9
  require 'jquery-ui-rails'
6
10
  require 'chosen-rails'
@@ -12,5 +16,8 @@ module Golden
12
16
  end
13
17
  end
14
18
 
19
+ require 'golden/theme/helpers'
15
20
  require 'golden/theme/engine'
21
+
16
22
  require 'golden/theme/bootstrap/link_renderer'
23
+ require 'golden/theme/foundation/link_renderer'
@@ -0,0 +1,25 @@
1
+ module Golden::Theme::Bootstrap
2
+ module AlertHelper
3
+ def bootstrap_alert_box key, value
4
+ alert_class = 'alert alert-dismissable'
5
+ alert_class << case key.to_sym
6
+ when :notice, :alert
7
+ " alert-warning #{key}"
8
+ when :error
9
+ " alert-danger #{key}"
10
+ else
11
+ " alert-#{key} #{key}"
12
+ end
13
+ button_options = {
14
+ type: 'button',
15
+ name: nil,
16
+ class: 'close',
17
+ data: { dismiss: 'alert' }
18
+ }
19
+ content_tag :div, class: alert_class do
20
+ concat button_tag('&times;'.html_safe, button_options)
21
+ concat value
22
+ end
23
+ end
24
+ end
25
+ end