Skip to content

Instantly share code, notes, and snippets.

@twinge
Created March 5, 2010 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twinge/322299 to your computer and use it in GitHub Desktop.
Save twinge/322299 to your computer and use it in GitHub Desktop.
var i = 0;
foreach (var dimType in ViewData.Model.SelectedProduct.DimensionTypes)
{
i++;
string ddlName = String.Format("ddlDimension_{0}", dimType.Key);
var dimensions = variations.Select(sv => sv.Dimensions.FirstOrDefault(d => d.TypeKey == dimType.Key));
var valueList = dimensions
.Select(d => new { Key = d.Key, ShortValue = d.ShortValue, IsInStock = variations.Any(sv => sv.Available && sv.Dimensions.Any(sd => sd.Key == d.Key)) })
.Distinct()
.OrderBy(d => DimensionSorter.GetSortOrder(d.Key))
.ToList();
if (valueList.Count > 0)
{
string selectedID = selectedDimensions.ContainsKey(dimType.Key) ? selectedDimensions[dimType.Key].ToString() : "";
string style = "";
if (dimType.Key == "SW" && !Model.SiteFeatureManager.IsFeatureEnabled(CatFootwear.Web.SiteFeature.ShowShoeWidth)) {
style = "display: none";
}
%>
<div class="RequiredDimension dimension <%= string.IsNullOrEmpty(style) ? "" : "heightadjustment" %> "
********** I WANT TO INSERT CLASS HERE ************
<&= i == 2 ? 'newclass' : '' %>
>
<span class="pdp-title DimName" id="<%= ddlName + "_ShortName" %>" style="<%= style %>"><%= Html.Encode(dimType.ShortName)%>:</span>
<input type="text" class="dimTextDisplay" id="<%= ddlName + "_Display" %>" readonly="readonly" value="" style="<%= style %>" />
<input type="hidden" class="dimType" value="<%= dimType.ShortName%>" />
<script type="text/javascript">
$('.dimType:last').after('<input type="hidden" class="dimID" name="<%= ddlName %>" id="<%= ddlName %>" />');
</script>
<ul style="<%= style %>">
<%
foreach (var item in valueList){%>
<li> <label title="<%=item.ShortValue%>" value="<%=item.Key %>" class="pdp-options <%=item.IsInStock?"valid":"outOfStock" %>" id="dimension_<%=item.Key%>">
<input name="<%= ddlName %>" type="radio" value="<%= item.Key %>" />
<%= item.ShortValue %>
</label></li>
<% } %>
<%
var firstVal = valueList != null && valueList.Count() > 0 ? valueList.First() : null;
if (potentiallyShowEuroSizingGrid) {
int LowestAcceptableEuroSize = 30;
// now check to see if the lowest value is 30 for euro dimensions. yes, using db sorting by string here to avoid casting all to int
int lowestDim;
if (firstVal != null && ((int.TryParse(firstVal.ShortValue, out lowestDim) && lowestDim > LowestAcceptableEuroSize) || "IY".Contains(Model.SelectedProduct.GenericSizeType.Key))) {
%>
<li><a href="<%= ResolveUrl(string.Format("~/Content/images/euro_sizes_{0}.gif", Model.SelectedProduct.GenericSizeType.Key)) %>" class="alt thickbox"><%= Html.ResolveTokenExpression("ProductDetail.Dimensions.SizeChart") %></a></li>
<% } } %>
</ul>
</div>
<% }
}%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment