Commit 59fb0d69cb6bed0488537bb2710a20823d795355

Authored by Stephen Crosby
1 parent 6cf43dc5
Exists in master and in 1 other branch production

new image icon interface

Gemfile.lock
1 1 GIT
2 2 remote: git://github.com/errbit/errbit_github_plugin.git
3   - revision: 7eb48d540b94d2fa4b8f9805ec0148322ae2bffe
  3 + revision: 3597f2d2c6aa75e014251747a30eeb5d19f641dd
4 4 specs:
5 5 errbit_github_plugin (0.1.0)
6 6 errbit_plugin
... ... @@ -8,7 +8,7 @@ GIT
8 8  
9 9 GIT
10 10 remote: git://github.com/errbit/errbit_plugin.git
11   - revision: 6a0b93d71a6b4545198f0c68b99b8e8f9281c17e
  11 + revision: 9cfe43119be46bfa36cbf4b940b80d39229595ef
12 12 specs:
13 13 errbit_plugin (0.4.0)
14 14  
... ...
app/assets/javascripts/form.js
... ... @@ -82,11 +82,17 @@ function activateTypeSelector(field_class, section_class) {
82 82 .attr('disabled','disabled').val('');
83 83  
84 84 $('div.'+field_class).find('.choose input[name*=type]').on('click', function(){
  85 + var input = $(this);
85 86 // Look for section in 'data-section', and fall back to 'value'
86   - var chosen = $(this).data("section") || $(this).val();
87   - var wrapper = $(this).closest('.nested');
  87 + var chosen = input.data("section") || input.val();
  88 + var wrapper = input.closest('.nested');
  89 + var allLabels = wrapper.find('.label_radio');
  90 +
88 91 wrapper.find('div.chosen.'+section_class).removeClass('chosen').find('input').attr('disabled','disabled');
89 92 wrapper.find('div.'+section_class+'.'+chosen).addClass('chosen').find('input').removeAttr('disabled');
  93 +
  94 + wrapper.find('.icon').each(function(){ $(this).attr('src', $(this).data('iconInactive')) });
  95 + input.siblings('.icon').each(function(){ $(this).attr('src', $(this).data('iconCreate')) });
90 96 });
91 97 }
92 98  
... ...
app/assets/stylesheets/application.css.erb
... ... @@ -2,12 +2,6 @@
2 2 *= require reset
3 3 *= require jquery.alerts
4 4 *= require errbit
5   - *= require issue_tracker_icons
6 5 *= require notification_service_icons
7 6 *= require_self
8 7 */
9   -
10   -// Allow any gems named 'errbit_*' to require their own assets
11   -<% Gem.loaded_specs.keys.grep(/^errbit_/).each do |plugin|
12   - require_asset(plugin) rescue Sprockets::FileNotFound
13   -end %>
... ...
app/assets/stylesheets/errbit.css.erb
... ... @@ -552,31 +552,55 @@ div.nested .choose {
552 552 margin-bottom: 0.5em;
553 553 }
554 554  
555   -div.issue_tracker.nested .choose, div.notification_service.nested .choose {
  555 +div.issue_tracker.nested .choose {
556 556 background-color: #ebebeb;
557 557 border: 1px solid #dddddd;
558 558 margin: 0 0 15px;
559 559 padding: 12px;
560 560 }
561   -div.issue_tracker.nested img, div.notification_service.nested img {
  561 +
  562 +div.notification_service.nested .choose {
  563 + background-color: #ebebeb;
  564 + border: 1px solid #dddddd;
  565 + margin: 0 0 15px;
  566 + padding: 12px;
  567 +
  568 +}
  569 +div.issue_tracker.nested img {
  570 + vertical-align: middle;
  571 +}
  572 +
  573 +div.notification_service.nested img {
562 574 vertical-align: middle;
563 575 }
564 576  
565 577 /* Icons for Issue Tracker Radio Buttons */
566   -div.issue_tracker.nested label.label_radio, div.notification_service.nested label.label_radio {
  578 +div.issue_tracker.nested label.label_radio {
  579 + color: #929292;
  580 + margin-right: 8px;
  581 +}
  582 +
  583 +div.notification_service.nested label.label_radio {
567 584 color: #929292;
568 585 padding-left: 33px;
569 586 margin-bottom: 6px;
570 587 margin-right: 8px;
571 588 line-height: 30px;
572 589 }
573   -div.issue_tracker.nested .choose, div.notification_service.nested .choose {
  590 +
  591 +div.notification_service.nested .choose {
574 592 padding-bottom: 6px;
575 593 }
  594 +
576 595 div.issue_tracker.nested label.label_radio:hover, div.notification_service.nested label.label_radio:hover {
577 596 color: #696969;
578 597 }
579   -div.issue_tracker.nested .label_radio input, div.notification_service.nested .label_radio input {
  598 +
  599 +div.issue_tracker.nested .label_radio input {
  600 + display: none;
  601 +}
  602 +
  603 +div.notification_service.nested .label_radio input {
580 604 position: absolute; left: -9999px;
581 605 }
582 606  
... ...
app/assets/stylesheets/issue_tracker_icons.css.erb
... ... @@ -1,9 +0,0 @@
1   -/* Issue Tracker inactive, select, create and goto icons */
2   -
3   -<% ErrbitPlugin::Registry.issue_trackers.keys.each do |label| %>
4   -div.issue_tracker.nested label.<%= label %> { background: url(<%= asset_path "#{ label }_inactive.png" %>) no-repeat; }
5   -div.issue_tracker.nested label.r_on.<%= label %> { background: url(<%= asset_path "#{ label }_create.png" %>) no-repeat; }
6   -#action-bar a.<%= label %>_create { background: transparent url(<%= asset_path "#{ label }_create.png" %>) 6px 5px no-repeat; }
7   -#action-bar a.<%= label %>_goto { background: transparent url(<%= asset_path "#{ label }_goto.png" %>) 6px 5px no-repeat; }
8   -<% end %>
9   -
app/decorators/issue_tracker_decorator.rb
... ... @@ -14,6 +14,15 @@ class IssueTrackerDecorator &lt; Draper::Decorator
14 14 end
15 15 end
16 16  
  17 + def icons
  18 + tracker_icons = object.icons
  19 + return unless tracker_icons
  20 +
  21 + tracker_icons.reduce({}) do |c, (k,v)|
  22 + c[k] = "data:#{v[0]};base64,#{Base64.encode64(v[1])}"; c
  23 + end
  24 + end
  25 +
17 26 def note
18 27 object.note.html_safe
19 28 end
... ...
app/helpers/application_helper.rb
... ... @@ -79,4 +79,3 @@ module ApplicationHelper
79 79 end
80 80  
81 81 end
82   -
... ...
app/models/issue_tracker.rb
... ... @@ -18,6 +18,10 @@ class IssueTracker
18 18 end
19 19 end
20 20  
  21 + def type_tracker
  22 + self.attributes['type_tracker'] ? self.attributes['type_tracker'] : 'none'
  23 + end
  24 +
21 25 # Allow the tracker to validate its own params
22 26 def validate_tracker
23 27 (tracker.errors || {}).each do |k,v|
... ...
app/views/apps/_issue_tracker_fields.html.haml
... ... @@ -5,6 +5,7 @@
5 5 %div.choose
6 6 - issue_tracker_form.object.issue_trackers do |tracker|
7 7 = issue_tracker_form.label :type_tracker, :class => "label_radio #{tracker.label}", :value => tracker.key do
  8 + %img.icon{"src" => tracker.icons[:inactive], "data-icon" => tracker.icons}
8 9 = issue_tracker_form.radio_button :type_tracker, tracker.key, 'data-section' => tracker.label
9 10 = tracker.label
10 11  
... ... @@ -15,9 +16,3 @@
15 16 - tracker.fields do |field|
16 17 = options_form.label field.key, field.label
17 18 = field.input(options_form, issue_tracker_form.object)
18   -
19   - .image_preloader
20   - - issue_tracker_form.object.issue_trackers do |tracker|
21   - = image_tag "#{tracker.label}_inactive.png"
22   - = image_tag "#{tracker.label}_create.png"
23   -
... ...
config/initializers/assets.rb
... ... @@ -6,6 +6,3 @@ Rails.application.config.assets.version = &#39;1.0&#39;
6 6 # Precompile additional assets.
7 7 # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
8 8 # Rails.application.config.assets.precompile += %w( search.js )
9   -
10   -# Need to initialize Rails environment for issue_tracker_icons.css.erb
11   -Rails.application.config.assets.initialize_on_precompile = true
... ...