<commit_before>(function(cms){
  
///// Content Handler Function definition //////////////////////////    
   
   /**
    * Displays the content of the preview item.
    * 
    * @param {Object} itemData server response as JSON object with preview data 
    */
   var showItemPreview = function(itemData) {                         
       //display the html preview
       $('.preview-area').append(itemData['previewdata']['itemhtml']);
       
       // display editable properties
       showEditArea(itemData['previewdata']['properties']);       
       
       //bind click event to preview close button 
       $('#cms-preview div.close-icon').click(function() {
          if ($(this).hasClass('cms-properties-changed')) {
              cms.galleries.loadSearchResults();
              $(this).removeClass('cms-properties-changed');
          }
          $(this).parent().fadeOut('slow');
          
       });
       
       $('.button-bar button').live('mouseover', function() {
             $(this).toggleClass('ui-state-hover', true);
          }).live('mouseout', function() {
             $(this).toggleClass('ui-state-hover', false);
      });                 
       
       // fade in the preview      
       $('#cms-preview').fadeIn('slow');                    
   }   				            
   
   /**
    * Generates html for the editable properties and add to the dom.
    * 
    * @param {Object} itemProperties server response as JSON object with the editable properties
    */     
   var showEditArea = function(itemProperties) {      
       var buttonBar = $('<div class="button-bar"></div>')
                                       .append('<button id="previewSave" disabled="true" class="ui-state-default ui-corner-all">\
                                                    <span class="cms-galleries-button">Save</span>\
                                                </button>')
                                       .append('<button id="previewPublish" class="ui-state-default ui-corner-all">\
                                                    <span class="cms-galleries-button cms-galleries-icon-publish cms-icon-text">Publish</span>\
                                                </button>'); 
                                        
       var target = $('.edit-area').append(buttonBar);
       $('#previewSave').click(saveChangedProperty);
       $('#publishSave').click(publishChangedProperty);
       
       if (cms.galleries.displaySelectButton()) {
           $('.edit-area').find('.button-bar').append('<button id="previewSelect" class="ui-state-default ui-corner-all">\
                                <span class="cms-galleries-button cms-galleries-icon-apply cms-icon-text">Select</span>\
                          </button>');
           $('#previewSelect').click(function() {
               //TODO: 
               var itemType = '';
               var itemId = $(this).closest('#cms-preview').attr('alt');              
               cms.galleries.getContentHandler(itemType)['setValues'][cms.galleries.initValues['dialogMode']](itemId, cms.galleries.initValues['fieldId']);          
           });
       }           
                 
       // generate editable form
       var form = $('<div class="edit-from"></div>');
       $.each(itemProperties, function() {
              $('<div style="margin: 2px;  clear: left;"></div>').attr('alt', this.name).appendTo(form)
                   .append('<span class="cms-item-title" style="margin-right:10px; width: 100px;">' + this.name + '</span>')
                   .append('<span class="cms-item-edit" style=" width: 100px;">' + (this.value ? this.value : '') + '</span>');                                 
           }); 
       $(target).append(form);      
       
       // bind direct input to the editable fields
       $('.cms-item-edit').directInput({
                     marginHack: true,
                     live: false,
                     setValue: markChangedProperty,
                     onChange: function(element, input){
                         $('#previewSave').removeAttr('disabled');
                     }
               });             
   }<commit_msg>- direct publish button is invisible for now<commit_after>(function(cms){
  
///// Content Handler Function definition //////////////////////////    
   
   /**
    * Displays the content of the preview item.
    * 
    * @param {Object} itemData server response as JSON object with preview data 
    */
   var showItemPreview = function(itemData) {                         
       //display the html preview
       $('.preview-area').append(itemData['previewdata']['itemhtml']);
       
       // display editable properties
       showEditArea(itemData['previewdata']['properties']);       
       
       //bind click event to preview close button 
       $('#cms-preview div.close-icon').click(function() {
          if ($(this).hasClass('cms-properties-changed')) {
              cms.galleries.loadSearchResults();
              $(this).removeClass('cms-properties-changed');
          }
          $(this).parent().fadeOut('slow');
          
       });
       
       $('.button-bar button').live('mouseover', function() {
             $(this).toggleClass('ui-state-hover', true);
          }).live('mouseout', function() {
             $(this).toggleClass('ui-state-hover', false);
      });                 
       
       // fade in the preview      
       $('#cms-preview').fadeIn('slow');                    
   }   				            
   
   /**
    * Generates html for the editable properties and add to the dom.
    * 
    * @param {Object} itemProperties server response as JSON object with the editable properties
    */     
   var showEditArea = function(itemProperties) {      
       var buttonBar = $('<div class="button-bar"></div>');
       if (itemProperties.length > 0) {
             buttonBar.append('<button id="previewSave" disabled="true" class="ui-state-default ui-corner-all">\
                                     <span class="cms-galleries-button">Save</span>\
                               </button>');
                     /*.append('<button id="previewPublish" class="ui-state-default ui-corner-all">\
                                    <span class="cms-galleries-button cms-galleries-icon-publish cms-icon-text">Publish</span>\
                                </button>');*/
       }
                                      
                                        
       var target = $('.edit-area').append(buttonBar);
       $('#previewSave').click(saveChangedProperty);
       // TODO: comment in for direct publish
       /* $('#publishSave').click(publishChangedProperty);*/
       
       if (cms.galleries.displaySelectButton()) {
           $('.edit-area').find('.button-bar').append('<button id="previewSelect" class="ui-state-default ui-corner-all">\
                                <span class="cms-galleries-button cms-galleries-icon-apply cms-icon-text">Select</span>\
                          </button>');
           $('#previewSelect').click(function() {               
               var itemType = '';
               var itemId = $(this).closest('#cms-preview').attr('alt');              
               cms.galleries.getContentHandler(itemType)['setValues'][cms.galleries.initValues['dialogMode']](itemId, cms.galleries.initValues['fieldId']);          
           });
       }           
                 
       // generate editable form
       var form = $('<div class="edit-from"></div>');
       $.each(itemProperties, function() {
              $('<div style="margin: 2px;  clear: left;"></div>').attr('alt', this.name).appendTo(form)
                   .append('<span class="cms-item-title" style="margin-right:10px; width: 100px;">' + this.name + '</span>')
                   .append('<span class="cms-item-edit" style=" width: 100px;">' + (this.value ? this.value : '') + '</span>');                                 
           }); 
       $(target).append(form);      
       
       // bind direct input to the editable fields
       $('.cms-item-edit').directInput({
                     marginHack: true,
                     live: false,
                     setValue: markChangedProperty,
                     onChange: function(element, input){
                         $('#previewSave').removeAttr('disabled');
                     }
               });             
   }
{'fraction_non_alphanumeric': 0.15422058648937434, 'fraction_numerical': 0.0022557283628160986, 'mean_word_length': 1.525937031484258, 'pattern_counts': {'":': 0, '<': 47, '<?xml version=': 0, '>': 48, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 15, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1799364', 'n_tokens_mistral': 2140, 'n_tokens_neox': 2014, 'n_words': 383}