1. 1 : /**
  2. 2 : * Embedder provides a way to embed a web page into your Voyant Tools experience.
  3. 3 : *
  4. 4 : * @class Embedder
  5. 5 : * @tutorial embedder
  6. 6 : * @memberof Tools
  7. 7 : */
  8. 8 : Ext.define('Voyant.panel.Embedder', {
  9. 9 : extend: 'Ext.Panel',
  10. 10 : mixins: ['Voyant.panel.Panel'],
  11. 11 : alias: 'widget.embedder',
  12. 12 : statics: {
  13. 13 : i18n: {
  14. 14 : title: 'Embedder',
  15. 15 : url: 'URL',
  16. 16 : go: 'Go',
  17. 17 : help: 'Embedder provides a way to embed a web page into your Voyant Tools experience.',
  18. 18 : helpTip: 'Embedder provides a way to embed a web page into your Voyant Tools experience.'
  19. 19 : },
  20. 20 : api: {
  21. 21 : /**
  22. 22 : * @memberof Tools.Embedder
  23. 23 : * @instance
  24. 24 : * @property {String} url The URL of the web page to embed.
  25. 25 : */
  26. 26 : url: undefined
  27. 27 : },
  28. 28 : glyph: 'xf0c1@FontAwesome'
  29. 29 : },
  30. 30 : constructor: function(config) {
  31. 31 : this.mixins['Voyant.util.Api'].constructor.apply(this, arguments);
  32. 32 : this.setApiParam('url', config.url);
  33. 33 :
  34. 34 : this.callParent(arguments);
  35. 35 :
  36. 36 : this.mixins['Voyant.panel.Panel'].constructor.apply(this, arguments);
  37. 37 : },
  38. 38 : initComponent: function() {
  39. 39 : Ext.apply(this, {
  40. 40 : title: this.localize('title'),
  41. 41 : layout: {
  42. 42 : type: 'fit'
  43. 43 : },
  44. 44 : items: {
  45. 45 : xtype: 'uxiframe',
  46. 46 : src: this.getApiParam('url')
  47. 47 : },
  48. 48 : tbar: [{
  49. 49 : xtype: 'textfield',
  50. 50 : value: this.getApiParam('url'),
  51. 51 : emptyText: this.localize('url'),
  52. 52 : listeners: {
  53. 53 : specialkey: function(field, e){
  54. 54 : if (e.getKey() == e.ENTER) {
  55. 55 : field.up('panel').down('uxiframe').load(field.getValue());
  56. 56 : }
  57. 57 : }
  58. 58 : }
  59. 59 : },{
  60. 60 : xtype: 'button',
  61. 61 : text: this.localize('go'),
  62. 62 : handler: function(btn) {
  63. 63 : var url = btn.prev('textfield').getValue();
  64. 64 : btn.up('panel').down('uxiframe').load(url);
  65. 65 : }
  66. 66 : }]
  67. 67 : });
  68. 68 :
  69. 69 : this.callParent();
  70. 70 : },
  71. 71 : loadUrl: function(url) {
  72. 72 : this.down('uxiframe').load(url);
  73. 73 : }
  74. 74 : });