Over in #1667742-19: Add abstracted dialog to core (resolves accessibility bug) the patch at #19 demonstrates that you can use the Request object and Content negotiation from the DIC to do away with nojs in your menu callbacks, ie decide whether the user has js based on the content negotiation.
This is a task to remove this logic from views.
Discussed with tim.plunkett on irc.
Example negotiation
// Check for the content-type.
$container = drupal_container();
$type = FALSE;
if ($container->has('request') && $container->has('content_negotiation')) {
$type = $container->get('content_negotiation')->getContentType($container->get('request'));
}
if ($type == 'ajax') {
// ...
}
I did try to sneak a utility wrapper for this into #1737148: Explicitly declare all JS dependencies, don't use drupal_add_js but it was removed until a case could be made for it being re-usable.
Perhaps this is that case?
/**
* Utility method to get the normalized type of the current request.
*
* Fetches the ContentNegotiation and Request objects from the current container
* and returns the associated request content type. The normalized type is a
* short, lowercase version of the format, such as 'html', 'json' or 'atom'.
*
* @return string
* The request type
*/
function drupal_get_request_content_type() {
$type = &drupal_static(__FUNCTION__);
if (isset($type)) {
return $type;
}
else {
$container = drupal_container();
if ($container->has('request') &&
$container->has('content_negotiation')) {
$type = $container->get('content_negotiation')->getContentType($container->get('request'));
}
else {
$type = FALSE;
}
}
return $type;
}
Comment | File | Size | Author |
---|---|---|---|
#7 | interdiff.txt | 49.59 KB | dawehner |
#7 | vdc-1831282-7.patch | 67.71 KB | dawehner |
#5 | vdc-1831282-5.patch | 18.12 KB | dawehner |
#2 | drupal-1831282-2.patch | 41.15 KB | dawehner |
Comments
Comment #1
tim.plunkettTagging.
Comment #2
dawehnerFinally figured it out that this assumption is build into the ajax system, for example in ajax.js
Comment #3
nod_This is in the way of #1533366: Simplify and optimize Drupal.ajax() instantiation and implementation
Comment #5
dawehnerJust a basic reroll for now.
Comment #7
dawehnerFixed all of them.
Comment #9
ericduran CreditAttribution: ericduran commentedSo I was actually about to file an issue about this.
This patches seems like it needs some work and it doesn't look complete.
What's everyone thought on me taking it over? Would it be useful? Personally I'll like to see it happen (not really a fan of the no-js/ajax).
Comment #10
ericduran CreditAttribution: ericduran commentedThis also only seems to be doing Views (I'll be doing it for everything ;-))