Просмотр исходного кода

New method for initialize a Lungo Instance

soyjavi 14 лет назад
Родитель
Сommit
14890fa663

+ 3 - 3
build.sh

@@ -20,7 +20,7 @@ echo -e "\033[0m"============================ LUNGO COMPILER ===================
     #Main
     DIR=$LUNGO_SOURCES$LUNGO_NAMESPACE
     echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES
-    FILES=(js Constants.js App.js Core.js Dom.js Service.js Element.js Fallback.js Events.js)
+    FILES=(js init.js Constants.js Core.js Dom.js Service.js Element.js Fallback.js Events.js)
     for file in "${FILES[@]}"
     do
         FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
@@ -70,7 +70,7 @@ echo -e "\033[0m"============================ LUNGO COMPILER ===================
     #Dom
     DIR=$LUNGO_SOURCES"boot/"$LUNGO_NAMESPACE"Boot."
     echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"boot/"
-    FILES=(js Resources.js Stats.js Layout.js Article.js Data.js Events.js Section.js)
+    FILES=(Resources.js Stats.js Layout.js Article.js Data.js Events.js Section.js)
     for file in "${FILES[@]}"
     do
         FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
@@ -114,4 +114,4 @@ FILES_TO_COMPRESS=""
 		cp $DIR"lungo.theme."$file $BUILDPATH'lungo.theme.'$file
 	done
 	echo -e "\033[32m  [BUILD]: lungo-"$VERSION.".css\033[0m"
-echo ============================ /LUNGO COMPILER ============================
+echo ============================ /LUNGO COMPILER ============================

+ 0 - 3
examples/test/app/app.js

@@ -1,8 +1,5 @@
 var App = (function(lng, undefined) {
 
-
-
-
     var _getEnvironmentFromQuoJS = (function() {
         var environment = lng.Core.environment();
         if (environment.isMobile) {

+ 18 - 12
examples/test/index.html

@@ -357,7 +357,7 @@
     <script src="../../release/lungo.js"></script>
     -->
     <script src="../../src/Lungo.js"></script>
-    <script src="../../src/Lungo.App.js" ></script>
+    <script src="../../src/Lungo.init.js"></script>
     <script src="../../src/Lungo.Core.js"></script>
     <script src="../../src/Lungo.Dom.js"></script>
     <script src="../../src/Lungo.Service.js"></script>
@@ -379,7 +379,9 @@
     <script src="../../src/data/Lungo.Data.Storage.js"></script>
     <script src="../../src/attributes/Lungo.Attributes.Data.js"></script>
     <script src="../../src/Lungo.Fallback.js"></script>
+    <!--
     <script src="../../src/boot/Lungo.Boot.js"></script>
+    -->
     <script src="../../src/boot/Lungo.Boot.Resources.js" ></script>
     <script src="../../src/boot/Lungo.Boot.Stats.js" ></script>
     <script src="../../src/boot/Lungo.Boot.Layout.js"></script>
@@ -387,25 +389,29 @@
     <script src="../../src/boot/Lungo.Boot.Data.js"></script>
     <script src="../../src/boot/Lungo.Boot.Section.js"></script>
     <script src="../../src/boot/Lungo.Boot.Article.js"></script>
-
+    <!--
+    <script src="../../src/Lungo.App.js" ></script>
+    -->
 
     <!-- LungoJS - Sandbox App -->
-    <script src="app/app.js"></script>
-    <script src="app/view.js"></script>
-    <script src="app/data.js"></script>
-    <script src="app/services.js"></script>
-    <script src="app/events.js"></script>
-        <script src="app/events.notification.js"></script>
-
     <script>
-        Lungo.App.init({
+        Lungo.init({
             name: 'Kitchen Sink',
             version: '2.0',
+            sugars: ['map', 'pull'],
             resources: {
-                sections: [
-                    'aside.html', 'aside-profiles.html', 'notification.html']
+                sections: ['aside.html', 'aside-profiles.html', 'notification.html'],
+                templates: [],
+                asides: []
             }
         });
     </script>
+
+    <script src="app/app.js"></script>
+    <script src="app/view.js"></script>
+    <script src="app/data.js"></script>
+    <script src="app/services.js"></script>
+    <script src="app/events.js"></script>
+        <script src="app/events.notification.js"></script>
 </body>
 </html>

+ 0 - 44
src/Lungo.App.js

@@ -1,44 +0,0 @@
-/**
- * Lungo sandbox APP initialization
- *
- * @namespace Lungo
- * @class App
- *
- * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
- */
-
-Lungo.App = (function(lng, undefined) {
-
-     var default_config = {
-         id: 1,
-         name: 'lungo_app',
-         version: 1.0,
-         icon: ''
-     };
-
-    /**
-     * Initializes all LungoJS system: setting properties for the application,
-     * subscribing to automatic events, initializing sections & articles
-     * and stating the title.
-     *
-     * @method init
-     *
-     * @param {object} Application configuration properties
-     */
-    var init = function(app_config) {
-        default_config = lng.Core.mix(default_config, app_config);
-
-        lng.Boot();
-    };
-
-    var get = function(property) {
-        return default_config[property];
-    };
-
-    return {
-        init: init,
-        get: get
-    };
-
-})(Lungo);

+ 20 - 0
src/Lungo.Init.js

@@ -0,0 +1,20 @@
+/**
+ * Instance initializer
+ *
+ * @namespace Lungo
+ * @class Init
+ *
+ * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
+ */
+
+Lungo.init = function(config) {
+    Lungo.Boot.Resources.init(config.resources);
+    //@todo: Resize Layout
+    //lng.Boot.Layout.init();
+    Lungo.Boot.Events.init();
+    Lungo.Boot.Data.init();
+    Lungo.Boot.Section.init();
+    Lungo.Boot.Article.init();
+    //@todo: Call to home?
+    // Lungo.Boot.Stats.init();
+};

+ 1 - 0
src/Lungo.js

@@ -29,5 +29,6 @@ Lungo.Attributes || (Lungo.Attributes = {});
 Lungo.Data || (Lungo.Data = {});
 Lungo.Sugar || (Lungo.Sugar = {});
 Lungo.View || (Lungo.View = {});
+Lungo.Boot || (Lungo.Boot = {});
 Lungo.Device || (Lungo.Device = {});
 Lungo.ready || (Lungo.ready = Quo().ready);

+ 2 - 2
src/boot/Lungo.Boot.Article.js

@@ -22,7 +22,7 @@ Lungo.Boot.Article = (function(lng, undefined) {
      *
      * @method init
      */
-    var start = function() {
+    var init = function() {
         _initElement(SELECTORS.LIST_IN_ARTICLE, _createListElement);
         _initElement(SELECTORS.CHECKBOX_IN_ARTICLE, _createCheckboxElement);
     };
@@ -48,7 +48,7 @@ Lungo.Boot.Article = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 2 - 2
src/boot/Lungo.Boot.Data.js

@@ -18,7 +18,7 @@ Lungo.Boot.Data = (function(lng, undefined) {
      *
      *
      */
-    var start = function() {
+    var init = function() {
         var attributes = lng.Attributes.Data;
 
         for (var attribute in attributes) {
@@ -38,7 +38,7 @@ Lungo.Boot.Data = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 2 - 2
src/boot/Lungo.Boot.Events.js

@@ -27,7 +27,7 @@ Lungo.Boot.Events = (function(lng, undefined) {
      * @method init
      *
      */
-    var start = function() {
+    var init = function() {
         var touch_move_event  = 'touchmove';
         var resize = 'resize';
 
@@ -98,7 +98,7 @@ Lungo.Boot.Events = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 2 - 2
src/boot/Lungo.Boot.Layout.js

@@ -21,7 +21,7 @@ Lungo.Boot.Layout = (function(lng, undefined) {
      * @method init
      *
      */
-    var start = function() {
+    var init = function() {
         if (lng.Core.isMobile()) {
             _window = window;
             _document = _window.document;
@@ -62,7 +62,7 @@ Lungo.Boot.Layout = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 2 - 3
src/boot/Lungo.Boot.Resources.js

@@ -24,8 +24,7 @@ Lungo.Boot.Resources = (function(lng, $$, undefined) {
      * @method start
      *
      */
-    var start = function() {
-        var resources = lng.App.get('resources');
+    var init = function(resources) {
         for (resource_key in resources) {
             _loadResources(resource_key, resources[resource_key]);
         }
@@ -100,7 +99,7 @@ Lungo.Boot.Resources = (function(lng, $$, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo, Quo);

+ 2 - 2
src/boot/Lungo.Boot.Section.js

@@ -19,7 +19,7 @@ Lungo.Boot.Section = (function(lng, undefined) {
      *
      * @method init
      */
-    var start = function() {
+    var init = function() {
         _initFirstSection();
         _initAllSections();
 
@@ -56,7 +56,7 @@ Lungo.Boot.Section = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 2 - 2
src/boot/Lungo.Boot.Stats.js

@@ -15,7 +15,7 @@ Lungo.Boot.Stats = (function(lng, undefined) {
      *
      * @method start
      */
-    var start = function() {
+    var init = function() {
         if (lng.Core.isMobile()) {
             _saveStats();
         }
@@ -35,7 +35,7 @@ Lungo.Boot.Stats = (function(lng, undefined) {
     };
 
     return {
-        start: start
+        init: init
     };
 
 })(Lungo);

+ 0 - 23
src/boot/Lungo.Boot.js

@@ -1,23 +0,0 @@
-/**
- * Boot for a new LungoJS Application instance
- *
- * @namespace Lungo
- * @class App
- *
- * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- */
-
-Lungo.Boot = (function(lng, undefined) {
-
-    return function() {
-        lng.Boot.Resources.start();
-        //@todo: Resize Layout
-        //lng.Boot.Layout.start();
-        lng.Boot.Events.start();
-        lng.Boot.Data.start();
-        lng.Boot.Section.start();
-        lng.Boot.Article.start();
-        lng.Boot.Stats.start();
-    };
-
-})(Lungo);