//-Created by zhuyan6 on 16/9/1.
//-定向页面的所有选择类型弹出框
block mod-ui-button
   include ~webComponents/widget/ui-widget.jade
- function refresh() {

- }

- var interestsType = (parseInt(conf.target)==6||parseInt(conf.target)==7)?'interestsApps':'interestsNormal';
//- 三级结构
mixin getRectInfo(subData,code,city)
   - if(!city) {
      - for(var i=0;i<subData.length;i++){
      - var checked = (code.indexOf(subData[i].name)!=-1||code.indexOf(subData[i].value)!=-1)?true:false;
         .sub-select-item
            +ui-widget-checkBox-default()(content=subData[i].name,width='auto',height='14px',active=checked,customAttr='code='+subData[i].value)
      - }
   - return;
   - }
   - if(subData.value.length > 0) {
      span #{subData.name}
   - }
   - for(var i=0;i<subData.value.length;i++){
   - var checked = (code.indexOf(subData.value[i].name)!=-1||code.indexOf(subData.value[i].value)!=-1)?true:false;
      .sub-select-item
         +ui-widget-checkBox-default()(content=subData.value[i].name,width='auto',height='14px',active=checked,customAttr='code='+subData.value[i].value)
   - }
//- 二级结构,con=保存的内容
mixin getSeoActive(secData,code,city,con)
   - var checkeds = city&&secData.value[0]?'false':'true';
   +ui-widget-checkBox-default()(content=secData.name,width='auto',height='14px',active=checkeds)


mixin addSubmit()
   +ui-widget-button-default()(content='确定',width='94px',height='34px',groupID='mod_direction_select_life_static_0',out='#f7f7f7',hover='#f2f2f2',outBg='#22bb9a',hoverBg='#1a856e')
   +ui-widget-button-default()(content='取消',width='94px',height='34px',groupID='mod_direction_select_life_static_1',out='#828287',hover='#f2f2f2',outBg='#ffffff',hoverBg='#c3c3c3')

mixin getPopContent(type,data,code)
   case type
      when '1'
         - var _data = data['lifeEvents'];
         - var _code = code['lifeEvents'];
         .select-life-static
            .select-life-static-cotent
               - for(var i=0;i<_data.length;i++){
                  .select-item
                     .select-button
                        +ui-widget-checkBox-default()(content=_data[i].name,width='auto',height='14px')
                     .select-rect-info
                        +getRectInfo(_data[i].value,_code)
               - }
                  .select-item(class='allCheck')
                        +ui-widget-checkBox-default()(content='全部',width='auto',height='14px')

            .select-life-static-submit
                  +addSubmit()
      when '2'
         - var _data = data['geoLocations'];
         - var _code = code['geoLocations'];
         .select-locals
            .select-locals-cotent
               - for(var j=0;j<_data.length;j++){
                  .select-content
                     .select-header
                        +ui-widget-checkBox-default()(content=_data[j].name,width='auto',height='14px',active=checkeds )
                     .select-body
                        - for(var i=0;i<_data[j].value.length;i++){
                        .select-item
                           .select-button
                              +getSeoActive(_data[j].value[i],_code,true)
                           .select-rect-info
                              +getRectInfo(_data[j].value[i],_code,true)
                        - }
                  //-分割线
                  .split-line
               - }
               .select-item(class='allCheck')
                  +ui-widget-checkBox-default()(content='全部',width='auto',height='14px')

            .select-locals-submit
               +addSubmit()
      when '3'
         - var _data = data[interestsType];//-interestsApps
         - var _code = code['categoryInterests'];//-interestsApps
         .select-interest
            .select-interest-cotent
               - for(var i=0;i<_data.length;i++){
               .select-item
                  -if(interestsType==='interestsNormal'){
                     .select-button
                        +ui-widget-checkBox-default()(content=_data[i].name,width='auto',height='14px')
                     .select-rect-info
                        +getRectInfo(_data[i].value,_code)
                  -}else{
                  - var checked = (_code.indexOf(_data[i].name)!=-1||_code.indexOf(_data[i].value)!=-1)?true:false;
                     .select-button
                        +ui-widget-checkBox-default()(content=_data[i].name,width='auto',height='14px',active=checked,customAttr='code='+_data[i].value)
                  -}

               - }
               .select-item(class='allCheck')
                  +ui-widget-checkBox-default()(content='全部',width='auto',height='14px')

            .select-interest-submit
               +addSubmit()
      when '4'
         - var _data = data['userDevice'];
         - var _code = code['userDevice'];
         .select-brands
            .select-brands-cotent
               - for(var i=0;i<_data.length;i++){
               - var checked = (_code.indexOf(_data[i].name)!=-1||_code.indexOf(_data[i].value)!=-1)?true:false;
               .select-item
                  .select-button
                     +ui-widget-checkBox-default()(content=_data[i].name,width='auto',height='14px',active=checked,customAttr='code='+_data[i].value)
               - }
               .select-item(class='allCheck')
                  +ui-widget-checkBox-default()(content='全部',width='auto',height='14px')

            .select-brands-submit
               +addSubmit()

.select-container
   +getPopContent(conf.type,conf.data,conf.code)