Dummy.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import Plugin from './Plugin'
  2. import html from '../core/html'
  3. /**
  4. * Dummy
  5. *
  6. */
  7. export default class Dummy extends Plugin {
  8. constructor (core, opts, props) {
  9. super(core, opts)
  10. this.type = 'acquirer'
  11. this.id = 'Dummy'
  12. this.title = 'Mr. Plugin'
  13. this.props = props
  14. // set default options
  15. const defaultOptions = {}
  16. // merge default options with the ones set by user
  17. this.opts = Object.assign({}, defaultOptions, opts)
  18. this.strange = html`<h1>this is strange 1</h1>`
  19. this.render = this.render.bind(this)
  20. this.install = this.install.bind(this)
  21. }
  22. addFakeFileJustToTest () {
  23. const blob = new Blob(
  24. ['data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMTIwIDEyMCI+CiAgPGNpcmNsZSBjeD0iNjAiIGN5PSI2MCIgcj0iNTAiLz4KPC9zdmc+Cg=='],
  25. {type: 'image/svg+xml'}
  26. )
  27. const file = {
  28. source: 'acceptance-test',
  29. name: 'test-file',
  30. type: 'image/svg+xml',
  31. data: blob
  32. }
  33. this.props.log('Adding fake file blob')
  34. this.props.addFile(file)
  35. }
  36. render () {
  37. const bla = html`<h2>this is strange 2</h2>`
  38. return html`
  39. <div class="wow-this-works">
  40. <input class="UppyDummy-firstInput" type="text" value="hello">
  41. ${this.strange}
  42. ${bla}
  43. </div>
  44. `
  45. }
  46. focus () {
  47. const firstInput = document.querySelector(`${this.target} .UppyDummy-firstInput`)
  48. // only works for the first time if wrapped in setTimeout for some reason
  49. // firstInput.focus()
  50. setTimeout(function () {
  51. firstInput.focus()
  52. }, 10)
  53. setTimeout(() => {
  54. this.core.emit('informer', 'Hello! I’m a test Informer message', 'info', 4500)
  55. this.addFakeFileJustToTest()
  56. }, 1000)
  57. }
  58. install () {
  59. const target = this.opts.target
  60. const plugin = this
  61. this.target = this.mount(target, plugin)
  62. }
  63. }