Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
plugin_dbui
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
w2pext
plugin_dbui
Commits
bf349596
Commit
bf349596
authored
10 years ago
by
legac
Browse files
Options
Downloads
Patches
Plain Diff
Redesign the App.form.field.AceEditor using the Ext.form.FieldContainer.
parent
0bd56533
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
static/plugin_dbui/src/form/field/AceEditor.js
+56
-65
56 additions, 65 deletions
static/plugin_dbui/src/form/field/AceEditor.js
with
56 additions
and
65 deletions
static/plugin_dbui/src/form/field/AceEditor.js
+
56
−
65
View file @
bf349596
...
@@ -3,13 +3,15 @@
...
@@ -3,13 +3,15 @@
* [ACE editor](http://http://ace.c9.io/#nav=about)
* [ACE editor](http://http://ace.c9.io/#nav=about)
* It can be embedded in Ext.form.Panel.
* It can be embedded in Ext.form.Panel.
*
*
* @experimental
* @since 0.4.15.0
* @since 0.4.15.0
*
*
*/
*/
Ext
.
define
(
'
App.form.field.AceEditor
'
,
{
Ext
.
define
(
'
App.form.field.AceEditor
'
,
{
extend
:
'
Ext.form.field.Base
'
,
extend
:
'
Ext.form.FieldContainer
'
,
mixins
:
{
field
:
'
Ext.form.field.Field
'
},
alias
:
'
widget.xaceeditorfield
'
,
alias
:
'
widget.xaceeditorfield
'
,
/**
/**
...
@@ -37,94 +39,78 @@ Ext.define('App.form.field.AceEditor', {
...
@@ -37,94 +39,78 @@ Ext.define('App.form.field.AceEditor', {
// private property
// private property
editor
:
null
,
editor
:
null
,
panel
:
null
,
valueBeforeRender
:
undefined
,
valueBeforeRender
:
undefined
,
// private method requests by the component model of ExtJS
// private method requests by the component model of ExtJS
initComponent
:
function
(
config
)
{
initComponent
:
function
(
config
)
{
// Hack to get the size of the editor render properly
var
me
=
this
;
// The width is to small when it is not specified.
this
.
minWidth
=
this
.
minWidth
||
258
;
this
.
callParent
(
arguments
);
me
.
items
=
[{
},
frame
:
true
,
height
:
me
.
editorHeight
,
xtype
:
'
panel
'
}];
// private method requests by the component model of ExtJS
me
.
callParent
(
arguments
);
beforeDestroy
:
function
()
{
me
.
panel
=
me
.
child
(
'
panel
'
);
Ext
.
destroyMembers
(
this
,
'
e
ditor
'
);
me
.
panel
.
on
(
'
afterrender
'
,
me
.
addE
ditor
,
me
);
this
.
callParent
(
arguments
);
me
.
initField
(
);
},
},
/**
// private method requests by the component model of ExtJS
* Return the value of this field.
beforeDestroy
:
function
()
{
*
* @return {String}
*
*/
getValue
:
function
()
{
"
use strict
"
;
var
me
=
this
;
if
(
this
.
editor
)
{
me
.
panel
.
un
(
'
afterrender
'
,
me
.
addEditor
,
me
);
return
this
.
editor
.
getValue
();
}
return
undefined
;
me
.
editor
.
destroy
()
;
},
Ext
.
destroyMembers
(
me
,
'
editor
'
);
/**
me
.
callParent
(
arguments
);
* Render the editor field.
},
*
* @param {Ext.Element} ct The container to render to.
* @param {Object} position The position in the container to render to.
*
*/
onRender
:
function
(
ct
,
position
)
{
this
.
callParent
(
arguments
);
//
wrap an element around the input fi
el
d
//
private to embed the ace editor inside the pan
el
this
.
resizeEl
=
this
.
positionEl
=
this
.
wrap
=
this
.
bodyEl
.
wrap
();
addEditor
:
function
()
{
// the editor require that the width an height are defined
"
use strict
"
;
this
.
wrap
.
setWidth
(
this
.
wrap
.
getWidth
());
var
me
=
this
;
this
.
wrap
.
setHeight
(
this
.
editorHeight
);
// instantiate the editor
// instantiate the editor
this
.
editor
=
ace
.
edit
(
this
.
wrap
.
id
);
me
.
editor
=
ace
.
edit
(
me
.
panel
.
getId
()
);
this
.
editor
.
getSession
().
setMode
(
'
ace/mode/
'
+
this
.
language
);
me
.
editor
.
getSession
().
setMode
(
'
ace/mode/
'
+
me
.
language
);
this
.
editor
.
setFontSize
(
this
.
fontSize
);
me
.
editor
.
setFontSize
(
me
.
fontSize
);
if
(
this
.
theme
)
{
if
(
me
.
theme
)
{
this
.
editor
.
setTheme
(
'
ace/theme/
'
+
this
.
theme
);
me
.
editor
.
setTheme
(
'
ace/theme/
'
+
me
.
theme
);
}
}
// load the value
// load the value
this
.
editor
.
setValue
(
this
.
valueBeforeRender
);
me
.
editor
.
setValue
(
me
.
valueBeforeRender
);
this
.
editor
.
clearSelection
();
me
.
editor
.
clearSelection
();
this
.
editor
.
moveCursorTo
(
0
,
0
);
me
.
editor
.
moveCursorTo
(
0
,
0
);
// hide the default input field
this
.
bodyEl
.
setVisibilityMode
(
Ext
.
dom
.
Element
.
DISPLAY
).
hide
();
},
},
/**
/**
* Re
size
the
component
* Re
turn
the
value of this field.
*
*
* @param {Number} w
* @return {String}
* @param {Number} h
*
*
*/
*/
onResize
:
function
(
w
,
h
)
{
getValue
:
function
()
{
"
use strict
"
;
var
me
=
this
;
this
.
wrap
.
setSize
(
w
-
this
.
getLabelWidth
(),
h
);
if
(
me
.
editor
)
{
if
(
this
.
editor
)
{
return
me
.
editor
.
getValue
();
this
.
editor
.
resize
();
}
}
this
.
callParent
(
arguments
)
;
return
undefined
;
},
},
/**
/**
...
@@ -135,19 +121,24 @@ Ext.define('App.form.field.AceEditor', {
...
@@ -135,19 +121,24 @@ Ext.define('App.form.field.AceEditor', {
*/
*/
setValue
:
function
(
value
)
{
setValue
:
function
(
value
)
{
this
.
callParent
(
arguments
);
"
use strict
"
;
var
me
=
this
;
if
(
this
.
editor
)
{
if
(
me
.
editor
)
{
this
.
editor
.
setValue
(
value
);
me
.
editor
.
setValue
(
value
);
this
.
editor
.
clearSelection
();
me
.
editor
.
clearSelection
();
this
.
editor
.
moveCursorTo
(
0
,
0
);
me
.
editor
.
moveCursorTo
(
0
,
0
);
this
.
valueBeforeRender
=
undefined
;
me
.
valueBeforeRender
=
undefined
;
// Keep track of the value.
// Keep track of the value.
// It will be used at the first rendering of the editor
// It will be used at the first rendering of the editor
}
else
{
}
else
{
this
.
valueBeforeRender
=
value
;
me
.
valueBeforeRender
=
value
;
}
}
// the standard way to set the value for a field
// extract from Ext.form.field.Base
return
me
.
mixins
.
field
.
setValue
.
call
(
me
,
value
);
}
}
});
});
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment