| 1 |
<?php |
| 2 |
|
| 3 |
namespace Jet_Form_Builder; |
| 4 |
|
| 5 |
use Jet_Form_Builder\Classes\Instance_Trait; |
| 6 |
use Jet_Form_Builder\Classes\Tools; |
| 7 |
|
| 8 |
// If this file is called directly, abort. |
| 9 |
if ( ! defined( 'WPINC' ) ) { |
| 10 |
die; |
| 11 |
} |
| 12 |
|
| 13 |
/** |
| 14 |
* @method static File_Upload instance() |
| 15 |
* |
| 16 |
* Class description |
| 17 |
* |
| 18 |
* @package package_name |
| 19 |
* @author Cherry Team |
| 20 |
* @license GPL-2.0+ |
| 21 |
*/ |
| 22 |
class File_Upload { |
| 23 |
|
| 24 |
use Instance_Trait; |
| 25 |
|
| 26 |
public function get_loader() { |
| 27 |
return '<div class="jet-form-builder-file-upload__loader">' . apply_filters( |
| 28 |
'jet-form-builder/file-upload/loader', |
| 29 |
'<svg xmlns="http://www.w3.org/2000/svg" width="38" height="38" viewBox="0 0 38 38" stroke="#fff"><g fill="none" fill-rule="evenodd"><g transform="translate(1 1)" stroke-width="2"><circle stroke-opacity=".5" cx="18" cy="18" r="18"/><path d="M36 18c0-9.94-8.06-18-18-18" transform="rotate(137.826 18 18)"><animateTransform attributeName="transform" type="rotate" from="0 18 18" to="360 18 18" dur="1s" repeatCount="indefinite"/></path></g></g></svg>' |
| 30 |
) . '</div>'; |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Register form-specific assets |
| 35 |
* |
| 36 |
* @return void |
| 37 |
*/ |
| 38 |
public function enqueue_scripts() { |
| 39 |
wp_enqueue_script( 'jet-form-builder-sortable' ); |
| 40 |
wp_enqueue_script( 'jet-form-builder-file-upload' ); |
| 41 |
|
| 42 |
$messages = wp_json_encode( jet_form_builder()->msg_router->get_manager()->get_messages() ); |
| 43 |
$form_id = (int) Live_Form::instance()->form_id; |
| 44 |
|
| 45 |
wp_add_inline_script( |
| 46 |
'jet-form-builder-file-upload', |
| 47 |
" |
| 48 |
window.JetFormBuilderFileUploadConfig = window.JetFormBuilderFileUploadConfig || {}; |
| 49 |
window.JetFormBuilderFileUploadConfig.errors = window.JetFormBuilderFileUploadConfig.errors || {}; |
| 50 |
|
| 51 |
window.JetFormBuilderFileUploadConfig.errors[ $form_id ] = $messages; |
| 52 |
" |
| 53 |
); |
| 54 |
} |
| 55 |
|
| 56 |
} |
| 57 |
|