This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('uiModules') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.getView().backgroundImage = getImageFileFromSVG({ | |
image : "/images/hearts.svg", | |
width : 400, | |
height : 400, | |
top : 0, | |
left : 0 | |
}); | |
function getImageFileFromSVG(svgOpts) { | |
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// app/lib/SVGProduct.js | |
function getImageFileFromSVG(svgOpts, name) { | |
var file = Ti.Filesystem.getFile(Ti.Filesystem.applicationCacheDirectory, | |
Ti.Utils.md5HexDigest(JSON.stringify(svgOpts))); | |
if (!file.exists()) { | |
var SVG = require('com.geraudbourdin.svgview'); | |
if (!file.write(SVG.createView(svgOpts).toImage())) { | |
Ti.API.error("Can't save to file. Product:", name); | |
return null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.populateCallLog = function(listview, items) { | |
var helper = require('listViewHelper'); | |
return helper.populate(listview, items, false /*no merge*/, function sectionGenerator(lv, items) { | |
var moment = require("alloy/moment"); | |
var headerViewCtrl = Alloy.createController('modules/call/log/pickerSectionHeaderView'); | |
var dateTitle, | |
item = items[0], | |
utcTime = new Date(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('networkMonitor').init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//******** 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()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function resizePhoto(blob, size) { | |
var measurement = require('alloy/measurement'), w, h; | |
if (blob.width / blob.height >= size.width / size.height) { | |
w = measurement.dpToPX(size.width); | |
h = blob.height * measurement.dpToPX(size.width) / blob.width; | |
} else { | |
w = blob.width * measurement.dpToPX(size.height) / blob.height; | |
h = measurement.dpToPX(size.height); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Created by: Andrey Tkachenko falko.lab@gmail.com | |
Source: https://gist.github.com/falkolab/c56585874223216e85d3 | |
This is fix code for https://jira.appcelerator.org/browse/TIMOB-20357 | |
!!! You must use only $.addListener for fixed button NOT button.addEventListener | |
`win` argument can be omited if controller root is Window already. | |
example: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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":"")), |