From 71f631803b3fd28d1dd0779681b8710e98a08e0a Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Fri, 29 Aug 2014 14:32:41 -0500 Subject: [PATCH] forms: Fixup flow of PJAX wrt. the upload form --- include/class.forms.php | 39 +++++++++++++++++-------------- include/staff/ticket-open.inc.php | 6 +++-- scp/js/scp.js | 29 +++++++++++------------ scp/tickets.php | 6 +++-- 4 files changed, 43 insertions(+), 37 deletions(-) diff --git a/include/class.forms.php b/include/class.forms.php index 98ae957cf..38d20c081 100644 --- a/include/class.forms.php +++ b/include/class.forms.php @@ -1378,7 +1378,7 @@ class FileUploadField extends FormField { return true; // Return true if all file types are allowed (.*) - if (strpos($config['__extensions'], '.*') || !$config['__extensions']) + if (!$config['__extensions'] || in_array('.*', $config['__extensions'])) return true; $allowed = $config['__extensions']; @@ -1416,25 +1416,30 @@ class FileUploadField extends FormField { if (strpos($config['extensions'], '.*') !== false) $config['extensions'] = ''; - foreach (preg_split('/\s+/', str_replace(',',' ', $config['extensions'])) as $ext) { - if (!$ext) { - continue; - } - elseif (strpos($ext, '/')) { - $mimetypes[$ext] = true; - } - else { - if ($ext[0] != '.') - $ext = '.' . $ext; - // Add this to the MIME types list so it can be exported to - // the @accept attribute - if (!isset($extensions[$ext])) + if (is_string($config['extensions'])) { + foreach (preg_split('/\s+/', str_replace(',',' ', $config['extensions'])) as $ext) { + if (!$ext) { + continue; + } + elseif (strpos($ext, '/')) { $mimetypes[$ext] = true; - - $extensions[$ext] = true; + } + else { + if ($ext[0] != '.') + $ext = '.' . $ext; + // Add this to the MIME types list so it can be exported to + // the @accept attribute + if (!isset($extensions[$ext])) + $mimetypes[$ext] = true; + + $extensions[$ext] = true; + } } + $config['__extensions'] = array_keys($extensions); + } + elseif (is_array($config['extensions'])) { + $config['__extensions'] = $config['extensions']; } - $config['__extensions'] = array_keys($extensions); // 'mimetypes' is the array represented from the user interface, // '__mimetypes' is a complete list of supported MIME types. diff --git a/include/staff/ticket-open.inc.php b/include/staff/ticket-open.inc.php index 138d7c6c2..d677070ed 100644 --- a/include/staff/ticket-open.inc.php +++ b/include/staff/ticket-open.inc.php @@ -409,9 +409,11 @@ $(function() { // Popup user lookup on the initial page load (not post) if we don't have a // user selected if (!$_POST && !$user) {?> - $.userLookup('ajax.php/users/lookup/form', function (user) { + setTimeout(function() { + $.userLookup('ajax.php/users/lookup/form', function (user) { window.location.href = window.location.href+'&uid='+user.id; - }); + }); + }, 100); <?php } ?> }); diff --git a/scp/js/scp.js b/scp/js/scp.js index 76ec812f0..e6e36147e 100644 --- a/scp/js/scp.js +++ b/scp/js/scp.js @@ -526,7 +526,7 @@ $.toggleOverlay = function (show) { return $.toggleOverlay(!$('#overlay').is(':visible')); } if (show) { - $('#overlay').fadeIn(); + $('#overlay').show().fadeIn(); $('body').css('overflow', 'hidden'); } else { @@ -545,13 +545,14 @@ $.dialog = function (url, codes, cb, options) { $.toggleOverlay(true); $('div.body', $popup).empty().hide(); - $('div#popup-loading', $popup).slideDown() + $('div#popup-loading', $popup).show() .find('h1').css({'margin-top':function() { return $popup.height()/3-$(this).height()/3}}); - $popup.slideDown(); + $popup.show(); $('div.body', $popup).load(url, function () { $('div#popup-loading', $popup).hide(); $('div.body', $popup).slideDown({ - duration: 200, + duration: 300, + queue: false, complete: function() { if (options.onshow) options.onshow(); } }); $(document).off('.dialog'); @@ -704,23 +705,19 @@ $(document).on('pjax:send', function(event) { $('#overlay').css('background-color','white').fadeIn(); }); +$(document).on('pjax:beforeReplace', function() { + // Close popups + // Close tooltips + $('.tip_box').remove(); + $('.dialog .body').empty().parent().hide(); +}); + $(document).on('pjax:complete', function() { // right $("#loadingbar").width("101%").delay(200).fadeOut(400, function() { $(this).remove(); }); - - $('.tip_box').remove(); - $('.dialog .body').empty().parent().hide(); - $('#overlay').stop(false, true).hide().removeAttr('style'); -}); - -$(document).on('pjax:end', function() { - // Close popups - // Close tooltips - $('.tip_box').remove(); - $('.dialog .body').empty().parent().hide(); - $('#overlay').hide(); + $('#overlay').fadeOut(100).removeAttr('style'); }); // Quick note interface diff --git a/scp/tickets.php b/scp/tickets.php index ebf2ed081..cd7d5ebfb 100644 --- a/scp/tickets.php +++ b/scp/tickets.php @@ -42,11 +42,13 @@ if ($_REQUEST['uid']) // Configure form for file uploads $response_form = new Form(array( 'attachments' => new FileUploadField(array('id'=>'attach', - 'name'=>'attach:response')) + 'name'=>'attach:response', + 'configuration' => array('extensions'=>''))) )); $note_form = new Form(array( 'attachments' => new FileUploadField(array('id'=>'attach', - 'name'=>'attach:note')) + 'name'=>'attach:note', + 'configuration' => array('extensions'=>''))) )); //At this stage we know the access status. we can process the post. -- GitLab