提交 e73310b6 编写于 作者: U unknown

创建widget.Paging,分页组件,并在视图中使用

上级 1bb5d719
{
"pagingBar" : {
"float": "left",
"margin-left": "10px",
"height": "24px",
"color": "#777777"
},
"firstPage" : {
"height": "24px",
"width": "80px",
"border": "1px solid #e6e6e6",
"color": "#777777",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"margin-right": "10px",
"background-color": "#ffffff",
"float": "left"
},
"firstPage_over" : {
"background-color": "#f1f1f1"
},
"lastPage" : {
"height": "24px",
"width": "80px",
"border": "1px solid #e6e6e6",
"color": "#777777",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"background-color": "#ffffff",
"float": "left"
},
"lastPage_over" : {
"background-color": "#f1f1f1"
},
"prePage" : {
"width": "24px",
"height": "24px",
"border": "1px solid #e6e6e6",
"color": "#777777",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"background-color": "#ffffff",
"float": "left",
"margin-right": "10px",
"background": "url(/o2_core/o2/widget/$Paging/default/icon/left.png) no-repeat center center"
},
"prePage_over" : {
"background-color": "#f1f1f1"
},
"pageTurnContainer" : {
"float" : "left"
},
"pageItem" : {
"width": "24px",
"height": "24px",
"border": "1px solid #e6e6e6",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"float": "left",
"margin-right": "10px",
"background-color": "#ffffff",
"color": "#777777"
},
"pageItem_over" : {
"background-color": "#f1f1f1"
},
"currentPage" : {
"width": "24px",
"height": "24px",
"border": "1px solid #e6e6e6",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"float": "left",
"margin-right": "10px",
"background-color": "#4a90e2",
"color": "#ffffff"
},
"pageJumper" : {
"float" : "left",
"height" : "20px",
"line-height" : "20px",
"text-align" : "center",
"width" : "20px",
"margin-left" : "5px",
"border" : "1px solid #ddd"
},
"pageJumper_over" : {
"border" : "1px solid #43AAFA"
},
"pageJumperText" : {
"float" : "left",
"height" : "20px",
"padding" : "2px 5px",
"text-align" : "center",
"line-height" : "20px",
"margin-right" : "5px"
},
"nextPage" : {
"width": "24px",
"height": "24px",
"border": "1px solid #e6e6e6",
"color": "#777777",
"text-align": "center",
"line-height": "24px",
"cursor": "pointer",
"background-color": "#ffffff",
"float": "left",
"margin-right": "10px",
"background": "url(/o2_core/o2/widget/$Paging/default/icon/right.png) no-repeat center center"
},
"nextPage_over" : {
"background-color": "#f1f1f1"
}
}
\ No newline at end of file
{
"pagingBar" : {
"float" : "right",
"margin-right" : "10px",
"padding-left" : "10px",
"overflow" : "hidden",
"height" : "36px",
"line-height" : "36px",
"margin-bottom" : "10px",
"background" : "#fff",
"color" : "#333"
},
"firstPage" : {
"float" : "left"
},
"firstPage_over" : {
},
"lastPage" : {
"float" : "left"
},
"lastPage_over" : {
},
"prePage" : {
"float" : "left",
"width" : "16px",
"height" : "20px",
"line-height" : "20px",
"text-align" : "center",
"padding" : "2px 5px",
"border" : "1px solid #f3f3f3",
"margin" : "5px",
"cursor" : "pointer",
"background": "url(/o2_core/o2/widget/$Paging/forum/icon/left.png) no-repeat center center",
"background-color" : "#f3f3f3"
},
"prePage_over" : {
"border" : "1px solid #43AAFA",
"background-color" : "#fff",
"color" : "#43AAFA"
},
"pageTurnContainer" : {
"float" : "left"
},
"pageItem" : {
"float" : "left",
"height" : "20px",
"min-width" : "16px",
"line-height" : "20px",
"text-align" : "center",
"padding" : "2px 5px",
"border" : "1px solid #f3f3f3",
"background-color" : "#f3f3f3",
"cursor" : "pointer",
"color" : "#333",
"margin" : "5px"
},
"pageItem_over" : {
"border" : "1px solid #43AAFA",
"background-color" : "#fff",
"color" : "#43AAFA"
},
"currentPage" : {
"float" : "left",
"height" : "20px",
"width" : "16px",
"line-height" : "20px",
"text-align" : "center",
"padding" : "2px 5px",
"border" : "1px solid #43AAFA",
"color" : "#fff",
"margin" : "5px",
"font-weight" : "bold",
"background-color" : "#43aafa"
},
"pageJumper" : {
"float" : "left",
"height" : "20px",
"line-height" : "20px",
"text-align" : "center",
"width" : "20px",
"margin-top" : "5px",
"margin-bottom" : "5px",
"margin-left" : "5px",
"border" : "1px solid #ddd"
},
"pageJumper_over" : {
"border" : "1px solid #43AAFA"
},
"pageJumperText" : {
"float" : "left",
"height" : "20px",
"padding" : "2px 5px",
"text-align" : "center",
"line-height" : "20px",
"margin-top" : "5px",
"margin-bottom" : "5px",
"margin-right" : "5px"
},
"nextPage" : {
"float" : "left",
"width" : "16px",
"height" : "20px",
"line-height" : "20px",
"text-align" : "center",
"padding" : "2px 5px",
"border" : "1px solid #f3f3f3",
"margin" : "5px",
"cursor" : "pointer",
"color" : "#333",
"background": "url(/o2_core/o2/widget/$Paging/forum/icon/right.png) no-repeat center center",
"background-color" : "#f3f3f3"
},
"nextPage_over" : {
"border" : "1px solid #43AAFA",
"background-color" : "#fff",
"color" : "#43AAFA"
}
}
\ No newline at end of file
o2.widget = o2.widget || {};
o2.require("o2.widget.Common", null, false);
o2.widget.Paging = new Class({
Implements: [Options, Events],
Extends: o2.widget.Common,
options: {
style : "default",
countPerPage: 20,
visiblePages: 10,
currentPage: 1,
itemSize: 0,
pageSize: 0,
hasNextPage: true,
hasPrevPage: true,
hasTruningBar: true,
hasJumper: true,
hiddenWithDisable: false,
hiddenWithNoItem: true,
text: {
prePage: "",
nextPage: "",
firstPage: "",
lastPage: ""
}
},
initialize: function (node, options, css) {
this.setOptions(options || {});
this.container = $(node);
this.path = o2.session.path + "/widget/$Paging/";
this.cssPath = o2.session.path + "/widget/$Paging/" + this.options.style + "/css.wcss";
this._loadCss();
if (css) {
this.css = Object.clone(this.css);
this.css = Object.merge(this.css, css);
}
},
load: function () {
this.fireEvent("queryLoad", this);
this.options.pageSize = Math.ceil(this.options.itemSize / this.options.countPerPage);
if ( this.options.pageSize == 0 && this.options.hiddenWithNoItem) return;
this.container.empty();
this.createNode();
this.fireEvent("postLoad", this);
},
createNode: function() {
var _self = this;
this.node = new Element("div.pagingBar", {styles: this.css.pagingBar}).inject(this.container);
var i, max, min;
var showWithDisable = !this.options.hiddenWithDisable;
var pageSize = this.options.pageSize;
var currentPage = this.options.currentPage;
var visiblePages = this.options.visiblePages;
var halfCount = Math.floor(visiblePages / 2);
if (pageSize <= visiblePages) {
min = 1;
max = pageSize;
} else if (currentPage + halfCount > pageSize) {
min = pageSize - visiblePages;
max = pageSize;
} else if (currentPage - halfCount < 1) {
min = 1;
max = visiblePages;
} else {
min = currentPage - halfCount;
max = currentPage + halfCount;
}
if (min > 1 || !this.options.hiddenWithDisable )this.createFirst();
if (this.options.hasPrevPage && ( currentPage != 1 || showWithDisable ) ){
this.createPrev();
}
if( this.options.hasTruningBar ){
this.pageTurnContainer = new Element("div", {
styles : this.css.pageTurnContainer
}).inject( this.node );
this.pageTurnNodes = [];
for (i = min; i <= max; i++) {
if (currentPage == i) {
this.currentPage = new Element("div.currentPage", {
"styles": this.css.currentPage,
"text" : i
}).inject(this.pageTurnContainer);
} else {
this.pageTurnNodes.push( this.createPageTurnNode(i) );
}
}
}
if (this.options.hasJumper) {
this.createPageJumper();
}
if (this.options.hasNextPage && ( currentPage != pageSize || showWithDisable )){
this.createNext();
}
if( max < pageSize || showWithDisable )this.createLast();
},
createFirst : function(){
var firstPage = this.firstPage = new Element("div.firstPage", {
styles: this.css.firstPage
}).inject(this.node);
if (this.options.text.firstPage) firstPage.set("text", this.options.text.firstPage);
firstPage.addEvents({
"mouseover": function (ev) {
ev.target.setStyles(this.css.firstPage_over)
}.bind(this),
"mouseout": function (ev) {
ev.target.setStyles(this.css.firstPage)
}.bind(this),
"click": function () {
this.gotoPage(1)
}.bind(this)
})
},
createLast : function(){
var lastPage = this.lastPage = new Element("div.lastPage", {
styles: this.css.lastPage
}).inject(this.node);
if (this.options.text.lastPage) lastPage.set("text", this.options.text.lastPage);
lastPage.addEvents({
"mouseover": function (ev) {
ev.target.setStyles(this.css.lastPage_over)
}.bind(this),
"mouseout": function (ev) {
ev.target.setStyles(this.css.lastPage)
}.bind(this),
"click": function () {
this.gotoPage( this.options.pageSize )
}.bind(this)
})
},
createPrev : function(){
var prePage = this.prePage = new Element("div.prePage", {
styles: this.css.prePage
}).inject(this.node);
if (this.options.text.prePage) prePage.set("text", this.options.text.prePage);
prePage.addEvents({
"mouseover": function (ev) {
ev.target.setStyles(this.css.prePage_over)
}.bind(this),
"mouseout": function (ev) {
ev.target.setStyles(this.css.prePage)
}.bind(this),
"click": function () {
this.gotoPage(this.options.currentPage - 1)
}.bind(this)
});
},
createNext : function(){
var nextPage = this.nextPage = new Element("div.nextPage", {
styles: this.css.nextPage
}).inject(this.node);
if (this.options.text.nextPage) nextPage.set("text", this.options.text.nextPage);
nextPage.addEvents({
"mouseover": function (ev) {
ev.target.setStyles(this.css.nextPage_over)
}.bind(this),
"mouseout": function (ev) {
ev.target.setStyles(this.css.nextPage)
}.bind(this),
"click": function () {
this.gotoPage(this.options.currentPage + 1)
}.bind(this)
});
},
createPageTurnNode: function(i){
var pageTurnNode = new Element("div.pageItem", {
"styles": this.css.pageItem,
"text": i
}).inject(this.pageTurnContainer);
pageTurnNode.addEvents({
"mouseover": function (ev) {
ev.target.setStyles(this.css.pageItem_over)
}.bind(this),
"mouseout": function (ev) {
ev.target.setStyles(this.css.pageItem)
}.bind(this),
"click": function () {
this.obj.gotoPage(this.num)
}.bind({obj: this, num: i})
});
return pageTurnNode;
},
createPageJumper : function(){
var _self = this;
var pageJumper = this.pageJumper = new Element("input.pageJumper", {
"styles": this.css.pageJumper,
"title": "输入页码,按回车跳转"
}).inject(this.node);
this.pageJumperText = new Element("div.pageText", {
"styles": this.css.pageJumperText,
"text": "/" + this.options.pageSize
}).inject(this.node);
pageJumper.addEvents({
"focus": function (ev) {
ev.target.setStyles(this.css.pageJumper_over)
}.bind(this),
"blur": function (ev) {
ev.target.setStyles(this.css.pageJumper)
}.bind(this),
"keyup": function (e) {
this.value = this.value.replace(/[^0-9_]/g, '')
},
"keydown": function (e) {
if (e.code == 13 && this.value != "") {
_self.gotoPage(this.value);
e.stopPropagation();
//e.preventDefault();
}
}
});
},
gotoPage: function (num) {
if (num < 1 || num > this.options.pageSize) return;
this.fireEvent("jumpingPage", [num]);
this.options.currentPage = num;
this.load();
},
gotoItem: function (itemNum) {
var pageNum = Math.ceil(itemNum / this.options.countPerPage);
var index = itemNum % this.options.countPerPage;
this.fireEvent("jumpingPage", [pageNum, itemNum, index]);
this.options.currentPage = pageNum;
this.load();
}
});
\ No newline at end of file
......@@ -81,6 +81,53 @@ MWF.CMSMacro.CMSFormContext = new Class({
});
if( !MWF.Macro.ViewContext ){
MWF.Macro.ViewContext = new Class({
macroFunction: null,
environment: {},
initialize: function(view){
this.form = view;
var environment = {
"view": view,
"viewInfor": view.viewInfor,
"target": null,
"event": null
};
MWF.require("MWF.xScript.ViewEnvironment", null, false);
this.environment = new MWF.xScript.ViewEnvironment(environment);
},
setTarget: function(target){
if (target){
this.environment.target = target;
}else{
this.environment.target = null;
}
},
setEvent: function(event){
if (event){
this.environment.event = event;
}else{
this.environment.event = null;
}
},
exec: function(code, target){
this.setTarget(target);
var returnValue = MWF.Macro.exec(code, this.environment);
//this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
return returnValue;
//this.environment.data
},
fire: function(code, target, event){
this.setTarget(target);
this.setEvent(event);
return MWF.Macro.exec(code, this.environment);
}
});
}
JSONObject = function(o){
};
\ No newline at end of file
......@@ -165,49 +165,51 @@ MWF.Macro.PageContext = new Class({
}
});
MWF.Macro.ViewContext = new Class({
macroFunction: null,
environment: {},
initialize: function(view){
this.form = view;
var environment = {
"view": view,
"viewInfor": view.viewInfor,
"target": null,
"event": null
};
MWF.require("MWF.xScript.ViewEnvironment", null, false);
this.environment = new MWF.xScript.ViewEnvironment(environment);
},
setTarget: function(target){
if (target){
this.environment.target = target;
}else{
this.environment.target = null;
}
},
setEvent: function(event){
if (event){
this.environment.event = event;
}else{
this.environment.event = null;
}
},
exec: function(code, target){
this.setTarget(target);
var returnValue = MWF.Macro.exec(code, this.environment);
//this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
if( !MWF.Macro.ViewContext ) {
MWF.Macro.ViewContext = new Class({
macroFunction: null,
environment: {},
initialize: function (view) {
this.form = view;
var environment = {
"view": view,
"viewInfor": view.viewInfor,
"target": null,
"event": null
};
MWF.require("MWF.xScript.ViewEnvironment", null, false);
this.environment = new MWF.xScript.ViewEnvironment(environment);
},
setTarget: function (target) {
if (target) {
this.environment.target = target;
} else {
this.environment.target = null;
}
},
setEvent: function (event) {
if (event) {
this.environment.event = event;
} else {
this.environment.event = null;
}
},
exec: function (code, target) {
this.setTarget(target);
var returnValue = MWF.Macro.exec(code, this.environment);
//this.form.businessData.data = Object.merge(this.form.businessData.data, this.environment.data);
return returnValue;
//this.environment.data
return returnValue;
//this.environment.data
},
fire: function(code, target, event){
this.setTarget(target);
this.setEvent(event);
return MWF.Macro.exec(code, this.environment);
}
});
},
fire: function (code, target, event) {
this.setTarget(target);
this.setEvent(event);
return MWF.Macro.exec(code, this.environment);
}
});
}
JSONObject = function(o){
};
......@@ -88,6 +88,7 @@ MWF.xApplication.cms.QueryViewDesigner.widget.ViewFilter = new Class({
this.valueBooleanInput.setStyle("display", "none");
break;
case "datetimeValue":
case "dateTimeValue":
this.valueTextInput.setStyle("display", "none");
this.valueNumberInput.setStyle("display", "none");
this.valueDatetimeInput.setStyle("display", "block");
......@@ -169,6 +170,7 @@ MWF.xApplication.cms.QueryViewDesigner.widget.ViewFilter = new Class({
value = this.valueNumberInput.get("value").toFloat();
break;
case "datetimeValue":
case "dateTimeValue":
value = this.valueDatetimeInput.get("value");
break;
case "booleanValue":
......@@ -221,6 +223,7 @@ MWF.xApplication.cms.QueryViewDesigner.widget.ViewFilter = new Class({
this.valueNumberInput.set("value", data.value);
break;
case "datetimeValue":
case "dateTimeValue":
this.valueDatetimeInput.set("value", data.value);
break;
case "booleanValue":
......
......@@ -131,7 +131,7 @@
<td class="editTableValue"><select>
<option value="textValue" selected>文本</option>
<option value="numberValue">数字</option>
<option value="datetimeValue">日期</option>
<option value="dateTimeValue">日期</option>
<option value="booleanValue">布尔</option>
</select></td>
</tr>
......
......@@ -199,7 +199,7 @@
<td class="editTableValue"><select>
<option value="textValue" selected>文本</option>
<option value="numberValue">数字</option>
<option value="datetimeValue">日期</option>
<option value="dateTimeValue">日期</option>
<option value="booleanValue">布尔</option>
</select></td>
</tr>
......
......@@ -118,7 +118,7 @@
<td class="editTableValue"><select>
<option value="textValue" selected>文本</option>
<option value="numberValue">数字</option>
<option value="datetimeValue">日期</option>
<option value="dateTimeValue">日期</option>
<option value="booleanValue">布尔</option>
</select></td>
</tr>
......
......@@ -269,7 +269,7 @@
<td class="editTableValue"><select>
<option value="textValue" selected>文本</option>
<option value="numberValue">数字</option>
<option value="datetimeValue">日期</option>
<option value="dateTimeValue">日期</option>
<option value="booleanValue">布尔</option>
</select></td>
</tr>
......
......@@ -132,6 +132,7 @@ MWF.xApplication.process.ViewDesigner.widget.ViewFilter = new Class({
this.valueBooleanInput.setStyle("display", "none");
break;
case "datetimeValue":
case "dateTimeValue":
this.valueTextInput.setStyle("display", "none");
this.valueNumberInput.setStyle("display", "none");
this.valueDatetimeInput.setStyle("display", "block");
......@@ -277,6 +278,7 @@ MWF.xApplication.process.ViewDesigner.widget.ViewFilter = new Class({
value = this.valueNumberInput.get("value").toFloat();
break;
case "datetimeValue":
case "dateTimeValue":
value = this.valueDatetimeInput.get("value");
break;
case "booleanValue":
......@@ -332,6 +334,7 @@ MWF.xApplication.process.ViewDesigner.widget.ViewFilter = new Class({
this.valueNumberInput.set("value", data.value);
break;
case "datetimeValue":
case "dateTimeValue":
this.valueDatetimeInput.set("value", data.value);
break;
case "booleanValue":
......
MWF.xApplication.query = MWF.xApplication.query || {};
MWF.xApplication.query.Query = MWF.xApplication.query.Query || {};
MWF.require("MWF.widget.Common", null, false);
MWF.require("o2.widget.Paging", null, false);
MWF.require("MWF.xScript.Macro", null, false);
MWF.xDesktop.requireApp("query.Query", "lp.zh-cn", null, false);
MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
......@@ -634,75 +635,103 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
this.lookup(data);
}
},
_loadPageCountNode: function(){
this.viewPageContentNode.empty();
var size = this.viewPageAreaNode.getSize();
var w1 = this.viewPageFirstNode.getSize().x*2;
var w2 = this.viewPageContentNode.getStyle("margin-left").toInt();
var w = size.x-w1-w2;
var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt();
var count = (w/bw).toInt()-2;
if (count>10) count = 10;
this.showPageCount = Math.min(count, this.pages);
var tmp = this.showPageCount/2;
var n = tmp.toInt();
var left = this.currentPage-n;
if (left<=0) left = 1;
var right = this.showPageCount + left-1;
if (right>this.pages) right = this.pages;
left = right-this.showPageCount+1;
if (left<=1) left = 1;
this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode);
this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){
if (this.currentPage>1) this.currentPage--;
this.loadCurrentPageData();
}.bind(this));
for (i=left; i<=right; i++){
var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode);
if (i==this.currentPage){
node.setStyles(this.css.viewPageButtonNode_current);
}else{
this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){
this.currentPage = e.target.get("text").toInt();
this.loadCurrentPageData();
}.bind(this));
}
}
this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode);
this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){
if (this.currentPage<=this.pages-1) this.currentPage++;
this.loadCurrentPageData();
}.bind(this));
},
loadPageButtonEvent: function(node, over, out, down, click){
node.addEvents({
"mouseover": function(){node.setStyles(this.css[over])}.bind(this),
"mouseout": function(){node.setStyles(this.css[out])}.bind(this),
"mousedown": function(){node.setStyles(this.css[down])}.bind(this),
"mouseup": function(){node.setStyles(this.css[out])}.bind(this),
"click": click
});
},
_loadPageNode: function(){
// _loadPageCountNode: function(){
// this.viewPageContentNode.empty();
//
// var size = this.viewPageAreaNode.getSize();
// var w1 = this.viewPageFirstNode.getSize().x*2;
// var w2 = this.viewPageContentNode.getStyle("margin-left").toInt();
// var w = size.x-w1-w2;
//
// var bw = this.css.viewPageButtonNode.width.toInt()+this.css.viewPageButtonNode["margin-right"].toInt();
// var count = (w/bw).toInt()-2;
// if (count>10) count = 10;
// this.showPageCount = Math.min(count, this.pages);
//
// var tmp = this.showPageCount/2;
// var n = tmp.toInt();
// var left = this.currentPage-n;
// if (left<=0) left = 1;
// var right = this.showPageCount + left-1;
// if (right>this.pages) right = this.pages;
// left = right-this.showPageCount+1;
// if (left<=1) left = 1;
//
// this.viewPagePrevNode = new Element("div", {"styles": this.css.viewPagePrevButtonNode}).inject(this.viewPageContentNode);
// this.loadPageButtonEvent(this.viewPagePrevNode, "viewPagePrevButtonNode_over", "viewPagePrevButtonNode_up", "viewPagePrevButtonNode_down", function(){
// if (this.currentPage>1) this.currentPage--;
// this.loadCurrentPageData();
// }.bind(this));
//
// for (i=left; i<=right; i++){
// var node = new Element("div", {"styles": this.css.viewPageButtonNode, "text": i}).inject(this.viewPageContentNode);
// if (i==this.currentPage){
// node.setStyles(this.css.viewPageButtonNode_current);
// }else{
// this.loadPageButtonEvent(node, "viewPageButtonNode_over", "viewPageButtonNode_up", "viewPageButtonNode_down", function(e){
// this.currentPage = e.target.get("text").toInt();
// this.loadCurrentPageData();
// }.bind(this));
// }
// }
// this.viewPageNextNode = new Element("div", {"styles": this.css.viewPageNextButtonNode}).inject(this.viewPageContentNode);
// this.loadPageButtonEvent(this.viewPageNextNode, "viewPageNextButtonNode_over", "viewPageNextButtonNode_up", "viewPageNextButtonNode_down", function(){
// if (this.currentPage<=this.pages-1) this.currentPage++;
// this.loadCurrentPageData();
// }.bind(this));
// },
// loadPageButtonEvent: function(node, over, out, down, click){
// node.addEvents({
// "mouseover": function(){node.setStyles(this.css[over])}.bind(this),
// "mouseout": function(){node.setStyles(this.css[out])}.bind(this),
// "mousedown": function(){node.setStyles(this.css[down])}.bind(this),
// "mouseup": function(){node.setStyles(this.css[out])}.bind(this),
// "click": click
// });
// },
// _loadPageNode: function(){
// this.viewPageAreaNode.empty();
// this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode);
// this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode);
// this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode);
// this._loadPageCountNode();
//
// this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
// this.currentPage = 1;
// this.loadCurrentPageData();
// }.bind(this));
// this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
// this.currentPage = this.pages;
// this.loadCurrentPageData();
// }.bind(this));
// },
_loadPageNode : function(){
debugger;
this.viewPageAreaNode.empty();
this.viewPageFirstNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.firstPage}).inject(this.viewPageAreaNode);
this.viewPageContentNode = new Element("div", {"styles": this.css.viewPageContentNode}).inject(this.viewPageAreaNode);
this.viewPageLastNode = new Element("div", {"styles": this.css.viewPageFirstLastNode, "text": this.lp.lastPage}).inject(this.viewPageAreaNode);
this._loadPageCountNode();
this.loadPageButtonEvent(this.viewPageFirstNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
this.currentPage = 1;
this.loadCurrentPageData();
}.bind(this));
this.loadPageButtonEvent(this.viewPageLastNode, "viewPageFirstLastNode_over", "viewPageFirstLastNode_up", "viewPageFirstLastNode_down", function(){
this.currentPage = this.pages;
this.loadCurrentPageData();
}.bind(this));
this.paging = new o2.widget.Paging(this.viewPageAreaNode, {
countPerPage: this.json.pageSize || this.options.perPageCount,
visiblePages: 10,
currentPage: this.currentPage,
itemSize: this.count,
pageSize: this.pages,
hasNextPage: true,
hasPrevPage: true,
hasTruningBar: true,
hasJumper: true,
hiddenWithDisable: false,
hiddenWithNoItem: true,
text: {
prePage: "",
nextPage: "",
firstPage: this.lp.firstPage,
lastPage: this.lp.lastPage
},
onJumpingPage : function( pageNum, itemNum ){
this.currentPage = pageNum;
this.loadCurrentPageData();
}.bind(this)
});
this.paging.load();
},
_initPage: function(){
this.count = this.bundleItems.length;
......@@ -737,98 +766,6 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
}
}.bind(this));
},
//api 使用 开始
getParentEnvironment : function(){
return this.parentMacro ? this.parentMacro.environment : null;
},
getViewInfor : function(){
return this.json;
},
getPageInfor : function(){
return {
pages : this.pages,
perPageCount : this.options.perPageCount,
currentPageNumber : this.currentPage
};
},
getPageData : function () {
return this.gridJson;
},
toPage : function( pageNumber, callback ){
this.currentPage = pageNumber;
this.loadCurrentPageData( callback );
},
selectAll : function(){
var flag = this.json.select || this.viewJson.select || "none";
if ( flag==="multi"){
this.items.each( function (item) {
if( item.clazzType === "item" ){
item.selected();
}else{
item.expand();
if( item.items ){
item.items.each( function (it) {
it.selected();
})
}
}
})
}
},
unSelectAll : function(){
var flag = this.json.select || this.viewJson.select || "none";
if ( flag==="multi"){
this.items.each( function (item) {
if( item.clazzType === "item" ){
item.unSelected();
}else{
if(item.items){
item.items.each( function (it) {
it.unSelected();
})
}
}
})
}
},
setFilter : function( filter ){
if( !filter )filter = [];
if( typeOf( filter ) === "object" )filter = [ filter ];
this.json.filter = filter;
this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
},
switchView : function( json ){
debugger;
// json = {
// "application": application,
// "viewName": viewName,
// "isTitle": "yes",
// "select": "none",
// "titleStyles": titleStyles,
// "itemStyles": itemStyles,
// "isExpand": "no",
// "filter": filter
// }
this.node.setStyle("display", "block");
if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
this.searchMorph = null;
this.viewSearchCustomContentNode = null;
var newJson = Object.merge( Object.clone(this.originalJson), json );
this.container.empty();
this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
},
confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
},
alert: function (type, title, text, width, height) {
this.app.alert(type, "center", title, text, width, height);
},
notice: function (content, type, target, where, offset, option) {
this.app.notice(content, type, target, where, offset, option)
},
//api 使用 结束
loadCurrentPageData: function( callback ){
debugger;
//是否需要在翻页的时候清空之前的items ?
......@@ -1096,7 +1033,100 @@ MWF.xApplication.query.Query.Viewer = MWF.QViewer = new Class({
}
}
}.bind(this));
},
//api 使用 开始
getParentEnvironment : function(){
return this.parentMacro ? this.parentMacro.environment : null;
},
getViewInfor : function(){
return this.json;
},
getPageInfor : function(){
return {
pages : this.pages,
perPageCount : this.options.perPageCount,
currentPageNumber : this.currentPage
};
},
getPageData : function () {
return this.gridJson;
},
toPage : function( pageNumber, callback ){
this.currentPage = pageNumber;
this.loadCurrentPageData( callback );
},
selectAll : function(){
var flag = this.json.select || this.viewJson.select || "none";
if ( flag==="multi"){
this.items.each( function (item) {
if( item.clazzType === "item" ){
item.selected();
}else{
item.expand();
if( item.items ){
item.items.each( function (it) {
it.selected();
})
}
}
})
}
},
unSelectAll : function(){
var flag = this.json.select || this.viewJson.select || "none";
if ( flag==="multi"){
this.items.each( function (item) {
if( item.clazzType === "item" ){
item.unSelected();
}else{
if(item.items){
item.items.each( function (it) {
it.unSelected();
})
}
}
})
}
},
setFilter : function( filter ){
if( !filter )filter = [];
if( typeOf( filter ) === "object" )filter = [ filter ];
this.json.filter = filter;
this.createViewNode({"filterList": this.json.filter ? this.json.filter.clone() : null});
},
switchView : function( json ){
debugger;
// json = {
// "application": application,
// "viewName": viewName,
// "isTitle": "yes",
// "select": "none",
// "titleStyles": titleStyles,
// "itemStyles": itemStyles,
// "isExpand": "no",
// "filter": filter
// }
this.node.setStyle("display", "block");
if (this.loadingAreaNode) this.loadingAreaNode.setStyle("display", "block");
this.searchMorph = null;
this.viewSearchCustomContentNode = null;
var newJson = Object.merge( Object.clone(this.originalJson), json );
this.container.empty();
this.initialize( this.container, newJson, Object.clone(this.options), this.app, this.parentMacro);
},
confirm: function (type, e, title, text, width, height, ok, cancel, callback, mask, style) {
this.app.confirm(type, e, title, text, width, height, ok, cancel, callback, mask, style)
},
alert: function (type, title, text, width, height) {
this.app.alert(type, "center", title, text, width, height);
},
notice: function (content, type, target, where, offset, option) {
this.app.notice(content, type, target, where, offset, option)
}
//api 使用 结束
});
MWF.xApplication.query.Query.Viewer.Item = new Class({
......
......@@ -43,5 +43,8 @@
"iconOverStyle": "xform_blue_flat_over",
"customIconStyle" : "blue",
"customIconOverStyle" : "white"
},
"paging" : {
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册