View file store/templates/store/includes/upload.html

File size: 7.8Kb
<div class="verf-active">
    <form class="form pg_page padd pp_store_upload" id="upload_store_image">
		<h2 class="pg_in_page_title">{{LANG upload}}</h2>
		<div class="row">
			<div class="col-lg-1"></div>
			<div class="col-lg-10">
				<div class="fak_image" data-block="video-drop-zone" onclick="document.getElementById('user-photo').click(); return false">
					<div class="upload_fk_image">
						<svg id="Capa_1" enable-background="new 0 0 512 512" height="512" viewBox="0 0 512 512" width="512" xmlns="http://www.w3.org/2000/svg"><g><g><path d="m256 512c-64.349 0-129.788-2.237-194.5-6.649l-7.639-.521c-10.546-.719-19.053-8.906-20.176-19.416l-.814-7.614c-9.706-90.844-9.706-182.967 0-273.81l.814-7.614c1.123-10.51 9.63-18.697 20.176-19.416l7.639-.521c64.72-4.412 130.159-6.649 194.5-6.649 64.342 0 129.781 2.237 194.5 6.649l7.639.521c10.546.719 19.053 8.906 20.176 19.416l.814 7.613c9.707 90.844 9.707 182.967 0 273.811l-.814 7.613c-1.123 10.51-9.63 18.697-20.176 19.416l-7.639.521c-64.712 4.413-130.15 6.65-194.5 6.65z" fill="#dfeaef"/><path d="m448.402 474.512c-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-2.915-27.288-4.946-54.652-6.075-82.035-2.52-61.761-.508-123.654 6.075-185.208 64.074-4.363 128.599-6.582 192.392-6.582 26.536 0 53.185.376 79.872 1.147 37.519 1.072 75.095 2.877 112.539 5.435 2.313 21.628 4.062 43.312 5.228 64.996 1.091 19.521 1.693 39.043 1.862 58.564.376 47.957-1.994 95.914-7.091 143.683z" fill="#6bbef6"/><path d="m452.803 423.546c-1.129 17.001-2.595 34.003-4.401 50.966-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-1.034-9.667-1.956-19.333-2.746-29-1.486-17.659-2.595-35.338-3.329-53.035h.019c61.761 0 112.426-106.784 181.841-76.75 69.415 30.015 112.05 86.36 216.069 15.026l.038.075c.245 30.919-.658 61.838-2.689 92.718z" fill="#86f1a7"/><path d="m452.803 423.546c-1.129 17.001-2.595 34.003-4.401 50.966-64.074 4.382-128.599 6.582-192.41 6.582-63.792 0-128.318-2.2-192.392-6.582-1.034-9.667-1.956-19.333-2.746-29 .001 0 205.726-21.966 391.949-21.966z" fill="#66b49d"/><g><circle cx="360.366" cy="273.394" fill="#f4dd45" r="45.22"/></g></g><path d="m337.231 96.515-68.095-92.032c-4.423-5.978-13.366-5.978-17.789 0l-68.095 92.032c-5.403 7.303-.19 17.645 8.894 17.645h14.251c6.111 0 11.064 4.954 11.064 11.064v92.383c0 6.111 4.954 11.064 11.064 11.064h63.432c6.111 0 11.064-4.954 11.064-11.064v-92.383c0-6.111 4.954-11.064 11.064-11.064h14.251c9.085.001 14.298-10.342 8.895-17.645z" fill="#617881"/></g></svg>
						<p>{{LANG your_photo}}</p>
						<small>(Minimun 1024 x 768px size)</small>
					</div>
					<div id="user_image"></div>
				</div>
				<div class="row">
					<div class="col-md-6">
						<div class="pg_mat_input">
							<input type="text" name="title" value="" id="title" required="true" placeholder="{{LANG title}}">
							<label for="title">{{LANG title}}</label>
						</div>
					</div>
					<div class="col-md-6">
						<div class="pg_mat_input">
							<select name="category" required="true" id="category">
								<option value="" selected disabled>{{LANG category}}</option>
								<?php
									$store_categories = store_categories();
									foreach ($store_categories as $key => $category) {
										echo '<option value="'.$key.'">'.$category.'</option>';
									}
								?>
							</select>
						</div>
					</div>
				</div>
				<div class="row m_license" id="0">
					<div class="col-md-6">
						<div class="pg_mat_input mb-0">
							<select name="license[]">
								<option value="" selected disabled>{{LANG license_type}}</option>
								<option value="rights_managed_license">{{LANG rights_managed_license}}</option>
								<option value="editorial_use_license">{{LANG editorial_use_license}}</option>
								<option value="royalty_free_license">{{LANG royalty_free_license}}</option>
								<option value="royalty_free_extended_license">{{LANG royalty_free_extended_license}}</option>
								<option value="creative_commons_license">{{LANG creative_commons_license}}</option>
								<option value="public_domain">{{LANG public_domain}}</option>
							</select>
						</div>
					</div>
					<div class="col-md-6">
						<div class="pg_mat_input mb-0 valign pp_store_lic_chose">
							<input type="wallet" name="price[]" value="" placeholder="{{LANG price}}">
							<label for="price">{{LANG price}}</label>
							<button class="btn btn-success btn_add_license" type="button">+</button>
						</div>
					</div>
				</div>
				<div class="pg_mat_input">
					<textarea id="tags" name="tags" rows="1" required="true" placeholder="{{LANG tags}}"></textarea>
					<label for="tags">{{LANG tags}}</label>
				</div>
				<div class="pg_page_footer">
					<button class="btn btn-large btn-main btn-mat btn-mat-raised" type="submit"><span>{{LANG upload}}</span></button>
				</div>
			</div>
			<div class="col-lg-1"></div>
		</div>
		<input type="hidden" name="user_id" value="<?php echo($context['me']['user_id']) ?>">
		<input type="hidden" name="hash" value="<?php echo($context['csrf_token']) ?>">
		<input type="file" name="photo" class="hidden" id="user-photo" accept="image/x-png,image/jpg,image/jpeg">
    </form>
</div>

<?php 
include $context['dirname_theme'].'/main/templates/includes/lazy-load.html';
 ?>

<script>
    jQuery(document).ready(function($) {
		
		var video_drop_block = $("[data-block='video-drop-zone']");

		if (typeof(window.FileReader)){
			video_drop_block[0].ondragover = function() {
				video_drop_block.addClass('hover');
				return false;
			};
          
			video_drop_block[0].ondragleave = function() {
				video_drop_block.removeClass('hover');
				return false;
			};

			video_drop_block[0].ondrop = function(e) {
				e.preventDefault();
				video_drop_block.removeClass('hover');
				var file = e.dataTransfer.files;
				$('#user-photo').prop('files', file);
				$("#user_image").html("<img src='" + window.URL.createObjectURL(e.dataTransfer.files[0]) + "' alt='Picture'>")
			};
		};
		
        $("#user-photo").change(function(event) {
            $("#user_image").html("<img src='" + window.URL.createObjectURL(this.files[0]) + "' alt='Picture' width='100%'>")
        });
		
		$( "body" ).delegate( '.btn_add_license', "click", function() {
			var id = $(".m_license:last").attr('id');
			var appendDiv = jQuery($(".m_license:last")[0].outerHTML);
				var b = $(".m_license .btn_add_license");
				b.removeClass('btn_add_license').removeClass('btn-success').addClass('btn_remove_license').addClass('btn-danger').text('-');
				
				var c = appendDiv.find('.btn_add_license');
				c.removeClass('btn_add_license').removeClass('btn-danger').removeClass('btn_remove_license').addClass('btn_add_license').addClass('btn-success').text('+');
				appendDiv.attr('id', ++id).insertAfter(".m_license:last");
		});

		$( "body" ).delegate( '.btn_remove_license', "click", function() {
			$(this).closest(".m_license").remove();
		});

        var form = $("form#upload_store_image");
        form.ajaxForm({
            url: link('main/upload_store_image'),
            type: 'POST',
            dataType: 'json',
            beforeSend: function(){
                form.find('button[type="submit"]').attr('disabled','true');
            },
            success: function(data){
                $.toast(data.message,{
                    duration: 5000,
                    type: 'success',
                    align: 'bottom',
                    singleton: true
                });
                form.find('button[type="submit"]').removeAttr('disabled');
                if (data.status == 200) {
                    setTimeout(function () {
                        window.location = '{{CONFIG site_url}}/store/<?php echo($context["user_data"]["username"]);?>/items';
                    },3000);
                }
            }
        });
    });
</script>