Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
w2pext
plugin_dbui
Commits
3c8ac1fb
Commit
3c8ac1fb
authored
Feb 20, 2014
by
LE GAC Renaud
Browse files
All MathJax processing is performed by a single plugin pMathJax.
parent
9285585d
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
187 additions
and
202 deletions
+187
-202
models/ui_categories.py
models/ui_categories.py
+1
-1
models/ui_publications.py
models/ui_publications.py
+1
-1
models/widgets_viewport.py
models/widgets_viewport.py
+1
-1
modules/plugin_dbui/converter.py
modules/plugin_dbui/converter.py
+1
-2
static/plugin_dbui/CHANGELOG
static/plugin_dbui/CHANGELOG
+4
-0
static/plugin_dbui/src/grid/button/ExpertMenu.js
static/plugin_dbui/src/grid/button/ExpertMenu.js
+10
-10
static/plugin_dbui/src/grid/plugin/MathJax.js
static/plugin_dbui/src/grid/plugin/MathJax.js
+0
-87
static/plugin_dbui/src/panel/WithUrlSelector.js
static/plugin_dbui/src/panel/WithUrlSelector.js
+2
-50
static/plugin_dbui/src/panel/plugin/MathJax.js
static/plugin_dbui/src/panel/plugin/MathJax.js
+0
-50
static/plugin_dbui/src/plugin/MathJax.js
static/plugin_dbui/src/plugin/MathJax.js
+167
-0
No files found.
models/ui_categories.py
View file @
3c8ac1fb
...
...
@@ -20,7 +20,7 @@
#
#-------------------------------------------------------------------------------
gridModifier
=
dbui
.
GridModifier
(
'categories'
)
gridModifier
.
configure
(
plugins
=
[
'pGridPaging'
,
'p
Grid
MathJax'
])
gridModifier
.
configure
(
plugins
=
[
'pGridPaging'
,
'pMathJax'
])
gridModifier
.
configure_column
(
'code'
,
width
=
10
)
gridModifier
.
set_rownumbering
(
True
)
...
...
models/ui_publications.py
View file @
3c8ac1fb
...
...
@@ -101,7 +101,7 @@ tpl = ['<b>{PublicationsTitle}</b><br>',
]
gridModifier
=
dbui
.
GridModifier
(
'publications'
)
gridModifier
.
configure
(
plugins
=
[
'p
Grid
MathJax'
])
gridModifier
.
configure
(
plugins
=
[
'pMathJax'
])
gridModifier
.
merge_columns
(
'title'
,
'authors'
,
'id_collaborations'
,
...
...
models/widgets_viewport.py
View file @
3c8ac1fb
...
...
@@ -50,7 +50,7 @@ leaf_1 = dbui.Panel(html="salut ma poule")
leaf_2
=
dbui
.
to_panelWithUrlSelector
(
virtdb
.
foo1
,
baseUrl
=
URL
(
'reports'
,
'report_2'
),
extField
=
'my_format'
,
is
MathJax
=
True
)
plugins
=
[
'p
MathJax
'
]
)
leaf_3
=
dbui
.
to_panelWithUrlSelector
(
virtdb
.
harvester_selector
,
baseUrl
=
URL
(
'reports'
,
'report_3'
),
...
...
modules/plugin_dbui/converter.py
View file @
3c8ac1fb
...
...
@@ -779,8 +779,7 @@ def to_panelWithUrlSelector(table, selectorTitle='Select', **kwargs):
title
=
current
.
T
(
selectorTitle
))
# build the configuration for the PanelWithUrlSelector
default
=
dict
(
isMathJax
=
False
,
selectorItems
=
selector
)
default
=
dict
(
selectorItems
=
selector
)
default
.
update
(
kwargs
)
cfg
=
PanelWithUrlSelector
(
**
default
)
...
...
static/plugin_dbui/CHANGELOG
View file @
3c8ac1fb
...
...
@@ -26,6 +26,7 @@ HEAD
GridModifier.set_rownumbering(False) to inhibit it.
+ pGridExperMenu → pGridToolbar
+ pGridMathJax → pMathJax
+ GridModifier.set_filters → configure_filters
+ GridModifier.configure_gridWithFilter
...
...
@@ -37,6 +38,9 @@ HEAD
+ Remove IFRAME stuff in controller and define extField in
the PanelWithUrlSelector configuration.
+ Replace the configuration parameter PanelWithUrlSelector.isMathJax
by plugins=['pMathJax'].
0.4.15.2 (Oct 2013)
- Release only compatible with ExtJS 3.4.1.1 but identical to 0.4.15.1.
- Deploy the limited part of new ExtJS class model available in 3.4.1.1.
...
...
static/plugin_dbui/src/grid/button/ExpertMenu.js
View file @
3c8ac1fb
...
...
@@ -25,7 +25,7 @@ Ext.define('App.grid.button.ExpertMenu', {
// private method requests by the component model of ExtJS
initComponent
:
function
()
{
var
p
Grid
MathJax
,
var
pMathJax
,
tableName
=
App
.
getTableName
(
this
.
grid
.
getStore
());
// the menu configuration
...
...
@@ -43,10 +43,10 @@ Ext.define('App.grid.button.ExpertMenu', {
};
// add check item to activate deactivate MathJax processing
p
Grid
MathJax
=
this
.
grid
.
findPlugin
(
'
p
Grid
MathJax
'
);
if
(
p
Grid
MathJax
)
{
pMathJax
=
this
.
grid
.
findPlugin
(
'
pMathJax
'
);
if
(
pMathJax
)
{
this
.
menu
.
items
.
push
({
checked
:
p
Grid
MathJax
.
activated
,
checked
:
pMathJax
.
activated
,
itemId
:
'
buttonMathJax
'
,
text
:
this
.
textMathJax
,
xtype
:
'
menucheckitem
'
...
...
@@ -57,9 +57,9 @@ Ext.define('App.grid.button.ExpertMenu', {
this
.
callParent
(
arguments
);
// process checkItem event
if
(
p
Grid
MathJax
)
{
if
(
pMathJax
)
{
this
.
buttonMathJax
=
this
.
menu
.
getComponent
(
'
buttonMathJax
'
);
this
.
buttonMathJax
.
on
(
'
checkchange
'
,
this
.
onCheckItemChange
,
p
Grid
MathJax
);
this
.
buttonMathJax
.
on
(
'
checkchange
'
,
this
.
onCheckItemChange
,
pMathJax
);
}
},
...
...
@@ -76,17 +76,17 @@ Ext.define('App.grid.button.ExpertMenu', {
"
use strict
"
;
var
p
Grid
MathJax
=
this
;
var
pMathJax
=
this
;
p
Grid
MathJax
.
activated
=
checked
;
pMathJax
.
activated
=
checked
;
// process equation
if
(
checked
)
{
p
Grid
MathJax
.
onProcessMath
();
pMathJax
.
onProcessMath
();
// refresh the grid
}
else
{
p
Grid
MathJax
.
getCmp
().
getView
().
refresh
();
pMathJax
.
getCmp
().
getView
().
refresh
();
}
},
...
...
static/plugin_dbui/src/grid/plugin/MathJax.js
deleted
100644 → 0
View file @
9285585d
/**
* The plugin to render mathematics formula embedded in grid content.
* The processing is performed by [MathJax](http://www.mathjax.org/).
* The MathJax library is loaded by the framework
*
*/
Ext
.
define
(
'
App.grid.plugin.MathJax
'
,
{
extend
:
'
Ext.AbstractPlugin
'
,
alias
:
'
plugin.pGridMathJax
'
,
/**
* @property {Boolean}
* False to deactivate the MathJax processing.
*/
activated
:
true
,
// Private attributes for internationalization
textMask
:
'
Processing symbols
'
,
/**
* Initialize the plugin
*
* @param {App.grid.Panel} grid
*
*/
init
:
function
(
grid
)
{
"
use strict
"
;
this
.
setCmp
(
grid
);
// process latex formula each time the grid is refreshed.
//
// NOTE: MathJax processing is lost when the gridView is
// modified (sort, filter, add, remove or delete).
//
grid
.
getView
().
on
(
'
refresh
'
,
this
.
onProcessMath
,
this
);
},
/**
* destroy the plugin
*/
destroy
:
function
()
{
"
use strict
"
;
this
.
getCmp
().
getView
().
un
(
'
refresh
'
,
this
.
onProcessMath
,
this
);
},
/**
* Process maths objects
*
*/
onProcessMath
:
function
()
{
"
use strict
"
;
var
grid
=
this
.
getCmp
(),
domEl
,
loadMask
,
target
;
if
(
!
this
.
activated
)
{
return
;
}
// mask the grid / gridWithFilter during MathJax processing
target
=
grid
.
up
(
'
xgridwithfilter
'
);
if
(
!
target
)
{
target
=
grid
;
}
loadMask
=
Ext
.
create
(
'
Ext.LoadMask
'
,
{
target
:
target
,
msg
:
this
.
textMask
});
loadMask
.
show
();
// push in the MatJax queue the processing followed by the unmasking
domEl
=
Ext
.
getDom
(
grid
.
getView
().
getEl
());
MathJax
.
Hub
.
Queue
([
"
Typeset
"
,
MathJax
.
Hub
,
domEl
]);
MathJax
.
Hub
.
Queue
([
function
(
mask
)
{
mask
.
hide
();
},
loadMask
]);
}
});
\ No newline at end of file
static/plugin_dbui/src/panel/WithUrlSelector.js
View file @
3c8ac1fb
...
...
@@ -8,12 +8,8 @@
* The URL display in the main panel is defined by the #baseUrl option.
* It can be modified dynamically by extracting the name of the
* *controller*, *function* and/or *extension* from the selector fields.
* The options #ctrlField, #extField and #funcField are used to determine
* the associated fields.
*
* Mathematical symbols will be interpreted when the javascript library
* [MathJax](http://www.mathjax.org/) is load and when the #isMathJax
* property is true.
* The options #ctrlField, #extField and #funcField determine
* the field mappings.
*
*/
Ext
.
define
(
'
App.panel.WithUrlSelector
'
,
{
...
...
@@ -48,12 +44,6 @@ Ext.define('App.panel.WithUrlSelector', {
*/
funcField
:
undefined
,
/**
* @cfg {Boolean}
* Set the value to true when the mathjax library is installed.
*/
isMathJax
:
false
,
/**
* @cfg {Number}
* The time out for the {@link Ext.Ajax Ajax request} in millisecond.
...
...
@@ -239,44 +229,6 @@ Ext.define('App.panel.WithUrlSelector', {
}
},
/**
* Handler call when the main panel is loaded.
* Process symbols and enable the selector.
*
*/
onLoad
:
function
()
{
"
use strict
"
;
var
domEl
,
loadMask
;
function
enable
(
mask
,
selector
)
{
mask
.
hide
();
selector
.
enable
();
}
// process symbols
if
(
MathJax
&&
this
.
isMathJax
)
{
domEl
=
Ext
.
getDom
(
this
.
mainPanel
.
getEl
());
loadMask
=
Ext
.
create
(
'
Ext.LoadMask
'
,
{
target
:
this
.
mainPanel
,
msg
:
'
Processing symbols
'
});
loadMask
.
show
();
MathJax
.
Hub
.
Queue
([
"
Typeset
"
,
MathJax
.
Hub
,
domEl
]);
MathJax
.
Hub
.
Queue
([
enable
,
loadMask
,
this
.
selectorPanel
]);
}
else
{
// enable the selector
this
.
selectorPanel
.
enable
();
}
},
/**
* Handler to reset the selector
*/
...
...
static/plugin_dbui/src/panel/plugin/MathJax.js
deleted
100644 → 0
View file @
9285585d
/**
* the plugin to render mathematics formula embedded in the HTML content.
* The processing is performed by the [MathJax](http://www.mathjax.org/)
* library.
*
*/
Ext
.
define
(
'
App.panel.plugin.MathJax
'
,
{
extend
:
'
Ext.AbstractPlugin
'
,
alias
:
'
plugin.pPanelMathJax
'
,
/**
* Initialize the plugin.
*
* @param {Ext.Panel} panel
*
*/
init
:
function
(
panel
)
{
"
use strict
"
;
// register an handler which is activated only once
// when the panel is rendered for the first time
panel
.
on
(
'
render
'
,
this
.
onPanelRender
,
this
,
{
single
:
true
});
},
/**
* Activate the MathJax processing
* when the HTML content of the panel is loaded.
*
* @param {Ext.Panel} panel
*/
onPanelRender
:
function
(
panel
)
{
"
use strict
"
;
var
updater
=
panel
.
body
.
getUpdater
();
updater
.
on
(
'
update
'
,
this
.
onProcess
);
},
/**
* Run the mathJax processing.
*
* @param {Ext.Element} el
* @param {Object} o the response object
*/
onProcess
:
function
(
e
,
o
)
{
"
use strict
"
;
MathJax
.
Hub
.
PreProcess
();
MathJax
.
Hub
.
Process
();
}
});
\ No newline at end of file
static/plugin_dbui/src/plugin/MathJax.js
0 → 100644
View file @
3c8ac1fb
/**
* The plugin renders mathematics equation embedded in panel and grid.
* The processing is performed by [MathJax](http://www.mathjax.org/).
* The MathJax library is loaded by the framework.
*
* The plugin works with the classes: Ext.panel.Panel, Ext.grid.GridPanel,
* App.grid.GridPanel, App.panel.BaseWithSelector, App.panel.WithUrlSelector,
* and App.panel.GridWithFilter.
*
* @since 0.6.0.10
*
*/
Ext
.
define
(
'
App.plugin.MathJax
'
,
{
extend
:
'
Ext.AbstractPlugin
'
,
alias
:
'
plugin.pMathJax
'
,
/**
* @property {Boolean}
* False to deactivate the MathJax processing.
*/
activated
:
true
,
// Private short cuts
target
:
null
,
targetDomEl
:
null
,
targetType
:
undefined
,
// Private attributes for internationalization
textMask
:
'
Processing symbols
'
,
/**
* Initialize the plugin
*
* @param {Ext.grid.GridPanel/Ext.panel.Panel/App.panel.BaseWithSelector} cmp
*
*/
init
:
function
(
cmp
)
{
"
use strict
"
;
var
parent
,
xtype
=
cmp
.
getXType
();
// protection
if
(
!
MathJax
)
{
return
;
}
this
.
setCmp
(
cmp
);
// determine the target component to be processed
switch
(
xtype
)
{
case
'
grid
'
:
this
.
target
=
cmp
.
getView
();
this
.
targetType
=
'
grid
'
;
break
;
case
'
panel
'
:
this
.
target
=
cmp
;
this
.
targetType
=
'
panel
'
;
break
;
case
'
xpanelwithurlselector
'
:
this
.
target
=
cmp
.
mainPanel
;
this
.
targetType
=
'
panel
'
;
break
;
case
'
xpanelwithselector
'
:
this
.
target
=
cmp
.
mainPanel
;
this
.
targetType
=
'
panel
'
;
break
;
case
'
xgrid
'
:
this
.
target
=
cmp
.
getView
();
this
.
targetType
=
'
grid
'
;
break
;
case
'
xgridwithfilter
'
:
this
.
target
=
cmp
.
grid
.
getView
();
this
.
targetType
=
'
grid
'
;
break
;
}
// the DOM element of the target
this
.
targetDomEl
=
Ext
.
getDom
(
this
.
target
.
getEl
());
// listener to trigger the MathJax processing
switch
(
this
.
targetType
)
{
case
'
grid
'
:
//
// process equation each time the grid is refreshed.
//
// NOTE: MathJax processing is lost when the gridView is
// modified (sort, filter, add, remove or delete).
//
this
.
target
.
on
(
'
refresh
'
,
this
.
onProcessMath
,
this
);
break
;
case
'
panel
'
:
//
// process equation when the panel is loaded
//
this
.
target
.
getLoader
().
on
(
'
load
'
,
this
.
onProcessMath
,
this
);
break
;
}
},
/**
* destroy the plugin
*/
destroy
:
function
()
{
"
use strict
"
;
switch
(
this
.
targetType
)
{
case
'
grid
'
:
this
.
target
.
un
(
'
refresh
'
,
this
.
onProcessMath
,
this
);
break
;
case
'
panel
'
:
this
.
target
.
getLoader
().
un
(
'
load
'
,
this
.
onProcessMath
,
this
);
break
;
}
},
/**
* Process maths objects
*
*/
onProcessMath
:
function
()
{
"
use strict
"
;
var
cmp
=
this
.
getCmp
(),
loadMask
,
parent
,
targetMask
=
cmp
;
if
(
!
this
.
activated
)
{
return
;
}
// parent of a grid can be gridWithFilter.
// In that case the gridWithFilter should be masked
//
// NOTE: the parent is not define when the plugin is initialized.
//
if
(
this
.
targetType
===
'
grid
'
)
{
parent
=
cmp
.
up
(
'
xgridwithfilter
'
);
if
(
parent
)
{
targetMask
=
parent
;
}
}
// mask the component
loadMask
=
Ext
.
create
(
'
Ext.LoadMask
'
,
{
target
:
targetMask
,
msg
:
this
.
textMask
});
loadMask
.
show
();
// MatJax processing followed by the unmasking
MathJax
.
Hub
.
Queue
([
"
Typeset
"
,
MathJax
.
Hub
,
this
.
targetDomEl
]);
MathJax
.
Hub
.
Queue
([
function
(
mask
)
{
mask
.
hide
();
},
loadMask
]);
}
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment