hide "use flash uploader" with ie >= 10

#time 8h
This commit is contained in:
Jean-Yves Gaulier
2015-02-05 14:20:44 +01:00
parent 21054d3849
commit f71f7adf19
4 changed files with 38 additions and 9 deletions

View File

@@ -80,6 +80,8 @@ class Upload implements ControllerProviderInterface
*/ */
$controllers->get('/flash-version/', $this->call('getFlashUploadForm')) $controllers->get('/flash-version/', $this->call('getFlashUploadForm'))
->bind('upload_flash_form'); ->bind('upload_flash_form');
$controllers->get('/html5-version/', $this->call('getHtml5UploadForm'))
->bind('upload_html5_form');
/** /**
* UPLOAD route * UPLOAD route
@@ -119,11 +121,24 @@ class Upload implements ControllerProviderInterface
return $app['twig']->render( return $app['twig']->render(
'prod/upload/upload-flash.html.twig', array( 'prod/upload/upload-flash.html.twig', array(
'sessionId' => session_id(), 'sessionId' => session_id(),
'collections' => $this->getGrantedCollections($app['authentication']->getUser()), 'collections' => $this->getGrantedCollections($app['authentication']->getUser()),
'maxFileSize' => $maxFileSize, 'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize) 'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
)); ));
}
public function getHtml5UploadForm(Application $app, Request $request)
{
$maxFileSize = $this->getUploadMaxFileSize();
return $app['twig']->render(
'prod/upload/upload.html.twig', array(
'sessionId' => session_id(),
'collections' => $this->getGrantedCollections($app['authentication']->getUser()),
'maxFileSize' => $maxFileSize,
'maxFileSizeReadable' => \p4string::format_octets($maxFileSize)
));
} }
/** /**

View File

@@ -61,7 +61,7 @@
{% if module == "prod" %} {% if module == "prod" %}
{% if app['authentication'].getUser().ACL.has_access_to_module('upload') %} {% if app['authentication'].getUser().ACL.has_access_to_module('upload') %}
<li> <li>
{% set link = path('upload_form') %} {% set link = path('upload_html5_form') %}
{% if not app['browser'].supportFileAPI() %} {% if not app['browser'].supportFileAPI() %}
{% set link = path('upload_flash_form') %} {% set link = path('upload_flash_form') %}

View File

@@ -41,7 +41,7 @@
{% trans 'You are using the Flash uploader.'%} {% trans 'You are using the Flash uploader.'%}
{% trans 'This version does not allow you to access all the features offered by the HTML5 uploader' %} {% trans 'This version does not allow you to access all the features offered by the HTML5 uploader' %}
</p> </p>
<a href="{{ path('upload_form') }}" class="dialog full-dialog">{% trans 'Use the HTML5 uploader' %}</a> <a href="{{ path('upload_html5_form') }}" class="dialog full-dialog">{% trans 'Use the HTML5 uploader' %}</a>
</td> </td>
</tr> </tr>
</table> </table>
@@ -167,7 +167,6 @@
$('#uploadBox #status-' + selectedCollId).show(); $('#uploadBox #status-' + selectedCollId).show();
}); });
//global file order, start uploads from swf.queue, following //global file order, start uploads from swf.queue, following
//order of "file_order" //order of "file_order"
var file_order = []; var file_order = [];

View File

@@ -46,7 +46,7 @@
{% trans 'Your browser does not support all HTML5 features properly.' %} {% trans 'Your browser does not support all HTML5 features properly.' %}
{% endif %} {% endif %}
</p> </p>
<a href="{{ path('upload_flash_form') }}" class="dialog full-dialog">{% trans 'Use the Flash uploader' %}</a> <a id="UPLOAD_FLASH_LINK" href="{{ path('upload_flash_form') }}" class="dialog full-dialog">{% trans 'Use the Flash uploader' %}</a>
</td> </td>
</tr> </tr>
</table> </table>
@@ -143,6 +143,21 @@
<script> <script>
$(document).ready(function () { $(document).ready(function () {
var userAgent = navigator.userAgent.toLowerCase();
$.browser = {
version: (userAgent.match( /.+(?:rv|it|ra|ie|me)[/: ]([\d.]+)/ ) || [])[1],
chrome: /chrome/.test( userAgent ),
safari: /webkit/.test( userAgent ) && !/chrome/.test( userAgent ),
opera: /opera/.test( userAgent ),
msie: /msie/.test( userAgent ) && !/opera/.test( userAgent ),
mozilla: /mozilla/.test( userAgent ) && !/(compatible|webkit)/.test( userAgent )
};
if($.browser.msie && parseFloat($.browser.version)>=10) {
$("#UPLOAD_FLASH_LINK").hide();
}
//Upload management //Upload management
var UploaderManager = new p4.UploaderManager({ var UploaderManager = new p4.UploaderManager({
container: $('#uploadBox'), container: $('#uploadBox'),