--- a/src/eric7/WebBrowser/Tools/WebBrowserTools.py Tue Jan 03 17:13:24 2023 +0100 +++ b/src/eric7/WebBrowser/Tools/WebBrowserTools.py Wed Jan 04 12:33:48 2023 +0100 @@ -14,6 +14,8 @@ from PyQt6.QtCore import QBuffer, QByteArray, QCoreApplication, QIODevice, QUrl from PyQt6.QtGui import QPixmap +from eric7.SystemUtilities import OSUtilities + WebBrowserDataDirectory = { "html": os.path.join(os.path.dirname(__file__), "..", "data", "html"), "icons": os.path.join(os.path.dirname(__file__), "..", "data", "icons"), @@ -285,3 +287,27 @@ jsFileName = os.path.join(WebBrowserDataDirectory["js"], jsFileName) return readAllFileContents(jsFileName) + + +def getJquery(jqName): + """ + Module function to load a JQuery source file. + + Note: If the JQuery file is not found in the javascript data directory and + the platform is Linux, it is assumed that it is installed system wide in the + '/usr/share/javascript' directory (e.g. as packaged by Debian). + + @param jqName name of the JQuery library to be loaded (one of 'jquery' or + 'jquery-ui') + @type str + @return JQuery source + @rtype str + """ + jsFileName = os.path.join(WebBrowserDataDirectory["js"], jqName + ".js") + if not os.path.exists(jsFileName) and OSUtilities.isLinuxPlatform(): + if jqName == "jquery": + jsFileName = "/usr/share/javascript/jquery/jquery.min.js" + elif jqName == "jquery-ui": + jsFileName = "/usr/share/javascript/jquery-ui/jquery-ui.min.js" + + return readAllFileContents(jsFileName)