Kaydet (Commit) b730973f authored tarafından Tim Graham's avatar Tim Graham

Refs #28956 -- Removed usage of jQuery's deprecated .selector property in admin JavaScript.

üst 8dbaeb61
......@@ -145,10 +145,10 @@
// Tabular inlines ---------------------------------------------------------
$.fn.tabularFormset = function(options) {
$.fn.tabularFormset = function(selector, options) {
var $rows = $(this);
var alternatingRows = function(row) {
$($rows.selector).not(".add-row").removeClass("row1 row2")
$(selector).not(".add-row").removeClass("row1 row2")
.filter(":even").addClass("row1").end()
.filter(":odd").addClass("row2");
};
......@@ -212,10 +212,10 @@
};
// Stacked inlines ---------------------------------------------------------
$.fn.stackedFormset = function(options) {
$.fn.stackedFormset = function(selector, options) {
var $rows = $(this);
var updateInlineLabel = function(row) {
$($rows.selector).find(".inline_label").each(function(i) {
$(selector).find(".inline_label").each(function(i) {
var count = i + 1;
$(this).html($(this).html().replace(/(#\d+)/g, "#" + count));
});
......@@ -281,13 +281,16 @@
$(document).ready(function() {
$(".js-inline-admin-formset").each(function() {
var data = $(this).data(),
inlineOptions = data.inlineFormset;
inlineOptions = data.inlineFormset,
selector;
switch(data.inlineType) {
case "stacked":
$(inlineOptions.name + "-group .inline-related").stackedFormset(inlineOptions.options);
selector = inlineOptions.name + "-group .inline-related";
$(selector).stackedFormset(selector, inlineOptions.options);
break;
case "tabular":
$(inlineOptions.name + "-group .tabular.inline-related tbody:first > tr").tabularFormset(inlineOptions.options);
selector = inlineOptions.name + "-group .tabular.inline-related tbody:first > tr";
$(selector).tabularFormset(selector, inlineOptions.options);
break;
}
});
......
......@@ -11,7 +11,7 @@ QUnit.module('admin.inlines: tabular formsets', {
$('#qunit-fixture').append($('#tabular-formset').text());
this.table = $('table.inline');
this.inlineRow = this.table.find('tr');
that.inlineRow.tabularFormset({
that.inlineRow.tabularFormset('table.inline tr', {
prefix: 'first',
addText: that.addText,
deleteText: 'Remove'
......@@ -60,7 +60,7 @@ QUnit.test('existing add button', function(assert) {
this.inlineRow = this.table.find('tr');
this.table.append('<i class="add-button"></i>');
var addButton = this.table.find('.add-button');
this.inlineRow.tabularFormset({
this.inlineRow.tabularFormset('table.inline tr', {
prefix: 'first',
deleteText: 'Remove',
addButton: addButton
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment