var PMUI={version:"1.0.0",isCtrl:!1,isShift:!1,activeCanvas:null,currentContextMenu:null}; $(document).keydown(function(a){if(PMUI.activeCanvas)switch(a.which){case 16:PMUI.isShift=!0;break;case 17:PMUI.isCtrl=!0;break;case 116:a.preventDefault();window.location.reload(!0);break;case 37:PMUI.activeCanvas.currentLabel||(a.preventDefault(),PMUI.activeCanvas.moveElements(PMUI.activeCanvas,"LEFT"));break;case 38:PMUI.activeCanvas.currentLabel||(a.preventDefault(),PMUI.activeCanvas.moveElements(PMUI.activeCanvas,"TOP"));break;case 39:PMUI.activeCanvas.currentLabel||(a.preventDefault(),PMUI.activeCanvas.moveElements(PMUI.activeCanvas, "RIGHT"));break;case 40:PMUI.activeCanvas.currentLabel||(a.preventDefault(),PMUI.activeCanvas.moveElements(PMUI.activeCanvas,"BOTTOM"));break;case 67:!PMUI.activeCanvas.currentLabel&&PMUI.isCtrl&&(a.preventDefault(),PMUI.activeCanvas.copy());break;case 86:!PMUI.activeCanvas.currentLabel&&PMUI.isCtrl&&(a.preventDefault(),PMUI.activeCanvas.paste());break;case 90:PMUI.isCtrl&&(PMUI.isShift?PMUI.activeCanvas.redo():PMUI.activeCanvas.undo(),a.preventDefault())}}).keypress(function(a){}).keyup(function(a){a.preventDefault(); switch(a.which){case 8:PMUI.isCtrl&&PMUI.activeCanvas&&!PMUI.activeCanvas.currentLabel&&PMUI.activeCanvas.removeElements();break;case 13:PMUI.activeCanvas&&PMUI.activeCanvas.currentLabel&&PMUI.activeCanvas.currentLabel.loseFocus();break;case 46:PMUI.activeCanvas&&!PMUI.activeCanvas.currentLabel&&PMUI.activeCanvas.removeElements();break;case 16:PMUI.isShift=!1;break;case 17:PMUI.isCtrl=!1;break;case 113:PMUI.activeCanvas&&null!==PMUI.activeCanvas.getCurrentSelection().getLast()&&(a=PMUI.activeCanvas.getCurrentSelection().getLast(), void 0!==a&&null!==a.label.html&&($(a.label.html).dblclick(),$(a.label.text.html).focus()))}});PMUI.extendNamespace=function(a,b){var f,c,d,e;if(2!==arguments.length)throw Error("PMUI.extendNamespace(): method needs 2 arguments");c=a.split(".");"PMUI"===c[0]&&(c=c.slice(1));f=PMUI;for(e=0;eb.length){a="";for(c=0;c<1+(f-b.length);c+=1)a+="0";return a+b}return b};this.php_js||(this.php_js={});this.php_js.uniqidSeed||(this.php_js.uniqidSeed=Math.floor(123456789*Math.random())); this.php_js.uniqidSeed+=1;a=b+g(parseInt((new Date).getTime()/1E3,10),8);a+=g(this.php_js.uniqidSeed,5);f&&(a+=(10*Math.random()).toFixed(8).toString());return a},f;do f=b(a(0,999999999),!0),f=f.replace(".","0");while(32!==f.length);return f};PMUI.createHTMLElement=function(a){return document.createElement(a)}; PMUI.calculateWidth=function(a,b){var f=b||"12px arial",c=$(this.createHTMLElement("div"));c.text(a).css({position:"absolute","float":"left","white-space":"nowrap",visibility:"hidden",font:f}).appendTo($("body"));f=c.width();c.remove();return f};PMUI.getVersion=function(){return this.version}; PMUI.triggerEvent=function(a,b,f){if(a instanceof PMUI.core.Element)if(a.events[b]instanceof PMUI.event.Event)a.events[b].handler.call(f||this);else throw Error("Event name is not registered int this element");else throw Error("Current Element is not able to trigger events");};PMUI.setActiveCanvas=function(a){PMUI.activeCanvas=a;return this};PMUI.getActiveCanvas=function(){return PMUI.activeCanvas}; PMUI.pageCoordinatesToShapeCoordinates=function(a,b,f,c){f=!f?b.pageX:f;b=!c?b.pageY:c;c=a.getCanvas();f+=c.getLeftScroll()-a.getAbsoluteX()-c.getX();b+=c.getTopScroll()-a.getAbsoluteY()-c.getY();return new PMUI.util.Point(f,b)};PMUI.getPointRelativeToPage=function(a){var b=a.getCanvas(),f=a.absoluteX+b.getX()-b.getLeftScroll()+a.zoomWidth/2;a=a.absoluteY+b.getY()-b.getTopScroll()+a.zoomHeight/2;return new PMUI.point.Point(f,a)}; PMUI.json2xml=function(a){var b,f,c,d;b=function(b){var f=0,a;for(a in b)b.hasOwnProperty(a)&&(f+=1);return f};f=function(a,d){var h,k,l="<"+a,m=!1;if("undefined"===typeof d||null===d)return l+"/>";if("object"!==typeof d)return l+=">"+c(d)+"";if(d.constructor===Object){for(h in d)if(d.hasOwnProperty(h)&&"@"===h.charAt(0))if("object"!==typeof d[h])l+=" "+h.substring(1)+'="'+d[h]+'"',delete d[h];else throw Error(typeof d[h]+" being attribute is not supported.");0===b(d)?(l+="/>",m=!0):l+=">"; if(m)return l;if("undefined"!==typeof d["#text"])if("object"!==typeof d["#text"])l+=d["#text"],delete d["#text"];else throw Error(typeof d["#text"]+" being #text is not supported.");for(k in d)if(d.hasOwnProperty(k))if(d[k].constructor===Array)for(h=0;h"}};c=function(b){b=b.toString();b=b.replace(/\&/g,"&");b=b.replace(/\"/g,""");b=b.replace(//g,">")};if("object"===typeof a&&a.constructor===Object&&1===b(a))for(d in a)if(a.hasOwnProperty(d))return f(d,a[d])};PMUI.removeContextMenu=function(){PMUI.currentContextMenu&&(document.body.removeChild(PMUI.currentContextMenu.html),PMUI.currentContextMenu=null);return this};PMUI.getContextMenu=function(){return PMUI.currentContextMenu}; PMUI.setContextMenu=function(a,b){var f,c;b&&a.addEvent("contextmenu").listen(a.html,function(d){d.preventDefault();PMUI.removeContextMenu();PMUI.currentContextMenu=new PMUI.ui.Menu(b);f=PMUI.currentContextMenu;f.setParentWidget(a);c=f.listeners.clickParent;c(f.parent,d);d.stopPropagation()})};PMUI.showContextMenu=function(a){var b=PMUI.getContextMenu();b&&(document.body.appendChild(b.getHTML()),b.show(a.x,a.y),b.defineEvents())};"undefined"!==typeof exports&&(module.exports=PMUI); (function(){var a=function(){var b=[],f=0,a,d;return{id:Math.random(),get:function(f){return b[f]},insert:function(a){b[f]=a;f+=1;return this},remove:function(d){a=this.indexOf(d);if(-1===a)return!1;f-=1;b.splice(a,1);return!0},getSize:function(){return f},isEmpty:function(){return 0===f},indexOf:function(a){for(d=0;db[d].y&&(a[0]=b[d].y),a[1]b[d].x&&(a[3]=b[d].x);return a},clear:function(){0!==f&&(b=[],f=0);return this}}};PMUI.extendNamespace("PMUI.util.ArrayList", a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(b){this.belongsTo=this.cssClasses=this.cssProperties=null;a.prototype.initObject.call(this,b)};a.prototype.type="Style";a.MAX_ZINDEX=100;a.prototype.initObject=function(b){var f={cssClasses:[],cssProperties:{},belongsTo:null};jQuery.extend(!0,f,b);this.cssClasses=f.cssClasses;this.cssProperties=f.cssProperties;this.belongsTo=f.belongsTo};a.prototype.applyStyle=function(){if(!this.belongsTo.html)throw Error("applyStyle(): can't apply style to an object with no html");var b, f;b=this.belongsTo.type.toLowerCase();jQuery(this.belongsTo.html).addClass("pmui-"+b);jQuery(this.belongsTo.html).css(this.cssProperties);for(b=0;b=b)&&(this.red=b);return this};a.prototype.setGreen=function(b){"number"=== typeof b&&(0<=b&&255>=b)&&(this.green=b);return this};a.prototype.setBlue=function(b){"number"===typeof b&&(0<=b&&255>=b)&&(this.blue=b);return this};a.prototype.setOpacity=function(b){"number"===typeof b&&(0<=b&&255>=b)&&(this.opacity=b);return this};a.prototype.getCSS=function(){return"rgba("+this.red+","+this.green+","+this.blue+","+this.opacity+")"};PMUI.extendNamespace("PMUI.util.Color",a)})(); (function(){var a=function(b,f){this.x=b;this.y=f};a.prototype.type="Point";a.prototype.getX=function(){return this.x};a.prototype.getY=function(){return this.y};a.prototype.add=function(b){return new a(this.x+b.x,this.y+b.y)};a.prototype.subtract=function(b){return new a(this.x-b.x,this.y-b.y)};a.prototype.multiply=function(b){return new a(this.x*b,this.y*b)};a.prototype.equals=function(b){return Math.abs(this.x-b.x)h&&(k=2,l=1);k=!e?k:e;l=!g?l:g;if(0===d)for(;0=k?(this._mkDiv(b,f,k,1),b+=k+l,a-=k+l):(this._mkDiv(b,f,a,1),a=0);else for(;0< d;)d>=k?(this._mkDiv(b,f,1,k),f+=k+l,d-=k+l):(this._mkDiv(b,f,1,d),d=0)}};a.prototype.makeSegmentDotLine=function(b,f,a,d,e,g){var h;if(!(a!==b&&d!==f)){if(a===b){if(d===f)return;a=0;d=e?(this._mkDiv(b,f,e,1),a-=e+g,b+=e+g,0=e?(this._mkDiv(b,f,1,e),d-=e+g,f+=e+g,0=Math.min(f.x,a.x)&&b.x<=Math.max(f.x,a.x)&&b.y>=Math.min(f.y,a.y)&&b.y<=Math.max(f.y,a.y)},perpendicularSegmentIntersection:function(b,f,a,d){var e,g=null;if(b.x>f.x||b.y>f.y)e=b.clone(),b=f.clone(),f=e;if(a.x>d.x||a.y>d.y)e=a.clone(),a=d.clone(), d=e;b.x===f.x?a.y===d.y&&(a.xh||0>g&&0l||0>k&&0=f.x&&b.x<=a.x&&b.y>=f.y&&b.y<=a.y},pointInCircle:function(b,f,a){return f.getDistance(b)<=a},pointInRhombus:function(b,f,a){var d,e=f.length-1;for(d=0;doptgroup[label="'+a+'"]')}if("number"===typeof f)d.options[f].disabled=b,e.find(">*").eq(f).attr("disabled",b);else if("string"===typeof f){for(g=0;goptgroup[label="'+f+'"]')}if("number"===typeof b)a.options.splice(b,1),d.find(">*").eq(b).remove();else if("string"===typeof b){for(e=0;ed?-1:1)*parseInt(e[1],10)):l=m=n=d=e=0;if(!this.isValidDateTime(g, h,k,l,m,n))throw Error("setValue(): invalid date time.");a.setFullYear(g);a.setMonth(h-1);a.setDate(k);a.setHours(l);a.setMinutes(m);a.setSeconds(n);a.setMilliseconds(0);a.setHours(a.getHours()+d);a.setMinutes(a.getMinutes()+e);p||f?(this.dateObject.setUTCFullYear(a.getFullYear()),this.dateObject.setUTCMonth(a.getMonth()),this.dateObject.setUTCDate(a.getDate()),this.dateObject.setUTCHours(a.getHours()),this.dateObject.setUTCMinutes(a.getMinutes()),this.dateObject.setUTCSeconds(a.getSeconds())):(this.dateObject.setFullYear(g), this.dateObject.setMonth(h-1),this.dateObject.setDate(k),this.dateObject.setHours(l),this.dateObject.setMinutes(m),this.dateObject.setSeconds(n),this.dateObject.setMilliseconds(0));a=null}else q=!0;else q=!0;if(q)throw Error("setValue(): Invalid parameter format/data type.");this.dateObject||(this.dateObject=new Date);a&&(this.dateObject.setFullYear(a.getFullYear()),this.dateObject.setMonth(a.getMonth()),this.dateObject.setDate(a.getDate()),this.dateObject.setHours(a.getHours()),this.dateObject.setMinutes(a.getMinutes()), this.dateObject.setSeconds(a.getSeconds()));this.html&&(this.html.value=this.formatDate(this.dateObject,this.dateFormat));this.value=this.getValue("UTC");return this};a.prototype.setFirstDay=function(b){if("number"===typeof b&&0<=b&&7>b)return this.firstDay=Math.floor(b),this.html&&(this.setDays(this.days),this.buildDaysTable()),this;throw Error("setFirstDay(): The parameter must be a number between 0 and 6.");};a.prototype.setDateFormat=function(b){if("string"===typeof b)this.dateFormat=b,this.updateValue(); else throw Error("setDateFormat(): The parameter must be a string.");return this};a.prototype.getDateFormat=function(){return this.dateFormat};a.prototype.getFormatedDate=function(){return this.html.value};a.prototype.getValue=function(b){b=b||"UTC";if(this.dateObject)switch(b){case "timestamp":case "@":b=this.formatDate(this.dateObject,"@");break;default:b=this.formatDate(this.dateObject,b)}else b="";return b};a.prototype.isLeapYear=function(b){return 0===b%400?!0:0===b%100?!1:0===b%4?!0:!1};a.prototype.isValidDateTime= function(b,f,a,d,e,g,h){if(!("number"===typeof b&&"number"===typeof f&&"number"===typeof a))return!1;d=d||0;e=e||0;g=g||0;h=h||0;if(!("number"===typeof d&&"number"===typeof e&&"number"===typeof g&&"number"===typeof h)||!(0<=d&&23>=d)||!(0<=e&&59>=e)||!(0<=g&&59>=g)||!(0<=h&&999>=h)||1>a||31f||12=a:28>=a}return!0};a.prototype.parseDate=function(b){var f,a,d,e;if("number"===typeof b)f= new Date,f.setDate(f.getDate()+b);else if("string"===typeof b){if(f=new Date,b=" "+jQuery.trim(b),/^(\s[\+|\-]\d+[y|m|d|w])+$/.test(b)){b=b.match(/[\+|\-]\d+[y|m|d]/g);for(d=0;dthis.maxDate)throw Error("setMinDate(): The min date can't be major than the max date");this.minDate=b;this.fillYearSelector();this.fillMonthSelector();this.buildDaysTable();this.html&&(a=new Date,this.dom.todayButton.disabled=!(a>=b&&this.maxDate&&a<=this.maxDate));return this};a.prototype.setMaxDate= function(b){b=this.parseDate(b);var a;if(this.minDate&&b=this.minDate));return this};a.prototype.setMonths=function(b){var a,c;for(a in this.months)this.months.hasOwnProperty(a)&&b.hasOwnProperty(a)&&("string"===typeof b[a]?(c=!0,this.months[a].name= b[a],this.months[a].shortname=b[a].charAt(0).toUpperCase()+b[a].slice(1,3)):"object"===typeof b[a]&&(this.months[a].name=b[a].name,this.months[a].shortname=b[a].shortname,c=!0));c&&this.fillMonthSelector();return this};a.prototype.fillMonthSelector=function(){var b,a,c,d;if(this.html){a=this.dom.yearSelector.value;b=this.dom.monthSelector.value||(new Date).getMonth().toString();jQuery(this.dom.monthSelector).empty();c=0;d=this.monthsOrder.length-1;a===this.minDate.getFullYear().toString()&&(c=this.minDate.getMonth()); a===this.maxDate.getFullYear().toString()&&(d=this.maxDate.getMonth());for(c;c<=d;c+=1)a=PMUI.createHTMLElement("option"),a.label=this.months[this.monthsOrder[c]].name,a.textContent=a.label,a.value=this.months[this.monthsOrder[c]].value,a.selected=b===a.value.toString(),this.dom.monthSelector.appendChild(a)}return this};a.prototype.setDays=function(b){var a,c,d=this.daysOrder.length;for(a in this.days)if(this.days.hasOwnProperty(a)&&b.hasOwnProperty(a)){if("string"===typeof b[a])this.days[a].name= b[a],this.days[a].shortname=b[a].substr(0,3);else if("object"===typeof b[a])this.days[a].name=b[a].name||this.days[a].name||"",this.days[a].shortname=b[a].shortname&&b[a].shortname.substr(0,3)||this.days[a].name&&this.days[a].name.substr(0,3)||"";else throw Error("setDays(): The argument supplied must be a string or an object.");c=!0}if(c&&this.html){jQuery(this.dom.daysHeader).empty();c=0;for(b=this.firstDay;ca||12b&&(b=7+b);a=this.daysInMonth(c,d);l=7*Math.ceil((b+a)/7); h=PMUI.createHTMLElement("tr");for(e=0;ethis.maxDate.getDate()&&(m=!1):d-1===this.minDate.getMonth()&&c===this.minDate.getFullYear()&&gn?"+":"-";n=Math.sqrt(n*n);q=Math.floor(n/60);n-=60*q;p+=(10>q?"0":"")+q+":"+(10>n?"0":"")+n;d=[{regExp:/dd/g,value:10>c?"0"+c:c},{regExp:/d/g,value:c},{regExp:/oo/g,value:10>d?"00"+d:100>d?"0"+d:d},{regExp:/o/g,value:d},{regExp:/mm/g,value:10>e?"0"+e:e},{regExp:/m/g,value:e},{regExp:/yy/g,value:m},{regExp:/y/g,value:m%100},{regExp:/\@/g,value:b.getTime()},{regExp:/\!/g,value:1E4*b.getTime()+621355968E9},{regExp:/MM/g,value:this.months[this.monthsOrder[b.getMonth()]].name},{regExp:/M/g,value:this.months[this.monthsOrder[b.getMonth()]].shortname}, {regExp:/HH/g,value:(10>g?"0":"")+g},{regExp:/H/g,value:g},{regExp:/hh/g,value:(10>h?"0":"")+h},{regExp:/h/g,value:h},{regExp:/ii/g,value:(10>k?"0":"")+k},{regExp:/i/g,value:k},{regExp:/ss/g,value:(10>l?"0":"")+l},{regExp:/s/g,value:l},{regExp:/UTC/g,value:m+"-"+(10>e?"0":"")+e+"-"+(10>c?"0":"")+c+"T"+(10>g?"0":"")+g+":"+(10>k?"0":"")+k+":"+(10>l?"0":"")+l+p},{regExp:/P/g,value:12').find("h2").text(b):$(this.header).append('

').find("h2").html(" "),this.updateDimensions()));return this};a.prototype.setName=function(b){this.name=b;this.html&&(this.html.name=b);return this}; a.prototype.setAction=function(b){this.action=b;this.html&&(this.html.action=b);return this};a.prototype.setEncType=function(b){this.encType=b;this.html&&(this.html.encType=b);return this};a.prototype.showHeader=function(){this.visibleHeader=!0;this.header.style.display="";this.updateDimensions();return this};a.prototype.hideHeader=function(){this.visibleHeader=!1;this.header.style.display="none";this.updateDimensions();return this};a.prototype.isValid=function(){return this.panel.isValid()};a.prototype.submit= function(){if(this.isValid()&&"function"===typeof this.onSubmit)this.onSubmit(this.getData());return this};a.prototype.getData=function(){return this.data};a.prototype.defineEvents=function(){var b=this.buttons.asArray(),a;for(a=0;a=parseInt(this.criteria.minLength,10));return this};PMUI.extendNamespace("PMUI.form.TextLengthValidator",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(b){a.superclass.call(this,b);a.prototype.init.call(this,b)};PMUI.inheritFrom("PMUI.form.Validator",a);a.prototype.type="RegExpValidator";a.prototype.init=function(b){var a={errorMessage:"The text pattern doesn't match"};$.extend(!0,a,b);this.setErrorMessage(a.errorMessage)};a.prototype.validate=function(){var b;this.parent&&this.parent.value?this.criteria instanceof RegExp?this.valid=this.criteria.test(this.parent.value):"string"===typeof this.criteria&&(b=RegExp(this.criteria.pattern, this.criteria.modifiers),this.valid=b.text(this.parent.value)):this.valid=!1;return this};PMUI.extendNamespace("PMUI.form.RegExpValidator",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(){a.superclass.call(this);a.prototype.init.call(this)};PMUI.inheritFrom("PMUI.util.Factory",a);a.prototype.init=function(){this.setProducts({textLength:PMUI.form.TextLengthValidator,regexp:PMUI.form.RegExpValidator}).setDefaultProduct("textLength")};PMUI.extendNamespace("PMUI.form.ValidatorFactory",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(b){a.superclass.call(this,b);var f=["north","center","south","east","west"],c={size:"size",closed:"initClosed",resizable:"resizable",closable:"closable",togglerOpen:"togglerLength_open",togglerClosed:"togglerLength_closed",overflow:"allowOverflow",hidden:"initHidden",cssProperties:"cssProperties",cssClasses:"cssClasses"};this.panels={};this.instance=this.west=this.east=this.south=this.center=this.north=null;a.prototype.getConfig=function(){return{panels:this.panels,prefix:"ui-layout-", positions:f,isSetting:function(b){return"undefined"!==typeof c[b]},transformSetting:function(b){return c[b]}}};a.prototype.setConfig=function(b,a){this.panels[b]=a;return this};a.prototype.init.call(this,b)};PMUI.inheritFrom("PMUI.core.Panel",a);a.prototype.type="LayoutPanel";a.prototype.init=function(b){var a={center:{cssProperties:{},cssClasses:[]},factory:{products:{layout:PMUI.panel.LayoutPanel,treePanel:PMUI.panel.TreePanel,panel:PMUI.core.Panel},defaultProduct:"panel"}};jQuery.extend(!0,a,b); this.setFactory(a.factory).setPluginSettings(a).setPanels(a)};a.prototype.setPluginSettings=function(b){var a=this.getConfig(),c=this;jQuery.each(a.positions,function(d,e){var g=b[e],h={};if(g){c.factory&&c.factory.isValidClass(g)?h=b[e+"Config"]||{}:jQuery.each(g,function(b,c){a.isSetting(b)&&(h[a.transformSetting(b)]=c)});if(!h.cssClasses||!jQuery.isArray(h.cssClasses))h.cssClasses=[];h.cssClasses.push(a.prefix+e);c.setConfig(e,h)}});return this};a.prototype.setPanels=function(b){var a=this.getConfig(), c=this,d;jQuery.each(a.positions,function(e,g){b[g]&&(c[g]=c.factory.make(b[g]),c[g]instanceof PMUI.panel.LayoutPanel&&c.setConfig(g,jQuery.extend(!0,a.panels[g],{instance:c[g]})),c[g]instanceof PMUI.panel.TreePanel&&(d={cssProperties:c[g].style.cssProperties,cssClasses:c[g].style.cssClasses},c.setConfig(g,jQuery.extend(!0,a.panels[g],d))),c[g].style.cssProperties=a.panels[g].cssProperties||{},c[g].style.cssClasses=a.panels[g].cssClasses||[a.prefix+g],c.addItem(c[g]))});return this};a.prototype.createHTML= function(){var b,f;f=this.items.asArray();a.superclass.prototype.createHTML.call(this);for(b=0;bthis.maxLenght?this.text.substr(0,this.maxLenght-3)+"...":this.text;d.appendChild(document.createTextNode(k));h=document.createElement("div");h.className="pmui-"+this.family.toLowerCase()+"-"+this.type.toLowerCase();h.appendChild(a); h.appendChild(c);h.appendChild(d);parseInt(this.maxLenght,10);h.setAttribute("style","padding-left:"+this.space+"px;");b.id=this.id;this.addEvent("click").listen(d,function(b){g=jQuery("#"+e.idTreePanel+" li").children();jQuery(g).removeClass("pmui-item-selected");jQuery(h).addClass("pmui-item-selected");l=e.listeners.select;l(e,e.relationship.shape,b);b.stopPropagation()});b.appendChild(h);0e&&c.shift();f()},addToRedo:function(b){d.push(b)},undo:function(){var b;if(0===c.length)return console.log("undo(): can't undo because there are no actions to undo"),!1;b=c.pop();b.undo();d.unshift(b);f();return!0},redo:function(){var b;if(0===d.length)return console.log("redo(): can't redo because there are no actions to redo"), !1;b=d.shift();b.redo();c.push(b);f();return!0},clearStack:function(){console.log("CommandStack.clearStack(): WARNING - clearing the stacks");d=[];c=[]},debug:function(b){var a;console.log("Debugging command stack:");console.log("Undo stack size: "+c.length);if(b)for(a=0;ab;b+=1)this.cornerResizeHandlers.insert(new PMUI.draw.ResizeHandler({parent:this,zOrder:PMUI.util.Style.MAX_ZINDEX+3,representation:new PMUI.draw.Rectangle,orientation:this.cornersIdentifiers[b],resizableStyle:c,nonResizableStyle:d}));a-=4;for(b=0;bc&&(m=b-c,p=!0,this.oldAbsoluteX=this.oldX=this.x,this.oldY=this.y, this.oldAbsoluteY=this.absoluteY);0>d&&(n=b-d,p=!0,this.oldAbsoluteX=this.oldX=this.x,this.oldY=this.y,this.oldAbsoluteY=this.absoluteY);k+=m;l+=n;e>this.width&&(k+=e-this.width+b,q=!0,this.oldWidth=this.width);a>this.height&&(l+=a-this.height+b,q=!0,this.oldHeight=this.height);this.setPosition(g-m,h-n);this.setDimension(k,l);p&&this.changePosition(this.oldX,this.oldY,this.absoluteX,this.absoluteY);q&&this.changeSize(this.oldWidth,this.oldHeight);this.updateChildrenPosition(m,n);return this};a.prototype.applyZoom= function(){this.refreshShape();return this};a.prototype.setDimension=function(b,f){a.superclass.prototype.setDimension.call(this,b,f);this.xCorners&&(this.xCorners=[0,Math.round(this.zoomWidth),Math.round(this.zoomWidth),0],this.yCorners=[0,0,Math.round(this.zoomHeight),Math.round(this.zoomHeight)],this.xMidPoints=[Math.round(this.zoomWidth/2),Math.round(this.zoomWidth),Math.round(this.zoomWidth/2),0],this.yMidPoints=[0,Math.round(this.zoomHeight/2),Math.round(this.zoomHeight),Math.round(this.zoomHeight/ 2)],this.updateHandlers());return this};a.prototype.changeParent=function(b,a,c,d,e,g){g.updatedElement={id:this.id,type:this.type,fields:[{field:"x",oldVal:b,newVal:this.x},{field:"y",oldVal:a,newVal:this.y},{field:"absoluteX",oldVal:c,newVal:this.absoluteX},{field:"absoluteY",oldVal:d,newVal:this.absoluteY},{field:"parent",oldVal:e,newVal:this.parent}],relatedObject:this};$(g.html).trigger("changeelement");return this};a.prototype.changeSize=function(b,a){var c=this.canvas;c.updatedElement={id:this.id, type:this.type,fields:[{field:"width",oldVal:b,newVal:this.width},{field:"height",oldVal:a,newVal:this.height}],relatedObject:this};$(c.html).trigger("changeelement");return this};a.prototype.changePosition=function(b,a,c,d){var e=this.canvas;e.updatedElement={id:this.id,type:this.type,fields:[{field:"x",oldVal:b,newVal:this.x},{field:"y",oldVal:a,newVal:this.y},{field:"absoluteX",oldVal:c,newVal:this.absoluteX},{field:"absoluteY",oldVal:d,newVal:this.absoluteY}],relatedObject:this};$(e.html).trigger("changeelement"); return this};a.prototype.setFixed=function(b){"boolean"===typeof b&&(this.fixed=b);return this};a.prototype.fixZIndex=function(b,a){var c,d,e,g;b.setZOrder(parseInt(b.parent.html.style.zIndex,10)+a+parseInt(b.defaultZOrder,10));for(c=0;cd;d+=1)if(b===m[d]){this.setPosition(e[d].x/k+a,e[d].y/k+c);break}}this.location=b;this.diffX=a;this.diffY=c;return this};a.prototype.getFocus=function(){var b=$(this.textField.html);this.displayText(!1); this.canvas.currentLabel=this;$(b).select();this.onFocus=!0;return this};a.prototype.loseFocus=function(){var b;this.canvas.currentLabel=null;this.textField.value!==this.message&&(b=new PMUI.command.CommandEditLabel(this,this.textField.value),b.execute(),this.canvas.commandStack.add(b),this.setLabelPosition(this.location,this.diffX,this.diffY));this.paint();this.onFocus=!1;return this};a.prototype.onMouseDown=function(b){return function(a,c){"Canvas"===b.parent.family&&a.stopPropagation()}};a.prototype.onClick= function(b){return function(a,c){"Canvas"===b.parent.family&&a.stopPropagation();b.onFocus&&a.stopPropagation()}};a.prototype.onDblClick=function(b){return function(a,c){var d=b.getCanvas();$(b.html);d.currentLabel&&d.currentLabel.loseFocus();b.getFocus()}};a.prototype.getZoomFontSize=function(){return this.fontSize=this.fontSizeOnZoom[this.canvas.zoomPropertiesIndex]};a.prototype.parseMessage=function(){var b;b=0;for(var a=[],c;" "===this.message.charAt(b);)b+=1;for(c=0;bb.zoomHeight-10?a+10:b.zoomHeight)/this.canvas.zoomFactor);b.updateChildrenPosition(0,0);b.refreshConnections();this.setLabelPosition(this.location,this.diffX,this.diffY);return this};a.prototype.updateHorizontally=function(){var b=this.parent,a=this.zoomWidth,c=this.zoomHeight,d=this.canvas.zoomFactor; b.setDimension((a>b.zoomWidth-10?a+10:b.zoomWidth)/d,(c>b.zoomHeight-10?c+10:b.zoomHeight)/d);b.refreshConnections();this.setLabelPosition(this.location,this.diffX,this.diffY);return this};a.prototype.stringify=function(){var b={},a={id:this.getID(),message:this.getMessage(),orientation:this.getOrientation(),position:{location:this.location,diffX:this.diffX,diffY:this.diffY}};$.extend(!0,b,a);return b};PMUI.extendNamespace("PMUI.draw.Label",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(b){this.layers=new PMUI.util.ArrayList;a.superclass.call(this,b);this.ports=new PMUI.util.ArrayList;this.labels=new PMUI.util.ArrayList;this.zoomProperties=new PMUI.util.ArrayList;this.limits=[0,0,0,0];this.border=[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}];this.dragType=this.CANCEL;this.connectAtMiddlePoints=this.startConnectionPoint=null;this.previousYDragPosition=this.previousXDragPosition=0;this.connectionType=null;a.prototype.init.call(this,b)};PMUI.inheritFrom("PMUI.draw.Shape", a);a.prototype.type="CustomShape";a.prototype.family="CustomShape";a.prototype.containerDropBehavior=null;a.prototype.connectionDropBehavior=null;a.prototype.noDropBehavior=null;a.prototype.CONNECT=1;a.prototype.DRAG=2;a.prototype.CANCEL=0;a.prototype.init=function(b){var a={connectAtMiddlePoints:!0,layers:[],labels:[],connectionType:"regular",drag:"customshapedrag"};this.limits=[5,5,5,5,5];this.setStartConnectionPoint(new PMUI.util.Point(0,0));$.extend(!0,a,b);for(b=0;bb.getPriority()&&c>g&&(c=g,a=e);return a};a.prototype.addLayer=function(b){var a=this.findLayerPosition(b);this.html&&(a?this.html.insertBefore(b.getHTML(),a.getHTML()):this.html.appendChild(b.getHTML()),b.paint()); this.layers.insert(b);return this};a.prototype.findLayer=function(b){return this.layers.find("id",b)};a.prototype.setDimension=function(b,f){a.superclass.prototype.setDimension.call(this,b,f);this.updateLabels();this.updateLayers();return this};a.prototype.updateLabels=function(){};a.prototype.hideLayer=function(b){if(!b||"string"!==typeof b)return this;b=this.findLayer(b);if(!b)return this;b.setVisible(!1);return this};a.prototype.showLayer=function(b){if(!b||"string"!==typeof b)return this;b=this.findLayer(b); if(!b)return this;b.setVisible(!0);return this};a.prototype.addPort=function(b,a,c,d,e){a=new PMUI.util.Point(a,c);b.setParent(this);b.setCanvas(this.canvas);this.definePortPosition(b,a,e);this.html.appendChild(b.getHTML());b.paint();this.ports.insert(b);return this};a.prototype.removePort=function(b){this.ports.remove(b);return this};a.prototype.definePortPosition=function(b,a,c){var d=[this.TOP,this.RIGHT,this.BOTTOM,this.LEFT],e=[new PMUI.util.Point(Math.round(this.zoomWidth/2),0),new PMUI.util.Point(this.zoomWidth, Math.round(this.zoomHeight/2)),new PMUI.util.Point(Math.round(this.zoomWidth/2),this.zoomHeight),new PMUI.util.Point(0,Math.round(this.zoomHeight/2))],g=[new PMUI.util.Point(a.x,0),new PMUI.util.Point(this.getZoomWidth(),a.y),new PMUI.util.Point(a.x,this.getZoomHeight()),new PMUI.util.Point(0,a.y)],h,k,l,m=[-1,1,1,-1],n=[0,0,-2,0],p=[0,-2,0,0],e=this.connectAtMiddlePoints?e:g;l="getSquaredDistance";c&&this.connectAtMiddlePoints&&(l="getManhattanDistance");c=void 0;k=Infinity;for(g=0;gh&&(k=h,c=d[g]);a=this.getBorderConsideringLayers();for(g=0;4>g;g+=1)this.border[g].x=a*m[g]+a*n[g],this.border[g].y=a*m[g]+a*p[g];b.setDirection(c);b.setPosition(e[c].x-b.getWidth()/2,e[c].y-b.getHeight()/2);b.applyBorderMargin(!0);b.determinePercentage();return this};a.prototype.getBorderConsideringLayers=function(){var b=parseInt(this.style.getProperty("borderTopWidth")||0,10),a,c;for(c=0;ca});return this};a.prototype.binarySearch=function(b){for(var a=0,c=this.data.length-1,d;a<=c;){d=parseInt((a+c)/2,10);if(this.data[d]===b)return b;this.data[d]>b?c=d-1:a=d+1}return!1};a.prototype.attachListeners=function(b){$(b.html).mousemove(function(){b.hide()});return this};a.prototype.setOrientation=function(b){if("horizontal"===b||"vertical"===b)this.orientation= b;else throw Error("setOrientation(): parameter is not valid");return this};a.prototype.getOrientation=function(){return this.orientation};PMUI.extendNamespace("PMUI.draw.Snapper",a);"undefined"!==typeof exports&&(module.exports=a)})();(function(){var a=function(){a.superclass.call(this)};PMUI.inheritFrom("PMUI.draw.Core",a);a.prototype.type="Router";a.prototype.createRoute=function(){return!0};PMUI.extendNamespace("PMUI.draw.Router",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(){a.superclass.call(this);this.mindist=20};PMUI.inheritFrom("PMUI.draw.Router",a);a.prototype.type="ManhattanConnectionRouter";a.prototype.createRoute=function(b){var a,c,d,e=[];a=b.srcPort.getPoint(!1);c=b.srcPort.direction;d=b.destPort.getPoint(!1);this.route(b,d,b.destPort.direction,a,c,e);return e};a.prototype.route=function(b,a,c,d,e,g){var h,k,l,m;h=a.x-d.x;k=a.y-d.y;0.01>h*h&&0.01>k*k?g.push(d):(3===c?0k*k&&1===e?(l=d,m=e):(0>h?l=new PMUI.util.Point(a.x-this.mindist, a.y):0k&&0===e?l=new PMUI.util.Point(d.x,a.y):c===e?(c=Math.min(a.x,d.x)-this.mindist,l=new PMUI.util.Point(c,a.y)):l=new PMUI.util.Point(a.x-h/2,a.y),m=0h&&0.1>k*k&&3===e?(l=d,m=e):(0k&&0===e?l=new PMUI.util.Point(d.x,a.y):c===e?(c=Math.max(a.x,d.x)+this.mindist,l=new PMUI.util.Point(c,a.y)):l=new PMUI.util.Point(a.x-h/2,a.y),m=0h*h&&0>k&&0===e?(l=d,m=e):(0h&&3===e?l=new PMUI.util.Point(a.x,d.y):c===e?(c=Math.max(a.y,d.y)+this.mindist,l=new PMUI.util.Point(a.x,c)):l=new PMUI.util.Point(a.x,a.y-k/2),m=0h*h&&0k?l=new PMUI.util.Point(a.x,a.y-this.mindist):0h&&3===e?l=new PMUI.util.Point(a.x,d.y):c===e?(c=Math.min(a.y,d.y)-this.mindist,l=new PMUI.util.Point(a.x,c)):l=new PMUI.util.Point(a.x,a.y-k/2),m=0a.priority};a.prototype.createHTML=function(b){this.setProperties();a.superclass.prototype.createHTML.call(this,b);return this.html};a.prototype.paint=function(){$(this.html);var b;this.style.removeClasses([this.currentZoomClass]);b=this.zoomSprites[this.canvas.zoomPropertiesIndex];this.style.addClasses([b]);this.currentZoomClass=b;this.style.applyStyle();return this};a.prototype.setProperties= function(){if(!this.parent)return this;this.id=this.parent.getID()+"Layer-"+this.layerName;this.setDimension(this.parent.getWidth(),this.parent.getHeight());this.canvas=this.parent.canvas;return this};a.prototype.getLayerName=function(){return this.layerName};a.prototype.getPriority=function(){return this.priority};a.prototype.setLayerName=function(b){"string"===typeof b&&""!==b&&(this.layerName=b);return this};a.prototype.setPriority=function(b){"number"===typeof b&&(this.priority=b);return this}; a.prototype.setParent=function(b){b&&(this.parent=b);return this};a.prototype.getParent=function(){return this.parent};a.prototype.setZoomSprites=function(b){var a;this.zoomSprites=["","","","",""];for(a=0;ab)this.direction=b;else throw Error("setDirection(): parameter '"+b+"'is not valid");return this};a.prototype.getDirection=function(){return this.direction};a.prototype.setParent=function(b,a){this.canvas&&a&&(this.canvas.updatedElement={id:this.id,type:this.type,fields:[{field:"parent",oldVal:this.parent,newVal:b}]},$(this.canvas.html).trigger("changeelement"));this.parent=b;return this};a.prototype.getParent=function(){return this.parent}; a.prototype.setOldParent=function(b){this.oldParent=b;return this};a.prototype.getOldParent=function(){return this.oldParent};a.prototype.setConnection=function(b){if(b&&"Connection"===b.family)this.connection=b;else throw Error("setConnection(): parameter is not valid");return this};a.prototype.getConnection=function(){return this.connection};a.prototype.getRepresentation=function(){return this.representation};a.prototype.setRepresentation=function(b){if(b instanceof PMUI.draw.RegularShape)this.representation= b;else throw Error("setRepresentation(): parameter must be an instance of any regularShape");return this};a.prototype.getPoint=function(b){parseInt(this.parent.style.getProperty("border"),10);return b?new PMUI.util.Point(this.getX()+Math.round(this.getWidth()/2),this.getY()+Math.round(this.getHeight()/2)):new PMUI.util.Point(this.getAbsoluteX()+Math.round(this.getWidth()/2),this.getAbsoluteY()+Math.round(this.getHeight()/2))};a.prototype.getPercentage=function(){return this.percentage};a.prototype.stringify= function(){var b={},a={x:this.getX(),y:this.getY(),realX:this.realX,realY:this.realY,parent:this.getParent().getID()};$.extend(!0,b,a);return b};PMUI.extendNamespace("PMUI.draw.Port",a);"undefined"!==typeof exports&&(module.exports=a)})(); (function(){var a=function(b){a.superclass.call(this,b);this.endPoint=this.startPoint=this.parent=null;this.zOrder=PMUI.draw.Shape.prototype.MAX_ZINDEX;this.nextNeighbor=this.previousNeighbor=null;this.orientation="";this.width=1;this.moveHandler=this.segmentColor=this.segmentStyle=this.graphics=null;this.intersections=new PMUI.util.ArrayList;this.hasMoveHandler=!1;a.prototype.init.call(this,b)};PMUI.inheritFrom("PMUI.draw.Core",a);a.prototype.type="Segment";a.prototype.init=function(b){var a={startPoint:new PMUI.util.Point(0, 0),endPoint:new PMUI.util.Point(0,0),parent:null,color:new PMUI.util.Color(0,0,0)};$.extend(!0,a,b);this.setStartPoint(a.startPoint).setEndPoint(a.endPoint).setColor(a.color).setParent(a.parent)};a.prototype.createHTML=function(){this.html=document.createElement("div");this.html.id=this.id;this.html.style.position="absolute";this.html.style.left="0px";this.html.style.top="0px";this.html.style.height="0px";this.html.style.width="0px";this.html.style.zIndex=this.zOrder;return this.html};a.prototype.paint= function(){if(null===this.getHTML())return this;null===this.graphics&&(this.graphics=new PMUI.draw.Graphics(this.html));this.graphics.drawLine(this.startPoint.x,this.startPoint.y,this.endPoint.x,this.endPoint.y,this.segmentStyle,this.segmentColor);this.parent.html.appendChild(this.html);return this};a.prototype.destroy=function(){$(this.html).remove();return this};a.prototype.paintWithIntersections=function(){this.destroy();var b,a,c,d,e=!1;if(null===this.getHTML())return this;null===this.graphics&& (this.graphics=new PMUI.draw.Graphics(this.html));this.hasMoveHandler&&($(this.moveHandler.html).remove(),this.addSegmentMoveHandler());this.orientation===this.HORIZONTAL?(c=new PMUI.util.Point(PMUI.draw.Shape.prototype.DEFAULT_RADIUS,0),this.startPoint.x>this.endPoint.x&&(e=!0),this.intersections.sort(function(b,a){return b.center.x>=a.center.x})):(c=new PMUI.util.Point(0,PMUI.draw.Shape.prototype.DEFAULT_RADIUS),this.startPoint.y>this.endPoint.y&&(e=!0),this.intersections.sort(function(b,a){return b.center.y>= a.center.y}));this.graphics.graphics.clear();b=this.startPoint.clone();for(d=0;da&&(a=d))}this.setDimension(71+a,f);return this};a.prototype.defineEvents=function(){var a,f;if(0