Skip to content

Instantly share code, notes, and snippets.

View falkolab's full-sized avatar
🏠
Working from home

Andrey Tkachenko falkolab

🏠
Working from home
  • Russian Federation
View GitHub Profile
@falkolab
falkolab / alloy.js
Last active August 29, 2015 14:10
TIMOB-18128 monkey patch
var patches = require('patches');
patches.fix_displayCaps();
@falkolab
falkolab / base.js
Last active September 4, 2015 13:31
View proxy remain in memory after window closed. https://yadi.sk/i/jmtrY-I0isR3g
exports.setMenuItemEnabled = function(menuItem, isEnabled) {
if(OS_ANDROID) {
if(Alloy.Globals.isAndroid3Plus && menuItem.actionView) {
menuItem.actionView.touchEnabled = isEnabled;
}
menuItem.setEnabled(isEnabled);
}
};
@falkolab
falkolab / index.js
Last active September 22, 2015 07:53
Memory leak test case for Titanium SDK
function doClick(e) {
Alloy.createController("test").getView().open();
}
$.index.open();
@falkolab
falkolab / alloy.js
Last active October 15, 2015 09:54
Android VERSION_CODES for Titanium SDK
Alloy.Globals.Android = Alloy.Globals.Android || {};
_.extend(Alloy.Globals.Android.VERSION_CODES, {
CUR_DEVELOPMENT: 10000,
BASE: 1,
BASE_1_1: 2,
CUPCAKE: 3,
DONUT: 4,
ECLAIR: 5,
ECLAIR_0_1: 6,
ECLAIR_MR1: 7,
require('uiModules')
@falkolab
falkolab / demo.js
Created December 5, 2015 12:30
underscore string mixin
//******** underscore.string ***********
var _ = require("alloy/underscore")._;
// Import Underscore.string to separate object,
// because there are conflict functions (include, reverse, contains)
_.str = require('underscore.string');
// Mix in non-conflict functions to Underscore namespace if you want
_.mixin(_.str.exports());
@falkolab
falkolab / bbcode2html.js
Created February 6, 2016 18:46
Android: HTML tags and localized strings for Titanium SDK.
/* Escapes a string for use with regular expressions */
function escapeString(input) {
return input.replace(/([\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g,
function(c){return "\\" + c;});
}
/* replaces all */
function replaceAll(search, input, replacement, ignore) {
return input.replace(
new RegExp(escapeString(search), "g"+(ignore?"i":"")),
@falkolab
falkolab / alloy.js
Last active February 7, 2016 02:58
Network state monitor for Titanium SDK
require('networkMonitor').init();
@falkolab
falkolab / momentLang.js
Last active February 11, 2016 10:11
Set Moment locale to the Titanium SDK Ti.Locale.currentLocale
var moment = require('alloy/moment');
// First add languages that support your application
var languages = ['ru', 'nl', 'fr', 'fr-ca'];
// Full language list: https://github.com/appcelerator/alloy/tree/master/Alloy/builtins/moment/lang
// You must explicit way to require language files in order to compiler saw their.
require('alloy/moment/lang/ru');
require('alloy/moment/lang/nl');
require('alloy/moment/lang/fr');
@falkolab
falkolab / fixmenu.js
Last active February 14, 2016 19:50
Fix for not displayed ActionBar menu in Titanium SDK
// Not rendered menu fix
// Author: Andrey Tkachenko, falkolab
// Source: https://gist.github.com/falkolab/29ab007f4981f1d747f2
exports.fix = function(win) {
if (win.activity) {
win.addEventListener('open', function fixMenu(evt) {
evt.source.removeEventListener(evt.type, fixMenu);
var activity = evt.source.activity;
if (activity.onCreateOptionsMenu) {
activity.onCreateOptionsMenu = _.partial(function(func, e) {