customer_galleriesmanager.phtml 3.88 KB
<script type="text/javascript">
	function loadNcImageIntoFormThumbnailButton() {
		jQuery('.anc_image_choose').unbind("click").click(function(e){
			e.preventDefault(); 					
			loadNcImageIntoForm(jQuery(this).data('site'));
		});				
	}
	function loadNcImageIntoForm(param_url) {
		jQuery(".ancimage-customer_galleriesmanager * #ancimage-customer_galleriesmanager-form-content").load(param_url, function() {

			jQuery('#ancimage-customer_showNcImageFormDelete').submit(function() { // catch the form's submit event
				jQuery.ajax({ // create an AJAX call...
					data: jQuery(this).serialize(), // get the form data
					type: jQuery(this).attr('method'), // GET or POST
					url: jQuery(this).attr('action'), // the file to call
					success: function(response) { // on success..
						jQuery('.ancimage-customer_galleriesmanager * #ancimage-customer_galleriesmanager-form-content').html(response); // update the DIV
					}
				});
				return false; // cancel original event to prevent form submitting
			});																						
			jQuery('#ancimage-customer_showNcImageForm').submit(function() { // catch the form's submit event
				jQuery.ajax({ // create an AJAX call...
					data: jQuery(this).serialize(), // get the form data
					type: jQuery(this).attr('method'), // GET or POST
					url: jQuery(this).attr('action'), // the file to call
					success: function(response) { // on success..
						jQuery('.ancimage-customer_galleriesmanager * #ancimage-customer_galleriesmanager-form-content').html(response); // update the DIV
						loadNcImageIntoForm(param_url)
					}
				});
				return false; // cancel original event to prevent form submitting
			});												
		});
	}
</script>
<div class="ancimage-customer_galleriesmanager">
	<?php if(Mage::getSingleton('customer/session')->isLoggedIn()): ?>
		<div class="col2-set">
			<div class="col-1">
				<div class="ancimage-customer_galleriesmanager-form">
					<div class="ancimage-customer_galleriesmanager-main"><h1>Ihre Motive</h1></div>
					<div class="ancimage-customer_galleriesmanager-content" id="ancimage-customer_galleriesmanager-form-content"></div>				
				</div>
			</div>			
			<div class="col-2">
				<?php $dropzone_id = 'ancimage-dropzone-id'.Mage::helper('anc_lib/data')->getElementIndexForId(); ?> 
				<?php $ancnote_id = 'ancnote-id'; ?>
				<?php echo $this->getLayout()
								->getBlockSingleton('anc_image/galleriesmanager')
								->setTemplate('anc/image/customer_galleries.phtml')
								->setSelectorIdDropzoneOwn($dropzone_id)
								->toHtml(); ?>
				<script type="text/javascript">
					jQuery(document).ready(function($) {
						var dropzone_params = {
							url: "<?php echo $this->getUrl('ancimage/customer/uploadImage', array()) ?>",
							dictDefaultMessage: 'Bild hochladen',
							success: function() {	this.removeAllFiles();	}
						}
						var gallery_ajaxData = {
							url: "<?php echo $this->getUrl('ancimage/customer/gallerysimple', array()) ?>  ul.gallery",
							context: jQuery(".ancimage-customer_galleriesown > .ancimage-gallerie-content > .ancimage-gallerie-content-view"),
							success: function(reponse) { 
								// damit die gallerie auch klickbar ist
									loadNcImageIntoFormThumbnailButton();	
								// damit hochgeladenes Bild auch im Formular gleich angezeigt wird
									loadNcImageIntoForm('<?php echo $this->getUrl('ancimage/customer/showNcImageForm', array())?>id/'+reponse.id+'/');
							},
						};						
						
						Anc_Image_Type.droppableFile(
							jQuery(" #<?php echo $dropzone_id; ?>"), 
							dropzone_params,
							null, 
							jQuery(" #<?php echo $ancnote_id; ?>"), 
							gallery_ajaxData,
							false
						);							
					}); 			
				</script>					
			</div>			
		</div>		

		<script type="text/javascript">
			jQuery(document).ready(function($) {
				loadNcImageIntoFormThumbnailButton();
			}); 			
		</script>	
	
	<?php else: ?>
		<h1>Bitte loggen Sie sich ein!</h1>
	<?php endif; ?>	
</div>