Adding a callback handler to a jQuery plugin
(function($){
$.fn.myAwesomePlugin = function(settings) {
var callback = settings.callback;
if ($.isFunction(callback)) {
var parameter = 'Hello World';
callback.call(this, parameter);
}
/* | |
http://css-tricks.com/snippets/css/media-queries-for-standard-devices/ | |
*/ | |
/* Smartphones (portrait and landscape) ----------- */ | |
@media only screen | |
and (min-device-width : 320px) | |
and (max-device-width : 480px) { | |
/* Styles */ | |
} |
var test_str = 'test\n\n\nha\n\n\n\n\n\n\n\nbla\nbla\n'; | |
// Replace more than two \n with two \n | |
var data = test_str.replace(new RegExp('(\n){3,}', 'gim') , '\n\n'); | |
// normalize line endings to \n, because \r is not recognized as "end of line" | |
data = data.replace (/\s*\R/g, "\n"); | |
// remove leading and trailing whitespace | |
data = data.replace (/^\s*|[\t ]+$/gm, ""); |
/** | |
* zindex-test | |
*/ | |
.cnt { max-width: 200px; margin: 10px auto; } | |
.box { background: #fff; border: 1px solid; height: 50px; margin-bottom: 10px; position:relative; /*z-index: 50;*/ } | |
.hint-trigger { position: absolute; bottom: 0; } | |
.hint { position: absolute; top:0; background: #eee; padding: 10px; z-index: 100; } |
/** | |
* Bottom floated elements stack | |
*/ | |
body { background: #999; font-family: Helvetica; } | |
* { box-sizing: border-box; } | |
.cf:before,.cf:after { content: " "; display: table; } | |
.cf:after { clear: both; } | |
.the-dialog { width:500px; background: #fff; margin: 10px auto; box-shadow: 0 0 5px; } | |
.the-dialog__top { background: #eee url('https://dl.dropboxusercontent.com/u/31132753/pics/small_bg.jpg'); background-size:cover; background-position:50% 25%; padding: 20px; } |
/** | |
* Javasting :) | |
*/ | |
var start_with_space = function (string) { | |
return /^\s+\S+\s*$/.test(string) | |
} | |
var is_blank = function(string) { | |
return /^\s*$/.test(string) |
// Object Constructor | |
var Suit = function(name){ | |
// Private value | |
var name = name; | |
// Private function | |
function getName(){ | |
return name; | |
} |
/** | |
* Iron Man suitcase | |
*/ | |
* { box-sizing: border-box; } | |
.container { padding: 20px; } | |
.iron_title { | |
text-align: center; | |
font-family: stark; | |
color: red; |
/** | |
* Iron Man suitcase | |
*/ | |
* { box-sizing: border-box; } | |
.container { padding: 20px; } | |
.iron_title { | |
text-align: center; | |
font-family: stark; | |
color: red; |
Adding a callback handler to a jQuery plugin
(function($){
$.fn.myAwesomePlugin = function(settings) {
var callback = settings.callback;
if ($.isFunction(callback)) {
var parameter = 'Hello World';
callback.call(this, parameter);
}
if (!Function.prototype.bind) { | |
Function.prototype.bind = function (oThis) { | |
if (typeof this !== "function") { | |
// closest thing possible to the ECMAScript 5 internal IsCallable function | |
throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); | |
} | |
var aArgs = Array.prototype.slice.call(arguments, 1), | |
fToBind = this, | |
fNOP = function () {}, | |
fBound = function () { |