@extends('layouts.app')
@section('title')
@if($alphabet)
Journals by Titles :: Journals in {{$alphabet}}
@else
All Journals
@endif
@parent
@stop
@section('metatags')
<meta description = "Bentham Science Journals by Titles :: Journals | Bentham Science" />
<meta name="keywords" content="Journals,Search Journal"> 

<meta property="og:type"   content="website" /> 
<meta property="og:title" content="Current Immunology Reviews" />   
<meta property="og:url" content="http://www.eurekaselect.com/614/journal/current-immunology-reviews"/>
<meta property="og:image" content="http://www.eurekaselect.com/sites/default/files/images/bentham/CIR_0.gif" />
<meta property="og:description" content="" />
<meta property="og:site_name" content="http://www.eurekaselect.com" />
@stop
@section('header_styles')
<link href="{{ asset('assets/vendors/select2/css/select2.min.css') }}" rel="stylesheet" type="text/css">
    <link href="{{ asset('assets/vendors/select2/css/select2-bootstrap.css') }}" rel="stylesheet">
<script type='text/javascript' src='https://platform-api.sharethis.com/js/sharethis.js#property=5f2d6cad2e6de20011ec6cd1&product=inline-share-buttons' async='async'></script>


        @stop
@section('content')
        <main id="j-listing">
            <section class="pt-4" id="listing-search">
                <div class="container">
                    <div class="row">
                        <div class="col-md-12 text-white">
                            <h1 class="h3">
                                Journals
                            </h1>
                            <hr>                            
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <div class="card text-white bigbox-hvr-slow">
                                <div class="card-body">
                                    <form action="{{ route($searchFormRoute) }}" enctype="multipart/form-data" method="post">
                                      <input type="hidden"  name="_token" value="{{ csrf_token() }}">
                                    <h5 class="card-title text-dark text-center">
                                        Find Journals, Volumes, Issues & Articles
                                    </h5>
                                    <div class="row">
                                        <div class="col-md-8 offset-md-2"  ng-app="myapp" ng-controller="fetchCtrl">
                                            <div class="input-group input-group-lg"  ng-click='containerClicked();'>                                                
											
                                                <input class="form-control" aria-label="Search Journal name / issn / eissn / doi" name="journal_search" autocomplete="off" autocorrect="off" id="exampleFormControlInput1" placeholder="Journal name / issn / eissn / doi" type="text"

                                                ng-change='fetchUsers()' 
                                                ng-click='searchboxClicked($event);' 
                                                ng-model='searchText'
                                                >
                                                    <!--select id="jlist-search" class="form-control col-3">
                                                      <option value="journal">Journal</option>
                                                      <option value="volume">Volume</option>
                                                      <option value="doi">DOI</option>
                                                      <option value="subject">Subject</option>
                                                    </select-->
                                                    <div class="input-group-prepend">
                                                        <button class="btn btn-primary bg-siteblue" value="1" name="btnjournalsearch" type="submit">
                                                            Search
                                                        </button>
                                                    </div>                                                
												    <div id='searchResult' class="fancy-scroll d-none" >
													<ul class='smart-box'>
														
													  <li ng-click='setValue($index,$event)' 
														  ng-repeat="journal_title in searchResult" >
														  {[{ journal_title.title }]}
													  </li>
													  
													</ul>
                                                    </div>
													
                                            </div>
											
											
											
                                            <br>
																					
											
                                           
                                        </div>
                                    </div>
                                    </form>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-md-12">
                            <div aria-label="First group" class="btn-group d-flex alpha-page text-white" role="group">
                                <a class="btn col" href="{{route('bypublication')}}">
                                    All
                                </a>
                                @foreach (range('A', 'Z')  as $letter)
                                <a class="btn col" href="{{route($searchFormRoute)}}/{{$letter}}">
                                    {{$letter}}
                                </a>
                                @endforeach
                                
                                
                            </div>
                            
                        </div>
                    </div>
                </div>
            </section>
            <section class="pt-5">
                <div class="container">
                    <div class="row list">
                      @if(!empty($journal))
                        @php $subscribe=''; 

                          if(session()->has('mysubscribption'))  {
                              $subscribe ='subscribe';
                          }else{
                              $subscribe ='';
                          }    
                        @endphp  
                        @foreach ($journal as $journals)
                          
                            <div class="col-md-6">
                                <div class="item bigbox-hvr-slow">
                                    <div class="col-md-3">

                                      <a href="{{ URL::route('journal', ['journal_id'=>strtolower($journals->subtitle),'page_name'=>$subscribe] ) }}">

                                        @if(isset($journals->image_file_name))
                                        <img class="img-fluid" alt="{{$journals->title}}" src="{{'/images/bentham/'.$journals->image_file_name}}"/>

                                        @else
                                        <img alt="profile pic" src="https://via.placeholder.com/95x125">
                                        @endif
                                        </a>
                                    </div>
                                    <div class="col-md-9">
                                        <h4>

                                            <a href="{{ URL::route('journal', ['journal_id'=>strtolower($journals->subtitle),'page_name'=>$subscribe] ) }}">

                                                {{$journals->title}}
                                            </a>
                                        </h4>
                                        <p>
                                @if($journals->subtitle != "NEMJ")
                                            ISSN (Print):{{$journals->issn}}
										<br>
                                @endif

                                                ISSN (Online):{{$journals->eissn}}
                                            </br>
                                            <?php echo DisplaySocialNetworkLink($journals->title,'https://'.$_SERVER['HTTP_HOST'].'/journal/'.$journals->journal_id.'');?>
                                        </p>
                                    </div>
                                </div>
                            </div>
                           
                        @endforeach
                        
                        <div class="col-md-12 d-inline-flex list-pagination">{{ $journal->appends(request()->input())->links() }}</div>
                      @else
                      <div class="col-md-12 text-center">No Record Found</div>
                      @endif
                    </div>
                </div>
            </section>

        </main>
        @endsection
@section('footer_scripts')
 <script type="text/javascript" src="{!! asset('js/angular.js') !!}"></script>
 <script type="text/javascript">
    
    var fetch = angular.module('myapp', []);
       fetch.config(function($interpolateProvider) 
        {
            $interpolateProvider.startSymbol('{[{').endSymbol('}]}');
        });


    fetch.controller('fetchCtrl', ['$scope', '$http', function ($scope, $http, $window) {
       
       // Fetch data
       $scope.fetchUsers = function(){
                    
          var searchText_len = $scope.searchText.trim().length;
          returnResult = [];
          // Check search text length
          if(searchText_len > 0){
            
             $http({
               method: 'POST',
               url: '/api/services_journals/json/20',
               data: {searchText:$scope.searchText}
             }).then(function successCallback(response) 
			 {  
			 
				$("#searchResult").removeClass('d-none');
				
				//console.log(response.data.journal_list.data);
				$scope.searchResult = 0;
				//$scope.searchResult = response.data.journal_list;
                $scope.searchResult.IsVisible  = true;
                angular.forEach(response.data, function(value, key)
				{  
                    angular.forEach(value.data,function(v1,k1)
					{   
						//this is nested angular.forEach loop
                        returnResult.push( { title : v1.journal_title });
                    });                                 
                });
				
                $scope.searchResult = returnResult;
				
             });
          }else{
             $scope.searchResult = {};
          }
                    
       }

       // Set value to search box
       $scope.setValue = function(index,$event)
	   {
          $scope.searchText = $scope.searchResult[index].title;
          $scope.searchResult = {};
          $event.stopPropagation();
		  
       }

       $scope.searchboxClicked = function($event){
          $event.stopPropagation();
       }

       $scope.containerClicked = function(){
          $scope.searchResult = {};
       }
     
    }]);

 </script>
<script src="{{ asset('js/jquery.min.js') }}" type="text/javascript"></script>
        <script language="javascript" src="{{ asset('assets/vendors/select2/js/select2.js') }}" type="text/javascript">
        </script>
        <script>
            $(document).ready(function() {

    $("#journal_year").change(function(){
        
      var vYear= $("#journal_year").val();
      $(location).attr('href', '/bypublication/'+vYear);
    });
});
             $(".select2").select2({
                theme:"bootstrap",
                placeholder:"",
                width: '100%'
            });
        </script>
        @stop
