Changes between Version 7 and Version 8 of AnotherPluginDevelopmentGuide
- Timestamp:
- 18.07.2012 16:34:41 (12 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AnotherPluginDevelopmentGuide
v7 v8 331 331 A plugin that loads some type specific renderer and adds a custom command: 332 332 {{{#!js 333 dm4c.add_plugin('d e.deepamehta.example', function() {333 dm4c.add_plugin('dm4.example.plugin', function() { 334 334 335 335 // load some renderer and a style sheet … … 342 342 var name = prompt('Example name', 'Another Example') 343 343 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) 345 345 } 346 346 … … 349 349 var url = '/example/increase/' + dm4c.selected_object.id, 350 350 topic = dm4c.restc.request('GET', url) 351 dm4c.show_topic( topic, 'show', null, true)351 dm4c.show_topic(new Topic(topic), 'show', null, true) 352 352 } 353 353 … … 382 382 type_uri: "dm4.webclient.view_config", 383 383 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" 386 386 } 387 387 } … … 397 397 398 398 {{{#!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 400 dm4c.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 }) 416 415 }}} 417 416 … … 422 421 423 422 {{{#!js 424 // a page render erthat simply renders the value of an example content topic instance425 function ExampleContentPageRenderer(){426 427 this.render_page =function(topic) {423 // a page render that simply renders the value of an example content topic instance 424 dm4c.add_page_renderer("dm4.example.content_page_renderer", { 425 426 render_page: function(topic) { 428 427 dm4c.render.field_label('Content') 429 428 dm4c.render.page(topic.value) 430 } 431 432 this.render_form =function(topic) {429 }, 430 431 render_form: function(topic) { 433 432 var $content = dm4c.render.input(topic.value) 434 433 dm4c.render.field_label('Content') 435 434 dm4c.render.page($content) 436 return function () { 435 return function () { // update topic with value of input 437 436 topic.value = $.trim($content.val()) 438 437 dm4c.do_update_topic(topic) … … 440 439 } 441 440 } 442 } 441 }) 443 442 }}} 444 443