Changes between Version 7 and Version 8 of AnotherPluginDevelopmentGuide


Ignore:
Timestamp:
18.07.2012 16:34:41 (12 years ago)
Author:
dgf
Comment:

adapt master branch

Legend:

Unmodified
Added
Removed
Modified
  • AnotherPluginDevelopmentGuide

    v7 v8  
    331331A plugin that loads some type specific renderer and adds a custom command: 
    332332{{{#!js 
    333 dm4c.add_plugin('de.deepamehta.example', function() { 
     333dm4c.add_plugin('dm4.example.plugin', function() { 
    334334 
    335335    // load some renderer and a style sheet 
     
    342342        var name = prompt('Example name', 'Another Example') 
    343343            topic = dm4c.restc.request('POST', '/example/create', { name: name }) 
    344         dm4c.show_topic(topic, 'show', null, true) 
     344        dm4c.show_topic(new Topic(topic), 'show', null, true) 
    345345    } 
    346346 
     
    349349        var url = '/example/increase/' + dm4c.selected_object.id, 
    350350            topic = dm4c.restc.request('GET', url) 
    351         dm4c.show_topic(topic, 'show', null, true) 
     351        dm4c.show_topic(new Topic(topic), 'show', null, true) 
    352352    } 
    353353 
     
    382382            type_uri: "dm4.webclient.view_config", 
    383383            composite: { 
    384                 dm4.webclient.js_field_renderer_class: "ExampleContentFieldRenderer", 
    385                 dm4.webclient.js_page_renderer_class: "ExampleContentPageRenderer" 
     384                dm4.webclient.field_renderer_uri: "dm4.example.content_field_renderer", 
     385                dm4.webclient.page_renderer_uri: "dm4.example.content_page_renderer" 
    386386            } 
    387387        } 
     
    397397 
    398398{{{#!js 
    399 // a simple field renderer that renders a example topic name with a additional CSS class 
    400 function ExampleContentFieldRenderer(field_model) { 
    401     this.field_model = field_model 
    402 } 
    403  
    404 ExampleContentFieldRenderer.prototype.render_field = function(parent_element) { 
    405     dm4c.render.field_label(this.field_model, parent_element) 
    406     parent_element.append($("<span>").addClass('example').text(this.field_model.value)) 
    407 } 
    408  
    409 ExampleContentFieldRenderer.prototype.render_form_element = function(parent_element) { 
    410     var $content = dm4c.render.input(this.field_model) 
    411     parent_element.append($content) 
    412     return function() { 
    413         return $.trim($content.val()) 
    414     } 
    415 } 
     399// a simple field renderer that renders an example topic name with an additional CSS class 
     400dm4c.add_field_renderer("dm4.example.content_field_renderer", { 
     401 
     402    render_field: function(field_model, parent_element) { 
     403        dm4c.render.field_label(field_model, parent_element) 
     404        parent_element.append($("<span>").addClass('example').text(field_model.value)) 
     405    }, 
     406 
     407    render_form_element: function(field_model, parent_element) { 
     408        var $content = dm4c.render.input(field_model) 
     409        parent_element.append($content) 
     410        return function() { // return input value 
     411            return $.trim($content.val()) 
     412        } 
     413    } 
     414}) 
    416415}}} 
    417416 
     
    422421 
    423422{{{#!js 
    424 // a page renderer that simply renders the value of an example content topic instance 
    425 function ExampleContentPageRenderer() { 
    426  
    427     this.render_page = function(topic) { 
     423// a page render that simply renders the value of an example content topic instance 
     424dm4c.add_page_renderer("dm4.example.content_page_renderer", { 
     425 
     426    render_page: function(topic) { 
    428427        dm4c.render.field_label('Content') 
    429428        dm4c.render.page(topic.value) 
    430     } 
    431  
    432     this.render_form = function(topic) { 
     429    }, 
     430 
     431    render_form: function(topic) { 
    433432        var $content = dm4c.render.input(topic.value) 
    434433        dm4c.render.field_label('Content') 
    435434        dm4c.render.page($content) 
    436         return function () { 
     435        return function () { // update topic with value of input 
    437436            topic.value = $.trim($content.val()) 
    438437            dm4c.do_update_topic(topic) 
     
    440439        } 
    441440    } 
    442 } 
     441}) 
    443442}}} 
    444443