Skip to content

Instantly share code, notes, and snippets.

View altintx's full-sized avatar

Brian altintx

View GitHub Profile
@altintx
altintx / swipe_to_delete.js
Created April 20, 2012 19:26
Swipe to Delete on Sencha Touch 2.0 list
/* Assuming:
* dataview is a { xtype: "list" }
* dataview.itemTpl includes a <div class="deleteplaceholder"></div>
*
* Delete button will disappear as soon as something is touched
*/
dataview.on("itemswipe", function(dataview, ix, target, record, event, options) {
if (event.direction == "left") {
var del = Ext.create("Ext.Button", {
@altintx
altintx / src.ux.ComboButton.js
Created April 27, 2012 20:56
Sencha Touch button that can recognize long taps
Ext.define("Ext.ux.ComboButton", {
extend: "Ext.Button",
alias: "widget.combobutton",
initialize: function() {
var $this = this;
var touches = {};
this.element.on("tap", function(event, node, options, eOpts) {
var T = touches[event.touch.identifier];
@altintx
altintx / Card.js
Created October 3, 2012 22:09
In a Sencha Touch navigation view, have you ever wanted different buttons in the titlebar portion of individual cards? With the activeitemchange listener down below, each card can declare their own navbar buttons (or even other types of widgets) and they'll be automatically appear when that particular card is active.
Ext.define("App.view.default.Card", {
extend: "Ext.List",
alias: "widget.defaultcard",
navigationBarItems: [
{
text: "Add",
align: "right",
eventName: "add"
}
@altintx
altintx / group_or_sort_by_custom_renderer.js
Created September 4, 2013 17:08
In Ext.js 4, sort or group by a rendered value in a grid. Groupers/Sorters are store functions, renderers are grid functions, so this data typically lives in incompatible places. What we do is establish a rendered_ shadow copy of the data the renderer works with, render the shadow, and persist render output IN the renderer, so sorting and groupi…
// model
Ext.define("Person", {
extend: "Ext.data.Model",
fields: ["name", "parents", "renderered_parents"]
});
// store
var Family = Ext.create("Ext.data.Store", {
model: "Person",
data: [
function flatten(input) { console.log(input);
var _flatten = (input, output) => {
console.debug("flattening %o", input);
return input.reduce((output, item) => {
if (typeof item == "object" && item instanceof Array) {
console.debug("flattening nested array %o", item);
return _flatten(item, output);
} else {
output.push(item);
return output;
@altintx
altintx / fix-bootstrap-4-dropdown-menus.js
Last active April 18, 2017 15:50
In bootstrap 4 alpha 6 dropdown menus don't open. These jQuery listeners fix it.
$(document).on('click', ".dropdown [data-toggle=dropdown]", function(eve){
const button = $(eve.target),
dropdownContainer = button.parent(".dropdown");
const closeMenu = function() {
dropdownContainer.removeClass("show");
$(document).unbind("click", docListener);
$("a", dropdownContainer).unbind("click", menuClickListener);
};