Skip to content
This repository has been archived by the owner on Apr 2, 2019. It is now read-only.

Use 'D' symbol in format to specify minimal length of fractional part #84

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iogorodov
Copy link

This request address issues #45 and #63 (as far as I understand this issues duplicate each other). Now it's possible to specify minimal length of fractional part using 'D' symbol. At the same time 'd' symbol used to specify maximal length as it works in current version.

Here some examples how format works. Assume that value is 1.23:

  • ( ddd).d became 1.2
  • ( ddd).D became 1.2
  • ( ddd).ddd became 1.23
  • ( ddd).DDD became 1.230
  • ( ddd).Ddd became 1.23
  • ( ddd).DDd became 1.23
  • ( ddd).dD will raise exception

Look for live sample in trailing-zero.html file in test folder

@zefrench
Copy link

Thank you very much for solution !!
It looks great !!
But do you have a solution to put "€" just after the number ?
Thank you again.
Best Regards.

@iogorodov
Copy link
Author

I use :before and :after css selector to out currency's symbol. I.e.

<span class="eur odometer" id="eur_value"></span>
.eur:before {content: "\20AC\00A0";}

And then set value to span via textContent

@zefrench
Copy link

Thanks again !
But where do I have to call on this class Euro cos I'm using this script ?
I create the class and call it with : class="eur" but the class is not called
Here is the file

<script> jQuery(document).ready(function(){ var cat="all"; var url="getoffers.php?cat="+cat; $.getJSON(url, function(obj) { $.each(obj, function(key, value) { $('
', { id: value.id_offer, text: value.slogan_offre_intro, style : "display:table", class : "block_offer" }).appendTo('#list_offers') $('
', { id: "description"+value.id_offer, html: value.offer_title, style : "", class: "description" }).appendTo('#'+value.id_offer) $('
', { id: "photo"+value.id_offer, // text: value.photo_offre_intro, style : "background-image: url('images_offers/"+value.photo_offre_intro+"')", class: "picture" }).appendTo('#'+value.id_offer) // $("#photo"+value.id_offer).prepend($('',{src:'../'+value.photo_offre_intro})) // var image=""; // $("#photo"+value.id_offer).html(image); $('
', { id: "prix"+value.id_offer, class:"pricebanner" }).appendTo('#photo'+value.id_offer) var el = document.querySelector('#prix'+value.id_offer); od = new Odometer({ el: el, value: value.shop_price, format: '(d).DDD', class: "eur" //----- I tried with this line but it does not works }); $(window).scroll(function(){ $('#prix'+value.id_offer) .filter(":onScreen") .html(value.shop_price) }); setInterval(function(){ var id_offer=value.id_offer; var newprice; $.get('prix_couv.php?id_offer='+id_offer, function(data){ newprice= data; if (newprice=="Trop Tard !") { $('#prix'+value.id_offer).removeClass(); $('#prix'+value.id_offer).empty(); $('
', { id: "prixnull"+value.id_offer, }).appendTo('#'+value.id_offer) $('#prixnull'+value.id_offer).text("Trop Tard !"); } else { $('#prix'+value.id_offer).html(newprice); } }) }, 1000) }); }); }); </script>�

@zefrench
Copy link

Finally, the class is now loaded but the price is placed under the Euro sign. I don't understand cos there is no breakline...
The result is like that :

180,250

@iogorodov
Copy link
Author

I've add follow lines to the bottom of my odometer's theme file:

.odometer-inside {
  display: inherit;
}

I'm not sure about correctness of this solution and you cat try replay display: block in odometer's theme

@zefrench
Copy link

Ok. Thank you !
Perfect ;-)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants