2 * Copyright 2016-2017, CMCC Technologies Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 monitorUtil.growl=function(message,type){
28 icon: "fa fa-envelope-o fa-lg",
29 title: " "+$.i18n.prop('com_zte_openo_umc_monitor_tip')+" ",
30 message: message+" "
38 $.fn.dataTableExt.oApi.fnPagingInfo = function (oSettings) {
40 "iEnd": oSettings.fnDisplayEnd(),
41 "iLength": oSettings._iDisplayLength,
42 "iTotal": oSettings.fnRecordsTotal(),
43 "iFilteredTotal": oSettings.fnRecordsDisplay(),
44 "iPage": Math.ceil(oSettings._iDisplayStart / oSettings._iDisplayLength),
45 "iTotalPages": Math.ceil(oSettings.fnRecordsDisplay() / oSettings._iDisplayLength)
49 $.extend($.fn.dataTableExt.oPagination, {
50 "bootstrap_extended": {
51 "fnInit": function (oSettings, nPaging, fnDraw) {
52 var oLang = oSettings.oLanguage.oPaginate;
53 var oPaging = oSettings.oInstance.fnPagingInfo();
55 var fnClickHandler = function (e) {
57 if (oSettings.oApi._fnPageChange(oSettings, e.data.action)) {
63 '<div class="pagination-panel"> ' + oLang.sPage + ' ' +
64 '<a href="#" class="btn btn-sm default prev disabled" title="' + oLang.sPrevious + '"><i class="fa fa-angle-left"></i></a>' +
65 '<input type="text" class="pagination-panel-input input-mini input-inline input-sm" maxlenght="5" style="text-align:center; margin: 0 4px; border: 1px solid rgb(169, 169, 169);height: 28px;">' +
66 '<a href="#" class="btn btn-sm default next disabled" title="' + oLang.sNext + '"><i class="fa fa-angle-right"></i></a> ' +
67 oLang.sPageOf + ' <span class="pagination-panel-total"></span>' +
71 var els = $('a', nPaging);
73 $(els[0]).bind('click.DT', {action: "previous"}, fnClickHandler);
74 $(els[1]).bind('click.DT', {action: "next"}, fnClickHandler);
76 $('.pagination-panel-input', nPaging).bind('change.DT', function (e) {
77 var oPaging = oSettings.oInstance.fnPagingInfo();
79 var page = parseInt($(this).val());
80 if (page > 0 && page < oPaging.iTotalPages) {
81 if (oSettings.oApi._fnPageChange(oSettings, page - 1)) {
85 $(this).val(oPaging.iPage + 1);
89 $('.pagination-panel-input', nPaging).bind('keypress.DT', function (e) {
90 var oPaging = oSettings.oInstance.fnPagingInfo();
92 var page = parseInt($(this).val());
93 if (page > 0 && page < oSettings.oInstance.fnPagingInfo().iTotalPages) {
94 if (oSettings.oApi._fnPageChange(oSettings, page - 1)) {
98 $(this).val(oPaging.iPage + 1);
105 "fnUpdate": function (oSettings, fnDraw) {
107 var oPaging = oSettings.oInstance.fnPagingInfo();
108 var an = oSettings.aanFeatures.p;
109 var i, j, sClass, iStart, iEnd, iHalf = Math.floor(iListLength / 2);
111 if (oPaging.iTotalPages < iListLength) {
113 iEnd = oPaging.iTotalPages;
115 else if (oPaging.iPage <= iHalf) {
118 } else if (oPaging.iPage >= (oPaging.iTotalPages - iHalf)) {
119 iStart = oPaging.iTotalPages - iListLength + 1;
120 iEnd = oPaging.iTotalPages;
122 iStart = oPaging.iPage - iHalf + 1;
123 iEnd = iStart + iListLength - 1;
127 for (i = 0, iLen = an.length; i < iLen; i++) {
128 var wrapper = $(an[i]).parents(".dataTables_wrapper");
130 if (oPaging.iTotalPages <= 0) {
131 $('.pagination-panel, .dataTables_length', wrapper).hide();
133 $('.pagination-panel, .dataTables_length', wrapper).show();
136 $('.pagination-panel-total', an[i]).html(oPaging.iTotalPages);
137 $('.pagination-panel-input', an[i]).val(oPaging.iPage + 1);
139 // Remove the middle elements
140 $('li:gt(1)', an[i]).filter(':not(.next)').remove();
142 // Add the new list items and their event handlers
143 for (j = iStart; j <= iEnd; j++) {
144 sClass = (j == oPaging.iPage + 1) ? 'class="active"' : '';
145 $('<li ' + sClass + '><a href="#">' + j + '</a></li>')
146 .insertBefore($('li.next:first', an[i])[0])
147 .bind('click', function (e) {
149 oSettings._iDisplayStart = (parseInt($('a', this).text(), 10) - 1) * oPaging.iLength;
154 // Add / remove disabled classes from the static elements
155 if (oPaging.iPage === 0) {
156 $('a.prev', an[i]).addClass('disabled');
158 $('a.prev', an[i]).removeClass('disabled');
161 if (oPaging.iPage === oPaging.iTotalPages - 1 || oPaging.iTotalPages === 0) {
162 $('a.next', an[i]).addClass('disabled');
164 $('a.next', an[i]).removeClass('disabled');