소스 검색

Lungo.Template deprecated

Now this task will do @amazing_monocle (http://monocle.tapquo.com)
soyjavi 13 년 전
부모
커밋
54f487f9e4

+ 0 - 117
build.sh

@@ -1,117 +0,0 @@
-#!/bin/bash
-VERSION="2.0"
-
-#define paths
-COMPILER=vendor/google-compiler/compiler.jar
-COMPRESSOR=vendor/yuicompressor/yuicompressor-2.4.2.jar
-LUNGO_SOURCES=src/
-LUNGO_NAMESPACE=Lungo.
-BUILDPATH=release/
-MINIFIED="min"
-
-#script
-clear
-echo -e "\033[0m"============================ LUNGO COMPILER ============================
-
-    ## Files to compile
-    FILES_TO_COMPILE=""
-    FILES_TO_JOIN=""
-
-    #Main
-    DIR=$LUNGO_SOURCES$LUNGO_NAMESPACE
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES
-    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
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #Router
-    DIR=$LUNGO_SOURCES"router/"$LUNGO_NAMESPACE"Router."
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"router/"
-    FILES=(js History.js)
-    for file in "${FILES[@]}"
-    do
-        FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #View
-    DIR=$LUNGO_SOURCES"view/"$LUNGO_NAMESPACE"View."
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"view/"
-    FILES=(Article.js Resize.js Template.js Template.Binding.js Template.List.js Aside.js Element.js)
-    for file in "${FILES[@]}"
-    do
-        FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #Attributes
-    DIR=$LUNGO_SOURCES"attributes/"$LUNGO_NAMESPACE"Attributes."
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"attributes/"
-    FILES=(Data.js)
-    for file in "${FILES[@]}"
-    do
-        FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #Data
-    DIR=$LUNGO_SOURCES"data/"$LUNGO_NAMESPACE"Data."
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"data/"
-    FILES=(Cache.js Sql.js Storage.js)
-    for file in "${FILES[@]}"
-    do
-        FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #Dom
-    DIR=$LUNGO_SOURCES"boot/"$LUNGO_NAMESPACE"Boot."
-    echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"boot/"
-    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
-        FILES_TO_JOIN=$FILES_TO_JOIN" "$DIR$file
-    done
-
-    #COMPILED Version
-    FILES_TO_COMPILE=" --js "$LUNGO_SOURCES"lib/QuoJS.js "$FILES_TO_COMPILE
-    java -jar $COMPILER $FILES_TO_COMPILE --js_output_file $BUILDPATH/lungo-$VERSION.js
-    echo -e "\033[32m  [BUILD]: lungo-"$VERSION.js"\033[0m"
-
-
-FILES_TO_COMPRESS=""
-    DIR=$LUNGO_SOURCES"stylesheets/css/"
-
-    echo -e "\033[33m  [DIR]: "$DIR
-    FILES=(base layout layout.nav layout.aside layout.article layout.list widgets widgets.splash widgets.button widgets.form widgets.colour widgets.loading )
-    for file in "${FILES[@]}"
-    do
-        echo "    - Compressing "$DIR$LUNGO_NAMESPACE$file".css ..."
-        #Compressing via YUI
-        #java -jar $COMPRESSOR $DIR$LUNGO_NAMESPACE$file".css" -o $DIR$LUNGO_NAMESPACE$file".min.css"
-        #FILES_TO_COMPRESS=$FILES_TO_COMPRESS" "$DIR$LUNGO_NAMESPACE$file".min.css"
-
-        FILES_TO_COMPRESS=$FILES_TO_COMPRESS" "$DIR$LUNGO_NAMESPACE$file".css"
-    done
-    FILES_TO_COMPRESS=$FILES_TO_COMPRESS" "$DIR$LUNGO_NAMESPACE"widgets.icon.css"
-	cat $FILES_TO_COMPRESS > $BUILDPATH/lungo-$VERSION.css
-
-    #for file in "${FILES[@]}"
-    #do
-    #    rm $DIR$LUNGO_NAMESPACE$file".min.css"
-    #done
-
-	DIR=$LUNGO_SOURCES"stylesheets/css/"
-	FILES=(default.css default.font.css)
-	echo -e "\033[33m  [DIR]: "$DIR
-	for file in "${FILES[@]}"
-	do
-		echo "   - [THEME] "$file
-		cp $DIR"lungo.theme."$file $BUILDPATH'lungo.theme.'$file
-	done
-	echo -e "\033[32m  [BUILD]: lungo-"$VERSION.".css\033[0m"
-echo ============================ /LUNGO COMPILER ============================

+ 0 - 4
examples/kitchen-sink/index.html

@@ -129,9 +129,6 @@
     <script src="../../src/view/Lungo.View.Article.js" ></script>
     <script src="../../src/view/Lungo.View.Aside.js" ></script>
     <script src="../../src/view/Lungo.View.Element.js"></script>
-    <script src="../../src/view/Lungo.View.Template.js"></script>
-    <script src="../../src/view/Lungo.View.Template.Binding.js"></script>
-    <script src="../../src/view/Lungo.View.Template.List.js"></script>
     <script src="../../src/data/Lungo.Data.Cache.js"></script>
     <script src="../../src/data/Lungo.Data.Sql.js"></script>
     <script src="../../src/data/Lungo.Data.Storage.js"></script>
@@ -153,7 +150,6 @@
             sugars: ['map', 'pull'],
             resources: {
                 sections: [ 'layout.html', 'notification.html', 'list.html', 'icon.html', 'grid.html', 'form.html', 'aside.html', 'touchevents.html', 'splash.html', 'data-attribute.html', 'scroll.html', 'color.html'],
-                templates: [],
                 asides: ['features.html', 'left.html', 'right.html']
             }
         });

+ 0 - 3
examples/kitchen-sink/old_index.html

@@ -371,9 +371,6 @@
     <script src="../../src/view/Lungo.View.Article.js" ></script>
     <script src="../../src/view/Lungo.View.Aside.js" ></script>
     <script src="../../src/view/Lungo.View.Element.js"></script>
-    <script src="../../src/view/Lungo.View.Template.js"></script>
-    <script src="../../src/view/Lungo.View.Template.Binding.js"></script>
-    <script src="../../src/view/Lungo.View.Template.List.js"></script>
     <script src="../../src/data/Lungo.Data.Cache.js"></script>
     <script src="../../src/data/Lungo.Data.Sql.js"></script>
     <script src="../../src/data/Lungo.Data.Storage.js"></script>

+ 1 - 6
src/Lungo.Constants.js

@@ -56,15 +56,10 @@ Lungo.Constants = {
     BINDING: {
         START: '{{',
         END: '}}',
-        KEY: 'value',
-        PARSER: /\{{.*?\}}/gi
+        KEY: 'value'
     },
 
     ERROR: {
-        CREATE_SCROLL: 'ERROR: Impossible to create a <scroll> without ID.',
-        BINDING_DATA_TYPE: 'ERROR: Processing the type of binding data.',
-        BINDING_TEMPLATE: 'ERROR: Binding Template not exists >> ',
-        BINDING_LIST: 'ERROR: Processing parameters for list binding.',
         DATABASE: 'ERROR: Connecting to Data.Sql.',
         DATABASE_TRANSACTION: 'ERROR: Data.Sql >> ',
         ROUTER: 'ERROR: The target does not exists >>',

+ 11 - 1
src/boot/Lungo.Boot.Data.js

@@ -10,6 +10,7 @@
  */
 
 Lungo.Boot.Data = (function(lng, undefined) {
+    var BINDING = lng.Constants.BINDING;
 
     /**
      * Initialize the <markup> data-attributes analisys
@@ -33,7 +34,16 @@ Lungo.Boot.Data = (function(lng, undefined) {
 
         for (var i = 0, len = elements.length; i < len; i++) {
             var element = lng.dom(elements[i]);
-            lng.View.Template.Binding.dataAttribute(element, attribute);
+            _dataAttribute(element, attribute);
+        }
+    };
+
+    var _dataAttribute = function(element, attribute) {
+        var data = element.data(attribute.tag);
+
+        if (data) {
+            var html_binded = attribute.html.replace(BINDING.START + BINDING.KEY + BINDING.END, data);
+            element.prepend(html_binded);
         }
     };
 

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

@@ -14,8 +14,7 @@ Lungo.Boot.Resources = (function(lng, $$, undefined) {
 
     var RESOURCE = {
         SECTION: 'sections',
-        ASIDE: 'asides',
-        TEMPLATE: 'templates'
+        ASIDE: 'asides'
     };
 
     /**
@@ -36,7 +35,7 @@ Lungo.Boot.Resources = (function(lng, $$, undefined) {
 
             try {
                 var response = _loadSyncResource(url);
-                _factoryResources(resource_key, response);
+                _pushResourceInBody(response);
             } catch(error) {
                 lng.Core.log(3, error.message);
             }
@@ -59,31 +58,12 @@ Lungo.Boot.Resources = (function(lng, $$, undefined) {
         });
     };
 
-    var _factoryResources = function(resource_key, response) {
-        if (resource_key == RESOURCE.TEMPLATE) {
-             _createTemplate(response);
-        } else {
-            _pushSectionInLayout(response);
-        }
-    };
-
-    var _pushSectionInLayout = function(section) {
+    var _pushResourceInBody = function(section) {
         if (lng.Core.toType(section) === 'string') {
             lng.dom(ELEMENT.BODY).append(section);
         }
     };
 
-    var _createTemplate = function(markup) {
-        var div = document.createElement(ELEMENT.DIV);
-        div.innerHTML = markup;
-
-        var template_id = lng.dom(div.firstChild).data('template');
-
-        if (template_id) {
-            lng.View.Template.create(template_id, markup);
-        }
-    };
-
     return {
         init: init
     };

+ 0 - 73
src/view/Lungo.View.Template.Binding.js

@@ -1,73 +0,0 @@
-/**
- * Lungo Data-Binding system
- *
- * @namespace Lungo.View.Template
- * @class Binding
- *
- * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
- */
-
-Lungo.View.Template.Binding = (function(lng, undefined) {
-
-    var BINDING = lng.Constants.BINDING;
-    var ERROR = lng.Constants.ERROR;
-
-    /**
-     * Performs databinding process for a data set and a given template
-     *
-     * @method process
-     *
-     * @param {String} Markup for binding
-     * @param {Object} Data for binding
-     */
-    var process = function(markup, data) {
-        var data_type = lng.Core.toType(data);
-
-        if (data_type === 'array') {
-            return _bindPropertiesInMultiplesElements(data, markup);
-        } else if (data_type === 'object') {
-            return _bindProperties(data, markup);
-        } else {
-            throw new Error(ERROR.BINDING_DATA_TYPE);
-        }
-    };
-
-    var dataAttribute = function(element, attribute) {
-        var data = element.data(attribute.tag);
-
-        if (data) {
-            var html_binded = attribute.html.replace(BINDING.START + BINDING.KEY + BINDING.END, data);
-            element.prepend(html_binded);
-        }
-    };
-
-    var _bindPropertiesInMultiplesElements = function(elements, template) {
-        var markup = '';
-        for (var i = 0, len = elements.length; i < len; i++) {
-            markup += _bindProperties(elements[i], template);
-        }
-        return markup;
-    };
-
-    var _bindProperties = function(element, template) {
-        var binding_field;
-        for (var property in element) {
-            if (lng.Core.isOwnProperty(element, property) && element[property] !== null) {
-                binding_field = new RegExp(BINDING.START + property + BINDING.END, 'g');
-                template = template.replace(binding_field, element[property]);
-            }
-        }
-        return _removeNoBindedProperties(template);
-    };
-
-    var _removeNoBindedProperties = function(template) {
-        return template.replace(BINDING.PARSER, '');
-    };
-
-    return {
-        process: process,
-        dataAttribute: dataAttribute
-    };
-
-})(Lungo);

+ 0 - 101
src/view/Lungo.View.Template.List.js

@@ -1,101 +0,0 @@
-/**
- * Auto generate lists based on Template and Data-Binding system
- *
- * @namespace Lungo.View.Template
- * @class List
- *
- * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
- */
-
-Lungo.View.Template.List = (function(lng, undefined) {
-
-    var ERROR = lng.Constants.ERROR;
-    var ATTRIBUTE = lng.Constants.ATTRIBUTE;
-
-    /**
-     * Create a list based DataBind with a configuration object for an element <article>
-     * if the config has a 'norecords' property it will display the norecords markup rather than nothing.
-     *
-     * @method create
-     *
-     * @param {object} Id of the container showing the result of databinding
-     */
-     var create = function(config) {
-        config.container = _getContainer(config.el);
-
-        if (_validateConfig(config)) {
-            config.data = _order(config);
-            _render(config);
-        }
-    };
-
-    /**
-     * Append a list based DataBind with a configuration object for an element <article>
-     * if the config has a 'norecords' property it will display the norecords markup rather than nothing.
-     *
-     * @method append
-     *
-     * @param {object} Id of the container showing the result of databinding
-     */
-    var append = function(config) {
-        var markup = lng.View.Template.markup(config.template, config.data);
-        var container = _getContainer(config.el);
-
-        container.append(markup);
-    };
-
-    /**
-     * Prepend a list based DataBind with a configuration object for an element <article>
-     * if the config has a 'norecords' property it will display the norecords markup rather than nothing.
-     *
-     * @method prepend
-     *
-     * @param {object} Id of the container showing the result of databinding
-     */
-    var prepend = function(config) {
-        var markup = lng.View.Template.markup(config.template, config.data);
-        var container = _getContainer(config.el);
-
-        container.prepend(markup);
-    };
-
-    var _validateConfig = function(config) {
-        var checked = false;
-        var container_exists = !! config.container.length > 0;
-        var template_exists = lng.View.Template.exists(config.template);
-
-        if (container_exists && template_exists) {
-            var type = lng.Core.toType(config.data);
-            if (type === 'array' || type === 'object') {
-                checked = true;
-            }
-        } else {
-            throw new Error(ERROR.BINDING_LIST);
-        }
-
-        return checked;
-    };
-
-    var _getContainer = function(element) {
-        return lng.dom(element).children().first();
-    };
-
-    var _order = function(config) {
-        if (config.order && config.order.field && config.order.type) {
-            config.data = lng.Core.orderByProperty(config.data, config.order.field, config.order.type);
-        }
-        return config.data;
-    };
-
-    var _render = function(config) {
-        lng.View.Template.render(config.container.selector, config.template, config.data);
-    };
-
-    return {
-        create: create,
-        append: append,
-        prepend: prepend
-    };
-
-})(Lungo);

+ 0 - 105
src/view/Lungo.View.Template.js

@@ -1,105 +0,0 @@
-/**
- * Lungo Template system
- *
- * @namespace Lungo.View
- * @class Template
- *
- * @author Javier Jimenez Villar <javi@tapquo.com> || @soyjavi
- * @author Guillermo Pascual <pasku@tapquo.com> || @pasku1
- */
-
-Lungo.View.Template = (function(lng, undefined) {
-
-    var ERROR = lng.Constants.ERROR;
-
-    var _templates = {};
-
-    /**
-     * Create a new databinding template based on a <markup>
-     *
-     * @method create
-     *
-     * @param {String} Id of the new databinding template
-     * @param {String} <markup> of the new databinding template
-     */
-    var create = function(id, markup) {
-        _templates[id] = markup;
-    };
-
-    /**
-     * Returns the existence of a certain Id databinding template
-     *
-     * @method exists
-     *
-     * @param {String} Id of the databinding template
-     * @return {Boolean} true if exists, false if not.
-     */
-    var exists = function(id) {
-        return (_templates[id]) ? true : false;
-    };
-
-    /**
-     * Returns the instance of a certain Id databinding template
-     *
-     * @method get
-     *
-     * @param {String} Id of the databinding template
-     * @return {String} Markup of template
-     */
-    var get = function(id) {
-        return _templates[id];
-    };
-
-    /**
-     * Performs databinding process for a data set and a given template
-     *
-     * @method render
-     *
-     * @param {String} Element selector for showing the result of databinding
-     * @param {String} Databinding Template Id
-     * @param {Object} Data for binding
-     */
-    var render = function(element, template_id, data) {
-        if (lng.View.Template.exists(template_id)) {
-            var container = lng.dom(element);
-            container.html(this.markup(template_id, data));
-        } else {
-            throw new Error(ERROR.BINDING_TEMPLATE + template_id);
-        }
-    };
-
-    /**
-     * Performs databinding process for a data set and a given template
-     *
-     * @method markup
-     *
-     * @param {String} Databinding Template Id
-     * @param {Object} Data for binding
-     */
-    var markup = function(template_id, data) {
-        var template_markup = this.get(template_id);
-        return lng.View.Template.Binding.process(template_markup, data);
-    };
-
-    /**
-     * Performs databinding process for a data set and a given html
-     *
-     * @method html
-     *
-     * @param {String} Markup for binding
-     * @param {Object} Data for binding
-     */
-    var html = function(markup, data) {
-        return lng.View.Template.Binding.process(markup, data);
-    };
-
-    return {
-        create: create,
-        exists: exists,
-        get: get,
-        render: render,
-        markup: markup,
-        html: html
-    };
-
-})(Lungo);

+ 1 - 1
vendor/build.sh

@@ -39,7 +39,7 @@ echo -e "\033[0m"============================ LUNGO COMPILER ===================
     #View
     DIR=$LUNGO_SOURCES"view/"$LUNGO_NAMESPACE"View."
     echo -e "\033[33m  [DIR]: "$LUNGO_SOURCES"view/"
-    FILES=(Resize.js Article.js Aside.js Element.js Template.js Template.Binding.js Template.List.js )
+    FILES=(Resize.js Article.js Aside.js Element.js)
     for file in "${FILES[@]}"
     do
         FILES_TO_COMPILE=$FILES_TO_COMPILE" --js "$DIR$file