I need to create a modal window in the other normal window. When I create a modal window is blocked mask.
Ext.application({
name : 'Fiddle',
launch : function() {
var win2 = null;
var win1 = Ext.create('Ext.window.Window', {
closeAction: 'hide',
width: 500,
height: 500,
resizable: false,
titleAlign: 'center',
items: {
xtype: 'button',
text: 'show modal',
handler: function() {win2.show()}
},
title: 'Simple window'
});
Ext.create('Ext.panel.Panel', {
items: {
xtype: 'button',
text: 'show window',
handler: function() {
var isRendered = win1.rendered;
win1.show(null, function() {
if (!isRendered) {
win2 = Ext.create('Ext.window.Window', {
closeAction: 'hide',
resizable: false,
titleAlign: 'center',
width: 200,
height: 200,
renderTo: win1.getEl(),
modal: true,
title: 'Modal window'
})
}
});
}
},
renderTo: Ext.getBody()
});
}});
z-index is right:
Mask component is 19006
Modal window component is 19010
Simple window component is 19000
I don't understand where I was wrong.
The problem is that you render win2 into win1.getEl(). Normally, you don't render a window into anything, and let it take care of itself.
Indeed, if you remove
renderTo: win1.getEl(),
from your fiddle, the modal window is working.
If, for some reason, you want win2 to be modal only inside win1, you can use
floatParent : win1,
on win2 instead.
Related
I have a Ext.toast and Ext.Msg to be displayed on button click. So on click of button the content of toast and messagebox should be read.
I have applied ariaLabel but its still not readable, tried setting focus and containsFocus as well but still no luck, when I set defaultFocus:1 on messagebox it works for the first time only. Any hints please.
Ext.toast({
html: 'Data Saved',
title: 'My Title',
width: 200,
align: 't',
ariaLabel: 'My Title Data Saved'
});
Ext.Msg.show({
title: 'Invalid search criteria',
msg: 'check',
ariaLabel:'Invalid search criteria check',
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
Screen reader to be used - NVDA
Fiddle can be found here
The problem is that attribute aria-labelledby is always set automatically. (and has the higher precedence ariaLabelledBy). I did not find a way to avoid automatic substitution, so I created an override that does this for window instances
Ext.define('Ext.window.WindowAriaOverride', {
override: 'Ext.window.Window',
afterShow: function () {
this.el.dom.setAttribute('aria-labelledby', null)
this.el.dom.setAttribute('aria-label', this.ariaLabel)
}
});
Fiddle
If you will look at the documentation of the Ext.Msg.show, you will not find there any aria* config/param. This config is available only to Ext.window.MessageBox class.
I have changed your fiddle example to force it work, but unfortunately this aria features looks like to be buggy.
Ext.application({
name: 'Fiddle',
launch: function () {
Ext.create('Ext.Button', {
text: 'toast',
renderTo: Ext.getBody(),
handler: function () {
Ext.create('Ext.window.Toast', {
html: 'Data Saved',
title: 'My Title',
width: 200,
align: 't',
containsFocus: true,
closeAction: 'destroy',
ariaLabel: 'ARIA_LABEL_VALUE',
//ariaLabelledBy: 'ARIA_LABELLED_BY',
ariaDescribedBy: "ARIA_DESCRIBED_BY",
listeners: {
show: function () {
console.log(
this.el.dom.getAttribute('aria-label'),
this.el.dom.getAttribute('aria-labelledby'),
this.el.dom.getAttribute('aria-describedby')
);
}
}
}).show();
}
});
Ext.create('Ext.Button', {
text: 'msgbox',
renderTo: Ext.getBody(),
handler: function () {
Ext.create('Ext.window.MessageBox', {
closeAction: 'destroy',
ariaLabel: 'ARIA_LABEL_VALUE',
//ariaLabelledBy: 'ARIA_LABELLED_BY',
ariaDescribedBy: "ARIA_DESCRIBED_BY",
listeners: {
show: function () {
console.log(
this.el.dom.getAttribute('aria-label'),
this.el.dom.getAttribute('aria-labelledby'),
this.el.dom.getAttribute('aria-describedby')
);
}
}
}).show({
title: 'Invalid search criteria',
cls: 'error-message',
msg: 'yooo',
containsFocus: true,
ariaLabel: 'msg yoo',
modal: true,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK,
});
}
});
}
});
fiddle
I have tried below code its working fine for first time, but when I close popup and click on button again it stops working.
var myForm = new Ext.form.Panel({
width: 500,
height: 400,
title: 'Foo',
floating: true,
closable : true
});
//myForm.show();
Ext.create('Ext.Button', {
text: 'Click Me',
renderTo: Ext.getBody(),
listeners: {
click: function() {
myForm.show();
}
}
});
Because by default closeAction is equal to 'destroy', which means component will be destroyed on clicking the close button. After you destroy your myForm object, it won't be available on the second try.
solution:
1) You can change closeAction to 'hide' and after clicking the close button component will just hide in dom.
var myForm = new Ext.form.Panel({
width: 500,
height: 400,
title: 'Foo',
floating: true,
closable: true,
closeAction: 'hide'//<-------------
});
2) You can create new object on every click on the button.
Ext.create('Ext.Button', {
text: 'Click Me',
renderTo: Ext.getBody(),
listeners: {
click: function () {
new Ext.form.Panel({
width: 500,
height: 400,
title: 'Foo',
floating: true,
closable: true
}).show();
}
}
});
You can add the following to your panel. That would hide it after you close it
closeAction: 'hide'
If you were building a big screen though you'd be better off leaving it as is (it keeps the dom tidy) but you'll need to recreate the component then when you click the button again
I have an ExtJS toolbar at the top of my panel that can have between 5 and 10 actions (buttons), plus a search text field as the last item.
Depending on the size of the window, all items may fit directly on the toolbar, or some of them may get put into a "more" menu button. I need to specify one of those button to have some sort of priority so it is the last one to be put on the "more" button. Or even to never be put on it.
Is there any way to achieve this?
Solution:
Add items with code. I don't know if this is exactly your case, but I often use this to arrange buttons in toolbar:
Working example:
Ext.onReady(function(){
Ext.QuickTips.init();
Ext.FocusManager.enable();
Ext.Ajax.timeout = 100 * 1000;
Ext.define('Trnd.TestWindow', {
extend: 'Ext.window.Window',
closeAction: 'destroy',
border: false,
width: 400,
height: 500,
modal: true,
closable: true,
resizable: true,
layout: 'fit',
fillToolbar: function() {
var me = this;
me.toolbar.add(me.button5);
me.toolbar.add(me.button1);
me.toolbar.add(me.button2);
me.toolbar.add(me.button3);
me.toolbar.add(me.edit);
me.toolbar.add(me.button4);
},
initComponent: function() {
var me = this;
me.callParent(arguments);
me.button1 = Ext.create('Ext.button.Button', {
text: 'Button 1'
});
me.button2 = Ext.create('Ext.button.Button', {
text: 'Button 2'
});
me.button3 = Ext.create('Ext.button.Button', {
text: 'Button 3'
});
me.button4 = Ext.create('Ext.button.Button', {
text: 'Button 4'
});
me.button5 = Ext.create('Ext.button.Button', {
text: 'Button 5'
});
me.edit = Ext.create('Ext.form.TextField', {
text: 'Edit'
});
me.toolbar = Ext.create('Ext.toolbar.Toolbar', {
enableOverflow: true,
items: []
});
me.panel = Ext.create('Ext.panel.Panel', {
tbar: me.toolbar
});
me.add(me.panel);
me.fillToolbar();
}
});
var win = new Trnd.TestWindow({
});
win.show();
});
Notes:
Tested with ExtJS 4.2
I solved this by wrapping the toolbar in a container like this:
tbar: [
{
xtype: 'container',
layout: {
type: 'hbox',
pack: 'start',
align: 'stretch'
},
items: [
{
xtype: 'mail-compose-toolbar',
flex: 1
},
{
xtype: 'mail-compose-search',
itemId: 'mailComposeSearch',
width: 200
}
]
}
]
The search field is of fixed width and the toolbar has a flex:1 so it stretches.
I have a border layout with two panels inside center and west regions. By default, west panel is collapsed and if you click on any part of the title bar while is collapsed, the panel is temporary expanded until you move the mouse pointer out of its boundaries.
What I want to do is to have this same "temporary expand" not by clicking on the panel's title bar, but just hovering over it. How can I make that possible?
Here is my code:
Ext.onReady(function() {
Ext.create('Ext.window.Window', {
width: 500,
height: 300,
layout: 'border',
items: [{
xtype: 'panel',
title: 'Center Panel',
region: 'center',
flex: 1
},{
xtype: 'panel',
title: 'West Panel',
region: 'west',
flex: 1,
collapsible: true,
collapsed: true,
animCollapse: false,
collapseDirection: Ext.Component.DIRECTION_BOTTOM,
titleCollapse: true
}]
}).show();
});
Please refer to the following fiddle for your convenience: http://jsfiddle.net/3FJ58/3/
Thanks in advance!
Yes, this is possible but you have to extend from Ext.panel.Panel to override the getPlaceholder method that is used by the borderlayout
getPlaceholder: function(direction) {
var me = this,
collapseDir = direction || me.collapseDirection,
listeners = null,
placeholder = me.placeholder,
floatable = me.floatable,
titleCollapse = me.titleCollapse;
if (!placeholder) {
if (floatable || (me.collapsible && titleCollapse)) {
listeners = {
mouseenter: {
// titleCollapse needs to take precedence over floatable
fn: (!titleCollapse && floatable) ? me.floatCollapsedPanel : me.toggleCollapse,
element: 'el',
scope: me
}
};
}
me.placeholder = placeholder = Ext.widget(me.createReExpander(collapseDir, {
id: me.id + '-placeholder',
listeners: listeners
}));
}
// User created placeholder was passed in
if (!placeholder.placeholderFor) {
// Handle the case of a placeholder config
if (!placeholder.isComponent) {
me.placeholder = placeholder = me.lookupComponent(placeholder);
}
Ext.applyIf(placeholder, {
margins: me.margins,
placeholderFor: me
});
placeholder.addCls([Ext.baseCSSPrefix + 'region-collapsed-placeholder', Ext.baseCSSPrefix + 'region-collapsed-' + collapseDir + '-placeholder', me.collapsedCls]);
}
return placeholder;
}
See the updated JSFiddle
Overriding is at least the cleanest way IMO. But it would also be possible to manipulate the placeholder created by the borderlayout.
#JoseRivas already posted something like this but with some issues I will add the snipped how this can be done in a cleaner way
listeners: {
afterrender: function(p){
p.placeholder.getEl().on('mouseenter', function(){ p.floatCollapsedPanel() })
}
}
See the updated JSFiddle
jacoviza. Can you try to capture focus event of panel. this link helps you. Extjs panel. Keyboard events
add a listener to the el of the placeholder for mouseover and then call the floatCollapsedPanel()
Ext.onReady(function () {
Ext.create('Ext.window.Window', {
width: 500,
height: 300,
layout: 'border',
items: [{
xtype: 'panel',
title: 'panel1',
region: 'center',
flex: 1
}, {
xtype: 'panel',
title: 'panel2',
region: 'west',
flex: 1,
id: 'mypanel2',
collapsible: true,
collapsed: true,
animCollapse: false,
collapseDirection: Ext.Component.DIRECTION_BOTTOM,
titleCollapse: true,
listeners: {
afterrender: {
fn: function (self) {
self.placeholder.getEl().on('mouseover', function () {
var panel = Ext.getCmp('mypanel2');
panel.floatCollapsedPanel()
})
}
}
}
}]
}).show();
});
I want to show message box when user click (X) button of ext window, and on 'ok' button of message box window will close. I wrote the code but it closes window first than show message box. Here is the code:
var assignReportFlag = 0;
var assignReportLoader = function(title,url){
var panel = new Ext.FormPanel({
id: 'arptLoader',
height: 485,
border: false,
layout: 'fit',
autoScroll: true,
method:'GET',
waitMsg: 'Retrieving form data',
waitTitle: 'Loading...',
autoLoad: {url: url,scripts: true}
});
var cqok = new Ext.Button({
text:'OK',
id:'1',
handler: function(){
if(assignReportFlag == 1){
assignReportFlag = 0;
Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
}else{
assignReportWindow.close();
}
}
});
var assignReportWindow = new Ext.Window({
layout:'fit',
title: title,
height:Ext.getBody().getViewSize().height - 60,
width:Ext.getBody().getViewSize().width-20,
closable: true,
modal:true,
resizable: false,
autoScroll:true,
plain: true,
border: false,
items: [panel],
buttons: [cqok],
listeners:{
beforeclose:function(){
if(assignReportFlag == 1){
assignReportFlag = 0;
Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
}else{
assignReportWindow.destroy();
}
}
}
});
function showResult(btn){
assignReportWindow.destroy();
};
assignReportWindow.show();
};
Thanks
In your beforeclose listener return false to stop the close event being fired.
This works fine for me.Have a look
http://jsfiddle.net/DrjTS/266/
var cqok = new Ext.Button({
text:'OK',
id:'1',
handler: function(){
Ext.MessageBox.alert('Status', 'Changes has been saved successfully',showResult);
}
});
Ext.create('Ext.panel.Panel', {
title: 'Hello',
width: 200,
renderTo: Ext.getBody(),
items:[
{
xtype:'button',
text:'SUBMIT',
handler:function(thisobj)
{
Ext.create('Ext.window.Window', {
id:'W',
height: 200,
width: 400,
layout: 'fit',
buttons: [cqok],
listeners:{
beforeclose:function(){
Ext.MessageBox.alert('Status', 'Changes has been saved');
}
}
}).show();
}
}
]
});
function showResult(btn){
Ext.getCmp('W').destroy();
};