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
window.ENV = window.ENV || {};
window.ENV["EXPERIMENTAL_CONTROL_HELPER"] = true;
App = Ember.Application.create();
App.Node = Ember.Object.extend({
name: null,
children: []
});
App.TreeNodeView = Ember.View.extend({
templateName: 'node-template',
classNameBindings: ['isOpen', 'hasChildren']
{ [ { id: "32111aae", spot_number: "BAH", commercials: [{ id: "33321eaz", title: "yar"}] } ] }
Binder.Spot = DS.Model.extend({
spot_number: DS.attr('string')
});
Binder.Commercial = DS.Model.extend({
title: DS.attr('string'),
spot: DS.belongsTo(Binder.Spot)
});
var App = Ember.Application.create();
App.Store = DS.Store.extend({
revision: 11
, adapter: YamAdapter.create()
});
App.YamModel = DS.Model.extend({
type: DS.attr('string')
, url: DS.attr('string')
, webUrl: DS.attr('string')
});
@cloke
cloke / gist:4519996
Last active December 11, 2015 00:58
{ food: {_id: 'bc4', brand: 'test', food_nutrients: [{ _id: 'af1', name: 'sodium'}] }
FoodNutrient = DS.Model.extend({
name: DS.attr( 'string' )
});
Food = DS.Model.extend(
brand: DS.attr( 'string' ),
food_nutrients: DS.hasMany( Diets.FoodNutrient )
});
<?php
class Php53Traits {
public function __call($name, $params) {
if(!isset($this->{$name}) || !gettype($this->{$name}) == 'object') {
throw new Exception('not found');
}
$tmp = $this->{$name};
return call_user_func_array($tmp, $params);
}
// If you're using an off-the-shelf adapter:
DS.RESTAdapter.map('Links.List', {
urls: { embedded: 'load' }
});
// Otherwise:
App.MyAdapter = DS.RESTAdapter.extend({
// ...
@nimolix
nimolix / gist:4382065
Created December 26, 2012 18:30
Convert a numeric value into Persian words
String.prototype.persianThousandsSeparator = function () {
var val = this.toString();
var x = val.split('.');
var x1 = x[0];
var x2 = x.length > 1 ? '.' + x[1] : '';
var rgx = /(\d+)(\d{3})/;
while (rgx.test(x1)) {
x1 = x1.replace(rgx, '$1' + '٬' + '$2');
}
return x1 + x2;
addImages: (files) ->
formData = new FormData()
# Attach block id
formData.append "attachments[book_id]", @get('content.id')
# Loop through the FileList and render image files as thumbnails.
for file in files
# Only process image files.
if file.type.match("image.*")
App.ApplicationController = Ember.Controller.extend();
App.ApplicationView = Ember.View.extend({
templateName: "application"
});
App.DashboardController = Ember.Controller.extend();
App.DashboardView = Ember.View.extend({
templateName: "dashboard"
});
App.AdministrationController = Ember.Controller.extend();
App.AdministrationView = Ember.View.extend({