Page 1 of 1

Time for prototype.js to retire

Posted: 2018-12-19 01:31
by peebee
I see current version of Appgini is still loading prototype.js (resources/lightbox/js - Prototype V1.7.1)

Prototype is know to have several conflicts with both Bootstrap and select2 (I see some fixes have been added to common.js.php & dynamic.css.php in the current Appgini to remedy some conflicts)

prototype.js V1.7.1 was released in 2014. Last update to the Prototype JS project was Sept 2015.

Native Bootstrap tabs/pils and other functions still conflict with Prototype and a manual fix is required. There are plenty of other current (and maintained) lightbox js functions out there.

Whilst I am a great fan of Appgini, I do think it is time to get rid of Prototype JS completely. Just my 2c worth

Re: Time for prototype.js to retire

Posted: 2018-12-19 01:50
by peebee
Just to add to the my own post above.

You can fix some (if not all?) Prototype conflicts by adding the following to your hooks/header-extras.php I've tested and fixes my bootstrap issues at least. No apparent negative effects at this stage. Not tested in all browsers however......

Code: Select all

<script>
jQuery.noConflict();
if (Prototype.BrowserFeatures.ElementExtensions) {
    var disablePrototypeJS = function (method, pluginsToDisable) {
            var handler = function (event) {
                event.target[method] = undefined;
                setTimeout(function () {
                    delete event.target[method];
                }, 0);
            };
            pluginsToDisable.each(function (plugin) { 
                jQuery(window).on(method + '.bs.' + plugin, handler);
            });
        },
        pluginsToDisable = ['collapse', 'dropdown', 'modal', 'tooltip', 'popover', 'tab', 'pill'];
    disablePrototypeJS('show', pluginsToDisable);
    disablePrototypeJS('hide', pluginsToDisable);
}
jQuery(document).ready(function ($) {
    $('.bs-example-tooltips').children().each(function () {
        $(this).tooltip();
    });
    $('.bs-example-popovers').children().each(function () {
            $(this).popover();
    });
});
</script>
All credit goes here: https://jsfiddle.net/dgervalle/hhBc6/

Re: Time for prototype.js to retire

Posted: 2019-01-03 14:36
by a.gneady
Thanks for sharing this code snippet. We're gradually migrating Prototype code to jQuery with each new release of AppGini, and plan to remove it altogether in AppGini 5.80.