This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<input type="text" class="i18n" data-labels="value#str001 placeholder#str002" /> | |
<button class="i18n" data-labels="innerText#str003">Click Me</button> | |
<div class="i18n" data-labels="innerText#str004">This string will never be translated</div> | |
<script> | |
function i18n_parse (rootElement, labelAttribute, iterator) { | |
if (arguments.length === 1 && typeof arguments[0] === "function") { | |
iterator = arguments[0]; | |
rootElement = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// returns total amount of the days that passed since Jan 1 2000 | |
function getDay(aDate) { | |
if (typeof aDate === "string") { | |
aDate = new Date(aDate); | |
} | |
var zeroYear = 2000; | |
var totalYears = aDate.getFullYear() - zeroYear; | |
// calculate all days that passed | |
// since Jan 1 2000 till current time |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var isLeapYear = (new Date(now.getFullYear, 1, 29).getMonth() == 1); // year is leap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($){ | |
$.fn.offsetRelative = function(top){ | |
var $this = $(this); | |
var $parent = $this.offsetParent(); | |
var offset = $this.position(); | |
// add scroll | |
offset.top += $this.scrollTop()+$parent.scrollTop(); | |
offset.left += $this.scrollLeft()+$parent.scrollLeft(); | |
if(!top) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function($, window, document, undefined) { | |
'use strict'; | |
var pluginName = 'FunnelViz' | |
, defaults = { | |
}; | |
function init () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Title with action buttons</title> | |
<style id="jsbin-css"> | |
.bar { | |
position: relative; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('Property', inject(function($parse){ | |
function Property(context, fieldName) { | |
this.$getter = $parse(fieldName); | |
this.$setter = this.$getter.assign; | |
this.$context = context; | |
} | |
Property.prototype.get = function() { | |
return this.$getter(this.$context); | |
}; | |
Property.prototype.set = function(value) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function memoize(fn) { | |
fn.memoize || (fn.memoize = {}); | |
return function(arg) { | |
if (fn.memoize.hasOwnProperty(arg)) { | |
console.log('memoized //-> %s', arg); | |
return fn.memoize[arg]; | |
} | |
else { | |
console.log('computed //-> %s', arg); | |
fn.memoize[arg] = fn(arg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular | |
.module('myProject', []) | |
.filter('abbreviate', function () { | |
// Hello World | abbreviate:6:2 //-> 'Hello...Wo' | |
// Hello World | abbreviate:5 //-> 'Hello...' | |
return function(str, num, prefix) { | |
if (str == null) { str = ''; } | |
if (num == null) { num = str.length; } | |
if (prefix == null) { prefix = 0; } |