/**
 * Object completion widgets behavior
 */
jQuery.fn.objectCompletion = function(s) {
  var settings = jQuery.extend({ 
    'complete_event' : null, 
    'open_event' : null
  }, s);
  
  return this.each(function() {
    var wrapper = $(this);
    
    // Handle completion event
    if(settings['complete_event']) {
      App.Wireframe.Events.bind(settings['complete_event'], function(event, obj) {
        wrapper.text(App.lang('Completed by :user on :date', {
          'user' : obj['completed_by']['short_display_name'], 
          'date' : obj['completed_on']['formatted']
        }));
      });
    } // if
    
    // Handle reopening event
    if(settings['open_event']) {
      App.Wireframe.Events.bind(settings['open_event'], function(event, obj) {
        wrapper.text(App.lang('Open'));
      });
    } // if
  });
  
};