Skip to content

Instantly share code, notes, and snippets.

View ppcano's full-sized avatar

Pepe Cano ppcano

View GitHub Profile
@ppcano
ppcano / is_scroll_visible.js
Created June 29, 2012 13:53
Mixin to mark a view being visible via the scroller ( also using iscroll4 )
Yn.IsScrollVisible = Em.Mixin.create({
scrollVisibleId: null,
isScrollVisible: false,
didInsertElement: function() {
this._super();
var scroll = $(this.scrollVisibleId);
@ppcano
ppcano / assetfile.rb
Created July 4, 2012 07:26
Using Environments
config = ( !ENV['APP_ENV'].nil? && !ENV['APP_ENV'].empty? ) ? ENV['APP_ENV'] : "default"
match "app/config/**/#{config}.js" do
minispade :rewrite_requires => true, :string=> false, :module_id_generator => proc { |input|
id = input.path.dup
id.sub!(/\/[a-z\-\.]+.js$/, '') #filter file.js name
id
}
@ppcano
ppcano / logo_switch_button.css
Created July 10, 2012 08:32
Flip Switch Button with Ember on Touch Environment
@white00:#fefefe;
@white01:#f9f9f9;
@white02:#fbfbfb;
@white03:#f0f0f0;
@white04:#efefef;
@grey00:#919191;
@grey01:#7d7d7d;
@grey02:#7f7f7f;
@grey03:#b6b6b6;
@ppcano
ppcano / view.js
Created July 17, 2012 15:09
any possible workaround to set ElementId on init method?
elementId: Ember.computed(function(key, value) {
return value !== undefined ? value : Ember.guidFor(this);
}).cacheable(),
_elementIdDidChange: Ember.beforeObserver(function() {
throw "Changing a view's elementId after creation is not allowed.";
}, 'elementId'),
@ppcano
ppcano / transition_end_on_app.js
Created July 18, 2012 14:48
How to receive transitionEnd events on the view layer, which option is the most suitable?
App = Em.Application.create({
customEvents: {
webkitTransitionEnd: 'transitionEnd'
}
});
Em.View.extend({
transitionEnd: function(event) {
@ppcano
ppcano / example.handlebars
Created August 14, 2012 11:15
Ember Gesture does not avoid to bubble up.
<!-- id = touch-test -->
{{#view Yvi.TouchHoldView id="hold" }}
<div id="hold-scroller">
<div id="hold-scroller-container">
<div/><div/><div/><div/><div/><div/><div/><div/>
<div/><div/><div/><div/><div/><div/><div/><div/>
@ppcano
ppcano / comparison.js
Created September 11, 2012 10:35
Handlebar helper to comparte ember objects
var getBindingValue = function(context, options, path) {
var normalized = Ember.Handlebars.normalizePath(null, path, options.data),
thisContext;
if (normalized.isKeyword) {
thisContext = normalized.root;
} else if (!Ember.isGlobalPath(path)) {
thisContext = context;
} else {
@ppcano
ppcano / store.js
Created September 14, 2012 09:35
Ember-data cleanRecordCache
Yn.Store = DS.Store.extend({
revision: 4,
serverDomain: "",
adapter: Yn.DjangoTastypieAdapter.create({
}),
cleanRecordCache: function(type) {
var typeMaps = this.get('typeMaps');
@ppcano
ppcano / adapter.js
Created September 26, 2012 10:55
Adapter
Yn.DjangoTastypieAdapter = DS.DjangoTastypieAdapter.extend({
/*
* API credential to be inserted in the ajax requests
*/
authHeader: null,
@ppcano
ppcano / reload.js
Created September 26, 2012 11:01
ember reload
reload: function(record, query, rollback ) {
if ( record.get('isDirty') ) {
if ( rollback === true ) {
// this will rollback the record to the last loaded values in the
// store
record.send('rollback');