<commit_before># Tres
# ====

# The whole framework should fit nicely in a single file. Avoid magic,
# avoid indirection

# Grab all variables to shorter references we'll use throughout
Tres      = {}
$         = window.jQuery
_         = window._
Backbone  = window.Backbone
JST       = window.JST
$window   = $ window
$body     = $ 'body'
make      = Backbone.View.prototype.make

# Default screen template
defaultTemplate = _.template """
  <header></header>
  <h1>Tres</h1>
  <p>Welcome to Tres</p>
"""
# ---

# Tres.Device handles/exposes device events (orientation change, accellerometer,
# etc), screen width, and other hardware-related goodies
class Device
  constructor: ->
    _.extend @, Backbone.Events
    $window.on 'orientationchange', =>
      @trigger 'orientation:change'
      window.scrollTo 0, 0

  width: -> window.outerWidth
  height: -> window.outerHeight
  orientation: ->

Tres.Device = new Device

# ---

# Tres.Screen is the base screen class. So you'll pretty have one of these for
# each "route" in your app
class Tres.Screen extends Backbone.View

  # Defaults to using sections for screens
  tagName: 'section'

  # Ensure one can still declare events in a view without getting in the
  # way of the defaults
  __events:
    "click a[href]:not([href^='http://'])": 'touchLink'

    # Provide a convenience method `submit` which gets fired when you
    # submit a form in a screen. You can still trap forms normally.
    # This is just a shortcut in case you have 1 form in a screen
    "submit form": '__submit'

  events: {}

  initialize: (options = {}) ->
    _.extend @, options

  # Returns the title of the screen, which will only exist if there's a
  # header with a <h1> inside of it
  title: (title = null) ->
    if title?
      @$el.find('h1').html title
    else
      @$el.find('h1').html()

  # Renders the screen's template into the container element, and applies
  # the screen's events and the default screen class
  render: ->
    @$el.html (@template or defaultTemplate)(@model)
    @$el.addClass 'screen'
    @delegateEvents _.extend @events, @__events
    @

  # Embeds a Tres.Screen into the <body>. Returns false in case it's already
  # embedded
  embed: ->
    return false if @embedded
    @render()
    $body.prepend @el
    @embedded = true
    @

  # Click/touch on links will trigger pushState, but stay in the app
  touchLink: (event) ->
    event.preventDefault()
    Tres.Router.navigate $(event.currentTarget).attr('href'), true

  # Runs whatever @submit method is declared, with the added bonus of
  # un-focusing any text fields that are currently focused
  __submit: (event) ->
    @submit.apply @, arguments
    @$el.find(':focus').blur()

  # Default @submit to noop
  submit: ->

  # Sets the class "current" to this screen, removing the class from
  # whatever other sections that have it. Call the `active` method in
  # case a screen has one. Removes -webkit-transform to prevent Webkit from
  # screwing position: fixed
  activate: ->
    if not @modal then $body.find('>section').removeClass('current')
    @$el.addClass 'current'
    @$el.addClass 'modal' if @modal
    @$el.css 'min-height', window.innerHeight+50
    @active.apply @, arguments if _.isFunction @active

# ---

# This class is used as controller for each Tres.List item
class Tres.ListEntry extends Backbone.View
  initialize : (options = {}) ->
    _.extend @, options

  render: ->
    @$el.html @template @model
    @delegateEvents 'click': 'touch' if _.isFunction @url
    @

  # If a @url method is defined, means we want the user to touch and
  # visit the URL
  touch: (event) ->
    Tres.Router.navigate @url(), true
<commit_msg>Workarounds for device height/width bug and translate3d introducing bugs in Mobile Safari<commit_after># Tres
# ====

# The whole framework should fit nicely in a single file. Avoid magic,
# avoid indirection

# Grab all variables to shorter references we'll use throughout
Tres      = {}
$         = window.jQuery
_         = window._
Backbone  = window.Backbone
JST       = window.JST
$window   = $ window
$body     = $ 'body'
make      = Backbone.View.prototype.make

# Default screen template
defaultTemplate = _.template """
  <header></header>
  <h1>Tres</h1>
  <p>Welcome to Tres</p>
"""
# ---

# Tres.Device handles/exposes device events (orientation change, accellerometer,
# etc), screen width, and other hardware-related goodies
class Device
  constructor: ->
    _.extend @, Backbone.Events
    $window.on 'orientationchange', =>
      @trigger 'orientation:change'
      # Fix <html> not stretching beyond 320px
      $('html').width window.innerWidth
      window.scrollTo 0, 0

  width: -> window.outerWidth
  height: -> window.outerHeight
  orientation: ->

Tres.Device = new Device

# ---

# Tres.Screen is the base screen class. So you'll pretty have one of these for
# each "route" in your app
class Tres.Screen extends Backbone.View

  # Defaults to using sections for screens
  tagName: 'section'

  # Ensure one can still declare events in a view without getting in the
  # way of the defaults
  __events:
    "click a[href]:not([href^='http://'])": 'touchLink'

    # Provide a convenience method `submit` which gets fired when you
    # submit a form in a screen. You can still trap forms normally.
    # This is just a shortcut in case you have 1 form in a screen
    "submit form": '__submit'

  events: {}

  initialize: (options = {}) ->
    _.extend @, options

  # Returns the title of the screen, which will only exist if there's a
  # header with a <h1> inside of it
  title: (title = null) ->
    if title?
      @$el.find('h1').html title
    else
      @$el.find('h1').html()

  # Renders the screen's template into the container element, and applies
  # the screen's events and the default screen class
  render: ->
    @$el.html (@template or defaultTemplate)(@model)
    @$el.addClass 'screen'
    @delegateEvents _.extend @events, @__events
    @

  # Embeds a Tres.Screen into the <body>. Returns false in case it's already
  # embedded
  embed: ->
    return false if @embedded
    @render()
    $body.prepend @el
    @embedded = true
    @

  # Click/touch on links will trigger pushState, but stay in the app
  touchLink: (event) ->
    event.preventDefault()
    Tres.Router.navigate $(event.currentTarget).attr('href'), true

  # Runs whatever @submit method is declared, with the added bonus of
  # un-focusing any text fields that are currently focused
  __submit: (event) ->
    @submit.apply @, arguments
    @$el.find(':focus').blur()

  # Default @submit to noop
  submit: ->

  # Sets the class "current" to this screen, removing the class from
  # whatever other sections that have it. Call the `active` method in
  # case a screen has one. Removes -webkit-transform to prevent Webkit from
  # screwing a whole lot of stuff
  activate: ->
    if not @modal
      $body.find('>section')
        .removeClass('current')
        .css '-webkit-transform', ''
    @$el.addClass 'current'
    @$el.addClass 'modal' if @modal
    @$el.css
      'min-height': window.innerHeight+50
      '-webkit-transform': 'none'
    @active.apply @, arguments if _.isFunction @active

# ---

# This class is used as controller for each Tres.List item
class Tres.ListEntry extends Backbone.View
  initialize : (options = {}) ->
    _.extend @, options

  render: ->
    @$el.html @template @model
    @delegateEvents 'click': 'touch' if _.isFunction @url
    @

  # If a @url method is defined, means we want the user to touch and
  # visit the URL
  touch: (event) ->
    Tres.Router.navigate @url(), true

{'fraction_non_alphanumeric': 0.11219000131216376, 'fraction_numerical': 0.0031491930192888073, 'mean_word_length': 3.073757349011224, 'pattern_counts': {'":': 4, '<': 20, '<?xml version=': 0, '>': 54, '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': '1842105', 'n_tokens_mistral': 2314, 'n_tokens_neox': 2248, 'n_words': 848}