rlm@46: rlm@46: /* rlm@46: * rlm@46: */ rlm@46: rlm@46: Ext.BLANK_IMAGE_URL = 'theme/images/default/s.gif'; rlm@46: rlm@46: if(typeof console != 'object') { rlm@46: console = {}; rlm@46: console.log = function(){return false;}; rlm@46: } rlm@46: rlm@46: rlm@46: function $(e){return Ext.get(e).dom} rlm@46: var c, browser, browserpath; rlm@46: var colorpage="#ccccdd"; rlm@46: var colorpage1a="#ee00aa"; //north rlm@46: var colorpage1b="#ee00cc"; rlm@46: var colorpage1c="#ee00ee"; rlm@46: var colorpage2="#77aaaa"; //sud rlm@46: var colorpage3="#ddee00"; //est rlm@46: var colorpage4="#ccee00"; //west rlm@46: rlm@46: var selectmode=''; rlm@46: var selectedit=''; rlm@46: rlm@46: rlm@46: ie = navigator.appVersion.match(/MSIE (\d\.\d)/); rlm@46: opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1); rlm@46: rlm@46: rlm@46: rlm@46: window.onresize = doResize; rlm@46: var initialFile='onerobot.txt'; rlm@46: var docx=0; rlm@46: var docy=0; rlm@46: var docw=600; rlm@46: var doch=400; rlm@46: var canvasWidth=600;//FRONTsize[0]; rlm@46: var canvasW=canvasWidth; rlm@46: var canvasHeight=400;//FRONTsize[1]; rlm@46: var canvasH=canvasHeight; rlm@46: var canvasX=0; rlm@46: var canvasY=0; rlm@46: var zoomx=docx; rlm@46: var zoomy=docy; rlm@46: var zoomw=docw; rlm@46: var zoomh=doch; rlm@46: var marginx=0; rlm@46: var marginy=0; rlm@46: var margin=100; rlm@46: var screenSize=myWorkSize(); rlm@46: var scrW = screenSize[0];//screen.availWidth; rlm@46: var scrH = screenSize[1];//screen.availHeight; rlm@46: rlm@46: var canvasYpercent=100; rlm@46: var canvasXpercent=100; rlm@46: rlm@46: rlm@46: //? rlm@46: var wndW=scrW;//window.width; rlm@46: var wndH=scrH;//window.height; rlm@46: // rlm@46: var proporWindow= scrW/scrH; rlm@46: var proporCanvas=canvasW/canvasH; rlm@46: var proporDoc=docw/doch; rlm@46: var proporZoom= zoomw/zoomh; rlm@46: var proporx=proporCanvas; //IE rlm@46: var propory=1; //IE rlm@46: var viewMode='canvas';//'canvas' or 'preview' rlm@46: rlm@46: var zoominit=docx+' '+docy+' '+docw+' '+doch; rlm@46: var zoominit1 =zoominit; rlm@46: var zoominit2 =zoominit; rlm@46: rlm@46: var fieldViewx=Math.round(canvasH*proporCanvas); rlm@46: var fieldViewy=canvasH; rlm@46: var diagonalFrame=dist2p(0,0,fieldViewx,fieldViewy); rlm@46: var diagonalAngle=getAngle(fieldViewx,fieldViewy); rlm@46: var diagonalinit=diagonalFrame; rlm@46: //alert(diagonalinit); rlm@46: rlm@46: // double? rlm@46: var diagonalMidx=fieldViewx/2; rlm@46: var diagonalMidy=fieldViewy/2; rlm@46: var centerZoomx=diagonalMidx;//Math.round(zoomw/2); rlm@46: var centerZoomy=diagonalMidy;//Math.round(zoomh/2); rlm@46: // rlm@46: rlm@46: rlm@46: var proporDiagonal=diagonalFrame/diagonalinit; rlm@46: ////////////////////////// rlm@46: rlm@46: var wProportion={x:35, y:24} rlm@46: rlm@46: var vertexNORTHmenu={}; rlm@46: var vertexNORTHglobals={}; rlm@46: var vertexNORTHoptions={}; rlm@46: var vertexSUD={}; rlm@46: var vertexEST={}; rlm@46: var vertexWEST={}; rlm@46: var vertexFRONT={}; rlm@46: rlm@46: var NORTHmenusize=[]; rlm@46: var NORTHglobalssize=[]; rlm@46: var NORTHoptionssize=[]; rlm@46: var SUDsize=[]; rlm@46: var ESTsize=[]; rlm@46: var WESTsize=[]; rlm@46: var FRONTsize=[]; rlm@46: rlm@46: rlm@46: vertexFrames(); rlm@46: rlm@46: rlm@46: var FRONT=''; rlm@46: //FRONT+='
'; rlm@46: rlm@46: var NORTHmenu=''; rlm@46: NORTHmenu+='  File  Edit  View'; rlm@46: rlm@46: var NORTHglobals=''; rlm@46: NORTHglobals+=''; rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=' ' rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=' ', rlm@46: NORTHglobals+=' '; rlm@46: NORTHglobals+=''; rlm@46: rlm@46: var NORTHoptions=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: // rlm@46: NORTHoptions+=''; rlm@46: rlm@46: rlm@46: var EST=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: EST+=''; rlm@46: rlm@46: var WEST=''; rlm@46: WEST+='
0,0
'; rlm@46: WEST+='
0,0
'; rlm@46: rlm@46: WEST+='
Grid:
'; rlm@46: WEST+=''; rlm@46: WEST+='
'; rlm@46: rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+=' Fill
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+=' Line
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: WEST+='
'; rlm@46: rlm@46: WEST+='
'; rlm@46: WEST+=' '; rlm@46: rlm@46: var SUD=""; rlm@46: //SUD+=''; rlm@46: //SUD+=''; rlm@46: //SUD+=''; rlm@46: //SUD+='
 '; rlm@46: SUD+='
 '; rlm@46: SUD+=''; rlm@46: // SUD+=''; rlm@46: // SUD+='
'; rlm@46: // SUD+='
'; rlm@46: rlm@46: var currentEditStatus='off'; rlm@46: var currentFileStatus='off'; rlm@46: var currentViewStatus='off'; rlm@46: var infoFrame, docFrame; rlm@46: Ext.onReady(function() { rlm@46: rlm@46: rlm@46: //var map = new Ext.KeyMap(document, { rlm@46: // key: [Ext.EventObject.LEFT, Ext.EventObject.RIGHT], rlm@46: // ctrl: true, rlm@46: // fn: keypresshandler rlm@46: //}); rlm@46: //Ext.get("FRONT").dom.innerHTML=(FRONT); rlm@46: Ext.get("NORTHmenu").dom.innerHTML=(NORTHmenu); rlm@46: Ext.get("NORTHglobals").dom.innerHTML=(NORTHglobals); rlm@46: Ext.get("NORTHoptions").dom.innerHTML=(NORTHoptions); rlm@46: Ext.get("EST").dom.innerHTML=(EST); rlm@46: Ext.get("WEST").dom.innerHTML=(WEST); rlm@46: Ext.get("SUD").dom.innerHTML=(SUD); rlm@46: rlm@46: resizeFrame(); rlm@46: var map= new Ext.KeyMap(document, [ rlm@46: { rlm@46: key: [46],//DELETE rlm@46: fn: function(){ c.deleteSelection(); } rlm@46: }, { rlm@46: key: "x", rlm@46: ctrl:true, rlm@46: fn: function(){ rlm@46: c.clipboard=c.renderer.copy(c.selected); rlm@46: c.deleteSelection(); rlm@46: } rlm@46: }, { rlm@46: key: "c", rlm@46: ctrl:true, rlm@46: fn: function(){ rlm@46: c.clipboard=c.renderer.copy(c.selected); rlm@46: } rlm@46: }, { rlm@46: key: "d", rlm@46: ctrl:true, rlm@46: fn: function(){ rlm@46: c.selected=c.renderer.duplicate(c.selected); rlm@46: c.selected.id = 'shape:' + createUUID(); rlm@46: Ext.get(c.selected).on( "mousedown", c.onHit,c); rlm@46: } rlm@46: }, { rlm@46: key: "v", rlm@46: ctrl:true, rlm@46: fn: function(){ rlm@46: c.selected=c.renderer.paste(c.clipboard,c.mouseDownX,c.mouseDownY); rlm@46: c.selected.id = 'shape:' + createUUID(); rlm@46: Ext.get(c.selected).on( "mousedown", c.onHit,c); rlm@46: } rlm@46: }, { rlm@46: key: "z", //UNDO rlm@46: ctrl:true, rlm@46: shift:false, rlm@46: fn: function(){ c.clipboard=c.renderer.undo(); } rlm@46: } rlm@46: ]); rlm@46: rlm@46: /* rlm@46: Ext.get("richdraw").dom.style.width=(canvasWidth); rlm@46: Ext.get("richdraw").dom.style.height=(canvasHeight); rlm@46: Ext.get("richdraw").dom.style.left=(canvasX); rlm@46: Ext.get("richdraw").dom.style.top=(canvasY); rlm@46: */ rlm@46: rlm@46: rlm@46: rlm@46: menuEdit = new Ext.menu.Menu({ rlm@46: id: 'menuedit', rlm@46: items: [ rlm@46: {icon: "img/viewcode.gif", text: 'Copy all ', handler: shm}, rlm@46: {icon: "img/viewcode.gif", text: 'Paste all ', handler: lcm}, rlm@46: {icon: "img/viewcode.gif", text: 'Delete all ', handler: deleteAllShapes}, rlm@46: {icon: "img/viewcode.gif", text: 'Duplicate  Ctrl+d', handler: duplicateSelected}, rlm@46: {icon: "img/viewcode.gif", text: 'Cut    Ctrl+x', handler: cutSelected}, rlm@46: {icon: "img/viewcode.gif", text: 'Copy    Ctrl+c', handler: copySelected}, rlm@46: {icon: "img/viewcode.gif", text: 'Paste  Ctrl+v', handler: pasteSelected}, rlm@46: {icon: "img/viewcode.gif", text: 'Delete   Supr', handler: deleteShape}, rlm@46: {icon: "img/viewcode.gif", text: 'Delete last Ctrl+z', handler: deleteLastShapes}, rlm@46: rlm@46: ] rlm@46: }); rlm@46: rlm@46: menuFile = new Ext.menu.Menu({ rlm@46: id: 'menufile', rlm@46: rlm@46: items: [ rlm@46: new Ext.menu.Item({ icon: "img/viewcode.gif", text: 'New ', handler: newFile }), rlm@46: new Ext.menu.Item({ icon: "img/viewcode.gif", text: 'Open ', handler: openFile }), rlm@46: new Ext.menu.Item({ icon: "img/viewcode.gif", text: 'View SVG code ', handler: showMarkupCode }), rlm@46: new Ext.menu.Item({icon: "img/viewcode.gif", text: 'View OPF code ', handler: showMarkup }), rlm@46: new Ext.menu.Item({icon: "img/viewcode.gif", text: 'Document properties ', handler: documentProperties }) rlm@46: ] rlm@46: }); rlm@46: menuView = new Ext.menu.Menu({ rlm@46: id: 'menuview', rlm@46: rlm@46: items: [ rlm@46: {icon: "img/viewcode.gif", text: 'Preview ', handler: preView}, rlm@46: {icon: "img/viewcode.gif", text: 'Canvas ', handler: canvasView} rlm@46: ] rlm@46: }); rlm@46: /* rlm@46: items: [ rlm@46: {icon: "img/viewcode.gif", text: 'View SVG code ', handler: showMarkupCode }, rlm@46: {icon: "img/viewcode.gif", text: 'View OPF code ', handler: showMarkup }, rlm@46: {icon: "img/viewcode.gif", text: 'Document properties ', handler: documentProperties }, rlm@46: rlm@46: ] rlm@46: */ rlm@46: // define the handler for mouseover/out of either button or menu itself rlm@46: var editHandler = function(e) rlm@46: { rlm@46: if(currentEditStatus=='on') rlm@46: { rlm@46: var edit = menuEdit.getEl(); rlm@46: var buttonEdit = Ext.get('edit'); rlm@46: if(!edit.getRegion().contains(e.getPoint()) && !buttonEdit.getRegion().contains(e.getPoint())) rlm@46: { rlm@46: menuEdit.hide(); rlm@46: currentEditStatus='off'; rlm@46: } rlm@46: } rlm@46: else rlm@46: { rlm@46: menuEdit.show('edit'); rlm@46: currentEditStatus='on'; rlm@46: } rlm@46: } rlm@46: rlm@46: var fileHandler = function(e) rlm@46: { rlm@46: if(currentFileStatus=='on') rlm@46: { rlm@46: var file = menuFile.getEl(); rlm@46: var buttonFile = Ext.get('file'); rlm@46: if(!file.getRegion().contains(e.getPoint()) && !buttonFile.getRegion().contains(e.getPoint())) rlm@46: { rlm@46: menuFile.hide(); rlm@46: currentFileStatus='off'; rlm@46: } rlm@46: } rlm@46: else rlm@46: { rlm@46: menuFile.show('file'); rlm@46: currentFileStatus='on'; rlm@46: } rlm@46: } rlm@46: rlm@46: rlm@46: var viewHandler = function(e) rlm@46: { rlm@46: if(currentViewStatus=='on') rlm@46: { rlm@46: var view = menuView.getEl(); rlm@46: var buttonView = Ext.get('view'); rlm@46: if(!view.getRegion().contains(e.getPoint()) && !buttonView.getRegion().contains(e.getPoint())) rlm@46: { rlm@46: menuView.hide(); rlm@46: currentViewStatus='off'; rlm@46: } rlm@46: } rlm@46: else rlm@46: { rlm@46: menuView.show('view'); rlm@46: currentViewStatus='on'; rlm@46: } rlm@46: } rlm@46: rlm@46: // define the events to observe rlm@46: Ext.get('edit').on('mouseover',editHandler); rlm@46: Ext.get('edit').on('mouseout',editHandler); rlm@46: menuEdit.getEl().on('mouseout',editHandler); rlm@46: rlm@46: Ext.get('file').on('mouseover',fileHandler); rlm@46: Ext.get('file').on('mouseout',fileHandler); rlm@46: menuFile.getEl().on('mouseout',fileHandler); rlm@46: rlm@46: Ext.get('view').on('mouseover',viewHandler); rlm@46: Ext.get('view').on('mouseout',viewHandler); rlm@46: menuView.getEl().on('mouseout',viewHandler); rlm@46: rlm@46: rlm@46: rlm@46: }); rlm@46: rlm@46: // end ONREADY rlm@46: rlm@46: function borderDoc(){ rlm@46: //c.rectCanvas(docx,docy,docw,doch,viewBox) rlm@46: if(viewMode=='canvas') rlm@46: { rlm@46: var obj=document.getElementById("rectDoc"); rlm@46: if(obj){c.renderer.remove(obj) } rlm@46: c.renderer.rectDoc(zoominit); rlm@46: //c.renderer.rectDoc(zoominit1); rlm@46: //pst.id = "rectCanvas"; rlm@46: //c.selected=obj; rlm@46: // c.renderer.remove(obj) rlm@46: //var clip=c.renderer.copy(obj); rlm@46: rlm@46: rlm@46: rlm@46: //var pst=c.container.appendChild( clip ); rlm@46: //c.renderer.paste(clip,0,0); rlm@46: //pst.id = "rectCanvas"; rlm@46: rlm@46: rlm@46: //pasteSelected(); rlm@46: rlm@46: //c.renderer.duplicate(document.getElementById("rectCanvas")) rlm@46: //c.renderer.remove(document.getElementById("rectCanvas")); rlm@46: } rlm@46: if(viewMode=='preview') rlm@46: { rlm@46: var obj=document.getElementById("rectDoc"); rlm@46: if(obj){c.renderer.remove(obj) } rlm@46: } rlm@46: } rlm@46: function demo() { rlm@46: _dom=document.all?3:(document.getElementById?1:(document.layers?2:0)); rlm@46: ie = navigator.appVersion.match(/MSIE (\d\.\d)/); rlm@46: opera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1); rlm@46: rlm@46: var renderer; rlm@46: rlm@46: if ((!ie) || (opera)) { rlm@46: renderer = new SVGRenderer(); rlm@46: browser='svg'; rlm@46: browserpath="linkspath.htm"; rlm@46: } rlm@46: else { rlm@46: renderer = new VMLRenderer(); rlm@46: browser='vml'; rlm@46: browserpath="vmlpaths.htm"; rlm@46: } rlm@46: rlm@46: c = new RichDrawEditor(document.getElementById('richdraw'), renderer); rlm@46: rlm@46: c.onInputXY = function(x,y){$('xyinput').innerHTML = parseInt(x)+','+parseInt(y)}//[x,y].join("
")} rlm@46: c.onViewInputXY = function(x,y){$('zoomOverInput').innerHTML = parseInt(x)+','+parseInt(y)}//[x,y].join("
")} rlm@46: rlm@46: c.onselect = onSelect; rlm@46: c.onunselect = onUnselect; rlm@46: rlm@46: rlm@46: rlm@46: // c.onkeydown = keypresshandler; rlm@46: //c.onkeypress = c.onKeyPress; rlm@46: //document.onkeypress = c.onKeyPress; rlm@46: rlm@46: rlm@46: rlm@46: c.editCommand('fillcolor', 'red'); rlm@46: c.editCommand('linecolor', 'black'); rlm@46: c.editCommand('linewidth', '1px'); rlm@46: rlm@46: rlm@46: //setMode('path', 'Path'); rlm@46: setMode('select', 'Selection'); rlm@46: rlm@46: document.body.style.backgroundColor = colorpage; rlm@46: rlm@46: rlm@46: //alert(vertexSUD.SUD1[0]+' '+vertexSUD.SUD1[1]+ '--'+wndW+' '+wndH); rlm@46: rlm@46: setTimeout(loadDemo,500) rlm@46: //Ext.get("richdraw").on('keydown', function(e){alert('dfsd'); }, false); rlm@46: //Ext.get("richdraw").on('keydown', function(e){alert(e.keyCode); }); rlm@46: //document.onkeydown = keypresshandler; rlm@46: //richdraw.svgRoot.setAttributeNS(null,'viewBox', '0 0 700 500'); rlm@46: rlm@46: //setTimeout(borderDoc,500) rlm@46: rlm@46: } //END demo rlm@46: rlm@46: rlm@46: ///////////////// rlm@46: rlm@46: rlm@46: ////////////////// rlm@46: var Docs = function(){ rlm@46: return { rlm@46: init : function(){ rlm@46: var loading = Ext.get('loading'); rlm@46: var mask = Ext.get('loading-mask'); rlm@46: mask.setOpacity(.7); rlm@46: mask.shift({ rlm@46: xy:loading.getXY(), rlm@46: width:loading.getWidth(), rlm@46: height:loading.getHeight(), rlm@46: remove:true, rlm@46: duration:2, rlm@46: opacity:.8, rlm@46: easing:'bounceOut', rlm@46: callback : function(){ rlm@46: loading.fadeOut({duration:.2,remove:true}); rlm@46: } rlm@46: }); rlm@46: } rlm@46: }; rlm@46: }(); rlm@46: rlm@46: rlm@46: Ext.onReady(Docs.init, Docs, true); rlm@46: rlm@46: //var win; rlm@46: rlm@46: function showinfoFrame(wtitle) { rlm@46: var win = new Ext.Window({ rlm@46: closeAction: 'hide', rlm@46: renderTo: 'showInfo', rlm@46: autoScroll:true, rlm@46: modal:true, rlm@46: width: '440', rlm@46: height:'300', rlm@46: x: '120', rlm@46: y: '40', rlm@46: title: wtitle, rlm@46: draggable :true, rlm@46: html: '', rlm@46: hidden: true, rlm@46: contentEl: 'divCode', rlm@46: collapsed: true rlm@46: rlm@46: }); rlm@46: win.show(); rlm@46: } rlm@46: function showdocFrame(wtitle) { rlm@46: var win = new Ext.Window({ rlm@46: closeAction: 'hide', rlm@46: renderTo: 'showInfo', rlm@46: width: '340', rlm@46: height:'300', rlm@46: x: '120', rlm@46: y: '40', rlm@46: title: wtitle, rlm@46: draggable :true, rlm@46: html: '', rlm@46: hidden: true, rlm@46: contentEl: 'docProperties', rlm@46: collapsed: true rlm@46: rlm@46: }); rlm@46: win.show(); rlm@46: } rlm@46: function showopenFile(wtitle) { rlm@46: var win = new Ext.Window({ rlm@46: autoScroll:true, rlm@46: closeAction: 'hide', rlm@46: renderTo: 'showInfo', rlm@46: width: '440', rlm@46: height:'300', rlm@46: x: '120', rlm@46: y: '40', rlm@46: title: wtitle, rlm@46: draggable :true, rlm@46: html: '', rlm@46: hidden: true, rlm@46: contentEl: 'divopenFile', rlm@46: collapsed: true rlm@46: rlm@46: }); rlm@46: win.show(); rlm@46: } rlm@46: rlm@46: function preView() { rlm@46: viewMode='preview'; rlm@46: // rlm@46: //document.forms[0].code.value=Ext.util.JSON.encode(canvas(c)); rlm@46: //myOPF=document.forms[0].code.value; rlm@46: c.renderer.view(docx,docy,docw,doch,zoominit); rlm@46: borderDoc(); rlm@46: rlm@46: //var all=canvas(c) ; rlm@46: // deleteAllShapes() rlm@46: //load(all,c); rlm@46: rlm@46: } rlm@46: rlm@46: function canvasView() { rlm@46: viewMode='canvas'; rlm@46: //deleteAllShapes() rlm@46: //document.forms[0].code.value=Ext.util.JSON.encode(canvas(c)); rlm@46: //myOPF=document.forms[0].code.value; rlm@46: //load(myOPF,c); rlm@46: c.renderer.view(docx,docy,docw,doch,zoominit); rlm@46: borderDoc(); rlm@46: //var all=canvas(c) ; rlm@46: //deleteAllShapes() rlm@46: //load(all,c); rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: ///////////////////////////// rlm@46: //FUNCTIONS rlm@46: ///////////////////////////// rlm@46: rlm@46: function changeInitialFile() rlm@46: { rlm@46: initialFile=document.forms[0].file.value; rlm@46: c.renderer.removeAll() rlm@46: loadDemo(); rlm@46: if(viewMode=='canvas') rlm@46: { rlm@46: c.renderer.rectDoc(zoominit) rlm@46: } rlm@46: //win.hide(); rlm@46: //document.getElementById("showInfo").style.display='none'; rlm@46: } rlm@46: rlm@46: function setMode(mode, status) rlm@46: { rlm@46: rlm@46: rlm@46: selectmode=mode; rlm@46: if(mode=='shape') rlm@46: { rlm@46: c.editCommand('mode', 'select'); rlm@46: }else{ rlm@46: if(mode=='pathsEdit' ) rlm@46: { rlm@46: mode='select'; rlm@46: } rlm@46: c.editCommand('mode', mode); rlm@46: } rlm@46: rlm@46: var imgs = $('EST').getElementsByTagName('img'); rlm@46: rlm@46: for (var i=0; i'+$('option_text_size').value+'<;>'+$('option_text_family').value); rlm@46: } rlm@46: rlm@46: function setGridWidth(widths) rlm@46: { rlm@46: var width = eval(widths.options[widths.selectedIndex].value); rlm@46: RichDrawEditor.prototype.setGrid(width, width); rlm@46: } rlm@46: rlm@46: /////////////////////////////// rlm@46: rlm@46: rlm@46: function getOptionByValue(select, value) rlm@46: { rlm@46: /*for (var i=0; i1){ rlm@46: for(var a=1;a<=numpoints;a++) rlm@46: { rlm@46: rlm@46: if(a==mypointNum){ rlm@46: rlm@46: segment=points[a].split(' '); rlm@46: prevControl=segment[0]+' '; rlm@46: nextControl=segment[1]+' '; rlm@46: nodePoint=segment[2]+' '; rlm@46: rlm@46: rlm@46: /*if(controlNodeNum==0){chain+=prevControl; var point=prevControl.split(',');} rlm@46: if(controlNodeNum==1){chain+=nextControl; var point=nextControl.split(',');} rlm@46: if(controlNodeNum==2){chain+=nodePoint; var point=nodePoint.split(',');} rlm@46: */ rlm@46: rlm@46: var point=nodePoint.split(','); rlm@46: point[1]= $('option_path_x').value; rlm@46: point[2]= $('option_path_y').value; rlm@46: var change=point.join(',') rlm@46: rlm@46: chain+='C'+prevControl+ nextControl + change+' '; rlm@46: }else{ rlm@46: chain+='C'+points[a]; rlm@46: } rlm@46: rlm@46: } rlm@46: rlm@46: }else{ rlm@46: chain+='C'+points[1]; rlm@46: rlm@46: } rlm@46: //$('someinfo').value= chain; rlm@46: $('control_codebase').value=chain; rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: if (keycode == 13 || keycode == 40 || keycode == 38) rlm@46: { rlm@46: //alert(myfield.id); rlm@46: c.renderer.tocurve(); rlm@46: rlm@46: return false; rlm@46: rlm@46: } rlm@46: else rlm@46: return true; rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: function edit(myfield,e) rlm@46: { rlm@46: rlm@46: var keycode; rlm@46: rlm@46: rlm@46: // ++? if (window.event) keycode = window.event.e; rlm@46: //else if (e) keycode = e.which; rlm@46: rlm@46: e= (e) ? e : ((window.event) ? event : null); rlm@46: keycode=e.keyCode; rlm@46: //var keycode = e.which?e.which:e.keycode rlm@46: rlm@46: //document.layers ? e.which : rlm@46: //document.all ? e.keyCode : rlm@46: //document.getElementById ? e.keyCode : 0; rlm@46: //else return true; rlm@46: var keyChar = String.fromCharCode(keycode); rlm@46: //var numCheck = /\d/; rlm@46: //if (((keyChar=='.')&&(obj.value.indexOf('.')==-1))¦¦(keycode<32)¦¦numCheck.test(keyChar)¦¦((keycode>=37)&&(keycode<=40)&&(!e.modifiers&&!e.shiftKey))) { rlm@46: rlm@46: //alert(keycode+' _ '+keyChar); rlm@46: var shs= myfield.id.split('_'); rlm@46: var sh=shs[1]; rlm@46: if(myfield.id.indexOf('control_codebase')<=0) rlm@46: { rlm@46: if (keycode == 38)//#26 rlm@46: { rlm@46: rlm@46: if(eval(myfield.value)>0) rlm@46: { rlm@46: myfield.value=eval(myfield.value)+1; rlm@46: //alert(myfield.value); rlm@46: } rlm@46: //return false; rlm@46: //alert('keycode') rlm@46: rlm@46: } rlm@46: if (keycode == 40)// #28 rlm@46: { rlm@46: myfield.value=eval(myfield.value)-1; rlm@46: if(myfield.id=='option_path_sclx' || myfield.id=='option_path_scly') rlm@46: { rlm@46: if( eval(myfield.value)<=0 ) rlm@46: { rlm@46: myfield.value=1; rlm@46: } rlm@46: } rlm@46: rlm@46: if(myfield.id=='option_text_size') rlm@46: { rlm@46: if( eval(myfield.value)<=0 ) rlm@46: { rlm@46: myfield.value=1; rlm@46: } rlm@46: } rlm@46: } rlm@46: rlm@46: } rlm@46: rlm@46: if (keycode == 13 || keycode == 40 || keycode == 38) rlm@46: { rlm@46: var check=0; rlm@46: if(myfield.id=='control_codebase') rlm@46: { rlm@46: //alert(myfield.id) rlm@46: //c.submitShape($('control_codebase').value+''); rlm@46: check=1; rlm@46: setShape(); rlm@46: } rlm@46: rlm@46: if(myfield.id.indexOf('href')>0) rlm@46: { rlm@46: c.submitShape(myfield.value) rlm@46: } rlm@46: rlm@46: if(myfield.id.indexOf('tr')>0 || myfield.id.indexOf('scl')>0) rlm@46: { rlm@46: if(check==0) rlm@46: { rlm@46: c.submitShape($('option_'+sh+'_trx').value+';'+$('option_'+sh+'_try').value+';'+$('option_'+sh+'_sclx').value+';'+$('option_'+sh+'_scly').value+';'+$('option_'+sh+'_rot').value) rlm@46: } rlm@46: } rlm@46: rlm@46: if(myfield.id.indexOf('rot')>0) rlm@46: { rlm@46: c.submitShape($('option_'+sh+'_trx').value+';'+$('option_'+sh+'_try').value+';'+$('option_'+sh+'_sclx').value+';'+$('option_'+sh+'_scly').value+';'+$('option_'+sh+'_rot').value) rlm@46: } rlm@46: rlm@46: if(myfield.id.indexOf('text')>0) rlm@46: { rlm@46: c.submitShape($('option_text_message').value+'<;>'+$('option_text_size').value+'<;>'+$('option_text_family').value); rlm@46: } rlm@46: //alert(myfield.id); rlm@46: return false; rlm@46: rlm@46: } rlm@46: else rlm@46: return true; rlm@46: } rlm@46: rlm@46: rlm@46: rlm@46: rlm@46: function env(myfield,delta) rlm@46: { rlm@46: rlm@46: //alert(keycode+' _ '+keyChar); rlm@46: rlm@46: if (delta >0)//#26 rlm@46: { rlm@46: myfield.value=eval(myfield.value)+1; rlm@46: //return false; rlm@46: //alert('keycode') rlm@46: } rlm@46: else rlm@46: { rlm@46: myfield.value=eval(myfield.value)-1; rlm@46: //return false; rlm@46: } rlm@46: rlm@46: rlm@46: if(myfield.id=='option_image_href') rlm@46: { rlm@46: c.submitShape(myfield.value) rlm@46: } rlm@46: if(myfield.id=='option_select_trx' || myfield.id=='option_select_try' || myfield.id=='option_select_sclx' || myfield.id=='option_select_scly') rlm@46: { rlm@46: c.submitShape($('option_select_trx').value+';'+$('option_select_try').value+';'+$('option_select_sclx').value+';'+$('option_select_scly').value+';'+$('option_select_rot').value) rlm@46: } rlm@46: if(myfield.id=='option_select_rot') rlm@46: { rlm@46: c.submitShape($('option_select_trx').value+';'+$('option_select_try').value+';'+$('option_select_sclx').value+';'+$('option_select_scly').value+';'+$('option_select_rot').value) rlm@46: } rlm@46: rlm@46: } rlm@46: rlm@46: rlm@46: function clockdata(){ rlm@46: ////////////// rlm@46: //++ rlm@46: rlm@46: data_path_close = $('option_path_close').checked; rlm@46: data_text_family = $('option_text_family').value; rlm@46: data_text_size = parseFloat($('option_text_size').value); rlm@46: data_text_messaje = $('option_text_message').value; rlm@46: data_image_href = $('option_image_href').value; rlm@46: rlm@46: //////////// rlm@46: } rlm@46: rlm@46: function myWorkSize() { rlm@46: var myWidth = 0, myHeight = 0; rlm@46: if( typeof( window.innerWidth ) == 'number' ) { rlm@46: //Non-IE rlm@46: myWidth = window.innerWidth; rlm@46: myHeight = window.innerHeight; rlm@46: } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) { rlm@46: //IE 6+ in 'standards compliant mode' rlm@46: myWidth = document.documentElement.clientWidth; rlm@46: myHeight = document.documentElement.clientHeight; rlm@46: } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { rlm@46: //IE 4 compatible rlm@46: myWidth = document.body.clientWidth; rlm@46: myHeight = document.body.clientHeight; rlm@46: } rlm@46: return [ myWidth, myHeight] ; rlm@46: } rlm@46: rlm@46: function doResize(){ rlm@46: //deleteAllShapes(); rlm@46: vertexFrames(); rlm@46: resizeFrame(); rlm@46: //c.renderer.zoomFrame(zoominit); rlm@46: //c.renderer.view(canvasX,canvasY,canvasW,canvasH,zoominit) rlm@46: //c.renderer.view(docx,docy,docw,doch,zoominit1) rlm@46: // delete rectCanvas rlm@46: // var vB=zoomx+' '+zoomy+' '+zoomw+' '+zoomh; rlm@46: rlm@46: //c.renderer.rectCanvas(docx,docy,docw,doch,vB); rlm@46: } rlm@46: rlm@46: function vertexFrames(){ rlm@46: rlm@46: var screenSize=myWorkSize(); rlm@46: scrW = screenSize[0];//screen.availWidth; rlm@46: scrH = screenSize[1];//screen.availHeight; rlm@46: rlm@46: wndW=scrW;//window.width; rlm@46: wndH=scrH;//window.height; rlm@46: rlm@46: rlm@46: if (scrW != wndW || scrH != wndH) { rlm@46: //window.resizeTo(scrW, scrH); rlm@46: //window.moveTo(0, 0); rlm@46: } rlm@46: //var wProportion={x:35, y:24} rlm@46: rlm@46: vertexNORTHmenu={ NORTHmenu1:[0,0],NORTHmenu2:[scrW,0],NORTHmenu3:[0,wProportion.y],NORTHmenu4:[scrW,wProportion.y] }; rlm@46: vertexNORTHglobals={ NORTHglobals1:[0,wProportion.y],NORTHglobals2:[scrW,wProportion.y],NORTHglobals3:[0,wProportion.y*2],NORTHglobals4:[scrW,wProportion.y*2] }; rlm@46: vertexNORTHoptions={ NORTHoptions1:[0,wProportion.y*2],NORTHoptions2:[scrW,wProportion.y*2],NORTHoptions3:[0,wProportion.y*3],NORTHoptions4:[scrW,wProportion.y*3] }; rlm@46: vertexSUD={ SUD1:[0,wndH-wProportion.y*3], SUD2:[scrW,(wndH-wProportion.y*3)], SUD3:[0,wndH], SUD4:[scrW,wndH]}; rlm@46: vertexEST={ EST1:[0,wProportion.y*3], EST2:[wProportion.x,wProportion.y*3], EST3:[0,(wndH-wProportion.y*3)], EST4:[wProportion.x,(wndH-wProportion.y*3)] }; rlm@46: vertexWEST={ WEST1:[(scrW-wProportion.x*3),wProportion.y*3], WEST2:[scrW,wProportion.y*3], WEST3:[(scrW-wProportion.x*3),(wndH-wProportion.y*3)], WEST4:[scrW,(wndH-wProportion.y*3)] }; rlm@46: vertexFRONT={ FRONT1:[vertexEST.EST2[0],vertexEST.EST2[1]], FRONT2:[vertexWEST.WEST1[0],vertexWEST.WEST1[1]], FRONT3:[vertexEST.EST4[0],vertexEST.EST4[1]], FRONT4:[vertexWEST.WEST3[0],vertexWEST.WEST3[1]] }; rlm@46: rlm@46: NORTHmenusize=[vertexNORTHmenu.NORTHmenu4[0]-vertexNORTHmenu.NORTHmenu1[0],vertexNORTHmenu.NORTHmenu4[1]-vertexNORTHmenu.NORTHmenu1[1]]; rlm@46: NORTHglobalssize=[vertexNORTHglobals.NORTHglobals4[0]-vertexNORTHglobals.NORTHglobals1[0],vertexNORTHglobals.NORTHglobals4[1]-vertexNORTHglobals.NORTHglobals1[1]]; rlm@46: NORTHoptionssize=[vertexNORTHoptions.NORTHoptions4[0]-vertexNORTHoptions.NORTHoptions1[0],vertexNORTHoptions.NORTHoptions4[1]-vertexNORTHoptions.NORTHoptions1[1]]; rlm@46: SUDsize=[vertexSUD.SUD4[0]-vertexSUD.SUD1[0],vertexSUD.SUD4[1]-vertexSUD.SUD1[1]]; rlm@46: ESTsize=[vertexEST.EST4[0]-vertexEST.EST1[0],vertexEST.EST4[1]-vertexEST.EST1[1]]; rlm@46: WESTsize=[vertexWEST.WEST4[0]-vertexWEST.WEST1[0],vertexWEST.WEST4[1]-vertexWEST.WEST1[1]]; rlm@46: FRONTsize=[vertexFRONT.FRONT4[0]-vertexFRONT.FRONT1[0],vertexFRONT.FRONT4[1]-vertexFRONT.FRONT1[1]]; rlm@46: rlm@46: rlm@46: rlm@46: //percent of FRONTsize rlm@46: proporDoc= FRONTsize[0]/FRONTsize[1]; rlm@46: canvasYpercent=100; rlm@46: canvasXpercent=100; rlm@46: canvasWidth=Math.round(FRONTsize[0]*canvasXpercent/100);//FRONTsize[0]; rlm@46: canvasW=canvasWidth; rlm@46: canvasHeight=Math.round(canvasYpercent*FRONTsize[1]/100);//FRONTsize[1]; rlm@46: canvasH=canvasHeight; rlm@46: canvasX=Math.round((FRONTsize[0]-canvasW)/2); rlm@46: canvasY=Math.round((FRONTsize[1]-canvasH)/2); rlm@46: rlm@46: rlm@46: //vertexFRONTcanvas={ FRONT1:[vertexEST.EST2[0],vertexEST.EST2[1]], FRONT2:[vertexWEST.WEST1[0],vertexWEST.WEST1[1]], FRONT3:[vertexEST.EST4[0],vertexEST.EST4[1]], FRONT4:[vertexWEST.WEST3[0],vertexWEST.WEST3[1]] }; rlm@46: //FRONTcanvassize=[vertexFRONT.FRONT4[0]-vertexFRONT.FRONT1[0],vertexFRONT.FRONT4[1]-vertexFRONT.FRONT1[1]]; rlm@46: rlm@46: rlm@46: //centerZoomx=Math.round(canvasWidth/2); rlm@46: //centerZoomy=Math.round(canvasHeight/2); rlm@46: if(canvasH==0){ canvasH=0.00000001; } rlm@46: proporCanvas= canvasW/canvasH ; rlm@46: //zoominit='0 0 '+zoomw+' '+zoomh;// rlm@46: rlm@46: makeWorkSite(canvasH,(-canvasW/2)+(docw/2),(-canvasH/2)+(doch/2)); rlm@46: diagonalinit=diagonalFrame; rlm@46: proporDiagonal=diagonalFrame/diagonalinit; rlm@46: zoominit=(zoomx)+' '+(zoomy)+' '+zoomw+' '+zoomh; rlm@46: //$('someinfo').value= zoominit; rlm@46: //document.forms[0].someinfo.value= zoominit; rlm@46: //document.getElementById("someinfo").value = zoominit rlm@46: //Ext.get('richdraw').dom.style.scrollTop = ('40%'); rlm@46: //alert(zoominit); rlm@46: } rlm@46: rlm@46: function resizeFrame(){ rlm@46: rlm@46: Ext.get('NORTHmenu').dom.style.backgroundColor = (colorpage1a); rlm@46: Ext.get('NORTHglobals').dom.style.backgroundColor = (colorpage1b); rlm@46: Ext.get('NORTHoptions').dom.style.backgroundColor = (colorpage1c); rlm@46: rlm@46: Ext.get('SUD').dom.style.backgroundColor = (colorpage2); rlm@46: Ext.get('EST').dom.style.backgroundColor = (colorpage3); rlm@46: Ext.get('WEST').dom.style.backgroundColor = (colorpage4); rlm@46: rlm@46: Ext.get('linksPaths').dom.style.backgroundColor = (colorpage); // bad rlm@46: rlm@46: rlm@46: Ext.get('NORTHmenu').dom.style.left =(vertexNORTHmenu.NORTHmenu1[0]+'px'); Ext.get('NORTHmenu').dom.style.top =(vertexNORTHmenu.NORTHmenu1[1]+'px');Ext.get('NORTHmenu').dom.style.width =(NORTHmenusize[0]+'px'); Ext.get('NORTHmenu').dom.style.height = (NORTHmenusize[1]+'px'); rlm@46: Ext.get('NORTHglobals').dom.style.left =(vertexNORTHglobals.NORTHglobals1[0]+'px'); Ext.get('NORTHglobals').dom.style.top =(vertexNORTHglobals.NORTHglobals1[1]+'px');Ext.get('NORTHglobals').dom.style.width =(NORTHglobalssize[0]+'px'); Ext.get('NORTHglobals').dom.style.height =(NORTHglobalssize[1]+'px'); rlm@46: Ext.get('NORTHoptions').dom.style.left =(vertexNORTHoptions.NORTHoptions1[0]+'px'); Ext.get('NORTHoptions').dom.style.top =(vertexNORTHoptions.NORTHoptions1[1]+'px');Ext.get('NORTHoptions').dom.style.width =(NORTHoptionssize[0]+'px'); Ext.get('NORTHoptions').dom.style.height =(NORTHoptionssize[1]+'px'); rlm@46: Ext.get('SUD').dom.style.left =(vertexSUD.SUD1[0]+'px'); Ext.get('SUD').dom.style.top =(vertexSUD.SUD1[1]+'px');Ext.get('SUD').dom.style.width=(SUDsize[0]+'px'); Ext.get('SUD').dom.style.height =(SUDsize[1]+'px'); rlm@46: Ext.get('EST').dom.style.left =(vertexEST.EST1[0]+'px'); Ext.get('EST').dom.style.top =(vertexEST.EST1[1]+'px');Ext.get('EST').dom.style.width=(ESTsize[0]+'px'); Ext.get('EST').dom.style.height =((ESTsize[1]+'px')); rlm@46: Ext.get('WEST').dom.style.left =(vertexWEST.WEST1[0]+'px'); Ext.get('WEST').dom.style.top =(vertexWEST.WEST1[1]+'px');Ext.get('WEST').dom.style.width=(WESTsize[0]+'px'); Ext.get('WEST').dom.style.height =((WESTsize[1]+'px')); rlm@46: Ext.get('FRONT').dom.style.left =(vertexFRONT.FRONT1[0]+'px'); Ext.get('FRONT').dom.style.top =(vertexFRONT.FRONT1[1]+'px');Ext.get('FRONT').dom.style.width=(FRONTsize[0]+'px'); Ext.get('FRONT').dom.style.height =(FRONTsize[1]+'px'); rlm@46: rlm@46: Ext.get('richdraw').dom.style.left =(canvasX+'px'); Ext.get('richdraw').dom.style.top =(canvasY+'px');Ext.get('richdraw').dom.style.width=(canvasW+'px'); Ext.get('richdraw').dom.style.height =(canvasH+'px'); rlm@46: rlm@46: } rlm@46: rlm@46: function documentProperties(){ rlm@46: var tokens = zoominit.split(' '); rlm@46: rlm@46: document.forms[0].xDocument.value=tokens[0]; rlm@46: document.forms[0].yDocument.value=tokens[1]; rlm@46: rlm@46: document.forms[0].widthDocument.value=tokens[2]; rlm@46: document.forms[0].heightDocument.value=tokens[3]; rlm@46: showdocFrame('Document properties') rlm@46: //docFrame.setTitle('Document properties'); rlm@46: //docFrame.show(); rlm@46: rlm@46: } rlm@46: function changeDocumentProperties(){ rlm@46: rlm@46: //percent of FRONTsize rlm@46: proporSpace= FRONTsize[0]/FRONTsize[1]; rlm@46: //PERCENT rlm@46: rlm@46: //canvasYpercent=95; rlm@46: //canvasXpercent=97; rlm@46: /* rlm@46: canvasWidth=Math.round(FRONTsize[0]*canvasXpercent/100);//FRONTsize[0]; rlm@46: canvasW=canvasWidth; rlm@46: canvasHeight=Math.round(canvasYpercent*FRONTsize[1]/100);//FRONTsize[1]; rlm@46: canvasH=canvasHeight; rlm@46: */ rlm@46: rlm@46: docx=eval(document.forms[0].xDocument.value); rlm@46: docy=eval(document.forms[0].yDocument.value); rlm@46: rlm@46: docw=eval(document.forms[0].widthDocument.value); rlm@46: doch=eval(document.forms[0].heightDocument.value); rlm@46: zoominit= docx+' '+docy+' '+docw+' '+doch; rlm@46: c.renderer.view(docx,docy,docw,doch,zoominit); rlm@46: borderDoc(); rlm@46: rlm@46: //doResize(); rlm@46: //canvasX=Math.round((FRONTsize[0]-canvasW)/2); rlm@46: //canvasY=Math.round((FRONTsize[1]-canvasH)/2); rlm@46: rlm@46: rlm@46: //Ext.get('richdraw').dom.style.left =(canvasX+'px'); Ext.get('richdraw').dom.style.top =(canvasY+'px');Ext.get('richdraw').dom.style.width=(canvasW+'px'); Ext.get('richdraw').dom.style.height =(canvasH+'px'); rlm@46: rlm@46: } rlm@46: function makeWorkSite(width,left,top) { rlm@46: fieldViewx=Math.round(width*proporCanvas)*1; rlm@46: fieldViewy=width*1; rlm@46: diagonalFrame=dist2p(0,0,fieldViewx*1,fieldViewy*1); rlm@46: diagonalAngle=getAngle(fieldViewx,fieldViewy); rlm@46: diagonalMidx=fieldViewx/2; rlm@46: diagonalMidy=fieldViewy/2; rlm@46: centerZoomx=diagonalMidx; rlm@46: centerZoomy=diagonalMidy; rlm@46: rlm@46: //alert(diagonalinit+' '+diagonalFrame+' '+proporDiagonal); rlm@46: //alert(canvasW+''+canvasW+' propor:'+proporCanvas+' Docy:'+docy+' fieldView:'+fieldViewx+' '+fieldViewy); rlm@46: zoomx=(diagonalMidx+(diagonalFrame/2)*Math.cos(diagonalAngle+Math.PI))+left;//-(fieldViewx/8);//-(canvasW/2)docx-fieldViewx; rlm@46: zoomy=(diagonalMidy+(diagonalFrame/2)*Math.sin(diagonalAngle+Math.PI))+top;//-(fieldViewy/8);//-(canvasH/2);//docy-fieldViewy; rlm@46: zoomw=diagonalMidx+(diagonalFrame/2)*Math.cos(diagonalAngle);//fieldViewx*1.25;//docw+fieldViewx*2; rlm@46: zoomh=diagonalMidy+(diagonalFrame/2)*Math.sin(diagonalAngle);//fieldViewy*1.25;//doch+fieldViewy*2; rlm@46: } rlm@46: rlm@46: rlm@46: function RichDrawViewer(elem, renderer) rlm@46: { rlm@46: this.container = elem; rlm@46: this.renderer = renderer; rlm@46: this.renderer.init(this.container); rlm@46: this.renderer.editor = this; rlm@46: } rlm@46: /* rlm@46: onResize : function(){ rlm@46: Ext.TabPanel.superclass.onResize.apply(this, arguments); rlm@46: this.delegateUpdates(); rlm@46: }, rlm@46: */