Commit 25c199cd8ebddd2dfcd4735ba5700499b0a60cc7

Authored by Macieski
1 parent 6de45b4f
Exists in master

codigo favoritos

Showing 1 changed file with 36 additions and 32 deletions   Show diff stats
wscacicneo/templates/favoritos.pt
... ... @@ -12,11 +12,9 @@
12 12 <div class="widget-content">
13 13 <div class="padd">
14 14 <!-- Visitors, pageview, bounce rate, etc., Sparklines plugin used -->
15   - <ul tal:repeat="i itens" id='favoritos-off' class="current-status">
16   - <li>
17   - <label class="checkbox-inline">
18   - <a id="${i}">${i}</a>
19   - </label>
  15 + <ul id='itens' class="current-status">
  16 + <li tal:repeat="i itens">
  17 + <a id="${i}">${i}</a>
20 18 </li>
21 19 </ul>
22 20 </div>
... ... @@ -35,11 +33,9 @@
35 33 <div class="widget-content">
36 34 <div class="padd">
37 35 <!-- Visitors, pageview, bounce rate, etc., Sparklines plugin used -->
38   - <ul tal:repeat="doc favoritos" id="favoritos-on" class="current-status">
39   - <li>
40   - <label class="checkbox-inline">
41   - <a id="${doc}">${doc}</a>
42   - </label>
  36 + <ul id="favoritos" class="current-status">
  37 + <li tal:repeat="doc favoritos">
  38 + <a id="${doc}">${doc}</a>
43 39 </li>
44 40 </ul>
45 41 </div>
... ... @@ -51,34 +47,42 @@
51 47 </metal:content>
52 48 <metal:content fill-slot="javascript">
53 49 <script type="text/javascript">
54   - $('a').click(function(){
55   - value = $(this).html()
56   - label = $(this).parent()
57   - li = $(label).parent()
58   - ul = $(li).parent()
59   - id_ul = $(ul).attr('id')
60   - if(id_ul == 'favoritos-off'){
61   - matricula = $('#matricula').html()
62   - var data = {
63   - 'value': value,
64   - 'path': 'favoritos',
65   - 'matricula': $('#matricula').val()
66   - }
67   - $.ajax({
  50 + $('#itens li').on('click', function(){
  51 + index = $(this).index()
  52 + a = $(this).find('a')
  53 + value = $(a).html()
  54 + var data = {
  55 + 'value': value,
  56 + 'index': index,
  57 + 'path': 'favoritos',
  58 + 'matricula': $('#matricula').val()
  59 + }
  60 + $.ajax({
68 61 type: "PUT",
69 62 url: "${request.route_url('root')}edit_favoritos",
70 63 data: data,
71 64 success: function(){ location.reload(); },
72 65 error: function(){ alert('Não foi desta vez Tente novamente mais tarde') },
73   - });
74   - }
75   - else if(id_ul == 'favoritos-on'){
76   - alert(value)
77   - }
78   - else{
79   - return true
80   - }
  66 + });
81 67 });
  68 + $('#favoritos li').on('click', function(){
  69 + index = $(this).index()
  70 + a = $(this).find('a')
  71 + value = $(a).html()
  72 + var data = {
  73 + 'value': value,
  74 + 'index': index,
  75 + 'path': 'itens',
  76 + 'matricula': $('#matricula').val()
  77 + }
  78 + $.ajax({
  79 + type: "PUT",
  80 + url: "${request.route_url('root')}edit_favoritos",
  81 + data: data,
  82 + success: function(){ location.reload(); },
  83 + error: function(){ alert('Não foi desta vez Tente novamente mais tarde') },
  84 + });
  85 + });
82 86 </script>
83 87 </metal:content>
84 88 </metal:main>
... ...