Skip to content

Instantly share code, notes, and snippets.

View mcelotti's full-sized avatar

Marco Celotti mcelotti

  • Udine
View GitHub Profile
@mcelotti
mcelotti / GridPagingToolbar.js
Last active August 6, 2017 07:52
ExtJS6 Modern: Ext.grid.plugin.PagingToolbar that interacts with grid's store
/**
* When I first used the "Ext.grid.plugin.PagingToolbar" plugin with ExtJS6.2 modern I thought it could interact and load prev/next pages using the grid's store.
* The fact is that the pagingtoolbar does not interact with the store, it splits "pages" of data within the current grid data, but this is not what I was looking for.
* Therefore here's my attempt to extend the PagingToolbar and create a paging plugin that actually loads store pages according to the slider.
*/
Ext.define('MyApp.util.GridPagingToolbar', {
extend: 'Ext.grid.plugin.PagingToolbar',
@mcelotti
mcelotti / android_forward_result
Last active October 10, 2022 06:48
Android FLAG_ACTIVITY_FORWARD_RESULT howto
Nav flow is: A => B => C => A with results from C
If you're using fragments please note that "onActivityResult" will be called according to where "startActivityForResult" is called (method "startActivityForResult" is available in both, activity and fragment)
ActivityA
startActivityForResult(intentB, 22);
ActivityB
intentC.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
startActivity(intentC);
finish();
@mcelotti
mcelotti / Model.js
Last active November 20, 2015 09:27
Sencha Touch 2.4.2 override validate() to pass model and allow cross-field validation
Ext.define('MyApp.override.data.Model', {
override : 'Ext.data.Model',
/**
* @override
* we want to pass the model (not only config and value)
*/
validate : function() {
var errors = Ext.create('Ext.data.Errors'),
validations = this.getValidations().items,
Ext.define('Ext.ux.TimestampIdentifier', {
alias : 'data.identifier.timestamp',
config : {
negative : false,
string : true
},
constructor : function(config) {
this.initConfig(config);
@mcelotti
mcelotti / Ext.ux.Base64.js
Last active November 5, 2015 13:08
Ext.ux.Base64
//jshint camelcase:false
Ext.define('Ext.ux.Base64', {
singleton : true,
_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
encode : function(e) {
var t = "";
var n,
r,
i,
(function() {
var drawImage = function() {
var imageData = this.getImgData();
var maxWidth = this.getWidth();
var maxHeight = this.getHeight();
if (imageData && maxHeight && maxWidth) {
var img = document.createElement("img");
img.src = imageData;