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
@zoghal
zoghal / dev_view.coffee
Created August 26, 2012 01:09 — forked from charlesjolley/dev_view.coffee
Adding event locks to Ember
# example view implements a simple dragging for mouse events.
Wall.DevView = Ember.View.extend
mouseDown: (ev) ->
ev.dispatcher.lock @, 'mouseMove', 'mouseUp'
@_mouseDown = @$().offset()
@_mouseDown.pageX = ev.pageX
@_mouseDown.pageY = ev.pageY
@_mouseDown.dispatcher = ev.dispatcher
console.log 'mouseDown'
@zoghal
zoghal / key_responder.js
Created October 13, 2012 20:15
KeyResponder
(function() {
var get = Ember.get, set = Ember.set;
/*
Holds a stack of key responder views. With this we can neatly handle restoring the previous key responder
when some modal UI element is closed. There's a few simple rules that governs the usage of the stack:
- mouse click does .replace (this should also be used for programmatically taking focus when not a modal element)
- opening a modal UI element does .push
- closing a modal element does .pop
@zoghal
zoghal / pagination_support.js
Created October 13, 2012 20:26
Ember.PaginationSupport
var get = Ember.get;
/**
@extends Ember.Mixin
Implements common pagination management properties for controllers.
*/
Ember.PaginationSupport = Ember.Mixin.create({
/**
*/
@zoghal
zoghal / file_picker.js
Created November 1, 2012 22:54
Ember.FilePicker
var get = Ember.get, set = Ember.set, getPath = Ember.getPath;
Ember.FilePicker = Ember.Button.extend({
tagName: 'span',
classNames: ['ember-filepicker'],
classNameBindings: ['disabled'],
/**
* @type {String}
*/
init: function() {
var view = this;
var resizeHandler = function() {
view.rerender();
};
this.set('resizeHandler', resizeHandler);
$(window).bind('resize', this.get('resizeHandler'));
},
@zoghal
zoghal / Page.php
Last active December 17, 2015 01:09
CakePHP - virtual tree
<?php
class Page extends AppModel{
public $useTable = 'objects';
public $actsAs = array(
'Tree' => array( 'recursive' => 0 )
);
public $virtualFields = array(
'lft' => 'Tree.lft',
@zoghal
zoghal / Page.php
Created June 16, 2013 20:48
sample tree eroor
<?php
class Page extends AppModel{
public $actsAs = array(
'Tree'
);
public $hasOne = array( 'Category' );
@zoghal
zoghal / gist:6032614
Created July 18, 2013 20:09
CakePHP Module Base Exmaple:
Router::connect('/Module/Posts',array('controller' => 'posts','action' => 'index' );
Router::connect('/Module/Posts/:action/*',array('controller' => 'posts' );
class PostsController extends AppController {
public $components = array('Paginator');
public function index(){}
public function archive(){
@zoghal
zoghal / helper-loop
Created September 21, 2013 15:46
My Ember Handlebars Helper Collection
/*
{{loop countroller.count}}
{{name}}
{{/loop}}
*/
Ember.Handlebars.registerHelper('loop', function(property, options) {
var out = "";
var count = Ember.get(this, property);
if(Ember.typeOf(count) === 'number' && count >= 1 ){
while (count--) {
@zoghal
zoghal / Cakephp Model relations
Last active December 24, 2015 04:29
Test format responce json of Cakephp to Ember-data
Model Node:
-----------------------------------------------------------
$belongsTo => array(
'Type' => array(
'className' => 'RitaType',
'foreignKey' => 'type_id',
)
);
$hasOne = array(