Jump to content

Long-click modal actions


ottogal
 Share

Recommended Posts

The time for triggering the Long-click modal actions (introduced in PW 3.0.9) should be slightly longer to avoid erraneously opening a modal window. Some editor users (who normally don't use it) get irritated when the reaction to their "short" click is unusual.

Link to comment
Share on other sites

$.longclick.duration is set in /wire/modules/Jquery/JqueryCore/jquery.longclick.js (and it's minified version!) at line 61, so you could change the value there, but this is not recommended since core update will overwrite your changes.

Link to comment
Share on other sites

You need to set jQuery.longclick.duration to override the default value:

jQuery.longclick.duration = 2000

I'm working on a module that adds JS tweaks to the admin, including some tiny modules/snippets created by me & netcarver, and this now includes this tweak too.

Sneak preview:

post-3156-0-52915600-1464248416_thumb.pn

As you can see there's room for other tweaks so if you have something to add, please tell.

  • Like 5
Link to comment
Share on other sites

@matjazp

Is it necessary to modify both the files jquery.longclick.js and jquery.longclick.min.js?

Alternatively, is it possible to override them (or it) by a modified version located in /site/modules/? What should be the right path?

@tpr

Looking forward to this module, seems interesting! (No suggestions atm to add, though.)

Link to comment
Share on other sites

Add this to /site/ready.php:

<?php namespace ProcessWire;

// modify longclick duration
$page->addHookAfter('render', function ($event) {

    if ($this->page->template != 'admin') return;

    $js = <<< HTML
 <script>
 $(document).ready(function () {
    if (jQuery && jQuery.longclick) {
        jQuery.longclick.duration = 2000;
    }
});
</script>
HTML;

    $event->return = str_replace('</body>', $js . PHP_EOL . '</body>', $event->return);
});

  • Like 6
Link to comment
Share on other sites

It's jquery.longclick.min.js at least this is used in my installation. File is minimized and difficult to edit. This is not a recommended path (as I already mentioned), since core upgrade will overwrite your changes. The right path is by using AdminCustomFiles module: install the module, create folder /site/templates/AdminCustomFiles and create the file ProcessPageList.js with something like that:

$(document).ready(function(){  
  jQuery.longclick.duration = 2000;
});

Note: written in browser and not tested.

Or you could hook on Page::render (in some module or ready.php) and inject the script. Or wait for tpr's module :-)

Edit: tpr beat me :-) fast->faster->tpr

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...