<commit_before>define(function (require) {
  'use strict';

  // foreign modules

  var $ = require('jquery');
  var _ = require('underscore');
  var Backbone = require('backbone');
  var Forms = require('BlinkForms');
  var Mustache = require('mustache');
  var Promise = require('feature!promises');

  // local modules

  var Template = require('text!bic/template/form/controls.mustache');
  var app = require('bic/model-application');
  var API = require('bic/api');
  var USER_ACTIONS = require('bic/enum-user-actions');
  var MODEL_STATUS = require('bic/enum-model-status');
  var uiTools = require('bic/lib/ui-tools');

  // this module

  var isHTML = function (string) {
    var html$;
    var Node = window.Node;
    if (!string || typeof string !== 'string' || !string.trim()) {
      return false;
    }
    if (typeof Node === 'undefined' || !Node.TEXT_NODE) {
      return true; // the string _might_ be HTML, we just can't tell
    }
    html$ = $.parseHTML(string);
    return !html$.every(function (el) {
      return el.nodeType === Node.TEXT_NODE;
    });
  };

  var leaveViewBy = function (view, userAction) {
    // helper function for better control over what happens when
    // an item is added to the queue
    return function (updatedModel) {
      view.formLeave(userAction);
      return updatedModel;
    };
  };

  var enableSubmit = function () {
    return uiTools.enableElement('#submit');
  };

  var enableSave = function () {
    return uiTools.enableElement('#save');
  };

  var FormControlView = Backbone.View.extend({

    events: {
      'click #FormControls #submit:not([disabled])': 'formSubmit',
      'click #FormControls #close': 'formClose',
      'click #FormControls #save': 'formSave2',
      'click #nextFormPage': 'nextFormPage',
      'click #previousFormPage': 'previousFormPage',
      'click #firstFormPage': 'firstFormPage',
      'click #lastFormPage': 'lastFormPage'
    },

    render: function () {
      var view, options;
      var pages, index;
      view = this;
      options = {
        hasStorage: app.hasStorage()
      };

      if (Forms.current.get('pages').length > 1) {
        pages = Forms.current.get('pages');
        index = pages.current.index();
        options.pages = {
          current: index + 1,
          total: pages.length,
          greaterThanTwo: pages.length > 2
        };

        if (pages.current.index() !== 0) {
          options.pages.previous = true;
        }

        if (pages.current.index() !== pages.length - 1) {
          options.pages.next = true;
        }
      }

      view.$el.html(Mustache.render(view.constructor.template, options));
      $.mobile.activePage.trigger('pagecreate');

      return view;
    },

    firstFormPage: function () {
      var view, index;

      view = this;
      index = Forms.current.get('pages').current.index();

      if (index > 0) {
        Forms.current.get('pages').goto(0);
        view.render();
      }
    },

    lastFormPage: function () {
      var view, index, len;

      view = this;
      len = Forms.current.get('pages').length;
      index = Forms.current.get('pages').current.index();

      //only move and render if required
      if (index < len - 1) {
        Forms.current.get('pages').goto(len - 1);
        view.render();<commit_msg>BIC-179 # turning Forms pages over-enhances elements<commit_after>define(function (require) {
  'use strict';

  // foreign modules

  var $ = require('jquery');
  var _ = require('underscore');
  var Backbone = require('backbone');
  var Forms = require('BlinkForms');
  var Mustache = require('mustache');
  var Promise = require('feature!promises');

  // local modules

  var Template = require('text!bic/template/form/controls.mustache');
  var app = require('bic/model-application');
  var API = require('bic/api');
  var USER_ACTIONS = require('bic/enum-user-actions');
  var MODEL_STATUS = require('bic/enum-model-status');
  var uiTools = require('bic/lib/ui-tools');

  // this module

  var isHTML = function (string) {
    var html$;
    var Node = window.Node;
    if (!string || typeof string !== 'string' || !string.trim()) {
      return false;
    }
    if (typeof Node === 'undefined' || !Node.TEXT_NODE) {
      return true; // the string _might_ be HTML, we just can't tell
    }
    html$ = $.parseHTML(string);
    return !html$.every(function (el) {
      return el.nodeType === Node.TEXT_NODE;
    });
  };

  var leaveViewBy = function (view, userAction) {
    // helper function for better control over what happens when
    // an item is added to the queue
    return function (updatedModel) {
      view.formLeave(userAction);
      return updatedModel;
    };
  };

  var enableSubmit = function () {
    return uiTools.enableElement('#submit');
  };

  var enableSave = function () {
    return uiTools.enableElement('#save');
  };

  var FormControlView = Backbone.View.extend({

    events: {
      'click #FormControls #submit:not([disabled])': 'formSubmit',
      'click #FormControls #close': 'formClose',
      'click #FormControls #save': 'formSave2',
      'click #nextFormPage': 'nextFormPage',
      'click #previousFormPage': 'previousFormPage',
      'click #firstFormPage': 'firstFormPage',
      'click #lastFormPage': 'lastFormPage'
    },

    render: function () {
      var view, options;
      var pages, index;
      view = this;
      options = {
        hasStorage: app.hasStorage()
      };

      if (Forms.current.get('pages').length > 1) {
        pages = Forms.current.get('pages');
        index = pages.current.index();
        options.pages = {
          current: index + 1,
          total: pages.length,
          greaterThanTwo: pages.length > 2
        };

        if (pages.current.index() !== 0) {
          options.pages.previous = true;
        }

        if (pages.current.index() !== pages.length - 1) {
          options.pages.next = true;
        }
      }

      view.$el.html(Mustache.render(view.constructor.template, options));
      view.$el.trigger('create');
      return view;
    },

    firstFormPage: function () {
      var view, index;

      view = this;
      index = Forms.current.get('pages').current.index();

      if (index > 0) {
        Forms.current.get('pages').goto(0);
        view.render();
      }
    },

    lastFormPage: function () {
      var view, index, len;

      view = this;
      len = Forms.current.get('pages').length;
      index = Forms.current.get('pages').current.index();

      //only move and render if required
      if (index < len - 1) {
        Forms.current.get('pages').goto(len - 1);
        view.render();
{'fraction_non_alphanumeric': 0.14988713318284425, 'fraction_numerical': 0.0034612490594431904, 'mean_word_length': 2.54075652637187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '7124032', 'n_tokens_mistral': 2042, 'n_tokens_neox': 1943, 'n_words': 472}