Commit de99def3cb85728a9d07654efa1afcce6e25c6dc
Exists in
master
and in
10 other branches
Merge branch 'master' of https://gitlab.com/participa/proposal-app
Showing
3 changed files
with
78 additions
and
22 deletions
Show diff stats
index.html
| @@ -82,6 +82,10 @@ | @@ -82,6 +82,10 @@ | ||
| 82 | {{#each categories}} | 82 | {{#each categories}} |
| 83 | <li class='category proposal-category' data-category="{{slug}}"> | 83 | <li class='category proposal-category' data-category="{{slug}}"> |
| 84 | <a href="#/temas/{{slug}}/{{id}}" class="proposal-link" data-target="proposal-item-{{id}}">{{name}}</a> | 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-reply"></span> | ||
| 88 | + </button> | ||
| 85 | {{#select_proposal ../../article.children slug ../id}}{{/select_proposal}} | 89 | {{#select_proposal ../../article.children slug ../id}}{{/select_proposal}} |
| 86 | </li> | 90 | </li> |
| 87 | {{/each}} | 91 | {{/each}} |
js/main.js
| @@ -48,11 +48,8 @@ $.getJSON(noosferoAPI) | @@ -48,11 +48,8 @@ $.getJSON(noosferoAPI) | ||
| 48 | 48 | ||
| 49 | var $link = $(this); | 49 | var $link = $(this); |
| 50 | 50 | ||
| 51 | - // Update URL | 51 | + // Update URL and Navigate |
| 52 | updateHash($link.attr('href')); | 52 | updateHash($link.attr('href')); |
| 53 | - | ||
| 54 | - // Display the Category tab | ||
| 55 | - display_category_tab(); | ||
| 56 | }); | 53 | }); |
| 57 | 54 | ||
| 58 | $( '#nav-proposal-group a' ).click(function(event){ | 55 | $( '#nav-proposal-group a' ).click(function(event){ |
| @@ -60,21 +57,16 @@ $.getJSON(noosferoAPI) | @@ -60,21 +57,16 @@ $.getJSON(noosferoAPI) | ||
| 60 | 57 | ||
| 61 | var $link = $(this); | 58 | var $link = $(this); |
| 62 | 59 | ||
| 63 | - // Update URL | 60 | + // Update URL and Navigate |
| 64 | updateHash($link.attr('href')); | 61 | updateHash($link.attr('href')); |
| 65 | - | ||
| 66 | - //Display the Proposals tab | ||
| 67 | - display_proposals_tab(); | ||
| 68 | }); | 62 | }); |
| 69 | 63 | ||
| 70 | $( '.proposal-item a' ).click(function(event){ | 64 | $( '.proposal-item a' ).click(function(event){ |
| 71 | var $link = $(this); | 65 | var $link = $(this); |
| 72 | var item = $link.data('target'); | 66 | var item = $link.data('target'); |
| 73 | 67 | ||
| 74 | - // Update URL | 68 | + // Update URL and Navigate |
| 75 | updateHash($link.attr('href')); | 69 | updateHash($link.attr('href')); |
| 76 | - | ||
| 77 | - display_proposal(item); | ||
| 78 | }); | 70 | }); |
| 79 | 71 | ||
| 80 | $( '.proposal-category a' ).click(function(event){ | 72 | $( '.proposal-category a' ).click(function(event){ |
| @@ -83,30 +75,38 @@ $.getJSON(noosferoAPI) | @@ -83,30 +75,38 @@ $.getJSON(noosferoAPI) | ||
| 83 | var $link = $(this); | 75 | var $link = $(this); |
| 84 | var item = $link.data('target'); | 76 | var item = $link.data('target'); |
| 85 | 77 | ||
| 86 | - // Update URL | 78 | + // Update URL and Navigate |
| 87 | updateHash($link.attr('href')); | 79 | updateHash($link.attr('href')); |
| 80 | + }); | ||
| 81 | + | ||
| 82 | + $( '.proposal-category .go-back' ).click(function(event){ | ||
| 83 | + event.preventDefault(); | ||
| 88 | 84 | ||
| 89 | - display_proposal_by_category(item); | 85 | + // Update URL and Navigate |
| 86 | + updateHash('#/temas'); | ||
| 90 | }); | 87 | }); |
| 91 | 88 | ||
| 92 | $( '.send-button a' ).click(function(event){ | 89 | $( '.send-button a' ).click(function(event){ |
| 93 | //display form to send proposal (or login form for non-logged users) | 90 | //display form to send proposal (or login form for non-logged users) |
| 94 | - loginButton = $(this).parents('.send-button'); | 91 | + var $this = $(this); |
| 92 | + loginButton = $this.parents('.send-button'); | ||
| 95 | loginButton.hide(); | 93 | loginButton.hide(); |
| 96 | - $('.success-proposal-sent').hide(); | 94 | + $this.parents('.success-proposal-sent').hide(); |
| 97 | loginCallback(logged_in); | 95 | loginCallback(logged_in); |
| 98 | event.preventDefault(); | 96 | event.preventDefault(); |
| 99 | }); | 97 | }); |
| 98 | + | ||
| 100 | $( '#display-contrast' ).click(function(event){ | 99 | $( '#display-contrast' ).click(function(event){ |
| 101 | $('#proposal-result').toggleClass('contrast'); | 100 | $('#proposal-result').toggleClass('contrast'); |
| 102 | }); | 101 | }); |
| 102 | + | ||
| 103 | $( '.show_body a' ).click(function(event){ | 103 | $( '.show_body a' ).click(function(event){ |
| 104 | event.preventDefault(); | 104 | event.preventDefault(); |
| 105 | 105 | ||
| 106 | var $link = $(this); | 106 | var $link = $(this); |
| 107 | var item = $link.data('target'); | 107 | var item = $link.data('target'); |
| 108 | 108 | ||
| 109 | - // Update URL | 109 | + // Update URL and Navigate |
| 110 | updateHash($link.attr('href')); | 110 | updateHash($link.attr('href')); |
| 111 | }); | 111 | }); |
| 112 | 112 | ||
| @@ -116,7 +116,7 @@ $.getJSON(noosferoAPI) | @@ -116,7 +116,7 @@ $.getJSON(noosferoAPI) | ||
| 116 | var $link = $(this); | 116 | var $link = $(this); |
| 117 | var item = $link.data('target'); | 117 | var item = $link.data('target'); |
| 118 | 118 | ||
| 119 | - // Update URL | 119 | + // Update URL and Navigate |
| 120 | updateHash($link.attr('href')); | 120 | updateHash($link.attr('href')); |
| 121 | }); | 121 | }); |
| 122 | 122 | ||
| @@ -289,6 +289,9 @@ function display_category_tab(){ | @@ -289,6 +289,9 @@ function display_category_tab(){ | ||
| 289 | $('.proposal-category-items').hide(); | 289 | $('.proposal-category-items').hide(); |
| 290 | $('.proposal-category .arrow-box').hide(); | 290 | $('.proposal-category .arrow-box').hide(); |
| 291 | $('.proposal-detail').hide(); | 291 | $('.proposal-detail').hide(); |
| 292 | + | ||
| 293 | + $('#content').show(); | ||
| 294 | + $('nav').show(); | ||
| 292 | } | 295 | } |
| 293 | 296 | ||
| 294 | function display_proposals_tab(){ | 297 | function display_proposals_tab(){ |
| @@ -297,6 +300,9 @@ function display_proposals_tab(){ | @@ -297,6 +300,9 @@ function display_proposals_tab(){ | ||
| 297 | $('#nav-proposal-group a').addClass('active'); | 300 | $('#nav-proposal-group a').addClass('active'); |
| 298 | $('#nav-proposal-categories a').removeClass('active'); | 301 | $('#nav-proposal-categories a').removeClass('active'); |
| 299 | $(".proposal-item p").dotdotdot(); | 302 | $(".proposal-item p").dotdotdot(); |
| 303 | + | ||
| 304 | + $('#content').show(); | ||
| 305 | + $('nav').show(); | ||
| 300 | } | 306 | } |
| 301 | 307 | ||
| 302 | function display_proposal(proposal_id){ | 308 | function display_proposal(proposal_id){ |
| @@ -346,6 +352,8 @@ function display_proposal_by_category(item){ | @@ -346,6 +352,8 @@ function display_proposal_by_category(item){ | ||
| 346 | $('nav').show(); | 352 | $('nav').show(); |
| 347 | $('#content').show(); | 353 | $('#content').show(); |
| 348 | $('#proposal-categories').show(); | 354 | $('#proposal-categories').show(); |
| 355 | + $('#nav-proposal-categories a').addClass('active'); | ||
| 356 | + $('#nav-proposal-group a').removeClass('active'); | ||
| 349 | $('.proposal-category-items').hide(); | 357 | $('.proposal-category-items').hide(); |
| 350 | $('.proposal-detail').hide(); | 358 | $('.proposal-detail').hide(); |
| 351 | $item.show(); | 359 | $item.show(); |
| @@ -378,18 +386,33 @@ function locationHashChanged(){ | @@ -378,18 +386,33 @@ function locationHashChanged(){ | ||
| 378 | function navigateTo(hash){ | 386 | function navigateTo(hash){ |
| 379 | var regexProposals = /#\/programas/; | 387 | var regexProposals = /#\/programas/; |
| 380 | var regexCategory = /#\/temas/; | 388 | var regexCategory = /#\/temas/; |
| 381 | - var m; | ||
| 382 | var parts = hash.split('/'); | 389 | var parts = hash.split('/'); |
| 383 | 390 | ||
| 384 | - if( (m = regexProposals.exec(hash)) !== null ){ | 391 | + var isProposal = regexProposals.exec(hash) !== null; |
| 392 | + var isCategory = regexCategory.exec(hash) !== null; | ||
| 393 | + | ||
| 394 | + if( isProposal ){ | ||
| 395 | + | ||
| 396 | + // go to proposal | ||
| 385 | var proposalId = parts[2]; | 397 | var proposalId = parts[2]; |
| 386 | navigateToProposal(proposalId); | 398 | navigateToProposal(proposalId); |
| 387 | - } else if( (m = regexCategory.exec(hash)) !== null ){ | 399 | + |
| 400 | + return; | ||
| 401 | + } | ||
| 402 | + | ||
| 403 | + if( isCategory ){ | ||
| 404 | + | ||
| 405 | + // go to category | ||
| 388 | var categoryId = parts[3]; | 406 | var categoryId = parts[3]; |
| 389 | navigateToCategory(categoryId); | 407 | navigateToCategory(categoryId); |
| 390 | - } else { | ||
| 391 | - console.log('route not handled', hash); | 408 | + |
| 409 | + return; | ||
| 392 | } | 410 | } |
| 411 | + | ||
| 412 | + // default | ||
| 413 | + // show the 'index' -> category tab | ||
| 414 | + display_category_tab(); | ||
| 415 | + console.log('route not handled', hash); | ||
| 393 | } | 416 | } |
| 394 | 417 | ||
| 395 | function navigateToProposal(proposalId){ | 418 | function navigateToProposal(proposalId){ |
sass/style.scss
| @@ -99,3 +99,32 @@ form { | @@ -99,3 +99,32 @@ form { | ||
| 99 | margin-top: 10px; | 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 | \ No newline at end of file | 131 | \ No newline at end of file |