Skip to content

Commit

Permalink
Safari FormData workaround?
Browse files Browse the repository at this point in the history
  • Loading branch information
bloatware committed Aug 8, 2018
1 parent 45ef5e9 commit cad43c7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion textpattern/include/txp_css.php
Expand Up @@ -103,7 +103,7 @@ function css_list($current)

if ((!$count-- || $extension !== $ext) && !empty($out)) {
$id = 'all_styles_'.($extension ? $types[$extension-1] : 'css');
$label = $extension ? $mimetypes[$types[$extension-1]] : 'all_stylesheets';
$label = $extension ? strtoupper($types[$extension-1]).' ('.$mimetypes[$types[$extension-1]].')' : 'CSS (text/css)';
$list .= wrapGroup($id, tag(join(n, $out), 'ul', array('class' => 'switcher-list')), $label);
$out = array();
}
Expand Down
10 changes: 10 additions & 0 deletions textpattern/textpattern.js
Expand Up @@ -1002,13 +1002,23 @@ jQuery.fn.txpAsyncForm = function (options) {
if (typeof extra === 'undefined') extra = new Object;

var $this = $(this);

// Safari workaround?
var $inputs = $('input[type="file"]:not([disabled])', $this);
$inputs.each(function(i, input) {
if (input.files.length > 0) return
$(input).prop('disabled', true)
})

var form =
{
data : ( typeof window.FormData === 'undefined' ? $this.serialize() : new FormData(this) ),
extra : new Object,
spinner: typeof extra['_txp_spinner'] !== 'undefined' ? $(extra['_txp_spinner']) : $('<span />').addClass('spinner ui-icon ui-icon-refresh')
};

$inputs.prop('disabled', false);// Safari workaround.

if (typeof extra['_txp_submit'] !== 'undefined') {
form.button = $this.find(extra['_txp_submit']).eq(0);
} else {
Expand Down

2 comments on commit cad43c7

@bloatware
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could someone with Safari on MacOS/iOS test if article save works with abc_article_image enabled?

@phiw13
Copy link

@phiw13 phiw13 commented on cad43c7 Aug 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With that plugin installed and active, Safari Technology Preview (aka Safari.next) saves the forms (Write Panel) correctly without your patch. But saving fails with Safari Release v. 11.1.2 (**605.3.8)

With your patch, both save the forms correctly.

Please sign in to comment.