Skip to content

Instantly share code, notes, and snippets.

View alexissmirnov's full-sized avatar

Alexis Smirnov alexissmirnov

View GitHub Profile
Nav.testArray = [];
Nav.TestItem = SC.StaticContentView.extend({});
Nav.mainPage = SC.Page.design({
add: function() {
Nav.testArray.insertAt(Nav.testArray.length, 'some content some content some content some content some content some content');
}
childViews: [
SC.ScrollView.design({
layout: {top: 60, left: 10, width: 200, height: 300},
@alexissmirnov
alexissmirnov / main_page.js
Created August 10, 2010 17:48
SC.ScrollView around SC.StackedView
/*
This example shows how to use SC.StackedView with complex items.
The item view (List.ItemView) must use SC.StaticLayout mixin and
set useStaticLayout to YES -- that's a requirement of SC.StackedView.
Note that children views of List.ItemView also need to add SC.StaticLayout
and set useStaticLayout to YES. This setting doesn't preclude positioning
of child views within its block, by using layout's "left", "width"
*/
/**
* Profile view
*/
Nav.ProfileView = SC.View.extend(SC.Animatable, {
classNames: 'profile-view'.w(),
// initially positioned off screen
transitions: {
left: { duration: .2, timing: SC.Animatable.TRANSITION_EASE_OUT } // with timing curve
},
Below, the path /Users/alexis/workspace/donomo.trunk/inzen/nav contains a SC project
Installed abbot from gem, SC is from quilmes
See abbot error at the end of the output
/Users/alexis/workspace/donomo.trunk/inzen/nav# /usr/bin/sc-build --build app --verbose
INFO ~ Loaded project at: /Users/alexis/workspace/donomo.trunk/inzen/nav
INFO ~ Building targets: /sproutcore/documentation,/sproutcore/datejs,/sproutcore/testing,/sproutcore/tests,/sproutcore/desktop,/sproutcore/test_controls,/nav,/sproutcore/bootstrap,/sproutcore/debug,/sproutcore/table,/sproutcore/docs,/sproutcore/media,/sproutcore/jquery,/nav/src,/sproutcore/runtime,/sproutcore/standard_theme,/sproutcore/mobile,/sproutcore/welcome,/signup,/sproutcore/foundation,/sproutcore/empty_theme,/sproutcore/forms,/sproutcore/greenhouse,/sproutcore/designer,/sproutcore/datastore,/sproutcore/iphone_theme,/sproutcore/ace,/sproutcore/animation,/sproutcore/mini,/sproutcore,/sproutcore/core_tools,/sproutcore/statechart
@alexissmirnov
alexissmirnov / gist:672800
Created November 11, 2010 16:59
Simpler way to work with the SC store and records
App.ObjectsController = SC.ArrayController.extend({
/**
* Pseudo-synchronous API to handle all objects of a given type.
*
* This API in intended to hide the asynchronous nature of retrieving
* records by providing a callback to be called when the data in available.
*
* Example usage:
* App.MyModel.objects().all(function(obj) {console.log(obj);));
@alexissmirnov
alexissmirnov / locale.py
Created June 15, 2011 20:24
Django QueryParameterLocaleMiddleware
from django.middleware import locale
from django.utils import translation
class QueryParameterLocaleMiddleware(locale.LocaleMiddleware):
"""
Django's LocaleMiddleware picks the locale setting of the request from
multiple sources such as a cookie, Accept-Language header and server-side
session.
This middleware adds one more way to specify the language by supplying
App.contactsState = SC.Responder.create( {
didBecomeFirstResponder : function() {
var records = App.store.find(App.contactsQuery);
App.contactsController.set('content', records);
}
});
view = App.ContactsView.design({
contentBinding : 'App.contactsController.arrangedObjects'
});
onClickSendMessageToFavoriteContacts: function() {
var favoriteContacts = App.store.find(App.favoriteContactsQuery);
favoriteContacts.forEach(function(contact) {
App.sendSomeMessage(contact);
});
}
App.Contact.objects().filter({varotite: YES},
function(contacts) {
sendMessage(contacts);
}
);