-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathself.min.js
More file actions
1 lines (1 loc) · 5.51 KB
/
Copy pathself.min.js
File metadata and controls
1 lines (1 loc) · 5.51 KB
1
"use strict";$(function(){var e={};var t=$(".paper");var i=$(".center-y");var s=3;var n,a;d();function d(){$(".left-widget div").draggable({snap:".center-box,.line-left,.line-top",snapMode:"inner",snapTolerance:15,start:function(e,t){if(e.target.id=="titleDrag"||e.target.id=="subtitleDrag"){$(".center-box").removeClass("hidden").css({width:t.helper.width(),left:parseInt(i.css("left"))-Math.floor(t.helper.width()/2)})}else{$(".center-box").addClass("hidden")}},drag:function(e,t){if(e.target.id=="titleDrag"||e.target.id=="subtitleDrag"){n=t.offset.top+Math.floor(t.helper.height()/2);a=t.offset.left+Math.floor(t.helper.width()/2)}else{n=t.offset.top;a=t.offset.left}if(o(n,a)){$(".line-x").removeClass("hidden").css("top",n);$(".line-y").removeClass("hidden").css("left",a)}else{$(".line-x, .line-y").addClass("hidden")}},stop:function(i,n){if(o(n.offset.top,n.offset.left)){e[i.target.id]={id:i.target.id,outerHTML:r(i.target.outerHTML),style:"#"+i.target.id+"{position: absolute;left:"+(n.offset.left-260)/s+"mm;top:"+(n.offset.top-40)/s+"mm;}"};if(i.target.id=="imgDescI"||i.target.id=="diagDescI"){var a=parseInt($(this).find(".input-resize").css("width"));var d=parseInt($(this).find(".input-resize").css("height"));e[i.target.id].style="#"+i.target.id+"{position: absolute;left:"+(n.offset.left-260)/s+"mm;top:"+(n.offset.top-40)/s+"mm;width:"+a/s+"mm;height:"+d/s+"mm}"}$(this).next().removeClass("hidden");$(this).next().find(".line-left").css({top:40,left:n.offset.left,height:t.css("height"),width:parseInt(t.css("width"))-n.offset.left+260+"px"});$(this).next().find(".line-top").css({left:260,top:n.offset.top,width:t.css("width"),height:parseInt(t.css("height"))-n.offset.top+40+"px"})}else{$(this).next().addClass("hidden")}$(".line-x, .line-y").addClass("hidden")},zIndex:100})}$(".input-resize").resizable({resize:function(e,t){$(".line-x").removeClass("hidden").css("top",+t.size.height+$(this).offset().top);$(".line-y").removeClass("hidden").css("left",+t.size.width+$(this).offset().left)},stop:function(t,i){$(".line-x").addClass("hidden");$(".line-y").addClass("hidden");t=$(this).parent()[0];e[t.id].style="#"+t.id+"{position: absolute;left:"+($(this).offset().left-260)/s+"mm;top:"+($(this).offset().top-40)/s+"mm;width:"+i.size.width/s+"mm;height:"+i.size.height/s+"mm}"}});$(".title").dblclick(function(){$(this).toggleClass("hidden");$(this).next(".input").toggleClass("hidden")});$(".input input").bind("dblclick",function(){$(this).parent(".input").prev()[0].innerHTML=$(this)[0].value;$(this).parent(".input").prev().css("font-size",$(this).css("font-size"));$(this).parent(".input").toggleClass("hidden");$(this).parent(".input").prev().toggleClass("hidden")});$(".input").find("span").click(function(){var e=parseInt($(this).parent(".input").find("input").css("font-size"));if($(this)[0].className=="glyphicon glyphicon-plus-sign"){e=parseInt(e)+1+"px"}else{e=parseInt(e)-1+"px"}$(this).parent(".input").find("input").css("font-size",e)});$(".make-hr a").click(function(e){var t=$(".left-widget ul");var i;switch(e.target.id){case"thin":i='<li><div class="hr thin"></div></li>';t.append(i);break;case"middle":i='<li><div class="hr middle"></div></li>';t.append(i);break;case"thick":i='<li><div class="hr thick"></div></li>';t.append(i);break}d();$(".hr").resizable({handles:"e",minHeight:1,resize:function(e,t){$(".line-x").removeClass("hidden").css("top",+t.size.height+n);$(".line-y").removeClass("hidden").css("left",+t.size.width+a)},stop:function(){$(".line-x").addClass("hidden");$(".line-y").addClass("hidden")}})});$(".change-paper a").click(function(e){var i=$(".input-group-btn button");var n=$("#paper-type-cus");i[0].textContent=e.target.textContent;switch(e.target.id){case"a4":t.css({width:210*s+"px",height:297*s+"px"});n.addClass("hidden");break;case"b5":t.css({width:176*s+"px",height:250*s+"px"});n.addClass("hidden");break;case"16k":t.css({width:184*s+"px",height:260*s+"px"});n.addClass("hidden");break;case"cus":n.removeClass("hidden");break}l()});$("#cusGo").click(function(){var e=+$("#paper-cus-width")[0].value;var i=+$("#paper-cus-height")[0].value;if(e&&i){t.css({width:e*3+"px",height:i*3+"px"});l()}});l();function l(){var e=parseInt(t.css("width"));var i=parseInt(t.css("height"));var n=Math.round(e/s/5)+1;var a=Math.round(i/s/5)+1;var d="",l="",r="",o="";for(var h=0;h<n;h++){d="<li></li>"+d}for(var f=0;f<Math.round(n/2)+1;f++){l=l+"<li>"+f*10+"</li>"}for(var p=0;p<a;p++){r="<li></li>"+r}for(var c=0;c<Math.round(a/2)+1;c++){o=o+"<li>"+c*10+"</li>"}$(".ruler-x")[0].innerHTML=d;$(".num-x")[0].innerHTML=l;$(".ruler-y")[0].innerHTML=r;$(".num-y")[0].innerHTML=o;$(".center-y").css("left",e/2+260+"px")}function r(e){var t=e.indexOf("class");var i=e.indexOf('px;"',t)+4;return e.substring(0,t)+e.substring(i)}function o(e,i){var s=parseInt(t.css("width"));var n=parseInt(t.css("height"));return i>260&&i<260+s&&e>40&&e<40+n}$("#toHtml").click(function(){var t=_.map(e,"outerHTML").join("");var i=$("#hidden");var n=$(".hr");var a="";i.append(t).find("span").remove(".input");t=i.html();for(var d=0;d<n.length;d++){if(n[d].offsetLeft>260&&n[d].offsetTop>40){a=a+'<div style="position: absolute;left:'+(n[d].offsetLeft-260)/s+"mm;top:"+(n[d].offsetTop-40)/s+"mm;width: "+n[d].clientWidth/s+"mm;border-top: "+n[d].clientTop/s+'mm solid #0f0f0f"></div>'}}t=t+a;var l="<style>"+_.map(e,"style").join("")+"</style>";$(".showHtml").removeClass("hidden");$("#showHtml").text(l+t);$("#mainCon").addClass("hidden");$("body").addClass("back-c-b")});$("#close").click(function(){$(".showHtml").addClass("hidden");$("#mainCon").removeClass("hidden");$("body").removeClass("back-c-b")})});