Skip to content

Instantly share code, notes, and snippets.

View ppcano's full-sized avatar

Pepe Cano ppcano

View GitHub Profile
@ppcano
ppcano / collection_view_should_respond_to_test_event.js
Created November 10, 2011 18:18
Testing sproutcore-touch passing through child elements
require('sproutcore');
require('sproutcore-touch');
var set = SC.set, get = SC.get;
var tapEndWasCalled = true;
module("Touching handlebars tests", {
setup: function() {
console.group(' - Setup for new test');
@ppcano
ppcano / gesture_manager.js
Created November 15, 2011 12:45
Simulating Touch Events in mouse environment
mouseDown: function(evt, view) {
//console.log( ' mouse down.......');
//console.log( evt );
var simulatedEvent = new jQuery.Event();
simulatedEvent.type='touchstart';
simulatedEvent['originalEvent'] = {
targetTouches: [{
id: 0,
pageX: evt.pageX,
@ppcano
ppcano / observing_view.js
Created November 15, 2011 20:31
UI Controller observes a view to set properties
SC.addObserver(view, 'element' ,function() {
var element = view.get('element');
if ( element ) {
var deviceHeight = $(window).height();
var headerHeight = $('#header').outerHeight(); // null
var footerHeight = $('#footer').outerHeight(); // null
var availableHeight = deviceHeight - headerHeight - footerHeight;
@ppcano
ppcano / bind_class_helper.js
Created November 16, 2011 11:26
Binding class attribute with SC2-handlebars
SC.Handlebars.registerHelper('bindClass', function(options) {
var attrs = options.hash;
var view = options.data.view;
var ret = [];
var dataId = ++jQuery.uuid;
@ppcano
ppcano / scrollable_view.js
Created November 17, 2011 17:49
ScrollableView using sproutcore-touch
UI.Kit.ScrollableView = SC.CollectionView.extend({
// options
animationDuration: 1000,
easing: "easeOutExpo",
// must be set ( pixels available) to provide elastic scroll
scrollableHeight: 0,
// options elastic
@ppcano
ppcano / application.js
Created November 17, 2011 19:07
Ripple, SC2 triggering phonegap events
TestView.View1.app = SC.Application.create({
customEvents: {
backbutton : 'backButton',
deviceready : 'deviceReady',
resume : 'resume'
}
});
@ppcano
ppcano / phonegapevents.js
Created November 18, 2011 12:46
phone gap events in sc20
var get = SC.get, set = SC.set;
PG.PhoneGapEvents = SC.Mixin.create({
phoneGapEvents: {
deviceready: 'deviceReady',
pause: 'pause',
resume: 'resume',
online: 'online',
offline: 'offline',
@ppcano
ppcano / strobe.js
Created November 24, 2011 17:13
Strobe Client Proxy
// Copyright 2011 Strobe, Inc. All rights reserved.
(function ($) {
var Strobe = {};
/**
Strobe global object.
@class Strobe
@static
*/
@ppcano
ppcano / observes_test.js
Created November 24, 2011 19:30
Observing failing test ( don't understand something ??? )
test("Observes data... ", function() {
var count = 0;
//var model = SC.IO.Resource.create({
var model = SC.Object.create({
data: null
});
@ppcano
ppcano / handler.js
Created December 1, 2011 11:12
configuring socket server
this.manager.configure( function (){
this.set('authorization', function (handshakeData, callback) {
console.log( 'inside authorization......');
var room_id = handshakeData.query.room;
var authorized = this.room_trigger[room_id]!=undefined;
var error = authorized ? undefined : 'room is not available';
callback(error, authorized);