Skip to content

Instantly share code, notes, and snippets.

View zoghal's full-sized avatar
🏠
Working from home

Saleh Souzanchi zoghal

🏠
Working from home
View GitHub Profile
/*!
* jQuery TextChange Plugin
* http://www.zurb.com/playground/jquery-text-change-custom-event
*
* Copyright 2010, ZURB
* Released under the MIT License
*/
(function ($) {
$.event.special.textchange = {
@zoghal
zoghal / gist:2027599
Created March 13, 2012 08:31 — forked from aaronpeterson/gist:1874366
Cakephp flatten
<?php
// from my ApiComponent
/**
* Flatten Model find data
*
* Will flatten data from a find or find multi response by moving the specified
* className up to the root of the array. Useful for converting find results to
* REST responses.
*
{{#view Luh.Ui.TabMainView currentView="pane1"}}
{{#view Luh.Ui.TabPaneView id="pane1" class="content" viewName="pane1"}}
{{/view}}
{{#view Luh.Ui.TabPaneView id="pane2" class="content" viewName="pane2"}}
{{/view}}
{{#view Luh.Ui.TabMainView currentView="pane1"}}
{{#view Luh.Ui.TabPaneView id="pane1" class="content" viewName="pane1"}}
{{/view}}
{{#view Luh.Ui.TabPaneView id="pane2" class="content" viewName="pane2"}}
{{/view}}
@zoghal
zoghal / gist:2783361
Created May 24, 2012 18:35 — forked from borismus/gist:2165681
dynamic template loading
/*
* Loads a handlebars.js template at a given URL. Takes an optional name, in which case,
* the template is added and is reference-able via templateName.
*/
function loadTemplate(url, name, callback) {
var contents = $.get(url, function(templateText) {
var compiledTemplate = Ember.Handlebars.compile(templateText);
if (name) {
Ember.TEMPLATES[name] = compiledTemplate
} else {
@zoghal
zoghal / gist:2816139
Created May 27, 2012 22:16 — forked from tomdale/gist:1134558
Load remote Handlebars templates
jQuery.get('/templates/foo.handlebars', function(data) {
var template = SC.Handlebars.compile(data);
SC.TEMPLATES['foo'] = template;
})
// A mixin for `Em.ContainerView` that allows an initial render from
// a template, followed by further additions by mutating childViews.
// Note that the template should *only* contain calls to
// `{{childView}}`
App.Mixins.TemplateContainerView = Em.Mixin.create({
render: function() {
if (!this.get('_renderedFromTemplate')) {
Em.View.prototype.render.apply(this, arguments);
this.set('_renderedFromTemplate', true);
@zoghal
zoghal / didRequestRange.js
Created June 4, 2012 16:36
Ember.PaginationSupport
App.collectionController = Em.ArrayProxy.create(Ember.PaginationSupport, {
content: [],
fullContent: App.store.findAll(App.Job),
totalBinding: 'fullContent.length',
didRequestRange: function(rangeStart, rangeStop) {
var content = this.get('fullContent').slice(rangeStart, rangeStop);
this.replace(0, this.get('length'), content);
}
});
@zoghal
zoghal / 1-helper.js
Created June 4, 2012 16:40 — forked from wagenet/1-helper.js
Ember Handlebars Transform Helper
Ember.HandlebarsTransformView = Ember.View.extend(Ember.Metamorph, {
rawValue: null,
transformFunc: null,
value: function(){
var rawValue = this.get('rawValue'),
transformFunc = this.get('transformFunc');
return transformFunc(rawValue);
}.property('rawValue', 'transformFunc').cacheable(),
@zoghal
zoghal / animatable_view.js
Created June 4, 2012 18:49 — forked from ppcano/animatable_view.js
Control Animations on Ember Views
AnimatableView = Ember.ContainerView.extend(Em.Animatable,{
executeAnimation: function() {
.......
this.animate({duration: that.duration, stopEventHandling:true}, function() {
# perform animations based on your JS choices
move('#'+id)
.x(translatePosition)