// Copyright (c) 2008 Synology Inc. All rights reserved.
var g_sortable_div=null;function onClickUpdateAlbum(_1,_2){var _3=Ext.DialogManager.get("album-update-dlg");if(!_3){_3=new SYNOPHOTO_ALBUM_DIALOG("album-update-dlg");_3.on("show",onKeyMapSwitch.createCallback(false));_3.on("hide",onKeyMapSwitch.createCallback(true));}_3.reset(_1,_2);_3.show();}function onClickArrangeAlbumOrder(){window.location="/photo/index.php?arrange_album=true";}function onClickSaveAlbumOrder(){if(!g_is_for_arrange_album){return;}var _4=Ext.get(document.body).mask(photo_str_plz_wait,"x-mask-loading");var _5=g_sortable_div.serialize().join(",").replace(/album_item_/g,"");Ext.Ajax.request({url:"/photo/include/ajax_handler.php",params:{action:"save_album_order",list:_5},method:"POST",success:function(_6,_7){window.location="/photo/";}});}function onClickNextPage(_8){if(typeof g_current_page=="undefined"){return;}var _9=g_current_page+_8;if(_9<1||_9>g_total_page){return;}location.href="index.php?page="+_9;}Ext.onReady(function(){if(g_is_for_arrange_album){g_sortable_div=new Sortables($("photo_mainframe_content"),{clone:true,revert:true,opacity:0.5,snap:0,onStart:function(_a,_b){_b.style.zIndex=9999999;}});}createKeyMapper(onClickNextPage);});function onPressEnterInSearch(e){var _2;var _3;var _4;if(window.event){_2=e.keyCode;}else{if(e.which){_2=e.which;}}if(_2==13){var _5=document.getElementById("search_key").value;_5=Ext.util.Format.trim(_5);if(_5!=""){onClickSearch();}document.getElementById("search_key").value="";}}function onClickSearch(){var _6=document.getElementById("search_key").value;_6=Ext.util.Format.trim(_6);if(_6!=""){_6=encodeURIComponent(_6);var _7;if(Ext.isIE){_7=Ext.get(document.documentElement).mask(photo_str_plz_wait,"x-mask-loading");}else{_7=Ext.get(document.body).mask(photo_str_plz_wait,"x-mask-loading");}_7.setSize(Ext.lib.Dom.getViewWidth(true),Ext.lib.Dom.getViewHeight(true));var _8="/photo/photo_thumb.php?n="+_6+"&t="+_6+"&d="+_6+"&type=0";if(typeof (g_current_dir)!="undefined"&&g_current_dir!=""){_8=_8+"&dir="+g_current_dir;}window.location=_8;}document.getElementById("search_key").value="";}function onClickAdvancedSearch(){var _9=Ext.DialogManager.get("ad-search-dlg");if(!_9){_9=new SYNOPHOTO_AD_SEARCH_DIALOG("ad-search-dlg");_9.on("show",onKeyMapSwitch.createCallback(false));_9.on("hide",onKeyMapSwitch.createCallback(true));}_9.show();}SYNOPHOTO_AD_SEARCH_DIALOG=function(_1){config={modal:true,autoTabs:true,autoCreate:true,width:520,height:540,shadow:true,minWidth:520,minHeight:540,proxyDrag:true,closable:true,collapsible:false,center:{autoScroll:false,tabPosition:"top",closeOnTab:true,titlebar:false,alwaysShowTabs:true}};SYNOPHOTO_AD_SEARCH_DIALOG.superclass.constructor.call(this,_1,config);this.addButton(photo_str_btnOK,this.onClickSubmit,this);this.addButton(photo_str_btnReset,this.onClickReset,this);this.addButton(photo_str_btnClose,this.hide,this);this.init();this.getLayout().getRegion("center").showPanel(0);this.addKeyListener(27,this.hide,this);this.addKeyListener([10,13],this.onClickSubmit,this);};Ext.extend(SYNOPHOTO_AD_SEARCH_DIALOG,Ext.LayoutDialog,{form:null,init:function(){var _2=Ext.id();var _3=String.format("<div style=\"margin:20px;\" id=\"{0}\"></div>",_2);var _4=this.getLayout();_4.beginUpdate();var cp=_4.add("center",new Ext.ContentPanel(Ext.id(),{autoCreate:true,title:photo_str_search_advanced,background:true}));_4.endUpdate();cp.setContent(_3);this.form=new Ext.form.Form({labelWidth:155,labelAlign:"left",buttonAlign:"right",trackResetOnLoad:true});this.form.fieldset({legend:photo_str_search_condition,hideLabels:false,width:480});this.form.column({style:"float:none",labelWidth:155,width:440},new Ext.form.TextField({fieldLabel:photo_str_search_name,name:"n",width:270,maxLength:256,validateOnBlur:true,validationEvent:"blur"}),new Ext.form.TextField({fieldLabel:photo_str_photoalbum_title,name:"t",width:270,maxLength:256,validateOnBlur:true,validationEvent:"blur"}),new Ext.form.TextField({fieldLabel:photo_str_photoalbum_desc,name:"d",width:270,maxLength:256,validateOnBlur:true,validationEvent:"blur"}));this.form.fieldset({legend:photo_str_sort_type_shottime,hideLabels:false,width:480,labelWidth:145},new Ext.form.DateField({fieldLabel:photo_str_search_date_from,width:140,name:"taken_from",format:"Y-m-d"}),new Ext.form.DateField({fieldLabel:photo_str_search_date_to,width:140,name:"taken_to",format:"Y-m-d"}));this.form.fieldset({legend:photo_str_sort_type_createtime,hideLabels:false,width:480,labelWidth:145},new Ext.form.DateField({fieldLabel:photo_str_search_date_from,width:140,name:"created_from",format:"Y-m-d"}),new Ext.form.DateField({fieldLabel:photo_str_search_date_to,width:140,name:"created_to",format:"Y-m-d"}));this.form.end();this.form.fieldset({legend:photo_str_search_type,hideLabels:true},new Ext.form.SRadio({boxLabel:photo_str_search_or,name:"type",inputValue:"0",checked:true}),new Ext.form.SRadio({boxLabel:photo_str_search_and,name:"type",inputValue:"1",checked:false}));this.form.render(_2);SYNOBLOG_UTILS.SetTextMaxLen(this.form,"n",256);SYNOBLOG_UTILS.SetTextMaxLen(this.form,"t",256);SYNOBLOG_UTILS.SetTextMaxLen(this.form,"d",256);},onClickSubmit:function(){if(!this.form.isValid()){return;}var _6=this.form.getValues();if(_6.n==""&&_6.t==""&&_6.d==""&&_6.taken_from==""&&_6.taken_to==""&&_6.created_from==""&&_6.created_to==""){Ext.MessageBox.alert(photo_str_ap_name,photo_str_search_no_condition);return;}if(_6.taken_from!=""&&_6.taken_to==""){this.form.findField("taken_to").markInvalid(_JSLIBSTR("extlang","fieldblank"));return;}if(_6.taken_from==""&&_6.taken_to!=""){this.form.findField("taken_from").markInvalid(_JSLIBSTR("extlang","fieldblank"));return;}if(_6.created_from!=""&&_6.created_to==""){this.form.findField("created_to").markInvalid(_JSLIBSTR("extlang","fieldblank"));return;}if(_6.created_from==""&&_6.created_to!=""){this.form.findField("created_from").markInvalid(_JSLIBSTR("extlang","fieldblank"));return;}this.hide();var _7=Ext.get(document.body).mask(photo_str_plz_wait,"x-mask-loading");_7.setSize(Ext.lib.Dom.getViewWidth(true),Ext.lib.Dom.getViewHeight(true));var _8="/photo/photo_thumb.php?type="+_6.type;if(_6.n!=""){_8=_8+"&n="+_6.n;}if(_6.t!=""){_8=_8+"&t="+_6.t;}if(_6.d!=""){_8=_8+"&d="+_6.d;}if(_6.taken_from!=""){_8=_8+"&taken_from="+_6.taken_from+"&taken_to="+_6.taken_to;}if(_6.created_from!=""){_8=_8+"&created_from="+_6.created_from+"&created_to="+_6.created_to;}if(typeof (g_current_dir)!="undefined"&&g_current_dir!=""){_8=_8+"&dir="+g_current_dir;}window.location=_8;},onClickReset:function(){this.form.reset();}});