templates/Default/simple/widget_doc.html.twig line 1

Open in your IDE?
  1. {% extends "Default/layout.html.twig" %}
  2. {% set page_title = 'widget.metatitle' | trans %}
  3. {% set page_class='page-about' %}
  4. {%block page_headjs %}
  5.     <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  6.     <script src="https://code.jquery.com/jquery-1.12.4.min.js"  ></script>
  7.     <script type="text/javascript"
  8.             src="https://maps.googleapis.com/maps/api/js?libraries=places&key={{ constant('App\\Service\\MapsApi::GMAPSKEY_JSAUTOCOMPLETE') }}"></script>
  9. {% endblock%}
  10. {% block page_content %}
  11.     {#<h1>Widget ComparaBUS, afficher les offres de transports sur votre site !</h1>#}
  12.     <section class="panel">
  13.         <h1 class="panel-heading">{{ 'widget.doc.title' | trans }}</h1>
  14.         <div class="panel-body">
  15.             {{ 'widget.doc.body' | trans | raw }}
  16.             <div class="row">
  17.                 <div class="col-md-6">
  18.                     <iframe width="400" scrolling="no" height="300" frameborder="0" vspace="0" hspace="0" marginheight="0" marginwidth="0" src="https://www.comparabus.com/fr/widget/iframe2?bgImgLink=https://cdn.pixabay.com/photo/2019/07/21/15/48/paris-4353012_960_720.jpg&widgetTitle=ParisTourisme.com&headerType=false&buttonColor=ffffff&buttonBgColor=000000&arr=Paris, France&arrLat=48.85661400000001&arrLng=2.3522219000000177"></iframe>
  19.                     <br>fourni par <a href="https://www.comparabus.com/fr/">ComparaBUS</a>
  20.                 </div>
  21.                 <div class="col-md-6">
  22.                     <iframe width="400" scrolling="no" height="300" frameborder="0" vspace="0" hspace="0" marginheight="0" marginwidth="0" src="https://www.comparabus.com/en/widget/iframe2?bgImgLink=https://cdn.pixabay.com/photo/2017/12/22/11/09/schilthorn-3033448__340.jpg&widgetTitle=AlpesNordSki.com - How to come here&headerType=false&buttonColor=ffffff&buttonBgColor=2ecc71"></iframe>
  23.                     <br>fourni par <a href="https://www.comparabus.com/en/">ComparaBUS</a>
  24.                 </div>
  25.             </div>
  26.         </div>
  27.     </section>
  28.     <section class="panel" id="simple">
  29.         <h2 class="panel-heading">{{ 'widget.doc.simple.title' | trans }}</h2>
  30.         <div class="panel-body">
  31.             <div class="row">
  32.                 <div class="col-md-6">
  33.                     <div class="panel">
  34.                         <h1 class="panel-heading">{{ 'widget.doc.simple.body' | trans | raw }}</h1>
  35.                         <div class="panel-body">
  36.                             <form id="custom-simple">
  37.                                 <div class="form-group">
  38.                                     <div class="form-check form-check-inline">
  39.                                         <input class="form-check-input" type="checkbox" id="header_type_light" name="header_type" value="1">
  40.                                         <label for="header_type_light" class="form-check-label">{{ 'widget.doc.simple.lightHeader' |trans  }} </label>
  41.                                     </div>
  42.                                 </div>
  43.                                 <div class="form-group">
  44.                                     <label for="widget_title" >{{ 'widget.doc.simple.headerTitle'|trans }}</label>
  45.                                     <input type="text" class="form-control" id="widget_title" placeholder="{{ 'widget.simple.title'|trans }}" name="widget_title"/>
  46.                                 </div>
  47.                                 <div class="form-row">
  48.                                     <div class="form-group col-md-6 ">
  49.                                         <label for="city_dep">{{ 'widget.simple.dep' |trans }}</label>
  50.                                         <input class="form-control" type="text" id="city_dep" name="city_dep"  placeholder="{{ 'widget.doc.simple.city' | trans }}"/>
  51.                                     </div>
  52.                                     <div class="form-group col-md-6">
  53.                                         <label for="city_arr">{{ 'widget.simple.arr' |trans }}</label>
  54.                                         <input class="form-control" type="text" id="city_arr" name="city_arr"  placeholder="{{ 'widget.doc.simple.city' | trans }}"/>
  55.                                     </div>
  56.                                 </div>
  57.                                 <input type="hidden" id="city_dep_lat" name="city_dep_lat"/>
  58.                                 <input type="hidden" id="city_dep_lng" name="city_dep_lng"/>
  59.                                 <input type="hidden" id="city_arr_lat" name="city_arr_lat"/>
  60.                                 <input type="hidden" id="city_arr_lng" name="city_arr_lng"/>
  61.                                 <div class="form-group">
  62.                                     <label for="background_img_link">{{ 'widget.doc.simple.bgImgLink'|trans }}</label>
  63.                                     <input class="form-control" type="text" id="background_img_link" placeholder="{{ 'widget.doc.simple.bgImgLinkPH'|trans }}" name="background_img_link"/>
  64.                                 </div>
  65.                                 <div class="form-row">
  66.                                     <div class="form-group col-md-6">
  67.                                         <label for="button_color">{{ 'widget.doc.simple.buttonColor'|trans }}</label>
  68.                                         <input class="form-control" type="color" id="button_color" name="button_color" value="#ffffff"/>
  69.                                     </div>
  70.                                     <div class="form-group col-md-6">
  71.                                         <label for="button_bg_color">{{ 'widget.doc.simple.bgButtonColor'|trans }}</label>
  72.                                         <input class="form-control" type="color" id="button_bg_color" name="button_bg_color" value="#113c51"/>
  73.                                     </div>
  74.                                 </div>
  75.                                 <div class="form-group">
  76.                                     <label>{{ 'widget.doc.simple.language' | trans }} :</label>
  77.                                     <select class="form-control" name="locale">
  78.                                         {# TODO get that automatically from locales.yaml and homepage.footer.widget.enabled - langs: duplicated code with OdController #}
  79.                                         {% for lang in ['en','fr','es','it','cs','ru','uk_UA','tr','pl'] %}
  80.                                             <option {{ app.request.locale | slice(0,2) == lang ? 'selected' }}
  81.                                                     value="{{ url('widget_iframe2', {'_locale': lang}) }}">{{ lang }}</option>
  82.                                         {% endfor %}
  83.                                     </select>
  84.                                 </div>
  85.                                 <div class="form-group text-center">
  86.                                     <input type="button" value="{{ 'widget.doc.simple.create' | trans }}"
  87.                                            class="btn-custom btn btn-success "/>
  88.                                 </div>
  89.                             </form>
  90.                         </div>
  91.                     </div>
  92.                 </div>
  93.                 <div class="col-md-6">
  94.                     <div class="iframe-wrapper">
  95.                         <iframe width="400" scrolling="no" height="300" frameborder="0" vspace="0" hspace="0"
  96.                                 marginheight="0" marginwidth="0" src="{{ url('widget_iframe2') }}"></iframe>
  97.                         <br/><p style="text-align: right;">{{ 'widget.doc.simple.poweredby' | trans }} <a href="{{ url('homepageLocale') }}">ComparaBUS</a></p>
  98.                     </div>
  99.                 </div>
  100.             </div>
  101.             <div class="row" style="margin-top: 30px;">
  102.                 <div class="col-md-12" style="text-align: center;">
  103.                     {{ 'widget.doc.simple.code' | trans }}<br/>
  104.                     <textarea rows="4" cols="100%"></textarea>
  105.                 </div>
  106.             </div>
  107.         </div>
  108.     </section>
  109.     {% if app.request.locale | slice(0,2) == 'fr' %}
  110.     <section class="panel" id="advanced">
  111.         <h1 class="panel-heading">Widget avancé</h1>
  112.         <div class="panel-body">
  113.             Il vous suffit de copier-coller le code ci-dessous (sans modification).<br />
  114.             Le widget est compatible avec tout les sites et blogs (par exemple wordpress).<br />
  115.             N'hésitez pas à nous contacter sur <span class="contact-cb"></span> si vous avez des questions sur l'intégration, si vous souhaitez modifier son fonctionnement, ou pour nous indiquer que le widget est présent sur votre site.<br />
  116.             Customisation du widget :
  117.             <ul>
  118.                 <li>Afficher seulement un type de transport : bus/carpooling/train/flight
  119.                     <ul>
  120.                         <li>Afficher les offres de bus seulement : ...iframe?type[]=bus</li>
  121.                         <li>Afficher les offres de bus et covoiturage : ?type[]=bus&type[]=carpooling</li>
  122.                     </ul>
  123.                 <li>Afficher seulement une compagnie
  124.                     <ul>
  125.                         <li>Afficher les offres de OUIBUS seulement : ?company[]=1</li>
  126.                         <li>Afficher les offres de OUIGO seulement : ?company[]=8</li>
  127.                     </ul>
  128.                 </li>
  129.                 <li>Selectionner la ville de départ et d'arrivée
  130.                     <ul>
  131.                         <li>Selectionner la ville de départ : ?depStopId=10</li>
  132.                         <li>Selectionner la ville de départ et d'arrivée : ?depStopId=10&arrStopId=6</li>
  133.                         <li>Les ids de villes peuvent être retrouvés dans l'url après avoir effectué une recherche. Exple : 10=Paris, 6=Lille, ...</li>
  134.                     </ul>
  135.                 </li>
  136.                 <li>
  137.                     Configurer la couleur principale  : ?color=11ff00
  138.                 </li>
  139.                 <li>
  140.                     Résultats affichées dans une nouvelle fenêtre ComparaBUS (vous permettant de minimiser l'affichage du widget) : ?redirect=true (voir exemple #1)
  141.                 </li>
  142.             </ul>
  143.         <h3>Code à utiliser :</h3>
  144.             <textarea rows="4" cols="100%"><iframe style="border: 0; height: 700px; width: 100%;" src="{{ url('widget_iframe') }}" width="300" height="150"></iframe>
  145. <br /><em>{{ 'widget.doc.simple.poweredby'|trans }}<a href="http://www.comparabus.com/fr/">ComparaBUS</a></em>
  146.             </textarea>
  147.         <br/>
  148.         <h3>Exemples d'intégration</h3>
  149.         <ul>
  150.             <li><a href="http://www.transfermuga.eu/fr/comparabus/" rel="nofollow">Transfermuga</a></li>
  151.             <li><a href="http://www.welcomebask.com/edito/comparateur-de-trajet-bus" rel="nofollow">WelcomeBask</a></li>
  152.         </ul>
  153.         <h3>Rendu du widget mini #1 (?redirect=true)</h3>
  154.         <iframe style="border: 0; height: 300px; width: 100%;" src="{{ url('widget_iframe') }}?redirect=true"></iframe><br />
  155.         <em>fourni par <a href="http://www.comparabus.com/fr/">ComparaBUS</a></em></p>
  156.         <h3>Rendu du widget #2</h3>
  157.         <iframe style="border: 0; height: 500px; width: 100%;" src="{{ url('widget_iframe') }}"></iframe><br />
  158.         <em>fourni par <a href="http://www.comparabus.com/fr/">ComparaBUS</a></em></p>
  159.         </div>
  160.     </section>
  161.     {% endif %}
  162.     <script>
  163.         var place;
  164.         var place2;
  165.         var src = $("#simple iframe").attr('src');
  166.         function initializeAutocomplete(id) {
  167.             var element = document.getElementById(id);
  168.             var autocomplete = new google.maps.places.Autocomplete(element, {types: ['(cities)']});
  169.             google.maps.event.addListener(autocomplete, 'place_changed', function(){
  170.                 if(id === "city_dep"){
  171.                     place = this.getPlace();
  172.                 }
  173.                 else if(id === "city_arr"){
  174.                     place2 = this.getPlace();
  175.                 }
  176.                 updateWidget();
  177.             });
  178.         }
  179.         google.maps.event.addDomListener(window, 'load', function () {
  180.             initializeAutocomplete('city_dep');
  181.             initializeAutocomplete('city_arr');
  182.         });
  183.         function fillTextarea() {
  184.             var sourceCode = $("#simple .iframe-wrapper").html().trim();
  185.             sourceCode = sourceCode.replace(/&amp;/g, '&'); //or http://stackoverflow.com/questions/3700326
  186.             $("#simple textarea").val(sourceCode);
  187.         }
  188.         function updateWidget() {
  189.             var src_custom = $('select[name=locale]').val()+"?";
  190.             let params =
  191.                 {
  192.                     'bgImgLink':$("#background_img_link").val(),
  193.                     'widgetTitle': $("#widget_title").val(),
  194.                     'headerType': $('#header_type_light').is(':checked'),
  195.                     'buttonColor': $("#button_color").val(),
  196.                     'buttonBgColor': $("#button_bg_color").val()
  197.                 };
  198.             var depCity = $("#city_dep").val();
  199.             var arrCity = $("#city_arr").val();
  200.             let url = addParamToUrl(src_custom,params);
  201.             //src_custom += "?bgImgLink="+bg_img+"&widgetTitle="+title+"&headerType="+headerType+"&buttonColor="+button_color.substr(1)+"&buttonBgColor="+button_bg_color.substr(1);
  202.             if(depCity){
  203.                 url += "dep="+depCity+"&depLat="+place.geometry.location.lat()+"&depLng="+place.geometry.location.lng()+"&";
  204.             }
  205.             if(arrCity){
  206.                 url += "arr="+arrCity+"&arrLat="+place2.geometry.location.lat()+"&arrLng="+place2.geometry.location.lng()+"&";
  207.             }
  208.             $("#simple iframe").attr('src', url.slice(0,-1));
  209.             fillTextarea();
  210.         }
  211.         function addParamToUrl(url,array){
  212.             for(let key in array){
  213.                 if(array[key] !== ""){
  214.                     if(array[key].toString().charAt(0) === '#'){
  215.                         url += key+"="+array[key].substr(1)+"&";
  216.                     }else{
  217.                         url += key+"="+array[key]+"&";
  218.                     }
  219.                 }
  220.             }
  221.             return url;
  222.         }
  223.         $("form input, form select").change(function() {
  224.             updateWidget();
  225.         });
  226.         $("#simple .btn-custom").click(function() {
  227.             updateWidget();
  228.             return false;
  229.         });
  230.         fillTextarea();
  231.     </script>
  232. {% endblock %}