Commit 3c6689fd703f75bd94502797e1ef9c19b4fd8344
1 parent
58780dd2
Exists in
master
and in
17 other branches
TextArea has clickable links now
Showing
6 changed files
with
90 additions
and
8 deletions
Show diff stats
js/app/views/CatalogUI.js
... | ... | @@ -1307,7 +1307,12 @@ Ext.define('amdaUI.CatalogUI', { |
1307 | 1307 | }] |
1308 | 1308 | }] |
1309 | 1309 | }); |
1310 | - | |
1310 | + this.codeDescripton = Ext.create('amdaUI.DescriptionField',{ | |
1311 | + xtype: 'descriptionfield', | |
1312 | + height:150, | |
1313 | + align:'stretch', | |
1314 | + name: 'description', | |
1315 | + }); | |
1311 | 1316 | this.formPanel = Ext.create('Ext.form.Panel', { |
1312 | 1317 | region: 'center', |
1313 | 1318 | me:this, |
... | ... | @@ -1401,11 +1406,16 @@ Ext.define('amdaUI.CatalogUI', { |
1401 | 1406 | bodyStyle: {background: '#dfe8f6',padding: '1'}, |
1402 | 1407 | border:false, |
1403 | 1408 | layout:'fit', |
1404 | - items:[{ | |
1405 | - xtype: 'descriptionfield', | |
1406 | - align:'stretch', | |
1407 | - name: 'description', | |
1408 | - }], | |
1409 | + items:[ | |
1410 | + this.codeDescripton | |
1411 | + ], | |
1412 | + listeners:{ | |
1413 | + resize:function(a,b,height){ | |
1414 | + if(this.codeDescripton.codeMirror) | |
1415 | + this.codeDescripton.codeMirror.setSize(null, height-20); | |
1416 | + }, | |
1417 | + scope:this | |
1418 | + }, | |
1409 | 1419 | }, |
1410 | 1420 | { |
1411 | 1421 | xtype: 'operationsTT', | ... | ... |
js/app/views/DescriptionField.js
... | ... | @@ -4,6 +4,65 @@ Ext.define('amdaUI.DescriptionField', { |
4 | 4 | alias: 'widget.descriptionfield', |
5 | 5 | |
6 | 6 | fieldLabel: 'Description', |
7 | - | |
7 | + flex:1, | |
8 | + constructor: function() { | |
9 | + this.init(); | |
10 | + this.callParent(arguments); | |
11 | + }, | |
12 | + urlRegex : /(?:\b(?:https?|ftp):\/\/|www\.)(?:\S+(?::\S*)?@)?(?:\S+(?:\.\S+)+(?:[:\d]*)?)(?:\S+)?/gi, | |
13 | + amdaRegex : /amda/i, | |
14 | + | |
15 | + setValue : function(value){ | |
16 | + if(this.codeMirror){ | |
17 | + this.codeMirror.getDoc().setValue(value); | |
18 | + } | |
19 | + this.callParent(arguments); | |
20 | + }, | |
21 | + init : function() { | |
22 | + var me = this ; | |
23 | + CodeMirror.defineSimpleMode("amda_description", { | |
24 | + start: [ | |
25 | + { regex: me.urlRegex, token: "amda_url" }, | |
26 | + { regex: /\bamda\b/gi, token: "amda" } | |
27 | + ], | |
28 | + comment: [], | |
29 | + meta: {} | |
30 | + }); | |
31 | + | |
32 | + var myConf = { | |
33 | + listeners: | |
34 | + { | |
35 | + render:function(textArea, op){ | |
36 | + heightText = textArea.getHeight()-20; | |
37 | + if (heightText <0) | |
38 | + heightText = 50; | |
39 | + me.codeMirror = CodeMirror.fromTextArea(textArea.inputEl.dom, { | |
40 | + lineNumbers: false, | |
41 | + mode: 'amda_description', | |
42 | + styleActiveLine: true, | |
43 | + lineWrapping: true, | |
44 | + | |
45 | + }); | |
46 | + | |
47 | + me.codeMirror.setSize(null, heightText); | |
48 | + | |
49 | + me.codeMirror.on('mousedown', function(cm, event) { | |
50 | + var position = cm.coordsChar({ left: event.clientX, top: event.clientY }); | |
51 | + var token = cm.getTokenAt(position); | |
52 | + | |
53 | + if(token.type === 'amda_url' && token.end > position.ch && position.outside !== 1){ | |
54 | + var tokenText = token.string; | |
55 | + window.open((tokenText.startsWith('www')) ? 'https://'+tokenText : tokenText, "_blank"); | |
56 | + } | |
57 | + }); | |
58 | + me.codeMirror.on('change', function(a,e){ | |
59 | + me.setRawValue(a.getValue()); | |
60 | + }); | |
61 | + | |
62 | + } | |
63 | + } | |
64 | + }; | |
65 | + Ext.apply (this , Ext.apply (arguments, myConf)); | |
66 | + } | |
8 | 67 | }); |
9 | 68 | ... | ... |
js/app/views/DownloadUI.js
js/app/views/PlotComponents/PlotTabContent.js
... | ... | @@ -225,7 +225,7 @@ Ext.define('amdaPlotComp.PlotTabContent', { |
225 | 225 | bodyStyle: {background: '#dfe8f6',padding: '1', }, |
226 | 226 | border:false, |
227 | 227 | layout:'fit', |
228 | - items:[{ xtype: 'descriptionfield', name: 'description', | |
228 | + items:[{ xtype: 'descriptionfield', name: 'description', height:50, | |
229 | 229 | id:'plot_description',emptyText:'Description', fieldLabel: ''}] |
230 | 230 | }; |
231 | 231 | ... | ... |
js/app/views/TimeTableUI.js
js/resources/css/amda.css
... | ... | @@ -626,3 +626,14 @@ p + p { |
626 | 626 | font-weight: bold; |
627 | 627 | } |
628 | 628 | |
629 | +.cm-s-default .cm-amda_url { | |
630 | + color: #219; | |
631 | + font-weight: bold; | |
632 | + text-decoration: underline; | |
633 | + cursor:pointer; | |
634 | +} | |
635 | + | |
636 | +.cm-s-default .cm-amda { | |
637 | + color: rgb(9, 134, 218); | |
638 | + font-weight: bold; | |
639 | +} | |
629 | 640 | \ No newline at end of file | ... | ... |