Skip to content

Instantly share code, notes, and snippets.

View davidecassenti's full-sized avatar

Davide Cassenti davidecassenti

View GitHub Profile
@davidecassenti
davidecassenti / myframework.js
Created February 26, 2014 08:11
Appcelerator | How to implement Code Assist in Titanium using ScriptDoc. Supposing you have a MyFramework object with a UI component. The UI component has some static values and a function. Comments are used in the auto-complete process while coding.
/**
* The MyFramework component
*/
var MyFramework = {};
/**
* The UI component
*/
MyFramework.UI = {
@davidecassenti
davidecassenti / api.jsca
Created February 26, 2014 08:05
Sample on how to integrate a custom JSCA file in Titanium, in order to add custom Code Assist. The file can be placed anywhere in the project directory, and the Code Assist will be automatically recognize the new functions. More details on the file format here: http://docs.appcelerator.com/titanium/latest/#!/guide/JSCA_1.0_Specification
{
"types": [{
"name": "HelloWorld",
"examples": [],
"functions": [{
"name": "say",
"parameters": [{
"name": "message",
"usage": "optional",
"type": "String",
@davidecassenti
davidecassenti / home1.js
Created February 18, 2014 15:44
Appcelerator Alloy | Using a common library that can access multiple Alloy views
var HomeLibrary = require('home_library');
// HomeController is the name that will be used inside
// the XML view to access the methods of the library
var HomeController = new HomeLibrary('home1', $);
@davidecassenti
davidecassenti / index.js
Created February 17, 2014 15:21
Appcelerator Titanium | Alloy | Put 2 NavigationWindow inside TabGroup
function openMaster() {
var win = Ti.UI.createWindow({
title: "Master 2",
backgroundColor: 'red'
});
$.master_win.openWindow(win);
}
function openDetail() {
var win = Ti.UI.createWindow({
@davidecassenti
davidecassenti / app.js
Created June 13, 2013 09:02
Titanium convertPointToView example
/**
* This sample shows the usage of the function convertPointToView.
*
* In the example, a view is placed in the main window with relative positioning.
* When the user clicks on one of the titles in the list, the event listener will
* have the click position related to the source object (the row clicked).
*
* However, the goal is to move the description view (the yellow one) inside the
* window, in the position clicked by the user. Using convertPointToView, it is
* possible to convert the data received by the event listener to the position
@davidecassenti
davidecassenti / app.js
Created June 3, 2013 14:22
Node ACS File Upload example This example shows how to upload a file to Node ACS, and how to save it server side. The example uses FormData. Note: upload.html must be on a server (it won't work if running locally as a file); also, it requires jquery to be in the same directory to work. All other files are server side, in the Node ACS app.
// initialize app
function start(app, express) {
app.use(express.methodOverride());
// ## CORS middleware
// see: http://stackoverflow.com/questions/7067966/how-to-allow-cors-in-express-nodejs
//
// PLEASE NOTE: ANY SERVER CAN UPLOAD HERE! YOU SHOULS ONLY ALLOW SPECIFIC SERVERS BY
// EDITING THE ACCESS-CONTROL-ALLOW-ORIGIN HEADER BELOW
var allowCrossDomain = function(req, res, next) {
@davidecassenti
davidecassenti / app.js
Created September 14, 2012 09:47
Appcelerator - Fade out bottom of the image when scrolling down
(function() {
// Create a window
var win = Ti.UI.createWindow({
backgroundColor : 'white'
});
var sv = Ti.UI.createScrollView({
width: Ti.UI.FILL,
height: Ti.UI.FILL,
contentHeight: 1000,