/** * [ONEMAP.M.menu] * @return {[object]} */ define([ 'html!templates/layerController', 'css!styles/menu', ], function(layerController,tplLayout,modelFly) { function init() { setLayout(); bindEvent(); subscribe(); }; function setLayout() { var top = $(window).height() - 140; $("#layerControlMenu").css({ top:top }) $(layerController).appendTo($("#layerControlMenu .cover-content")); $("#layerControlMenu .myLayers .scroll-bar").mCustomScrollbar({ scrollInertia: 500 }); $('#layerControlMenu .im-m').dragmove($('#layerControlMenu')); } /** * 窗口布局重置 * @type {Function} */ function layoutResize(options) { $("#layerControlMenu .myLayers .scroll-bar").mCustomScrollbar('update'); }; function bindEvent() { $(".layerListSwitch").bind('click',function(){ var mylayer = $(this).parent().parent(); if(mylayer.hasClass('active')){ mylayer.removeClass("active"); $("#layerControlMenu").css("width",202+"px"); } else{ mylayer.addClass("active"); $("#layerControlMenu").css("width",230+"px"); } }) } // 检查我的图层是否为空 function checkLayerNull(){ // 我的图层暂无数据时 if(typeof($("#layerControlMenu .myLayers .mn-content li").eq(0).html()) == "undefined"){ $("#layerControlMenu .mn-content p.tip-none").show(); $("#layerControlMenu").removeClass("bl"); } else{ $("#layerControlMenu .mn-content p.tip-none").hide(); if(!$("#layerControlMenu").hasClass("bl")){ $("#layerControlMenu").addClass("bl"); } } } // 全屏 function fullMap(option){ if(option){ var layer = $("#layerControlMenu"); layer.removeClass("bl"); }else{ ONEMAP.M.layerControlMenu.checkLayerNull(); } } /** * 注册订阅 * @type {Function} * 推送:ONEMAP.C.publisher.publish(options,'moduleName::type'); * 订阅:ONEMAP.C.publisher.subscribe(layoutResize,'sideBarLayoutChange'); */ function subscribe() { ONEMAP.C.publisher.subscribe(fullMap, 'layout::fullMap'); ONEMAP.C.publisher.subscribe(layoutResize, 'menuListClick'); } return ONEMAP.M.layerControlMenu = { init: init, status:status, checkLayerNull:checkLayerNull }; })