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 PubSub() { | |
const callbacks = {}; | |
function on(event, callback) { | |
callbacks[event] = callbacks[event] || []; | |
callbacks[event].push(callback); | |
} | |
function emit(event, ...data) { | |
callbacks[event] && callbacks[event].forEach(function (callback) { |
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 throttle(callback, limit) { | |
let wait = false; | |
return function () { | |
if (!wait) { | |
callback.apply(null, arguments); | |
wait = true; | |
setTimeout(function () { | |
wait = false; | |
}, limit); | |
} |
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 debounce(fn, delay) { | |
let timer = null; | |
return function () { | |
const context = this, args = arguments; | |
clearTimeout(timer); | |
timer = setTimeout(function () { | |
fn.apply(context, args); | |
}, delay); | |
}; | |
} |
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
/** | |
* Dùng để add {template} | |
* | |
* Example: | |
* template: <div class="hide" id="template">{Somethinghere}</div> | |
* add new choice button: <button class="btn btn-primary js-choice-add" data-ref="#template">Add new choice</div> | |
* | |
* usage $('.js-choice-add').addByTemplate(); | |
*/ | |
$.fn.addByTemplate = 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
/** | |
* Hiển thị preview ở cho input. | |
*/ | |
$.fn.inputPreview = function(options = { | |
listen_in_runtime: true | |
}){ | |
// Validation-start | |
const $this = $(this); | |
const ref = $this.data('ref'); | |
if (!ref) { |
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
/** | |
* Khi dữ liệu được tham chiếu tới một trường khác thì khai báo theo mẫu sau. | |
* <div data-ref={ref}><input></div> | |
* | |
* @ref: chỉ tới phần tử DOM, nơi cần tham chiếu. | |
*/ | |
$.fn.inputRef = function(){ | |
// Validation-start | |
const $this = $(this); | |
const $input = $this.find('input'); |
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
// Create new Error type | |
function JQueryPropError(element, message) { | |
const instance = new Error(message); | |
instance.name = 'JQueryPropError'; | |
instance.element = element; | |
Object.setPrototypeOf(instance, Object.getPrototypeOf(this)); | |
if (Error.captureStackTrace) { | |
Error.captureStackTrace(instance, JQueryPropError); | |
} | |
return instance; |
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 | |
declare(strict_types=1); | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\JsonResponse; | |
/** | |
* Class ApiStaffMiddleware |
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 | |
declare(strict_types=1); | |
namespace App\Http\Controllers; | |
use Illuminate\Http\Request; | |
use function App\Helpers\get_lang_dot_js_content; | |
/** | |
* Class AssetController |
NewerOlder