Skip to content

Instantly share code, notes, and snippets.

View Jhony0311's full-sized avatar

Jonathan Ortega Jhony0311

View GitHub Profile
@Jhony0311
Jhony0311 / tabChange
Last active November 19, 2015 17:48
Browser tab visibility control
var eventName = "visibilitychange";
if (document.webkitHidden != undefined) {
eventName = "webkitvisibilitychange";
} else if (document.mozHidden != undefined) {
eventName = "mozvisibilitychange";
} else if (document.msHidden != undefined) {
eventName = "msvisibilitychange";
} else if (document.hidden != undefined) {
} else {
@Jhony0311
Jhony0311 / eachYearHadlebarsHelper.js
Created December 15, 2014 17:15
Dynamic Select for Years Handlebars Helper
Handlebars.registerHelper('eachYear', function(options) {
var data = '';
var d = new Date(); // Get user current date
var year = d.year; // Get year from date created;
for(var x = 1922; x <= year; x++) {
data = data + '<option value="' + x + '">' + x + '</option>';
}
return data;
});
@Jhony0311
Jhony0311 / FormViewClass.js
Last active August 29, 2015 14:11
Backbone.js Form validation view from a form view super class
var FormView = Backbone.View.extend({
//No numbers validation
nonumbers: function(e){
var a = [];
var k = e.which;
if(window.Modernizr.IE && (window.Modernizr.lessIE9))
{
var k=e.keyCode? e.keyCode : e.charCode;
@Jhony0311
Jhony0311 / sprites.scss
Last active August 29, 2015 14:11
Compass sprite simple example
// Reference:
// http://compass-style.org/help/tutorials/spriting/
// http://compass-style.org/help/tutorials/spriting/customization-options/
// Import Compass utility for sprites
@import 'compass/utilities/sprites';
// Set spacing
$icon-sprite-spacing: 5px;
@Jhony0311
Jhony0311 / YourCollection.js
Last active August 29, 2015 14:12
View render after collection fetch from JSON using jQuery in a require implementation
/*global define*/
define([
'jquery',
'underscore',
'backbone',
'models/YourModel'
], function($, _, Backbone, YourModel) {
'use strict';
@Jhony0311
Jhony0311 / _animations.scss
Created June 1, 2015 20:47
SASS Animations Mixin Sure crossplatform
@include keyframes(bounce-around) {
0% {
transform: rotateZ(0deg) translate3d(0,10%,0) rotateZ(0deg);
}
100% {
transform: rotateZ(360deg) translate3d(0,10%,0) rotateZ(-360deg);
}
}
@Jhony0311
Jhony0311 / childView
Created June 18, 2015 23:11
Get attached events for a child view in a composite view
'use strict';
var Backbone = require('backbone');
var Marionette = require('backbone.marionette');
var $ = require('jquery');
var templateHelpers = require('../../../common/helpers/HandlebarsHelpers');
var template = require('../templates/PostCardTemplate.hbs');
module.exports = Backbone.Marionette.ItemView.extend({
@Jhony0311
Jhony0311 / _settings.scss
Last active March 16, 2016 18:27
An opinionated media query string setting
// Media query ranges
$small-range: (0em, 40em);
$medium-range: (40.063em, 63.938em);
$large-range: (64em, 89.938em);
$xlarge-range: (90em, 119.938em);
$xxlarge-range: (120em, 99999999em);
// Media query operators
$screen: "only screen";
$landscape: " and (orientation: landscape)";
@Jhony0311
Jhony0311 / webpack.config.js
Last active September 28, 2016 16:03
FRCSTR - Medium Post - Webpack Config
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, 'client'),
devtool: 'source-map',
entry: ['webpack/hot/dev-server', './scripts/app.js'],
@Jhony0311
Jhony0311 / webpack.config.prod.js
Last active September 28, 2016 16:10
FRCSTR - Medium Post - Webpack Conf Prod
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
context: path.resolve(__dirname, 'client'),
devtool: 'source-map',
entry: ['./scripts/app.js'],