fixed mobile purchase flow (bug 718893)

This commit is contained in:
Davor Spasovski 2012-01-18 13:59:12 -08:00
Родитель 1c00337ea1
Коммит db390663d2
6 изменённых файлов: 29 добавлений и 20 удалений

Просмотреть файл

@ -18,6 +18,7 @@
{% else %} {% else %}
href="{{ link.url }}" href="{{ link.url }}"
{% endif %}> {% endif %}>
{{ csrf() }}
{% if request.MOBILE %} {% if request.MOBILE %}
{% if addon.is_webapp() %} {% if addon.is_webapp() %}
{% if (addon.is_premium() and addon.has_purchased(amo_user)) or (not addon.is_premium()) %} {% if (addon.is_premium() and addon.has_purchased(amo_user)) or (not addon.is_premium()) %}

Просмотреть файл

@ -6,6 +6,7 @@
{# TODO(apps): Finalize copy. #} {# TODO(apps): Finalize copy. #}
{% block primary %} {% block primary %}
{% block content %}
<section class="primary"> <section class="primary">
<header> <header>
<h1>Oops! Not allowed.</h1> <h1>Oops! Not allowed.</h1>
@ -21,3 +22,4 @@
</div> </div>
</section> </section>
{% endblock %} {% endblock %}
{% endblock %}

Просмотреть файл

@ -1,26 +1,6 @@
// Things global to the site should go here, such as re-usable helper // Things global to the site should go here, such as re-usable helper
// functions and common ui components. // functions and common ui components.
// CSRF Tokens
// Hijack the AJAX requests, and insert a CSRF token as a header.
$('html').ajaxSend(function(event, xhr, ajaxSettings) {
var csrf, $meta;
// Block anything that starts with "http:", "https:", "://" or "//"
if (!/^((https?:)|:?[/]{2})/.test(ajaxSettings.url)) {
// Only send the token to relative URLs i.e. locally.
$meta = $('meta[name=csrf]');
if (!z.anonymous && $meta.exists()) {
csrf = $meta.attr('content');
} else {
csrf = $("#csrfmiddlewaretoken").val();
}
if (csrf) xhr.setRequestHeader("X-CSRFToken", csrf);
}
}).ajaxSuccess(function(event, xhr, ajaxSettings) {
$(window).trigger('resize'); // Redraw what needs to be redrawn.
});
// Tooltip display. If you give an element a class of 'tooltip', it will // Tooltip display. If you give an element a class of 'tooltip', it will
// display a tooltip on hover. The contents of the tip will be the element's // display a tooltip on hover. The contents of the tip will be the element's
// title attribute OR the first title attribute in its children. Titles are // title attribute OR the first title attribute in its children. Titles are

Просмотреть файл

@ -0,0 +1,21 @@
// CSRF Tokens
// Hijack the AJAX requests, and insert a CSRF token as a header.
$('html').ajaxSend(function(event, xhr, ajaxSettings) {
var csrf, $meta;
// Block anything that starts with 'http:', 'https:', '://' or '//'.
if (!/^((https?:)|:?[/]{2})/.test(ajaxSettings.url)) {
// Only send the token to relative URLs i.e. locally.
$meta = $('meta[name=csrf]');
if (!z.anonymous && $meta.length) {
csrf = $meta.attr('content');
} else {
csrf = $("input[name='csrfmiddlewaretoken']").val();
}
if (csrf) {
xhr.setRequestHeader('X-CSRFToken', csrf);
}
}
}).ajaxSuccess(function(event, xhr, ajaxSettings) {
$(window).trigger('resize'); // Redraw what needs to be redrawn.
});

Просмотреть файл

@ -47,11 +47,13 @@
z.startPurchase = function(manifest_url, opt) { z.startPurchase = function(manifest_url, opt) {
$.ajax({ $.ajax({
url: opt.url, url: opt.url,
type: 'post',
dataType: 'json', dataType: 'json',
/* false so that the action is considered within bounds of /* false so that the action is considered within bounds of
* user interaction and does not trigger the Firefox popup blocker. * user interaction and does not trigger the Firefox popup blocker.
*/ */
async: false, async: false,
data: {'result_type': 'json'},
success: function(json) { success: function(json) {
$('.modal').trigger('close'); // Hide all modals $('.modal').trigger('close'); // Hide all modals
if (json.paykey) { if (json.paykey) {

Просмотреть файл

@ -572,6 +572,7 @@ MINIFY_BUNDLES = {
'js/lib/jquery-ui/jquery.ui.datepicker.js', 'js/lib/jquery-ui/jquery.ui.datepicker.js',
'js/lib/jquery-ui/jquery.ui.sortable.js', 'js/lib/jquery-ui/jquery.ui.sortable.js',
'js/zamboni/helpers.js',
'js/zamboni/global.js', 'js/zamboni/global.js',
'js/amo2009/global.js', 'js/amo2009/global.js',
'js/impala/ratingwidget.js', 'js/impala/ratingwidget.js',
@ -654,6 +655,7 @@ MINIFY_BUNDLES = {
'js/zamboni/truncation.js', 'js/zamboni/truncation.js',
'js/impala/ajaxcache.js', 'js/impala/ajaxcache.js',
'js/zamboni/helpers.js',
'js/zamboni/global.js', 'js/zamboni/global.js',
'js/impala/global.js', 'js/impala/global.js',
'js/impala/ratingwidget.js', 'js/impala/ratingwidget.js',
@ -792,6 +794,7 @@ MINIFY_BUNDLES = {
'js/impala/footer.js', 'js/impala/footer.js',
'js/zamboni/personas_core.js', 'js/zamboni/personas_core.js',
'js/zamboni/mobile/personas.js', 'js/zamboni/mobile/personas.js',
'js/zamboni/helpers.js',
'js/zamboni/mobile/general.js', 'js/zamboni/mobile/general.js',
'js/impala/ratingwidget.js', 'js/impala/ratingwidget.js',
'js/zamboni/browserid_support.js', 'js/zamboni/browserid_support.js',