Pārlūkot izejas kodu

Merge branch 'master' of https://github.com/TapQuo/Lungo.js

@soyjavi 14 gadi atpakaļ
vecāks
revīzija
ab9dd326b9
2 mainītis faili ar 13 papildinājumiem un 8 dzēšanām
  1. 8 5
      src/data/Lungo.Data.Sql.js
  2. 5 3
      src/view/Lungo.View.Article.js

+ 8 - 5
src/data/Lungo.Data.Sql.js

@@ -122,7 +122,10 @@ LUNGO.Data.Sql = (function(lng, undefined) {
         db.transaction(function(tx) {
             tx.executeSql(sql, [], function(tx, rs) {
                 _callbackResponse(callback, rs);
-            }, _throwError);
+            }, function(transaction, error){
+                transaction.executedQuery = sql;
+                _throwError.apply(null, arguments);
+            });
         });
     };
 
@@ -169,7 +172,7 @@ LUNGO.Data.Sql = (function(lng, undefined) {
                 var value = fields[field];
                 if (sql) sql += ' ' + separator + ' ';
                 sql += field + '=';
-                sql += (isNaN(value)) ? '"' + value + '"' : value;
+                sql += (typeof value === 'string') ? '"' + value + '"' : value;
             }
         }
         return sql;
@@ -190,15 +193,15 @@ LUNGO.Data.Sql = (function(lng, undefined) {
                 var value = row[field];
                 fields += (fields) ? ', ' + field : field;
                 if (values) values += ', ';
-                values += (isNaN(value)) ? '"' + value + '"' : value;
+                values += (typeof value === 'string') ? '"' + value + '"' : value;
             }
         }
 
         execute('INSERT INTO ' + table + ' (' + fields + ') VALUES (' + values + ')');
-    }
+    };
 
     var _throwError = function(transaction, error) {
-        lng.Core.log(3, 'lng.Data.Sql >> ' + error.code + ': ' + error.message);
+        lng.Core.log(3, 'lng.Data.Sql >> ' + error.code + ': ' + error.message + ' \n Executed query: ' + transaction.executedQuery);
     };
 
     return {

+ 5 - 3
src/view/Lungo.View.Article.js

@@ -24,9 +24,11 @@ LUNGO.View.Article = (function(lng, undefined) {
         _disableNavItems(nav_items);
 
         var current_nav_item = lng.dom(nav_items + '[href="' + article_id + '"]');
-        current_nav_item.addClass(CSS_CLASSES.ACTIVE);
-        _setTitle(section_id, current_nav_item);
-
+        if(current_nav_item.length > 0) {
+            current_nav_item.addClass(CSS_CLASSES.ACTIVE);
+            _setTitle(section_id, current_nav_item);
+        }
+        
         _showContainer(section_id, article_id);
     };