How to get path for jQuery in Moodle? - moodle

What's the code to programmatically get the path to jQuery in Moodle (Version 3.4)? On my recent moodle it's '/theme/jquery.php/core/jquery-1.11.3.min.js' but I need to get it dynamically in case of updates etc.

The method where the URL of each jquery plugin (and the jquery library itself) is programatically build is jquery_plugin at lib/outputrequirementslib.php (with params jquery and core).
Ultimately that method builds it approximately like so:
$CFG->wwwroot . '/theme/jquery.php/core/' . $file
where $file value is taken from required file lib/jquery/plugins.php, where the current jquery version-file is declared.

Related

How to run javascript with flutter Windows

Is there any way to use flutter in Windows in order to call javascript methods that would require a browser? For example if I use a js method that does a simple task as return a + b it works, but if i try to use browser methods like window.open() it does not
Things I tried:
InAppWebView, but does not support Windows
flutter_html, i could make a page according to a given html code, but the javascripts functions would not run

how to call a GWT module entry point class?

l split my GWT code in different different modules like
PrintPermit.gwt.xml
EmployeeResponse.gwt.xml
Rejected.gwt.xml
and every module has its own entry point class
in my HTML host page I am calling script like
ae.init.EmployeeResponse.nocache.js
I have a menu like
Print Application
Reject Application
New application
whenever user will click on new application default new application will open
as I declare EmployeeResponse.nocache.js statically in my HTML host page.
now I want to call other modules on click button print and reject button
how can i call nocache js for print and reject modules. is there any way to dynamic call.
please help me guys.
Here's how I've done it in the past:
First of all, in the module you want to export, you need to make sure that the code you're going to export doesn't end up obfuscated. This can be accomplished with the liberal use of #JsType; this is the new way of exporting JS, available in GWT 2.8 (as opposed to JSNI).
Your module's entry point onModuleLoad can be empty; it doesn't need to do anything.
Include your JS in the HTML you want to use (maybe the same page as your "main" module)
Check JSInterop documentation (perhaps the one available here) on how you can use native JS in your GWT app (because now, your GWT module became native JS). Import the classes via JSInterop from your library, and use them.
Please be aware of the async nature of the GWT JS loading; your library will be loading in an async manner, just like any JS application (and therefore, it won't be available immediately when your page loads). To overcome this, I've placed a call to a native JS function in my library's onModuleLoad function (i.e. to make sure you notify any potential listeners that the code has loaded; because when onModuleLoad runs, the code surely loaded).
There is a example of an InterAppEventBus:
https://github.com/sambathl/interapp-eventbus
which shows the communication between two GWT applications.
I have adopted it and replaced JSNI with Elemental2 and WebStorage:
https://github.com/FrankHossfeld/InterAppEventBus
Hope that helps.
You can achieve this through separate Html file for each module.
So first of all create separate html for each application e.g. PrintPermit.html and specify corresponding nocache.js in each html.
then on your buttons in menu, add click handlers and in each on click load a corresponding html through Window.open()
e.g. for PrintPermit,
printPermitButton.addClickHandler(new ClickHandler{
#Override
public void onClick(ClickEvent arg0) {
String s = GWT.getHostPageBaseURL() + "PrintPermit.html";
Window.open(s, "PrintPermit", "");
}
});
Please note the window.open will open in new tab in browser, you can also use gwt iframe to open html in same browser page.
Each module will have corresponding nocache.js and will be loaded through html using Window.open()

$(...).datetimepicker is not a function when use converse.js

I want to implement XMPP chat functionality in my system using converse.js for client side chat interface. but when i use converse.js in my layout page, browser showing me error like
$(...).datetimepicker is not a function
$(...).dataTable is not a function.
I have used bootstrap datetimepicker and datatables. It seems like jquery conflictions.
I have tried to resolve conflictions by changing place of some jquery files. but i didn't get success. So how can i remove conflictions?
EDIT: As of version 3.0.1 this shouldn't be an issue anymore. In previous builds the $.noConflict call wasn't being made. This is now fixed in 3.0.1. If you're using an older version, then the text below is still relevant.
Converse.js comes bundled with jQuery. It uses jQuery's noConflict method to relinquish control of the $ variable and therefore to avoid conflicts with other versions of jQuery, but apparently this doesn't always work reliably.
There are a few things you can try:
Load converse.js before all your other JS libraries.
Alternatively, drop your own jQuery and instead use the one included in converse.js. You can access it via converse.env.jQuery.
Or alternatively use the converse.js bundle that doesn't include jQuery: https://cdn.conversejs.org/dist/converse-no-jquery.min.js

Wicket 6: Write inline javascript to script tag in body

Working in Wicket 6. My page includes a javascript reference in the html to a third party library. I have a block of additional standard utils that I include via JavaScriptHeaderItem in a renderHead in the Behavior class from a custom component.
Now, that same component needs to write some specific javascript code inline to call methods from those two includes. The problem is that the code is running before even simple variables within those includes are loaded. Wicket puts both ABOVE the 3rd party library in the header.
I want to render the code in a tag within the body to make sure that both have at least loaded before my code runs. The third party library has a DomReady event, but that at least requires the base variable to be defined.
I gather that I am meant to use FilteringHeaderResponse or HeaderResponseContainer somehow, but the examples/javadocs aren't very clear to me. Let's say my inline javascript was meant to be:
String js = "alert('Hello '" + userName + ");";
from java. It isn't, it's more complicated than that, but if it were, how would I, from a FormComponentPanel, render this inline javascript? And how can I dynamically include my custom js, but make sure it renders BELOW the 3rd party js in the header, but before my inline script runs?
I ended up using:
response.render(OnDomReadyHeaderItem.forScript(writeGridJS()));
Put your js into a file like my.js and make it a ResourceReference. Then add the libraries your code depends on as dependencies to this ResourceReference. here you got two good links on that:
http://wicketinaction.com/2012/07/wicket-6-resource-management/
http://wicket.apache.org/guide/guide/chapter14.html#chapter14_5

How can I expose plugin functions to docpad partials?

tldr; Is there a way to expose functions defined in one plugin for another plugin to use?
I'm trying to use the tagging plugin (https://github.com/rantecki/docpad-plugin-tagging) within a partial.
I have a Jade partial setup as follows:
.post-tags
| Posted in
each tag in tags
a(href=getTagUrl(tag))= tag + ' '
where getTagUrl is a function defined by the tagging plugin. The problem is that the partial has no knowledge and this partial does not render.
As v2.8.0+ of the partials plugin now includes the template data by default (you don't have to manually specify it's inclusion anymore), try running docpad update in your project's root directory and trying again. Otherwise, we'll probably have to see the source code of your project to help isolate the issue.
It's because partial do not have access by default to templateData, the object holding the getTagUrl helper. You have to pass it explicitly to the partial.
Here's a similar answer provided for the eco templating language :
https://stackoverflow.com/a/16631649/232943