JSFiddle - React, Tailwind, and code Playground
by wookiehangover
HTML
<div id="container" />
<script type="text/javascript"
src="https://getfirebug.com/firebug-lite.js">
{
startOpened: true,
}
</script>
JavaScript
(function( $ ) {
var MonkeyFist, MF = (function MF() {
var slice = Array.prototype.slice,
pre_params, ready_params,
fn = {
// ##MF.initialize()
// Creates 2 callback functions: preReady & onReady,
// which act as callback chains for passed in arguments with
// over-rideable defaults. Uses `apply()` to pass additional
// arguments
initialize: function(preDom, postDom){
var preReady = fn.constr( fn.liveEvents ),
onReady = fn.constr ( fn.bindEvents );
pre_params = (preDom && !!preDom.params) ? preDom.params: null;
ready_params = (postDom && !!postDom.params) ? postDom.params: null;
preReady.call( pre_params, preDom );
$( onReady.call( ready_params, postDom ) );
},
// ##MF.constr()
// Creates a constructor that returns a callback chain for
// with any functions passed as arguments. If any of the arguments have a params object, that
// will passed to each function.
constr: function() {
var args_orig = slice.call(arguments);
return function constr(){
var args = args_orig.concat(slice.call(arguments)),
i = 0,
a = args.length,
params = $.isPlainObject(this) === true ? this: null;
for(i; i < a; i += 1 ) {
if( $.isFunction( args[i] ) ) {
args[i].call(params);
}
}
};
}
};
fn.liveEvents = function(){
var params = this;
if( $.isPlainObject(params) && $.isFunction( params.hoist ) ){
if( !!params.greedy ) {
return params.hoist();
} else {
params.hoist();
}
}
/** Your custom code lives here :) */
};
fn.bindEvents = function(){
var params = this;
if( $.isPlainObject(params) && $.isFunction( params.hoist ) ){
if( !!params.greedy ) {
return params.hoist();
} else {
...