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
| if (window.matchMedia("(min-width: 40em)").matches) { | |
| /* do something here, load supplementary content or something. */ | |
| } |
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
| document.addEventListener("touchstart", function(){}, true) | |
| .btn { | |
| -webkit-tap-highlight-color: rgba(0,0,0,0); | |
| &:active { | |
| /* some props */ | |
| } | |
| } |
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
| // Simple execution | |
| window["functionName"](arguments); | |
| // Nested exection. | |
| window["My"]["Namespace"]["functionName"](arguments); | |
| // Helper function. | |
| function executeFunctionByName(functionName, context /*, args */) { | |
| var args = Array.prototype.slice.call(arguments).splice(2); | |
| var namespaces = functionName.split("."); |
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 table = document.createElement('table'), | |
| tbody = document.createElement('tbody'), | |
| i, rowcount; | |
| table.appendChild(tbody); | |
| for (i = 0; i <= 9; i++) { | |
| rowcount = i + 1; | |
| tbody.insertRow(i); | |
| tbody.rows[i].insertCell(0); |
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(win){ | |
| "use strict"; | |
| var el = win.document.createElement('div'), | |
| camelRe = /-([a-z]|[0-9])/ig, | |
| cache = {}, | |
| support, | |
| camel, | |
| key; | |
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 start = null; | |
| var d = document.getElementById("SomeElementYouWantToAnimate"); | |
| function step(timestamp) { | |
| var progress; | |
| if (start === null) start = timestamp; | |
| progress = timestamp - start; | |
| d.style.left = Math.min(progress/10, 200) + "px"; | |
| if (progress < 2000) { |
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
| @iterations: 6; | |
| .h(@index) when (@index > 0) { | |
| h@{index} { | |
| font-size: 72px - @index*10; | |
| } | |
| .h(@index - 1); | |
| } | |
| .h(0) {} | |
| .h(@iterations); |
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 mergeTo = [4,5,6]; | |
| var mergeFrom = [7,8,9]; | |
| Array.prototype.push.apply(mergeTo, mergeFrom); | |
| mergeTo; // is: [4, 5, 6, 7, 8, 9] |
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
| // Set canvas as an image's source. | |
| var data = canvas.toDataURL(); | |
| img.src = data; // img implied | |
| // Create image. | |
| var jpg = canvas.toDataURL('image/jpeg',.7); // .7 is compression |
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 target = document.getElementById("drop-target"); | |
| target.addEventListener("dragover", function(e){e.preventDefault();}, true); | |
| target.addEventListener("drop", function(e){ | |
| e.preventDefault(); | |
| loadImage(e.dataTransfer.files[0]); | |
| }, true); |