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 / index.html
Created July 1, 2012 07:00 — forked from fpauser/index.html
Ember.Router
<!doctype html>
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js'></script>
<script type='text/javascript' src="http://cloud.github.com/downloads/wycats/handlebars.js/handlebars-1.0.0.beta.6.js"></script>
<script type='text/javascript' src="http://cloud.github.com/downloads/emberjs/ember.js/ember-latest.js"></script>
</head><body>
<script type="text/x-handlebars" data-template-name="application">
<h1>Application</h1>
<a href="#/dashboard">Dashboard</a>
@zoghal
zoghal / gist:3051597
Created July 5, 2012 05:50
Ember Router reopen
App = Ember.Application.create();
App.RootState = Em.State.extend({
index : Em.State.extend({
route : '/'
}),
main: Em.State.extend({
route : '/main',
index : Em.State.extend({
route : '/'
@zoghal
zoghal / ember-store.js
Created July 10, 2012 22:32
Ember-Data Example
// <== BOOTSTRAP
var App = Ember.Application.create();
App.stateManager = Ember.StateManager.create();
DS.fixtureAdapter.createRecord = function(store, type, record) {
var json = record.toJSON();
json.id = 1;
store.didCreateRecord(record, json);
@zoghal
zoghal / gist:3149026
Created July 20, 2012 06:21
CakePHP Event
// /app/Event/BlogEventListener.php
<?php
App::uses('CakeEventListener', 'Event');
class BlogEventListener implements CakeEventListener {
public function implementedEvents() {
return array(
'Controller.Blog.afterAdd' => 'myEventFunction', // assign event to function
);
@zoghal
zoghal / localization_helper.js
Created July 24, 2012 19:23 — forked from davidwkeith/localization_helper.js
Localization Helper for Ember.js's Handlebars
Handlebars.registerHelper('loc', function(property, fn) {
var str;
// we are bound to a value, it is now the context
if (fn.contexts && typeof fn.contexts[0] === 'string') {
str = fn.contexts[0];
// Convention, start all localization keys with _
} else if (property[0] === '_') {
str = property;
@zoghal
zoghal / view.handlebars
Created July 25, 2012 02:54 — forked from coop/view.handlebars
Getting access to form properties in Ember.js
<form>
<div>
<label for="name">Name</label>
{{view Ember.TextField valueBinding="view.name"}}
</div>
<div>
<label for="application">Application</label>
{{view Ember.TextField valueBinding="view.file" type="file"}}
</div>
@zoghal
zoghal / carousel_view.js
Created July 27, 2012 15:01 — forked from johanvalcoog/carousel_view.js
Ember Touch ScrollView without iScroll, and using movejs for transfomations.
@zoghal
zoghal / transition_end_on_app.js
Created July 30, 2012 19:09 — forked from ppcano/transition_end_on_app.js
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) {
@zoghal
zoghal / contentchange.js
Created August 5, 2012 10:13
jQuery.event.special.contentchange
var interval;
jQuery.fn.contentchange = function(fn) {
return this.bind('contentchange', fn);
};
jQuery.event.special.contentchange = {
setup: function(data, namespaces) {
var self = this,
$this = $(this),
@zoghal
zoghal / meli-code.js
Created August 8, 2012 02:36
Iranian MeliCode Validation
function checkMeliCode(code)
{
if(!/^\d{8,10}$/.test(code) || /^(0{8,10}|1{8,10}|2{8,10}|3{8,10}|4{8,10}|5{8,10}|6{8,10}|7{8,10}|8{8,10}|9{8,10})$/.test(code))
return false;
var L=code.length, _=0;
for(i=0;i<L-1;i++)
_+=code.charAt(i)*(L-i);
_%=11;
return (code.charAt(L-1)==((_<2)?_:11-_))
}