Skip to content

Instantly share code, notes, and snippets.

Avatar
🎨
Building accessible UIs

Vitaly Kondratiev vitkon

🎨
Building accessible UIs
View GitHub Profile
@vitkon
vitkon / JS Inhertence
Last active Aug 29, 2015
Simple JS Prototype chain
View JS Inhertence
var Person = function (name) {
this.name = name;
}
Person.prototype.test = function () {
return 'This is person test';
}
Person.prototype.describe = function () {
return 'This is ' + this.name;
@vitkon
vitkon / gist:0e3a5d4842475868b8e2
Created Aug 26, 2014
JavaScriptCore symlink for OSX
View gist:0e3a5d4842475868b8e2
sudo ln /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc /bin/jsc
@vitkon
vitkon / gist:0c2efb70103332715e44
Created Nov 17, 2014
Get url parameter by name
View gist:0c2efb70103332715e44
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
View gist:1cb46e5042f4622e1626
<h3>Choose a building</h3>
Current building: {{currentBuilding.name}}
<select>
{{#each buildings}}
<option value="{{_id}}" selected={{equals _id currentBuilding._id}}>{{name}}</option>
{{/each}}
</select>
@vitkon
vitkon / gist:5672858
Created May 29, 2013
CSS: Display URLs In A Printed Webpage
View gist:5672858
@media print {
a:after {
content: " [" attr(href) "] ";
}
}
View gist:5672920
.clearfix:before, .container:after { content: ""; display: table; }
.clearfix:after { clear: both; }
/* IE 6/7 */
.clearfix { zoom: 1; }
@vitkon
vitkon / gist:5672988
Created May 29, 2013
CSS: General media queries
View gist:5672988
/* Smartphones (portrait and landscape) ----------- */
@media only screen
and (min-device-width : 320px) and (max-device-width : 480px) {
/* Styles */
}
/* Smartphones (landscape) ----------- */
@media only screen and (min-width : 321px) {
/* Styles */
}
@vitkon
vitkon / gist:5673058
Created May 29, 2013
JS: Test email validity
View gist:5673058
function checkMail (email) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}
return false;
}
@vitkon
vitkon / gist:5673129
Last active Dec 17, 2015
JS: Safe console.log (cross-browser)
View gist:5673129
// make it safe to use console.log always
(function(a){function b(){}for(var c="assert,count,debug,dir,dirxml,error,exception,group,groupCollapsed,groupEnd,info,log,markTimeline,profile,profileEnd,time,timeEnd,trace,warn".split(","),d;!!(d=c.pop());){a[d]=a[d]||b;}})
(function(){try{console.log();return window.console;}catch(a){return (window.console={});}}());
@vitkon
vitkon / gist:5673222
Last active Dec 17, 2015
JS: Resize iFrame to its content
View gist:5673222
$("#modalIFrame").bind('load',
function () {
var newheight,
newwidth;
newheight = this.contentWindow.document.body.scrollHeight;
newwidth = this.contentWindow.document.body.scrollWidth;
$(this).height(newheight);
$(this).width(newwidth);