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