<commit_before>/**
 * The JazzeePageBranching type
  @extends JazzeePage
 */
function JazzeePageBranching(){}
JazzeePageBranching.prototype = new JazzeePage();
JazzeePageBranching.prototype.constructor = JazzeePageBranching;

/**
 * Override JazzeePage::newPage to set variable defaults
 * @returns {JazzeePageBranching}
 */
JazzeePageBranching.prototype.newPage = function(id,title,typeId,typeName,typeClass,status,pageBuilder){
  var page = JazzeePage.prototype.newPage.call(this, id,title,typeId,typeName,typeClass,status,pageBuilder);
  page.setVariable('branchingElementLabel', title);
  return page;
};

JazzeePageBranching.prototype.workspace = function(){
  JazzeePage.prototype.workspace.call(this);
  var pageClass = this;
  $('#pageToolbar').append(this.pagePropertiesButton());
  $('#workspace').append(this.listBranchesBlock());
};

/**
 * Create the page properties dropdown
*/
JazzeePageBranching.prototype.pageProperties = function(){
  var pageClass = this;
  
  var div = $('<div>');
  div.append(this.isRequiredButton());
//  div.append(this.showAnswerStatusButton());
//  if(pageClass.answerStatusDisplay == 1){
//    var button = $('<button>').html('Edit Answer Status Display').attr('id', 'editDisplayButton').bind('click', function(e){
//      $('.qtip').qtip('api').hide();
//      pageClass.displayAnswerStatusForm();
//    });
//    button.button({
//      icons: {
//        primary: 'ui-icon-newwin'
//      }
//    });
//    div.append(button);
//  }
//  
//  $('#answerStatusDisplayButton', div).bind('click',function(e){
//    if(pageClass.answerStatusDisplay == 0){
//      pageClass.setVariable('answerStatusTitle',  null);
//      pageClass.setVariable('answerStatusText', null);
//    }
//    //rebuild the tooltip so the edit status display button will show up or be hidden
//    div.replaceWith(pageClass.pageProperties());
//  });
  if(!this.isGlobal || this.pageBuilder.editGlobal) div.append(this.editBranchingElementLabelButton());
  var slider = $('<div>');
  slider.slider({
    value: this.min,
    min: 0,
    max: 20,
    step: 1,
    slide: function( event, ui ) {
      pageClass.setProperty('min', ui.value);
      $('#minValue').html(pageClass.min == 0?'No Minimum':pageClass.min);
    }
  });
  div.append($('<p>').html('Minimum Answers Required ').append($('<span>').attr('id', 'minValue').html(this.min == 0?'No Minimum':this.min)));
  div.append(slider);
  
  
  var slider = $('<div>');
  slider.slider({
    value: this.max,
    min: 0,
    max: 20,
    step: 1,
    slide: function( event, ui ) {
      pageClass.setProperty('max', ui.value);
      $('#maxValue').html(pageClass.max == 0?'No Maximum':pageClass.max);
    }
  });
  div.append($('<p>').html('Maximum Answers Allowed ').append($('<span>').attr('id', 'maxValue').html(this.max == 0?'No Maximum':this.max)));
  div.append(slider);
  
  return div;
};

JazzeePageBranching.prototype.listBranchesBlock = function(){
  var div = $('<div>').append($('<h5>').html('Branched Pages'));
  var pageClass = this;
  var ol = $('<ol>').addClass('page-list');
  for(var i in this.children){
    var branch = this.children[i];
    var li = $('<li>').html(branch.title);
    var button = $('<button>').html('Edit').data('page', branch).bind('click',function(){
      var page = $(this).data('page');
      page.workspace();
      //empty the toolbar becuase the delete/copy are going to be wrong
      $('#pageToolbar .copy').remove();
      $('#pageToolbar .delete').remove();
      $('#pageToolbar .properties').remove();
      var button = $('<button>').html('Back to parent').bind('click', function(){
        pageClass.workspace();
      });
      button.button({
        icons: {
          primary: 'ui-icon-arrowreturnthick-1-s'
        }
      });
      $('#pageToolbar').prepend(button);
      
      var button = $('<button>').html('Delete Branch').data('page', page).bind('click', function(e){
        $('#editPage').effect('explode',500);
        pageClass.deleteChild($(e.target).parent().data('page'));
      });
      button.button({
        icons: {
          primary: 'ui-icon-trash'
        }
      });<commit_msg>Fix deleteing branching child pages in firefox (and probalby others).<commit_after>/**
 * The JazzeePageBranching type
  @extends JazzeePage
 */
function JazzeePageBranching(){}
JazzeePageBranching.prototype = new JazzeePage();
JazzeePageBranching.prototype.constructor = JazzeePageBranching;

/**
 * Override JazzeePage::newPage to set variable defaults
 * @returns {JazzeePageBranching}
 */
JazzeePageBranching.prototype.newPage = function(id,title,typeId,typeName,typeClass,status,pageBuilder){
  var page = JazzeePage.prototype.newPage.call(this, id,title,typeId,typeName,typeClass,status,pageBuilder);
  page.setVariable('branchingElementLabel', title);
  return page;
};

JazzeePageBranching.prototype.workspace = function(){
  JazzeePage.prototype.workspace.call(this);
  var pageClass = this;
  $('#pageToolbar').append(this.pagePropertiesButton());
  $('#workspace').append(this.listBranchesBlock());
};

/**
 * Create the page properties dropdown
*/
JazzeePageBranching.prototype.pageProperties = function(){
  var pageClass = this;
  
  var div = $('<div>');
  div.append(this.isRequiredButton());
//  div.append(this.showAnswerStatusButton());
//  if(pageClass.answerStatusDisplay == 1){
//    var button = $('<button>').html('Edit Answer Status Display').attr('id', 'editDisplayButton').bind('click', function(e){
//      $('.qtip').qtip('api').hide();
//      pageClass.displayAnswerStatusForm();
//    });
//    button.button({
//      icons: {
//        primary: 'ui-icon-newwin'
//      }
//    });
//    div.append(button);
//  }
//  
//  $('#answerStatusDisplayButton', div).bind('click',function(e){
//    if(pageClass.answerStatusDisplay == 0){
//      pageClass.setVariable('answerStatusTitle',  null);
//      pageClass.setVariable('answerStatusText', null);
//    }
//    //rebuild the tooltip so the edit status display button will show up or be hidden
//    div.replaceWith(pageClass.pageProperties());
//  });
  if(!this.isGlobal || this.pageBuilder.editGlobal) div.append(this.editBranchingElementLabelButton());
  var slider = $('<div>');
  slider.slider({
    value: this.min,
    min: 0,
    max: 20,
    step: 1,
    slide: function( event, ui ) {
      pageClass.setProperty('min', ui.value);
      $('#minValue').html(pageClass.min == 0?'No Minimum':pageClass.min);
    }
  });
  div.append($('<p>').html('Minimum Answers Required ').append($('<span>').attr('id', 'minValue').html(this.min == 0?'No Minimum':this.min)));
  div.append(slider);
  
  
  var slider = $('<div>');
  slider.slider({
    value: this.max,
    min: 0,
    max: 20,
    step: 1,
    slide: function( event, ui ) {
      pageClass.setProperty('max', ui.value);
      $('#maxValue').html(pageClass.max == 0?'No Maximum':pageClass.max);
    }
  });
  div.append($('<p>').html('Maximum Answers Allowed ').append($('<span>').attr('id', 'maxValue').html(this.max == 0?'No Maximum':this.max)));
  div.append(slider);
  
  return div;
};

JazzeePageBranching.prototype.listBranchesBlock = function(){
  var div = $('<div>').append($('<h5>').html('Branched Pages'));
  var pageClass = this;
  var ol = $('<ol>').addClass('page-list');
  for(var i in this.children){
    var branch = this.children[i];
    var li = $('<li>').html(branch.title);
    var button = $('<button>').html('Edit').data('page', branch).bind('click',function(){
      var page = $(this).data('page');
      page.workspace();
      //empty the toolbar becuase the delete/copy are going to be wrong
      $('#pageToolbar .copy').remove();
      $('#pageToolbar .delete').remove();
      $('#pageToolbar .properties').remove();
      var button = $('<button>').html('Back to parent').bind('click', function(){
        pageClass.workspace();
      });
      button.button({
        icons: {
          primary: 'ui-icon-arrowreturnthick-1-s'
        }
      });
      $('#pageToolbar').prepend(button);
      
      var button = $('<button>').html('Delete Branch').data('page', page).bind('click', function(e){
        pageClass.deleteChild($(this).data('page'));
        $('#editPage').effect('explode',500);
        pageClass.workspace();
      });
      button.button({
        icons: {
          primary: 'ui-icon-trash'
        }
      });
{'fraction_non_alphanumeric': 0.19662113587347232, 'fraction_numerical': 0.00455307931943446, 'mean_word_length': 3.629506378258458, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7478303', 'n_tokens_mistral': 2707, 'n_tokens_neox': 2646, 'n_words': 468}