How is the damage to items and the repair cost calculated?
Diablo 3's durability formula is a pretty broad formula, and there isn't just one.
Your equipment will lose durability when:
You are in combat
You deal damage
You are hit
You die
All three of these scenarios have different durability formulas that aren't actively released to the user. It would take someone that knows the code base to speak on it.
Dying causes you to lose the flat 10% like you said, but they also have a chance to lose durability based on how many times you are hit and not how much you are hit for. Like wise your gear has a chance to lose durability while you deal damage. This is called "stress" durability. If the gear is being used to negate or deal damage through its stats than the game considers the items to be "in use" and will passively lower the durability.
Low level items lose durability from stress much slower than higher level items do as well.
Based on the repair costs we know from World of Warcraft, it is safe to assume that repair costs in Diablo 3 are calculated in a similar manner. By using a flat rate based on the items rarity with additions for how much durability is lost from its total durability and a multiplier for its item level.
Blizzard seems to have copied much of their durability formula's from what they have created for World of Warcraft already. You can review them here:
WoW durability guidelines