Framework7-- basic tools

 

        /**
         * Framework7
         **/
        function SeabootFramework7(option) {
            var root = $(document);
            if (typeof option !== 'undefined') {
                initDom(option);
                root = option.dom;
            }

            /**
             * 查找dom对象
             * */
            function initDom(option) {
                if (typeof option.elem === 'string') {
                    option.dom = root.find(option.elem);
                } else if (typeof option.elem === 'object') {
                    option.dom = option.elem;
                } else {
                    throw 'elem is undefined!';
                }
            }

            /**
             * 绑定值
             */
            function bindValue(dom, data) {
                dom.find('*').each(function () {
                    var d = $(this), id = d.attr('id');
                    IF ( typeof ID == 'undefined'! ) {
                         var V = Data [ID];
                         IF ( typeof V == 'undefined'! ) { 
                            d.text (V); 
                        } 
                    } 
                }) 
            } 

            / * * 
             * Built template rendering 
             * * / 
            function the compile (STR, Data) {
                 return Template7.compile (STR) (Data); 
            } 

            / * * 
             * function 
             * * /
            return {
                bindValue: bindValue,
                compile: compile
            }
        }

 

Guess you like

Origin www.cnblogs.com/chenss15060100790/p/11199353.html