forked from p85126437/datagear
[web]重构page_obj_grid.jsp函数,采用表格自带的ajax加载数据,解决表格初始化重复请求、窗口resize后表格尺寸不对等问题
This commit is contained in:
parent
f7a894099c
commit
ccc8c98291
|
@ -32,7 +32,6 @@ no=\u5426
|
|||
moreOperation=\u66F4\u591A\u64CD\u4F5C
|
||||
operationConfirm=\u64CD\u4F5C\u786E\u8BA4
|
||||
haveAdd=\u5DF2\u6DFB\u52A0
|
||||
noData=\u6CA1\u6709\u6570\u636E
|
||||
loading=\u52A0\u8F7D\u4E2D...
|
||||
backToMainPage=\u8FD4\u56DE\u9996\u9875
|
||||
restart=\u91CD\u65B0\u5F00\u59CB
|
||||
|
@ -41,6 +40,9 @@ import=\u5BFC\u5165
|
|||
export=\u5BFC\u51FA
|
||||
find=\u67E5\u627E
|
||||
|
||||
dataTables.noData=\u6CA1\u6709\u6570\u636E
|
||||
dataTables.zeroRecords=\u6CA1\u6709\u7ED3\u679C
|
||||
|
||||
#validation
|
||||
validation.required=\u6B64\u9879\u5FC5\u586B
|
||||
validation.integer=\u6B64\u9879\u4EC5\u53EF\u586B\u5199\u6574\u6570\u503C
|
||||
|
|
|
@ -64,49 +64,10 @@ List<PropertyPathNameLabel> conditionSource = (List<PropertyPathNameLabel>)reque
|
|||
{
|
||||
pageObj.conditionSource = <%writeJson(application, out, conditionSource);%>;
|
||||
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".operation")).button();
|
||||
$.initButtons(pageObj.element(".operation"));
|
||||
|
||||
pageObj.onModel(function(model)
|
||||
{
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null, null);
|
||||
};
|
||||
|
||||
pageObj.paging = function(pagingParam)
|
||||
{
|
||||
pageObj.refresh(null, pagingParam, null);
|
||||
return false;
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, null, order);
|
||||
};
|
||||
|
||||
pageObj.refresh = function(searchParam, pagingParam, order)
|
||||
{
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!pagingParam)
|
||||
pagingParam = pageObj.getPagingParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
|
||||
var url = pageObj.url("queryData");
|
||||
|
||||
var param = {};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, pagingParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(pagingData)
|
||||
{
|
||||
pageObj.setPagingData(pagingData);
|
||||
});
|
||||
};
|
||||
|
||||
<%if(!readonly){%>
|
||||
pageObj.element("input[name=addButton]").click(function()
|
||||
{
|
||||
|
@ -162,12 +123,11 @@ List<PropertyPathNameLabel> conditionSource = (List<PropertyPathNameLabel>)reque
|
|||
return re;
|
||||
});
|
||||
<%}%>
|
||||
|
||||
|
||||
pageObj.conditionAutocompleteSource = $.buildSearchConditionAutocompleteSource(pageObj.conditionSource);
|
||||
pageObj.initConditionPanel();
|
||||
pageObj.initModelTable(model);
|
||||
pageObj.initPagination();
|
||||
pageObj.refresh();
|
||||
pageObj.initModelDataTableAjax(pageObj.url("queryData"), model);
|
||||
});
|
||||
})
|
||||
(${pageId});
|
||||
|
|
|
@ -44,7 +44,9 @@ boolean isPrivatePropertyModel = ModelUtils.isPrivatePropertyModelTail(propertyP
|
|||
<div id="${pageId}" class="page-data-grid page-data-grid-empv">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<%if(!clientOperation){%>
|
||||
<%@ include file="include/data_page_obj_searchform_html.jsp" %>
|
||||
<%}%>
|
||||
</div>
|
||||
<div class="operation">
|
||||
<%if(readonly){%>
|
||||
|
@ -73,8 +75,10 @@ boolean isPrivatePropertyModel = ModelUtils.isPrivatePropertyModelTail(propertyP
|
|||
</div>
|
||||
<%}%>
|
||||
<%@ include file="include/data_page_obj.jsp" %>
|
||||
<%if(!clientOperation){%>
|
||||
<%@ include file="include/data_page_obj_searchform_js.jsp" %>
|
||||
<%@ include file="../include/page_obj_pagination.jsp" %>
|
||||
<%}%>
|
||||
<%@ include file="include/data_page_obj_grid.jsp" %>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
|
@ -83,9 +87,12 @@ boolean isPrivatePropertyModel = ModelUtils.isPrivatePropertyModelTail(propertyP
|
|||
pageObj.data = $.unref(<%writeJson(application, out, data);%>);
|
||||
pageObj.propName = "<%=propName%>";
|
||||
pageObj.clientOperation = <%=clientOperation%>;
|
||||
|
||||
<%if(!clientOperation){%>
|
||||
pageObj.conditionSource = <%writeJson(application, out, conditionSource);%>;
|
||||
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".operation")).button();
|
||||
<%}%>
|
||||
|
||||
$.initButtons(pageObj.element(".operation"));
|
||||
|
||||
pageObj.buildActionOptions = function(property, propertyConcreteModel, extraRequestParams, extraPageParams)
|
||||
{
|
||||
|
@ -124,51 +131,19 @@ boolean isPrivatePropertyModel = ModelUtils.isPrivatePropertyModelTail(propertyP
|
|||
|
||||
pageObj.mappedByWith = $.model.findMappedByWith(property, propertyModel);
|
||||
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null);
|
||||
};
|
||||
pageObj.dataTableAjaxParamParent = pageObj.dataTableAjaxParam;
|
||||
|
||||
pageObj.paging = function(pagingParam)
|
||||
pageObj.dataTableAjaxParam = function()
|
||||
{
|
||||
pageObj.refresh(null, pagingParam);
|
||||
return false;
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, null, order);
|
||||
};
|
||||
|
||||
pageObj.refresh = function(searchParam, pagingParam, order)
|
||||
{
|
||||
//客户端操作不支持刷新
|
||||
if(pageObj.clientOperation)
|
||||
return;
|
||||
var param = pageObj.dataTableAjaxParamParent();
|
||||
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!pagingParam)
|
||||
pagingParam = pageObj.getPagingParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
|
||||
var url = pageObj.url("queryMultiplePropValueData");
|
||||
|
||||
var param =
|
||||
$.extend(param,
|
||||
{
|
||||
"data" : pageObj.data,
|
||||
"propName" : pageObj.propName
|
||||
};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, pagingParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(pagingData)
|
||||
{
|
||||
pageObj.setPagingData(pagingData);
|
||||
});
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
pageObj.element("input[name=viewButton]").click(function()
|
||||
|
@ -347,16 +322,14 @@ boolean isPrivatePropertyModel = ModelUtils.isPrivatePropertyModelTail(propertyP
|
|||
return re;
|
||||
});
|
||||
<%}%>
|
||||
|
||||
pageObj.conditionAutocompleteSource = $.buildSearchConditionAutocompleteSource(pageObj.conditionSource);
|
||||
pageObj.initConditionPanel();
|
||||
pageObj.initModelTable(propertyModel, $.model.propValue(pageObj.data, pageObj.propName), pageObj.mappedByWith);
|
||||
|
||||
<%if(clientOperation){%>
|
||||
|
||||
pageObj.initModelDataTableLocal(propertyModel, $.model.propValue(pageObj.data, pageObj.propName), pageObj.mappedByWith);
|
||||
<%}else{%>
|
||||
pageObj.initPagination();
|
||||
pageObj.refresh();
|
||||
pageObj.conditionAutocompleteSource = $.buildSearchConditionAutocompleteSource(pageObj.conditionSource);
|
||||
pageObj.initConditionPanel();
|
||||
pageObj.initPagination();
|
||||
pageObj.initModelDataTableAjax(pageObj.url("queryMultiplePropValueData"), propertyModel, pageObj.mappedByWith);
|
||||
<%}%>
|
||||
});
|
||||
})
|
||||
|
|
|
@ -71,7 +71,7 @@ else
|
|||
pageObj.isMultipleSelect = <%=isMultipleSelect%>;
|
||||
pageObj.conditionSource = <%writeJson(application, out, conditionSource);%>;
|
||||
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".operation")).button();
|
||||
$.initButtons(pageObj.element(".operation"));
|
||||
|
||||
pageObj.onModel(function(model)
|
||||
{
|
||||
|
@ -80,47 +80,20 @@ else
|
|||
var propertyModel = propertyInfo.model;
|
||||
|
||||
pageObj.mappedByWith = $.model.findMappedByWith(property, propertyModel);
|
||||
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null);
|
||||
};
|
||||
|
||||
pageObj.paging = function(pagingParam)
|
||||
{
|
||||
pageObj.refresh(null, pagingParam);
|
||||
return false;
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, null, order);
|
||||
};
|
||||
pageObj.dataTableAjaxParamParent = pageObj.dataTableAjaxParam;
|
||||
|
||||
pageObj.refresh = function(searchParam, pagingParam, order)
|
||||
pageObj.dataTableAjaxParam = function()
|
||||
{
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!pagingParam)
|
||||
pagingParam = pageObj.getPagingParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
var param = pageObj.dataTableAjaxParamParent();
|
||||
|
||||
var url = pageObj.url("selectPropValueData");
|
||||
var param =
|
||||
$.extend(param,
|
||||
{
|
||||
"data" : pageObj.data,
|
||||
"propName" : pageObj.propName
|
||||
};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, pagingParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(pagingData)
|
||||
{
|
||||
pageObj.setPagingData(pagingData);
|
||||
});
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
pageObj.element("input[name=confirmButton]").click(function()
|
||||
|
@ -211,9 +184,8 @@ else
|
|||
|
||||
pageObj.conditionAutocompleteSource = $.buildSearchConditionAutocompleteSource(pageObj.conditionSource);
|
||||
pageObj.initConditionPanel();
|
||||
pageObj.initModelTable(propertyModel);
|
||||
pageObj.initPagination();
|
||||
pageObj.refresh();
|
||||
pageObj.initModelDataTableAjax(pageObj.url("selectPropValueData"), propertyModel);
|
||||
});
|
||||
})
|
||||
(${pageId});
|
||||
|
|
|
@ -8,12 +8,26 @@
|
|||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.initModelTable = function(model, datas, ignorePropertyNames)
|
||||
/**
|
||||
* 构建Model的本地表格。
|
||||
*/
|
||||
pageObj.initModelDataTableLocal = function(model, data, ignorePropertyNames)
|
||||
{
|
||||
var tableColumns = $.buildDataTablesColumns(model, {"ignorePropertyNames" : ignorePropertyNames});
|
||||
var tableSettings = pageObj.getTableSettings(tableColumns, datas);
|
||||
var columns = $.buildDataTablesColumns(model, {"ignorePropertyNames" : ignorePropertyNames});
|
||||
var settings = pageObj.buildDataTableSettingsLocal(columns, data);
|
||||
|
||||
pageObj.initTable(tableSettings);
|
||||
pageObj.initDataTable(settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* 构建Model的ajax表格。
|
||||
*/
|
||||
pageObj.initModelDataTableAjax = function(url, model, ignorePropertyNames)
|
||||
{
|
||||
var columns = $.buildDataTablesColumns(model, {"ignorePropertyNames" : ignorePropertyNames});
|
||||
var settings = pageObj.buildDataTableSettingsAjax(columns, url);
|
||||
|
||||
pageObj.initDataTable(settings);
|
||||
};
|
||||
})
|
||||
(${pageId});
|
||||
|
|
|
@ -83,7 +83,7 @@ boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEntity
|
|||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.element("input:submit, input:button, input:reset, button, .fileinput-button").button();
|
||||
$.initButtons(pageObj.element());
|
||||
|
||||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
pageObj.driverFiles = pageObj.element(".driver-files");
|
||||
|
|
|
@ -29,10 +29,7 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEnti
|
|||
<div id="${pageId}" class="page-data-grid page-data-grid-driverEntity">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<form id="${pageId}-searchForm" class="search-form" action="#">
|
||||
<div class="ui-widget ui-widget-content keyword-widget"><input name="keyword" type="text" class="ui-widget ui-widget-content input-keyword" /></div>
|
||||
<input name="submit" type="submit" value="<fmt:message key='query' />" />
|
||||
</form>
|
||||
<%@ include file="../include/page_obj_searchform.html.jsp" %>
|
||||
</div>
|
||||
<div class="operation">
|
||||
<%if(selectonly){%>
|
||||
|
@ -60,67 +57,18 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEnti
|
|||
</div>
|
||||
<%}%>
|
||||
<%@ include file="../include/page_js_obj.jsp" %>
|
||||
<%@ include file="../include/page_obj_searchform_js.jsp" %>
|
||||
<%@ include file="../include/page_obj_grid.jsp" %>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".head")).button();
|
||||
$.initButtons(pageObj.element(".operation"));
|
||||
|
||||
pageObj.url = function(action)
|
||||
{
|
||||
return contextPath + "/driverEntity/" + action;
|
||||
};
|
||||
|
||||
pageObj.searchForm = pageObj.element(".search-form");
|
||||
pageObj.searchForm.submit(function()
|
||||
{
|
||||
var searchParam = pageObj.getSearchParam();
|
||||
|
||||
pageObj.search(searchParam);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null);
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, order);
|
||||
};
|
||||
|
||||
pageObj.refresh = function(searchParam, order)
|
||||
{
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
|
||||
var url = pageObj.url("queryData");
|
||||
|
||||
var param = {};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(data)
|
||||
{
|
||||
pageObj.setTableData(data);
|
||||
});
|
||||
};
|
||||
|
||||
pageObj.getSearchParam = function()
|
||||
{
|
||||
var param =
|
||||
{
|
||||
"keyword" : $.trim(pageObj.element("input[name='keyword']", pageObj.searchForm).val())
|
||||
};
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
<%if(!selectonly){%>
|
||||
pageObj.element("input[name=addButton]").click(function()
|
||||
{
|
||||
|
@ -204,14 +152,7 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEnti
|
|||
{
|
||||
"confirm" : function()
|
||||
{
|
||||
var data = "";
|
||||
for(var i=0; i< rows.length; i++)
|
||||
{
|
||||
if(data != "")
|
||||
data += "&";
|
||||
|
||||
data += "id=" + rows[i].id;
|
||||
}
|
||||
var data = $.getPropertyParamString(rows, "id");
|
||||
|
||||
$.post(pageObj.url("delete"), data, function()
|
||||
{
|
||||
|
@ -264,9 +205,8 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, DriverEnti
|
|||
pageObj.buildTableColumValueOption("<fmt:message key='driverEntity.displayDesc' />", "displayDescMore"),
|
||||
pageObj.buildTableColumValueOption("", "displayText", true)
|
||||
];
|
||||
var tableSettings = pageObj.getTableSettings(tableColumns);
|
||||
pageObj.initTable(tableSettings);
|
||||
pageObj.refresh();
|
||||
var tableSettings = pageObj.buildDataTableSettingsAjax(tableColumns, pageObj.url("queryData"));
|
||||
pageObj.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.element("input:submit, input:button, input:reset, button, .fileinput-button").button();
|
||||
$.initButtons(pageObj.element());
|
||||
|
||||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
pageObj.testSmtpUrl = "<%=request.getContextPath()%>/globalSetting/testSmtp";
|
||||
|
|
|
@ -41,6 +41,7 @@ var contextPath="<%=request.getContextPath()%>";
|
|||
<script src="<c:url value="/static/script/jquery-validation-1.17.0/jquery.validate.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/jquery-validation-1.17.0/additional-methods.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/textarea-helper-0.3.1/textarea-helper.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/jquery.actual-1.0.19/jquery.actual.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/datagear-pagination.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/datagear-model.js" />" type="text/javascript"></script>
|
||||
<script src="<c:url value="/static/script/datagear-modelcache.js" />" type="text/javascript"></script>
|
||||
|
|
|
@ -9,38 +9,176 @@
|
|||
|
||||
依赖:
|
||||
page_js_obj.jsp
|
||||
|
||||
变量:
|
||||
//排序回调函数,允许为null,格式为:function(order){}
|
||||
pageObj.sort = undefined;
|
||||
--%>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.table = pageObj.element("#${pageId}-table");
|
||||
//上一次order,DataTables会在某些无关的情况产生order事件,这里存储上一次order,用于比较并忽略排序
|
||||
pageObj.previousOrder = undefined;
|
||||
|
||||
//计算表格高度
|
||||
pageObj.calTableHeight = function()
|
||||
{
|
||||
var height = pageObj.element(".content").height() - 50;
|
||||
var height = pageObj.element("> .content").actual("innerHeight") - 50;
|
||||
|
||||
return height;
|
||||
};
|
||||
|
||||
//计算表格宽度
|
||||
pageObj.calTableWidth = function()
|
||||
{
|
||||
var width = pageObj.element("> .content").actual("innerWidth");
|
||||
|
||||
return width;
|
||||
};
|
||||
|
||||
pageObj.renderCheckColumn = function(data, type, row, meta)
|
||||
{
|
||||
return "<div class='ui-widget ui-widget-content ui-corner-all checkbox'><span class='ui-icon ui-icon-check'></span></div>";
|
||||
};
|
||||
|
||||
pageObj.getTableSettings = function(columns, initDatas)
|
||||
/**
|
||||
* 默认pageObj.buildDataTableSettingsAjax请求参数实现。
|
||||
*/
|
||||
pageObj.dataTableAjaxParam = function()
|
||||
{
|
||||
var param = {};
|
||||
|
||||
if(pageObj.searchParam)
|
||||
$.extend(param, pageObj.searchParam);
|
||||
|
||||
if(pageObj.pagingParam)
|
||||
$.extend(param, pageObj.pagingParam);
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
/**
|
||||
* 默认pageObj.buildDataTableSettingsAjax请求成功回调实现。
|
||||
*/
|
||||
pageObj.dataTableAjaxSuccess = function(pagingData, textStatus, jqXHR)
|
||||
{
|
||||
if(pageObj.refreshPagination)
|
||||
pageObj.refreshPagination(pagingData.total, pagingData.page, pagingData.pageSize);
|
||||
};
|
||||
|
||||
/**
|
||||
* 集成data_page_obj_searchform_js.jsp的默认实现。
|
||||
*/
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.searchParam = searchParam;
|
||||
|
||||
pageObj.refresh();
|
||||
};
|
||||
|
||||
/**
|
||||
* 集成page_obj_pagination.jsp的默认实现。
|
||||
*/
|
||||
pageObj.paging = function(pagingParam)
|
||||
{
|
||||
pageObj.pagingParam = pagingParam;
|
||||
pageObj.refresh();
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* 构建ajax数据表格选项。
|
||||
* 此ajax选项支持两个回调函数:
|
||||
* pageObj.dataTableAjaxParam() 用于扩展ajax请求参数;
|
||||
* pageObj.dataTableAjaxSuccess(pagingData, textStatus, jqXHR) ajax成功回调函数;
|
||||
* @param columns 必选,列元数据
|
||||
* @param url 必选,ajax请求URL
|
||||
* @param ajaxSuccessCallback 可选,ajax成功回调函数,function(pagingData, textStatus, jqXHR){}
|
||||
* @param settings 可选,其他选项
|
||||
*/
|
||||
pageObj.buildDataTableSettingsAjax = function(columns, url, settings)
|
||||
{
|
||||
settings = $.extend(
|
||||
{
|
||||
"serverSide": true,
|
||||
"columns" : columns,
|
||||
"ajax" : function(data, callback, settings)
|
||||
{
|
||||
var nameOrder = [];
|
||||
|
||||
for(var i=0; i<data.order.length; i++)
|
||||
nameOrder[i] = { "name" : data.columns[data.order[i].column].data, "type" : data.order[i].dir };
|
||||
|
||||
var myData = undefined;
|
||||
|
||||
if($.isFunction(pageObj.dataTableAjaxParam))
|
||||
myData = pageObj.dataTableAjaxParam();
|
||||
else
|
||||
myData = pageObj.dataTableAjaxParam;
|
||||
|
||||
var param = $.extend({ "order" : nameOrder }, myData);
|
||||
|
||||
$.ajax(
|
||||
{
|
||||
url : url,
|
||||
dataType : "json",
|
||||
type : "POST",
|
||||
data : param,
|
||||
success : function(data, textStatus, jqXHR)
|
||||
{
|
||||
var isPagingData = (data.page != undefined && data.pageSize != undefined);
|
||||
|
||||
if(isPagingData)
|
||||
{
|
||||
data.data = data.items;
|
||||
callback(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
var tableData = { "data" : data };
|
||||
callback(tableData);
|
||||
}
|
||||
|
||||
if(pageObj.dataTableAjaxSuccess)
|
||||
pageObj.dataTableAjaxSuccess(data, textStatus, jqXHR);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
settings);
|
||||
|
||||
return pageObj.buildDataTableSettings(settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* 构建本地数据表格选项。
|
||||
* @param columns 必选,列元数据
|
||||
* @param data 可选,初始数据
|
||||
* @param settings 可选,其他选项
|
||||
*/
|
||||
pageObj.buildDataTableSettingsLocal = function(columns, data, settings)
|
||||
{
|
||||
settings = $.extend(
|
||||
{
|
||||
"columns" : columns,
|
||||
"data" : (data ? data : [])
|
||||
},
|
||||
settings);
|
||||
|
||||
return pageObj.buildDataTableSettings(settings);
|
||||
};
|
||||
|
||||
/**
|
||||
* 构建表格选项。
|
||||
* @param settings 必选,选项
|
||||
*/
|
||||
pageObj.buildDataTableSettings = function(settings)
|
||||
{
|
||||
var newColumns = [
|
||||
{ title : "<fmt:message key='select' />", data : "", defaultContent: "", width : "3em", orderable : false, render : pageObj.renderCheckColumn, className : "column-check" }
|
||||
{
|
||||
title : "<fmt:message key='select' />", data : "", defaultContent: "", width : "3em",
|
||||
orderable : false, render : pageObj.renderCheckColumn, className : "column-check"
|
||||
}
|
||||
];
|
||||
newColumns = newColumns.concat(columns);
|
||||
newColumns = newColumns.concat(settings.columns);
|
||||
|
||||
var settings=
|
||||
settings = $.extend(
|
||||
{
|
||||
"scrollX": true,
|
||||
"scrollY" : pageObj.calTableHeight(),
|
||||
|
@ -48,12 +186,11 @@ pageObj.sort = undefined;
|
|||
"paging" : false,
|
||||
"searching" : false,
|
||||
"select" : { style : 'os' },
|
||||
"data": (initDatas || []),
|
||||
"order": [[1, "asc"]],
|
||||
"columns": newColumns,
|
||||
"language":
|
||||
{
|
||||
"emptyTable": "<fmt:message key='noData' />"
|
||||
"emptyTable": "<fmt:message key='dataTables.noData' />",
|
||||
"zeroRecords" : "<fmt:message key='dataTables.zeroRecords' />"
|
||||
},
|
||||
"createdRow": function(row, data, dataIndex)
|
||||
{
|
||||
|
@ -70,56 +207,18 @@ pageObj.sort = undefined;
|
|||
pageObj.table.DataTable().row(tr).select();
|
||||
});
|
||||
}
|
||||
};
|
||||
},
|
||||
settings);
|
||||
|
||||
settings.columns = newColumns;
|
||||
|
||||
return settings;
|
||||
};
|
||||
|
||||
pageObj.initTable = function(tableSettings)
|
||||
pageObj.initDataTable = function(tableSettings)
|
||||
{
|
||||
pageObj.tableSettings = tableSettings;
|
||||
pageObj.table.dataTable(tableSettings)
|
||||
.on("order.dt", function(event, settings)
|
||||
{
|
||||
var doSort = false;
|
||||
|
||||
var currentOrder = pageObj.getOrder();
|
||||
|
||||
if(!pageObj.previousOrder)
|
||||
doSort=true;
|
||||
else
|
||||
{
|
||||
if(pageObj.previousOrder.length != currentOrder.length)
|
||||
doSort = true;
|
||||
else
|
||||
{
|
||||
var po = pageObj.previousOrder;
|
||||
var co = currentOrder;
|
||||
|
||||
for(var i=0; i<po.length; i++)
|
||||
{
|
||||
if(po[i][0] != co[i][0] || po[i][1] != co[i][1])
|
||||
{
|
||||
doSort = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(doSort)
|
||||
{
|
||||
if(pageObj.sort)
|
||||
{
|
||||
var propNameOrder = pageObj.copyOrder(currentOrder, pageObj.tableSettings.columns);
|
||||
pageObj.sort(propNameOrder, currentOrder);
|
||||
}
|
||||
|
||||
pageObj.previousOrder = pageObj.copyOrder(currentOrder);
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
pageObj.table.dataTable(tableSettings);
|
||||
|
||||
$(".dataTables_scrollHead .column-check", pageObj.table.DataTable().table().container()).click(function()
|
||||
{
|
||||
|
@ -141,13 +240,9 @@ pageObj.sort = undefined;
|
|||
});
|
||||
};
|
||||
|
||||
pageObj.setPagingData = function(pagingData)
|
||||
pageObj.refresh = function()
|
||||
{
|
||||
pageObj.deleteAllRow();
|
||||
pageObj.addRowData(pagingData.items);
|
||||
|
||||
if(pageObj.refreshPagination)
|
||||
pageObj.refreshPagination(pagingData.total, pagingData.page, pagingData.pageSize);
|
||||
pageObj.table.DataTable().draw();
|
||||
};
|
||||
|
||||
pageObj.setTableData = function(tableDatas)
|
||||
|
@ -259,44 +354,6 @@ pageObj.sort = undefined;
|
|||
pageObj.table.DataTable().rows().remove();
|
||||
};
|
||||
|
||||
pageObj.getOrder = function()
|
||||
{
|
||||
var table = pageObj.table.DataTable();
|
||||
|
||||
return table.order();
|
||||
};
|
||||
|
||||
pageObj.getOrderTyped = function()
|
||||
{
|
||||
var order = pageObj.getOrder();
|
||||
return pageObj.copyOrder(order, pageObj.tableSettings.columns);
|
||||
};
|
||||
|
||||
pageObj.copyOrder = function(order, columns)
|
||||
{
|
||||
var target = [];
|
||||
|
||||
for(var i=0; i<order.length; i++)
|
||||
{
|
||||
if(columns)
|
||||
{
|
||||
target[i] =
|
||||
{
|
||||
"name" : columns[order[i][0]].data,
|
||||
"type" : order[i][1]
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
target[i] = [];
|
||||
target[i][0] = order[i][0];
|
||||
target[i][1] = order[i][1];
|
||||
}
|
||||
}
|
||||
|
||||
return target;
|
||||
};
|
||||
|
||||
//表格高度自适应
|
||||
$(window).on('resize', function(e)
|
||||
{
|
||||
|
@ -304,9 +361,12 @@ pageObj.sort = undefined;
|
|||
|
||||
pageObj.tableResizeTimer = setTimeout(function()
|
||||
{
|
||||
var table = pageObj.table.DataTable();
|
||||
pageObj.element('.dataTables_scrollBody').css('height', pageObj.calTableHeight()+"px");
|
||||
table.draw();
|
||||
var width = pageObj.calTableWidth();
|
||||
var height = pageObj.calTableHeight();
|
||||
|
||||
pageObj.element('.dataTables_scrollHeadInner').css('width', width+"px");
|
||||
pageObj.element('.dataTables_scrollHeadInner > .dataTable').css('width', width+"px");
|
||||
pageObj.element('.dataTables_scrollBody').css('height', height+"px");
|
||||
},
|
||||
250);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<%--
|
||||
/*
|
||||
* Copyright 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
--%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%--
|
||||
查询表单HTML片段。
|
||||
--%>
|
||||
<form id="${pageId}-searchForm" class="search-form" action="#">
|
||||
<div class="ui-widget ui-widget-content keyword-widget"><input name="keyword" type="text" class="ui-widget ui-widget-content input-keyword" /></div>
|
||||
<input name="submit" type="submit" value="<fmt:message key='query' />" />
|
||||
</form>
|
|
@ -0,0 +1,44 @@
|
|||
<%--
|
||||
/*
|
||||
* Copyright 2018 datagear.tech. All Rights Reserved.
|
||||
*/
|
||||
--%>
|
||||
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||||
<%--
|
||||
查询表单JS片段。
|
||||
|
||||
依赖:
|
||||
page_js_obj.jsp
|
||||
page_obj_searchform_html.jsp
|
||||
|
||||
变量:
|
||||
//查询回调函数,不允许为null,格式为:function(searchParam){}
|
||||
pageObj.search = undefined;
|
||||
--%>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.searchForm = pageObj.element("#${pageId}-searchForm");
|
||||
|
||||
pageObj.searchForm.submit(function()
|
||||
{
|
||||
var searchParam = pageObj.getSearchParam();
|
||||
pageObj.search(searchParam);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
pageObj.getSearchParam = function()
|
||||
{
|
||||
var param =
|
||||
{
|
||||
"keyword" : $.trim(pageObj.element("input[name='keyword']", pageObj.searchForm).val())
|
||||
};
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
pageObj.element("input:submit", pageObj.searchForm).button();
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
|
@ -85,7 +85,7 @@ if(loginUser == null)
|
|||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
|
||||
//需要先渲染按钮,不然对话框尺寸不合适,出现滚动条
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element()).button();
|
||||
$.initButtons(pageObj.element());
|
||||
//元素设置了“checked='checked'”后icon显示有问题,这里先隐藏
|
||||
$("input[type=checkbox]", pageObj.element()).checkboxradio({icon:false});
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@
|
|||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
|
||||
//需要先渲染按钮,不然对话框尺寸不合适,出现滚动条
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element()).button();
|
||||
$.initButtons(pageObj.element());
|
||||
//元素设置了“checked='checked'”后icon显示有问题,这里先隐藏
|
||||
$("input[type=checkbox]", pageObj.element()).checkboxradio({icon:false});
|
||||
|
||||
|
|
|
@ -158,9 +158,10 @@ String loginUrl = request.getContextPath() + "/login";
|
|||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
//需要先渲染按钮,不然对话框尺寸不合适,出现滚动条
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element()).button();
|
||||
$.initButtons(pageObj.element());
|
||||
|
||||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
|
||||
pageObj.element("#viewResetPasswordAdminReqHistoryLink").click(function()
|
||||
{
|
||||
|
|
|
@ -22,10 +22,7 @@
|
|||
<div id="${pageId}" class="page-data-grid page-data-grid-reset-password-request-history">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<form id="${pageId}-searchForm" class="search-form" action="#">
|
||||
<div class="ui-widget ui-widget-content keyword-widget"><input name="keyword" type="text" class="ui-widget ui-widget-content input-keyword" /></div>
|
||||
<input name="submit" type="submit" value="<fmt:message key='query' />" />
|
||||
</form>
|
||||
<%@ include file="include/page_obj_searchform.html.jsp" %>
|
||||
</div>
|
||||
<div class="operation">
|
||||
</div>
|
||||
|
@ -42,77 +39,17 @@
|
|||
</div>
|
||||
<%}%>
|
||||
<%@ include file="include/page_js_obj.jsp" %>
|
||||
<%@ include file="include/page_obj_searchform_js.jsp" %>
|
||||
<%@ include file="include/page_obj_pagination.jsp" %>
|
||||
<%@ include file="include/page_obj_grid.jsp" %>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".head")).button();
|
||||
|
||||
pageObj.url = function(action)
|
||||
{
|
||||
return contextPath + "/resetPasswordRequestHistory/" + action;
|
||||
};
|
||||
|
||||
pageObj.searchForm = pageObj.element(".search-form");
|
||||
pageObj.searchForm.submit(function()
|
||||
{
|
||||
var searchParam = pageObj.getSearchParam();
|
||||
|
||||
pageObj.search(searchParam);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null, null);
|
||||
};
|
||||
|
||||
pageObj.paging = function(pagingParam)
|
||||
{
|
||||
pageObj.refresh(null, pagingParam, null);
|
||||
return false;
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, null, order);
|
||||
};
|
||||
|
||||
pageObj.refresh = function(searchParam, pagingParam, order)
|
||||
{
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!pagingParam)
|
||||
pagingParam = pageObj.getPagingParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
|
||||
var url = pageObj.url("pagingQueryData");
|
||||
|
||||
var param = {};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, pagingParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(pagingData)
|
||||
{
|
||||
pageObj.setPagingData(pagingData);
|
||||
});
|
||||
};
|
||||
|
||||
pageObj.getSearchParam = function()
|
||||
{
|
||||
var param =
|
||||
{
|
||||
"keyword" : $.trim(pageObj.element("input[name='keyword']", pageObj.searchForm).val())
|
||||
};
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
pageObj.buildTableColumValueOption = function(title, data)
|
||||
{
|
||||
var option =
|
||||
|
@ -135,11 +72,12 @@
|
|||
pageObj.buildTableColumValueOption("<fmt:message key='resetPasswordRequestHistory.username' />", "resetPasswordRequest.user.name"),
|
||||
pageObj.buildTableColumValueOption("<fmt:message key='resetPasswordRequestHistory.effectiveTime' />", "effectiveTime"),
|
||||
];
|
||||
var tableSettings = pageObj.getTableSettings(tableColumns);
|
||||
tableSettings.order=[[1,"desc"]];
|
||||
pageObj.initTable(tableSettings);
|
||||
|
||||
pageObj.initPagination();
|
||||
pageObj.refresh();
|
||||
|
||||
var tableSettings = pageObj.buildDataTableSettingsAjax(tableColumns, pageObj.url("pagingQueryData"));
|
||||
tableSettings.order=[[1,"desc"]];
|
||||
pageObj.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
|
|
|
@ -222,7 +222,7 @@ boolean readonly = ("true".equalsIgnoreCase(getStringValue(request, SchemaContro
|
|||
pageObj.element("input[name='shared']").checkboxradio({icon:false});
|
||||
pageObj.element(".schema-shared-radios").controlgroup();
|
||||
|
||||
$("input:submit, input:button, input:reset, button", pageObj.page).button();
|
||||
$.initButtons(pageObj.element());
|
||||
|
||||
if(pageObj.isDriverEntityEmpty)
|
||||
pageObj.schemaDriverEntityFormItem.hide();
|
||||
|
|
|
@ -105,7 +105,8 @@ boolean isAdd = "saveAdd".equals(formAction);
|
|||
{
|
||||
pageObj.form = pageObj.element("#${pageId}-form");
|
||||
|
||||
pageObj.element("input:submit, input:button, input:reset, button, .fileinput-button").button();
|
||||
$.initButtons(pageObj.element());
|
||||
|
||||
<%--禁用新建管理员账号功能
|
||||
pageObj.element("input[name='admin']").checkboxradio({icon:false});
|
||||
pageObj.element(".user-admin-radios").controlgroup();
|
||||
|
|
|
@ -29,10 +29,7 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, AbstractCo
|
|||
<div id="${pageId}" class="page-data-grid page-data-grid-user">
|
||||
<div class="head">
|
||||
<div class="search">
|
||||
<form id="${pageId}-searchForm" class="search-form" action="#">
|
||||
<div class="ui-widget ui-widget-content keyword-widget"><input name="keyword" type="text" class="ui-widget ui-widget-content input-keyword" /></div>
|
||||
<input name="submit" type="submit" value="<fmt:message key='query' />" />
|
||||
</form>
|
||||
<%@ include file="../include/page_obj_searchform.html.jsp" %>
|
||||
</div>
|
||||
<div class="operation">
|
||||
<%if(selectonly){%>
|
||||
|
@ -58,68 +55,18 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, AbstractCo
|
|||
</div>
|
||||
<%}%>
|
||||
<%@ include file="../include/page_js_obj.jsp" %>
|
||||
<%@ include file="../include/page_obj_searchform_js.jsp" %>
|
||||
<%@ include file="../include/page_obj_grid.jsp" %>
|
||||
<script type="text/javascript">
|
||||
(function(pageObj)
|
||||
{
|
||||
$("input:submit, input:button, input:reset, button", pageObj.element(".head")).button();
|
||||
$.initButtons(pageObj.element(".operation"));
|
||||
|
||||
pageObj.url = function(action)
|
||||
{
|
||||
return contextPath + "/user/" + action;
|
||||
};
|
||||
|
||||
pageObj.searchForm = pageObj.element(".search-form");
|
||||
pageObj.searchForm.submit(function()
|
||||
{
|
||||
var searchParam = pageObj.getSearchParam();
|
||||
|
||||
pageObj.search(searchParam);
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
pageObj.search = function(searchParam)
|
||||
{
|
||||
pageObj.refresh(searchParam, null);
|
||||
};
|
||||
|
||||
pageObj.sort = function(order)
|
||||
{
|
||||
pageObj.refresh(null, order);
|
||||
};
|
||||
|
||||
pageObj.refresh = function(searchParam, order)
|
||||
{
|
||||
if(!searchParam)
|
||||
searchParam = pageObj.getSearchParam();
|
||||
if(!order)
|
||||
order = pageObj.getOrderTyped();
|
||||
|
||||
var url = pageObj.url("queryData");
|
||||
|
||||
var param = {};
|
||||
|
||||
$.extend(param, searchParam);
|
||||
$.extend(param, { "order" : order });
|
||||
|
||||
$.getJSONOnPost(url, param, function(data)
|
||||
{
|
||||
pageObj.setTableData(data);
|
||||
});
|
||||
};
|
||||
|
||||
pageObj.getSearchParam = function()
|
||||
{
|
||||
var param =
|
||||
{
|
||||
"keyword" : $.trim(pageObj.element("input[name='keyword']", pageObj.searchForm).val())
|
||||
};
|
||||
|
||||
return param;
|
||||
};
|
||||
|
||||
<%if(!selectonly){%>
|
||||
pageObj.element("input[name=addButton]").click(function()
|
||||
{
|
||||
|
@ -179,14 +126,7 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, AbstractCo
|
|||
{
|
||||
"confirm" : function()
|
||||
{
|
||||
var data = "";
|
||||
for(var i=0; i< rows.length; i++)
|
||||
{
|
||||
if(data != "")
|
||||
data += "&";
|
||||
|
||||
data += "id=" + rows[i].id;
|
||||
}
|
||||
var data = $.getPropertyParamString(rows, "id");
|
||||
|
||||
$.post(pageObj.url("delete"), data, function()
|
||||
{
|
||||
|
@ -248,9 +188,8 @@ boolean selectonly = ("true".equalsIgnoreCase(getStringValue(request, AbstractCo
|
|||
pageObj.buildTableColumValueOption("<fmt:message key='user.admin' />", "admin"),
|
||||
pageObj.buildTableColumValueOption("<fmt:message key='user.createTime' />", "createTime")
|
||||
];
|
||||
var tableSettings = pageObj.getTableSettings(tableColumns);
|
||||
pageObj.initTable(tableSettings);
|
||||
pageObj.refresh();
|
||||
var tableSettings = pageObj.buildDataTableSettingsAjax(tableColumns, pageObj.url("queryData"));
|
||||
pageObj.initDataTable(tableSettings);
|
||||
})
|
||||
(${pageId});
|
||||
</script>
|
||||
|
|
|
@ -353,6 +353,14 @@
|
|||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始化指定元素内的所有按钮。
|
||||
*/
|
||||
initButtons : function($parent)
|
||||
{
|
||||
$("input:submit, input:button, input:reset, button", $parent).button();
|
||||
},
|
||||
|
||||
/**
|
||||
* 提示成功。
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
/*! Copyright 2012, Ben Lin (http://dreamerslab.com/)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Version: 1.0.19
|
||||
*
|
||||
* Requires: jQuery >= 1.2.3
|
||||
*/
|
||||
;( function ( factory ) {
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD. Register module depending on jQuery using requirejs define.
|
||||
define( ['jquery'], factory );
|
||||
} else {
|
||||
// No AMD.
|
||||
factory( jQuery );
|
||||
}
|
||||
}( function ( $ ){
|
||||
$.fn.addBack = $.fn.addBack || $.fn.andSelf;
|
||||
|
||||
$.fn.extend({
|
||||
|
||||
actual : function ( method, options ){
|
||||
// check if the jQuery method exist
|
||||
if( !this[ method ]){
|
||||
throw '$.actual => The jQuery method "' + method + '" you called does not exist';
|
||||
}
|
||||
|
||||
var defaults = {
|
||||
absolute : false,
|
||||
clone : false,
|
||||
includeMargin : false,
|
||||
display : 'block'
|
||||
};
|
||||
|
||||
var configs = $.extend( defaults, options );
|
||||
|
||||
var $target = this.eq( 0 );
|
||||
var fix, restore;
|
||||
|
||||
if( configs.clone === true ){
|
||||
fix = function (){
|
||||
var style = 'position: absolute !important; top: -1000 !important; ';
|
||||
|
||||
// this is useful with css3pie
|
||||
$target = $target.
|
||||
clone().
|
||||
attr( 'style', style ).
|
||||
appendTo( 'body' );
|
||||
};
|
||||
|
||||
restore = function (){
|
||||
// remove DOM element after getting the width
|
||||
$target.remove();
|
||||
};
|
||||
}else{
|
||||
var tmp = [];
|
||||
var style = '';
|
||||
var $hidden;
|
||||
|
||||
fix = function (){
|
||||
// get all hidden parents
|
||||
$hidden = $target.parents().addBack().filter( ':hidden' );
|
||||
style += 'visibility: hidden !important; display: ' + configs.display + ' !important; ';
|
||||
|
||||
if( configs.absolute === true ) style += 'position: absolute !important; ';
|
||||
|
||||
// save the origin style props
|
||||
// set the hidden el css to be got the actual value later
|
||||
$hidden.each( function (){
|
||||
// Save original style. If no style was set, attr() returns undefined
|
||||
var $this = $( this );
|
||||
var thisStyle = $this.attr( 'style' );
|
||||
|
||||
tmp.push( thisStyle );
|
||||
// Retain as much of the original style as possible, if there is one
|
||||
$this.attr( 'style', thisStyle ? thisStyle + ';' + style : style );
|
||||
});
|
||||
};
|
||||
|
||||
restore = function (){
|
||||
// restore origin style values
|
||||
$hidden.each( function ( i ){
|
||||
var $this = $( this );
|
||||
var _tmp = tmp[ i ];
|
||||
|
||||
if( _tmp === undefined ){
|
||||
$this.removeAttr( 'style' );
|
||||
}else{
|
||||
$this.attr( 'style', _tmp );
|
||||
}
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
fix();
|
||||
// get the actual value with user specific methed
|
||||
// it can be 'width', 'height', 'outerWidth', 'innerWidth'... etc
|
||||
// configs.includeMargin only works for 'outerWidth' and 'outerHeight'
|
||||
var actual = /(outer)/.test( method ) ?
|
||||
$target[ method ]( configs.includeMargin ) :
|
||||
$target[ method ]();
|
||||
|
||||
restore();
|
||||
// IMPORTANT, this plugin only return the value of the first element
|
||||
return actual;
|
||||
}
|
||||
});
|
||||
}));
|
Loading…
Reference in New Issue