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 init (global) { | |
'use strict' | |
// Constructor function, initialise states and actions | |
global.Container = function constructor (initialState) { | |
this._states = initialState === undefined ? [] : [initialState] | |
this._actions = {} | |
} | |
// Get the current state |
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
const sortable = function(data) { | |
const table = document.createElement('table'); | |
const thead = document.createElement('thead'); | |
const tbody = document.createElement('tbody'); | |
const currentOrder = {}; | |
// Function to populate the tbody with the data | |
const _populate = current => { | |
const row = tbody.insertRow(); |
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(global) { | |
global.AOP = function(subject) { | |
return { | |
after(method, advice) { | |
const original = subject[method]; | |
subject[method] = function() { | |
const result = original.apply(this, arguments); |
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
<?php | |
/** | |
* Return the reference to an element/subarray | |
* of an array, specified by a key array | |
* | |
* @param array &$array Array to access by reference | |
* @param mixed $keys Array of the keys | |
* @return mixed Reference to the match | |
*/ | |
function &array_access(&$array, $keys) { |
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
/** | |
* Get an array (!) of elements in a given context | |
*/ | |
const find = (selector, context) => | |
Array.from((context || document).querySelectorAll(selector)); | |
/** | |
* Create a new element and optionally initialize it | |
* with some content and attributes | |
*/ |
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
<?php | |
/** | |
* Optional convenience class. Objects extending the | |
* StateHandler class can register with a StateArchivist | |
* instance; then calling remember() or restore() on the | |
* archivist will be propagated to all registered objects. | |
*/ | |
class StateArchivist { | |
/** |
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
window._ = function() {console.log(...arguments)}; |
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($) { | |
$.fn.watch = function(callback, once) { | |
var options = { | |
childList: true, | |
subtree: true | |
}; | |
var _callOnNode = function() { |
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
$.fn.observe = function(callback, options) { | |
options = options || { | |
attributes: true, | |
childList: true, | |
characterData: true | |
}; | |
$(this).each(function() { | |
var observer = new MutationObserver(callback.bind(this)); | |
observer.observe(this, options); |
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
/** | |
* Plugin to reduce a set of elements to those | |
* visible in the viewport | |
* | |
* @param {Object} | |
* @param {Function} | |
* @param {Function} | |
* @return {jQuery} | |
*/ | |
(function($) { |