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
// Use: passing in an object representing a jQuery plugin. The object is expected to have | |
// a name attribute (your plugin name in string form, e.g. name: "accordion") and an init | |
// method. The createPlugin method will take each element in the collection when the | |
// plugin method is called and initialize the plugin individually, writing a data object | |
// to the element with the same name as the plugin and storing the plugin object for | |
// later reference. | |
(function($) { | |
$.createPlugin = function(plugin) { | |
$.fn[plugin.name] = function(opts) { | |
var $els = this, |
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
// Problem: jQuery's :contains expression does not do an exact match. | |
// Solution: Exact contains `$("div").filter(":econtains(smart)");` | |
$.extend($.expr[":"], { | |
econtains: function(obj, index, meta, stack) { | |
return (obj.textContent || obj.innerText || $(obj).text() || "").toLowerCase() == meta[3].toLowerCase(); | |
} | |
}); |
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 œ = function(number) { | |
return { | |
times: { | |
length: number, | |
"do": function(fn) { | |
var len = this.length; | |
for (var i = 0; i < len; i++) { | |
fn(i); | |
} | |
} |
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
Storage.prototype.setObject = function(key, value) { | |
this.setItem(key, JSON.stringify(value)); | |
}; | |
Storage.prototype.getObject = function(key) { | |
return JSON.parse(this.getItem(key)); | |
}; |
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 codemirror_overrides = { | |
setMarker: function(line, gutter_text, line_class) { | |
if (!this.markers) { this.markers = []; } | |
this.markers.indexOf(line) === -1 && this.markers.push(line); | |
this._setMarker(line, gutter_text, line_class); | |
}, | |
clearMarkers: function(line) { | |
var e = this; | |
if (!e.markers) { return; } | |
if (line) { |
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
$colors: lighten(#026dbd, 45%), lighten(#fad52c, 20%), lighten(#f17d32, 20%), lighten(#da1c1c, 25%), lighten(#8266ba, 20%), lighten(#7bb545, 17%) | |
$i: 1 | |
@each $color in $colors | |
&:nth-child(#{$i}) | |
background-color: $color | |
$i: $i + 1 |
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
.rating | |
.current.three | |
- %w(one two three four five).each do |rating| | |
= link_to rating, "#", class: rating |
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
Array.prototype.forEach.call(document.querySelectorAll("iframe"), function(el) { el.parentNode.removeChild(el); }); |
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
= gradient-bg-horizontal($color1, $color2) | |
background-color: $color2 | |
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#{ie-hex-str($color1)}, endColorstr=#{ie-hex-str($color2)}) | |
-ms-filter: progid:DXImageTransform.Microsoft.gradient(GradientType=1, startColorstr=#{ie-hex-str($color1)}, endColorstr=#{ie-hex-str($color2)}) | |
background-image: -moz-linear-gradient(100% 100% 180deg, $color2, $color1) | |
background-image: -webkit-gradient(linear, left center, right center, from($color1), to($color2)) |
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.smartToggle = function(bool, prop) { | |
prop = prop || bool; | |
return this.each(function() { | |
var $e = $(this); | |
if (bool === prop) { | |
$e.is(":visible") ? $e.hide() : $e.css("display", prop); | |
} | |
else { | |
bool ? $e.css("display", prop) : $e.hide(); |