/*
 * ExpressionEngine - by EllisLab
 *
 * @package		ExpressionEngine
 * @author		ExpressionEngine Dev Team
 * @copyright	Copyright (c) 2003 - 2011, EllisLab, Inc.
 * @license		http://expressionengine.com/user_guide/license.html
 * @link		http://expressionengine.com
 * @since		Version 2.0
 * @filesource
 */

$(document).ready(function(){var k,c,p,l,q,r;function A(b){h[b]===void 0&&(b=0);jQuery.each(h[b],function(a,b){switch(a){case "categories":$("select#f_cat_id").empty().append(b);break;case "statuses":$("select#f_status").empty().append(b)}})}function i(){if($("#custom_date_start").val()!="yyyy-mm-dd"&&$("#custom_date_end").val()!="yyyy-mm-dd")focus_number=$("#date_range").children().length,$("#date_range").append('<option id="custom_date_option">'+$("#custom_date_start").val()+" to "+$("#custom_date_end").val()+
"</option>"),document.getElementById("date_range").options[focus_number].selected=!0,$("#custom_date_picker").slideUp("fast"),oTable.fnDraw()}function u(b,a,f){for(var d=0,c=b.length;d<c;d++)if(b[d].name==a)b[d].value=f}function m(b,a){for(var f=0,d=b.length;f<d;f++)if(b[f].name==a)return b[f].value;return null}$(".paginationLinks .first").hide();$(".paginationLinks .previous").hide();$(".toggle_all").toggle(function(){$("input.toggle").each(function(){this.checked=!0})},function(){$("input.toggle").each(function(){this.checked=
!1})});$("#custom_date_start_span").datepicker({dateFormat:"yy-mm-dd",prevText:"<<",nextText:">>",onSelect:function(b){$("#custom_date_start").val(b);i()}});$("#custom_date_end_span").datepicker({dateFormat:"yy-mm-dd",prevText:"<<",nextText:">>",onSelect:function(b){$("#custom_date_end").val(b);i()}});$("#custom_date_start, #custom_date_end").focus(function(){$(this).val()=="yyyy-mm-dd"&&$(this).val("")});$("#custom_date_start, #custom_date_end").keypress(function(){$(this).val().length>=9&&i()});
var h=EE.edit.channelInfo,B=RegExp("!-!","g"),C=(new Date).getTime();(function(){jQuery.each(h,function(b,a){jQuery.each(a,function(a,d){var c=new String;jQuery.each(d,function(a,b){c+='<option value="'+b[0]+'">'+b[1].replace(B,String.fromCharCode(160))+"</option>"});h[b][a]=c})})})();$("#f_channel_id").change(function(){A(this.value)});$("#date_range").change(function(){$("#date_range").val()=="custom_date"?($("#custom_date_start").val("yyyy-mm-dd"),$("#custom_date_end").val("yyyy-mm-dd"),$("#custom_date_option").remove(),
$("#custom_date_picker").slideDown("fast")):$("#custom_date_picker").hide()});$("#entries_form").submit(function(){if(!$("input:checkbox",this).is(":checked"))return $.ee_notice(EE.lang.selection_required,{type:"error"}),!1});c=-1;k=void 0;p=void 0;l=void 0;q=void 0;r=void 0;EE.edit.tableColumns==9?(MyCols=[null,null,{bSortable:!1},null,null,null,null,null,{bSortable:!1}],MySortCol=5):(MyCols=[null,null,{bSortable:!1},null,null,null,null,{bSortable:!1}],MySortCol=4);oTable=$("#entries_form .mainTable").dataTable({sPaginationType:"full_numbers",
bLengthChange:!1,aaSorting:[[MySortCol,"desc"]],bFilter:!1,sWrapper:!1,sInfo:!1,bAutoWidth:!1,iDisplayLength:+EE.edit.perPage,aoColumns:MyCols,oLanguage:{sZeroRecords:EE.lang.noEntries,oPaginate:{sFirst:'<img src="'+EE.edit.themeUrl+'images/pagination_first_button.gif" width="13" height="13" alt="&lt; &lt;" />',sPrevious:'<img src="'+EE.edit.themeUrl+'images/pagination_prev_button.gif" width="13" height="13" alt="&lt; &lt;" />',sNext:'<img src="'+EE.edit.themeUrl+'images/pagination_next_button.gif" width="13" height="13" alt="&lt; &lt;" />',
sLast:'<img src="'+EE.edit.themeUrl+'images/pagination_last_button.gif" width="13" height="13" alt="&lt; &lt;" />'}},bProcessing:!0,bServerSide:!0,sAjaxSource:EE.BASE+"&C=content_edit&M=edit_ajax_filter&time="+C,fnServerData:function(b,a,f){function d(){return $(v).data("user_data")=="n"?"":v.value}var h=+EE.edit.pipe,n=!1,i=m(a,"sEcho"),e=m(a,"iDisplayStart"),j=m(a,"iDisplayLength"),g=e+j,v=document.getElementById("keywords"),w=document.getElementById("f_status"),s=document.getElementById("f_channel_id"),
x=document.getElementById("f_cat_id"),t=document.getElementById("f_search_in"),y=document.getElementById("date_range"),z=document.getElementById("f_perpage"),o;o="&ajax=true&keywords="+d()+"&channel_id="+s.value;if(t.value=="comments")window.location=EE.BASE+"&C=content_edit&M=view_comments"+o;a.push({name:"keywords",value:d()},{name:"status",value:w.value},{name:"channel_id",value:s.value},{name:"cat_id",value:x.value},{name:"search_in",value:t.value},{name:"date_range",value:y.value},{name:"per_page",
value:z.value});k=e;if(c<0||e<c||g>p)n=!0;if(l&&!n){g=0;for(o=a.length;g<o;g++)if(a[g].name!="iDisplayStart"&&a[g].name!="iDisplayLength"&&a[g].name!="sEcho"&&a[g].value!=l[g].value){n=!0;break}}l=a.slice();n?(e<c&&(e-=j*(h-1),e<0&&(e=0)),c=e,p=e+j*h,q=m(a,"iDisplayLength"),u(a,"iDisplayStart",e),u(a,"iDisplayLength",j*h),a.push({name:"keywords",value:d()},{name:"status",value:w.value},{name:"channel_id",value:s.value},{name:"cat_id",value:x.value},{name:"search_in",value:t.value},{name:"date_range",
value:y.value},{name:"per_page",value:z.value}),$.getJSON(b,a,function(a){r=jQuery.extend(!0,{},a);c!=k&&a.aaData.splice(0,k-c);a.aaData.splice(q,a.aaData.length);f(a)})):(json=jQuery.extend(!0,{},r),json.sEcho=i,json.aaData.splice(0,e-c),json.aaData.splice(j,json.aaData.length),f(json))}});$("#keywords").keyup(function(){oTable.fnDraw()});$("select#f_channel_id").change(function(){oTable.fnDraw()});$("select#f_cat_id").change(function(){oTable.fnDraw()});$("select#f_status").change(function(){oTable.fnDraw()});
$("select#f_search_in").change(function(){oTable.fnDraw()});$("select#date_range").change(function(){oTable.fnDraw()});$("select#f_perpage").change(function(){oTable.fnDraw()})});
