11 import os |
11 import os |
12 import re |
12 import re |
13 |
13 |
14 from PyQt6.QtCore import QBuffer, QByteArray, QCoreApplication, QIODevice, QUrl |
14 from PyQt6.QtCore import QBuffer, QByteArray, QCoreApplication, QIODevice, QUrl |
15 from PyQt6.QtGui import QPixmap |
15 from PyQt6.QtGui import QPixmap |
|
16 |
|
17 from eric7.SystemUtilities import OSUtilities |
16 |
18 |
17 WebBrowserDataDirectory = { |
19 WebBrowserDataDirectory = { |
18 "html": os.path.join(os.path.dirname(__file__), "..", "data", "html"), |
20 "html": os.path.join(os.path.dirname(__file__), "..", "data", "html"), |
19 "icons": os.path.join(os.path.dirname(__file__), "..", "data", "icons"), |
21 "icons": os.path.join(os.path.dirname(__file__), "..", "data", "icons"), |
20 "js": os.path.join(os.path.dirname(__file__), "..", "data", "javascript"), |
22 "js": os.path.join(os.path.dirname(__file__), "..", "data", "javascript"), |
283 """ |
285 """ |
284 if not os.path.isabs(jsFileName): |
286 if not os.path.isabs(jsFileName): |
285 jsFileName = os.path.join(WebBrowserDataDirectory["js"], jsFileName) |
287 jsFileName = os.path.join(WebBrowserDataDirectory["js"], jsFileName) |
286 |
288 |
287 return readAllFileContents(jsFileName) |
289 return readAllFileContents(jsFileName) |
|
290 |
|
291 |
|
292 def getJquery(jqName): |
|
293 """ |
|
294 Module function to load a JQuery source file. |
|
295 |
|
296 Note: If the JQuery file is not found in the javascript data directory and |
|
297 the platform is Linux, it is assumed that it is installed system wide in the |
|
298 '/usr/share/javascript' directory (e.g. as packaged by Debian). |
|
299 |
|
300 @param jqName name of the JQuery library to be loaded (one of 'jquery' or |
|
301 'jquery-ui') |
|
302 @type str |
|
303 @return JQuery source |
|
304 @rtype str |
|
305 """ |
|
306 jsFileName = os.path.join(WebBrowserDataDirectory["js"], jqName + ".js") |
|
307 if not os.path.exists(jsFileName) and OSUtilities.isLinuxPlatform(): |
|
308 if jqName == "jquery": |
|
309 jsFileName = "/usr/share/javascript/jquery/jquery.min.js" |
|
310 elif jqName == "jquery-ui": |
|
311 jsFileName = "/usr/share/javascript/jquery-ui/jquery-ui.min.js" |
|
312 |
|
313 return readAllFileContents(jsFileName) |