<commit_before>angular.module('bp').service('bpView', function($rootScope) {
  function BpView() {
    this.onViewContentLoaded  = angular.bind(this, this.onViewContentLoaded)
    this.onStateChangeStart   = angular.bind(this, this.onStateChangeStart)
  }

  BpView.prototype.listen = function() {
    $rootScope.$on('$stateChangeStart', this.onStateChangeStart)
    $rootScope.$on('$viewContentLoaded', this.onViewContentLoaded)
  }

  BpView.prototype.onStateChangeStart = function(
    event,
    toState,
    toParams,
    fromState) {

    var direction = toParams.direction ||
      this.getDirection(fromState, toState)

    var type = toParams.transition ||
      this.getType(fromState, toState, direction)

    this.setTransition(type, direction)
  }

  BpView.prototype.onViewContentLoaded = function() {
    var $views = angular.element('[ui-view], ui-view')
    if (this.transition != null) {
      $views
        .removeClass(this.lastTransition)
        .addClass(this.transition)
      this.lastTransition = this.transition
    } else {
      $views.removeClass(this.lastTransition)
    }
  }

  BpView.prototype.setTransition = function(type, direction) {
    if (type != null && direction != null) {
      this.transition = type + '-' + direction
    } else {
      this.transition = null
    }
  }

  BpView.prototype.getDirection = function(from, to) {
    if (from.url === '^') {
      return null
    }

    if (angular.isObject(to.data) && to.data.up === from.name) {
      return 'normal'
    }

    if (angular.isObject(from.data) && from.data.up === to.name) {
      return 'reverse'
    }

    var fromSegs = this._getURLSegments(from)
    var toSegs   = this._getURLSegments(to)
    var fromLen  = fromSegs.length
    var toLen    = toSegs.length
    var diff     = toLen - fromLen

    if (diff > 0 && angular.equals(fromSegs, toSegs.slice(0,toLen - diff))) {
      return 'normal'
    } else if (diff < 0 &&
      angular.equals(toSegs, fromSegs.slice(0, fromLen  + diff))) {

      return 'reverse'
    }
    return null
  }

  BpView.prototype.getType = function(from, to, direction) {
    if (direction === 'reverse') {
      if (angular.isObject(from.data)) {
        return from.data.transition || null
      }
    } else {
      if (angular.isObject(to.data)) {
        return to.data.transition || null
      }
    }
    return null
  }

  BpView.prototype._getURLSegments = function(state) {
    return (state.url || '')
      .replace(/\/$/, '')
      .split('/')
  }

  return new BpView()
})<commit_msg>feat(view): platform specific transition defaults<commit_after>angular.module('bp').service('bpView', function($rootScope, bpConfig) {
  function BpView() {
    this.onViewContentLoaded  = angular.bind(this, this.onViewContentLoaded)
    this.onStateChangeStart   = angular.bind(this, this.onStateChangeStart)
  }

  BpView.prototype.listen = function() {
    $rootScope.$on('$stateChangeStart', this.onStateChangeStart)
    $rootScope.$on('$viewContentLoaded', this.onViewContentLoaded)
  }

  BpView.prototype.onStateChangeStart = function(
    event,
    toState,
    toParams,
    fromState) {

    var direction = toParams.direction ||
      this.getDirection(fromState, toState)

    var type = toParams.transition ||
      this.getType(fromState, toState, direction)

    this.setTransition(type, direction)
  }

  BpView.prototype.onViewContentLoaded = function() {
    var $views = angular.element('[ui-view], ui-view')
    if (this.transition != null) {
      $views
        .removeClass(this.lastTransition)
        .addClass(this.transition)
      this.lastTransition = this.transition
    } else {
      $views.removeClass(this.lastTransition)
    }
  }

  BpView.prototype.setTransition = function(type, direction) {
    if (type != null && direction != null) {
      this.transition = type + '-' + direction
    } else {
      this.transition = null
    }
  }

  BpView.prototype.getDirection = function(from, to) {
    if (from.url === '^') {
      return null
    }

    if (angular.isObject(to.data) && to.data.up === from.name) {
      return 'normal'
    }

    if (angular.isObject(from.data) && from.data.up === to.name) {
      return 'reverse'
    }

    var fromSegs = this._getURLSegments(from)
    var toSegs   = this._getURLSegments(to)
    var fromLen  = fromSegs.length
    var toLen    = toSegs.length
    var diff     = toLen - fromLen

    if (diff > 0 && angular.equals(fromSegs, toSegs.slice(0,toLen - diff))) {
      return 'normal'
    } else if (diff < 0 &&
      angular.equals(toSegs, fromSegs.slice(0, fromLen  + diff))) {

      return 'reverse'
    }
    return null
  }

  BpView.prototype.getType = function(from, to, direction) {
    var typeFromState = function(state) {
      var data = state.data
      var hasData = angular.isObject(data)

      if (hasData && angular.isString(data.transition)) {
        return data.transition
      } else if (hasData && data.modal) {
        return 'cover'
      } else {
        return bpConfig.platform === 'ios' ? 'slide' : 'scale'
      }
    }

    if (direction === 'reverse') {
      return typeFromState(from)
    } else {
      return typeFromState(to)
    }
  }

  BpView.prototype._getURLSegments = function(state) {
    return (state.url || '')
      .replace(/\/$/, '')
      .split('/')
  }

  return new BpView()
})
{'fraction_non_alphanumeric': 0.13635515761984704, 'fraction_numerical': 0.0014922589069203507, 'mean_word_length': 2.721027064538515, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5264560', 'n_tokens_mistral': 1737, 'n_tokens_neox': 1710, 'n_words': 321}