Home | History | Annotate | Download | only in promote
      1 page.title=Google Play 
      2 page.image=/images/gp-badges-set.png
      3 page.metaDescription=
      4 
      5 @jd:body
      6 
      7   <p itemprop="description"> Google Play  Google </p>
      8 
      9   <p> HTML <em></em></p>
     10 
     11   <p> <a href="{@docRoot}distribute/tools/promote/device-art.html">Device Art Generator</a></p>
     12 
     13   <p> Google Play <a href="{@docRoot}distribute/tools/promote/brand.html#brand-google_play"></a></p>
     14 
     15   <style type="text/css">form.button-form {
     16   margin-top: 2em;
     17 }
     18 /* the label and input elements are blocks that float left in order to   keep the left edgets of the input aligned, and IE 6/7 do not fully support     22inline-block    22 */
     19 label.block {
     20   display: block;
     21   float: left;
     22   width: 100px;
     23   padding-right: 10px;
     24 }
     25 input.text {
     26   display: block;
     27   float: left;
     28   width: 250px;
     29 }
     30 div.button-row {
     31   white-space: nowrap;
     32   min-height: 80px;
     33 }
     34 div.button-row input {
     35   vertical-align: middle;
     36   margin: 0 5px 0 0;
     37 }
     38 #jd-content div.button-row img {
     39   margin: 0;
     40   vertical-align: middle;
     41 }
     42 </style>
     43 
     44   <script type="text/javascript">
     45 
     46   // locales for which we have the 'app' badge
     47   var APP_LANGS = ['it','pt-br','pt-pt','nl','ko','ja','fr','es','es-419','en','de'];
     48 
     49   // variables for creating 'try it out' demo button
     50   var imagePath = "/images/brand/"
     51   var linkStart = "<a href=\"https://play.google.com/store/";
     52   var imageStart = "\">\n"
     53           + "  <img alt=\"";
     54     // leaves opening for the alt text value
     55   var imageSrc = "\"\n       src=\"" + imagePath;
     56     // leaves opening for the image file name
     57   var imageEnd = ".png\" />\n</a>";
     58 
     59   // variables for creating code snippet
     60   var linkStartCode = "&lt;a href=\"https://play.google.com/store/";
     61   var imageStartCode = "\"&gt;\n"
     62           + "  &lt;img alt=\"";
     63     // leaves opening for the alt text value
     64   var imageSrcCode = "\"\n       src=\"" + imagePath;
     65     // leaves opening for the image file name
     66   var imageEndCode = ".png\" />\n&lt;/a>";
     67 
     68   /** Generate the HTML snippet and demo based on form values */
     69   function buildButton(form) {
     70     var lang = $('#locale option:selected').val();
     71     var selectedValue = lang + $('form input[type=radio]:checked').val();
     72     var altText = selectedValue.indexOf("generic") != -1 ? "Get it on Google Play" : "Android app on Google Play";
     73 
     74     if (form["package"].value != "com.example.android") {
     75       $("#preview").show();
     76       var packageName = escapeHTML(form["package"].value);
     77       $("#snippet").show().html(linkStartCode + "apps/details?id=" + packageName
     78               + imageStartCode + altText + imageSrcCode
     79               + selectedValue + imageEndCode);
     80       $("#button-preview").html(linkStart + "apps/details?id=" + packageName
     81               + imageStart + altText + imageSrc
     82               + selectedValue + imageEnd);
     83 
     84       // Send the event to Analytics
     85       ga('send', 'event', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue);
     86     } else if (form["publisher"].value != "Example, Inc.") {
     87       $("#preview").show();
     88       var publisherName = escapeHTML(form["publisher"].value);
     89       $("#snippet").show().html(linkStartCode + "search?q=pub:" + publisherName
     90               + imageStartCode + altText + imageSrcCode
     91               + selectedValue + imageEndCode);
     92       $("#button-preview").html(linkStart + "search?q=pub:" + publisherName
     93               + imageStart + altText + imageSrc
     94               + selectedValue + imageEnd);
     95 
     96       // Send the event to Analytics
     97       ga('send', 'event', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue);
     98     } else {
     99       alert("Please enter your package name or publisher name");
    100     }
    101     return false;
    102   }
    103 
    104   /** Listen for Enter key */
    105   function onTextEntered(event, form, me) {
    106     // 13 = enter
    107     if (event.keyCode == 13) {
    108       buildButton(form);
    109     }
    110   }
    111 
    112   /** When input is focused, remove example text and disable other input */
    113   function onInputFocus(object, example) {
    114     if (object.value == example) {
    115       $(object).val('').css({'color' : '#000'});
    116     }
    117     $('input[type="text"]:not(input[name='+object.name+'])',
    118             object.parentNode).attr('disabled','true');
    119     $('#'+object.name+'-clear').show();
    120   }
    121 
    122   /** When input is blured, restore example text if appropriate and enable other input */
    123   function onInputBlur(object, example) {
    124     if (object.value.length < 1) {
    125       $(object).attr('value',example).css({'color':'#ccc'});
    126       $('input[type="text"]', object.parentNode).removeAttr('disabled');
    127       $('#'+object.name+'-clear').hide();
    128     }
    129   }
    130 
    131   /** Clear the form to start over */
    132   function clearLabel(id, example) {
    133     $("#preview").hide();
    134     $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'});
    135     $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled');
    136     $('#'+id+'-clear').hide();
    137     return false;
    138   }
    139 
    140   /** Switch the badge urls for selected language */
    141   function changeBadgeLang() {
    142     var lang = $('#locale option:selected').val();
    143 
    144     // check if we have the 'app' badge for this lang and show notice if not
    145     $("div.button-row.error").remove();  // remove any existing instance of error message
    146     if ($.inArray(lang,APP_LANGS) == -1) {
    147       $("div.button-row.app").hide();
    148       $("div.button-row.app").after('<div class="button-row error"><p class="note" style="margin:1em 0 -1em">'
    149           + 'Sorry, we currently don\'t have the '
    150           + '<em>Android app on Google Play</em> badge translated for '
    151           + $("select#locale option[value="+lang+"]").attr("title")
    152           + '.<br>Please check back later or instead use the <em>Get it on Google Play</em> badge below.'
    153           + '</p></div>');
    154     } else {
    155       $("div.button-row.app").show(); // show the 'app' badge row
    156     }
    157 
    158     $('.button-row img').each(function() {
    159       var id = $(this).parent().attr('for');
    160       var imgName = lang + $('input#'+id).attr('value') + '.png';
    161       var lastSlash = $(this).attr('src').lastIndexOf('/');
    162       var imgPath = $(this).attr('src').substring(0, lastSlash+1);
    163       $(this).attr('src', imgPath + imgName);
    164     });
    165   }
    166 
    167   /** When the doc is ready, find the inputs and color the input grey if the value is the example
    168       text. This is necessary to handle back-navigation, which can auto-fill the form with previous
    169       values (and text should not be grey) */
    170   $(document).ready(function() {
    171     $(".button-form input.text").each(function(index) {
    172       if ($(this).val() == $(this).attr("default")) {
    173         $(this).css("color","#ccc");
    174       } else {
    175         /* This is necessary to handle back-navigation to the page after form was filled */
    176         $('input[type="text"]:not(input[name='+this.name+'])',
    177                 this.parentNode).attr('disabled','true');
    178         $('#'+this.name+'-clear').show();
    179       }
    180     });
    181   });
    182 
    183   </script>
    184 
    185   <form class="button-form">
    186     <label class="block" for="locale"></label>
    187     <select id="locale" style="display:block;float:left;margin:0" onchange="changeBadgeLang()">
    188       <option title="" value="af">Afrikaans</option>
    189       <option title="" value="ar"></option>
    190       <option title="" value="be"></option>
    191       <option title="" value="bg"></option>
    192       <option title="" value="ca">Catal</option>
    193       <option title="" value="zh-cn"></option>
    194       <option title="" value="zh-hk"></option>
    195       <option title="" value="zh-tw"></option>
    196       <option title="" value="hr">Hrvatski</option>
    197       <option title="" value="cs">esky</option>
    198       <option title="" value="da">Dansk</option>
    199       <option title="" value="nl">Nederlands</option>
    200       <option title="" value="et">Eesti</option>
    201       <option title="" value="fa"></option>
    202       <option title="" value="fil">Tagalog</option>
    203       <option title="" value="fi">Suomi</option>
    204       <option title="" value="fr">Franais</option>
    205       <option title="" value="de">Deutsch</option>
    206       <option title="" value="el"></option>
    207       <option title="" value="en" selected="">English</option>
    208   <!--
    209       <option title="" value="iw-he"></option>
    210   -->
    211       <option title="" value="hu">Magyar</option>
    212       <option title="" value="id-in">Bahasa Indonesia</option>
    213       <option title="" value="it">Italiano</option>
    214       <option title="" value="ja"></option>
    215       <option title="" value="ko"></option>
    216       <option title="" value="lv">Latvieu</option>
    217       <option title="" value="lt">Lietuvikai</option>
    218       <option title="" value="ms">Bahasa Melayu</option>
    219       <option title="" value="no">Norsk (bokml)</option>
    220       <option title="" value="pl">Polski</option>
    221       <option title="" value="pt-br">Portugus (Brasil)</option>
    222       <option title="" value="pt-pt">Portugus (Portugal)</option>
    223       <option title="" value="ro">Romn</option>
    224       <option title="" value="ru"></option>
    225       <option title="" value="sr"> / srpski</option>
    226       <option title="" value="sk">Slovenina</option>
    227       <option title="" value="sl">Slovenina</option>
    228       <option title="" value="es">Espaol (Espaa)</option>
    229       <option title="" value="es-419">Espaol (Latinoamrica)</option>
    230       <option title="" value="sv">Svenska</option>
    231       <option title="" value="sw">Kiswahili</option>
    232       <option title="" value="th"></option>
    233       <option title="" value="tr">Trke</option>
    234       <option title="" value="uk"></option>
    235       <option title="" value="vi">Ting Vit</option>
    236       <option title="" value="zu">isiZulu</option>
    237     </select>
    238     <p style="clear:both;margin:0"></p>
    239     <label class="block" for="package" style="clear:left">  
    240 </label>
    241     <input class="text" type="text" id="package" name="package" value="com.example.android" default="com.example.android" onfocus="onInputFocus(this, &#39;com.example.android&#39;)" onblur="onInputBlur(this, &#39;com.example.android&#39;)" onkeyup="return onTextEntered(event, this.parentNode, this)" />
    242            <a id="package-clear" href="#" onclick="return clearLabel(&#39;package&#39;,&#39;com.example.android&#39;);"></a>
    243     <p style="clear:both;margin:0"><em></em></p>
    244     <label class="block" style="margin-top:5px" for="publisher">  
    245 </label>
    246     <input class="text" type="text" id="publisher" name="publisher" value="Example, Inc." default="Example, Inc." onfocus="onInputFocus(this, &#39;Example, Inc.&#39;)" onblur="onInputBlur(this, &#39;Example, Inc.&#39;)" onkeyup="return onTextEntered(event, this.parentNode, this)" />
    247            <a id="publisher-clear" href="#" onclick="return clearLabel(&#39;publisher&#39;,&#39;Example, Inc.&#39;);"></a>
    248            <br /><br />
    249 
    250 
    251   <div class="button-row app">
    252     <input type="radio" name="buttonStyle" value="_app_rgb_wo_45" id="ws" />
    253       <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png" alt=" Android  Google Play" /></label>
    254       
    255     <input type="radio" name="buttonStyle" value="_app_rgb_wo_60" id="wm" />
    256       <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png" alt=" Android  Google Play" /></label>
    257   </div>
    258 
    259   <div class="button-row">
    260     <input type="radio" name="buttonStyle" value="_generic_rgb_wo_45" id="ns" checked="" />
    261       <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png" alt=" Google Play" /></label>
    262       
    263     <input type="radio" name="buttonStyle" value="_generic_rgb_wo_60" id="nm" />
    264       <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png" alt=" Google Play" /></label>
    265   </div>
    266 
    267     <input class="button" type="button" value="" style="padding:10px" onclick="return buildButton(this.parentNode);" />
    268     <br />
    269   </form>
    270 
    271   <div id="preview">
    272     <p> HTML </p>
    273     <textarea id="snippet" cols="100" rows="5" style="font-family:monospace;background-color:#efefef;padding:5px;margin-bottom:1em" onclick="this.select()"></textarea>
    274 
    275   <p></p>
    276   <div id="button-preview" style="margin-top:1em"></div>
    277   </div>
    278 
    279