Skip to content

Instantly share code, notes, and snippets.

@saniyathossain
Created April 22, 2021 09:25
Show Gist options
  • Save saniyathossain/dda8233811643fde6e2dadad426430ac to your computer and use it in GitHub Desktop.
Save saniyathossain/dda8233811643fde6e2dadad426430ac to your computer and use it in GitHub Desktop.
global js script file
$ = jQuery.noConflict(); // define jquery no-conflict
String.prototype.replaceAll = function(search, replacement) {
var target = this;
return target.replace(new RegExp(search, 'g'), replacement);
};
// GLOBAL AJAX SETUP
$.ajaxSetup({
// timeout: 0,
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
// 'Accept': 'application/json'
// 'Access-Control-Allow-Origin': '*'
},
error: function (jqxhr, settings, exception) {
// console.error(exception);
// if (App.appDebug != true) {
// ajaxErrorMessage();
// }
}
});
const SELECTOR_AJAX_LOADER = $('#ajax-loader');
const AJAX_LOADER_HTML = '<i class="fas fa-4x fa-circle-notch fa-spin text-center theme-color loading-z-index"></i>';
(function($, window) {
$(function() {
// INITIALIZE CKEDITOR
window.initCkEditor = function (selector = '[data-ckeditor]', options = {}) {
const SELECTOR_CKEDITOR = $(selector);
if (SELECTOR_CKEDITOR.length > 0) {
ClassicEditor
.create(document.querySelector(selector))
.then(editor => {
})
.catch(error => {
});
}
}
// can be called this globally, therefore can be used in ajax call's done, success callbacks, to make sure the function initiates after ajax render
window.initCkEditor();
});
}) (jQuery, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment