Guest User

Untitled

a guest
Apr 26th, 2017
856
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.25 KB | None | 0 0
  1. <!--
  2. @license
  3. Copyright (c) 2016 The Polymer Project Authors. All rights reserved.
  4. This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
  5. The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
  6. The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
  7. Code distributed by Google as part of the polymer project is also
  8. subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
  9. -->
  10. <link rel="import" href="../../bower_components/polymer/polymer.html">
  11. <link rel="import" href="../../bower_components/file-upload/file-upload.html">
  12. <link rel="import" href="../../bower_components/iron-collapse/iron-collapse.html">
  13. <link rel="import" href="../../bower_components/paper-dialog/paper-dialog.html">
  14. <link rel="import" href="../../bower_components/neon-animation/neon-animation.html">
  15. <link rel="import" href="../../bower_components/neon-animation/neon-animations.html">
  16. <link rel="import" href="../../bower_components/iron-flex-layout/iron-flex-layout.html">
  17. <link rel="import" href="../../bower_components/neon-animation/neon-animatable.html">
  18. <link rel="import" href="../../bower_components/neon-animation/neon-animatable-behavior.html">
  19. <link rel="import" href="../../bower_components/neon-animation/neon-animatable-runner-behavior.html">
  20. <link rel="import" href="../../bower_components/neon-animation/animations/slide-down-animation.html">
  21. <link rel="import" href="../../bower_components/neon-animation/animations/slide-up-animation.html">
  22. <link rel="import" href="my-animatable.html">
  23. <dom-module id="my-qrcodescanner">
  24. <template>
  25. <style>
  26. :host {
  27. display: block;
  28. padding: 10px;
  29. }
  30.  
  31. .card {
  32. box-shadow: 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12), 0 3px 1px -2px rgba(0, 0, 0, 0.2);
  33. padding: 16px;
  34. margin: 24px;
  35. border-radius: 5px;
  36. background-color: #fff;
  37. color: #757575;
  38. }
  39.  
  40. .circle {
  41. display: inline-block;
  42. height: 64px;
  43. width: 64px;
  44. border-radius: 50%;
  45. background: #ddd;
  46. line-height: 64px;
  47. font-size: 30px;
  48. color: #555;
  49. text-align: center;
  50. }
  51.  
  52. h1 {
  53. font-size: 22px;
  54. margin: 16px 0;
  55. color: #212121;
  56. }
  57. </style>
  58. <div class="card">
  59. <div class="circle">5</div>
  60. <h1>QR codes</h1>
  61. <iron-collapse opened="{{!isDisabled}}">
  62. <file-upload hide-fileList raised name="qrscan" id="qrscan" method="POST" accept="image/*;capture=camera" target="/qrscan">Upload qr code
  63. </file-upload>
  64. </iron-collapse>
  65.  
  66. <paper-button raised onclick="dialog.open()">plain dialog</paper-button>
  67.  
  68. <paper-dialog id="dialog">
  69. <div id="rect" style="width:100px;height:100px;background-color:red"></div>
  70. <h1>essai</h1>
  71. <h1>essai</h1>
  72. <button on-click="move" raised>Move above rectangle</button>
  73. <h1>essai</h1>
  74. <div id="fin">fin</div>
  75. </paper-dialog>
  76.  
  77. <iron-collapse id="qrInvalid">
  78. <div>{{poiincorrectMessage}}</div>
  79. <paper-button on-click="retry">Retry</paper-button>
  80. </iron-collapse>
  81. <iron-collapse id="qrValid">
  82. <div>{{poireachedMessage}}</div>
  83. <paper-button on-click="next">Next</paper-button>
  84. </iron-collapse>
  85. </div>
  86. </template>
  87. <script>
  88. Polymer({
  89.  
  90.  
  91. is: 'my-qrcodescanner',
  92. ready: function() {
  93. this.$.qrscan.addEventListener('success', this.qrscanListener.bind(this))
  94. this.isDisabled = false
  95. console.log(this.poi)
  96. },
  97. qrscanListener: function(item) {
  98. if (item && item.detail && item.detail.xhr && item.detail.xhr.response) {
  99. var code = item.detail.xhr.response
  100. var pass = code == '[' + this.poi._id + ']'
  101. if (!pass) {
  102. this.$.qrInvalid.show()
  103. this.isDisabled = true
  104. } else {
  105. this.$.qrValid.show()
  106. this.isDisabled = true
  107. }
  108. }
  109. },
  110. retry: function() {
  111. this.$.qrInvalid.hide()
  112. this.$.qrValid.hide()
  113. this.isDisabled = false
  114. },
  115. _poiObserver: function(item) {
  116. console.log(item)
  117. },
  118.  
  119. property: {
  120. poi: {
  121. type: Object,
  122. notify: true,
  123. obersver: '_poiObserver',
  124. },
  125. poiincorrectMessage: {
  126. type: String,
  127. notify: true,
  128. },
  129. poireachedMessage: {
  130. type: String,
  131. notify: true,
  132. },
  133. },
  134.  
  135. move: function () {
  136. this.playAnimation('move');
  137. },
  138.  
  139. });
  140. </script>
  141. </dom-module>
Advertisement
Add Comment
Please, Sign In to add comment