Change jquery-sortable to jquery-ui
This commit is contained in:
parent
ecfbd56d65
commit
6a3a234146
2 changed files with 39 additions and 69 deletions
13
resources/jquery-ui.min.js
vendored
Normal file
13
resources/jquery-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -7,7 +7,7 @@
|
||||||
$(function () {
|
$(function () {
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script type="text/javascript" src="{{ static('libs/jquery-sortable.js') }}"></script>
|
<script type="text/javascript" src="{{ static('jquery-ui.min.js') }}"></script>
|
||||||
<script type="text/javascript" src="{{ static('libs/featherlight/featherlight.min.js') }}"></script>
|
<script type="text/javascript" src="{{ static('libs/featherlight/featherlight.min.js') }}"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
|
@ -75,6 +75,17 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function swap_row($a, $b) {
|
||||||
|
var $a_order = $a.find('input[id$=order]'), $b_order = $b.find('input[id$=order]');
|
||||||
|
var order = $a_order.val();
|
||||||
|
$a_order.val($b_order.val());
|
||||||
|
$b_order.val(order);
|
||||||
|
$b.after($a);
|
||||||
|
$a.find('span.order').text($a_order.val());
|
||||||
|
$b.find('span.order').text($b_order.val());
|
||||||
|
handle_table_reorder();
|
||||||
|
}
|
||||||
|
|
||||||
function checker_precision($checker) {
|
function checker_precision($checker) {
|
||||||
var $td = $checker.parent();
|
var $td = $checker.parent();
|
||||||
var $args = $td.find('input');
|
var $args = $td.find('input');
|
||||||
|
@ -118,18 +129,6 @@
|
||||||
}).change();
|
}).change();
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
function swap_row($a, $b) {
|
|
||||||
var $a_order = $a.find('input[id$=order]'), $b_order = $b.find('input[id$=order]');
|
|
||||||
var order = $a_order.val();
|
|
||||||
$a_order.val($b_order.val());
|
|
||||||
$b_order.val(order);
|
|
||||||
$b.after($a);
|
|
||||||
$a.find('span.order').text($a_order.val());
|
|
||||||
$b.find('span.order').text($b_order.val());
|
|
||||||
handle_table_reorder();
|
|
||||||
}
|
|
||||||
|
|
||||||
checker_precision($('#id_problem-data-checker'));
|
checker_precision($('#id_problem-data-checker'));
|
||||||
|
|
||||||
$table.on('add-row', function (e, $tr) {
|
$table.on('add-row', function (e, $tr) {
|
||||||
|
@ -281,33 +280,29 @@
|
||||||
for (var i = 0; i < outFiles.length; i++) {
|
for (var i = 0; i < outFiles.length; i++) {
|
||||||
$("#id_cases-" + i + "-output_file").val(outFiles[i]).change();
|
$("#id_cases-" + i + "-output_file").val(outFiles[i]).change();
|
||||||
}
|
}
|
||||||
|
|
||||||
// add points
|
// add points
|
||||||
if ($('#problem-type').val() == "ICPC") {
|
if ($('#problem-type').val() == "ICPC") {
|
||||||
for (i = 0; i + 1 < inFiles.length; i++) {
|
$('#case-table tbody tr td').find('input[id$=points]').val('0').change();
|
||||||
$("#id_cases-" + i + "-points").val("0").change();
|
$('#case-table tbody tr td').find('input[id$=points]:visible')
|
||||||
}
|
.last().val('100').change();
|
||||||
$("#id_cases-" + (inFiles.length - 1) + "-points").val("100").change();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (i = 0; i < inFiles.length; i++) {
|
$('#case-table tbody tr td').find('input[id$=points]').val('1').change()
|
||||||
$("#id_cases-" + i + "-points").val("1").change();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
var oldIndex;
|
var oldIndex;
|
||||||
$table.sortable({
|
$('#case-table tbody').sortable({
|
||||||
containerSelector: 'table',
|
|
||||||
itemPath: '> tbody:first',
|
|
||||||
itemSelector: 'tr',
|
itemSelector: 'tr',
|
||||||
handle: 'i.fa-ellipsis-v',
|
handle: 'i.fa-ellipsis-v',
|
||||||
placeholder: '<tr class="placeholder">',
|
start: function (event, ui) {
|
||||||
onDragStart: function ($item, container, _super) {
|
$item = ui.item;
|
||||||
oldIndex = $item.index();
|
oldIndex = $item.index();
|
||||||
_super($item, container);
|
|
||||||
},
|
},
|
||||||
onDrop: function ($item, container, _super) {
|
stop: function (event, ui) {
|
||||||
|
$item = ui.item;
|
||||||
var newIndex = $item.index();
|
var newIndex = $item.index();
|
||||||
if (newIndex > oldIndex) {
|
if (newIndex > oldIndex) {
|
||||||
var order = parseInt($item.parent().children().slice(oldIndex, newIndex).each(function () {
|
var order = parseInt($item.parent().children().slice(oldIndex, newIndex).each(function () {
|
||||||
|
@ -324,7 +319,6 @@
|
||||||
}
|
}
|
||||||
if (newIndex != oldIndex)
|
if (newIndex != oldIndex)
|
||||||
handle_table_reorder();
|
handle_table_reorder();
|
||||||
_super($item, container);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -368,47 +362,10 @@
|
||||||
z-index: 2000;
|
z-index: 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.placeholder {
|
|
||||||
display: block;
|
|
||||||
background: red;
|
|
||||||
position: relative;
|
|
||||||
margin: 0;
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
tr.placeholder:before {
|
|
||||||
content: "";
|
|
||||||
position: absolute;
|
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
border: 5px solid transparent;
|
|
||||||
border-left-color: red;
|
|
||||||
margin-top: -5px;
|
|
||||||
left: -5px;
|
|
||||||
border-right: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
i.fa-ellipsis-v {
|
i.fa-ellipsis-v {
|
||||||
cursor: move;
|
cursor: move;
|
||||||
}
|
}
|
||||||
|
|
||||||
.edit-generator-args {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generator-args-editor textarea {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
margin-bottom: 0.5em;
|
|
||||||
height: 8em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.generator-args-editor #submit-button {
|
|
||||||
display: block;
|
|
||||||
float: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
#case-table tbody td {
|
#case-table tbody td {
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
}
|
}
|
||||||
|
@ -491,7 +448,9 @@
|
||||||
<tbody class="extra-row-body" style="display: none">
|
<tbody class="extra-row-body" style="display: none">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<tr data-type="{{ form['type'].value() }}">
|
<tr data-type="{{ form['type'].value() }}">
|
||||||
<td>{{ form.id }}{{ form.order.errors }}{{ form.order }}</td>
|
<td>
|
||||||
|
{{ form.id }}{{ form.order.errors }}{{ form.order }}
|
||||||
|
</td>
|
||||||
<td class="type-column">{{ form.type.errors }}{{ form.type }}</td>
|
<td class="type-column">{{ form.type.errors }}{{ form.type }}</td>
|
||||||
<td{% if not (form.empty_permitted or form['type'].value() != 'C' or
|
<td{% if not (form.empty_permitted or form['type'].value() != 'C' or
|
||||||
form['input_file'].value() in valid_files) %} class="bad-file"{% endif %}>
|
form['input_file'].value() in valid_files) %} class="bad-file"{% endif %}>
|
||||||
|
@ -504,8 +463,7 @@
|
||||||
<td>{{ form.points.errors }}{{ form.points }}</td>
|
<td>{{ form.points.errors }}{{ form.points }}</td>
|
||||||
<td>{{ form.is_pretest.errors }}{{ form.is_pretest }}</td>
|
<td>{{ form.is_pretest.errors }}{{ form.is_pretest }}</td>
|
||||||
{% if cases_formset.can_delete %}
|
{% if cases_formset.can_delete %}
|
||||||
<td>{{ form.DELETE }}
|
<td>{{ form.DELETE }}</td>
|
||||||
</td>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
@ -514,5 +472,4 @@
|
||||||
<input type="submit" value="{{ _('Apply!') }}" class="button" id="submit-button">
|
<input type="submit" value="{{ _('Apply!') }}" class="button" id="submit-button">
|
||||||
<a id="add-case-row" href="#"><i class="fa fa-plus"></i> {{ _('Add new case') }}</a>
|
<a id="add-case-row" href="#"><i class="fa fa-plus"></i> {{ _('Add new case') }}</a>
|
||||||
</form>
|
</form>
|
||||||
<div style="display: none" class="generator-args-editor"><textarea></textarea><a class="button">Save</a></div>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue