text-input-behavior.html 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <link rel="import" href="text-input-dialog.html">
  2. <script>
  3. 'use strict';
  4. window.Chat = window.Chat || {};
  5. (function() {
  6. var textInput = Polymer.Base.create('text-input-dialog');
  7. textInput.className = 'textInput';
  8. document.body.appendChild(textInput);
  9. Chat.TextInputBehavior = {
  10. properties: {
  11. contact: Object,
  12. },
  13. get textInput() {
  14. var textInput = Polymer.dom(document).querySelector('.textInput');
  15. return textInput;
  16. },
  17. openTextDialog: function() {
  18. this.textInput.open(this.contact);
  19. },
  20. listeners: {
  21. 'contextmenu': '_handleContextMenu',
  22. 'down': '_handleDown',
  23. 'up': '_handleUp',
  24. },
  25. _handleContextMenu: function(ev) {
  26. ev.preventDefault();
  27. ev.stopPropagation();
  28. ev.cancelBubble = true;
  29. this.cancelAsync(this.pressTimer);
  30. this.openTextDialog();
  31. return false;
  32. },
  33. _handleUp: function(e) {
  34. this.cancelAsync(this.pressTimer);
  35. },
  36. _handleDown: function(ev) {
  37. this.pressTimer = this.async(function() {
  38. this.openTextDialog();
  39. ev.preventDefault();
  40. ev.stopPropagation();
  41. ev.cancelBubble = true;
  42. return false;
  43. }, 1100);
  44. },
  45. attached: function() {
  46. // this.addEventListener('mousedown', function(e) {
  47. // clearTimeout(this.pressTimer);
  48. // }.bind(this), false);
  49. // this.addEventListener('mousup', function(e) {
  50. // this.pressTimer = window.setTimeout(function() {
  51. // this.openTextDialog();
  52. // }, 1500);
  53. // }.bind(this), false);
  54. }
  55. };
  56. }());
  57. </script>