Prechádzať zdrojové kódy

Merge branch 'master' of git.lattuga.net:hacklabbo/Ilovexm24

gine 7 rokov pred
rodič
commit
28be9ab3ce
5 zmenil súbory, kde vykonal 56 pridanie a 13 odobranie
  1. 1 1
      README.md
  2. 5 5
      www/js/crud.events.js
  3. 38 5
      www/js/main.js
  4. 1 1
      www/js/query.js
  5. 11 1
      www/js/update.js

+ 1 - 1
README.md

@@ -37,7 +37,7 @@ ADK (android developer kit) e
 
 ### Cordova CLI ###
 
-Cordova si intalla con npm, packager di nodejs
+Cordova si intalla con npm, packager di nodejs:
 
 `npm install -g cordova`
 

+ 5 - 5
www/js/crud.events.js

@@ -30,11 +30,11 @@ EVENTS.eventsLoaded = 0;
 EVENTS.render = function() {
     EVENTS.eventsLoaded = 0;
     
-    //Se si lancia il loader prima che sia cambiata pagina il loader scompare,
-    // ritardando invece che appaia, quando appare è già sulla pagina in cambiata
-    setTimeout(function () {
-        $.mobile.loading('show');
-    }, 300);
+//    //Se si lancia il loader prima che sia cambiata pagina il loader scompare,
+//    // ritardando invece che appaia, quando appare è già sulla pagina in cambiata
+//    setTimeout(function () {
+//        $.mobile.loading('show');
+//    }, 300);
     
     var ret = checkConnection('ERR_EVENT');
     if (ret) {

+ 38 - 5
www/js/main.js

@@ -39,6 +39,8 @@ FONTE.hrefseguente = "";
 FONTE.contentListId = '#mostralistainfo';
 FONTE.contentListClass = '.news';
 FONTE.ajaxError = false;
+
+FONTE.back_pressed = false;
 /*
  * data ultimo aggiornamento
  */
@@ -63,7 +65,20 @@ function displayLastUpdateDate() {
 function alterContent(url) {
     var paginacorrente = $("body").pagecontainer("getActivePage").attr("id");
 
-    switch (url) {
+    var oldUrl = url;
+
+    $( "#outside" ).panel( "close" );
+    // Alter the url according to the anchor's href attribute, and
+    // store the data-foo attribute information with the url
+    $.mobile.navigate(url);
+
+    //Se si lancia il loader prima che sia cambiata pagina il loader scompare,
+    // ritardando invece che appaia, quando appare è già sulla pagina in cambiata
+//    setTimeout(function () {
+//        $.mobile.loading('show');
+//    }, 300);
+
+    switch (oldUrl) {
     case '#index':
         $("#navheader").addClass("hide");
         $("#navfooter").addClass("hide");
@@ -113,10 +128,10 @@ function alterContent(url) {
         myJsonRandomPost('#titolosingleR', '#mostracontentsingleR');
         break;
     }
-    $( "#outside" ).panel( "close" );
-    // Alter the url according to the anchor's href attribute, and
-    // store the data-foo attribute information with the url
-    $.mobile.navigate(url);
+//    $( "#outside" ).panel( "close" );
+//    // Alter the url according to the anchor's href attribute, and
+//    // store the data-foo attribute information with the url
+//    $.mobile.navigate(url);
 }
 /*///////////////utilities//////////////http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript*/
 function getParameterByName(name, url) {
@@ -152,6 +167,24 @@ function initMainPage() {
 document.addEventListener("deviceready", onDeviceReady, false);
 //le cose all'inizio
 
+
+$(window).on("navigate", function (event, data) {
+  var direction = data.state.direction;
+  if (direction == 'back') {
+    FONTE.back_pressed = true;
+  }
+  else {
+    FONTE.back_pressed = false;
+  }
+});
+
+$(document).on("pagecontainershow", function (e, ui) {
+    var pageId = $('body').pagecontainer('getActivePage').prop('id');
+    if ((pageId == 'ilove' || pageId == 'info' || pageId == 'events') && !FONTE.back_pressed) {
+        $.mobile.loading('show');
+    }
+});
+
 $(document).on("mobileinit", function () {
     $("body").pagecontainer({
         defaults: true

+ 1 - 1
www/js/query.js

@@ -103,7 +103,7 @@ var appendPostList = function(div, resultSet, categories, fallback) {
 var prependPostsList = function(div, resultSet, categories, fallback) {
     var type = getObjKey(FONTE.categories, categories);
     
-    $(div).empty();
+    //$(div).empty();
     if (resultSet.rows.length > 0) {
         FONTE.page_loaded[type]++;
         drawListPost(div, resultSet, 'prepend');

+ 11 - 1
www/js/update.js

@@ -62,6 +62,8 @@ function update() {
 }
 
 function postsUpdate(categories) {
+    $(FONTE.contentListClass).empty();
+
     var storage = window.localStorage;
     var type = getObjKey(FONTE.categories, categories);
     var jsonurl = weburl + REST_PARAMS.posts + REST_PARAMS.per_page + "&categories=" + categories.join(',');
@@ -177,6 +179,10 @@ function getPrevSinglePageRecur(url, pagenum, categories) {
 }
 
 function getLastSinglePageRecur(url, pagenum, categories) {
+    // resetto la paginazione di #info e #ilove
+    FONTE.page_loaded.info = 0;
+    FONTE.page_loaded.ilove = 0;
+
     var type = getObjKey(FONTE.categories, categories);
     
     console.log('url:'+url);
@@ -238,7 +244,11 @@ function getLastSinglePageRecur(url, pagenum, categories) {
                     insertOrUpdateCatToPost(id, val);
                 });
             });
+
+            if (data.length == 0) {
+                renderLastNews(FONTE.contentListClass, categories);
+            }
         },
         error: JSONErrorHandler
     });
-}
+}