forked from cypht-org/cypht
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow the exclusion of certain JS libraries from being bundled when i…
…ntegrating Cypht with third-party software (cypht-org#1301) * Allow the exclusion of certain JS libraries from being bundled when integrating Cypht with third-party software * Fix unit tests and add the new variable to .env.example * Bundle js files contents instead of the script tags
- Loading branch information
1 parent
cf27b9d
commit cc3eb91
Showing
10 changed files
with
120 additions
and
83 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
define('JS_LIBS', [ | ||
'bootstrap' => 'vendor/twbs/bootstrap/dist/js/bootstrap.bundle.min.js', | ||
'cash' => 'third_party/cash.min.js', | ||
'resumable' => 'third_party/resumable.min.js', | ||
'ays-beforeunload-shim' => 'third_party/ays-beforeunload-shim.js', | ||
'jquery-are-you-sure' => 'third_party/jquery.are-you-sure.js', | ||
'sortable' => 'third_party/sortable.min.js' | ||
]); | ||
|
||
function get_js_libs($exclude_deps = []) { | ||
$js_lib = ''; | ||
|
||
foreach (JS_LIBS as $dep) { | ||
if (!in_array($dep, $exclude_deps)) { | ||
$js_lib .= '<script type="text/javascript" src="'.WEB_ROOT.$dep.'"></script>'; | ||
} | ||
} | ||
return $js_lib; | ||
} | ||
|
||
function get_js_libs_content($exclude_deps = []) { | ||
$js_lib = ''; | ||
|
||
foreach (JS_LIBS as $dep) { | ||
if (!in_array($dep, $exclude_deps)) { | ||
$js_lib .= file_get_contents(APP_PATH.$dep); | ||
} | ||
} | ||
return $js_lib; | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* extend cash.js with some useful bits */ | ||
$.inArray = function(item, list) { | ||
for (var i in list) { | ||
if (list[i] === item) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
$.isEmptyObject = function(obj) { | ||
for (var key in obj) { | ||
if (obj.hasOwnProperty(key)) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
$.fn.submit = function() { this[0].submit(); } | ||
$.fn.focus = function() { this[0].focus(); }; | ||
$.fn.serializeArray = function() { | ||
var parts; | ||
var res = []; | ||
var args = this.serialize().split('&'); | ||
for (var i in args) { | ||
parts = args[i].split('='); | ||
if (parts[0] && parts[1]) { | ||
res.push({'name': parts[0], 'value': parts[1]}); | ||
} | ||
} | ||
return res.map(function(x) {return {name: x.name, value: decodeURIComponent(x.value.replace(/\+/g, " "))}}); | ||
}; | ||
$.fn.sort = function(sort_function) { | ||
var list = []; | ||
for (var i=0, len=this.length; i < len; i++) { | ||
list.push(this[i]); | ||
} | ||
return $(list.sort(sort_function)); | ||
}; | ||
$.fn.fadeOut = function(timeout = 600) { | ||
return this.css("opacity", 0) | ||
.css("transition", `opacity ${timeout}ms`) | ||
}; | ||
$.fn.fadeOutAndRemove = function(timeout = 600) { | ||
this.fadeOut(timeout) | ||
var tm = setTimeout(() => { | ||
this.remove(); | ||
clearTimeout(tm) | ||
}, timeout); | ||
return this; | ||
}; | ||
|
||
$.fn.modal = function(action) { | ||
const modalElement = this[0]; | ||
if (modalElement) { | ||
const modal = new bootstrap.Modal(modalElement); | ||
if (action === 'show') { | ||
modal.show(); | ||
} else if (action === 'hide') { | ||
modal.hide(); | ||
} | ||
} | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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