public function registerClientScript()
{
$view = $this->getView();
if ($this->gallery) {
GalleryAsset::register($view);
}
FileUploadUIAsset::register($view);
$options = Json::encode($this->clientOptions);
$id = $this->options['id'];
$js[] = ";jQuery('#{$id}').fileupload({$options});";
if (!empty($this->clientEvents)) {
foreach ($this->clientEvents as $event => $handler) {
$js[] = "jQuery('#{$id}').on('{$event}', {$handler});";
}
}
$view->registerJs(implode("\n", $js));
if ($this->load) {
$view->registerJs("\n \$('#{$id}').addClass('fileupload-processing');\n \$.ajax({\n url: \$('#{$id}').fileupload('option', 'url'),\n dataType: 'json',\n context: \$('#{$id}')[0]\n }).always(function () {\n \$(this).removeClass('fileupload-processing');\n }).done(function (result) {\n \$(this).fileupload('option', 'done').call(this, \$.Event('done'), {result: result});\n });\n ");
}
}