Przeglądaj źródła

Initializes events after knowing the environment

@soyjavi 14 lat temu
rodzic
commit
4bed4e16d2
3 zmienionych plików z 18 dodań i 6 usunięć
  1. 5 5
      src/Lungo.Environment.js
  2. 12 1
      src/Lungo.Events.js
  3. 1 0
      src/boot/Lungo.Boot.Events.js

+ 5 - 5
src/Lungo.Environment.js

@@ -1,7 +1,7 @@
-/** 
+/**
  * Set environment (Desktop or Mobile) automatically, depending on the
  * environment the subscribed events wil be different.
- * 
+ *
  * @namespace LUNGO
  * @class Environment
  *
@@ -31,7 +31,7 @@ LUNGO.Environment = (function(lng, undefined) {
     /**
      * Gets the current environment for LungoJS
      *
-     * @method init
+     * @method current
      *
      * @return {String} Current environment enumerator
      */
@@ -54,14 +54,14 @@ LUNGO.Environment = (function(lng, undefined) {
      * Save in LungoJS.com the use of the service for further ranking
      *
      * @method _saveStatsInLungoJS
-     */    
+     */
     var _saveStatsInLungoJS = function() {
         lng.Service.post( 'http://www.lungojs.com/stats/', {
             name: lng.App.get('name'),
             version: lng.App.get('version'),
             icon: lng.App.get('icon')
         });
-    }
+    };
 
     return {
         start: start,

+ 12 - 1
src/Lungo.Events.js

@@ -30,8 +30,13 @@ LUNGO.Events = (function(lng, undefined) {
         }
     };
 
+    /*
     var current_environment = lng.Environment.current();
     var current_events = EVENTS[current_environment];
+    */
+    var current_environment = null;
+    var current_events = null;
+
 
     /**
      * Returns the touch event based on an enumeration of LungoJS
@@ -46,8 +51,14 @@ LUNGO.Events = (function(lng, undefined) {
         return current_events[eventName];
     };
 
+    var init = function() {
+        current_environment = lng.Environment.current();
+        current_events = EVENTS[current_environment];
+    };
+
     return {
-        get: get
+        get: get,
+        init: init
     };
 
 })(LUNGO);

+ 1 - 0
src/boot/Lungo.Boot.Events.js

@@ -24,6 +24,7 @@ LUNGO.Boot.Events = (function(lng, undefined) {
         var target_selector = 'a[href][data-target]';
         var target_selector_from_aside = 'aside a[href][data-target]';
 
+        lng.Events.init();
         lng.Dom.Event.listener(document, touch_move_event, _iScroll);
         lng.Dom.Event.listener(window, orientation_change, _changeOrientation);
         lng.Dom.Event.live(target_selector_from_aside, touch_start_event, _toggleAside);