<commit_before>/* global lib */

'use strict'

import './carrousel'
import './slider.css'

const DEFAULT_INTERVAL = 3000

let extend, Component

function idleWhenPageDisappear (slider) {
  function handlePageShow () {
    slider.isPageShow = true
    slider.autoPlay && !slider.isDomRendering && slider.play()
  }
  function handlePageHide () {
    slider.isPageShow = false
    slider.stop()
  }
  global.addEventListener('pageshow', handlePageShow)
  global.addEventListener('pagehide', handlePageHide)
  document.addEventListener('visibilitychange', function () {
    if (document.visibilityState === 'visible') {
      handlePageShow()
    }
    else if (document.visibilityState === 'hidden') {
      handlePageHide()
    }
  })
}

function idleWhenDomRendering (slider) {
  global.addEventListener('renderend', function () {
    slider.isDomRendering = false
    slider.autoPlay && slider.isPageShow && slider.play()
  })
  global.addEventListener('renderbegin', function () {
    slider.isDomRendering = true
    slider.stop()
  })
}

function updateIndicators (slider) {
  slider.indicator && slider.indicator.setIndex(slider.currentIndex)
}

function getSliderChangeHandler (slider) {
  if (!slider._sliderChangeHandler) {
    slider._sliderChangeHandler = function (e) {
      const index = this.carrousel.items.index
      this.currentIndex = index
      updateIndicators(this)
      this.dispatchEvent('change', { index: index })
    }.bind(slider)
  }
  return slider._sliderChangeHandler
}

function doRender (slider) {
  slider.createChildren()
  slider.onAppend()
}

const proto = {
  create () {
    const node = document.createElement('div')
    node.classList.add('slider')
    node.style.position = 'relative'
    node.style.overflow = 'hidden'
    return node
  },

  createChildren () {
    const componentManager = this.getComponentManager()

    // recreate slider container.
    if (this.sliderContainer) {
      this.node.removeChild(this.sliderContainer)
    }
    if (this.indicator) {
      this.indicator.node.parentNode.removeChild(this.indicator.node)
    }
    this.children = []

    const sliderContainer = document.createElement('ul')
    sliderContainer.style.listStyle = 'none'
    this.node.appendChild(sliderContainer)<commit_msg>* [html5] fix slider container's style. (#2157)<commit_after>/* global lib */

'use strict'

import './carrousel'
import './slider.css'

const DEFAULT_INTERVAL = 3000

let extend, Component

function idleWhenPageDisappear (slider) {
  function handlePageShow () {
    slider.isPageShow = true
    slider.autoPlay && !slider.isDomRendering && slider.play()
  }
  function handlePageHide () {
    slider.isPageShow = false
    slider.stop()
  }
  global.addEventListener('pageshow', handlePageShow)
  global.addEventListener('pagehide', handlePageHide)
  document.addEventListener('visibilitychange', function () {
    if (document.visibilityState === 'visible') {
      handlePageShow()
    }
    else if (document.visibilityState === 'hidden') {
      handlePageHide()
    }
  })
}

function idleWhenDomRendering (slider) {
  global.addEventListener('renderend', function () {
    slider.isDomRendering = false
    slider.autoPlay && slider.isPageShow && slider.play()
  })
  global.addEventListener('renderbegin', function () {
    slider.isDomRendering = true
    slider.stop()
  })
}

function updateIndicators (slider) {
  slider.indicator && slider.indicator.setIndex(slider.currentIndex)
}

function getSliderChangeHandler (slider) {
  if (!slider._sliderChangeHandler) {
    slider._sliderChangeHandler = function (e) {
      const index = this.carrousel.items.index
      this.currentIndex = index
      updateIndicators(this)
      this.dispatchEvent('change', { index: index })
    }.bind(slider)
  }
  return slider._sliderChangeHandler
}

function doRender (slider) {
  slider.createChildren()
  slider.onAppend()
}

const proto = {
  create () {
    const node = document.createElement('div')
    node.classList.add('slider')
    node.classList.add('weex-container')
    node.style.position = 'relative'
    node.style.overflow = 'hidden'
    return node
  },

  createChildren () {
    const componentManager = this.getComponentManager()

    // recreate slider container.
    if (this.sliderContainer) {
      this.node.removeChild(this.sliderContainer)
    }
    if (this.indicator) {
      this.indicator.node.parentNode.removeChild(this.indicator.node)
    }
    this.children = []

    const sliderContainer = document.createElement('ul')
    sliderContainer.style.listStyle = 'none'
    this.node.appendChild(sliderContainer)
{'fraction_non_alphanumeric': 0.12242686890574214, 'fraction_numerical': 0.0028169014084507044, 'mean_word_length': 3.7295081967213113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5624595', 'n_tokens_mistral': 1387, 'n_tokens_neox': 1330, 'n_words': 252}