Skip to content

Commit c786373

Browse files
committed
Fix #29: Better validation for graceful downgrade for older browsers
1 parent 505c429 commit c786373

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGE.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ version 1.0.2
44

55
- (enh #23): Add Chinese translations.
66
- (enh kartik-v/yii2-krajee-base#34, kartik-v/yii2-krajee-base#35): Enhance i18n translation locales.
7+
- (enh #29): Better validation for graceful downgrade for older browsers.
78

89
version 1.0.1
910
=============

FileInput.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public function init()
6363
Html::addCssClass($this->options, 'file-loading');
6464
}
6565
$input = $this->getInput('fileInput');
66-
$id = 'jQuery("#' . $this->options['id'] . '")';
66+
$script = 'document.getElementById("' . $this->options['id'] . '").className.replace(/\bfile-loading\b/,"");';
6767
if ($this->showMessage) {
6868
$validation = ArrayHelper::getValue($this->pluginOptions, 'showPreview', true) ? 'file preview and multiple file upload' : 'multiple file upload';
6969
$message = '<strong>' . Yii::t('fileinput', 'Note:') . '</strong> ' . Yii::t('fileinput', 'Your browser does not support {validation}. Try an alternative or more recent browser to access these features.', ['validation' => $validation]);
70-
$content = Html::tag('div', $message, $this->messageOptions) . "<script>{$id}.removeClass('file-loading');</script>";
70+
$content = Html::tag('div', $message, $this->messageOptions) . "<script>{$script};</script>";
7171
$input .= "\n" . $this->validateIE($content);
7272
}
7373
echo $input;
@@ -101,4 +101,4 @@ public function registerAssets()
101101
$this->registerAssetBundle();
102102
$this->registerPlugin('fileinput');
103103
}
104-
}
104+
}

0 commit comments

Comments
 (0)