提交 320ee0ac 编写于 作者: NoSubject's avatar NoSubject

Merge branch 'fix/doceditor_position' into 'develop'

公文编辑器取消双页,优化位置计算,增加pagePosition事件

See merge request o2oa/o2oa!413
...@@ -3178,7 +3178,7 @@ if (!window.o2) { ...@@ -3178,7 +3178,7 @@ if (!window.o2) {
"getScaleOffsets": function () { "getScaleOffsets": function () {
var hasGetBoundingClientRect = this.getBoundingClientRect; var hasGetBoundingClientRect = this.getBoundingClientRect;
//<1.4compat> //<1.4compat>
hasGetBoundingClientRect = hasGetBoundingClientRect && !Browser.Platform.ios; //hasGetBoundingClientRect = hasGetBoundingClientRect && !Browser.Platform.ios;
//</1.4compat> //</1.4compat>
if (hasGetBoundingClientRect) { if (hasGetBoundingClientRect) {
var bound = this.getBoundingClientRect(); var bound = this.getBoundingClientRect();
......
...@@ -149,8 +149,8 @@ ...@@ -149,8 +149,8 @@
<tr> <tr>
<td class="editTableTitle">{{$.lp.doublePage}}:</td> <td class="editTableTitle">{{$.lp.doublePage}}:</td>
<td class="editTableValue"> <td class="editTableValue">
<input class="editTableRadio" name="canDoublePage" text{($.canDoublePage!=='n')?'checked':''} type="radio" value="y"/>{{$.lp.yes}} <input class="editTableRadio" name="canDoublePage" text{($.canDoublePage=='y')?'checked':''} type="radio" value="y"/>{{$.lp.yes}}
<input class="editTableRadio" name="canDoublePage" text{($.canDoublePage=='n')?'checked':''} type="radio" value="n"/>{{$.lp.no}} <input class="editTableRadio" name="canDoublePage" text{($.canDoublePage!=='y')?'checked':''} type="radio" value="n"/>{{$.lp.no}}
<div>{{$.lp.doublePageInfo}}</div> <div>{{$.lp.doublePageInfo}}</div>
</td> </td>
</tr> </tr>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"name": "", "name": "",
"type": "Documenteditor", "type": "Documenteditor",
"description": "", "description": "",
"canDoublePage": "n",
"events": { "events": {
"queryLoad": { "queryLoad": {
"code": "", "code": "",
......
...@@ -22,7 +22,7 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -22,7 +22,7 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
* @event MWF.xApplication.process.Xform.Documenteditor#loadPage * @event MWF.xApplication.process.Xform.Documenteditor#loadPage
* @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明} * @see {@link https://www.yuque.com/o2oa/ixsnyt/hm5uft#i0zTS|组件事件说明}
*/ */
"moduleEvents": ["load", "queryLoad", "beforeLoad", "postLoad", "afterLoad", "loadPage", "fullScreen", "returnScreen"], "moduleEvents": ["load", "queryLoad", "beforeLoad", "postLoad", "afterLoad", "loadPage", "fullScreen", "returnScreen", "pagePosition"],
"docPageHeight": 850.4, "docPageHeight": 850.4,
"docPageFullWidth": 794, "docPageFullWidth": 794,
"pageShow": "single" "pageShow": "single"
...@@ -90,7 +90,8 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -90,7 +90,8 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
// }else{ // }else{
this._singlePage(); this._singlePage();
// } // }
this._checkScale(); // this.scaleTo(this.scale);
// this._checkScale();
}.bind(this)); }.bind(this));
o2.UD.getDataJson("documenteditorScale", function(json){ o2.UD.getDataJson("documenteditorScale", function(json){
...@@ -1509,17 +1510,45 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -1509,17 +1510,45 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
}, },
_checkScale: function(offset){ _checkScale: function(offset){
offset = 0; offset = 0;
this._contentNodeWitdh();
if (this.pages.length){ if (this.pages.length){
//var pageSize = this.pages[0].getSize(); //var pageSize = this.pages[0].getSize();
var pageSize_x = this.options.docPageFullWidth var pageSize_x = this.options.docPageFullWidth;
var contentSize = this.contentNode.getSize(); // var contentSize = this.contentNode.getSize();
var contentWidth = (offset) ? contentSize.x-20-offset : contentSize.x-20; //var contentSize = this.node.getSize();
if (contentWidth<pageSize_x){ // var contentWidth = (offset) ? contentSize.x-20-offset : contentSize.x-20;
// if (contentWidth<pageSize_x){
// this.isScale = true;
// var scale = (contentWidth)/pageSize_x;
// //this.scale = scale;
// this.zoom(scale);
// this.resetNodeSize();
// }
var contentSize_x = this.node.getSize().x;
//pageSize_x = this.scale;
// if (this.scale){
// pageSize_x = this.scale*pageSize_x;
// contentSize_x = this.scale*contentSize_x;
// //offset = this.scale*(offset+20);
// }
var contentWidth = contentSize_x-offset-20;
console.log("pageSize_x: "+pageSize_x);
console.log("contentWidth: "+contentWidth);
var p = pageSize_x*(this.documenteditorScale || 1);
console.log("pageSize_x*this.scale = "+p);
if (contentWidth<p){
this.isScale = true; this.isScale = true;
var scale = (contentWidth)/pageSize_x; var scale = (contentWidth)/pageSize_x;
this.scale = scale; //this.scale = scale;
this.zoom(); this.zoom(scale);
this.resetNodeSize(); this.resetNodeSize();
}else if (this.documenteditorScale){
// p = pageSize_x*(this.documenteditorScale || 1);
} }
} }
}, },
...@@ -1549,6 +1578,8 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -1549,6 +1578,8 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
if (this.filetextEditor && this.filetextEditor.element) { if (this.filetextEditor && this.filetextEditor.element) {
this.filetextEditor.element.$.store("scale", this.scale); this.filetextEditor.element.$.store("scale", this.scale);
} }
this._pageMargin();
}, },
_switchReadOrEdit: function(){ _switchReadOrEdit: function(){
...@@ -2255,32 +2286,33 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -2255,32 +2286,33 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
* this.form.get("fieldId").scaleTo(0.5); * this.form.get("fieldId").scaleTo(0.5);
*/ */
scaleTo: function(scale){ scaleTo: function(scale){
this._returnScale(); //this._returnScale();
this.isScale = false;
this.scale = scale; this.scale = scale;
this.zoom(); this.zoom();
//var w = this.contentNode.getSize().x*this.scale; // //var w = this.contentNode.getSize().x*this.scale;
var w = this.contentNode.offsetWidth*this.scale; // var w = this.contentNode.offsetWidth*this.scale;
//if (layout.userLayout && layout.userLayout.scale) w = w*layout.userLayout.scale; // //if (layout.userLayout && layout.userLayout.scale) w = w*layout.userLayout.scale;
var count = 1; // var count = 1;
var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth; // var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
//if (layout.userLayout && layout.userLayout.scale) docPageFullWidth = docPageFullWidth*layout.userLayout.scale; // //if (layout.userLayout && layout.userLayout.scale) docPageFullWidth = docPageFullWidth*layout.userLayout.scale;
var pageWidth = count * docPageFullWidth; // var pageWidth = count * docPageFullWidth;
var margin = (w-pageWidth)/(count+1); // var margin = (w-pageWidth)/(count+1);
if (this.isScale){ // if (this.isScale){
margin = "10"; // margin = "10";
} // }
if (this.scale) margin = margin/this.scale; // if (this.scale) margin = margin/this.scale;
if (margin < 10){ // if (margin < 10){
var offset = 10-margin; // var offset = 10-margin;
margin = 10; // margin = 10;
this.contentNode.scrollTo(offset, 0); // this.contentNode.scrollTo(offset, 0);
} // }
this.pages.each(function(page, i){ // this.pages.each(function(page, i){
page.setStyles({ // page.setStyles({
"float": "left", // "float": "left",
"margin-left": ""+margin+"px" // "margin-left": ""+margin+"px"
}); // });
}); // });
this.resetNodeSize(); this.resetNodeSize();
}, },
...@@ -2300,30 +2332,24 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -2300,30 +2332,24 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
this._checkScale(); this._checkScale();
} }
}, },
_singlePage: function(){ _contentNodeWitdh: function(){
//if (this.editMode) this._readFiletext(); var w = this.node.getSize().x;
if (this.history && this.history.historyListAreaNode) w = w-this.history.historyListAreaNode.getComputedSize().totalWidth-2;
var scale = this.singlePageZoom || 1; w = w/this.scale;
if( this.singlePageZoom && this.singlePageZoom.toInt() != 1 ){ this.contentNode.setStyles({
this.isScale = true; "width": ""+w+"px"
this.scale = this.singlePageZoom; });
this.singlePageZoom = null; },
} _pageMargin: function(){
this._contentNodeWitdh();
this.zoom(scale);
this._checkScale();
var w = this.contentNode.getSize().x; var w = this.contentNode.getSize().x;
w = (this.scale) ? this.scale*w : w;
var count = 1; var count = 1;
var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth; var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
//var docPageFullWidth = this.options.docPageFullWidt;
var pageWidth = count * docPageFullWidth; var pageWidth = count * docPageFullWidth;
var margin = (w-pageWidth)/(count+1); var margin = (w-pageWidth)/(count+1);
if (this.isScale){
margin = "10";
}
if (this.scale) margin = margin/this.scale; if (this.scale) margin = margin/this.scale;
this.pages.each(function(page, i){ this.pages.each(function(page, i){
page.setStyles({ page.setStyles({
...@@ -2332,6 +2358,43 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla ...@@ -2332,6 +2358,43 @@ MWF.xApplication.process.Xform.Documenteditor = MWF.APPDocumenteditor = new Cla
}); });
}); });
this.fireEvent("pagePosition");
},
_singlePage: function(){
//if (this.editMode) this._readFiletext();
var scale = this.singlePageZoom;
if (!scale) scale = this.scale || 1;
if( this.singlePageZoom && this.singlePageZoom.toInt() != 1 ){
this.isScale = true;
this.scale = this.singlePageZoom;
this.singlePageZoom = null;
}
//this.zoom(scale);
this._checkScale();
this._pageMargin();
// var w = this.contentNode.getSize().x;
// var count = 1;
// var docPageFullWidth = (this.scale) ? this.scale*this.options.docPageFullWidth : this.options.docPageFullWidth;
// //var docPageFullWidth = this.options.docPageFullWidt;
//
// var pageWidth = count * docPageFullWidth;
// var margin = (w-pageWidth)/(count+1);
//
// if (this.isScale){
// margin = "10";
// }
// if (this.scale) margin = margin/this.scale;
// this.pages.each(function(page, i){
// page.setStyles({
// "float": "left",
// "margin-left": ""+margin+"px"
// });
// });
this.resetNodeSize(); this.resetNodeSize();
// this.pages.each(function(page){ // this.pages.each(function(page){
// page.setStyle("float", "none"); // page.setStyle("float", "none");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册