0001-javascript-to-open-rel-popup-links-in-popups-5111.patch
gadjo/static/js/gadjo.js | ||
---|---|---|
1 |
function displayPopup(event) |
|
2 |
{ |
|
3 |
var url = $(this).attr('href'); |
|
4 |
$.ajax({ |
|
5 |
url: url, |
|
6 |
success: function(html) { |
|
7 |
var form = $(html).find('#content form'); |
|
8 |
var title = $(html).find('#appbar h2').text(); |
|
9 |
var dialog = $(form).dialog({modal: true, title: title, width: 'auto'}); |
|
10 |
var buttons = Array(); |
|
11 |
if (! form.prop('action')) { |
|
12 |
form.prop('action', url); |
|
13 |
} |
|
14 |
$(dialog).find('.buttons').hide(); |
|
15 |
$(html).find('.buttons button, .buttons a').each(function(idx, elem) { |
|
16 |
var button = Object(); |
|
17 |
button.text = $(elem).text(); |
|
18 |
if ($(elem).hasClass('cancel')) { |
|
19 |
button.click = function() { $(this).dialog('destroy'); return false; }; |
|
20 |
} else { |
|
21 |
button.click = function() { (form).find('button').click(); return false; }; |
|
22 |
} |
|
23 |
if ($(elem).hasClass('submit-button')) { |
|
24 |
button.class = 'submit-button'; |
|
25 |
} else if ($(elem).hasClass('delete-button')) { |
|
26 |
button.class = 'delete-button'; |
|
27 |
} |
|
28 |
buttons.push(button); |
|
29 |
}); |
|
30 |
buttons.reverse(); |
|
31 |
$(dialog).dialog('option', 'buttons', buttons); |
|
32 |
if ($(dialog).find('input:visible').length) { |
|
33 |
$(dialog).find('input:visible')[0].focus(); |
|
34 |
} |
|
35 |
return false; |
|
36 |
} |
|
37 |
}); |
|
38 |
return false; |
|
39 |
} |
|
40 | ||
41 |
$(function() { |
|
42 |
$('a[rel=popup]').click(displayPopup); |
|
43 |
}); |
gadjo/templates/gadjo/base.html | ||
---|---|---|
12 | 12 |
{% endblock %} |
13 | 13 |
<script src="{{ STATIC_URL }}js/jquery-1.11.0.min.js"></script> |
14 | 14 |
<script src="{{ STATIC_URL }}js/jquery-ui-1.10.4.custom.min.js"></script> |
15 |
<script src="{{ STATIC_URL }}js/gadjo.js"></script> |
|
15 | 16 |
{% block extrascripts %} |
16 | 17 |
{% endblock %} |
17 | 18 |
</head> |
18 |
- |