This file is indexed.

/usr/share/hotot/js/widget.scrollbar.coffee is in hotot-common 1:0.9.8.14-3.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
class Scrollbar
  constructor: (track, content, margin) ->
    if typeof (track) != 'string'
      @track = $(track)
    else
      @track = track
    if typeof (track) != 'string'
      @content = $(content)
    else
      @content = content
    @disabled = false
    @margin = margin
    @handle = @track.find('.scrollbar_handle')
    @content_height = 0
    @handle_height = 0
    if @track.length ==0 and @content.length == 0 and @handle.length == 0
      return null
    @recalculate_layout()
    @bind()

  disable: ->
    @disabled = true
    @content.css({'overflow-y': 'auto', 'overflow-x': 'hidden'})
    @track.hide()

  enable: ->
    @disabled = false
    @content.css({'overflow-y': 'hidden', 'overflow-x': 'hidden'})
    @track.show()

  recalculate_layout: ->
    if @disabled
      return
    @content_height = @content.height()
    @track.css('height', (@content_height - (@track.outerHeight(true) - @track.outerHeight())) + 'px')
    @track_height = @track.height()
    if (@content.get(0).scrollHeight <= @content_height)
      @hide()
    else
      @show()
      @handle.css(
        'height', (@track_height * @content_height / @content.get(0).scrollHeight) + 'px')
    @handle_height = @handle.height()
    pos = @content.get(0).scrollTop * (@track_height - @handle_height) / @content.get(0).scrollHeight
    @handle.css('top', pos + 'px')
    return

  on_wheel: (ev) ->
    if @disabled
      return
    if event.wheelDeltaY > 1 or event.wheelDeltaY < -1
      if event.wheelDelta
        delta = event.wheelDelta / 2.5
      offsetY = (@content.get(0).offsetTop - delta)
      @scroll(offsetY)
      return false
    else
      return true

  activate: ->
    @on_active = true
    @track.addClass('active')

  deactivate: ->
    @on_active = false
    @track.removeClass('active')
    
  show: ->
    @track.show()

  hide: ->
    @track.hide()
    
  scroll_to: (pos) ->
    @content.get(0).scrollTop = pos

  scroll: (offset) ->
    pos = @content_pos_check(@content.get(0).scrollTop + offset)
    @content.get(0).scrollTop = pos

  scroll_by_handle: (pos) ->
    @handle.css('top', pos + 'px')
    @content.get(0).scrollTop = pos * @content.get(0).scrollHeight / (@track_height - @handle_height)

  handle_pos_check: (pos) ->
    if pos < 0
      pos = 0
    if pos > @track_height - @handle_height
      pos = @track_height - @handle_height
    return pos

  content_pos_check: (pos) ->
    if pos < 0
      pos = 0
    if pos > @content.get(0).scrollHeight
      pos = @content.get(0).scrollHeight
    return pos

  bind: ->
    @handle.mousedown( (ev) =>
      @activate()
      @track_scroll_y = ev.clientY - @track.get(0).offsetTop - @handle.get(0).offsetTop
      root._active_scrollbar = @
      return false
    ).mouseup( (ev) =>
      @deactivate()
    )

    @track.mousedown( (ev) =>
      @activate()
      pos = @handle_pos_check(ev.clientY - @track.offset().top - @handle_height*0.5)
      @scroll_by_handle(pos)
      return false
    ).mouseup( (ev) =>
      @deactivate()
    )
    @content.on('mousewheel', (ev) => @on_wheel ev)
    @content.on('DOMMouseScroll', (ev) => @on_wheel ev)
    @content.scroll( (ev) =>
      if not @on_active and not @disabled
        pos = @content.get(0).scrollTop * (@track_height - @handle_height) / @content.get(0).scrollHeight
        @handle.css('top', pos + 'px')
    )

  destory: ->
    @track.off()
    @track = null
    @handle.off()
    @handle = null
    @content.off()
    @content = null
  
root = exports ? this
root.widget = root.widget ? {}
root.widget.Scrollbar = Scrollbar
root.widget.Scrollbar.register = ->
    $(document).mousemove( (ev) =>
      # notify active scrollbar of its job
      if root._active_scrollbar
        sb = root._active_scrollbar
        if sb.on_active and not sb.disabled and sb.track_scroll_y
          pos = sb.handle_pos_check(ev.clientY - sb.track.get(0).offsetTop - sb.track_scroll_y)
          sb.scroll_by_handle(pos)
        return false
    ).mouseup( (ev) =>
      # notify active scrollbar of releasing mouse.
      if root._active_scrollbar
        sb = root._active_scrollbar
        sb.deactivate()
    )
    return

root._active_scrollbar = null