| 1: | <?php
|
| 2: |
|
| 3: | final class SphpJsM {
|
| 4: | private static $jslib = array();
|
| 5: |
|
| 6: | public function __construct() {
|
| 7: | $this->init();
|
| 8: | }
|
| 9: |
|
| 10: | public function init() {
|
| 11: | global $jslibpath;
|
| 12: |
|
| 13: |
|
| 14: |
|
| 15: |
|
| 16: | addFileLink("{$jslibpath}/jquery/jquery-3.2.1.min.js", true, "jquery-min", "js", "jquery:3.2.1");
|
| 17: | SphpJsM::$jslib["jquery"] = 321;
|
| 18: |
|
| 19: |
|
| 20: | addFileLink("{$jslibpath}/jquery/jslib.js", true,"sphp-jslib","js","jslib: 1.0.1");
|
| 21: | SphpJsM::$jslib["jslib"] = 1;
|
| 22: |
|
| 23: |
|
| 24: |
|
| 25: | addHeaderJSFunction('ready', "$(document).ready(function() {", "});", true);
|
| 26: | addHeaderJSFunction('ready', "$(document).ready(function() {", "});");
|
| 27: | addHeaderJSFunction('pageload', "$(window).on('load',function() {", "});", true);
|
| 28: | addFileLink('window["sphpjq"] = window.jQuery = window.$ = jql;', true, "jquery-js-code", "js");
|
| 29: |
|
| 30: | addHeaderJSFunction('onconsole', "window['onconsole'] = function(msg,type){var nooutput = false;", " if(!nooutput){switch(type){
|
| 31: | case \"i\": {sconsole.info(msg); break;}
|
| 32: | case \"w\": {sconsole.warn(msg); break;}
|
| 33: | case \"e\": {sconsole.error(msg);break;}
|
| 34: | default: {sconsole.log(msg);break;}
|
| 35: | }
|
| 36: | }};", true);
|
| 37: |
|
| 38: | }
|
| 39: |
|
| 40: | public static function setMinimumLib($jquerypath="") {
|
| 41: | global $jslibpath;
|
| 42: | if($jquerypath != ""){
|
| 43: | updateFileLink($jquerypath, true, "jquery-min", "js");
|
| 44: | }else{
|
| 45: | updateFileLink("{$jslibpath}/jquery/jquery-min1.10.js", true, "jquery-min", "js");
|
| 46: | }
|
| 47: | updateFileLink('var jql = $;', true, "jquery-js-code", "js");
|
| 48: | updateFileLink("{$jslibpath}/jquery/jslib_old_browser.js",true,'sphp-jslib');
|
| 49: | }
|
| 50: | public static function addAlertDialog() {
|
| 51: | global $jslibpath;
|
| 52: | addFileLink("$jslibpath/jquery/jquery-confirm.min.css", true);
|
| 53: | addFileLink("$jslibpath/jquery/jquery-confirm.min.js", true);
|
| 54: | addFileLink("$jslibpath/jquery/alertDialog.js", true,"sphp-jslib");
|
| 55: | SphpJsM::$jslib["alert_dialog"] = 1;
|
| 56: | }
|
| 57: |
|
| 58: | public static function getSphpLib() {
|
| 59: | \SphpBase::JSServer()->getAJAX();
|
| 60: | addFileLink(\SphpBase::sphp_settings()->comp_uikit_res_path . "/form/assets/validation.js", true);
|
| 61: | addFileLink(\SphpBase::sphp_settings()->comp_uikit_res_path . "/form/assets/jquery.form.js", true);
|
| 62: | }
|
| 63: | public static function addjQueryl($default = false, $replaceVar = "") {
|
| 64: | global $jslibpath;
|
| 65: | updateFileLink("$jslibpath/jquery/jquery-3.4.1.min.js", true, "jquery-min", "js", "jquery:3.4.1");
|
| 66: | addHeaderJSFunction('ready', "jql(document).ready(function() {", "});", true);
|
| 67: | addHeaderJSFunction('ready', "jql(document).ready(function() {", "});");
|
| 68: | addHeaderJSFunction('pageload', "jql(window).on('load',function() {", "});", true);
|
| 69: |
|
| 70: | if ($default) {
|
| 71: | updateFileLink('window["sphpjq"] = window.jQuery = window.$ ' . $replaceVar . ' = jql;', true, "jquery-js-code", "js");
|
| 72: | }
|
| 73: | SphpJsM::$jslib["jquery"] = 341;
|
| 74: | }
|
| 75: |
|
| 76: | public static function addjQuery2($default = false) {
|
| 77: | global $jslibpath;
|
| 78: | addFileLink("$jslibpath/jquery/jquery-2.2.4.min.js", true, "jquery-min2", "js");
|
| 79: | addHeaderJSFunction('readyjq2', "jq2(document).ready(function() {", "});", true);
|
| 80: | addHeaderJSFunction('readyjq2', "jq2(document).ready(function() {", "});");
|
| 81: | addHeaderJSFunction('pageloadjq2', "jq2(window).on('load',function() {", "});", true);
|
| 82: | if ($default) {
|
| 83: | updateFileLink('window["sphpjq"] = window.jQuery = window.$ = jq2;', true, "jquery-js-code", "js");
|
| 84: | }
|
| 85: | SphpJsM::$jslib["jquery"] = 224;
|
| 86: | }
|
| 87: |
|
| 88: | public static function addjQuery1($default = false, $latest = false) {
|
| 89: | global $jslibpath;
|
| 90: | if ($latest) {
|
| 91: | updateFileLink("$jslibpath/jquery/jquery-min1.10.js", true, "jquery-min", "js", "jquery:1.10.0");
|
| 92: | } else {
|
| 93: | addFileLink("$jslibpath/jquery/jquery-min1.10.js", true, "jquery-min1", "js");
|
| 94: | }
|
| 95: | addHeaderJSFunction('readyjq1', "jq1(document).ready(function() {", "});", true);
|
| 96: | addHeaderJSFunction('readyjq1', "jq1(document).ready(function() {", "});");
|
| 97: | addHeaderJSFunction('pageloadjq1', "jq1(window).on('load',function() {", "});", true);
|
| 98: | if ($default) {
|
| 99: | if ($latest) {
|
| 100: | updateFileLink('window["sphpjq"] = window.jQuery = window.$ = window.jq1 = jql;', true, "jquery-js-code", "js");
|
| 101: | } else {
|
| 102: | updateFileLink('window["sphpjq"] = window.jQuery = window.$ = window.jq1 = $.noConflict(true);', true, "jquery-js-code", "js");
|
| 103: | }
|
| 104: | }
|
| 105: | SphpJsM::$jslib["jquery"] = 110;
|
| 106: |
|
| 107: | }
|
| 108: | public static function addBootStrap() {
|
| 109: | global $jslibpath;
|
| 110: | if(SphpJsM::getJSLibVersion("bootstrap") == -1){
|
| 111: | SphpJsM::addFontAwesome6();
|
| 112: | |
| 113: | |
| 114: |
|
| 115: | addFileLink("$jslibpath/twitter/bootstrap5/bootstrap.min.css", true, "", "", "bootstrap:5");
|
| 116: | addFileLink("$jslibpath/twitter/bootstrap5/bootstrap.bundle.min.js", true);
|
| 117: | SphpJsM::addAlertDialog();
|
| 118: | SphpJsM::$jslib["bootstrap"] = 5;
|
| 119: |
|
| 120: | }
|
| 121: | }
|
| 122: | public static function includeRequired() {
|
| 123: | include_once(SphpBase::sphp_settings()->comp_uikit_path . "/assets_loader.php");
|
| 124: | includeRequired();
|
| 125: | }
|
| 126: |
|
| 127: | public static function includeFull() {
|
| 128: | include_once(SphpBase::sphp_settings()->comp_uikit_path . "/assets_loader.php");
|
| 129: | includeFull();
|
| 130: | }
|
| 131: |
|
| 132: | public static function addFontAwesome() {
|
| 133: | global $jslibpath;
|
| 134: | if(SphpJsM::getJSLibVersion("fontawesome") == -1){
|
| 135: | addFileLink("$jslibpath/fontawesome/css/font-awesome.min.css", true,"","","fontasm:5",["$jslibpath/fontawesome"]);
|
| 136: | SphpJsM::$jslib["fontawesome"] = 4;
|
| 137: | }
|
| 138: | }
|
| 139: |
|
| 140: | public static function addFontAwesome6() {
|
| 141: | global $jslibpath;
|
| 142: |
|
| 143: | addFileLink("$jslibpath/fontawesome6/css/all.min.css", true,"","","fontasm:6");
|
| 144: | addFileLink("$jslibpath/fontawesome6/css/v4-shims.min.css", true);
|
| 145: | SphpJsM::$jslib["fontawesome"] = 6;
|
| 146: | }
|
| 147: |
|
| 148: |
|
| 149: | public static function addAngular() {
|
| 150: | global $jslibpath;
|
| 151: | addFileLink("$jslibpath/angular/angular.js", true);
|
| 152: | addFileLink("$jslibpath/angular/angular-mocks.js", true);
|
| 153: | SphpJsM::$jslib["angular"] = 126;
|
| 154: | }
|
| 155: |
|
| 156: | public static function addjQueryMobile() {
|
| 157: | global $jslibpath;
|
| 158: |
|
| 159: | addFileLink("$jslibpath/jquery.mobile/jquery.mobile-1.4.5.min.css", true,"","","jquerymob:4",["$jslibpath/jquery.mobile"]);
|
| 160: |
|
| 161: | addFileLink("$jslibpath/jquery.mobile/jquery.mobile-1.4.5.min.js", true);
|
| 162: | SphpJsM::$jslib["jquery_mobile"] = 145;
|
| 163: | }
|
| 164: |
|
| 165: | public static function addjQueryUI($version = "1.12.1") {
|
| 166: | global $jslibpath;
|
| 167: | addFileLink("$jslibpath/jquery-ui-" . $version . "/jquery-ui.min.css", true);
|
| 168: |
|
| 169: |
|
| 170: |
|
| 171: |
|
| 172: | addFileLink("$jslibpath/jquery-ui-" . $version . "/jquery-ui.min.js", true, "jquery-ui2", "", "jqueryui:" . $version);
|
| 173: | SphpJsM::$jslib["jqueryui"] = str_replace('\.', '', $version);
|
| 174: | }
|
| 175: |
|
| 176: | public static function addReact() {
|
| 177: | global $jslibpath;
|
| 178: | addFileLink("$jslibpath/react/react.production18.min.js", true, "", "", "react:18");
|
| 179: | addFileLink("$jslibpath/react/react-dom.production18.min.js", true, "", "", "reactdom:18");
|
| 180: | addFileLink("$jslibpath/react/babel6.26.0.min.js", true, "", "", "babel:6.26.0");
|
| 181: |
|
| 182: | SphpJsM::$jslib["react"] = 18;
|
| 183: | SphpJsM::$jslib["react_babel"] = 6260;
|
| 184: | }
|
| 185: |
|
| 186: | |
| 187: | |
| 188: | |
| 189: | |
| 190: |
|
| 191: | public static function getJSLibVersion($jslib_name) {
|
| 192: | if(isset(SphpJsM::$jslib[$jslib_name])){
|
| 193: | return SphpJsM::$jslib[$jslib_name];
|
| 194: | }
|
| 195: | return -1;
|
| 196: | }
|
| 197: | |
| 198: | |
| 199: | |
| 200: | |
| 201: |
|
| 202: | public static function setJSLibVersion($jslib_name,$version=1) {
|
| 203: | SphpJsM::$jslib[$jslib_name] = intval($version);
|
| 204: | }
|
| 205: | }
|
| 206: | |