294 lines
12 KiB
Plaintext
294 lines
12 KiB
Plaintext
|
|
= semantic_form_for [:public, @annonce], :remote => true do |f|
|
|
=hidden_field_tag :create, true if @create
|
|
#annonce_form_large
|
|
-if !@create
|
|
.center.row{:style => "position:relative;"}
|
|
.col-sm-8
|
|
#annonce_save.col-sm-4{:style => "position:absolute;top:0;right:0; max-width:400px"}
|
|
%nav.pannel.alert.alert-success
|
|
%h3 Déposer une annonce c'est simple
|
|
%p Il suffit de remplir le formulaire sur cette page et de cliquer sur enregistrer.
|
|
%p Une fois l'annonce enregistrée vous pourrez ajouter des photos.
|
|
%p
|
|
-if ! @annonce.id
|
|
=f.submit "Enregistrer", :class => "btn btn-success btn-lg"
|
|
-else
|
|
%p=f.submit "Enregistrer les modifications", :class => "btn btn-success btn-lg"
|
|
%p=link_to i(:eye)+" Voir l'annonce", public_annonce_path(@annonce.id)
|
|
%p=link_to i(:plus)+" Mettre en valeur mon annonce", options_public_annonce_path(@annonce.id)
|
|
%p=link_to i(:"trash-o")+" désactiver mon annonce", [:public, @annonce], :data => {:confirm => "Voulez-vous vraiment désactiver votre annonce ? Elle ne sera plus visible sur Sideplace"}, :method => :delete
|
|
|
|
-if @annonce.id and !@annonce.published
|
|
#annonce_publish.alert.alert-warning
|
|
%h3 Votre annonce n'est pas publiée
|
|
%p Une fois que vous avez vérifié le contenu de votre annonce vous devez la publier pour qu'elle soit visible de tous :
|
|
=link_to "Publier maintenant", publish_public_annonce_path(@annonce), :remote => true, :class => "btn btn-warning btn-lg"
|
|
.center.padding
|
|
%div{:class => (@annonce.id ? "col-sm-8" : "")}
|
|
=f.inputs do
|
|
=f.input :annonce_style_id, :collection => [["Classique", 1],["Large view (image panoramique)", 2] ], :as => :radio, :label => "Style de l'annonce :"
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:annonce_cat_id].size > 0)}
|
|
.col-sm-2
|
|
=f.label :annonce_cat_id, "Catégorie* :", :class => "control-label"
|
|
|
|
.col-sm-4
|
|
-if !@annonce.id
|
|
=f.select :annonce_cat_id, option_groups_from_collection_for_select(AnnonceCat.where(:parent_id => nil).all, :children, :name, :id, :name,f.object.annonce_cat_id), {:include_blank => true}, {:onchange => ("$.ajax({ url: '#{new_public_annonce_path()}',data: {annonce_cat_id : $(this).val()}});" if !@annonce.id), :class => "form-control" }
|
|
|
|
-else
|
|
%strong
|
|
=@annonce.annonce_cat.name
|
|
|
|
|
|
.clear
|
|
|
|
|
|
|
|
|
|
.clear
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:price].size > 0)}
|
|
.col-sm-2
|
|
=f.label :price, "Prix :", :class => "control-label"
|
|
|
|
.col-sm-3
|
|
=f.text_field :price, :class => "form-control", :placeholder => "Prix", :"aria-describedby"=>"inputWarning2Status"
|
|
.col-sm-2
|
|
=f.label :devise_id, "Devise"
|
|
.col-sm-3
|
|
=f.collection_select :devise_id, Devise.all, :id,:name, {:include_blank => false}, {:onchange => "", :class => "form-control" }
|
|
|
|
.clear
|
|
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:title].size > 0)}
|
|
.col-sm-2
|
|
=f.label :title, "Titre* :", :class => "control-label"
|
|
|
|
.col-sm-10
|
|
=f.text_field :title, :class => "form-control", :placeholder => "Titre de l'annonce", :"aria-describedby"=>"inputWarning2Status"
|
|
.clear
|
|
|
|
= f.label :content, "Texte de l'annonce :"
|
|
= f.text_area :content, :class => "form-control", :style => "width:100%;height:400px;", :place_holder => "Texte de l'annonce"
|
|
|
|
|
|
%br
|
|
%p
|
|
=f.check_box :internet #, :onchange => "if($(this).is(':checked')){$('#localisation_space').hide();}else{$('#localisation_space').show();}"
|
|
=f.label :internet, "Mon annonce concerne un produit qui n'est pas forcément à récupérer en main propre (exemple : produit facilement expédiable, VAD, services par internet, etc.)."
|
|
#localisation_space
|
|
.row{:style => "margin:0 -15px;"}
|
|
.col-md-6
|
|
#g_localisation
|
|
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:g_text].size > 0)}
|
|
.col-sm-2
|
|
=f.label :g_text, "Ville :", :class => "control-label",:autocomplete => "off"
|
|
|
|
.col-sm-10
|
|
|
|
=f.text_field :g_text, :class => "form-control g_text_field", :placeholder => "Ville (préciser le département si besoin)",:autocomplete => "off", :id => "g_autocomplete"
|
|
|
|
#lat
|
|
|
|
#geocode{:style => "min-height:3em;"}
|
|
=render :partial => "public/annonces/geocode"
|
|
%p
|
|
Vous pouvez indiquer le nom de votre ville, et éventuellement préciser le département s'il existe des homonymes. Dans le cas d'un arrondissement vous pouvez également indiquer le code postal.
|
|
.clear
|
|
.col-md-6
|
|
#map{:style => "background:gray;height:300px;"}
|
|
|
|
-if @annonce.g_latitude? and @annonce.g_longitude?
|
|
%script
|
|
=raw "var center = new google.maps.LatLng(#{@annonce.g_latitude}, #{@annonce.g_longitude});"
|
|
=raw "var map_center = {lat: #{@annonce.g_latitude}, lng: #{@annonce.g_longitude}}"
|
|
|
|
-else
|
|
%script
|
|
=raw "var center = new google.maps.LatLng(46.2238208, 2.2162428);"
|
|
=raw "var map_center = {lat: -2, lng: 1}"
|
|
|
|
:javascript
|
|
var placeSearch, autocomplete;
|
|
|
|
|
|
var map;
|
|
function initMap() {
|
|
map = new google.maps.Map(document.getElementById('map'), {
|
|
center: map_center,
|
|
zoom: 10,
|
|
scrollwheel: false,
|
|
draggable: false,
|
|
navigationControl: false,
|
|
mapTypeControl: false,
|
|
streetViewControl: false
|
|
});
|
|
}
|
|
initMap();
|
|
|
|
|
|
var marker = new google.maps.Marker({
|
|
position: center,
|
|
map: map
|
|
|
|
});
|
|
|
|
function initAutocomplete(country) {
|
|
autocomplete = new google.maps.places.Autocomplete(
|
|
(document.getElementById('g_autocomplete')),
|
|
{
|
|
types: ['(regions)'],
|
|
componentRestrictions: {}
|
|
}
|
|
);
|
|
autocomplete.addListener('place_changed', fillInAddress);
|
|
$("#country_selectors .btn").removeClass("btn-primary");
|
|
$("#country_selectors ."+country.toLowerCase()).addClass("btn-primary");
|
|
}
|
|
|
|
|
|
function change_country(country) {
|
|
initAutocomplete(country);
|
|
reset_geocode();
|
|
|
|
}
|
|
|
|
function fillInAddress() {
|
|
var place = autocomplete.getPlace();
|
|
var result = {}
|
|
result["type"] = place.types[0]
|
|
|
|
result["lat"] = place.geometry.location.lat()
|
|
result["lng"] = place.geometry.location.lng()
|
|
console.log(place.address_components);
|
|
var components = place.address_components;
|
|
for (var i = 0, component; component = components[i]; i++) {
|
|
result[component.types[0]] = component['long_name'];
|
|
result[component.types[0]+"_short"] = component['short_name'];
|
|
}
|
|
center = new google.maps.LatLng(place.geometry.location.lat(), place.geometry.location.lng());
|
|
// using global variable:
|
|
map.panTo(center);
|
|
marker.setPosition(center );
|
|
|
|
|
|
|
|
|
|
|
|
console.log(result);
|
|
//$("#lat").append(place.geometry.location.lat()+"<br>")
|
|
//$("#g_longitude").val(place.geometry.location.lng())
|
|
$.ajax({url : '/public/annonces/geocode.js', data : {lat : place.geometry.location.lat(), lng : place.geometry.location.lng()}})
|
|
}
|
|
|
|
function reset_geocode(){
|
|
|
|
$("#g_text_visu").html("");
|
|
$("#geocode input").val('');
|
|
}
|
|
|
|
:javascript
|
|
$(document).ready(function() {
|
|
$("#g_autocomplete").keydown(function() {
|
|
if(event.keyCode == 13) {
|
|
event.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$("#g_autocomplete").change(function() {
|
|
reset_geocode();
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
-if @annonce.g_country_code?
|
|
%script
|
|
=raw "initAutocomplete('"+@annonce.g_country_code+"');"
|
|
-else
|
|
:javascript
|
|
initAutocomplete("mq");
|
|
|
|
|
|
|
|
|
|
|
|
%p
|
|
=f.check_box :tel
|
|
=f.label :tel, "Afficher mon numéro de téléphone ?"
|
|
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:tel_number].size > 0)}
|
|
.col-sm-2
|
|
=f.label :tel_number, "Téléphone* :", :class => "control-label"
|
|
|
|
.col-sm-10
|
|
=f.text_field :tel_number, :class => "form-control", :placeholder => "Téléphone", :"aria-describedby"=>"inputWarning2Status"
|
|
.clear
|
|
.clear
|
|
|
|
|
|
#specific_large
|
|
.center
|
|
%div{:class => (@annonce.id ? "col-sm-8" : "")}
|
|
#specific
|
|
=render :partial => "public/annonces/specific_form"
|
|
|
|
|
|
|
|
|
|
.clear
|
|
|
|
-if @annonce.link
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:link_url].size > 0)}
|
|
.col-sm-2
|
|
=f.label :link_url, "Lien (url)* :", :class => "control-label"
|
|
|
|
.col-sm-10
|
|
=f.text_field :link_url, :class => "form-control", :placeholder => "http://exemple.com", :"aria-describedby"=>"inputWarning2Status"
|
|
.clear
|
|
|
|
-if @annonce.video
|
|
.form-group{:class => ("has-error has-feedback" if @annonce.errors[:video_url].size > 0)}
|
|
.col-sm-2
|
|
=f.label :video_url, "ID youtube * :", :class => "control-label"
|
|
|
|
.col-sm-10
|
|
=f.text_field :video_url, :class => "form-control", :placeholder => "ex : p00mU0LsSIg", :"aria-describedby"=>"inputWarning2Status", :onkeydown => "youtube_parser($(this).val());", :onchange => "youtube_parser($(this).val());", :onkeyup => "youtube_parser($(this).val());", :id => "youtube_id"
|
|
%p
|
|
Collez directement l'url de la vidéo youtube (https://www.youtube.com/watch?v=p00mU0LsSIg ou https://youtu.be/p00mU0LsSIg par exemple) et l'ID sera automatiquement détecté.
|
|
.clear
|
|
|
|
:javascript
|
|
function youtube_parser(url){
|
|
var regExp = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
|
|
var match = url.match(regExp);
|
|
if (match&&match[7].length==11){
|
|
|
|
$("#youtube_id").val(match[7]);
|
|
}else{
|
|
//alert("Url incorrecta");
|
|
}
|
|
}
|
|
|
|
-if @create
|
|
.next_step=f.submit "Enregistrer et passer à l'étape suivante", :class => "btn btn-success btn-lg"
|
|
|
|
|
|
|
|
-if @annonce.id and !@create
|
|
#annonce_photos_large
|
|
.center
|
|
.col-sm-8
|
|
%a{:name => "photos"}
|
|
=render :partial => "photo_form"
|
|
.clear
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|