<script type="text/javascript" src="{!! asset('js/angular.js') !!}"></script>
<script type="text/javascript" src="{!! asset('js/angular.min.js') !!}"></script>
<script type="text/javascript" src="{!! asset('js/ajax_article.js') !!}"></script>
<link rel="stylesheet" href="{{ asset('css/loader/spinner.css') }}" />

<h2 class="h4">{!! ucwords(str_replace('-', ' ', $page_name)) !!}</h2>
<hr>
<div ng-app="APP.Subapp.Admin">
   <div ng-controller="ArticleController" id="ArticleController" style="display:none;">
      <div class="br-section1" on-scroll-to-bottom="getArticle()"></div>
      <div ng-repeat="(index, article) in articles">
         <div ng-repeat="(index, val) in article">
            <div class="card bigbox-hvr-slow">
               <div class="card-body" >
			   
					
						<div ng-switch="val.article_type_name">
							<div ng-switch-default >
					<span  class="badge badge-pill badge-info mb-2" >{[{ val.article_type_name }]}</span>
					</div>
							<div ng-switch-when="Withdrawal Notice" >								
							</div>
							
						</div>
					
					<span class="badge badge-pill badge-danger float-right">{[{ val.access_base_text }]}</span>
			   
                  <h4 class="card-title"><a href ="{{url('article')}}/{[{ val.article_id}]}">{[{ val.title }]}</a></h4>
				  
					<p> 
						<div ng-switch="val.is_epub">
							<div ng-switch-when="0" >
								<div ng-switch on="(val.first_page != '')">
                                    <span ng-switch-when="true">
                                        Pp: {[{val.first_page}]}-{[{val.last_page}]}
                                    </span>
                                    <span ng-switch-default>
                                        Article ID: {[{val.elocator}]}
                                    </span>
                                </div>
								Volume: {[{ val.volume_name }]},  Issue: {[{ val.issue }]}<br>
							</div>
						</div>						
						Authors: {[{ val.authors }]}<br>
						DOI: <a href="http://dx.doi.org/{[{ val.doi }]}">{[{ val.doi }]}</a>
					</p>


				<div ng-switch on="(val.is_epub != 4) && (val.publish_on != 0) && (val.publish_on >= 1635724800)">
				    <span ng-switch-when="true">
				       Published on: {[{val.publish_on*1000 | date:'longDate'}]}
				    </span>
				    <span ng-switch-default>
				    </span>
				</div>

				<div ng-switch on="(val.is_epub == 0) && (val.graph_abs_sm_filename!='')">
				    <span ng-switch-when="true">
							<p align="center">
								<a href="javascript:void(0);" onclick="enlargeImage(this);">
									<img src="{{ url('/') }}{[{ val.graph_abstract_small }]}" data-high-res-src="{[{ val.graphical_abstract_large }]}" alt="" class="gallery-items img-thumbnail">   
								</a>
							</p>						
				    </span>
				    <span ng-switch-default>
				    </span>
				</div>
					
               </div>
			   	
				<div class="card-footer text-muted" ng-switch="val.is_epub">
				
					<div ng-switch-default>  <!-- If Epub is not 4 -->

						<div ng-switch="val.download_access"> 
						
							<div ng-switch-default>	<!-- If download access is not true -->
							
								<div ng-switch="val.article"> 

									<div ng-switch-default class="d-flex"> <!-- If bundle is false -->
										
										<form class="mb-0" name="marklistfrm" method="POST" action="/marklist">
											<input type="hidden" name="param" value="{[{val.param}]}">
											<input type="hidden" name="_token" value="{{csrf_token()}}">
											<input type="hidden" name="itemtype" value="1">          
											<button type="submit" id="markitembtn" class="card-link text-dark">Add to Wish List</button>
										</form>
										
										<form name="addtocartForm" method="POST" action="/cart" class="mb-0">
											<input type="hidden" name="_token" value="{[{val.csrf_token}]}">
											<input type="hidden" name="param" value="{[{val.param}]}">
											<button type="submit" id="addcartbtn" class="card-link text-dark">Purchase PDF</button>		               
										</form>
									
									</div>
									
									<div ng-switch-when="1" class="d-flex" >
										<form name="addtocartForm" method="POST" action="{{ action('ArticleController@DownlodBundleFile') }}" class="mb-0">
											<input type="hidden" value="{{csrf_token()}}" name="_token">
											<input type="hidden" name="agree-flag" id="agree-flag" value="1">
											<input type="hidden" name="bundle_offer_order_id" id="bundle_offer_order_id" value="{[{ val.bundle_offer_order_id }]}"> 
						                  <input type="hidden" name="param" value="{[{val.sparam}]}">
					
											<div ng-if="val.view_option == 0" class="float-left" >
											<button type="submit" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark" >Download PDF File</button>  
											</div>	 

											<div ng-if="val.view_option == 1" class="float-left" >
												<a type="button" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark" href="{[{ val.route }]}">Read Article</a>
											</div>	


										</form>
									</div>
									
								</div>
								
							</div>
							
							<div ng-switch-when="1">  <!-- If download access is true -->
								
								<form id="download-form-{[{val.article_id}]}" class="mb-0" method="POST" action="/download_file" accept-charset="UTF-8" >
									<input type="hidden" value="{{csrf_token()}}" name="_token">
									<input type="hidden" name="agree-flag" id="agree-flag" value="1">							
									<input type="hidden" name="param" value="{[{ val.sparam }]}">
									
									<div ng-switch="val.terms_popup" name="{[{val.terms_popup}]}"> 
									
										<div ng-switch-when=1  class="d-flex"> <!-- If popup terms is true (Trail Access) -->
											<div ng-if="val.view_option == 0" >
												<button type="button" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark " onclick="javascript:return CheckLicense(this.id);">Download PDF File</button>
											</div>	
											
											<div ng-if="val.view_option == 1" >
												<a type="button" id="readpdf_{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark" href="{[{ val.route }]}" onclick="javascript:return CheckLicense(this.id);">Read Article</a>
											</div>	
											
										</div>
										
										<div ng-switch-default> <!-- If popup terms is false (Corporate or Token Access) -->
										
											<div ng-switch on="(val.type == 444) || (val.type == 555)"> <!-- If popup terms is false (Single or Multiple Token Access) -->
											
												<div class="d-flex"  ng-switch-when="true">
													<div ng-switch="val.view_option">	
														<div ng-switch-when="0">
														<button type="button" class="card-link text-dark" data-toggle="modal" data-target="#token_{[{val.article_id}]}">Download PDF File</button>
													</div>	

														<div ng-switch-when="1">
															<a type="button" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark" href="{[{ val.route }]}">{[{ val.view_type }]}Read Article</a>
														</div>
													</div>	

													<!-- Model Window Start -->
													<div class="modal fade" id="token_{[{val.article_id}]}" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
													<div class="modal-dialog">
													<div class="modal-content">
													<div class='modal-header bg-primary'>
														<h4 class="modal-title text-white" id="modalLabelprimary">Restricted Access Panel</h4>
														<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>&times;</span></button>
													</div>
														<div class='modal-body'>
															<label class="control-label">Content Access Key</label>
															<input type="text" name="user_name" class="form-control" required>
															<label class="control-label">Password</label>
															<input type="password" name="password" class="form-control" required>
														</div> 
													<div class="modal-footer">
													<button type="button" class="btn btn-primary" onclick="javscript:logintoDownload(this);" value="{[{val.article_id}]}"><span class="glyphicon glyphicon-remove-circle"></span> Login to Download</button>
													<button type="button" class="btn btn-default" data-dismiss="modal"><span class="glyphicon glyphicon-remove-circle"></span> Close</button>

													</div> 
													</div>
													</div> 
													</div>
													<!-- Model Window End -->
												</div>
												
												<div class="d-flex" ng-switch-default>		
													<!-- If popup terms is false (Trail (Free) / Corporate / Download without key Token Access) -->

													<div ng-if="val.view_option == 0" >
														<button type="submit" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark ">Download PDF File</button>
													</div>	
													<span class="my-2 py-1">|</span>
													<div ng-if="val.view_option == 1" >
														<a type="button" id="{[{ val.article_id }]}" name="download{[{ val.article_id }]}" class="card-link text-dark" href="{[{ val.route }]}">Read Article</a>
													</div>	

												</div>
												
												
											</div>
										</div>
									</div>
								</form>
								
							</div>							
							
							
						</div>	
							
					</div>

					<div ng-switch-when="4"> <!-- If Epub is 4 -->
							<a class="card-link text-dark d-block" href ="{{url('full-text-inquiry')}}/{[{ val.article_id}]}">Full Text Inquiry</a>

					</div>
					
				</div>
				
			   
            </div>
            <br>
				<!-- --------------Trial Trial Terms Condition------------------------- -->

					<div ng-if="val.type == 111">
					   <a id="license{[{ val.article_id}]}" href="{[{ val.terms_url}]}"></a>
         </div>
					<div ng-if="val.type != 111" >
					   <a id="license{[{ val.article_id}]}" href="{[{ val.terms_url}]}"></a>
					</div>
         </div>
      </div>
      
         <a ng-click="getArticle()" class="btn btn-white btn-block align-middle">Load More <i class="fa fa-arrow-alt-circle-down"></i></a>
      
   </div>
   
   <div id="EmptyDiv" class="cardbox text-center d-none alert alert-danger">No Record Found</div>
   
   
	<input type="hidden" name="license_downloadid" id="license_downloadid" value="0">

   <!-- Loader Start-->
	<div id="loader" class="card-body">
		<center>
			<div class="lds-spinner"><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div></div>
		<h4 class="card-title"><strong>LOADING</strong></h4>
		</center>
	</div>
	<!-- Loader End -->

</div>


	<div style="text-align:left;" class="modal fade" id="TnCModal" tabindex="-1" role="dialog" aria-labelledby="TnCModalLabel" aria-hidden="true">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
			
			</div> 
		</div> 
	</div>





<link href="{{ asset('css/imageviewer.css') }}"  rel="stylesheet" type="text/css" />
<script src="{{ asset('js/imageviewer.js') }}"></script>

<script type="text/javascript" src="{{ asset('js/jquery.min.js') }}"></script>
<script>

function enlargeImage(_this)
{
	var viewer = ImageViewer();
	var imgSrc = $(_this).find('img').attr('src'),
	highResolutionImage = $(_this).find('img').attr('data-high-res-src');
	viewer.show(imgSrc, highResolutionImage);
	

	$('.alert[data-auto-dismiss]').each(function (index, element) {
		var $element = $(element),
			timeout  = $element.data('auto-dismiss') || 5000;

		setTimeout(function () {
			$element.alert('close');
		}, timeout);
	});
	
}

function CheckLicense(id) {
  $('#license_downloadid').val(id);

  var array = id.split('_');
  var file_type = '';
  if(array[0] != "readpdf")
  {
  	id=id;
  }
  else
  {
  	id=array[1];
  	file_type="readpdf";
  }
  if($("#agree-flag").val() == "" || $("#agree-flag").val() != "Y"){
    
    var target = $("#license"+id).attr("href");
    $("#TnCModal .modal-content").load(target+'/article/'+file_type, function() {                      
      $("#TnCModal").modal("show"); 
    });                     
      return false;
    }
  
} 

function logintoDownload(element)
{
	$("#download-form-"+element.value).submit(); 
	$("#token_"+element.value).modal("hide");
		return ;	
	
	
}

</script>