Commit 99c98687680eb953cc35191dc9863444eb5d1adf
1 parent
acf8a3e0
Exists in
master
and in
7 other branches
favoritos na pagina principal
Showing
2 changed files
with
57 additions
and
6 deletions
Show diff stats
init/index.js
| @@ -169,6 +169,7 @@ botoesIni = [ | @@ -169,6 +169,7 @@ botoesIni = [ | ||
| 169 | "target": "_self" | 169 | "target": "_self" |
| 170 | } | 170 | } |
| 171 | ]; | 171 | ]; |
| 172 | +reordenaBotoesPorFavoritos(); | ||
| 172 | function mostraBotoes(){ | 173 | function mostraBotoes(){ |
| 173 | $i("mensagemLogin").innerHTML = men; | 174 | $i("mensagemLogin").innerHTML = men; |
| 174 | i3GEO.configura = {"locaplic" : ".."}; | 175 | i3GEO.configura = {"locaplic" : ".."}; |
| @@ -215,6 +216,7 @@ function mostraBotoesBT(men){ | @@ -215,6 +216,7 @@ function mostraBotoesBT(men){ | ||
| 215 | {"d":botoesIni,"abrir" : $trad(36,g_traducao_init)} | 216 | {"d":botoesIni,"abrir" : $trad(36,g_traducao_init)} |
| 216 | ); | 217 | ); |
| 217 | $("#botoesTpl").html(html); | 218 | $("#botoesTpl").html(html); |
| 219 | + aplicaFavoritos() | ||
| 218 | } | 220 | } |
| 219 | function findBootstrapDeviceSize() { | 221 | function findBootstrapDeviceSize() { |
| 220 | var dsize = ['lg', 'md', 'sm', 'xs']; | 222 | var dsize = ['lg', 'md', 'sm', 'xs']; |
| @@ -232,3 +234,49 @@ function findBootstrapDeviceSize() { | @@ -232,3 +234,49 @@ function findBootstrapDeviceSize() { | ||
| 232 | } | 234 | } |
| 233 | return 'unknown'; | 235 | return 'unknown'; |
| 234 | } | 236 | } |
| 237 | +//cookies sao armazenados em favoritosInit | ||
| 238 | +function favorita(obj){ | ||
| 239 | + $(obj).find("span").toggleClass("amarelo"); | ||
| 240 | + // | ||
| 241 | + //modifica os cookies | ||
| 242 | + // | ||
| 243 | + var cookies = []; | ||
| 244 | + $(".amarelo").each( | ||
| 245 | + function(i,el){ | ||
| 246 | + cookies.push($(el).attr("data-cookie")); | ||
| 247 | + } | ||
| 248 | + ); | ||
| 249 | + i3GEO.util.insereCookie("favoritosInit",cookies.join("|"),200); | ||
| 250 | +} | ||
| 251 | +function aplicaFavoritos(){ | ||
| 252 | + var favoritos = i3GEO.util.pegaCookie("favoritosInit"); | ||
| 253 | + if(favoritos){ | ||
| 254 | + favoritos = favoritos.split("|"); | ||
| 255 | + $(favoritos).each( | ||
| 256 | + function(i,el){ | ||
| 257 | + $('span[data-cookie="'+el+'"]').toggleClass("amarelo"); | ||
| 258 | + } | ||
| 259 | + ); | ||
| 260 | + } | ||
| 261 | +} | ||
| 262 | +function reordenaBotoesPorFavoritos(){ | ||
| 263 | + var f = [], | ||
| 264 | + nf = [], | ||
| 265 | + favoritos = i3GEO.util.pegaCookie("favoritosInit"); | ||
| 266 | + if(favoritos){ | ||
| 267 | + favoritos = favoritos.split("|"); | ||
| 268 | + $(botoesIni).each( | ||
| 269 | + function(i,el){ | ||
| 270 | + if(jQuery.inArray(el.img,favoritos) >= 0){ | ||
| 271 | + f.push(el); | ||
| 272 | + } | ||
| 273 | + else{ | ||
| 274 | + nf.push(el); | ||
| 275 | + } | ||
| 276 | + } | ||
| 277 | + ); | ||
| 278 | + botoesIni = jQuery.merge( f, nf ); | ||
| 279 | + } | ||
| 280 | +} | ||
| 281 | + | ||
| 282 | + |
init/index.php
| @@ -35,7 +35,11 @@ if (file_exists ( $dir_tmp )) { | @@ -35,7 +35,11 @@ if (file_exists ( $dir_tmp )) { | ||
| 35 | error_reporting ( 0 ); | 35 | error_reporting ( 0 ); |
| 36 | include "head.php"; | 36 | include "head.php"; |
| 37 | ?> | 37 | ?> |
| 38 | - | 38 | +<style> |
| 39 | +.amarelo { | ||
| 40 | + color: yellow; | ||
| 41 | +} | ||
| 42 | +</style> | ||
| 39 | <body style="padding-top: 90px;" id="topo"> | 43 | <body style="padding-top: 90px;" id="topo"> |
| 40 | <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation"> | 44 | <nav class="navbar navbar-fixed-top navbar-inverse" role="navigation"> |
| 41 | <div class="container-fluid"> | 45 | <div class="container-fluid"> |
| @@ -116,11 +120,10 @@ include "head.php"; | @@ -116,11 +120,10 @@ include "head.php"; | ||
| 116 | <a role="button" data-toggle="quadroQrcode" data-url="{{{href}}}" class="btn btn-primary btn-fab btn-fab-mini" href="#"> <span | 120 | <a role="button" data-toggle="quadroQrcode" data-url="{{{href}}}" class="btn btn-primary btn-fab btn-fab-mini" href="#"> <span |
| 117 | class="glyphicon glyphicon-qrcode" aria-hidden="true"></span> | 121 | class="glyphicon glyphicon-qrcode" aria-hidden="true"></span> |
| 118 | </a> | 122 | </a> |
| 119 | - <!-- TODO incluir favorito para ordenar lista | ||
| 120 | - <a role="button" data-toggle="quadroQrcode" data-url="{{{href}}}" class="btn btn-primary btn-fab btn-fab-mini disabled" href="#"> <span | ||
| 121 | - class="glyphicon glyphicon-star-empty" aria-hidden="true"></span> | ||
| 122 | - </a> | ||
| 123 | - --> | 123 | + |
| 124 | + <button onclick="favorita(this);return false;" class="btn btn-primary btn-fab btn-fab-mini"> <span | ||
| 125 | + data-cookie="{{{img}}}" class="glyphicon glyphicon-star" aria-hidden="true"></span> | ||
| 126 | + </button> | ||
| 124 | </div> | 127 | </div> |
| 125 | <div class="col-xs-6" > | 128 | <div class="col-xs-6" > |
| 126 | <a class="btn btn-primary" href="{{{href}}}" role="button" target="{{{target}}}"> | 129 | <a class="btn btn-primary" href="{{{href}}}" role="button" target="{{{target}}}"> |