Commit b14ea06132f1d3046300ba7b93e144c53ca65e6b
1 parent
a8618196
Exists in
master
Add pairwise group content
Showing
6 changed files
with
142 additions
and
42 deletions
Show diff stats
controllers/profile/pairwise_plugin_profile_controller.rb
| @@ -14,6 +14,11 @@ class PairwisePluginProfileController < ProfileController | @@ -14,6 +14,11 @@ class PairwisePluginProfileController < ProfileController | ||
| 14 | end | 14 | end |
| 15 | end | 15 | end |
| 16 | 16 | ||
| 17 | + def group | ||
| 18 | + pairwise_group ||= profile.articles.find(params[:id]) | ||
| 19 | + instance_exec(&pairwise_group.to_html('embeded' => true)) | ||
| 20 | + end | ||
| 21 | + | ||
| 17 | #FIXME reuse | 22 | #FIXME reuse |
| 18 | def load_prompt | 23 | def load_prompt |
| 19 | @pairwise_content = find_content(params) | 24 | @pairwise_content = find_content(params) |
lib/pairwise_plugin.rb
| @@ -19,7 +19,7 @@ class PairwisePlugin < Noosfero::Plugin | @@ -19,7 +19,7 @@ class PairwisePlugin < Noosfero::Plugin | ||
| 19 | end | 19 | end |
| 20 | 20 | ||
| 21 | def content_types | 21 | def content_types |
| 22 | - [PairwisePlugin::PairwiseContent] | 22 | + [PairwisePlugin::PairwiseContent, PairwisePlugin::PairwiseGroup] |
| 23 | # if context.profile.is_a?(Community) | 23 | # if context.profile.is_a?(Community) |
| 24 | # else | 24 | # else |
| 25 | # [] | 25 | # [] |
| @@ -0,0 +1,20 @@ | @@ -0,0 +1,20 @@ | ||
| 1 | +class PairwisePlugin::PairwiseGroup < Folder | ||
| 2 | + | ||
| 3 | + def self.short_description | ||
| 4 | + 'Pairwise Group' | ||
| 5 | + end | ||
| 6 | + | ||
| 7 | + def self.description | ||
| 8 | + 'Group of Pairwise Questions' | ||
| 9 | + end | ||
| 10 | + | ||
| 11 | + def to_html(options = {}) | ||
| 12 | + embeded = options.has_key? "embeded" | ||
| 13 | + pairwise_group = self | ||
| 14 | + proc do | ||
| 15 | + layout = embeded ? 'embeded' : nil | ||
| 16 | + render :file => 'content_viewer/pairwise_group', :layout => layout, :locals => {:pairwise_group => pairwise_group, :embeded => embeded, :questions => pairwise_group.children} | ||
| 17 | + end | ||
| 18 | + end | ||
| 19 | + | ||
| 20 | +end |
public/style.css
| @@ -432,47 +432,6 @@ div.pairwise_group_list_container .row { | @@ -432,47 +432,6 @@ div.pairwise_group_list_container .row { | ||
| 432 | cursor: auto; | 432 | cursor: auto; |
| 433 | } | 433 | } |
| 434 | 434 | ||
| 435 | -div.pairwise_group_menu_container .row { | ||
| 436 | - cursor: auto; | ||
| 437 | - font-weight: bold; | ||
| 438 | -} | ||
| 439 | -div.pairwise_group_menu_container .row.secondary { | ||
| 440 | - font-weight: normal; | ||
| 441 | -} | ||
| 442 | -div.pairwise_group_menu_container .questions-menu .menu-icon { | ||
| 443 | - float: right; | ||
| 444 | - font-size: 16px; | ||
| 445 | -} | ||
| 446 | -div.pairwise_group_menu_container .questions-menu .icon-label { | ||
| 447 | - float: right; | ||
| 448 | -} | ||
| 449 | -div.pairwise_group_menu_container .questions-menu .icon-bar { | ||
| 450 | - background-color: rgb(100, 100, 100); | ||
| 451 | - display: block; | ||
| 452 | - width: 1.125em; | ||
| 453 | - height: 0.125em; | ||
| 454 | - border-radius: 1px; | ||
| 455 | - box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); | ||
| 456 | - margin: 3px; | ||
| 457 | -} | ||
| 458 | -div.pairwise_group_menu_container .questions-menu .menu { | ||
| 459 | - position: absolute; | ||
| 460 | - background-color: rgb(247, 247, 247); | ||
| 461 | - width: 96%; | ||
| 462 | - z-index: 999; | ||
| 463 | - padding: 10px; | ||
| 464 | - top: 17px; | ||
| 465 | - box-shadow: -5px 7px 10px #888888; | ||
| 466 | -} | ||
| 467 | -div.pairwise_group_menu_container .questions-menu .menu .item { | ||
| 468 | - cursor: pointer; | ||
| 469 | - color: rgb(107, 107, 107); | ||
| 470 | -} | ||
| 471 | -div.pairwise_group_menu_container .questions-menu .menu .label { | ||
| 472 | - color: rgb(175, 175, 175); | ||
| 473 | - margin-bottom: 10px; | ||
| 474 | -} | ||
| 475 | - | ||
| 476 | div.pairwise_group_list_container .row p { | 435 | div.pairwise_group_list_container .row p { |
| 477 | line-height: 30px; | 436 | line-height: 30px; |
| 478 | margin: auto; | 437 | margin: auto; |
| @@ -555,3 +514,45 @@ div.pairwise_main .spinner h5{ | @@ -555,3 +514,45 @@ div.pairwise_main .spinner h5{ | ||
| 555 | float: right; | 514 | float: right; |
| 556 | color: #999; | 515 | color: #999; |
| 557 | } | 516 | } |
| 517 | + | ||
| 518 | +div.pairwise_group_menu_container .row { | ||
| 519 | + cursor: auto; | ||
| 520 | + font-weight: bold; | ||
| 521 | +} | ||
| 522 | +div.pairwise_group_menu_container .row.secondary { | ||
| 523 | + font-weight: normal; | ||
| 524 | +} | ||
| 525 | +div.pairwise_group_menu_container .questions-menu .menu-icon { | ||
| 526 | + float: right; | ||
| 527 | + font-size: 16px; | ||
| 528 | +} | ||
| 529 | +div.pairwise_group_menu_container .questions-menu .icon-label { | ||
| 530 | + float: right; | ||
| 531 | +} | ||
| 532 | +div.pairwise_group_menu_container .questions-menu .icon-bar { | ||
| 533 | + background-color: rgb(100, 100, 100); | ||
| 534 | + display: block; | ||
| 535 | + width: 1.125em; | ||
| 536 | + height: 0.125em; | ||
| 537 | + border-radius: 1px; | ||
| 538 | + box-shadow: 0 1px 0 rgba(0, 0, 0, 0.25); | ||
| 539 | + margin: 3px; | ||
| 540 | +} | ||
| 541 | +div.pairwise_group_menu_container .questions-menu .menu { | ||
| 542 | + position: absolute; | ||
| 543 | + background-color: rgb(247, 247, 247); | ||
| 544 | + width: 96%; | ||
| 545 | + z-index: 999; | ||
| 546 | + padding: 10px; | ||
| 547 | + top: 74px; | ||
| 548 | + box-shadow: -5px 7px 10px #888888; | ||
| 549 | +} | ||
| 550 | +div.pairwise_group_menu_container .questions-menu .menu .item { | ||
| 551 | + cursor: pointer; | ||
| 552 | + color: rgb(107, 107, 107); | ||
| 553 | +} | ||
| 554 | +div.pairwise_group_menu_container .questions-menu .menu .label { | ||
| 555 | + color: rgb(175, 175, 175); | ||
| 556 | + margin-bottom: 10px; | ||
| 557 | +} | ||
| 558 | + |
views/blocks/questions_group_menu.html.erb
| @@ -67,6 +67,13 @@ | @@ -67,6 +67,13 @@ | ||
| 67 | $('.pairwise_group_menu_container .questions-menu .items .row').click(function() { | 67 | $('.pairwise_group_menu_container .questions-menu .items .row').click(function() { |
| 68 | $('.pairwise_group_menu_container .questions-menu .menu').hide('fast'); | 68 | $('.pairwise_group_menu_container .questions-menu .menu').hide('fast'); |
| 69 | }); | 69 | }); |
| 70 | + | ||
| 71 | + function updatePairwiseMenuInfo() { | ||
| 72 | + var block_id = '#pairwise_group_list_block_<%= block.id %>'; | ||
| 73 | + $(block_id + ' .pairwise_body').text('<%= block.title %>'); | ||
| 74 | + $(block_id + ' .pairwise_body').after('<div class="description"><%= block.group_description %></div>'); | ||
| 75 | + } | ||
| 76 | + //updatePairwiseMenuInfo(); | ||
| 70 | }); | 77 | }); |
| 71 | 78 | ||
| 72 | // FIXME move to js file | 79 | // FIXME move to js file |
| @@ -0,0 +1,67 @@ | @@ -0,0 +1,67 @@ | ||
| 1 | +<% extend PairwisePlugin::Helpers::ViewerHelper %> | ||
| 2 | + | ||
| 3 | +<div id='pairwise_group_list_block_<%= pairwise_group.id %>' class="pairwise_group_menu_container" data-open-prompt="0"> | ||
| 4 | + <div class="questions-menu clearfix"> | ||
| 5 | + <span class="menu-icon"> | ||
| 6 | + <span class="icon-bar"></span> | ||
| 7 | + <span class="icon-bar"></span> | ||
| 8 | + <span class="icon-bar"></span> | ||
| 9 | + </span> | ||
| 10 | + <span class="icon-label"><%= _('Select theme') %></span> | ||
| 11 | + <% if questions.count > 1 %> | ||
| 12 | + <div class="menu" style="display: none"> | ||
| 13 | + <div class="label"> | ||
| 14 | + <%= _('Select a specific theme below to vote on proposals:') %> | ||
| 15 | + </div> | ||
| 16 | + <div class="items"> | ||
| 17 | + <% questions.each_with_index do |pairwise_content, index| %> | ||
| 18 | + <div class="item <%= pairwise_group_row_classes(index) %>"> | ||
| 19 | + <%= pairwise_content.name %> | ||
| 20 | + </div> | ||
| 21 | + <% end %> | ||
| 22 | + </div> | ||
| 23 | + </div> | ||
| 24 | + <% end %> | ||
| 25 | + </div> | ||
| 26 | + <div class="question container"> | ||
| 27 | + <% if questions.blank? %> | ||
| 28 | + <span><%= _("Empty") %></span> | ||
| 29 | + <% else %> | ||
| 30 | + <% questions.each_with_index do |pairwise_content, index| %> | ||
| 31 | + <%= pairwise_group_content_body(index, pairwise_content) %> | ||
| 32 | + <% end %> | ||
| 33 | + <% end %> | ||
| 34 | + </div> | ||
| 35 | +</div> | ||
| 36 | + | ||
| 37 | +<script type="text/javascript"> | ||
| 38 | + jQuery(document).ready(function($){ | ||
| 39 | + $('.pairwise_group_menu_container .questions-menu .menu-icon').click(function() { | ||
| 40 | + $(this).siblings('.menu').toggle(); | ||
| 41 | + }); | ||
| 42 | + $('.pairwise_group_menu_container .questions-menu .items .row').click(function() { | ||
| 43 | + $('.pairwise_group_menu_container .questions-menu .menu').hide('fast'); | ||
| 44 | + }); | ||
| 45 | + }); | ||
| 46 | + | ||
| 47 | +// FIXME move to js file | ||
| 48 | +jQuery(document).ready(function($){ | ||
| 49 | + var block_id = '#pairwise_group_list_block_<%= pairwise_group.id %>'; | ||
| 50 | + var block_element = $(block_id); | ||
| 51 | + var questions_arrows = $(block_id + ' .arrow'); | ||
| 52 | + var questions_rows = $(block_id + ' .row'); | ||
| 53 | + var questions_bodies = $(block_id + ' .pairwise_inner_body'); | ||
| 54 | + questions_rows.click(function(){ | ||
| 55 | + var current_open = parseInt(block_element.attr('data-open-prompt')); | ||
| 56 | + var index_clicked = questions_rows.index(this); | ||
| 57 | + if(index_clicked != current_open){ | ||
| 58 | + block_element.attr('data-open-prompt', index_clicked); | ||
| 59 | + $(questions_bodies[current_open]).slideToggle(); | ||
| 60 | + $(questions_rows[current_open]).toggleClass("secondary"); | ||
| 61 | + | ||
| 62 | + $(questions_bodies[index_clicked]).slideToggle(); | ||
| 63 | + $(questions_rows[index_clicked]).toggleClass("secondary"); | ||
| 64 | + } | ||
| 65 | + }); | ||
| 66 | +}); | ||
| 67 | +</script> |