<%@ Page Language="C#" MasterPageFile="~/Admin/MasterPage.master" AutoEventWireup="true" Inherits="Kesion.NET.WebSite.Admin_Label_ProBrandList" Title="Untitled Page" Codebehind="KS.Label.ProBrandList.aspx.cs" %>
<%@ Import Namespace="Kesion.Cache"%>
<%@ Import Namespace="Kesion.BLL"%>


<asp:Content ID="Content1" ContentPlaceHolderID="KSContent" Runat="Server">
<!--
<body onmousemove="dragmove();" onmouseup="dragclear()">
-->
<script type="text/javascript">


  
  function setstyle(obj,id)
  {
	  	$('#format-detailed').hide();
	  	var $t = $(obj);
		$t.addClass('active').siblings().removeClass('active');
	  	if(id==1){
			
			var colVal = $('#col input:checked').val();
			$('#<%=this.Num.ClientID %>').val(colVal);
			var colClass = 'm-b-col'+colVal+' ';
			
			if($('input[name="check-border"]').is(':checked')==true){
				var borderClass = 'm-b-border ';
			}else{
				var borderClass = '';
			};
			
			$('input[name="check-border"]').click(function(){
				if($(this).is(':checked')==true){
					borderClass = 'm-b-border ';
				}else{
					borderClass = '';
				};
				colFormat();
			});

			if($('input[name="check-spacing"]').is(':checked')==true){
				var spacingClass = '';
			}else{
				var spacingClass = 'm-b-nospacing ';
			};
			
			$('input[name="check-spacing"]').click(function(){
				if($(this).is(':checked')==true){
					spacingClass = '';
				}else{
					spacingClass = 'm-b-nospacing ';
				};
				colFormat();
			});

			
			if($('input[name="check-name"]').is(':checked')==true){
				var name = '				<div class="m-b-name"><a href="{KS:Field:Url(brandview,brandid)}" target="_blank" title="{$Field(BrandName,text,0,...,2,)}">{$Field(BrandName,text,0,...,2,)}</a></div>\n';
			}else{
				var name = '';
			};
			
			$('input[name="check-name"]').click(function(){
				if($(this).is(':checked')==true){
					name = '				<div class="m-b-name"><a href="{KS:Field:Url(brandview,brandid)}" target="_blank" title="{$Field(BrandName,text,0,...,2,)}">{$Field(BrandName,text,0,...,2,)}</a></div>\n';
				}else{
					name = '';
				};
				colFormat();
			});
			
			//版式详细设置
			$('#format-detailed').show();
			$('#col').on('click','input',function(){
				$(this).attr('checked',true).parent().siblings().find('input').attr('checked',false);
				colVal = $(this).val();
				colClass = 'm-b-col'+colVal+' '
				$('#<%=this.Num.ClientID %>').val(colVal);
				colFormat();
				
			});
			
			colFormat();
			
			function colFormat(){
				$("#<%=this.LoopBody.ClientID %>").val('<div class="m-brand-style1">\n'+
													'	<ul class="'+colClass+''+borderClass+''+spacingClass+'clearfix">\n'+
													'		[Loop Times="$n"]\n' +
													'		<li>\n'+
													'			<div class="m-b-box">\n'+
													'				<div class="m-b-img">\n'+
													'					<A href="{KS:Field:Url(brandview,brandid)}" target="_blank">\n'+
													'						<img src="{$Field(PhotoUrl,text,0,...,2,/ks_drag/images/nopic_225_142.png)}" class="ks-Limg" alt="{$Field(BrandName,text,0,...,2,)}" onerror=\'javascript:this.src="/ks_drag/images/nopic_225_142.png"\'>\n'+
													'					</A>\n'+
													'				</div>\n'+
													name+
													'			</div>\n'+
													'		</li>\n'+
													'		[/Loop]\n'+
													'	</ul>\n'+
													'</div>');
			};
			
			
		}else if(id==2){
			 $('#<%=this.Num.ClientID %>').val('10');
			 
				$("#<%=this.LoopBody.ClientID %>").val('<div class="m-brand-style2">\n'+
													'	<ul class="clearfix">\n'+
													'		[Loop Times="$n"]\n' +
													'		<li>\n'+
													'			<div class="m-b-box">\n'+
													'				<div class="m-b-img">\n'+
													'					<A href="{KS:Field:Url(brandview,brandid)}" target="_blank">\n'+
													'						<img src="{$Field(PhotoUrl,text,0,...,2,/ks_drag/images/nopic_225_142.png)}" class="ks-Limg" alt="{$Field(BrandName,text,0,...,2,)}" onerror=\'javascript:this.src="/ks_drag/images/nopic_225_142.png"\'>\n'+
													'					</A>\n'+
													'				</div>\n'+
													'				<div class="m-b-name"><a href="{KS:Field:Url(brandview,brandid)}" target="_blank" title="{$Field(BrandName,text,0,...,2,)}">{$Field(BrandName,text,0,...,2,)}</a></div>\n'+
													'				<div class="m-b-intro ks-info-color">{$Field(Intro,text,0,...,2,)}</div>\n'+
													'			</div>\n'+
													'		</li>\n'+
													'		[/Loop]\n'+
													'	</ul>\n'+
													'</div>');
			};
		
  };


  
    function selectclassid(v) {

        var va = v.split(',');
        for (var i = 0; i < jQuery("#classid1")[0].options.length; i++) {
            for (var n = 0; n < va.length; n++) {
                if (va[n] == jQuery("#classid1")[0].options[i].value) {
                    jQuery("#classid1")[0].options[i].selected = true;
                }
            }
        }
    }

  function checkform()
    {
      var childclass = 0;
      if (jQuery('#<%=this.ChildClass.ClientID %>')[0].checked) childclass = 1;
      var classid = '';
      jQuery("#classid1 option:selected").each(function () {
          if (jQuery(this).val() != '0')
              if (classid == '')
                  classid = jQuery(this).val()
              else
                  classid += "," + jQuery(this).val();
      })
      if (classid == '') classid = '0';
   var recommends=0;
   if (jQuery("#<%=this.Attribute.ClientID %>_0")[0].checked)
   recommends=1;

   var haspic=0;
   if (jQuery("#<%=this.Attribute.ClientID %>_1")[0].checked)
   haspic=1;


   
   var str='{KS:Label Type="IProBrandList"'
          + ' Ajax="<%=this.PrintStyle.SelectedValue %>"'
          + ' CacheTime="<%=this.TxtCacheTime.Text%>"'
          + ' Recommends="' + recommends + '"'
          + ' ClassID="' + classid + '"'
          + ' ChildClass="' + childclass + '"'
          + ' HasPic="' + haspic + '"'
          + ' Order="'+jQuery('#<%=this.Order.ClientID %>').val()+'"'
          + ' Num="'+jQuery('#<%=this.Num.ClientID %>').val()+'"'
          + ' SQLCondition="' + jQuery('#<%=this.SQLCondition.ClientID %>').val() + '"'
          + '}' + jQuery('#<%=this.LoopBody.ClientID%>').val() + '{/KS:Label}';
   
   jQuery("#<%=this.LabelContent.ClientID %>").val(str);
   return true;
  }
    function purview()
    { parent.openWin("自动编号变量样式预览","../admin/include/autoid.html",false,650,230);
    } 
    
   var pos=null;
   function setPos()
	{ if (document.all){
			jQuery("#<%=this.LoopBody.ClientID %>").focus();
		    pos = document.selection.createRange();
		  }else{
		    pos = jQuery("#<%=this.LoopBody.ClientID %>")[0].selectionStart;
		  }
   }
   		//插入到循环体
	function InsertValue(Val) {
	    if (pos == null) { KesionJS.Alert('请先定位插入位置!', null); return false; }
			 if (document.all){
			  pos.text=Val;
			 }else{
			   var obj=jQuery("#<%=this.LoopBody.ClientID %>");
			   var lstr=obj.val().substring(0,pos);
			   var rstr=obj.val().substring(pos);
			   obj.val(lstr+Val+rstr);
			 }
	}
     
   function InsertLabel(fieldname,fieldtype)
   {  
    dragclear();
    if(pos==null) {KesionJS.Alert('请先定位插入位置!',null);return false;}
	var link="<%=MyCache.GetCacheConfig(0)+MyCache.GetCacheConfig(4)%>/label/KS.GetFieldParam.aspx?m_fieldname=" + fieldname+"&fieldtype="+fieldtype;
	parent.openWin('插入字段标签',link,false,350,200);
   }
 
  
var fieldname,fieldtype;
function DragStart()
{
    dragclear();
    window.drag = 1;
    dragspan = document.createElement('div');
    dragspan.style.position = "absolute";
    dragspan.className="div" ;
    var mousePos = mouseCoords(window.event);
    dragspan.style.left = mousePos.x + 10;
    dragspan.style.top = mousePos.y + 8;    
    fieldname = window.event.srcElement.id;
    fieldtype=window.event.srcElement.fieldtype;
    dragspan.appendChild(document.createTextNode(window.event.srcElement.innerHTML));
    document.body.appendChild(dragspan);
}
function SetValue()
{	
    setPos();
    var link="<%=MyCache.GetCacheConfig(0)+MyCache.GetCacheConfig(4)%>/label/KS.GetFieldParam.aspx?m_fieldname=" + fieldname+"&fieldtype="+fieldtype;
    parent.openWin('插入字段标签',link,false,350,200);
    if(window.drag)
    {
        window.drag = 0;
        window.event.returnValue = true;
    } 
    
}
function dragend()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan); 
        SetValue(); 
    }
}
function mouseCoords(ev) {
    if(ev.pageX || ev.pageY) {
      return {x:ev.pageX, y:ev.pageY};
    }
    return {
      x:ev.clientX + document.documentElement.scrollLeft - document.body.clientLeft,
      y:ev.clientY + document.documentElement.scrollTop - document.body.clientTop
    };
}
function dragclear()
{
    if(window.drag)
    {
        document.body.removeChild(dragspan);
        window.drag = 0;
        window.event.returnValue = true;
    }
    
}
function dragmove()
{
    if(window.drag)
    {
        var ev = ev || window.event;
        var mousePos = mouseCoords(ev);
        ev.returnValue = false; 
        dragspan.style.left = mousePos.x + 10;
        dragspan.style.top = mousePos.y + 8;
    }
}
function movePoint() 
{
    if(window.drag)
    {
        var rng = event.srcElement.createTextRange(); 
        rng.moveToPoint(event.x,event.y); 
        rng.select(); 
    }
}
</script>
<!--<KS:TopNav runat="server" Text="品牌列表标签第一步" ID="TopNav1" />-->
  <div class="content-area mt20">
    <div class="myTitle">品牌列表标签</div>
    <asp:Panel ID="Step1Panel" runat="server" Width="100%">
        <table style="margin:6px" width="98%" align="center" cellpadding="0" cellspacing="0" class="CTable no-borderTable">
        <tr>
            <td class="lefttd" style="height: 30px; text-align: right">
                <strong>标签名称：</strong></td>
            <td id="Td2" runat="server" class="righttd" style="height: 30px; text-align: left">
                <span style="color: #000066">{KS_</span><asp:TextBox CssClass="noborder" ID="LabelName" runat="server" Width="250px"></asp:TextBox><span style="color: #000066"> } * 调用格式：{KS_标签名称}</span><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="LabelName"
                    Display="Dynamic" ErrorMessage="标签名称必须输入"></asp:RequiredFieldValidator></td>
        </tr>
    <tr>
     <td class="lefttd" style="text-align: right; height: 30px;">
         <strong>标签目录：</strong></td>
     <td class="righttd" style="text-align: left; height: 30px;"><span  id="classidarea" runat="server"></span><span style="color:blue"> 请选择标签所属目录，以便日后管理标签</span></td>
    </tr>
            <tr style="display:none">
                <td class="lefttd" style="height: 30px; text-align: right">
                    <strong>选择模型：</strong></td>
                <td class="righttd" style="height: 30px; text-align: left">

                      <asp:DropDownList ID="ChannelID" runat="server">
                      <asp:ListItem Value="0">--不指定模型--</asp:ListItem>
                      </asp:DropDownList>
                      
                      <span style="color:blue">指定具体模型时,可用字段会包括自定义字段</span>
                      </td>
            </tr>
           
        <tr>
            <td class="lefttd" style="height: 30px; text-align: right">
                <strong>输出方式：</strong></td>
            <td class="righttd" style="height: 30px; text-align: left">
                    <asp:RadioButtonList ID="PrintStyle" runat="server" RepeatDirection="Horizontal">
                        <asp:ListItem Value="0" Selected="True">不采用Ajax输出</asp:ListItem>
                        <asp:ListItem Value="1">采用Ajax输出</asp:ListItem>
                    </asp:RadioButtonList></td>
        </tr>
      <tr>
                <td class="lefttd" style="height: 30px; text-align: right">
                    <strong>数据缓存时间：</strong></td>
                <td class="righttd" style="height: 30px; text-align: left">
                    <asp:TextBox ID="TxtCacheTime" CssClass="textbox" Text="0" runat="server" Width="60px" style="text-align:center"></asp:TextBox>分钟
                    <span class="tips">Tips:设置为“0”不启用缓存，设置为“-1”永久缓存。对查询出来的数据没有经常更新的标签，建议设置一个缓存时间，减少数据库查询，整个系统的性能将得到很好的提升。</span>
                </td>
            </tr>
        <tr>
            <td class="lefttd" style="height: 30px; text-align: right">
                <strong>简要介绍：</strong></td>
            <td class="righttd" style="height: 30px; text-align: left">
                <asp:TextBox ID="Descript" runat="server" CssClass="textbox textarea" Height="100px" Rows="8" TextMode="MultiLine" Width="500px"></asp:TextBox>
                   <a class="textarea_min" href="javascript:zoomtextarea(-5,'<%=this.Descript.ClientID %>');"></a>
                   <a class="textarea_max" href="javascript:zoomtextarea(5,'<%=this.Descript.ClientID %>');"></a>
            </td>
        </tr>
    </table><br />
    <KS:Foot ID="Foot1" runat="server" OnSubmit="Foot1_Submit" SubmitButtonText="下一步(0)" />
    </asp:Panel>


        <asp:Panel ID="Step2Panel" runat="server" Visible="false" Width="100%">
        
          <table style="margin:6px" width="98%" align="center" cellpadding="0" cellspacing="0" class="CTable no-borderTable">
            <tr>
                <td class="lefttd" style="height: 30px; text-align: right">
                    <span style="background-color: #f0f9fe"></span><strong>查询条数：</strong></td>
                <td id="Td3" runat="server" class="righttd" colspan="2" 
                    style="height: 30px; text-align: left">
                    <asp:TextBox ID="Num" runat="server" CssClass="textbox" 
                        style="text-align:center" Width="41px">10</asp:TextBox>
                    条&nbsp; <strong>排序方式：</strong><asp:DropDownList ID="Order" runat="server">
                        <asp:ListItem Value="ID desc">品牌ID降序</asp:ListItem>
                        <asp:ListItem Value="ID asc">品牌ID升序</asp:ListItem>
                        <asp:ListItem Value="orderid desc">品牌序号降序</asp:ListItem>
                        <asp:ListItem Value="orderid asc">品牌序号升序</asp:ListItem>
                        <asp:ListItem Value="newid()">随机显示</asp:ListItem>
                    </asp:DropDownList>
                    SQL附加条件：<asp:TextBox ID="SQLCondition" runat="server" CssClass="textbox" 
                        Width="150px">1</asp:TextBox>
                    可留空，如: and brandname=&#39;三星&#39;
                </td>
               
            </tr>
                 <tr>
                <td class="lefttd" style="height: 30px; text-align: right">
                    <strong>所属栏目：</strong><br /></td>
                <td id="Td4" runat="server" class="righttd" colspan="2" style="height: 30px; text-align: left">
                 <table border="0" cellpadding="0" cellspacing="0">
                     <tr>
                      <td style="width: 1px">
                      <select name='classid1' id='classid1' multiple size='3' style='height:120px;width: 350px'>
                      <option value='0'>-不指定栏目-</option>
                      <option value='-1' style='color:red'>当前栏目通用</option>
                     <%=MyCache.GetShopClassOptionList(0)%>
                      </select>
                       <br/>
                     <a class="textarea_min" href="javascript:zoomtextarea(-5,'classid1');"></a>
                      <a class="textarea_max" href="javascript:zoomtextarea(5,'classid1');"></a>
                      </td>
                         <td valign="top">
                     
                      <asp:CheckBox ID="ChildClass" runat="server" Checked="true" Text="允许列出子栏目品牌(仅对单选有效)" />
                      <br />&nbsp;&nbsp;<font color=blue>若要调用多个栏目，可以按Ctrl进行多选</font>
                             </td>
                      </tr>
                     </table>
                    </td>
             </tr>    
                    <tr>
                        <td class="lefttd" style="height: 30px; text-align: right">
                         <strong>&nbsp;属性控制：</strong>
                        </td>
                        <td class="righttd" colspan="2" style="height: 30px; text-align: left">
                        
                        <table border="0" cellpadding="0" cellspacing="0">
                     <tr>
                      <td style="width: 1px"></td>

                      <td>
                          <asp:CheckBoxList ID="Attribute" runat="server" RepeatDirection="Horizontal">
                            <asp:ListItem Value="1">推荐</asp:ListItem>
                            <asp:ListItem Value="2">仅显示带图片</asp:ListItem>
                        </asp:CheckBoxList>
                      </td>
                     </tr>
                    </table>
                        
                        
                        </td>
                    </tr>
            
       
             
            <tr>
                <td class="lefttd" style="height: 30px; text-align: right">
                    <strong>可用字段：</strong></td>
                <td class="righttd" colspan="2" style="height: 30px; text-align: left">
                
                <table width="95%" cellspacing="0" cellpadding="0" border="0">
                <tr>
                <td align="center"><div  onclick="InsertValue('{KS:Field:Url(brandview,brandid)}')" class="field" style="cursor:pointer">品牌链接URL</div></td>
                <td align="center"><div  onclick="InsertValue('{KS:Field:BrandID}')" class="field" style="cursor:pointer">品牌ID</div></td>
                <td align="center"><div onmousedown="DragStart()" id="BrandName" fieldtype="1" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">品牌名称</div></td>
                <td align="center"><div onmousedown="DragStart()" id="PhotoUrl" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">品牌小图</div></td>
                <td align="center"><div onmousedown="DragStart()" id="BigPhoto" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">品牌大图</div></td>
                <td align="center"><div onmousedown="DragStart()" id="Intro" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">品牌介绍</div></td>
                <tr>
                  <td align="center"><div onmousedown="DragStart()" id="firstAlphabet" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">首字母</div></td>
                  <td align="center"><div onmousedown="DragStart()" id="Num" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">商品数量</div></td>
                <td align="center"><div onmousedown="DragStart()" id="OrderID" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">排列序号</div></td>
                <td align="center"><div onmousedown="DragStart()" id="BrandEName" fieldtype="0" onclick="InsertLabel(this.id,this.fieldtype)" class="field" style="cursor:pointer">英文名称</div></td></tr>
                </tr></table>
                
                
                </td>
            </tr>
            <tr>
                <td class="lefttd" style="height: 30px; text-align: right">
                    <strong>样式循环体：</strong><br />
                    自动编号变量<font color=red>{$Auto(n)}</font><br />
                    n取值范围0-6之间,<a href='#' onclick="purview();return false;"><font color=blue>预览</font></a>
                    &nbsp;&nbsp;
                    </td>
                <td id="Td10" runat="server" class="righttd" colspan="2" style="height: 30px; text-align: left">
                    <asp:TextBox CssClass="textbox textarea" Height="150px" ID="LoopBody" onmouseup="dragend()" onmousemove="movePoint()" onclick='setPos()' onkeyup='setPos()' runat="server" Rows="6" TextMode="MultiLine" Width="92%"></asp:TextBox>
                    <a class="textarea_min" href="javascript:zoomtextarea(-5,'<%=this.LoopBody.ClientID %>');"></a>
                   <a class="textarea_max" href="javascript:zoomtextarea(5,'<%=this.LoopBody.ClientID %>');"></a>
                   </td>
            </tr>
                    <tr>
                        <td class="lefttd" style="height: 30px; text-align: right">
                            <strong>简要描述：</strong></td>
                        <td runat="server" class="righttd" colspan="2" style="height: 30px; text-align: left" id="Td8">
                           <span style="color: #6666ff">1、Loop使用规则</span><br />
循环体格式：[loop times="n"]循环标签的内容[/loop]<br />
其中n表示循环次数，且n满足n>=0。loop为循环关键字，此循环体可以重复使用,但是不能嵌套。 <br />
                            <span style="color: #6666ff">2、字段标签规则说明</span><br />
                                格式：{$Field(FieldName,OutType,Len)}<br/>
FieldName  --数据库表的字段名称<br />
OutType    --输出格式，支持文本(text),日期(date),对象(url)<br />
Len        --输出长度</td>
                    </tr>
            
      </table>

      <script src="/ks_drag/js/frame.format.js"></script>

     <div style="text-align:center">
         <asp:TextBox ID="LabelContent" runat="server" Height="87px" TextMode="MultiLine" Width="445px"></asp:TextBox>&nbsp;
         <asp:TextBox ID="LabelClassID" runat="server"></asp:TextBox>
         <asp:TextBox ID="LName" runat="server"></asp:TextBox>
         <asp:TextBox ID="LNote" runat="server"></asp:TextBox>
          <asp:HiddenField ID="HidTemplateID" runat="server" Value="0" />
         <br />
         <KS:Foot ID="Foot2" runat="server" OnSubmit="Foot2_Submit" />
     </div>

        </asp:Panel>

	</div>
</asp:Content>

