mozilla
Your Search Results

    Template:cssbox

    <%
    // $0 is the property name
    
    var p = "/" + env.locale + "/docs/";
    
    if (env.locale == "zh-CN") {
        p = "/en-US/docs/";
    }
    
    var syntaxPageURL        = p + "Web/CSS/CSS_values_syntax";
    var animatedPageURL      = p + "Web/CSS/CSS_animated_properties";
    var serializationPageURL = p + "Web/CSS/CSS_values_serialization";
    var percentagesPageURL   = p + "Web/CSS/CSS_percentage_values";
    var specialPageURL       = "/en-US/docs/Web/CSS/CSS_special_properties"; // Need to look at the English page, here!
    
    var syntaxPage        = wiki.page(syntaxPageURL);
    var animatedPage      = wiki.page(animatedPageURL);
    var serializationPage = wiki.page(serializationPageURL);
    var percentagesPage   = wiki.page(percentagesPageURL);
    var specialPage       = wiki.page(specialPageURL);
    
    var str_Media = mdn.localString({
        "ja" : "メディア",
        "fr" : "Média",
        "de" : "Medium",
        "en-US" : "Media",
        "zh-CN" : "适用媒体" 
    });
    
    var str_Applies_to = mdn.localString({
       "ja" : "適用対象",
       "fr" : "S'applique à",
       "de" : "Anwendbar auf",
       "en-US" : "Applies to",
       "zh-CN" : "适用元素"
    });
    
    var str_Also_Applies_to = mdn.localString({
       "fr" : "S'applique aussi à",
       "de" : "Auch anwendbar auf",
       "en-US" : "It also applies to",
    });
    
    var str_Percentages = mdn.localString({
        "ja" : "相対値の基準",
        "fr" : "Pourcentages",
        "de" : "Prozentwerte",
        "en-US" : "Percentages"
    });
    
    
    function getValue(page, prefix, postfix) {
        var re = new RegExp("<\\s*span\\s+id\\s*=\\s*"+'"' + prefix + '-' + postfix +'"'+"[^>]*>(.*)<\\s*/\\s*span\\s*\\>","igm");
        var value = re.exec(page);
        
        if (value) {
            value = value[1];
        } else {
            value = "*Value '" + prefix + "-" + postfix + "' not found in DB*";
        }
    
        return value;
    }
    
    var initialValue      = getValue(syntaxPage,        "initial",    $0);
    var appliesValue      = getValue(serializationPage, "appliesto",  $0);
    var inheritedValue    = getValue(syntaxPage,        "inherited",  $0);
    var mediaValue        = getValue(syntaxPage,        "media",      $0);
    var computedValue     = getValue(serializationPage, "computed",   $0);
    var canonicalValue    = getValue(serializationPage, "order",      $0);
    var animatableValue   = getValue(animatedPage,      "animatable",   $0);
    var percentageValue   = getValue(percentagesPage,   "percentage",   $0);
    var firstLetterValue  = getValue(specialPage,       "first-letter", $0);
    var firstLineValue    = getValue(specialPage,       "first-line",   $0);
    
    var additionalApplies = "";
    if (firstLetterValue === 'yes') {
        additionalApplies = template("cssxref", ["::first-letter"]);
    }
    if (firstLineValue === 'yes') {
        additionalApplies += (additionalApplies?" and ":"") + template("cssxref", ["::first-line"]);
    }
    
    if (additionalApplies) {
        additionalApplies = ". " + str_Also_Applies_to + " " + additionalApplies + ".";
    }
    
    var result  = '';
    
    result += '  <li><dfn>' + template("Xref_cssinitial") + '</dfn> ' + initialValue + '</li>';
    result += '  <li><dfn>' + str_Applies_to + '</dfn> ' + appliesValue + additionalApplies + '</li>';
    result += '  <li><dfn>' + template("Xref_cssinherited") +'</dfn> ' + inheritedValue + '</li>';
    
    
    // If percentages contains N/A, it means there are no percentage for that value -> don't display it.
    rePer = new RegExp("N/A","igm");
    
    if (!rePer.exec(percentageValue)) {
        result += '  <li><dfn>' + str_Percentages + '</dfn> ' + percentageValue + '</li>';
    }
    
    result += '  <li><dfn>' + str_Media + '</dfn> ' + mediaValue + '</li>';
    result += '  <li><dfn>' + template("Xref_csscomputed") +'</dfn> ' + computedValue + '</li>';
    result += '  <li><dfn>' + template("Xref_cssanimatable") +'</dfn> ' + animatableValue + '</li>';
    result += '  <li><dfn>' + template("Xref_csscanonicalorder") + '</dfn> ' + canonicalValue + '</li>';
    
    %><ul class="cssprop">
    <%- result %>
    </ul>
    Search for pages that use Template:cssbox to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Contributors to this page: ziyunfei, tregagnon, SJW, ethertank, teoli
    Last updated by: ziyunfei,