swiping event handling - swipe

I am coding swipe to remove functions. It works fine on the first event but..if I swipe twice...it doesn't seem to work properly.
I don't know why "Delete" button disappears if I swipe left twice.
Please see my code below:
<div id="showlist">
<div id="btn_del">Delete</div>
</div>
<style>
#showlist {
width:100%;
height:100px;
background:#DDD;
border-bottom:1px dashed #666;
}
#btn_del {
float:right;
margin-right:-60px;
background:red;
padding:5px;
display:none;margin;
border:1px solid #FFF;
margin-top:20px;
color:#FFF;
font:12px Arial;
font-wieght:bold;
border-radius:5px;
}
</style>
<script>
$('#showlist').bind({
swipeleft: function() {
$("#showlist").animate( {'width': '90%'}, 300 );
$("#btn_del").fadeIn();
},
swiperight: function() {
$("#btn_del").hide();
$("#showlist").animate( {'width': '100%'}, 300 );
},
preventDefaultEvents: true
});
Demo:
http://jsfiddle.net/Chae/uLwJg/2/
Any help would be very appreciated.
Chae from Seoul

I have simply solved the problem myself.
I put the checking code for visibility of delete button object.
$('#showlist').bind({
swipeleft: function() {
chk = $("#btn_del").is(':visible');
if (!chk) {
$("#showlist").animate( {'width': '90%'}, 300 );
$("#btn_del").fadeIn();
}
},
swiperight: function() {
$("#btn_del").hide();
$("#showlist").animate( {'width': '100%'}, 300 );
},
preventDefaultEvents: true
});

Related

EXTJS 4 how to validate radio group?

Before I dive into source code and hack it.
I set allowBlank: false on radio group. I would like to mark it if none of the radio is selected. What method to override ?
Regards
Armando
just override validate method and do the magic there.
.field-container-error-border {
background-image: url(../ext4/extjs/ext-4_2_1/resources/ext-theme-gray/images/grid/invalid_line.gif);
background-repeat: repeat-x;
background-position: bottom;
border-bottom: 1px solid #c30 !important;
}
Ext.override(Ext.form.RadioGroup, {
validate: function() {
let isValid = this.callParent();
let el = Ext.dom.Element.get(this.el.query('.x-table-plain')[0]);
if (!isValid) {
el.addCls('field-container-error-border');
} else {
el.removeCls('field-container-error-border');
}
return isValid;
},
});

pressedCls doesn´t work with segmentedButton in Sencha Touch app

I am working with a Sencha Touch app with the component "segmentedbutton"
{
xtype : 'segmentedbutton',
cls : 'filterbar-segmented-button',
pressedCls: 'filterbar-segmented-button-pressed',
items : [
{
itemId : 'showAllCustomers',
iconCls : 'user',
iconMask: true,
pressed : true
},
{
itemId : 'showCustomersWithSurvey',
iconCls : 'compose',
iconMask: true
}
]
}
I am specifying different css classes depending of the button is pressed or not.. but it is not working correctly and the colour of the font is not changing..
Here the css code:
.filterbar-segmented-button {
padding-left: 18%;
color: blue;
.filterbar-segmented-button-pressed{
background-color: blue;
color: white;
}
}
What am I doing wrong?
Thank you in advance
Your Applying Css In Wrong Way the Hierarchy of the Css Class is Wrong
'filterbar-segmented-button',
'filterbar-segmented-button-pressed'
These Two Css Will be applied to the Same Segmented Button.
Inorder to Apply the Presed Cls For the Button
.filterbar-segmented-button.filterbar-segmented-button-pressed{
//PRessed Cls Code
}
This Will Work As Expected
I found the solution of this way..
.filterbar-segmented-button {
padding-left: 18%;
color: blue;
.filterbar-segmented-button-pressed{
background-color: blue;
.x-button-icon,
.x-button-label {
color: #f8f8f8;
}
}
}
Your css is not correct. Try this.
.filterbar-segmented-button {
padding-left: 18%;
color: blue;
}
.filterbar-segmented-button-pressed{
background-color: blue;
color: white;
}

Extjs Chart Legend items with scroll bar when legend items overflows

I have an Ext JS pie chart with too many items. Because of this legend overflows and few items are not visible. I took a look at Smart legends (https://market.sencha.com/extensions/ext-ux-chart-smartlegend). But that seems ugly when the legend items are too many, and that makes the Chart looks tiny. So I'm looking for a solution where it would add a vertical scrollbar (when legend is in left or right hand side of the graph).
I was trying to see if I could add the scrollable container to the graph on which I could add the legends and when it overflows, scrollable container would add the scrollbar. So I was trying to override the "Ext.chart.Legend", and override the 'createBox' function. But I'm not sure how to add the component to the Chart since createBox() adds the Sprite to the chart's surface. Not sure how to add the 'scrollable container' to the chart on which I could add the legend.
Basically I'm looking for the graph which looks like in the attached image. Please help me on this.!! I need it ASAP. Thanks in advance!
https://www.dropbox.com/s/4q9o6v5ei4ba96r/Chart%20Legend%20items%20with%20scroll%20bar.png
Thanks!
Omega
JavaScript:
Ext.override(Ext.chart.Legend, {
createItems: function() {
if (this.customLegend != null) {
this.customLegend.remove();
}
this.customLegend = $('<div class="custom-legend"></div>');
$(this.chart.el.dom).append(this.customLegend);
this.callParent();
},
createLegendItem: function(series, yFieldIndex) {
var colorItem = series.getLegendColor(yFieldIndex).match(/.+?\-(.+?)\-.+?/i)[1];
var legendItem = $('<div class="custom-legendItem"><div class="custom-legendItemMarker" style="background-color: #'+colorItem+'"></div>'+series.yField[yFieldIndex]+'</div>');
$(this.customLegend).append(legendItem);
legendItem.on('mouseover', function() {
series._index = yFieldIndex;
series.highlightItem();
});
legendItem.on('mouseout', function() {
series._index = yFieldIndex;
series.unHighlightItem();
});
legendItem.on('mousedown', function() {
var me = this,
index = yFieldIndex;
if (!me.hiddenSeries) {
series.hideAll(index);
legendItem.addClass('hide');
} else {
series.showAll(index);
legendItem.removeClass('hide');
}
me.hiddenSeries = !me.hiddenSeries;
me.legend.chart.redraw();
});
},
updateItemDimensions: function() {
return {
totalWidth: 0,
totalHeight: 0,
maxWidth: 0,
maxHeight: 0
};
},
updatePosition: function() {
},
removeItems: function() {
}
});
CSS:
.custom-legend {
position: absolute;
right: 20px;
top: 0;
height: 100%;
overflow-y: auto;
border: 1px solid #CCC;
padding: 20px;
min-width: 200px;
}
.custom-legendItem {
margin: 4px 0;
}
.custom-legendItem.hide {
opacity: 0.5;
}
.custom-legendItem:hover {
cursor: pointer;
font-weight: bold;
}
.custom-legendItemMarker { display: inline-block; width: 12px; height: 12px; margin-right: 12px; }

Apply a loadmask to Viewport that also covers floating Components

How can I add a loadmask within the launch method of the Ext.applcation to the viewport that will also covers floating components like windows when get showed?
Currently the mask work but does not cover any opened window.
I found the answer here, the trick is to increase the z-order of the mask:
Ext.getBody().mask().dom.style.zIndex = '99999';
I made a test, it works for me.
You can create custom loader that will hide itself when everything is loaded...
1.Create html holder in body:
<div id="loading-mask"></div>
<div id="loading">
<span id="loading-message">Loading. Please wait...</span>
</div>
2. Add css to properly position mask:
#loading-mask {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: #ffffff;
z-index: 1;
}
#loading {
position: absolute;
top: 40%;
left: 45%;
z-index: 2;
font-family: tahoma,arial,verdana,sans-serif;
font-size: 12px;
}
#loading span {
padding: 5px 30px;
display: block;
}
3. Create js function outside Ext.onReady call:
function hidePreloader() {
var loadingMask = Ext.get('loading-mask');
var loading = Ext.get('loading');
// Hide loading message
loading.fadeOut({ duration: 0.2, remove: true });
// Hide loading mask
loadingMask.setOpacity(0.9);
loadingMask.shift({
xy: loading.getXY(),
width: loading.getWidth(),
height: loading.getHeight(),
remove: true,
duration: 1,
opacity: 0.1,
easing: 'bounceOut'
});
}
4. Call hidePreloader method when all components and tasks are completed and ready, in your case after app.js launch method is fininshed loading, for example:
listeners: {
afterrender: function(form) {
hidePreloader();
}
}
here is a example in fiddle.
I preferred my solution with CSS:
body.x-masked .x-mask {
z-index: 20000;
}
since window z-index is 19001, so 20000 is not bad.

How to make Extjs Button look a link?

I want to either make a link in Extjs or make a button look like a link and on hover you see the button. They do this in the docs with Code Editor button and the Live Preview button.
If they do this using CSS, what CSS do I use and when/how to I apply it?
I recently wanted a LinkButton component. I tried to find a pre-existing component without any luck, so I ended up writing one from scratch. Its implementation is almost entirely CSS-based.
/******************************************************************************/
/*** LINK BUTTON CSS **********************************************************/
/******************************************************************************/
a.ux-linkbutton {
background-image: none;
border: 0px none;
margin-top: 1px;
}
a.ux-linkbutton.x-btn-default-small-focus {
background-color: inherit;
}
a.ux-linkbutton * {
font-size: inherit !important;
}
a.ux-linkbutton:hover {
text-decoration: underline;
background-color: inherit;
}
/******************************************************************************/
/*** LINK BUTTON JS ***********************************************************/
/******************************************************************************/
Ext.define( "Ext.ux.button.LinkButton", {
extend: "Ext.button.Button",
alias: "widget.linkbutton",
cls: "ux-linkbutton",
initComponent: function() {
this.callParent();
this.on( "click", this.uxClick, this, { priority: 999 } );
},
// This function is going to be used to customize
// the behaviour of the button and click event especially as it relates to
// its behaviour as a link and as a button and how these aspects of its
// functionality can potentially conflict.
uxClick: function() {
//Ext.EventObject.preventDefault();
//Ext.EventObject.stopEvent();
//Ext.EventObject.stopPropagation();
//return false;
}
} );
The click handler is a work-in-progress.
The class does have one minor issue: a pseudo-class style is applied after clicking/focusing that I have not been able to remove. If someone fixes it before I do, please, post the CSS for it.
With Ext 4.0.7 I had managed to do the following:
View:
...
{
xtype: 'button'
,text: 'Discard changes'
,action: 'cancel'
,cls: 'secondary-action-btn'
}
CSS:
....
.secondary-action-btn {
border: none;
background: none;
}
.secondary-action-btn span {
cursor: pointer;
text-decoration: underline;
}
I recall there is an extension called linkButton. You can refer to the extjs forum here

Resources