Skip to content

Instantly share code, notes, and snippets.

@denisnazarov
denisnazarov / component.js
Created August 18, 2014 21:11
Ember dynamic component helper: {{component foo}}
import Ember from 'ember';
Ember.Handlebars.registerHelper('component', function (name, options) {
var context = (options.contexts && options.contexts.length) ? options.contexts[0] : this;
if (options.types[0] === "ID") {
name = Ember.Handlebars.get(context, name, options);
}
var container = options.data.view.container;
var fullName = 'component:' + name;
var templateFullName = 'template:components/' + name;
@denisnazarov
denisnazarov / video_convert.sh
Last active October 31, 2016 13:40
FFMPEG batch convert to h264 mp4 and webm
#! /bin/bash
# Based on Batch Convert Script originally by Beterhans
# Put all video files need to be converted in a folder!
# the name of files must not have " " Space!
# Rename the File if contain space
# Target dir
indir=$1
@denisnazarov
denisnazarov / app.css
Created February 20, 2014 03:53
Ember Resizable Image Component http://jsbin.com/ucanam/3882/edit
.sized-container{
position: relative;
}
.element-resize{
position: absolute;
bottom: 0px;
right: 0px;
width: 20px;
height: 20px;
background-color: black;
@denisnazarov
denisnazarov / app.css
Created February 20, 2014 03:51
Ember Youtube Loop Component http://emberjs.jsbin.com/tadaseku/3/
/* Put your CSS here */
html, body {
margin: 10px;
}
form{
width: 560px;
margin-bottom: 10px;
}
.ui-slider-horizontal .ui-slider-handle {
width: 2px;
@denisnazarov
denisnazarov / full-screen-video.css
Created December 24, 2013 21:24
Full screen (background) video with just CSS: http://jsbin.com/EzakOYIb/1
.full-screen-video-container{
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
overflow: hidden;
}
.full-screen-video-container video{
position: absolute;
li > ul{
display: none;
}
@denisnazarov
denisnazarov / interacting_jquery.js
Created November 20, 2013 14:41
Interacting with jQuery events in Ember.js Views
// jQuery event handler in the View
didInsertElement: function () {
var self = this;
this._boundApplyResize = function(){
self.applyResize();
}
$(window).on('resize', this._boundApplyResize);
},
Application.LoadingTransitionMixin = Ember.Mixin.create
afterModel: (model, transition) ->
previousRoute = @get('router').previousRoute
if previousRoute
@get('router').previousRoute.cleanUp()
cleanUp: ->
deferredPromise = new Ember.Deferred()
@controller.set('cleanUpPromise', deferredPromise)
{{view "Application.CrossfadeVideoContainerView" url=videoUrl class="crossfade-container"}}
fade: (opacity, callback) -> | 10 if (url === this.get('currentView.src')){
11 currentOpacity = @$().css('opacity') | 11 this.get('controller.videoPromise').resolve();
12 return callback() if currentOpacity == opacity | 12 return;
13 | 13 }
14 @$().css('opacity', opacity) | 14