Commit 9a4816248107e1265b28c38eab0ef2c28afb2051

Authored by Leonardo Merlin
1 parent de00eeb8

Fix #28: Add botao voltar.

Showing 3 changed files with 66 additions and 5 deletions   Show diff stats
index.html
... ... @@ -82,6 +82,10 @@
82 82 {{#each categories}}
83 83 <li class='category proposal-category' data-category="{{slug}}">
84 84 <a href="#/temas/{{slug}}/{{id}}" class="proposal-link" data-target="proposal-item-{{id}}">{{name}}</a>
  85 + <button class="go-back btn btn-default pull-right">
  86 + VOLTAR
  87 + <span class="fa fa-arrow-circle-left"></span>
  88 + </button>
85 89 {{#select_proposal ../../article.children slug ../id}}{{/select_proposal}}
86 90 </li>
87 91 {{/each}}
... ...
js/main.js
... ... @@ -79,6 +79,13 @@ $.getJSON(noosferoAPI)
79 79 updateHash($link.attr('href'));
80 80 });
81 81  
  82 + $( '.proposal-category .go-back' ).click(function(event){
  83 + event.preventDefault();
  84 +
  85 + // Update URL and Navigate
  86 + updateHash('#/temas');
  87 + });
  88 +
82 89 $( '.send-button a' ).click(function(event){
83 90 //display form to send proposal (or login form for non-logged users)
84 91 loginButton = $(this).parents('.send-button');
... ... @@ -279,6 +286,9 @@ function display_category_tab(){
279 286 $('.proposal-category-items').hide();
280 287 $('.proposal-category .arrow-box').hide();
281 288 $('.proposal-detail').hide();
  289 +
  290 + $('#content').show();
  291 + $('nav').show();
282 292 }
283 293  
284 294 function display_proposals_tab(){
... ... @@ -287,6 +297,9 @@ function display_proposals_tab(){
287 297 $('#nav-proposal-group a').addClass('active');
288 298 $('#nav-proposal-categories a').removeClass('active');
289 299 $(".proposal-item p").dotdotdot();
  300 +
  301 + $('#content').show();
  302 + $('nav').show();
290 303 }
291 304  
292 305 function display_proposal(proposal_id){
... ... @@ -368,18 +381,33 @@ function locationHashChanged(){
368 381 function navigateTo(hash){
369 382 var regexProposals = /#\/programas/;
370 383 var regexCategory = /#\/temas/;
371   - var m;
372 384 var parts = hash.split('/');
373 385  
374   - if( (m = regexProposals.exec(hash)) !== null ){
  386 + var isProposal = regexProposals.exec(hash) !== null;
  387 + var isCategory = regexCategory.exec(hash) !== null;
  388 +
  389 + if( isProposal ){
  390 +
  391 + // go to proposal
375 392 var proposalId = parts[2];
376 393 navigateToProposal(proposalId);
377   - } else if( (m = regexCategory.exec(hash)) !== null ){
  394 +
  395 + return;
  396 + }
  397 +
  398 + if( isCategory ){
  399 +
  400 + // go to category
378 401 var categoryId = parts[3];
379 402 navigateToCategory(categoryId);
380   - } else {
381   - console.log('route not handled', hash);
  403 +
  404 + return;
382 405 }
  406 +
  407 + // default
  408 + // show the 'index' -> category tab
  409 + display_category_tab();
  410 + console.log('route not handled', hash);
383 411 }
384 412  
385 413 function navigateToProposal(proposalId){
... ...
sass/style.scss
... ... @@ -99,3 +99,32 @@ form {
99 99 margin-top: 10px;
100 100 }
101 101 }
  102 +
  103 +// @TO_ADD: Leonardo
  104 +.btn {
  105 + display: inline-block;
  106 + padding: 6px 12px;
  107 + margin-bottom: 0;
  108 + font-size: 14px;
  109 + font-weight: 400;
  110 + line-height: 3.1;
  111 + text-align: center;
  112 + white-space: nowrap;
  113 + vertical-align: middle;
  114 + -ms-touch-action: manipulation;
  115 + touch-action: manipulation;
  116 + cursor: pointer;
  117 + -webkit-user-select: none;
  118 + -moz-user-select: none;
  119 + -ms-user-select: none;
  120 + user-select: none;
  121 + background-image: none;
  122 + border: 1px solid transparent;
  123 + /* border-radius: 4px; */
  124 +}
  125 +
  126 +.btn-default {
  127 + color: #333;
  128 + background-color: #fff;
  129 + border-color: #ccc;
  130 +}
102 131 \ No newline at end of file
... ...