What time of year do you plan to make the trip?
I'd start by figuring what I wanted to see in Morocco and checking transportation links. You may find you need more than 7 days there (I would), which would mean cutting some of your Spain/Portugal destinations since you're probably more likely to return to Spain or Portugal than to Morocco, right? Among the cities in Morocco you could check out are Fes, Marrakech, Rabat and Meknes--and you haven't gotten into the desert yet. You may need to fly into as well as out of Casablanca, which would not otherwise be a place I'd go, so there's some time being wasted there.
Another concern is getting from Portugal to Spain, or vice versa. It's not as easy as one would expect. This is likely to cost you substantial time unless the night train between Madrid and Lisbon works for you (and that might be a semi-sleepless night). You may need to alter the order in which you visit the cities because of transportation limitations between the two countries.
I haven't been to Valencia, but all your other proposed destinations are good ones. However, even if you keep Morocco at just 7 days, I believe you'd do better to cut a stop or two to allow more time in a few places. Barcelona for 3 nights at the beginning of your trip is seriously inadequate; won't you be dead on your feet as you get off the plane?
Madrid for 3 nights might be OK if you're not interested in any of the Big 3 art museums, but some extra time would allow for a day-trip or two. Madrid has three fabulous day trips: Toledo, Segovia and Cuenca (the latter works only by AVE train, which would need to be ticketed way in advance to be affordable).
Truthfully, I'd drop Portugal from this trip and expand the time in Morocco and Spain. There's more to Portugal than Lisbon and Porto, but you don't have time for anything else this time around.
If you must keep Portugal, you might consider trimming Valencia (unless you're all gung-ho about the museums there) and Salamanca, which I think don't need as much time as the other cities. I hate for you to be so close and miss Cordoba. Some folks see it on a day-trip from Seville or an on-the-way-to-Seville long stop, but I believe in that case you'd want 4 nights in Seville rather than 3.