From 87d8a523977eb3fb613128b4b3fc824378b91390 Mon Sep 17 00:00:00 2001 From: ChanMyeong Date: Tue, 16 Oct 2012 08:41:29 +0000 Subject: [PATCH] Issue 2589 fixed. Create 'label[for]' and 'input[id]' attributes and matching the value. git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@11737 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/admin/tpl/js/admin.js | 24 +++++++++++++++++------- modules/admin/tpl/js/admin.min.js | 24 +++++++++++++++++------- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/modules/admin/tpl/js/admin.js b/modules/admin/tpl/js/admin.js index 68796ef68..c94b9f43d 100644 --- a/modules/admin/tpl/js/admin.js +++ b/modules/admin/tpl/js/admin.js @@ -152,20 +152,30 @@ jQuery(function($){ }); // label[for] + input[id]/textarea[id]/select[id] creator $('label:not([for])').each(function(index){ - var $this = $(this); index = index + 1; - if($this.next('input[id], textarea[id], select[id]').not(':radio, :checkbox').length){ + var $this = $(this); + var input = 'input, textarea, select'; + var check = ':radio, :checkbox'; + var id = '[id]'; + var value = 'i' + index; + if($this.next(input).filter(id).not(check).length){ // next input, textarea, select id true $this.attr('for', $this.next().attr('id')); - } else if ($this.next('input:not([id]), textarea:not([id]), select:not([id])').not(':radio, :checkbox').length) { + } else if ($this.next(input).not(id).not(check).length) { // next input, textarea, select id false - $this.attr('for', 'i' + index).next().attr('id', 'i' + index); - } else if ($this.prev(':radio[id], :checkbox[id]').length) { + $this.attr('for', value).next().attr('id', value); + } else if ($this.prev(check).filter(id).length) { // prev :radio :checkbox id true $this.attr('for', $this.prev().attr('id')); - } else if ($this.prev(':radio:not([id]), :checkbox:not([id])').length) { + } else if ($this.prev(check).not(id).length) { // prev :radio :checkbox id false - $this.attr('for', 'i' + index).prev().attr('id', 'i' + index); + $this.attr('for', value).prev().attr('id', value); + } else if ($this.children(input).filter(id).length) { + // children id true + $this.attr('for', $this.children(input).filter(id).eq(0).attr('id')); + } else if ($this.children(input).not(id).length) { + // children id false + $this.attr('for', value).children(input).not(id).eq(0).attr('id', value); } }); }); diff --git a/modules/admin/tpl/js/admin.min.js b/modules/admin/tpl/js/admin.min.js index 68796ef68..c94b9f43d 100644 --- a/modules/admin/tpl/js/admin.min.js +++ b/modules/admin/tpl/js/admin.min.js @@ -152,20 +152,30 @@ jQuery(function($){ }); // label[for] + input[id]/textarea[id]/select[id] creator $('label:not([for])').each(function(index){ - var $this = $(this); index = index + 1; - if($this.next('input[id], textarea[id], select[id]').not(':radio, :checkbox').length){ + var $this = $(this); + var input = 'input, textarea, select'; + var check = ':radio, :checkbox'; + var id = '[id]'; + var value = 'i' + index; + if($this.next(input).filter(id).not(check).length){ // next input, textarea, select id true $this.attr('for', $this.next().attr('id')); - } else if ($this.next('input:not([id]), textarea:not([id]), select:not([id])').not(':radio, :checkbox').length) { + } else if ($this.next(input).not(id).not(check).length) { // next input, textarea, select id false - $this.attr('for', 'i' + index).next().attr('id', 'i' + index); - } else if ($this.prev(':radio[id], :checkbox[id]').length) { + $this.attr('for', value).next().attr('id', value); + } else if ($this.prev(check).filter(id).length) { // prev :radio :checkbox id true $this.attr('for', $this.prev().attr('id')); - } else if ($this.prev(':radio:not([id]), :checkbox:not([id])').length) { + } else if ($this.prev(check).not(id).length) { // prev :radio :checkbox id false - $this.attr('for', 'i' + index).prev().attr('id', 'i' + index); + $this.attr('for', value).prev().attr('id', value); + } else if ($this.children(input).filter(id).length) { + // children id true + $this.attr('for', $this.children(input).filter(id).eq(0).attr('id')); + } else if ($this.children(input).not(id).length) { + // children id false + $this.attr('for', value).children(input).not(id).eq(0).attr('id', value); } }); });