blob: 90e8c0d6f0996ff63cb9b6749ed3b3c638aafe23 [file] [log] [blame]
Scott Main50e990c2012-06-21 17:14:39 -07001page.title=Google Play Badges
2@jd:body
3
Scott Main44204022012-09-13 14:52:03 -07004<p>Google Play badges allow you to promote your app with official branding in your
5online ads, promotional materials, or anywhere else you want a link to your app.</p>
Scott Main50e990c2012-06-21 17:14:39 -07006
Scott Main44204022012-09-13 14:52:03 -07007<p>In the form below,
8input your app's package name or publisher name, choose the badge style,
9click <em>Build my badge</em>, then paste the HTML into your web content.</p>
Scott Main50e990c2012-06-21 17:14:39 -070010
Scott Main44204022012-09-13 14:52:03 -070011<p>If you're creating a promotional web page for your app, you should also use the
12<a href="{@docRoot}distribute/promote/device-art.html">Device Art Generator</a>, which quickly
13wraps your screenshots in real device artwork.</p>
14
15<p>For guidelines when using the Google Play badge and other brand assets,
Scott Maind401d582012-09-17 22:08:57 -070016see the <a href="{@docRoot}distribute/googleplay/promote/brand.html">Brand
Scott Main44204022012-09-13 14:52:03 -070017Guidelines</a>.</p>
Scott Main50e990c2012-06-21 17:14:39 -070018
19<style type="text/css">
20
21form.button-form {
22 margin-top:2em;
23}
24
25/* the label and input elements are blocks that float left in order to
26 keep the left edgets of the input aligned, and IE 6/7 do not fully support "inline-block" */
27label.block {
28 display: block;
29 float: left;
30 width: 100px;
31 padding-right: 10px;
32}
33
34input.text {
35 display: block;
36 float: left;
37 width: 250px;
38}
39
40div.button-row {
41 white-space:nowrap;
42 min-height:80px;
43}
44
45div.button-row input {
Scott Main44204022012-09-13 14:52:03 -070046 vertical-align:middle;
47 margin:0 5px 0 0;
Scott Main50e990c2012-06-21 17:14:39 -070048}
49
50#jd-content div.button-row img {
51 margin: 0;
Scott Main44204022012-09-13 14:52:03 -070052 vertical-align:middle;
Scott Main50e990c2012-06-21 17:14:39 -070053}
54
55</style>
56
57<script type="text/javascript">
58
59// variables for creating 'try it out' demo button
Scott Main44204022012-09-13 14:52:03 -070060var imagePath = "http://developer.android.com/images/brand/"
Scott Main50e990c2012-06-21 17:14:39 -070061var linkStart = "<a href=\"http://play.google.com/store/";
62var imageStart = "\">\n"
63 + " <img alt=\"";
64 // leaves opening for the alt text value
65var imageSrc = "\"\n src=\"" + imagePath;
66 // leaves opening for the image file name
67var imageEnd = ".png\" />\n</a>";
68
69// variables for creating code snippet
70var linkStartCode = "&lt;a href=\"http://play.google.com/store/";
71var imageStartCode = "\"&gt;\n"
72 + " &lt;img alt=\"";
73 // leaves opening for the alt text value
74var imageSrcCode = "\"\n src=\"" + imagePath;
75 // leaves opening for the image file name
76var imageEndCode = ".png\" />\n&lt;/a>";
77
78/** Generate the HTML snippet and demo based on form values */
79function buildButton(form) {
80 var selectedValue = $('form input[type=radio]:checked').val();
81 var altText = selectedValue.indexOf("get_it") != -1 ? "Get it on Google Play" : "Android app on Google Play";
82
83 if (form["package"].value != "com.example.android") {
84 $("#preview").show();
85 $("#snippet").show().html(linkStartCode + "apps/details?id=" + form["package"].value
86 + imageStartCode + altText + imageSrcCode
87 + selectedValue + imageEndCode);
88 $("#button-preview").html(linkStart + "apps/details?id=" + form["package"].value
89 + imageStart + altText + imageSrc
90 + selectedValue + imageEnd);
Scott Mainfe3057f2012-10-03 15:23:06 -070091
92 // Send the event to Analytics
93 _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Package ' + selectedValue]);
Scott Main50e990c2012-06-21 17:14:39 -070094 } else if (form["publisher"].value != "Example, Inc.") {
95 $("#preview").show();
96 $("#snippet").show().html(linkStartCode + "search?q=pub:" + form["publisher"].value
97 + imageStartCode + altText + imageSrcCode
98 + selectedValue + imageEndCode);
99 $("#button-preview").html(linkStart + "search?q=pub:" + form["publisher"].value
100 + imageStart + altText + imageSrc
101 + selectedValue + imageEnd);
Scott Mainfe3057f2012-10-03 15:23:06 -0700102
103 // Send the event to Analytics
104 _gaq.push(['_trackEvent', 'Distribute', 'Create Google Play Badge', 'Publisher ' + selectedValue]);
Scott Main50e990c2012-06-21 17:14:39 -0700105 } else {
106 alert("Please enter your package name or publisher name");
107 }
108 return false;
109}
110
111/** Listen for Enter key */
112function onTextEntered(event, form, me) {
113 // 13 = enter
114 if (event.keyCode == 13) {
115 buildButton(form);
116 }
117}
118
119/** When input is focused, remove example text and disable other input */
120function onInputFocus(object, example) {
121 if (object.value == example) {
122 $(object).val('').css({'color' : '#000'});
123 }
124 $('input[type="text"]:not(input[name='+object.name+'])',
125 object.parentNode).attr('disabled','true');
126 $('#'+object.name+'-clear').show();
127}
128
129/** When input is blured, restore example text if appropriate and enable other input */
130function onInputBlur(object, example) {
131 if (object.value.length < 1) {
132 $(object).attr('value',example).css({'color':'#ccc'});
133 $('input[type="text"]', object.parentNode).removeAttr('disabled');
134 $('#'+object.name+'-clear').hide();
135 }
136}
137
138/** Clear the form to start over */
139function clearLabel(id, example) {
140 $("#preview").hide();
141 $('#'+id+'').html('').attr('value',example).css({'color':'#ccc'});
142 $('input[type="text"]', $('#'+id+'').parent()).removeAttr('disabled');
143 $('#'+id+'-clear').hide();
144 return false;
145}
146
147/** When the doc is ready, find the inputs and color the input grey if the value is the example
148 text. This is necessary to handle back-navigation, which can auto-fill the form with previous
149 values (and text should not be grey) */
150$(document).ready(function() {
151 $(".button-form input.text").each(function(index) {
152 if ($(this).val() == $(this).attr("default")) {
153 $(this).css("color","#ccc");
154 } else {
155 /* This is necessary to handle back-navigation to the page after form was filled */
156 $('input[type="text"]:not(input[name='+this.name+'])',
157 this.parentNode).attr('disabled','true');
158 $('#'+this.name+'-clear').show();
159 }
160 });
161});
162
163</script>
164
165<form class="button-form">
166 <label class="block" for="package">Package name:</label>
167 <input class="text" type="text" id="package" name="package"
168 value="com.example.android"
169 default="com.example.android"
170 onfocus="onInputFocus(this, 'com.example.android')"
171 onblur="onInputBlur(this, 'com.example.android')"
172 onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
173 <a id="package-clear" style="display:none" href="#"
174 onclick="return clearLabel('package','com.example.android');">clear</a>
175 <p style="clear:both;margin:0">&nbsp;<em>or</em></p>
176 <label class="block" style="margin-top:5px" for="publisher">Publisher&nbsp;name:</label>
177 <input class="text" type="text" id="publisher" name="publisher"
178 value="Example, Inc."
179 default="Example, Inc."
180 onfocus="onInputFocus(this, 'Example, Inc.')"
181 onblur="onInputBlur(this, 'Example, Inc.')"
182 onkeyup="return onTextEntered(event, this.parentNode, this)"/>&nbsp;
183 <a id="publisher-clear" style="display:none" href="#"
184 onclick="return clearLabel('publisher','Example, Inc.');">clear</a>
185 <br/><br/>
186
Scott Main50e990c2012-06-21 17:14:39 -0700187
188<div class="button-row">
Scott Main44204022012-09-13 14:52:03 -0700189 <input type="radio" name="buttonStyle" value="en_app_rgb_wo_45" id="ws" checked="checked" />
190 <label for="ws"><img src="{@docRoot}images/brand/en_app_rgb_wo_45.png"
Scott Main50e990c2012-06-21 17:14:39 -0700191alt="Android app on Google Play (small)" /></label>
192 &nbsp;&nbsp;&nbsp;&nbsp;
Scott Main44204022012-09-13 14:52:03 -0700193 <input type="radio" name="buttonStyle" value="en_app_rgb_wo_60" id="wm" />
194 <label for="wm"><img src="{@docRoot}images/brand/en_app_rgb_wo_60.png"
Scott Main50e990c2012-06-21 17:14:39 -0700195alt="Android app on Google Play (large)" /></label>
196</div>
197
Scott Main44204022012-09-13 14:52:03 -0700198<div class="button-row">
199 <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_45" id="ns" />
200 <label for="ns"><img src="{@docRoot}images/brand/en_generic_rgb_wo_45.png"
201alt="Get it on Google Play (small)" /></label>
202 &nbsp;&nbsp;&nbsp;&nbsp;
203 <input type="radio" name="buttonStyle" value="en_generic_rgb_wo_60" id="nm" />
204 <label for="nm"><img src="{@docRoot}images/brand/en_generic_rgb_wo_60.png"
205alt="Get it on Google Play (large)" /></label>
206</div>
207
Scott Mainfe3057f2012-10-03 15:23:06 -0700208 <input onclick="return buildButton(this.parentNode);"
Scott Main48b2cad2012-10-03 17:23:45 -0700209 type="button" value="Build my badge" style="padding:10px" />
Scott Main50e990c2012-06-21 17:14:39 -0700210 <br/>
211</form>
212
213<div id="preview" style="display:none">
214 <p>Copy and paste this HTML into your web site:</p>
215 <textarea id="snippet" cols="100" rows="5" onclick="this.select()"
216style="font-family:monospace;background-color:#efefef;padding:5px;display:none;margin-bottom:1em">
217 </textarea >
218
219<p>Try it out:</p>
220<div id="button-preview" style="margin-top:1em"></div>
221</div>