EcmaScript 5 Object.create() Object.defineProperties
Üdv mindenkinek, szerintem a kód magáért beszél :-). Hogy oldanátok meg egy hasonló öröklődést az új függvényekkel? Mit nézek el vajon?Köszi a véleményeket, üdv:
Gábor
■ - //Items hierarchy - all visible (User Interface) items has some properties in common
- var TIB = {};
- /*
- * TIB.ui.AbstractItem
- * Parent of all Visible items
- *
- */
- TIB.ui = {};
- TIB.ui.AbstractItem = {
- id : null,
- DOM : {
- events: {},
- html : {
- wrapper : '<div class="tibitemwrapper" >'+
- '<h3 class="ui-widget ui-widget-header ui-corner-all ui-border-all"></h3>'+
- '<div class="tibitemcontainer ui-widget ui-widget-content ui-corner-all ui-border-all">'+
- '</div>'+
- '</div>',
- content : null,
- classname : "abstract"
- },
- style : {},
- },
- events : {},
- enabled : true,
- properties : {
- name : "TIB.ui.AbstractItem"
- },
- value : null
- }
- /*
- * TIB.ui.AbstractTextItem
- * Parent of all Visisible Items that has Text on it.
- *
- */
- TIB.ui.AbstractTextItem = Object.create(TIB.ui.AbstractItem,{
- toString : { value : function() {
- return this.id+", "+this.properties.name+", "+this.properties.fontSize+", "+this.DOM.html.classname+", "+this.value;
- },
- },
- properties : {
- value : {
- name : "TIB.ui.AbstractTextItem",
- fontSize : "1em"
- }
- }
- });
- TIB.ui.TextArea = Object.create(TIB.ui.AbstractTextItem);
- Object.defineProperties(TIB.ui.TextArea,{
- properties : {
- value : {
- name : "TIB.ui.TextArea",
- fontSize : "2em"
- },
- },
- value : {
- value : "SzövegDoboz"
- },
- });
- console.log(TIB.ui.AbstractTextItem.toString()); //classname : abstract
- console.log(TIB.ui.TextArea.toString()); //classname abstract
- TIB.ui.TextArea.DOM.html.classname = "textareaclassname";
- console.log(TIB.ui.AbstractTextItem.toString()); //classname textareaclassname !!!!!
- console.log(TIB.ui.TextArea.toString()); //classname textareaclassname
Gábor
Erre lyukadtam ki:
Persze várom a véleményeket :-)
Üdv:
Gábor
Kár hogy erre senki sem