This file contains hidden or 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 debounce (fn, wait) { | |
| var timeout; | |
| return function() { | |
| var cntx = this; | |
| var args = arguments; | |
| clearTimeout(timeout); | |
| timeout = setTimeout(function() { | |
| timeout = null; |
This file contains hidden or 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
| class BaseClass { | |
| constructor(name, age) { | |
| this.name = name; | |
| this.age = age; | |
| } | |
| static getDescription() { | |
| return "this function can be called without instantiating BaseClass"; | |
| } | |
| getData() { | |
| return ["base data is:", this.name, this.age].join(' '); |
This file contains hidden or 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() { | |
| 'use strict'; | |
| if (window.FormData) { | |
| FormData.prototype.appendObject = function (obj, namespace) { | |
| // EXAMPLE: | |
| // var person = { name: 'some name', age: 87 }; | |
| // var fd = new FormData(); | |
| // fd.appenObject(obj, 'person'); |
This file contains hidden or 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
| // sample data for trying | |
| var paramsString = "?lunch=sandwich&dinner=stirfry"; | |
| console.log(parseParams(paramsString)); | |
| // | |
| // main function | |
| // | |
| function parseParams(str) { | |
| return str | |
| .replace(/(^\?)/, '') |
This file contains hidden or 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 el = document.getElementById('el'); | |
| document.addEventListener('click', outsideEvtListener); | |
| function outsideEvtListener(evt) { | |
| if (evt.target === el || el.contains(evt.target)) { | |
| return; | |
| } | |
| // code handling outside click | |
This file contains hidden or 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
| // DrawerApi.js | |
| // ** code from demo ommitted ** | |
| // | |
| // AnotherApi.js | |
| import Api from '../src/redux-apis'; | |
| export default class AnotherApi extends Api { | |
| constructor(state = { drawerIsOpened: false }) { | |
| super(state); |
This file contains hidden or 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('app.directives.svgBaseFix', []) | |
| .directive('svgBaseFix', function($rootScope) { | |
| return { | |
| restrict: 'A', | |
| link: function(scope, element, attrs) { | |
| var attr = 'xlinkHref'; | |
| var initialUrl = attrs[attr]; | |
| var parsingNode = document.createElement('a'); |
This file contains hidden or 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
| class Store { | |
| constructor(reducer, initialState) { | |
| this.reducer = reducer; | |
| this.state = this.reducer(initialState, {}); | |
| console.log('set state', this.state); | |
| this.listeners = []; | |
| } | |
| getState() { | |
| return this.state; |
This file contains hidden or 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
| /* global document */ | |
| import { KEY_CODES } from './data/constants'; | |
| export default function initTabSpy() { | |
| document.body.classList.add('isUsingPointer'); | |
| document.addEventListener('keydown', (evt) => { | |
| if (evt.which === KEY_CODES.TAB) { // or may be any keydown? | |
| document.body.classList.remove('isUsingPointer'); | |
| } | |
| }); |
This file contains hidden or 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
| class MyForm extends React.Component { | |
| constructor() { | |
| super(); | |
| this.handleSubmit = this.handleSubmit.bind(this); | |
| } | |
| handleSubmit(event) { | |
| event.preventDefault(); | |
| const data = new FormData(event.target); | |
OlderNewer