var WorkflowStateSelect = (function() {

   var format = function(object) {
      return '<div class="status '+ $(object.element).data('name') +'">' + object.text + '</div>';

   };

   var formatSelection = function(object) {
      return '<div class="status '+ $(object.element).data('name') +'">' + object.text + '</div>';
   };

   var formatResultCssClass = function(object) {
      return 'overstatus';
   };

   return {
      init: function(selectElem){
         selectElem.select2({
            allowClear: true,
            formatResult: format,
            formatSelection: formatSelection,
            formatResultCssClass: formatResultCssClass,
            containerCssClass: 'status'
         });

      }
   }
})();


$(function(){
   if ($('[data-workflow-state="data-workflow-state"]').length == 1) {
      WorkflowStateSelect.init($('[data-workflow-state="data-workflow-state"]'));
   }
});
