Tangram
        berg



    infoQ
Agenda

• Challenges & dreams
• Architecture
• Tangram Base
• Tangram UI
Challenges & dreams
Response
as Fast as we can
Changing Every Day
Rich Internet Application
Legacy from 2001, new legacy everyday
The dreams

•
•   Javascript

•
Architecture
app

 widget

component

  base
app

 widget

component

  base
app

 widget

component

  base
app

 widget     UI




component

  base
app

 widget     UI




component

  base
Tangram base
Challenges
•
•
•
•
•
    • T.dom.addClass(ele, "highlight");
•
    • T.dom.addClass(ele, "highlight");
•
    • T.e("#container").addClass("highlight");
•
    • T.dom.addClass(ele, "highlight");
•
    • T.e("#container").addClass("highlight");
•
page:
startBaiduHI.js:




  Put Tangram in a clusure
Conclusions

•
•
•
Tangram UI
Challenges

•
    •
•
•
constructor
              ...


              ...


prototype
              ...
constructor




prototype
constructor
Plugin constructor



prototype




Plugin prototype
baidu.ui.Dialog.register(function(dialog){

      dialog.addEventListener("onload", function(){

        if(dialog.type == "alert"){

            baidu.dom.insertHTML(

             dialog.getId("footer"),

             "beforeEnd",

             getButtonString()

            );

        }

      });

});                                    Constructor
baidu.ui.Dialog.extend({

      okText : "     ",

      _ok : function(){

          this.close();

      }

});
                     Prototype
462   Dialog

 44   closeButton
 57   draggable
 54   iframe
 69   keyboard
 44   modal
 99   resizable
 26   smartCover
UI   =
Data




UI   =
Data

          +
UI   =
Data

          +
UI   =   DOM
Data

          +
UI   =   DOM

          +
Data

           +
UI   =   DOM

           +
         Control
Javascript
Data

           +
UI   =   DOM

           +
         Control
Data

           +
UI   =   DOM

           +
         Control
Data

           +
UI   =   DOM

           +
         Control
Javascript
DOM
DOM
HTML:
DOM
HTML:




Javascript:
Data

           +
UI   =   DOM

           +
         Control
Data

           +
UI   =   DOM

           +
         Control
Data

           +
UI   =   DOM

           +
         Control
UI
ui.Base




          ui.create




Button
ui.Base




          ui.create




Button
ui.Base




          ui.create    lang.Class



                      baidu

Button
ui.Base



     mix-in

          ui.create    lang.Class


            inherit   baidu

Button
button   dialog   table   ...
button   dialog   table         ...

                      alert

                     confirm

                      modal

                     keyboard

                          ...
button   dialog   table         ...

                               alert
draggable
                              confirm

stateable                      modal

                              keyboard
   ...
                                   ...
Conclusions
•
    •
    •
•
    •
About us
http://tangram.baidu.com
Conclusions
•
    •
    •
•       Javascript

•
Tangram
mp3

  IM




Tangram
             hao123
!anks
        berg
!anks
                berg



  Twitter: @cnberg
            : @berg
    i@cnberg.com

百度前端的七巧板 - Tangram