123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968 |
- /**********************************************************************************一。解析传递的参数***************************************************************************/
- /**
- * 解析查询条件
- * @returns {___anonymous229_230}
- */
- function resolveUrl(){
- var encondeCondition=window.location.search;
- var condition= decodeURI(encondeCondition.substring(1,encondeCondition.length));
- var conditionArr=condition.split("&");
- var condJson={};
- for(var item in conditionArr){
- var temArr=conditionArr[item].split("=");
- condJson[temArr[0]]=temArr[1];
- }
- return condJson;
- }
- /**********************************************************************************二。保存布局***************************************************************************/
- /**********************************************************************************1。解析布局参数*************************************************************************/
- /**********************************************************************************2。矫正布局参数参数**********************************************************************/
- /**********************************************************************************3.保存布局****************************************************************************/
- /**********************************************************************************4.删除视图****************************************************************************/
- /**********************************************************************************3.设置默认视图*************************************************************************/
- /**********************************************************************************3.修改视图****************************************************************************/
- //layoutData:[{column:"50%",row:[{id:"a1",value:"50%"},{id:"content1",value:"50%"}]},
- // {column:"50%",row:[{id:"content2",value:"50%"},{id:"content3",value:"50%"}]}]},
- //获取布局后的layout参数列表
- function LayoutItem(){
- this.column=null;
- this.row=null;
- }
- function Layout() {
- this.layoutItem=[];
- }
- /**
- * 逆向解析布局后的数据
- * @params:$conDom,布局容器
- */
- function resolveLayout($conDom){
- var _this=arguments.callee;
- var layout=[];
- //初次加载时为列布局
- if($conDom.children("div ._column_content").not("._column_move").size()>0){
- $conDom.children("div ._column_content").not("._column_move").each(function () {
- var layoutItem=new LayoutItem();
- if($conDom.find("._column_content ").size()===1){
- //获取像素
- layoutItem.column=$(this).width();
- //layoutItem.column=Math.floor($(this).css("width")); //获取百分比
- }else if($conDom.find("._column_content ").size()>1){
- //获取像素
- layoutItem.column=$(this).width();
- //获取百分比
- //layoutItem.column=Math.floor($(this).width()*0.999/($(this).parent().width()-($conDom.find("._column_content ").size()-1)/**$(window).height()*0.003*/)*100).toFixed(2)+"%";
- }
- layoutItem.row=[];
- $(this).children("div ._row_content").not("._row_move").each(function(){
- var item=new Object();
- if($(this).attr("id")!=null){
- item.id=$(this).attr("id");
- }
- //获取像素
- item.value=$(this).height();
- //获取百分比
- //item.value=Math.floor($(this).height()*0.998/($(this).parent().height()-($conDom.find("._row_content ").size()-1)/*$(window).height()*0.003*/)*100).toFixed(2)+"%";
- //递归
- if($(this).children("div ._row_content").size()>0){
- item.layoutData=_this($(this));
- }
- if($(this).children("div ._column_content").size()>0){
- item.layoutData=_this($(this));
- }
- layoutItem.row.push(item);
- });
- layout.push(layoutItem);
- });
- }
- //初次加载时为行布局
- if($conDom.children("div ._row_content").not("._row_move").size()>0){
- $conDom.children("div ._row_content").not("._row_move").each(function () {
- var layoutItem=new LayoutItem();
- if($conDom.find("._row_content ").size()===1){
- //获取像素
- layoutItem.row=$(this).height();
- //获取百分比
- //layoutItem.row=Math.floor($(this).height()/$(this).parent().height()*100)+"%";
- }else if($conDom.find("._row_content ").size()>1){
- //获取像素
- layoutItem.row=$(this).height();
- //获取百分比
- //layoutItem.row=Math.floor(($(this).height()/($(this).parent().height()-($conDom.find("._column_content ").size()-1)/**$(window).height()*0.003*/)*100)).toFixed(2)+"%";
- }
- layoutItem.column=[];
- $(this).children("div ._column_content").not("._column_move").each(function(){
- var item=new Object();
- if($(this).attr("id")!=null){
- item.id=$(this).attr("id");
- }
- //获取像素
- item.value=$(this).width();
- //获取百分比
- //item.value=($(this).width()/($(this).parent().width()-($conDom.find("._row_content ").size()-1)/**$(window).height()*0.003*/)*100).toFixed(2)+"%";
- //递归
- if($(this).children("div ._row_content").size()>0){
- item.layoutData=_this($(this));
- }
- if($(this).children("div ._column_content").size()>0){
- item.layoutData=_this($(this));
- }
- layoutItem.column.push(item);
- });
- layout.push(layoutItem);
- });
- }
- return layout;
- }
- //数据等比率矫正方法
- //[{"column":"25.00%","row":[{"id":"content1","value":"33.00%"},{"id":"content2","value":"33.00%"},{"id":"content2","value":"33.00%"}]},
- // {"column":"75.00%","row":[{"id":"a1","value":"67.00%"},{"id":"a2","value":"33.00%","
- //layoutData":[{"row":"100%","column":[{"id":"content4","value":"33.30%"},{"id":"content5","value":"33.20%"},{"id":"content6","value":"33.30%"}],"row":"100%"}]}]}]}
- /**
- * 逆向解析后的布局数据存在四舍五入的误差,误差会影响再次布局的结构
- * 该方法通过对误差的矫正,保证布局结构的完整。
- * @param dataParams:逆向解析布局后的数据
- */
- function proportionalCorrectionData(dataParams){
- var _this=arguments.callee;
- //列布局
-
- if(dataParams[0].row instanceof Array){
- var colSum=0;
-
- //矫正column值
- $.each(dataParams,function(index,item){
- colSum+=parseFloat(item.column);
- });
- $.each(dataParams,function (colIndex,item) {
- dataParams[colIndex].column=parseFloat(item.column)/colSum*100+"%";
- var colRowSum=0;
- //矫正row值
- $.each(dataParams[colIndex].row,function(rowIndex,rowItem){
- colRowSum+=parseFloat(rowItem.value);
- });
- $.each(dataParams[colIndex].row,function(rowIndex,rowItem){
- dataParams[colIndex].row[rowIndex].value=parseFloat(rowItem.value)/colRowSum*100+"%";
- if( dataParams[colIndex].row[rowIndex].hasOwnProperty("layoutData")){
- _this(dataParams[colIndex].row[rowIndex].layoutData);
- }
- });
-
- });
- }
-
- //行布局
- if(dataParams[0].column instanceof Array){
- //矫正row值
- var rowSum=0;
- $.each(dataParams,function(index,item){
- rowSum+=parseFloat(item.row);
- });
- $.each(dataParams,function (rowIndex,item) {
- dataParams[rowIndex].row=parseFloat(item.row)/rowSum*100+"%";
- var rowColSum=0;
- //矫正column值
- $.each(dataParams[rowIndex].column,function(colIndex,colItem){
- rowColSum+=parseFloat(colItem.value);
- });
- $.each(dataParams[rowIndex].column,function(rowColIndex,rowColItem){
- dataParams[rowIndex].column[rowColIndex].value=parseFloat(rowColItem.value)/rowColSum*100+"%";
- if( dataParams[rowIndex].column.hasOwnProperty("layoutData")){
- _this(dataParams[rowIndex].column.layoutData);
- }
- });
-
- });
- }
-
-
- //console.log("+++++++++++++++++++"+JSON.stringify(dataParams));
- return dataParams;
- }
- /**
- * 保存视图方法
- * @param param:保存视图名称
- * 将容器的id作为指定的容器编号
- */
- function saveLayout(param) {
- //视图布局参数
- var layoutParam=JSON.stringify(proportionalCorrectionData(resolveLayout($("#main_content"))));
- //视图制定的模块的链接地址
- var saveMatic=eachCon($("#main_content"));
- var saveView={name:param,userId:conditionJson["user_id"],roleId:conditionJson["role_id"],param:layoutParam,conId:saveMatic["OL_CONID"],maticId:saveMatic["OL_MATICID"]};
- $.post(http_path+"ws/SysLayoutService/SysLayoutService/saveView",saveView,function(result){
- if(result["state"]=="SUCCESS"){
- loadAside($("#view_list_content"));
- $("._add").removeClass("_devide");
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"保存成功!!",
- input:"true",
- });
- //创建节点
- alt.create("");
- alt=null;
- }else{
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"保存失败!",
- input:"true",
- });
- //创建节点
- alt.create("");
- alt=null;
- }
- },"json");
- }
-
- //获取视图中的链接地址的Id
- function eachCon($dom){
- var OL_CONID=[];
- var OL_MATICID=[];
- $dom.find("div[id^='content']").each(function () {
- OL_CONID.push($(this).attr("id"));
- OL_MATICID.push($(this).data("data"));
- });
-
- return {OL_CONID:OL_CONID.join("-"),OL_MATICID:OL_MATICID.join("-")};
- }
- //删除视图
- function deleteView(params){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"是否需要删除该专题?"
- });
- //创建节点
- alt.create("");
- alt=null;
- /**
- * 确定删除
- */
- function fn1(){
- $.post(http_path+"ws/SysLayoutService/SysLayoutService/deleteSysLayout",{FD_OBJECTID:params},function(result){
- if(result["state"]=="success"){
- loadAside($("#view_list_content"));
- }else{
- }
- },"json");
- }
- function fn2(){
- return;
- }
- }
- //设置默认的视图
- function setDefault(user_Id,objectId){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"是否设置为默认视图"});
- //创建节点
- alt.create("");
- alt=null;
- function fn1(){
- $.post(http_path+"ws/SysLayoutService/SysLayoutService/setDefaultLayout",{fd_objectId:objectId,userId:user_Id,roleId:conditionJson["role_id"]},function(result){
- if(result["state"]=="SUCCESS"){
- loadAside($("#view_list_content"));
- }
- },"json");
- return;
- }
- function fn2(){
- return ;
- }
- }
- //修改默认视图
- function editView(name,objectId,callFunction){
- var maticParams=eachCon($("#main_content"));
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"是否修改视图!"});
- //创建节点
- alt.create("");
- alt=null;
- function fn1(){
- $.post(http_path+"ws/SysLayoutService/SysLayoutService/updateName",{objectId:objectId,name:name,conId:maticParams["OL_CONID"],maticId:maticParams["OL_MATICID"]},function(result){
- if(result["state"]=="SUCCESS"){
- loadAside($("#view_list_content"));
- }
- },"json");
- }
- function fn2(){
- callFunction();
- return;
- }
-
- }
-
- /******************************************************************************三。初始化加载页面***************************************************************************/
- /******************************************************************************1。初始化页面************************************************************************/
- /******************************************************************************1。为容器加载iframe************************************************************************/
- /******************************************************************************1。为容器加载iframe************************************************************************/
- /******************************************************************************1。为容器加载iframe************************************************************************/
- /******************************************************************************1。为容器加载iframe************************************************************************/
- /******************************************************************************1。为容器加载iframe************************************************************************/
- /**
- * 初始化加载页面
- */
- function loadPage($conDom){
- /*$($conDom).find("*").each(function(){
- $(this).get(0).
- })*/
- $conDom.find("div[id^='content']").each(function(e) {
- var conDom=this;
- $(this).append("<iframe class='_iframe' scrolling='no' src='"+path+"page/cockpit/background.html' name='test' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe>");
- create_bar($(conDom));//创建浮动工具条
- });
- }
- function iframeTYLoadPage(){
- loadPage($("#main_content"));
- }
- //初始化iframe中的数据
- /**
- * 初始化加载引用页面的地址
- * @params:url:后台查询引用地址的路径
- * @params:params查询条件
- * 通过查询条件的控制,更改后台返回的结果
- */
- function changeLayout(url,params){
- //初始化动态iframe设置路径
- $.post(url,params,function(result){
- $("#main_content").find("div[id^='content']").find("iframe").each(function (i) {
- for(var index in result.rows){
- if(result.rows[index]["OL_CONID"]==$(this).parent().attr("id")){
- if(result.rows[i]["OL_MATICURL"].indexOf("http://")==0){
- $(this).attr("src",result.rows[i]["OL_MATICURL"]);
- }else{
- $(this).attr("src",http_path+result.rows[i]["OL_MATICURL"]+window.location.search+"&&conId="+$(this).parent().attr("id"));
- }
- $(this).parents("div[id^='content']").data("charMenuInfo",result.rows[i]);
- $(this).parents("div[id^='content']").data("data",result.rows[i]["OL_MATICID"]);
-
- }
- }
- });
- },"json");
-
- };
- /*******************************************************************************************************************************************************************/
- /* //创建组选择项list
- function accordionMenu($dom,data){
- var $divCon=$("<div class='_ul_count_content'></div>");
- if(data.length==0)throw Error("accordionMenu($dom,data)中data的长度为0或者空");
- if($dom==null||$dom==undefined)throw new Error("accordionMenu($dom,data)中容器节点不能为空");
- for(var item in data){
- if(data[item].rows.length==0) continue;
- $div=$("<div class='_ul_content'></div>");
- menuItem($div,data[item]);
- $divCon.append($div);
- };
- $dom.append($divCon);
- $dom.append("<div class='_jsc_close'></div>");
- $dom.find("._jsc_close").on("click",function(){
- top.destoryMenu();
- }).on("mouseenter",function(){
- $(this).addClass("_jsc_close_changeImg");
- }).on("mouseleave",function(){
- $(this).removeClass("_jsc_close_changeImg");
- })
- }*/
- //创建单个选择list
- /* function menuItem($dom,data){
- $ul=$("<ul></ul>");
- $h2=$("<div class='_ul_head'><div class='_view_list_line'></div><div class='_view_list'><h2>"+data.name+"</h2></div></div>");
- //点击隐藏选择项
- $ul.append($h2);
- $dom.append($ul);
- for(var item1 in data.rows){
- $dom.find("ul").last().append("<li class='_ul_li'><div class='_matic_title'><p >"+data.rows[item1]["TM_NAME"]+"</p></div><div class='_matic_img' title='"+data.rows[item1]["TM_NAME"]+"'><img src='"+(path+data.rows[item1]["TM_IMGURL"])+"'/></div></li>");
- $dom.find("ul").last().find("li").last().data("data",data.rows[item1]);
- inAndLeaveAndClick($dom.find("ul").last().find("li").last(),function($dom){
- top.changeSite(conditionJson["iframeId"],$dom.data("data"));
- top.destoryMenu();
- },moveIn,moveOut);
- }
- $dom.find("._view_list").click(function(){
- $(this).parents("._ul_content").toggleClass("_ul_content_hide");
- });
- }*/
- //点击事件增加样式
- function click($dom){
- if($("._ul_count_content").find("._click_li").size()>0){
- $("._ul_count_content").find("._click_li").removeClass("_click_li");
- }
- $dom.addClass("_click_li");
- }
- //移入增加样式
- function moveIn($dom){
- var _this=$dom;
- _this.addClass("_movein_li");
- }
- //移出增加样式
- function moveOut($dom){
- var _this=$dom;
- _this.removeClass("_movein_li");
- }
- //绑定点击,移入,移出事件
- function inAndLeaveAndClick($dom,fn_click,fn_enter,fn_leave){
- $dom.on("click",function(){
- fn_click($(this));
- return false;
- });
- $dom.on("mouseenter",function(){
- fn_enter($(this));
- return false;
- });
- $dom.on("mouseleave",function(){
- fn_leave($(this));
- return false;
- });
- }
- /**
- * 设置浮动容器的高度
- * @param $dom
- * @param top
- * @param left
- */
- function setPosition($dom,top,left){
- if((parseInt($dom.width())+parseInt(left))<$(window).width()){
- $dom.css({left:left+"px"});
- }else{
- $dom.css({left:parseInt($(window).width())-parseInt($dom.width())-5+"px"});
- }
- if((parseInt($dom.height())+parseInt(top))<$(window).height()){
- $dom.css({top:top+"px"});
- }else{
- $dom.css({top:parseInt($(window).height())-parseInt($dom.height())+"px"});
- }
- }
- /**
- * 更改引用页面的引用地址,并保存到数据库
- * @params:conDom引用页面的容器,绑定有初始加载数据,通过绑定的数据进行更改
- */
- function changeSite(conId,data){
- if(data["TM_URL"].indexOf("http://")==0){
- $("#"+conId).find("iframe").attr("src",data["TM_URL"]+window.location.search);
- }else{
- $("#"+conId).find("iframe").attr("src",http_path+data["TM_URL"]+window.location.search+"&&conId=conId");
- }
- $("#"+conId).data("data",data["FD_OBJECTID"]);
- return false;
- }
-
- //展开引用页面的查询状态
-
-
- //***************************************全屏*************************************************************
-
- /**
- * 鼠标点击放大图表事件
- * 无二次加载放大
- */
- function allScreen($dom){
- if( $("body").find("div[class='_zoom']").size()==0){
- $conDiv=$("<div class='_zoom'></div>");
- $dom.children().each(function(){
- $(this).appendTo($conDiv);
- });
- $conDiv.data("swapData",$dom);
- $("body").prepend($conDiv);
- $conDiv.find("._toolBarContent").width($conDiv.width());
- }else{
- $("body").find("div[class='_zoom']").each(function(){
- var _dom=$(this).data("swapData");
- $(this).children().each(function(){
- $(this).appendTo(_dom);
- });
- $(this).remove();
- });
- }
- }
- //展开布局菜单
- /**
- * 展开布局控制菜单
- * createSetMenu(dataParam):布局选择菜单
- */
- /**
- * @param
- */
- function openLayout(dataParam){
- if($("#layout_list_iframe").size()>0){
- $("#layout_list_iframe").remove();
- }
- var htmlStr="<div id='layout_list_iframe' class='_layout_list_iframe'><iframe class='_list_iframe' stytle='position:absolute;' scrolling='no' " +
- "src=/nwyj/page/cockpit/cockpit_layout/matic_layout.html name='n_layou_list' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe></div>";
-
- $("body").append(htmlStr);
- htmlStr=null;
- /*
- $("#menu_content").createSetMenu(dataParam);
- $("#menu_content").show();
- $("#menu_content").css({display:"inline-block"});
- $("#content").css({height:(parseInt($(window).height())-parseInt($("#menu_content").height()))/parseInt($(window).height())*100+"%"});*/
- }
- /**
- * 创建浮动工具条:1.展开浮动菜单:(e.data.options,this)
- * 2。锁定图层;
- * 3,控制查询条件的隐现,changeState(e.data.conDomParam);
- * 4,全屏放大
- */
- function create_bar(conDom){
- //工具条隐藏事件绑定
- conDom.on("mouseenter",function(){
- //获取子页面配置的工具栏参数
- var childToolBar=conDom.find("iframe").get(0).contentWindow.customMadeTool;
- var _toolBar=getToolBar(toolBar,childToolBar);
- if(conDom.find("._toolBarContent").size()>0){
- conDom.find("._toolBarContent").each(function(){
- $(this).remove();
- });
- }
- conDom.prepend("<div class='_toolBarContent'><div class='_toolBar'></div></div>");
- for(var index in _toolBar){
- //添加toolbar按钮
- conDom.find("._toolBar").append("<div class='"+_toolBar[index]["classIcon"]+" _opacity_90'> <div>");
- //为按钮绑定动作
- conDom.find("._toolBar").find("."+_toolBar[index]["classIcon"]).on("click",{index:index,win:conDom.find("iframe").get(0).contentWindow},function(e){
- _toolBar[e.data.index]["fn"](e.data.win,conDom);
- }).on("mouseenter",function(){
- $(this).addClass("_opacity_100");
- }).on("mouseleave",function(){
- $(this).removeClass("_opacity_100");
- });
- }
- //设置toolbar容器的宽度
- conDom.find("._toolBarContent").width(conDom.width());
- }).on("mouseleave",function(){
- if(conDom.find("._toolBarContent").size()>0){
- conDom.find("._toolBarContent").each(function(){
- $(this).remove();
- });
- }
- });
- /* //按钮3绑定事件:展开浮动菜单
- conDom.find("._content_set_menu").eq(2)
- .on("click",function(e){
- $("#float_menu_content").createMenu($(this).parent().parent().parent(),e);})
- .on("mouseleave",function(){
- //鼠标移除,启动自动关闭浮动菜单
- setTimeout(function(){
- if($("#float_menu_content").data("data")=="0"||$("#float_menu_content").data("data")==undefined){
- $("#float_menu_content").css("display","none");
- }
- },5000);
- });
- //按钮2绑定事件:放大容器
- conDom.find("._content_set_menu").eq(1).on("click",function(e){allScreen(conDom,123);});
- //按钮3绑定事件:查询状态
- */
- }
- /*
- * 展开查询条件面板
- */
- function fn_search(win,$dom){
- //如果存在展开/关闭方法则触发该动作
- if( win.switchSearchPlane!=undefined){
- win.switchSearchPlane();
- }
- }
- /*
- * 页面携带数据刷新
- */
- function fn_render(win,$dom){
- //如果存在刷新方法则触发刷新方法的动作
- if(win.rend!=undefined){
- win.rend();
- }
- }
- /**
- * 展开专题选择菜单
- * @param win
- * @param $dom
- */
- function fn_list(win,$dom){
- $("#float_menu_content").createMenu($dom);
- }
- /**
- * 销毁菜单
- */
- function destoryMenu(){
- $("#float_menu_content").empty();
- $("#float_menu_content").css({display:"none"});
- };
- /**
- * 关闭父页面子页面的id
- * @param id iframe页面容器的id
- */
- function destoryIframeContent(id){
- $(id).empty();
- $(id).css({display:"none"});
- }
- function fn_resource(win,$dom){
- $("._tool_peo").toggleClass("_tool_sys");
- }
-
- function fn_enlarge(win,$dom){
- if($dom.attr("class").indexOf("_zoom_div")==-1?false:true){
- $dom.removeClass("_zoom_div");
- $dom.css(zoomDiv);
- if($("._toolBarContent")!=undefined){
- $("._toolBarContent").find("._tool_enlarge").addClass("_tool_narrow");
- }
-
- }else{
- zoomDiv={width: parseInt($dom.css("width"))/$dom.parent().width()*100+"%",height:parseInt($dom.css("height"))/$dom.parent().height()*100+"%"};
- $dom.css({width:$(window).width(),height:$(window).height()});
- $dom.addClass("_zoom_div");
- if($("._toolBarContent")!=undefined){
- $("._toolBarContent").find("._tool_enlarge").removeClass("_tool_narrow");
- }
- }
- $dom.find("._toolBarContent").width($dom.width());
- }
- //横向移动放大
- //代码待删除
- function moveDomY(e1){
- var flag = true;
- if(e1==null)e1 = e1||window.event;
- var $conDom=$(this);
- var proxyConDom=$conDom.clone();
- proxyConDom.addClass("_proxy").width(5).css({top:$conDom.offset().top,left:$conDom.offset().left,width:$conDom.width(),height:$conDom.height(),id:'proxy'});
- proxyConDom.appendTo($("body"));
- $(document).mousemove(function (e) {
- if(e==null)e = e||window.event;
- if (flag) { proxyConDom.css({left:e.clientX+"px"});}
- });
- $("iframe").each(function () {
- var _iframe=$(this);
- $($(this).get(0).contentWindow.document).mousemove(function (e) {
- if(e==null)e = e||window.event;
- if (flag) {proxyConDom.css({left:e.clientX+_iframe.offset().left+"px"});}
- });
- });
- $("iframe").each(function () {
- $($(this).get(0).contentWindow.document).on("mouseup",function(){
- dragResizeY($conDom,proxyConDom.offset().left-$conDom.offset().left);
- $("body").remove(proxyConDom);
- flag = false;return false;});
- });
- $(document).on("mouseup",function(){
- dragResizeY($conDom,proxyConDom.offset().left-$conDom.offset().left);
- proxyConDom.remove();
- flag = false;return false;});
- return false;
-
- }
- /**
- * 宗向移动放大
- * @param e
- */
- function moveDomX(e){
- var flag = true;
- if(e==null)e = e||window.event;
- var $conDom=$(this);
- var proxyConDom=$conDom.clone();
- proxyConDom.addClass("_proxy").width(5).css({top:$conDom.offset().top,left:$conDom.offset().left,width:$conDom.width(),height:$conDom.height(),id:'proxy'});
- proxyConDom.appendTo($("body"));
- $(document).mousemove(function (e) {
- if(e==null)e = e||window.event;
- if (flag) { proxyConDom.css({top:e.clientY+"px"});}
- });
- $("iframe").each(function () {
- var _iframe=$(this);
- $($(this).get(0).contentWindow.document).mousemove(function (e) {
- if(e==null)e = e||window.event;
- if (flag) {proxyConDom.css({top:e.clientY+_iframe.offset().top+"px"});}
- });
- });
-
- $("iframe").each(function () {
- $($(this).get(0).contentWindow.document).on("mouseup",function(){
- dragResizeX($conDom,proxyConDom.offset().top-$conDom.offset().top);
- proxyConDom.remove();
- flag = false;
- return false;
- });
- });
-
- $(document).on("mouseup",function(){
- dragResizeX($conDom,proxyConDom.offset().top-$conDom.offset().top);
- proxyConDom.remove();
- flag = false;return false;});
- return false;
- }
-
- //移动事件----------------------------------结束
- function moveDom1(e){
- if(e==null)e = e||window.event;
- $("#float_menu_content").css({left:e.clientX+5+ "px" ,top:e.clientY +5+ "px"});
- if(($(window).width()-$("#float_menu_content").offset().left-$("#float_menu_content").width())<0){
- $("#float_menu_content").css({left:($(window).width()-$("#float_menu_content").width())*0.95+"px"});
- }
- $("#float_menu_content").height(($(window).height()-$("#float_menu_content").offset().top)*0.9);
- // isInContent();
- return false;
-
- }
- //水平改变尺寸
- function dragResizeY($conDom,distance) {
- if(distance>0){
- if(distance< $conDom.next('._column_content ').width()){
- $conDom.next('._column_content ').css("width",(parseFloat($conDom.next('._column_content ').css("width"))-distance)/parseFloat($conDom.parent().css("width"))*100+"%");
- $conDom.prev('._column_content ').css("width",(parseFloat($conDom.prev('._column_content ').css("width"))+distance)/parseFloat($conDom.parent().css("width"))*100+"%");
-
- }
- }else{
- if((-distance)<$conDom.prev('._column_content').width()){
- $conDom.prev('._column_content ').css("width",(parseFloat($conDom.prev('._column_content ').css("width"))+distance)/parseFloat($conDom.parent().css("width"))*100+"%");
- $conDom.next('._column_content ').css("width",(parseFloat($conDom.next('._column_content ').css("width"))-distance)/parseFloat($conDom.parent().css("width"))*100+"%");
- }
- }
- }
- //垂直改变尺寸
- function dragResizeX($conDom,distance) {
- if((distance)>0){
- if(distance< $conDom.next('._row_content ').height()){
- $conDom.next('._row_content').css("height",(parseFloat($conDom.next('._row_content ').css("height"))-distance)/parseFloat($conDom.parent().css("height"))*100+"%");
- $conDom.prev('._row_content').css("height",(parseFloat($conDom.prev('._row_content ').css("height"))+distance)/parseFloat($conDom.parent().css("height"))*100+"%");
- }
- }else{
- if((-distance)< $conDom.prev('._row_content ').height()){
- $conDom.prev('._row_content').css("height",(parseFloat($conDom.prev('._row_content ').css("height"))+distance)/parseFloat($conDom.parent().css("height"))*100+"%");
- $conDom.next('._row_content').css("height",(parseFloat($conDom.next('._row_content ').css("height"))-distance)/parseFloat($conDom.parent().css("height"))*100+"%");
- }
- }
- }
- /**
- * 生成布局
- * @param $dom 布局作用的容器
- * @param params 布局的参数
- * @param interSpace 子容器间的间隔
- */
- function createLayout($dom,params,interSpace){
- params=$.parseJSON(JSON.stringify(params));
- if(interSpace==""&& $dom==""){
- console.log(JSON.stringify({params:params}));
- $("#main_content").createLayout(params ,$(window).width()*0.003);
- }else if(interSpace==""&& $dom!=""){
- $dom.createLayout(params,$(window).width()*0.003);
- }else if(interSpace!=""&& $dom!=""){
- $dom.createLayout(params,interSpace);
- }
- $("._column_move").each(function(){$(this).on("mousedown",moveDomY).addClass("_drag");});
- $("._row_move").each(function(){$(this).on("mousedown",moveDomX).addClass("_drag");});
- // loadPage($("#main_content"),"");
-
- }
- (function ($) {
- //创建布局功能------------------------开始
- /**
- * @param params 参数格式:[{column:"50%",row:[{id:"content1",value:"100%"}]},{column:"50%",row:[{id:"content2",value:"100%"}]}]
- * @param interSpace 间距
- */
- $.fn.createLayout=function(params,interSpace){
- console.log(JSON.stringify({params:params}));
- //制定dom对象
- var selfDom=this;
- //清空dom对象
- $(selfDom).empty();
- //@params:layolayoutData:[{row:70%,column:[20%,40%,40%]},{row:50%,column:[30%,50%,20%]}]}
- $(selfDom).removeClass("_single_content");
- if(!(params[0].row instanceof Array)){
- console.log("行布局");
- for(var index=0 ,len=params.length;index<len;index++){
- $(selfDom).append("<div class='_row_content'></div>");
- if(len!==1){
- $(selfDom).find("._row_content").last().css("height",(parseFloat(params[index].row)*(1-(len-1)*interSpace/$(selfDom).height()))+"%").css("width","100%");
- }else{
- $(selfDom).find("._row_content").last().css("height",params[index].row).css("width","100%");
- }
- /* $(selfDom).find("._row_content").last().css("height",params[index].row).css("width","100%");*/
- console.log(JSON.stringify({paramsArr:params}));
- console.log("index="+index);
- console.log(JSON.stringify(params[index]));
- $(selfDom).find("._row_content").last().createColumn(params[index].column,interSpace);
- if(index<len-1){
- $(selfDom).append("<div class='_row_content _row_move'></div>");
- $(selfDom).find("._row_content").last().css("height",(interSpace/ $(selfDom).height()*100)+"%").css("width","100%");
- }
- }
- }else if(!(params[0].column instanceof Array)){
- console.log("列布局");
- for(var index=0 ,len=params.length;index<len;index++){
- $(selfDom).append("<div class='_column_content _inline_block'></div>");
- if(len!==1){
- $(selfDom).find("._column_content").last().css("width",(parseFloat(params[index].column)*(1-(len-1)*interSpace/$(selfDom).width()))+"%").css("height","100%");
- }else{
- $(selfDom).find("._column_content").last().css("width",params[index].column).css("height","100%");
- }
- $(selfDom).find("._column_content").last().createRow(params[index].row,interSpace);
- if(index<len-1){
- $(selfDom).append("<div class='_column_content _column_move _inline_block'></div>");
- $(selfDom).find("._column_content").last().css("width",(interSpace/ $(selfDom).width()*100)+"%").css("height","100%");
- }
- }
- }
- return false;
- };
- //创建布局功能------------------------结束
-
- //创建行----------------------------结束
- // @parames:{row:[20%,40%,40%]};
- $.fn.createRow=function(e,interSpace){
- var selfDom=this;
- var params=null;
- params=e;
- //添加节点
- $(selfDom).removeClass("_single_content");
- for(var index=0,len=params.length;index<len;index++){
- if(params[index].id===undefined){
- $(selfDom).append("<div class='_row_content _single_content '></div>");
- }else{
- $(selfDom).append("<div id="+params[index].id+" class='_row_content _single_content '></div>");
- $(selfDom).find("#"+params[index].id).data("data",params[index].id.substring(1,params[index].id.length));
- }
- if(len!==1){
- $(selfDom).find("._row_content").last().css("height",(parseFloat(params[index].value)*(1-(len-1)*interSpace/$(selfDom).height()))+"%").css("width","100%");
- }else{
- $(selfDom).find("._row_content").last().css("height",params[index].value).css("width","100%");
- }
- if(index<len-1){
- $(selfDom).append("<div class='_row_content _row_move'></div>");
- $(selfDom).find("._row_content").last().css("height",(interSpace/ $(selfDom).height()*100)+"%").css("width","100%");
- }
-
- if(params[index].layoutData instanceof Array){
- $(selfDom).find("._row_content").last().createLayout(params[index].layoutData,interSpace);
- }
- };
- };
- //创建行---------------------------结束
-
- //创建列---------------------------开始
- // @parames:{column:[20%,40%,40%]};
- $.fn.createColumn=function(params,interSpace){
- var selfDom=this;
- $(selfDom).removeClass("_single_content");
- console.log(JSON.stringify({column:params}));
- //添加节点
- for(var index=0,len=params.length;index<len;index++){
- if(params[index].id===undefined){
- $(selfDom).append("<div class='_column_content _single_content _inline_block'></div>");
- }else{
- $(selfDom).append("<div id="+params[index].id+" class='_column_content _single_content _inline_block'></div>");
- $(selfDom).find("#"+params[index].id).data("data",params[index].id.substring(1,params[index].id.length));
- }
- // $(selfDom).find("._column_content").last().css("width",params[index].value).css("height","100%");
- if(len!==1){
- $(selfDom).find("._column_content").last().css("width",(parseFloat(params[index].value)*(1-(len-1)*interSpace/$(selfDom).width()))+"%").css("height","100%");
- }else{
- $(selfDom).find("._column_content").last().css("width",params[index].value).css("height","100%");
- }
- if(index<len-1){
- $(selfDom).append("<div class='_column_content _column_move _inline_block'></div>");
- $(selfDom).find("._column_content").last().css("height","100%").css("width",(interSpace/ $(selfDom).width()*100)+"%");
- }
- if(params[index].layoutData instanceof Array){
- $(selfDom).find("._column_content").last().createLayout(params[index].layoutData,interSpace);
- }
- };
- };
- //创建列---------------------------开始
- //创建生成li功能-----------------------------开始
- $.fn.createLi=function(dataParams,fn_option){
- var selfDom=this;
- $(selfDom).append("<ul></ul>");
- for(var index=0,len=dataParams.items.length;index<len;index++){
- $(selfDom).find("ul").append("<li class='_img_content'><img src='"+dataParams.items[index].url+"' title='"+dataParams.items[index].text+"'/></li>");
- $(selfDom).find("ul").find("li").last().data("layouParams",dataParams.items[index].layoutData)
- .on("click",function(){fn_option($(this).data("layouParams"));});
- $(selfDom).find("li").last().on("mouseenter",function(){
- $(this).addClass("_fn_mouse");}).on("mouseleave",function(){
- $(this).removeClass("_fn_mouse");}).on("click",function(){
- $(this).siblings().each(function() {
- $(this).removeClass("_fn_click_layout");
- });
- $(this).addClass("_fn_click_layout");
- });;
- }
- return false;
- };
- //创建生成li功能-----------------------------结束
-
- //创建选择菜单/销毁菜单-------------------------------开始
- $.fn.createMenu=function($dom){
- $("#float_menu_content").empty();
- $("#float_menu_content").append("<div class='_matic_list'><iframe class='_iframe' scrolling='no' src='"
- +path+"page/cockpit/maticList/maticList.html"+window.location.search+"&&contentDivId="+$dom.attr("id")+"&&iframeId="+$dom.attr("id")+"' name='test' frameborder='0' >您的浏览器不支持框架,请升级您的浏览器以便正常访问脚本之家</iframe></div>")
- $("#float_menu_content").css({display:"inline-block"});
- };
- //创建选择菜单-------------------------------结束
- //创建自定义布局菜单------------------------------开始
- $.fn.createSetMenu=function(e){
- var options=e;
- $(this).empty();
- $(this).append("<div class='_set_menu'></div>");
- /*$("#menu_switch").show();布局菜单按钮开关控制*/
- $(this).find("._set_menu").createLi(options.layoutParams,function(a){
- $("#"+options.layoutParams.dom).createLayout(a,$(window).width()*0.003);
- $("._column_move").each(function(){$(this).on("mousedown",moveDomY).addClass("_drag");});
- $("._row_move").each(function(){$(this).on("mousedown",moveDomX).addClass("_drag");});
- loadPage($("#"+options.layoutParams.dom));
- return false;
- });
- $(this).find("._set_menu").append("<div><input type='button' value='保 存'/></div>");
- $(this).find("._set_menu").find("input[type='button']").on("click",{$dom: $(this)},function(e){
- var alt=new Alert({ok:fn1,cancle:fn2},
- {text:"视图名称:!",
- input:"true",
- });
- //创建节点
- alt.create("");
- alt=null;
- /* var diag = new top.Dialog();
- diag.Title = "视图名称";
- diag.Height=100;
- diag.Width=300;
- diag.URL = path+"page/cockpit/webgis/layoutName.jsp";
- diag.OKEvent = function(){
- var inputValue = diag.innerFrame.contentWindow.document.getElementById('layoutName').value;
- diag.close();
- saveLayout(inputValue);
- $("#menu_content").empty();
- $("#menu_content").hide();
- $("#content").css({height:"100%"});
- };
- diag.CancelEvent=function(){
- diag.close();
- }
- diag.show();*/
-
- });
- return false;
- };
- //创建自定义菜单------------------------------结束
- })(jQuery);
-
-
|