Fix list check issue
This commit is contained in:
parent
e903bd0c39
commit
bfebed7cb8
|
@ -1,98 +1,108 @@
|
||||||
var ListCheck = function(element) {
|
|
||||||
this.element = $(element);
|
|
||||||
this.element.data('exists', true);
|
|
||||||
if(this.element.context.parentNode.tagName == "TD") {
|
|
||||||
this.elementWrap = $(this.element.context.parentNode);
|
|
||||||
this.elementWrap.addClass('listCheck');
|
|
||||||
} else if(this.element.context.parentNode.tagName == "TH") {
|
|
||||||
this.elementWrap = $(this.element.context.parentNode);
|
|
||||||
this.elementWrap.addClass('listCheckHead');
|
|
||||||
}
|
|
||||||
this.element.before('<i class="icon-check-empty" />');
|
|
||||||
};
|
|
||||||
|
|
||||||
$.fn.listCheck = function (callback) {
|
|
||||||
this.each(function (i) {
|
|
||||||
if(!$(this).data('exists')) {
|
|
||||||
new ListCheck(this);
|
|
||||||
};
|
|
||||||
});
|
|
||||||
this.on(clickEvent, function(e) {
|
|
||||||
if($(this).prop('checked')) {
|
|
||||||
$(this).siblings('i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
|
||||||
} else {
|
|
||||||
$(this).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
|
||||||
};
|
|
||||||
if ($(this).closest('.listCheckHead').length) {
|
|
||||||
$('.listCheck .list-check').prop('checked', $(this).prop('checked'));
|
|
||||||
if($(this).prop('checked')) {
|
|
||||||
$('.listCheck i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
|
||||||
} else {
|
|
||||||
$('.listCheck i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
var _isCheck = $('tbody .list-check').filter(':checked').length,
|
|
||||||
_defaultLength = $('tbody .list-check').length;
|
|
||||||
|
|
||||||
if(_isCheck > 0 && _isCheck < _defaultLength) {
|
|
||||||
$('.listCheckHead i').removeClass('icon-check-empty icon-check').addClass('icon-minus');
|
|
||||||
} else if(!_isCheck) {
|
|
||||||
$('.listCheckHead i').removeClass('icon-minus icon-check').addClass('icon-check-empty');
|
|
||||||
} else {
|
|
||||||
$('.listCheckHead i').removeClass('icon-check-empty icon-minus').addClass('icon-check');
|
|
||||||
}
|
|
||||||
_isCheck ? $('.list-active-btn').removeClass('disabled').data('actionable', true) : $('.list-active-btn').addClass('disabled').data('actionable', false);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
function clearCheck() {
|
|
||||||
$('.list-check').each(function() {
|
|
||||||
$(this).prop('checked', false);
|
|
||||||
})
|
|
||||||
}
|
|
||||||
function actionSuccess(e) {
|
|
||||||
$("tbody .list-check").each(function() {
|
|
||||||
switch(e) {
|
|
||||||
case 'list-be-hide':
|
|
||||||
$(this).filter(':checked').closest('tr').addClass('checkHide');
|
|
||||||
break;
|
|
||||||
case 'list-be-show':
|
|
||||||
$(this).filter(':checked').closest('tr').removeClass('checkHide');
|
|
||||||
break;
|
|
||||||
case 'list-be-remove':
|
|
||||||
$(this).filter(':checked').closest('tr').fadeOut(300, function() {
|
|
||||||
$(this).remove();
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
};
|
|
||||||
$('.list-check').siblings('i').removeAttr('class').addClass('icon-check-empty').closest('tr').removeClass('checkHit');
|
|
||||||
});
|
|
||||||
clearCheck();
|
|
||||||
}
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var $t = null,
|
var ListCheckData = {},
|
||||||
_data = null;
|
ListCheck = function(element) {
|
||||||
clearCheck();
|
this.element = $(element);
|
||||||
$('.list-check').listCheck();
|
this.element.data('exists', true);
|
||||||
$('.list-active-btn').data('actionable', false).on(clickEvent, function(e) {
|
if(this.element.context.parentNode.tagName == "TD") {
|
||||||
$t = $(this)
|
this.elementWrap = $(this.element.context.parentNode);
|
||||||
_data = $(this).data()
|
this.elementWrap.addClass('listCheck');
|
||||||
_data.actionable ? $('#dialog').modal('show') : "";
|
} else if(this.element.context.parentNode.tagName == "TH") {
|
||||||
e.preventDefault();
|
this.elementWrap = $(this.element.context.parentNode);
|
||||||
});
|
this.elementWrap.addClass('listCheckHead');
|
||||||
$('.delete-item').on(clickEvent, function() {
|
}
|
||||||
var _v = [];
|
this.element.before('<i class="icon-check-empty" />');
|
||||||
$("tbody .list-check").each(function() {
|
};
|
||||||
this.checked && _v.push("ids[]="+this.value)
|
|
||||||
|
$.fn.listCheck = function () {
|
||||||
|
$(this).each(function() {
|
||||||
|
var $this = $(this),
|
||||||
|
$el = $this.find('input[type="checkbox"]');
|
||||||
|
$el.each(function (i) {
|
||||||
|
if(!$(this).data('exists')) {
|
||||||
|
new ListCheck(this);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
$this.on(clickEvent, $el, function(e) {
|
||||||
|
if($(e.target).prop('checked')) {
|
||||||
|
$(e.target).siblings('i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
||||||
|
} else {
|
||||||
|
$(e.target).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
};
|
||||||
|
if($(e.target).closest('th').hasClass('listCheckHead')) {
|
||||||
|
$this.find('.listCheck input[type="checkbox"]').prop('checked', $(e.target).prop('checked'));
|
||||||
|
if($(e.target).prop('checked')) {
|
||||||
|
$this.find('.listCheck i').addClass('icon-check').removeClass('icon-check-empty').closest('tr').addClass('checkHit');
|
||||||
|
} else {
|
||||||
|
$this.find('.listCheck i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var _isCheck = $this.find('tbody').find($el).filter(':checked').length,
|
||||||
|
_defaultLength = $this.find('tbody').find($el).length;
|
||||||
|
|
||||||
|
if(_isCheck > 0 && _isCheck < _defaultLength) {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-check-empty icon-check').addClass('icon-minus');
|
||||||
|
} else if(!_isCheck) {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-minus icon-check').addClass('icon-check-empty');
|
||||||
|
} else {
|
||||||
|
$this.find('.listCheckHead i').removeClass('icon-check-empty icon-minus').addClass('icon-check');
|
||||||
|
}
|
||||||
|
_isCheck ? $this.find('.list-active-btn').removeClass('disabled').data('actionable', true) : $this.find('.list-active-btn').addClass('disabled').data('actionable', false);
|
||||||
|
});
|
||||||
|
$this.on(clickEvent, '.list-active-btn', function(e) {
|
||||||
|
if(!$(this).hasClass('disabled')) {
|
||||||
|
ListCheckData.url = $(this).attr('rel');
|
||||||
|
ListCheckData.name = $this.find('tbody').find('input[type="checkbox"]').attr('name');
|
||||||
|
ListCheckData.action = $(this).data('checkAction');
|
||||||
|
ListCheckData.values = [];
|
||||||
|
ListCheckData.element = $this
|
||||||
|
$this.find('tbody').find('input[type="checkbox"]').each(function (i) {
|
||||||
|
this.checked && ListCheckData.values.push("ids[]=" + this.value);
|
||||||
|
});
|
||||||
|
console.log(ListCheckData.values.join("&"));
|
||||||
|
$('#dialog').modal('show');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
var _t = $t.attr("rel");
|
clearCheck($(this));
|
||||||
if(_t.indexOf("?") > -1) {
|
};
|
||||||
$.ajax(_t + "&" + _v.join("&")).done(function() {
|
|
||||||
actionSuccess(_data.checkAction)
|
function clearCheck(element) {
|
||||||
|
element.find('input[type="checkbox"]').each(function() {
|
||||||
|
$(this).prop('checked', false).siblings('i').addClass('icon-check-empty').removeClass('icon-check').closest('tr').removeClass('checkHit');
|
||||||
|
});
|
||||||
|
element.find('.list-active-btn').addClass('disabled');
|
||||||
|
};
|
||||||
|
|
||||||
|
function actionSuccess(e) {
|
||||||
|
ListCheckData.element.find('tbody').find('input[type="checkbox"]').each(function() {
|
||||||
|
switch(e) {
|
||||||
|
case 'list-be-hide':
|
||||||
|
$(this).filter(':checked').closest('tr').addClass('checkHide');
|
||||||
|
break;
|
||||||
|
case 'list-be-show':
|
||||||
|
$(this).filter(':checked').closest('tr').removeClass('checkHide');
|
||||||
|
break;
|
||||||
|
case 'list-be-remove':
|
||||||
|
$(this).filter(':checked').closest('tr').fadeOut(300, function() {
|
||||||
|
$(this).remove();
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
};
|
||||||
|
$('.list-check').siblings('i').removeAttr('class').addClass('icon-check-empty').closest('tr').removeClass('checkHit');
|
||||||
|
});
|
||||||
|
clearCheck(ListCheckData.element);
|
||||||
|
}
|
||||||
|
$('.list-check').listCheck();
|
||||||
|
$('.delete-item').on(clickEvent, function() {
|
||||||
|
if(ListCheckData.url.indexOf("?") > -1) {
|
||||||
|
$.ajax(ListCheckData.url + "&" + ListCheckData.values.join("&")).done(function() {
|
||||||
|
actionSuccess(ListCheckData.action);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$.ajax(_t + "?" + _v.join("&")).done(function() {
|
$.ajax(ListCheckData.url + "?" + ListCheckData.values.join("&")).done(function() {
|
||||||
actionSuccess(_data.checkAction)
|
actionSuccess(ListCheckData.action);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$('#dialog').modal('hide');
|
$('#dialog').modal('hide');
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
padding: 0 0 0 10px!important;
|
padding: 0 0 0 10px!important;
|
||||||
}
|
}
|
||||||
.listCheckHead .list-check,
|
.listCheckHead input[type="checkbox"],
|
||||||
.listCheck .list-check {
|
.listCheck input[type="checkbox"] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin: -12px 0 0 -1px;
|
margin: -12px 0 0 -1px;
|
||||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane fade in active" id="send-log">
|
<div class="tab-pane fade in active list-check" id="send-log">
|
||||||
<p class="">
|
<p class="">
|
||||||
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
|
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -71,7 +71,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
|
<input type="checkbox" name="to_delete[]" value="b" />
|
||||||
</th>
|
</th>
|
||||||
<th><%= t(:sent_date) %></th>
|
<th><%= t(:sent_date) %></th>
|
||||||
<th><%= t(:subject) %></th>
|
<th><%= t(:subject) %></th>
|
||||||
|
@ -81,26 +81,10 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
|
|
||||||
</td>
|
|
||||||
<td>2014-01-16 17:57</td>
|
|
||||||
<td>【轉知】國家教育研究院辦理普通高級中學語文及社會領域課綱微調分區公聽會
|
|
||||||
<div class="quick-edit">
|
|
||||||
<ul class="nav nav-pills">
|
|
||||||
<li><a href="#" class="text-error"><%= t(:delete_) %></a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>alluser@tea.ntue.edu.tw</td>
|
|
||||||
<td>蔣 欣潔</td>
|
|
||||||
<td>er_email</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade in" id="waiting-sent">
|
<div class="tab-pane fade in list-check" id="waiting-sent">
|
||||||
<p class="">
|
<p class="">
|
||||||
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
|
<a href="#" class="btn list-active-btn disabled" data-check-action="list-be-remove" rel="/panel/announcement/back_end/bulletins/delete"><i class="icons-trash"></i></a>
|
||||||
</p>
|
</p>
|
||||||
|
@ -108,32 +92,15 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>
|
<th>
|
||||||
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
|
<input type="checkbox" name="to_delete[]" value="b" />
|
||||||
</th>
|
</th>
|
||||||
<th>Sentdate</th>
|
<th><%= t(:sent_date) %></th>
|
||||||
<th>Subject</th>
|
<th><%= t(:subject) %></th>
|
||||||
<th>Mail To</th>
|
<th><%= t(:mail_to) %></th>
|
||||||
<th>Mail User</th>
|
<th><%= t(:mail_from_app) %></th>
|
||||||
<th>Mail From App</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<input type="checkbox" class="list-check" name="to_delete[]" value="b" />
|
|
||||||
</td>
|
|
||||||
<td>2014-01-16 17:57</td>
|
|
||||||
<td>【轉知】國家教育研究院辦理普通高級中學語文及社會領域課綱微調分區公聽會
|
|
||||||
<div class="quick-edit">
|
|
||||||
<ul class="nav nav-pills">
|
|
||||||
<li><a href="#" class="text-error"><%= t(:delete_) %></a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
<td>alluser@tea.ntue.edu.tw</td>
|
|
||||||
<td>蔣 欣潔</td>
|
|
||||||
<td>er_email</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
<div id="module-content">
|
<div id="module-content">
|
||||||
<div class="nano">
|
<div class="nano">
|
||||||
<div class="content">
|
<div class="content list-check">
|
||||||
<%=render :partial => @right_partial %>
|
<%=render :partial => @right_partial %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span1"><%= t('personal_book.year') %></th>
|
<th class="span1"><%= t('personal_book.year') %></th>
|
||||||
<th><%= t('personal_book.book_title') %></th>
|
<th><%= t('personal_book.book_title') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span1"><%= t('personal_conference.year') %></th>
|
<th class="span1"><%= t('personal_conference.year') %></th>
|
||||||
<th><%= t('module_name.personal_conference') %></th>
|
<th><%= t('module_name.personal_conference') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('date_') %></th>
|
<th class="span2"><%= t('date_') %></th>
|
||||||
<th><%= t('personal_diploma.school_name') %></th>
|
<th><%= t('personal_diploma.school_name') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('date_') %></th>
|
<th class="span2"><%= t('date_') %></th>
|
||||||
<th><%= t('personal_experience.organizationt_title') %></th>
|
<th><%= t('personal_experience.organizationt_title') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span1"><%= t('personal_honor.year') %></th>
|
<th class="span1"><%= t('personal_honor.year') %></th>
|
||||||
<th><%= t('personal_honor.award_name') %></th>
|
<th><%= t('personal_honor.award_name') %></th>
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span1"><%= t('personal_journal.year') %></th>
|
<th class="span1"><%= t('personal_journal.year') %></th>
|
||||||
<th><%= t('module_name.personal_journal') %></th>
|
<th><%= t('module_name.personal_journal') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span1"><%= t('personal_lab.year') %></th>
|
<th class="span1"><%= t('personal_lab.year') %></th>
|
||||||
<th><%= t('personal_lab.lab_title') %></th>
|
<th><%= t('personal_lab.lab_title') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('personal_patent.publication_date') %></th>
|
<th class="span2"><%= t('personal_patent.publication_date') %></th>
|
||||||
<th><%= t('personal_patent.patent_title') %></th>
|
<th><%= t('personal_patent.patent_title') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('personal_project.period') %></th>
|
<th class="span2"><%= t('personal_project.period') %></th>
|
||||||
<th><%= t('personal_project.project_title') %></th>
|
<th><%= t('personal_project.project_title') %></th>
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<% if is_admin? %>
|
<% if is_admin? %>
|
||||||
<th><input type="checkbox" class="list-check" /></th>
|
<th><input type="checkbox" /></th>
|
||||||
<% end -%>
|
<% end -%>
|
||||||
<th class="span2"><%= t('personal_research.publication_date') %></th>
|
<th class="span2"><%= t('personal_research.publication_date') %></th>
|
||||||
<th><%= t('personal_research.research_title') %></th>
|
<th><%= t('personal_research.research_title') %></th>
|
||||||
|
|
Reference in New Issue