/* Copyright (c) 2016 Synology Inc. All rights reserved. */ Ext.ns("PhotoStation");PhotoStation.BaseWindow=Ext.extend(Ext.Window,{constructor:function(b){var a=Ext.apply({cls:"photo-window",modal:true,closable:false,shadow:"frame",shadowOffset:1,resizable:false,frame:false,useStatusBar:true,listeners:{beforeshow:function(c){if(c.useStatusBar){c.clearStatus()}}}},b);if(a.useStatusBar){a=this.addStatusBar(a)}PhotoStation.BaseWindow.superclass.constructor.call(this,a);this.mon(this,"hide",this.setFocus,this);this.mon(this,"close",this.setFocus,this)},setFocus:function(){if(!window.Main){return}var a=Main.getScope("PhotoStation.ViewCard");if(a&&!PhotoStation.Util.isSpecialView()&&!PhotoStation.CurrentBrowse.isAboutMe()){a.getLayout().activeItem.focus()}},setStatusBusy:function(b,a){this.el.mask(b||_PST("photo","photo_str_loading"),a)},clearStatusBusy:function(){this.el.unmask()},addStatusBar:function(a){var b={xtype:"statusbar",defaultText:" ",statusAlign:"left",buttonAlign:"left",items:[]};if(a.buttons){b.items=b.items.concat(a.buttons);delete a.buttons}Ext.applyIf(a,{fbar:b});return a},clearStatus:function(b){var a=this.getFooterToolbar();if(a&&Ext.isFunction(a.clearStatus)){a.clearStatus(b)}},setStatus:function(b){b=b||{};var a=this.getFooterToolbar();if(a&&Ext.isFunction(a.setStatus)){a.setStatus(b)}},setStatusOK:function(a){a=a||{};Ext.applyIf(a,{text:_PST("photo","photo_theme_apply_success"),iconCls:"x-status-valid",clear:true});this.setStatus(a)},setStatusError:function(a){a=a||{};Ext.applyIf(a,{text:_PST("photo","photo_theme_server_error"),iconCls:"x-status-error"});this.setStatus(a)}});Ext.ns("PhotoStation");PhotoStation.CommonGridPanel=Ext.extend(SYNO.ux.GridPanel,{pageSize:15,constructor:function(a){PhotoStation.CommonGridPanel.superclass.constructor.call(this,a);if(this.bottomToolbar){this.bottomToolbar.setButtonsVisible(false)}this.getStore().on("load",function(){if(this.bottomToolbar){this.bottomToolbar.setButtonsVisible(this.bottomToolbar.getPageData().total>this.pageSize)}},this)}});Ext.ns("PhotoStation");PhotoStation.CopyMoveMenu=Ext.extend(SYNO.ux.Menu,{constructor:function(a){Main.addScope("PhotoStation.CopyMoveMenu",this);PhotoStation.CopyMoveMenu.superclass.constructor.call(this,this.fillConfig(a));this.addEvents("aftercopymove")},fillConfig:function(b){var a={cls:"photo-copy-move-menu",items:[{xtype:"menuitem",ctCls:"photo-menu-text",itemId:"name",text:""},{xtype:"menuseparator",itemId:"sep"},{itemId:"copyRename",text:_PST("photo","photo_str_copy")+" - "+_PST("photo","photo_str_upload_rename"),handler:this.onCopyMoveClick,scope:this},{itemId:"copyOverwrite",text:_PST("photo","photo_str_copy")+" - "+_PST("photo","photo_str_upload_overwrite"),handler:this.onCopyMoveClick,scope:this},{itemId:"copySkip",text:_PST("photo","photo_str_copy")+" - "+_PST("photo","photo_str_upload_skip"),handler:this.onCopyMoveClick,scope:this},{itemId:"moveRename",text:_PST("photo","photo_str_man_album_move")+" - "+_PST("photo","photo_str_upload_rename"),handler:this.onCopyMoveClick,scope:this},{itemId:"moveOverwrite",text:_PST("photo","photo_str_man_album_move")+" - "+_PST("photo","photo_str_upload_overwrite"),handler:this.onCopyMoveClick,scope:this},{itemId:"moveSkip",text:_PST("photo","photo_str_man_album_move")+" - "+_PST("photo","photo_str_upload_skip"),handler:this.onCopyMoveClick,scope:this},"-",{itemId:"cancel",text:_PST("photo","photo_str_btnCancel"),handler:this.onCopyMoveClick,scope:this}]};return Ext.apply(a,b)},onCopyMoveClick:function(b,d){var f=b.itemId;var c,a;this.action="";switch(f){case"copyRename":c="copy";a="rename";break;case"copyOverwrite":c="copy";a="overwrite";break;case"copySkip":c="copy";a="ignore";break;case"moveRename":c="move";a="rename";break;case"moveOverwrite":c="move";a="overwrite";break;case"moveSkip":c="move";a="ignore";break;default:return}if(!this.files.length&&!this.albums.length){return}this.action=c;PhotoStation.Util.showWaitMsg({scope:this,fn:this.cancelCopyMove});if(!this.files.length){this.moveAlbums(c,a);return}this.copyMoveFiles(c,a)},copyMoveFiles:function(b,a){this.photoAjaxId=SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Photo","copy",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:this.files.join(","),mode:b,duplicate:a,sharepath:this.targetId},this.copyMoveFilesCallback,this)},copyMoveFilesCallback:function(e,a,d,b){if(!e){this.clearItems();var c=PhotoStation.Util.getErrMsg(a);if(457==a.code){c=_PST("photo","photo_permission_denied_upload")}else{if(458===a.code){c=_PST("photo","photo_str_select_conflict")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),c);return}this.photoAjaxId=null;if(this.albums.length){this.moveAlbums(d.mode,d.duplicate)}else{this.fireEvent("aftercopymove",d.mode,this.targetId,[]);this.clearItems()}},cancelCopyMove:function(){if(this.albumAjaxId){Ext.Ajax.abort(this.albumAjaxId);this.cancelRequest("album")}if(this.photoAjaxId){Ext.Ajax.abort(this.photoAjaxId);this.cancelRequest("photo")}if("move"===this.action){Main.getScope("PhotoStation.ViewCard").containerReLoad()}},cancelRequest:function(b){var a={name:"",id:"",action:""};if("album"===b){a.name="SYNO.PhotoStation.Album";a.id=this.albums.join(",");a.action="mvcp"}else{if("photo"===b){a.name="SYNO.PhotoStation.Photo";a.id=this.files.join(",");a.action="mvcp"}}if(""===a.name||""===a.id){return}SYNO.API.currentManager.requestAPI(a.name,"cancel",1,{id:a.id,action:a.action},function(g,f,e,c){if(!g){this.clearItems();var d=PhotoStation.Util.getErrMsg(f);if(419==f.code){d=_PST("photo","photo_permission_denied_upload")}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),d);return}this.clearItems()},this)},moveAlbums:function(b,a){if("copy"===b){this.clearItems();return}this.albumAjaxId=SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Album","move",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:this.albums.join(","),duplicate:a,sharepath:this.targetId},function(o,f,g,c){if(!o){this.clearItems();var d=PhotoStation.Util.getErrMsg(f);if(419==f.code){d=_PST("photo","photo_permission_denied_upload")}else{if(425===f.code){d=_PST("photo","photo_str_select_conflict")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),d);return}this.albumAjaxId=null;var m=[],k=0,h=0,e,n=false;for(k=0;k0;this.getComponent("name").setVisible(true).setText("["+a+"]");this.getComponent("copyRename").setVisible(!d);this.getComponent("copyOverwrite").setVisible(!d);this.getComponent("copySkip").setVisible(!d);this.getComponent("moveRename").setVisible(!d)},clearItems:function(){this.files=[];this.albums=[];this.targetId=null;PhotoStation.Util.closeWaitMsg()}});Ext.namespace("SYNO.Debug");SYNO.Debug=function(){var b=false;var e=Ext.emptyFn;var h=Ext;var d=Ext.emptyFn;function a(){var j="";for(var k=0;k')},getCheckbox:function(a){return Ext.apply({xtype:"tricheckbox",triMode:false,value:true,hideLabel:true,scope:this},a)},getTextfieldAndCopyButton:function(a,c){var b=new PhotoStation.ClipboardPlugin({overCls:"x-btn-over"});return{xtype:"compositefield",hideLabel:true,items:[Ext.apply({xtype:"textfield",cls:"selectabletext",width:240,readOnly:true,selectOnFocus:true},a),{xtype:"button",id:c,icon:PhotoStation.Util.getImgUrl("Window/bt_copy.png",true),cls:"photo-grey-button photo-button",clipboardPlugin:b,plugins:[b],listeners:{afterrender:function(d){d.el.dom.title=_PST("photo","photo_str_clipboard_copy_link")}}}]}},getTextfield:function(a){function b(c){var d=parseInt(c.getValue(),10);if(!d){d=0}c.setValue(d);this.update()}return Ext.apply({xtype:"textfield",width:50,enableKeyEvents:true,listeners:{scope:this,keypress:function(d,c){if(c.keyCode!==13){return}b.call(this,d)},change:function(c){b.call(this,c)}}},a)}});Ext.namespace("SYNO.SDS.Gesture");SYNO.SDS.Gesture.EmptyGesture=Ext.extend(Ext.util.Observable,{onTouchStart:Ext.emptyFn,onTouchMove:Ext.emptyFn,onTouchEnd:Ext.emptyFn,onTouchCancel:Ext.emptyFn});SYNO.SDS.Gesture.BaseGesture=Ext.extend(SYNO.SDS.Gesture.EmptyGesture,{constructor:function(){SYNO.SDS.Gesture.BaseGesture.superclass.constructor.apply(this,arguments)},getBrowserEvent:function(a){if(!a||!a.browserEvent){return null}return a.browserEvent},getFirstTouch:function(a){var c=null,b;b=this.getBrowserEvent(a);if(b&&b.touches&&b.touches.length>0){c=b.touches[0]}return c},getFirstChangedTouch:function(a){var c=null,b;b=this.getBrowserEvent(a);if(b&&b.changedTouches&&b.changedTouches.length>0){c=b.changedTouches[0]}return c},getChangedTouchCount:function(a){var b;b=this.getBrowserEvent(a);if(!b||!b.changedTouches||!Ext.isNumber(b.changedTouches.length)){return -1}return b.changedTouches.length},getTouchCount:function(a){var b;b=this.getBrowserEvent(a);if(!b||!b.touches||!Ext.isNumber(b.touches.length)){return -1}return b.touches.length}});SYNO.SDS.Gesture.Swipe=Ext.extend(SYNO.SDS.Gesture.BaseGesture,{expectTouchCount:1,config:{minDistance:80,maxOffset:100,maxDuration:1000},fireSwipe:function(a,e,c,d,b){SYNO.SDS.GestureMgr.fireEvent("swipe",a,e,c,d,b)},getMinDistance:function(){return this.config.minDistance},getMaxOffset:function(){return this.config.maxOffset},getMaxDuration:function(){return this.config.maxDuration},setInitialXY:function(c){var a,d,b;for(b=0,a=c.changedTouches.length;bthis.getMaxOffset()){this.isVertical=false}if(this.isHorizontal&&a>this.getMaxOffset()){this.isHorizontal=false}if(!this.isHorizontal&&!this.isVertical){return this.fail()}},checkTouchMove:function(j,b,d){var c,h,a,g,i,f;h=this.getBrowserEvent(j);a=h.timeStamp;if(a-this.startTime>this.getMaxDuration()){return this.fail()}for(f=0,g=h.changedTouches.length;f0){return this.fail()}if(j&&j.browserEvent){c=j.browserEvent.timeStamp}this.lastTapTime=c;e=this.getFirstChangedTouch(j);if(!e){return false}h=e.pageX;g=e.pageY;this.lastX=h;this.lastY=g;if(i&&this.checkXY(b,a)){if(this.isInMaxDuration(c,i)){this.lastTapTime=0;this.fireDoubleTap(j,d);return}}},checkXY:function(b,e){var c=Math.abs(this.lastX-b),a=Math.abs(this.lastY-e),d=this.getMaxOffset();if(cthis.getMaxOffset()){this.isVertical=false}if(this.isHorizontal&&a>this.getMaxOffset()){this.isHorizontal=false}if(!this.isHorizontal&&!this.isVertical){return this.fail()}},checkTouchMove:function(a,c,g){var i,f,d,b,h;f=this.getBrowserEvent(a);d=f.timeStamp;if(d-this.startTime>this.getMaxDuration()){return this.fail()}for(i in this.initialTouches){if(this.initialTouches.hasOwnProperty(i)){b=this.initialTouches[i];if(!b){SYNO.Debug("Error: initial does not exist when handle touchmove, TouchEvent id:"+h.identifier);continue}if(false===this.checkTouchXY(f,b.x,b.y)){return false}}}},onTouchStart:function(a,b,d){var c=this.getBrowserEvent(a);this.startTime=c.timeStamp;this.isHorizontal=true;this.isVertical=true;if(!this.initialTouches){this.initialTouches={}}this.setInitialXY(c);this.touchCount=this.getTouchCount()},onTouchMove:function(a,b,c){if(this.expectTouchCount!==this.getTouchCount()){return false}a.preventDefault();return this.checkTouchMove(a,b,c)},onTouchEnd:function(r,d,k){var j,p,n,i,h,f,c,q,g,o,a,b,m=this.getBrowserEvent(r);if(!this.initialTouches||!this.initialTouches[m.pointerId]){return false}b=this.initialTouches[m.pointerId];delete this.initialTouches[m.pointerId];if(this.getTouchCount()!==0){return false}if(this.touchCount!==this.expectTouchCount){return false}p=m.pageX;n=m.pageY;i=p-b.x;h=n-b.y;f=Math.abs(i);c=Math.abs(h);q=this.getMinDistance();g=m.timeStamp-this.startTime;if(this.isVertical&&c0,b="SYNO.SDS.Gesture."+(a?"MS.":"");switch(c){case"Swipe":if(a&&((window.navigator.msMaxTouchPoints?window.navigator.msMaxTouchPoints:0)<3)){return SYNO.SDS.Gesture.MS.EmptyGestureObject}b+=c;break;case"LongPress":if(a){return SYNO.SDS.Gesture.MS.EmptyGestureObject}b+=c;break;case"DoubleTap":if(a){return SYNO.SDS.Gesture.MS.EmptyGestureObject}b+=c;break;default:if(a){return SYNO.SDS.Gesture.MS.EmptyGestureObject}return SYNO.SDS.Gesture.EmptyGestureObject}return this.getGestureInstance(b)},getGestureInstance:function(a){var b=Ext.getClassByName(a);return new b()}});Ext.ns("PhotoStation");PhotoStation.ImageLoadManager=Ext.extend(Ext.util.Observable,{MAX_CONCURRENT:5,running:0,jobs:null,preemptJobs:null,delegate:null,constructor:function(){PhotoStation.ImageLoadManager.superclass.constructor.apply(this,arguments);this.jobs=[];this.preemptJobs=[];this.delayedPreemptJob=new Ext.util.DelayedTask(this.preemptJob,this)},clear:function(){this.running=0;this.jobs=[];this.preemptJobs=[]},appendJob:function(a){if(-1!==this.jobs.indexOf(a)){return}this.jobs.push(a);this.dispatch()},insertJob:function(a){this.preemptJobs.push(a);this.delayedPreemptJob.delay(100)},preemptJob:function(){Ext.each(this.preemptJobs,function(a){this.jobs.remove(a)},this);this.jobs.unshift.apply(this.jobs,this.preemptJobs);this.preemptJobs=[];this.dispatch()},dispatch:function(){while(this.MAX_CONCURRENT>=this.running){var a=this.jobs.shift();if(!a){break}this.running++;this.setImgURL(a)}},setImgURL:function(a){var b=a.getAttribute("thumbnails");if(!b){this.running--;this.dispatch.defer(0,this);return}Ext.fly(a).on({load:this.onImageLoad.createDelegate(this,[a]),error:this.onImageError.createDelegate(this,[a])});a.removeAttribute("thumbnails");a.src=b},finalizedImageLoad:function(a){Ext.fly(a).removeAllListeners();this.running--;this.dispatch.defer(0,this)},onImageLoad:function(a){this.finalizedImageLoad(a);if(this.delegate){this.delegate.onImageLoad(a)}},onImageError:function(a){this.finalizedImageLoad(a);if(this.delegate){this.delegate.onImageError(a)}}});Ext.ns("PhotoStation");PhotoStation.ImageStyleUpdater=Ext.extend(Ext.util.Observable,{MAX_PROCESSING:10,jobs:null,delegate:null,constructor:function(){PhotoStation.ImageStyleUpdater.superclass.constructor.apply(this,arguments);this.jobs=[];window.requestAnimationFrame=window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||window.msRequestAnimationFrame;if(!window.requestAnimationFrame){this.delayedUpdateImageStyle=new Ext.util.DelayedTask(this.updateImageStyle,this)}},clear:function(){this.jobs=[]},appendJob:function(a){var b=(0===this.jobs.length);this.jobs.remove(a);this.jobs.push(a);if(b){this.dispatch()}},dispatch:function(){if(window.requestAnimationFrame){window.requestAnimationFrame(this.updateImageStyle.createDelegate(this))}else{this.delayedUpdateImageStyle.delay(250)}},updateImageStyle:function(){var b=0;while(this.MAX_PROCESSING>b&&0=c.getY()-this.heightThreshold},rightoffold:function(c,a){var b;b=a.getX()+a.dom.scrollLeft+a.getWidth();return b>=c.getX()-this.widthThreshold},abovethetop:function(c,a){var b;b=a.getY()+a.dom.scrollTop;return b>=c.getY()+this.heightThreshold+c.getHeight()},leftofbegin:function(c,a){var b;b=a.getX()+a.dom.scrollLeft;return b>=c.getX()+this.widthThreshold+c.getWidth()},isIntens:function(b,a){var c=this;if(!c.isVisible()){return false}if(c.abovethetop(b,a)||c.leftofbegin(b,a)){return false}else{if(c.belowthefold(b,a)&&c.rightoffold(b,a)){return true}}},updateScrollbar:function(a){var b=this;if(b.isVisible()){var c=b.el.dom;if(c&&c.fleXcroll){if(a){c.fleXcroll.setScrollPos(false,0)}c.fleXcroll.updateScrollBars();if(!a){c.fleXcroll.setScrollPos(0,0,true)}}else{if(c){fleXenv.fleXcrollMain(c);c.onfleXcroll=(function(){if(b.isVisible()&&b.onUpdate){b.onUpdate()}}).createDelegate(this)}}c=null}},afterRender:function(){var a=this;PhotoStation.LazyDataView.superclass.afterRender.call(a);a.mon(a,{resize:a.onUpdate,scope:a})},onUpdate:function(){if(this.delay){if(!this.renderTask){this.renderTask=new Ext.util.DelayedTask(this.lazyLoadItems,this)}this.renderTask.delay(this.delay)}else{this.lazyLoadItems()}},updateItem:function(a){var b=this;if(a.isVisible()){if(b.isIntens(a,b.getEl())){b.onLoadItem(a)}else{b.onUnLoadItem(a)}}},lazyLoadItems:function(){if(this.isDestroyed){return}var a=this;if(a.all.getCount()===0){return}a.all.each(function(b){this.updateItem(b)},a)},lazyLoadItem:function(a){var b=this;b.updateItem(Ext.fly(a))},bufferRender:function(b,c){var d=this,a=PhotoStation.LazyDataView.superclass.bufferRender.call(d,b,c);Ext.each(a,d.lazyLoadItem,this);return a},onBeforeLoad:function(){if(this.loadingText){this.clearSelections(false,true);this.getEl().mask(this.loadingText);this.all.clear()}},refresh:function(){var c=this;if(this.loadingText){this.getEl().unmask()}if(this.store&&this.store.reader&&this.store.reader.jsonData&&this.store.reader.jsonData.data&&this.store.reader.jsonData.data.watermark){var a=this.store.data.items;for(var b=0;b

'});g=Ext.get(e.dom.firstChild);var u=e.dom.childNodes[1];i=Ext.get(u.firstChild);p=Ext.get(u.childNodes[2].firstChild);p.enableDisplayMode();p.addKeyListener([10,13],function(){if(q.isVisible()&&b&&b.buttons){if(b.buttons.ok){d("ok")}else{if(b.buttons.yes){d("yes")}}}});a=Ext.get(u.childNodes[2].childNodes[1]);a.enableDisplayMode();j=new Ext.ProgressBar({renderTo:e});e.createChild({cls:"x-clear"})}return q},updateText:function(x){if(!q.isVisible()&&!b.width){q.setSize(this.maxWidth,100)}i.update(x?x+" ":" ");var u=c!==""?(g.getWidth()+g.getMargins("lr")):0,z=i.getWidth()+i.getMargins("lr"),v=q.getFrameWidth("lr"),y=q.body.getFrameWidth("lr"),t;t=Math.max(Math.min(b.width||u+z+v+y,b.maxWidth||this.maxWidth),Math.max(b.minWidth||this.minWidth,m||0));if(b.prompt===true){r.setWidth(t-u-v-y)}if(b.progress===true||b.wait===true){j.setSize(t-u-v-y)}if(Ext.isIE&&t==m){t+=4}i.update(x||" ");q.setSize(t,"auto").center();return this},updateProgress:function(u,t,v){j.updateProgress(u,t);if(v){this.updateText(v)}return this},isVisible:function(){return q&&q.isVisible()},hide:function(){var t=q?q.activeGhost:null;if(this.isVisible()||t){q.hide();s();if(t){q.unghost(false,false)}}return this},show:function(w){if(this.isVisible()){this.hide()}b=w;var x=this.getDialog(b.title||" ");x.setTitle(b.title||" ");var t=(b.closable===true&&b.progress!==true&&b.wait!==true);x.tools.close.setDisplayed(t);r=p;b.prompt=b.prompt||(b.multiline?true:false);if(b.prompt){if(b.multiline){p.hide();a.show();a.setHeight(Ext.isNumber(b.multiline)?b.multiline:this.defaultTextHeight);r=a}else{p.show();a.hide()}}else{p.hide();a.hide()}r.dom.value=b.value||"";if(b.prompt){x.focusEl=r}else{var v=b.buttons;var u=null;if(v&&v.ok){u=o.ok}else{if(v&&v.yes){u=o.yes}}if(u){x.focusEl=u}}if(Ext.isDefined(b.iconCls)){x.setIconClass(b.iconCls)}this.setIcon(Ext.isDefined(b.icon)?b.icon:f);m=h(b.buttons);j.setVisible(b.progress===true||b.wait===true);this.updateProgress(0,b.progressText);this.updateText(b.msg);if(b.cls){x.el.addClass(b.cls)}x.proxyDrag=b.proxyDrag===true;x.modal=b.modal!==false;x.mask=b.modal!==false?n:false;if(!x.isVisible()){document.body.appendChild(q.el.dom);x.setAnimateTarget(b.animEl);x.on("show",function(){if(t===true){x.keyMap.enable()}else{x.keyMap.disable()}},this,{single:true});x.show(b.animEl)}if(b.wait===true){j.wait(b.waitConfig)}return this},setIcon:function(t){if(!q){f=t;return}f=undefined;if(t&&t!==""){g.removeClass("x-hidden");g.replaceClass(c,t);e.addClass("x-dlg-icon");c=t}else{g.replaceClass(c,"x-hidden");e.removeClass("x-dlg-icon");c=""}return this},progress:function(v,u,t){this.show({title:v,msg:u,buttons:false,progress:true,closable:false,minWidth:this.minProgressWidth,progressText:t});return this},wait:function(v,u,t){this.show({title:u,msg:v,buttons:false,closable:false,wait:true,modal:true,minWidth:this.minProgressWidth,waitConfig:t});return this},alert:function(w,v,u,t){this.show({title:w,msg:v,buttons:this.OK,fn:u,scope:t,minWidth:this.minWidth});return this},confirm:function(w,v,u,t){this.show({title:w,msg:v,buttons:this.YESNO,fn:u,scope:t,icon:this.QUESTION,minWidth:this.minWidth});return this},prompt:function(y,x,v,u,t,w){this.show({title:y,msg:x,buttons:this.OKCANCEL,fn:v,minWidth:this.minPromptWidth,scope:u,prompt:true,multiline:t,value:w});return this},OK:{ok:true},CANCEL:{cancel:true},OKCANCEL:{ok:true,cancel:true},YESNO:{yes:true,no:true},YESNOCANCEL:{yes:true,no:true,cancel:true},INFO:"ext-mb-info",WARNING:"ext-mb-warning",QUESTION:"ext-mb-question",ERROR:"ext-mb-error",defaultTextHeight:75,maxWidth:600,minWidth:300,minProgressWidth:250,minPromptWidth:250,buttonText:{ok:_PST("photo","photo_str_btnOK"),cancel:_PST("photo","photo_str_btnCancel"),yes:_PST("photo","photo_str_boolYes"),no:_PST("photo","photo_str_boolNo")},buttonCls:{ok:"photo-blue-button photo-button",cancel:"photo-grey-button photo-button",yes:"photo-blue-button photo-button",no:"photo-grey-button photo-button"}}}();Ext.ns("PhotoStation");PhotoStation.SelectAllDataView=Ext.extend(PhotoStation.LazyDataView,{constructor:function(a){PhotoStation.SelectAllDataView.superclass.constructor.call(this,a);this.selectAll=new Ext.util.MixedCollection(false,function(b){return b.id})},getSelectionCount:function(){return this.selectAll.items.length},getSelectedRecords:function(){return[].concat(this.selectAll.items)},onContainerClick:function(a){this.clearAllSelections()},clearAllSelections:function(a,b){if((this.multiSelect||this.singleSelect)&&this.selectAll.getCount()>0){if(!b){this.all.removeClass(this.selectedClass)}this.selected.clear();this.selectAll.clear();this.last=false;this.lastSelect=null;if(!a){this.fireEvent("selectionchange",this,this.selected.elements)}}},selectAllData:function(a){var c=this,d=c.getStore(),b=d.getCount();c.getEl().mask(_PST("photo","photo_str_loading"));if(d.getTotalCount()===d.getCount()){c.selectRange(0,b-1);c.getEl().unmask();return}var e=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:d.proxy.url,listeners:{beforeload:function(g,h){var i=g.activeRequest.read;if(i){Ext.Ajax.abort(i)}}}}),baseParams:d.baseParams,root:d.root,idProperty:d.idProperty,totalProperty:d.totalProperty,fields:d.fields.keys});var f=PhotoStation.Util.getContainerLoadParams();f.offset=0;f.limit=d.getTotalCount();e.load({params:f,callback:function(){if(c.isDestroy){return}c.selectRange(0,b-1);this.selectAll.addAll(e.data.items);c.getEl().unmask();if(a&&a.callback){a.callback.call(a.scope||this)}},scope:this})},getNode:function(b){if(Ext.isString(b)){return document.getElementById(b)}else{if(Ext.isNumber(b)){return this.all.elements[b]}else{if(b instanceof Ext.data.Record){var a=this.store.indexOfId(b.id);return this.all.elements[a]}}}return b},selectRange:function(c,a,b){if(!b){this.clearAllSelections(true)}this.select(this.getNodes(c,a),true)},isSelected:function(a){var b=this.getRecord(this.getNode(a));if(undefined===b){return false}return this.selectAll.containsKey(b.id)},deselect:function(a){if(this.isSelected(a)){a=this.getNode(a);this.selected.removeElement(a);var b=this.getRecord(this.getNode(a));this.selectAll.removeKey(b.id);if(this.last==a.viewIndex){this.last=false}Ext.fly(a).removeClass(this.selectedClass);this.fireEvent("selectionchange",this,this.selected.elements)}},select:function(d,f,b){if(Ext.isArray(d)){if(!f){this.clearAllSelections(true)}for(var c=0,a=d.length;c",{xtype:"tbspacer",width:24},{itemId:"select_all_btn",cls:"select-item-text",text:_PST("photo","photo_str_select_all"),handler:this.onSelectAll,scope:this},"-",{cls:"select-item-text",style:"padding-right: 18px;",text:_PST("photo","photo_str_unselect_all"),handler:this.onUnselectAll,scope:this},{icon:"photo_new/ext-3/ux/images/TextFilter/search-cancel.png",handler:this.hideWindow,scope:this}],listeners:{beforeshow:{fn:function(){this.alignTo(Main.getScope("PhotoStation.StatusArea").getEl(),"t-t",[0,4]);this.selectAllBtn=this.fbar.getComponent("select_all_btn");if(PhotoStation.CurrentBrowse.isAlbum()||PhotoStation.CurrentBrowse.isSmart()||PhotoStation.CurrentBrowse.isSharedAlbum()){this.selectAllBtn.setText(_PST("photo","photo_str_select_album_all"))}else{if(PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isCategory()){this.selectAllBtn.setText(_PST("photo","photo_str_select_all_album_photo"))}else{this.selectAllBtn.setText(_PST("photo","photo_str_select_all"))}}},scope:this},show:function(){Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus(false,true)},hide:function(){Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus()}}};return a},onSelectAll:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;a.selectAllData({callback:this.updateText,scope:this});a.lastMenuXY=null;Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus()},onUnselectAll:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;a.clearAllSelections();a.lastSelect=null;a.lastMenuXY=null},updateText:function(){for(var b=1;b0){this.collapse();d=this.items.get(0);d.el.focus()}return true}if(g.getKey()===g.BACKSPACE){g.stopEvent();if(this.currentFocus){b=this.currentFocus;this.on("expand",function(){this.collapse()},this,{single:true});a=this.items.indexOfKey(b.key);this.clearCurrentFocus();if(a<(this.items.getCount()-1)){i=this.items.itemAt(a+1)}b.preDestroy(true);if(i){(function(){i.onLnkFocus();this.currentFocus=i}).defer(200,this)}return}else{d=this.items.get(this.items.getCount()-1);if(d){if(this.backspaceDeletesLastItem){this.on("expand",function(){this.collapse()},this,{single:true});d.preDestroy(true)}else{if(this.navigateItemsWithTab){d.onElClick()}else{this.on("expand",function(){this.collapse();this.currentFocus=d;this.currentFocus.onLnkFocus.defer(20,this.currentFocus)},this,{single:true})}}}return true}}if(!g.isNavKeyPress()){this.multiSelectMode=false;this.clearCurrentFocus();return}if(g.getKey()===g.LEFT||(g.getKey()===g.UP&&!this.isExpanded())){g.stopEvent();this.collapse();d=this.items.get(this.items.getCount()-1);if(this.navigateItemsWithTab){if(d){d.focus()}}else{if(this.currentFocus){a=this.items.indexOfKey(this.currentFocus.key);this.clearCurrentFocus();if(a!==0){this.currentFocus=this.items.itemAt(a-1);this.currentFocus.onLnkFocus()}}else{this.currentFocus=d;if(d){d.onLnkFocus()}}}return true}if(g.getKey()===g.DOWN){if(this.currentFocus){this.collapse();g.stopEvent();a=this.items.indexOfKey(this.currentFocus.key);if(a==(this.items.getCount()-1)){this.clearCurrentFocus.defer(10,this)}else{this.clearCurrentFocus();this.currentFocus=this.items.itemAt(a+1);if(this.currentFocus){this.currentFocus.onLnkFocus()}}return true}}if(g.getKey()===g.RIGHT){this.collapse();d=this.items.itemAt(0);if(this.navigateItemsWithTab){if(d){d.focus()}}else{if(this.currentFocus){a=this.items.indexOfKey(this.currentFocus.key);this.clearCurrentFocus();if(a<(this.items.getCount()-1)){this.currentFocus=this.items.itemAt(a+1);if(this.currentFocus){this.currentFocus.onLnkFocus()}}}else{this.currentFocus=d;if(d){d.onLnkFocus()}}}}},onKeyUpBuffered:function(a){if(!a.isNavKeyPress()){this.autoSize()}},reset:function(){this.killItems();Ext.ux.form.SuperBoxSelect.superclass.reset.call(this);this.addedRecords=[];this.autoSize().setRawValue("")},applyEmptyText:function(){this.setRawValue("");if(this.items.getCount()>0){this.el.removeClass(this.emptyClass);this.setRawValue("");return this}if(this.rendered&&this.emptyText&&this.getRawValue().length<1){this.setRawValue(this.emptyText);this.el.addClass(this.emptyClass)}return this},removeAllItems:function(){this.items.each(function(a){a.preDestroy(true)},this);this.manageClearBtn();return this},killItems:function(){this.items.each(function(a){a.kill()},this);this.resetStore();this.items.clear();this.manageClearBtn();return this},resetStore:function(){this.store.clearFilter();if(!this.removeValuesFromStore){return this}this.usedRecords.each(function(a){this.store.add(a)},this);this.usedRecords.clear();if(!this.store.remoteSort){this.store.sort(this.displayField,"ASC")}return this},sortStore:function(){var a=this.store.getSortState();if(a&&a.field){this.store.sort(a.field,a.direction)}return this},getCaption:function(c){if(typeof this.displayFieldTpl==="string"){this.displayFieldTpl=new Ext.XTemplate(this.displayFieldTpl)}var b,a=c instanceof Ext.data.Record?c.data:c;if(this.displayFieldTpl){b=this.displayFieldTpl.apply(a)}else{if(this.displayField){b=a[this.displayField]}}return b},addRecord:function(b){var e=b.data[this.displayField],c=this.getCaption(b),f=b.data[this.valueField],a=this.classField?b.data[this.classField]:"",d=this.styleField?b.data[this.styleField]:"";if(this.removeValuesFromStore){this.usedRecords.add(f,b);this.store.remove(b)}this.addItemBox(f,e,c,a,d);this.fireEvent("additem",this,f,b)},createRecord:function(a){if(!this.recordConstructor){var b=[{name:this.valueField},{name:this.displayField}];if(this.classField){b.push({name:this.classField})}if(this.styleField){b.push({name:this.styleField})}this.recordConstructor=Ext.data.Record.create(b)}return new this.recordConstructor(a)},addItems:function(a){if(Ext.isArray(a)){Ext.each(a,function(b){this.addItem(b)},this)}else{this.addItem(a)}},addNewItem:function(a){this.addItem(a,true)},addItem:function(a,c){var e=a[this.valueField];if(this.disabled){return false}if(this.preventDuplicates&&this.hasValue(e)){return}var b=this.findRecord(this.valueField,e);if(b){this.addRecord(b);return}else{if(!this.allowAddNewData){return}}if(!c&&this.mode==="remote"){this.remoteLookup.push(a);this.doQuery(e,false,false,c);return}var d=this.createRecord(a);this.store.add(d);this.addRecord(d);return true},addItemBox:function(c,e,i,h,d){var f,g=function(k){var j="";switch(typeof k){case"function":j=k.call();break;case"object":for(var m in k){if(k.hasOwnProperty(m)){j+=m+":"+k[m]+";"}}break;case"string":j=k+";"}return j},a=Ext.id(null,"sbx-item"),b=new Ext.ux.form.SuperBoxSelectItem({owner:this,disabled:this.disabled,renderTo:this.wrapEl,cls:this.extraItemCls+" "+h,style:g(this.extraItemStyle)+" "+d,caption:i,display:e,value:c,key:a,listeners:{remove:function(j){if(this.fireEvent("beforeremoveitem",this,j.value)===false){return false}this.items.removeKey(j.key);if(this.removeValuesFromStore){if(this.usedRecords.containsKey(j.value)){this.store.add(this.usedRecords.get(j.value));this.usedRecords.removeKey(j.value);this.sortStore();if(this.view){this.view.render()}}}if(!this.preventMultipleRemoveEvents){this.fireEvent.defer(250,this,["removeitem",this,j.value,this.findInStore(j.value)])}},destroy:function(){this.collapse();this.autoSize().manageClearBtn().validateValue()},scope:this}});b.render();f={tag:"input",type:"text",name:(this.hiddenName||this.name),style:"display:none"};if(this.disabled){Ext.apply(f,{disabled:"disabled"})}b.hidden=this.el.insertSibling(f,"before");b.hidden.dom.value=c;this.items.add(a,b);this.applyEmptyText().autoSize().manageClearBtn().validateValue()},manageClearBtn:function(){if(!this.renderFieldBtns||!this.rendered){return this}var a="x-superboxselect-btn-hide";if(this.items.getCount()===0){this.buttonClear.addClass(a)}else{this.buttonClear.removeClass(a)}return this},findInStore:function(b){var a=this.store.find(this.valueField,b);if(a>-1){return this.store.getAt(a)}return false},getSelectedRecords:function(){var a=[];if(this.removeValuesFromStore){a=this.usedRecords.getRange()}else{var b=[];this.items.each(function(c){b.push(c.value)});Ext.each(b,function(c){a.push(this.findInStore(c))},this)}return a},findSelectedItem:function(b){var a;this.items.each(function(c){if(c.el.dom===b){a=c;return false}});return a},findSelectedRecord:function(b){var a,c=this.findSelectedItem(b);if(c){a=this.findSelectedRecordByValue(c.value)}return a},findSelectedRecordByValue:function(b){var a;if(this.removeValuesFromStore){this.usedRecords.each(function(c){if(c.get(this.valueField)==b){a=c;return false}},this)}else{a=this.findInStore(b)}return a},getValue:function(){var a=[];this.items.each(function(b){a.push(b.value)});return a.join(this.valueDelimiter)},getCount:function(){return this.items.getCount()},getValueEx:function(){var a=[];this.items.each(function(c){var b={};b[this.valueField]=c.value;b[this.displayField]=c.display;if(this.classField){b[this.classField]=c.cls||""}if(this.styleField){b[this.styleField]=c.style||""}a.push(b)},this);return a},initValue:function(){if(Ext.isObject(this.value)||Ext.isArray(this.value)){this.setValueEx(this.value);this.originalValue=this.getValue()}else{Ext.ux.form.SuperBoxSelect.superclass.initValue.call(this)}if(this.mode==="remote"){this.setOriginal=true}},addValue:function(c){if(Ext.isEmpty(c)){return}var a=c;if(!Ext.isArray(c)){c=""+c;a=c.split(this.valueDelimiter)}Ext.each(a,function(e){var d=this.findRecord(this.valueField,e);if(d){this.addRecord(d)}else{if(this.mode==="remote"){this.remoteLookup.push(e)}}},this);if(this.mode==="remote"){var b=this.remoteLookup.join(this.queryValuesDelimiter);this.doQuery(b,false,true)}},setValue:function(a){if(!this.rendered){this.value=a;return}this.removeAllItems().resetStore();this.remoteLookup=[];this.addValue(a)},setValueEx:function(a){if(!this.rendered){this.value=a;return}this.removeAllItems().resetStore();if(!Ext.isArray(a)){a=[a]}this.remoteLookup=[];if(this.allowAddNewData&&this.mode==="remote"){Ext.each(a,function(c){var b=this.findRecord(this.valueField,c[this.valueField])||this.createRecord(c);this.addRecord(b)},this);return}Ext.each(a,function(b){this.addItem(b)},this)},hasValue:function(b){var a=false;this.items.each(function(c){if(c.value==b){a=true;return false}},this);return a},onSelect:function(a,b){if(this.fireEvent("beforeselect",this,a,b)!==false){var c=a.data[this.valueField];if(this.preventDuplicates&&this.hasValue(c)){return}this.setRawValue("");this.lastSelectionText="";if(this.fireEvent("beforeadditem",this,c,a,this.filteredQueryData)!==false){this.addRecord(a)}if(this.store.getCount()===0||!this.multiSelectMode){this.collapse()}else{this.restrictHeight()}}},onDestroy:function(){this.items.purgeListeners();this.killItems();if(this.allowQueryAll){Ext.destroy(this.buttonExpand)}if(this.renderFieldBtns){Ext.destroy(this.buttonClear,this.buttonWrap)}Ext.destroy(this.inputEl,this.wrapEl,this.outerWrapEl);Ext.ux.form.SuperBoxSelect.superclass.onDestroy.call(this)},autoSize:function(){if(!this.rendered){return this}if(!this.metrics){this.metrics=Ext.util.TextMetrics.createInstance(this.el)}var c=this.el,b=c.dom.value,e=document.createElement("div");if(b===""&&this.emptyText&&this.items.getCount()<1){b=this.emptyText}e.appendChild(document.createTextNode(b));b=e.innerHTML;e=null;b+=" ";var a=Math.max(this.metrics.getWidth(b)+24,24);if(typeof this._width!="undefined"){a=Math.min(this._width,a)}this.el.setWidth(a);if(Ext.isIE){this.el.dom.style.top="0"}this.fireEvent("autosize",this,a);return this},shouldQuery:function(b){if(this.lastQuery){var a=b.match("^"+this.lastQuery);if(!a||this.store.getCount()){return true}else{return(a[0]!==this.lastQuery)}}return true},doQuery:function(f,e,b,d){f=Ext.isEmpty(f)?"":f;if(this.queryFilterRe){this.filteredQueryData="";var a=f.match(this.queryFilterRe);if(a&&a.length){this.filteredQueryData=a[0]}f=f.replace(this.queryFilterRe,"");if(!f&&a){return}}var c={query:f,forceAll:e,combo:this,cancel:false};if(this.fireEvent("beforequery",c)===false||c.cancel){return false}f=c.query;e=c.forceAll;if(e===true||(f.length>=this.minChars)||b&&!Ext.isEmpty(f)){if(d||this.forceSameValueQuery||this.shouldQuery(f)){this.lastQuery=f;if(this.mode=="local"){this.selectedIndex=-1;if(e){this.store.clearFilter()}else{this.store.filter(this.displayField,f)}this.onLoad()}else{this.store.baseParams[this.queryParam]=f;this.store.baseParams[this.queryValuesIndicator]=b;this.store.load({params:this.getParams(f)});if(!d){this.expand()}}}else{this.selectedIndex=-1;this.onLoad()}}},onStoreLoad:function(b,a,c){var f=c.params[this.queryParam]||b.baseParams[this.queryParam]||"",g=c.params[this.queryValuesIndicator]||b.baseParams[this.queryValuesIndicator];if(!this.store){return}if(this.removeValuesFromStore){this.store.each(function(i){if(this.usedRecords.containsKey(i.get(this.valueField))){this.store.remove(i)}},this)}if(g){var h=f.split(this.queryValuesDelimiter);Ext.each(h,function(i){this.remoteLookup.remove(i);var j=this.findRecord(this.valueField,i);if(j){this.addRecord(j)}},this);if(this.setOriginal){this.setOriginal=false;this.originalValue=this.getValue()}}if(f!==""&&this.allowAddNewData){Ext.each(this.remoteLookup,function(i){if(typeof i==="object"&&i[this.valueField]===f){this.remoteLookup.remove(i);if(a.length&&a[0].get(this.valueField)===f){this.addRecord(a[0]);return}var j=this.createRecord(i);this.store.add(j);this.addRecord(j);this.addedRecords.push(j);(function(){if(this.isExpanded()){this.collapse()}}).defer(10,this);return}},this)}var d=[];if(f===""){Ext.each(this.addedRecords,function(i){if(this.preventDuplicates&&this.usedRecords.containsKey(i.get(this.valueField))){return}d.push(i)},this)}else{var e=new RegExp(Ext.escapeRe(f)+".*","i");Ext.each(this.addedRecords,function(i){if(this.preventDuplicates&&this.usedRecords.containsKey(i.get(this.valueField))){return}if(e.test(i.get(this.displayField))){d.push(i)}},this)}this.store.add(d);this.sortStore();if(this.store.getCount()===0&&this.isExpanded()){this.collapse()}}});Ext.reg("superboxselect",Ext.ux.form.SuperBoxSelect);Ext.ux.form.SuperBoxSelectItem=function(a){Ext.apply(this,a);Ext.ux.form.SuperBoxSelectItem.superclass.constructor.call(this)};Ext.ux.form.SuperBoxSelectItem=Ext.extend(Ext.ux.form.SuperBoxSelectItem,Ext.Component,{initComponent:function(){Ext.ux.form.SuperBoxSelectItem.superclass.initComponent.call(this)},onElClick:function(a){var b=this.owner;b.clearCurrentFocus().collapse();if(b.navigateItemsWithTab){this.focus()}else{b.el.dom.focus();(function(){this.onLnkFocus();b.currentFocus=this}).defer(10,this)}},onLnkClick:function(a){if(a){a.stopEvent()}this.preDestroy();if(!this.owner.navigateItemsWithTab){this.owner.el.focus()}},onLnkFocus:function(){this.el.addClass("x-superboxselect-item-focus");this.owner.outerWrapEl.addClass("x-form-focus")},onLnkBlur:function(){this.el.removeClass("x-superboxselect-item-focus");this.owner.outerWrapEl.removeClass("x-form-focus")},enableElListeners:function(){this.el.on("click",this.onElClick,this,{stopEvent:true});this.el.addClassOnOver("x-superboxselect-item-hover")},enableLnkListeners:function(){this.lnk.on({click:this.onLnkClick,focus:this.onLnkFocus,blur:this.onLnkBlur,scope:this})},enableAllListeners:function(){this.enableElListeners();this.enableLnkListeners()},disableAllListeners:function(){this.el.removeAllListeners();this.lnk.un("click",this.onLnkClick,this);this.lnk.un("focus",this.onLnkFocus,this);this.lnk.un("blur",this.onLnkBlur,this)},onRender:function(c,a){Ext.ux.form.SuperBoxSelectItem.superclass.onRender.call(this,c,a);var e=this.el;if(e){e.remove()}this.el=e=c.createChild({tag:"li"},c.last());e.addClass("x-superboxselect-item");var d=this.owner.navigateItemsWithTab?(Ext.isSafari?"button":"a"):"span";Ext.apply(e,{focus:function(){var f=this.down(d+".x-superboxselect-item-close");if(f){f.focus()}},preDestroy:function(){this.preDestroy()}.createDelegate(this)});this.enableElListeners();e.update(this.caption);var b={tag:d,"class":"x-superboxselect-item-close",tabIndex:this.owner.navigateItemsWithTab?"0":"-1"};if(d==="a"){b.href="#"}this.lnk=e.createChild(b);if(!this.disabled){this.enableLnkListeners()}else{this.disableAllListeners()}this.on({disable:this.disableAllListeners,enable:this.enableAllListeners,scope:this});this.setupKeyMap()},setupKeyMap:function(){this.keyMap=new Ext.KeyMap(this.lnk,[{key:[Ext.EventObject.BACKSPACE,Ext.EventObject.DELETE,Ext.EventObject.SPACE],fn:this.preDestroy,scope:this},{key:[Ext.EventObject.RIGHT,Ext.EventObject.DOWN],fn:function(){this.moveFocus("right")},scope:this},{key:[Ext.EventObject.LEFT,Ext.EventObject.UP],fn:function(){this.moveFocus("left")},scope:this},{key:[Ext.EventObject.HOME],fn:function(){var a=this.owner.items.get(0).el.focus();if(a){a.el.focus()}},scope:this},{key:[Ext.EventObject.END],fn:function(){this.owner.el.focus()},scope:this},{key:Ext.EventObject.ENTER,fn:function(){}}]);this.keyMap.stopEvent=true},moveFocus:function(a){var b=this.el[a=="left"?"prev":"next"]()||this.owner.el;b.focus.defer(100,b)},preDestroy:function(a){if(this.fireEvent("remove",this)===false){return}var b=function(){if(this.owner.navigateItemsWithTab){this.moveFocus("right")}this.hidden.remove();this.hidden=null;this.destroy()};if(a){b.call(this)}else{this.el.hide({duration:0.2,callback:b,scope:this})}return this},kill:function(){this.hidden.remove();this.hidden=null;this.purgeListeners();this.destroy()},onDisable:function(){if(this.hidden){this.hidden.dom.setAttribute("disabled","disabled")}this.keyMap.disable();Ext.ux.form.SuperBoxSelectItem.superclass.onDisable.call(this)},onEnable:function(){if(this.hidden){this.hidden.dom.removeAttribute("disabled")}this.keyMap.enable();Ext.ux.form.SuperBoxSelectItem.superclass.onEnable.call(this)},onDestroy:function(){Ext.destroy(this.lnk,this.el);Ext.ux.form.SuperBoxSelectItem.superclass.onDestroy.call(this)}});Ext.ns("PhotoStation");Ext.define("PhotoStation.WatermarkSelector",{extend:"PhotoStation.BaseWindow",WINDOW_WIDTH:880,WINDOW_HEIGHT:640,TREE_WIDTH:210,TREE_ROOT_ID_MY:"watermark_2f7661722f7061636b616765732f50686f746f53746174696f6e2f7461726765742f77617465726d61726b73",TREE_ROOT_ID_DS:"dsmshare_",CLASS_DATAVIEW_CLEAR:"syno-photo-watermark-dataview-clear",CLASS_DATAVIEW_SELECTED:"syno-photo-watermark-dataview-selected",UPLOAD_PANEL_HEIGHT:149,constructor:function(a){PhotoStation.WatermarkSelector.superclass.constructor.call(this,Ext.apply({width:this.WINDOW_WIDTH,height:this.WINDOW_HEIGHT,title:_PST("photo","watermark_str_select"),layout:"border",buttons:[{cls:"photo-blue-button photo-button",itemId:"button-ok",text:_PST("photo","photo_str_btnOK"),disabled:true,scope:this,handler:function(){this.handleButton(true)}},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),scope:this,handler:function(){this.handleButton()}}],listeners:{scope:this,afterrender:function(){this.fileButton=this.el.createChild({tag:"input",type:"file",multiple:true,hidden:true,accept:"image/*"});this.fileButton.on("change",this.onUpload,this);var b=this.getComponent("tree-panel");this.updateScrollbar.call(b);var c=b.getComponent(0);c.selectPath(c.getRootNode().getPath())}},defaults:{border:false},items:[{itemId:"tree-panel",region:"west",width:this.TREE_WIDTH,autoScroll:false,margins:"10, 10, 0, 10",items:this.getTreeItems()},{itemId:"data-panel",region:"center",margins:"10, 0, 10, 0",layout:"fit",bodyStyle:{borderLeft:"1px solid #d0d0d0",padding:"0 20px"},items:[{layout:"border",border:false,items:[{itemId:"upload-panel",region:"north",minHeight:0,style:{minHeight:0},bodyStyle:{minHeight:0},border:false,height:this.UPLOAD_PANEL_HEIGHT,defaults:{border:false},items:[{html:_PST("photo","photo_theme_from_computer"),cls:"syno-photo-watermark-selector-lable"},{xtype:"button",cls:"photo-button photo-grey-button",text:_PST("photo","photo_str_btnUpload"),style:{margin:"3px 8px 11px"},scope:this,handler:function(){this.fileButton.dom.click()}},{html:_PST("photo","photo_str_my_image"),cls:"syno-photo-watermark-selector-lable"},{xtype:"button",cls:"photo-button photo-grey-button",itemId:"delete-button",text:_PST("photo","photo_str_delete"),style:{margin:"3px 8px 0"},scope:this,handler:this.onClickDelete}]},this.getDataView({region:"center"})]}]}]},a))},onClickDelete:function(){var a=[];for(var b=0;b'+_PST("photo","photo_str_no_photo")+"";var d=this.getStore();d.setBaseParam("d",g.id);d.load()},getTemplate:function(){if(!this.tpl){this.tpl=new Ext.XTemplate('','
','
','{title:htmlEncode}',"
","
",'
',{getBackgroundUrl:function(a){return Ext.urlAppend(PhotoStation.Util.getWebAPIUrl("thumb.php"),Ext.urlEncode({api:"SYNO.PhotoStation.Thumb",method:"get_dsm_thumb",version:1,id:a.id}))}});this.tpl.compile()}return this.tpl},getStore:function(){if(!this.store){this.store=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("watermark.php")}),baseParams:{api:"SYNO.PhotoStation.Watermark",method:"listshare",version:1,d:this.TREE_ROOT_ID_MY},root:"data.items",idProperty:"id",fields:["id","title","width","height","path"],listeners:{scope:this,beforeload:function(a,b){var c=this.getComponent("data-panel");c.getComponent(0).getComponent("upload-panel").getComponent("delete-button").disable();this.watermark=null;this.getFooterToolbar().getComponent("button-ok").setDisabled(true);c.el.mask(_PST("photo","photo_str_loading"),"center-transparent-mask")},load:function(a,c,d){var e=this.getComponent("data-panel");e.el.unmask();var b=e.getComponent(0).getComponent("data-view");var f=b.getContentTarget().dom;if(f.fleXcroll){f.fleXcroll=null}this.updateScrollbar.call(b)}}})}return this.store},updateScrollbar:function(){if(this.isVisible()){var k=this.getContentTarget().dom;var h=k.childNodes;if(k&&k.fleXcroll&&2===h.length){fleXenv.updateScrollBars()}else{if(k&&k.fleXcroll){var d=k.childNodes;var c=[];for(var f=0,e=0;f0)||(g.data.ignored.length>0)){var f="";if(g.data.failed.length>0){f+="Failed: "+g.data.failed.join(", ")}if(g.data.ignored.length>0){if(f){f+="
"}f+="Ignored: "+g.data.ignored.join(", ")}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),f)}this.getStore().load()}).createDelegate(this);d.open("POST",PhotoStation.Util.getWebAPIUrl("watermark.php"));d.setRequestHeader("X-SYNO-TOKEN",Ext.util.Cookies.get("PHPSESSID"));d.send(c)}});Ext.ns("PhotoStation");Ext.define("PhotoStation.WatermarkWindow",{extend:"PhotoStation.BaseWindow",WINDOW_WIDTH:794,WINDOW_HEIGHT:548,PREVIEW_WIDTH:400,PREVIEW_HEIGHT:400,CLASS_GRAVITY_CLEAR:"syno-photostation-watermark-gravity-clear",CLASS_GRAVITY_SELECTED:"syno-photostation-watermark-gravity-selected",constructor:function(a){if(!a.watermark){a.watermark={title:"",path:"",opacity:100,gravity:0,size:100}}PhotoStation.WatermarkWindow.superclass.constructor.call(this,Ext.apply({width:this.WINDOW_WIDTH,height:this.WINDOW_HEIGHT,title:_PST("photo","watermark_str_edit"),buttons:[{scope:this,cls:"photo-blue-button photo-button",itemId:"button-ok",text:_PST("photo","photo_str_btnOK"),disabled:true,handler:this.onClickButtonOK},{scope:this,cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:function(){this.close()}}],layout:"fit",listeners:{scope:this,afterrender:function(){this.init()}},items:[{layout:"border",itemId:"window-body",border:false,defaults:{border:false},items:[{itemId:"preview-panel",region:"west",width:this.PREVIEW_WIDTH,cls:"syno-photo-watermark-preview",layout:"absolute",items:[{itemId:"preview-image",border:false,layout:"absolute",items:[{itemId:"watermark-panel",border:false,bodyCssClass:"syno-photo-watermark-preview-watermark"}]}]},{itemId:"control-panel",region:"center",margins:"0, 0, 0, 20",items:[this.getFieldSet({itemId:"watermark-field"},Ext.apply(this.getLabel(_PST("photo","watermark_str_watermark")),{margins:"0, 0, -1, 0"}),{itemId:"watermark-text",xtype:"textfield",style:"margin-top:5px;"},{xtype:"button",tooltip:_PST("photo","photo_str_ds_copy_window_title"),cls:"photo-grey-button photo-button",icon:"photo_new/images/PopupWindow/bt_select_image.png",scope:this,handler:this.showWatermarkSelector}),this.getFieldSet({itemId:"transparency-field"},this.getLabel(_PST("photo","watermark_str_transparency")),{itemId:"slider-transparency",xtype:"syno_sliderfield",listeners:{scope:this,valuechange:this.onSliderValueChangeTransparency}},{itemId:"transparency-text",xtype:"textfield",value:"0%",enableKeyEvents:true,listeners:{scope:this,keypress:function(c,b){if(b.button===12){this.getComponent("window-body").getComponent("control-panel").getComponent("transparency-field").getComponent("slider-transparency").setValue(this.parseTextFieldValue(c.el.dom.value))}},change:function(c,d,b){this.getComponent("window-body").getComponent("control-panel").getComponent("transparency-field").getComponent("slider-transparency").setValue(this.parseTextFieldValue(c.el.dom.value))}}}),this.getFieldSet({itemId:"size-field"},this.getLabel(_PST("photo","watermark_str_scale")),{itemId:"slider-size",xtype:"syno_sliderfield",tipText:function(b){return""+(parseInt(b.value,10)+50)+"%"},listeners:{scope:this,valuechange:this.onSliderValueChangeSize}},{itemId:"size-text",xtype:"textfield",value:"50%",enableKeyEvents:true,listeners:{scope:this,keypress:function(c,b){if(b.button===12){this.getComponent("window-body").getComponent("control-panel").getComponent("size-field").getComponent("slider-size").setValue(this.parseTextFieldValue(c.el.dom.value)-50)}},change:function(c,d,b){this.getComponent("window-body").getComponent("control-panel").getComponent("size-field").getComponent("slider-size").setValue(this.parseTextFieldValue(c.el.dom.value)-50)}}}),Ext.apply(this.getLabel(_PST("photo","watermark_str_position")),{border:false,height:28,style:{marginBottom:"6px"}}),this.getGravitySelector({itemId:"gravity-selector"})]}]}]},a))},parseTextFieldValue:function(a){a=parseInt(a,10);if(!a){a=0}return a},init:function(){if(this.watermark.size<50){this.watermark.size=100}this.getComponent("window-body").getComponent("control-panel").getComponent("watermark-field").getComponent("watermark-text").setValue(this.watermark.title);this.getFooterToolbar().getComponent("button-ok").setDisabled(this.watermark.path==="");this.gravity=this.getComponent("window-body").getComponent("control-panel").getComponent("gravity-selector").getComponent(this.watermark.gravity);this.gravity.getComponent(0).body.removeClass(this.CLASS_GRAVITY_CLEAR).addClass(this.CLASS_GRAVITY_SELECTED);this.preview={image:this.album,target:this.getComponent("window-body").getComponent("preview-panel").getComponent("preview-image"),scale:1};if(this.preview.image.width<=0){this.preview.image.width=this.PREVIEW_WIDTH}if(this.preview.image.height<=0){this.preview.image.height=this.PREVIEW_HEIGHT}this.updatePreview();var a=this.getComponent("window-body").getComponent("control-panel");a.getComponent("transparency-field").getComponent("slider-transparency").setValue(100-this.watermark.opacity);a.getComponent("size-field").getComponent("slider-size").setValue(this.watermark.size-50)},switchPreview:function(b,c,a){switch(b.keyCode){case 37:--this.preview.index;if(this.preview.index<0){this.preview.index=this.recs.length-1}this.updatePreview();break;case 39:++this.preview.index;if(this.preview.index>=this.recs.length){this.preview.index=0}this.updatePreview();break;default:break}},onClickButtonOK:function(){this.fireEvent("setting-done",this.watermark);this.close()},onSliderValueChangeTransparency:function(a,b){this.watermark.opacity=100-parseInt(b,10);this.getComponent("window-body").getComponent("control-panel").getComponent("transparency-field").getComponent("transparency-text").setValue(""+b+"%");this.preview.target.getComponent("watermark-panel").body.setStyle("opacity",this.watermark.opacity/100)},onSliderValueChangeSize:function(a,b){this.watermark.size=parseInt(b,10)+50;this.getComponent("window-body").getComponent("control-panel").getComponent("size-field").getComponent("size-text").setValue(""+this.watermark.size+"%");this.updateWatermark()},updatePreview:function(){var c=this.preview.image.width,a=this.preview.image.height;var g=this.PREVIEW_WIDTH/c,b=this.PREVIEW_HEIGHT/a;this.preview.scale=((gj){m*=j/b;b=j}if(m*3>f){b*=f/(m*3);m=f/3}var g=this.preview.target.getComponent("watermark-panel");g.setSize(b,m);var c=0,i=0,k=j-b,a=f-m;var e=k/2,d=a/2;switch(this.watermark.gravity){case 0:g.setPosition(c,i);break;case 1:g.setPosition(e,i);break;case 2:g.setPosition(k,i);break;case 3:g.setPosition(c,d);break;case 4:g.setPosition(e,d);break;case 5:g.setPosition(k,d);break;case 6:g.setPosition(c,a);break;case 7:g.setPosition(e,a);break;case 8:g.setPosition(k,a);break;default:g.setPosition(0,0);break}g.body.setStyle({backgroundImage:"url("+Ext.urlAppend(PhotoStation.Util.getWebAPIUrl("thumb.php"),Ext.urlEncode({api:"SYNO.PhotoStation.Thumb",method:"get_dsm_thumb",version:1,id:this.watermark.id}))+")",backgroundSize:""+b+"px "+m+"px"})},getFieldSet:function(c,d,b,a){return Ext.apply({layout:"border",border:false,height:60,defaults:{border:false},style:{marginBottom:"20px"},items:[Ext.apply({region:"north",height:28,margins:"0, 0, 4, 0"},d),Ext.apply({region:"west",width:250,height:28,margins:"0, 8, 0, 0"},b),Ext.apply({region:"center",height:28},a)]},c)},getLabel:function(a){return{html:a,cls:"syno-photostation-watermark-lable"}},showWatermarkSelector:function(){if(!this.selector){this.selector=new PhotoStation.WatermarkSelector({});this.selector.on("select",this.onSelectWatermark,this)}this.selector.show()},onSelectWatermark:function(a){Ext.apply(this.watermark,a);this.getComponent("window-body").getComponent("control-panel").getComponent("watermark-field").getComponent("watermark-text").setValue(a.title);this.getFooterToolbar().getComponent("button-ok").setDisabled(false);SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Watermark","copy",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:a.id},function(f,e,d,b){this.watermark.id=e.id;this.watermark.path=e.path;if(this.watermark.hash!==e.hash){var g=this.getComponent("window-body").getComponent("control-panel").getComponent("gravity-selector");g.getComponent(this.watermark.gravity).getComponent(0).body.removeClass(this.CLASS_GRAVITY_SELECTED).addClass(this.CLASS_GRAVITY_CLEAR);this.watermark.gravity=0;this.gravity=g.getComponent(this.watermark.gravity);this.gravity.getComponent(0).body.removeClass(this.CLASS_GRAVITY_CLEAR).addClass(this.CLASS_GRAVITY_SELECTED);var c=this.getComponent("window-body").getComponent("control-panel");c.getComponent("transparency-field").getComponent("slider-transparency").setValue(0);c.getComponent("size-field").getComponent("slider-size").setValue(50)}this.watermark.hash=e.hash;this.updateWatermark()},this)},getGravitySelector:function(b){var a=function(e){e.mon(e.getEl(),"click",this.onSelectGravity,e)};var d=[];for(var c=0;c<9;++c){d.push({parent:this,value:c,border:false,cls:"syno-photostation-watermark-gravity",layout:"fit",listeners:{scope:this,afterrender:a},items:[{border:false,bodyCssClass:this.CLASS_GRAVITY_CLEAR}]})}return Ext.apply({width:84,height:84,border:false,items:d},b)},onSelectGravity:function(){this.parent.gravity.getComponent(0).body.removeClass(this.parent.CLASS_GRAVITY_SELECTED).addClass(this.parent.CLASS_GRAVITY_CLEAR);this.parent.gravity=this;this.getComponent(0).body.removeClass(this.parent.CLASS_GRAVITY_CLEAR).addClass(this.parent.CLASS_GRAVITY_SELECTED);this.parent.watermark.gravity=this.value;this.parent.updateWatermark()}});Ext.namespace("SYNO.API");SYNO.API.Erros={minCustomeError:400,common:{0:"Connection Failed",100:"Unknown Error",101:"Bad Request",102:"No Such API",103:"No Such Method",104:"Not Supported Version",105:"Not Enough Privilege",106:"Timeout",107:"Interrupt"}};SYNO.API.CheckSpecialError=function(a,c,b){return};SYNO.API.CheckResponse=function(a,g,d){var b,f;if(a){return true}if(0===g.status){return false}try{b=Ext.isDefined(g.status)?0:(g.code||100);if(b
','
','
{shortName}
');c.compile();var b=function(d){d.shortName=Ext.util.Format.htmlEncode(Ext.util.Format.ellipsis(d.info.name,15));var e=PhotoStation.Upload.getThumbWidthHeight(d.additional.thumb_size.small.resolutionx,d.additional.thumb_size.small.resolutiony,75,75);d.thumb_width=e.width;d.thumb_height=e.height;d.url=this.getThumbUrl("small",d);d.display_info=Ext.util.Format.htmlEncode(d.info.name);return d};this.dataView=new Ext.DataView({tpl:c,overClass:"x-view-over",itemSelector:"div.thumb-wrap",emptyText:'
'+_PST("photo","photo_str_no_photo")+"
",store:this.dataViewStore,cls:"imgChooserDataView",singleSelect:true,prepareData:b.createDelegate(this)});return{region:"center",autoScroll:true,border:false,cls:"about-me-file-chooser",style:{"border-left-width":"1px"},items:this.dataView}},onTreeBeforeSelect:function(c,a,b){if(this.rootId===a.id){return false}return true},onTreeSelectionChange:function(b,a){this.dataViewStore.removeAll();this.dataViewStore.load({params:{id:a.id}})},applyHandler:function(){var a=this.dataView.getSelectedRecords();if(a.length){this.fireEvent("choose",this,a)}this.close();if(typeof(tinyMCEPopup)!="undefined"){tinyMCEPopup.close()}},cancelHandler:function(){this.close();if(typeof(tinyMCEPopup)!="undefined"){tinyMCEPopup.close()}},getThumbUrl:function(a,b){if(0>b.thumbnail_status.indexOf(a)&&0<=b.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(b,{size:"preview"})}else{return PhotoStation.Util.getThumbUrl(b,{size:a})}},onChooseSelector:function(d,b){if(0===b.length){return tinyMCEPopup.close()}var a=this.getThumbUrl("large",b[0].json);var c=tinyMCEPopup.getWindowArg("window");c.document.getElementById(tinyMCEPopup.getWindowArg("input")).value=a;if(c.getImageData){c.getImageData()}}});Ext.ns("PhotoStation");PhotoStation.AboutMePanel=Ext.extend(Ext.Container,{constructor:function(b){Main.addScope("PhotoStation.AboutMePanel",this);var a=this.fillConfig(b);PhotoStation.AboutMePanel.superclass.constructor.call(this,a)},fillConfig:function(b){var a={cls:"about-me-panel",border:false,padding:10,items:[{xtype:"container",itemId:"aboutMeContent"}],listeners:{scope:this,activate:this.activateHandler,afterlayout:this.updateScrollbar}};return Ext.apply(a,b)},activateHandler:function(a){this.load();Main.getScope("PhotoStation.CenterPanel").getTopToolbar().updateButtons()},editHandler:function(){var a=new PhotoStation.AboutMeDialog({aboutHtml:this.htmlContent});a.show()},load:function(){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.About","get",1,{},this.getAboutCallback,this)},getAboutCallback:function(d,c,b,a){if(!c){return}this.hasContent=c.has_content;this.htmlContent=c.html;if(this.hasContent&&this.htmlContent!==""){this.getComponent("aboutMeContent").update(this.htmlContent)}else{this.setDefaultContent()}this.updateScrollbar()},updateScrollbar:function(g){var k=this;if(k.isVisible()){var m=k.el.dom;if(m&&m.fleXcroll){var d=m.childNodes;var c=[];for(var f=0,e=0;f';a=String.format('{1}',this.editTextId=Ext.id(),_PST("photo","photo_str_edit"));b=String.format('
{0}
',_PST("photo","photo_str_empty_text_about_me").replace("{0}",a));c+=b}else{c='
'}this.getComponent("aboutMeContent").update(c);if(PhotoStation.Auth.is_admin){Ext.get(this.emptyImgId).on("click",this.editHandler,this);Ext.get(this.editTextId).on("click",this.editHandler,this)}}});Ext.ns("PhotoStation");PhotoStation.AdvancedSearchWindow=Ext.extend(PhotoStation.BaseWindow,{constructor:function(a){Main.addScope("PhotoStation.AdvancedSearchWindow",this);this.addEvents("search");PhotoStation.AdvancedSearchWindow.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={title:_PST("photo","photo_str_search_advanced"),layout:"fit",width:732,height:460,buttons:[{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:this.clickCancel,scope:this}],items:this.smartPanel=new PhotoStation.SmartPanel({hideTypeBtns:true,ignoreEmptyCondition:true})};this.hideComboFunc=function(c){c.getStore().filterBy(function(d){return d.get("value").indexOf("recently")===-1})};this.smartPanel.dateOp.on("expand",this.hideComboFunc,this.smartPanel.dateOp,{single:true});return Ext.apply(a,b)},onShow:function(){this.setStatusBusy();this.smartPanel.on("loadtag",this.loadTagStoreCallback,this,{single:true});this.smartPanel.loadTagStores()},loadTagStoreCallback:function(a){if(!a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"))}this.fireEvent("loadTag");this.clearStatusBusy()},clickOK:function(){var a=this.smartPanel.getSmartValue();if(!a){this.setStatusError({text:this.smartPanel.getErrorMsg()});return}this.fireEvent("search",a);this.smartPanel.clearSmartValue();this.hide()},clickCancel:function(){this.fireEvent("search");this.smartPanel.clearSmartValue();this.hide()}});Ext.ns("PhotoStation");PhotoStation.BasicView=Ext.extend(PhotoStation.SelectAllDataView,{onNodeMouseEnter:function(b,c,d,g){var h=b.getStore().getAt(c),a=Ext.fly(d).child(".thumb-check"),f=Ext.fly(d).child(".photo-info");if(!h||!a){return}a.removeAllListeners();a.on("click",this.onNodeCheckIconClick.createDelegate(this,[c],true));if((PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("manage"))&&f){f.removeAllListeners();f.on("click",this.onPhotoInfoClick.createDelegate(this,[c,d.id],true))}},onNodeClick:function(b,c,d,f){if(this.triggeredByDrop){this.triggeredByDrop=false;return}var a=this.store.getAt(c);var g=Main.getScope("PhotoStation.ViewCard");if(!a){return}if(this.getSelectionCount()>0){this.onNodeCheckIconClick(f,null,null,c)}else{if(-1!==["album","smart","defaultsmart","tag","sharedalbum"].indexOf(a.get("type"))){this.clearAllSelections();this.lastSelect=null;g.containerLoad(a,false)}else{g.photoLoad(a)}}},onNodeCheckIconClick:function(c,b,d,a){c.stopPropagation();if(this.getSelectionCount()>0&&c.shiftKey===true){this.selectRange(a,this.lastSelect,true)}else{if(this.isSelected(a)){this.deselect(a)}else{this.select(a,true);this.lastSelect=a}}},onPhotoInfoClick:function(i,m,b,h,c){i.stopPropagation();var g=this.getStore().getAt(h),k=Ext.get(c).child(".photo-info"),d=Ext.get(c).child(".photo-info-title"),f=Ext.get(c).child(".label-textfield");if(k&&!f){var a=new PhotoStation.LabelTextField({itemId:"addCategoryField",allowBlank:false,listeners:{scope:this,confirm:this.modifyTitle.createDelegate(this,[h],true)}});if(d){d.remove()}a.render(k);a.setText(g.get("info").title);a.textfieldEl.dom.style.width=k.getWidth()-3+"px";a.clickLabel();a.textfieldEl.dom.select()}else{var j=f.child("input");if(k&&j){j.dom.style.width=k.getWidth()-3+"px"}}},modifyTitle:function(c,b,a){var d=this.getStore().getAt(a);if(!d){return}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Photo","edit",1,{id:d.get("id"),title:b},function(h,g,f,e){if(!h){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"));return}d.get("info").title=b;d.commit();Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus()})},initCtxMenu:function(){var a=Main.getScope("PhotoStation.CenterPanel");var b=new PhotoStation.ClipboardPlugin();var c=new PhotoStation.GotoRealAlbumPlugin();var d=new SYNO.ux.Menu({items:[{itemId:"download",text:_PST("photo","photo_str_btnDownload"),hidden:true,handler:a.clickDownload.createDelegate(a)},{itemId:"move",text:_PST("photo","photo_str_man_album_move"),hidden:true,handler:a.clickMove.createDelegate(a)},{itemId:"copy",text:_PST("photo","photo_str_copy"),hidden:true,handler:(a.clickCopy).createDelegate(a,[true],true)},{itemId:"delete",text:_PST("photo","photo_str_deleteuser"),hidden:true,handler:a.clickDelete.createDelegate(a)},{itemId:"editCover",text:_PST("photo","photo_str_set_album_cover"),hidden:true,scope:this,handler:this.editCoverHandler},{itemId:"editProperty",text:_PST("photo","photo_str_edit_album_properties"),hidden:true,scope:this,handler:this.editPropertyHandler},{itemId:"sep",xtype:"menuseparator",hidden:true},{itemId:"pinTo",text:_PST("photo","photo_str_pin_to"),hidden:false,hideOnClick:false,menu:{items:[]}},{itemId:"getSharingLink",text:_PST("photo","photo_str_get_sharing_link"),hidden:true,handler:a.clickShare.createDelegate(a)},{itemId:"publicShare",text:_PST("photo","photo_str_public_share"),hidden:!PhotoStation.Auth.allow_public_share,handler:a.clickPublicShare.createDelegate(a)},{itemId:"addToSharedAlbum",text:_PST("photo","photo_str_add_to_shared_album"),hideOnClick:false,menu:{items:[],listeners:{beforeshow:{scope:a,fn:function(e){a.updateSharedAlbumMenu(e);return true}}}}},{itemId:"unpin",text:_PST("photo","photo_str_unpin"),hidden:true,handler:a.clickUnpin.createDelegate(a)},{itemId:"share",text:_PST("photo","photo_str_share"),hidden:true,disabled:true},{itemId:"setCover",text:_PST("photo","photo_str_setcover"),hidden:true,handler:a.clickSetCover.createDelegate(a)},{itemId:"rotate90",text:_PST("photo","photo_str_rotate_90"),hidden:true,handler:a.clickRotate.createDelegate(a,[90])},{itemId:"rotate270",text:_PST("photo","photo_str_rotate_270"),hidden:true,handler:a.clickRotate.createDelegate(a,[270])},{itemId:"rotate180",text:_PST("photo","photo_str_rotate_180"),hidden:true,handler:a.clickRotate.createDelegate(a,[180])},{itemId:"editGeoTag",text:_PST("photo","photo_str_album_edit_gps_label"),hidden:true,handler:a.clickEditGeoTag.createDelegate(a)},{itemId:"editDescTag",text:_PST("photo","photo_str_album_edit_desc_label"),hidden:true,handler:a.clickEditDescTag.createDelegate(a)},{itemId:"copyToClipboard",text:_PST("photo","photo_str_clipboard_copy_thumbnail_url"),hidden:true,clipboardPlugin:b,plugins:[b]},{itemId:"gotoRealAlbum",text:_PST("photo","photo_str_goto_containing_album"),hidden:true,gotoRealAlbumPlugin:c,plugins:[c]}],listeners:{render:{single:true,fn:function(e){e.getComponent("copyToClipboard").clipboardPlugin.on("aftercopy",function(){PhotoStation.Notify.showNotifyText(_PST("photo","photo_str_clipboard_copy_done"))},this)}},show:function(i){var f=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedNodes(),e=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();if(1!==f.length){return}var h=Ext.fly(f[0]).child("div.thumb img");if(!h){return}var g=location.protocol+"//"+location.host+h.dom.getAttribute("src");i.getComponent("copyToClipboard").clipboardPlugin.setCopiedText(g);i.getComponent("gotoRealAlbum").gotoRealAlbumPlugin.setId(e[0].get("id"))},beforehide:{fn:function(e){this.lastMenuXY=e.getPosition();(function(){Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus()}).defer(100)},scope:this}}});this.contextMenu=d},isCtxMenuVisible:function(c){var a,b=this.getSelectedRecords();if(b.length===0){b=this.getRecord(this.getNode(c))}a=this.getCtxConfig(b);return a.menuVisible},getCtxConfig:function(c){var a=Main.getScope("PhotoStation.CenterPanel");var b=a.getTopToolbar().calcActionConfig(false,c);b.publicShare=a.getTopToolbar().isPublicShareVisible();b.getSharingLink=false;if(c.length===1&&c[0].get("id")!==PhotoStation.Define.DEFAULT_SHARE_SINGLE_ITEM&&c[0].get("share_status")==="valid"){b.getSharingLink=true}b.share=false;b.menuVisible=(b.download||b.move||b.copy||b.Delete||b.pinto||b.unpin||b.share||b.setCover||b.rotate||b.editTag||b.publicShare);return b},updateCtxMenu:function(){var b=Main.getScope("PhotoStation.CenterPanel");var d=this.getSelectedRecords();var c=this.getCtxConfig(d);var a=(c.download||c.move||c.copy||c.Delete||c.editCover||c.editProperty)&&(c.pinto||c.unpin||c.share||c.setCover||c.rotate||c.editTag||c.publicShare||c.copyToClipboard||c.gotoRealAlbum);if(PhotoStation.CurrentBrowse.isSharedAlbum()){this.contextMenu.getComponent("delete").setText(_PST("photo","photo_str_remove_from_shared_album"))}else{this.contextMenu.getComponent("delete").setText(_PST("photo","photo_str_delete"))}this.contextMenu.getComponent("download").setVisible(c.download);this.contextMenu.getComponent("delete").setVisible(c.Delete);this.contextMenu.getComponent("copy").setVisible(c.copy);this.contextMenu.getComponent("move").setVisible(c.move);this.contextMenu.getComponent("editCover").setVisible(c.editCover);if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()){this.contextMenu.getComponent("editProperty").setText(_PST("photo","photo_str_edit_shared_album_properties"))}else{this.contextMenu.getComponent("editProperty").setText(_PST("photo","photo_str_edit_album_properties"))}this.contextMenu.getComponent("editProperty").setVisible(c.editProperty);this.contextMenu.getComponent("sep").setVisible(a);this.contextMenu.getComponent("pinTo").setVisible(c.pinto);this.contextMenu.getComponent("unpin").setVisible(c.unpin);this.contextMenu.getComponent("share").setVisible(c.share);this.contextMenu.getComponent("setCover").setVisible(c.setCover);this.contextMenu.getComponent("rotate90").setVisible(c.rotate);this.contextMenu.getComponent("rotate180").setVisible(c.rotate);this.contextMenu.getComponent("rotate270").setVisible(c.rotate);this.contextMenu.getComponent("editGeoTag").setVisible(c.editGeoTag&&PhotoStation.Util.checkGoogleMap());this.contextMenu.getComponent("editDescTag").setVisible(c.editTag);this.contextMenu.getComponent("copyToClipboard").setVisible(c.copyToClipboard);this.contextMenu.getComponent("gotoRealAlbum").setVisible(c.gotoRealAlbum);this.contextMenu.getComponent("getSharingLink").setVisible(c.getSharingLink);this.contextMenu.getComponent("publicShare").setVisible(c.publicShare);this.contextMenu.getComponent("addToSharedAlbum").setVisible(c.publicShare);if(!PhotoStation.Auth.is_admin){return}var e=this.contextMenu.getComponent("pinTo").menu;e.removeAll(true);Main.getScope("PhotoStation.CategoryList").store.each(function(f){if(!PhotoStation.CurrentBrowse.isCategory()||PhotoStation.CurrentBrowse.getId()!==f.get("id")){e.addItem({text:Ext.util.Format.ellipsis(f.get("name"),20),handler:b.clickPinTo.createDelegate(b,[f.get("id")])})}});if(!e.items.items.length){e.addItem({text:_PST("photo","photo_str_no_category")})}},showCtxMenu:function(b,a,c){if(!this.isSelected(b)){this.select(b,false)}this.updateCtxMenu();this.contextMenu.showAt([a,c])},updateSelection:function(b){if(this.isSelected(b)){var a=this.store.indexOf(b);this.all.item(a).addClass(this.selectedClass)}},onSelectionChange:function(b,d){var c=(Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords().length>0);var a=Main.getScope("PhotoStation.CenterPanel").getTopToolbar();a.updateShareBtn(c);a.updateAddBtn(c);a.updatePinHereBtn(c);a.updateMoreBtn(c);a.updateSlideshowBtn(c);a.updateActionBtn();a.updateDownloadBtn();this.showSelectionWindow(c)},showSelectionWindow:function(b){var c=Main.getScope("PhotoStation.SelectAllWindow");if(!c){c=new PhotoStation.SelectAllWindow()}var a=false;if(b){c.updateText();a=true}else{if(c.isShowConversionPrompt()){c.updateConversionPrompt();a=true}}c.setVisible(a)},editPropertyHandler:function(){var b=Main.getScope("PhotoStation.SettingWindow");if(!b){b=new PhotoStation.SettingWindow()}var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();b.show(a[0])},editCoverHandler:function(){var b=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords(),a=b[0].data.id;this.imageChooser=new PhotoStation.FileSelectorWindow({resizable:true,boxMinWidth:800,boxMinHeight:500,mode:"photo_station",initMode:"photo_station",fileType:"photo,video",record:b[0],choose:this.editCoverCallback.createDelegate(this,[a],true),cancel:this.editCoverCallback.createDelegate(this,[a],true)});this.imageChooser.show()},editCoverCallback:function(a,d,b){this.imageChooser.close();var c;if(!a){return}c={id:b,item_id:a.id};SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Cover","set",1,c,function(h,g,f,e){if(h){Main.getScope("PhotoStation.ViewCard").containerReLoad()}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"))}},this)}});Ext.ns("PhotoStation");PhotoStation.CenterPanel=Ext.extend(Ext.Panel,{constructor:function(a){Main.addScope("PhotoStation.CenterPanel",this);this.addEvents("rotate");PhotoStation.CenterPanel.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={cls:"center-panel",border:false,buttonAlign:"left",boxMinWidth:100,tbar:this.getTbar(),fbar:this.getFbar(),region:"center",layout:"border",margins:{left:15},items:[new PhotoStation.StatusArea({region:"north"}),new PhotoStation.ViewCard({region:"center"})],listeners:{single:true,scope:this,afterrender:function(){this.expandLeftPanelBtn=new Ext.Button({renderTo:Main.id,itemId:"expandLeftPanelBtn",cls:"left-panel-switch-btn photo-icon-btn",hidden:true,tooltip:_PST("photo","photo_str_left_panel_expand"),handler:this.clickExpandLeftPanel,scope:this});this.updateRSSBtn()}}};Ext.apply(a,b);return a},getTbar:function(){var a=new PhotoStation.ClipboardPlugin();var b=new PhotoStation.GotoRealAlbumPlugin();var c=new Ext.Toolbar({cls:"action-bar",height:28,items:[{itemId:"leftContentBtn",cls:"left-content-btn photo-icon-btn",hidden:true,xtype:"button",menu:{id:this.contentMenuId=Ext.id(),zIndex:10009,width:230,items:[{xtype:"panel",parentId:this.contentMenuId,border:false,cls:"left-content-menu",itemId:"content"}],listeners:{beforeshow:function(){Main.getScope("PhotoStation.LeftContent").resizeList()},show:function(){Main.getScope("PhotoStation.LeftContent").updateScrollbar()}}}},{itemId:"tbLeftContentSep",xtype:"tbseparator",hidden:true},{itemId:"editAboutMeBtn",text:_PST("photo","photo_str_edit"),hidden:true,handler:this.clickEditAboutMe,scope:this},{itemId:"addBtn",text:_PST("photo","photo_str_add"),hidden:true,scope:this,menu:{items:[{itemId:"createEmptyAlbum",text:_PST("photo","photo_str_man_album_add"),handler:this.clickCreateAlbum,scope:this},{itemId:"uploadBtn",text:_PST("photo","photo_str_btnUpload"),handler:this.clickUpload,scope:this},{itemId:"createSmartBtn",text:_PST("photo","photo_str_smart_album_title_create"),hidden:true,handler:this.clickCreateSmart.createDelegate(this,[]),scope:this},{itemId:"enableDefaultSmartAlbum",text:_PST("photo","photo_str_enable_default_smart_album"),handler:this.clickSetting,scope:this}]}},{itemId:"saveAsSmartBtn",text:_PST("photo","photo_str_smart_album_title_save_as"),hidden:true,handler:this.clickSaveAsSmart,scope:this},{itemId:"shareBtn",text:_PST("photo","photo_str_share"),hidden:true,hideOnClick:false,menu:{items:[{itemId:"link",text:_PST("photo","photo_str_share_link_menu"),handler:this.clickShare,scope:this},{itemId:"publicShare",text:_PST("photo","photo_str_public_share"),hidden:!PhotoStation.Auth.allow_public_share,handler:this.clickPublicShare,scope:this},{itemId:"addToSharedAlbum",text:_PST("photo","photo_str_add_to_shared_album"),hideOnClick:false,hidden:!PhotoStation.Auth.allow_public_share,menu:{items:[],listeners:{beforeshow:{scope:this,fn:function(d){this.updateSharedAlbumMenu(d)}}}}},{itemId:"facebook",text:_PST("photo","photo_str_upload_to_fb"),handler:(this.clickUploadSocialNetwork).createDelegate(this,["facebook"]),hidden:true,scope:this},{itemId:"picasa",text:_PST("photo","photo_str_upload_to_picasa"),handler:(this.clickUploadSocialNetwork).createDelegate(this,["picasa"]),hidden:true,scope:this},{itemId:"youtube",text:_PST("photo","photo_str_upload_to_youtube"),handler:(this.clickUploadSocialNetwork).createDelegate(this,["youtube"]),hidden:true,scope:this},{itemId:"flickr",text:_PST("photo","photo_str_upload_to_flickr"),handler:(this.clickUploadSocialNetwork).createDelegate(this,["flickr"]),hidden:true,scope:this}]}},{itemId:"slideshowBtn",text:_PST("photo","photo_str_slideshow"),hidden:true,handler:this.clickSlideshow,scope:this},{itemId:"downloadBtn",text:_PST("photo","photo_str_btnDownload"),hidden:true,handler:this.clickDownload,scope:this},{itemId:"actionBtn",text:_PST("photo","photo_str_action"),hidden:true,handler:this.clickAction,scope:this,menu:{items:[{itemId:"move",text:_PST("photo","photo_str_man_album_move"),handler:this.clickMove,scope:this},{itemId:"copy",text:_PST("photo","photo_str_copy"),handler:(this.clickCopy).createDelegate(this,[true],true),scope:this},{itemId:"delete",text:_PST("photo","photo_str_deleteuser"),handler:this.clickDelete,scope:this},{itemId:"actionSep",xtype:"menuseparator"},{itemId:"pinTo",text:_PST("photo","photo_str_pin_to"),hideOnClick:false,menu:{items:[]}},{itemId:"unpin",text:_PST("photo","photo_str_unpin"),handler:this.clickUnpin,scope:this},{itemId:"rotate90",text:_PST("photo","photo_str_rotate_90"),handler:this.clickRotate.createDelegate(this,[90])},{itemId:"rotate270",text:_PST("photo","photo_str_rotate_270"),handler:this.clickRotate.createDelegate(this,[270])},{itemId:"rotate180",text:_PST("photo","photo_str_rotate_180"),handler:this.clickRotate.createDelegate(this,[180])},{itemId:"editGeoTag",text:_PST("photo","photo_str_album_edit_gps_label"),handler:this.clickEditGeoTag,hidden:true,scope:this},{itemId:"editDescTag",text:_PST("photo","photo_str_album_edit_desc_label"),handler:this.clickEditDescTag,hidden:true,scope:this},{itemId:"copyToClipboard",text:_PST("photo","photo_str_clipboard_copy_thumbnail_url"),hidden:true,scope:this,clipboardPlugin:a,plugins:[a]},{itemId:"gotoRealAlbum",text:_PST("photo","photo_str_goto_containing_album"),hidden:true,gotoRealAlbumPlugin:b,plugins:[b]}],listeners:{render:{single:true,fn:function(d){d.getComponent("copyToClipboard").clipboardPlugin.on("aftercopy",function(){PhotoStation.Notify.showNotifyText(_PST("photo","photo_str_clipboard_copy_done"))},this)}},show:function(h){var e=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedNodes(),d=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();if(1!==e.length){return}var g=Ext.fly(e[0]).child("div.thumb img");if(!g){return}var f=location.protocol+"//"+location.host+g.dom.getAttribute("src");h.getComponent("copyToClipboard").clipboardPlugin.setCopiedText(f);h.getComponent("gotoRealAlbum").gotoRealAlbumPlugin.setId(d[0].get("id"))},beforehide:{fn:function(d){this.lastMenuXY=d.getPosition();(function(){Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.focus()}).defer(100)},scope:this}}}},{itemId:"pinHereBtn",text:_PST("photo","photo_str_pin_here"),hidden:true,handler:this.clickPinHere,scope:this},{itemId:"moreBtn",text:_PST("photo","photo_str_more"),hidden:true,scope:this,menu:{items:[{itemId:"editProperty",text:_PST("photo","photo_str_edit_album_properties"),handler:this.clickSetting,scope:this},{itemId:"resetManualSort",text:_PST("photo","photo_str_reset_sort_to_default"),handler:this.clickResetManualSort,scope:this},{itemId:"embedAlbum",text:_PST("photo","embed_embed_album_not_capitalized"),scope:this,handler:function(){var d=new PhotoStation.EmbedWindow({album:PhotoStation.CurrentBrowse.getRecord()});d.show()}}]}},"->",{itemId:"logIn",cls:"login-btn",text:_PST("photo","photo_login"),hidden:!!gIsDemoMode,handler:this.onLogIn.createDelegate(this,[false])},{itemId:"account",cls:"account-btn",text:"",hidden:true,menu:{items:[{text:_PST("photo","photo_str_help"),handler:this.clickHelp},{text:_PST("photo","photo_logout"),handler:this.onLogOut,scope:this}]}}],updateButtons:function(){if(Main.getScope("PhotoStation.ViewCard").getLayout().activeItem===Main.getScope("PhotoStation.AboutMePanel")){this.updateEditAboutMeBtn();return}this.getComponent("editAboutMeBtn").setVisible(false);this.updateAddBtn();this.updateSaveAsSmartBtn();this.updateShareBtn();this.updateActionBtn(true);this.updatePinHereBtn();this.updateDownloadBtn();this.updateMoreBtn();this.updateSlideshowBtn();Main.getScope("PhotoStation.StatusTopArea").updateViewModeBtn()},updateEditAboutMeBtn:function(){this.getComponent("editAboutMeBtn").setVisible(PhotoStation.Auth.is_admin);this.getComponent("addBtn").setVisible(false);this.getComponent("saveAsSmartBtn").setVisible(false);this.getComponent("shareBtn").setVisible(false);this.getComponent("downloadBtn").setVisible(false);this.getComponent("actionBtn").setVisible(false);this.getComponent("pinHereBtn").setVisible(false);this.getComponent("slideshowBtn").setVisible(false);this.getComponent("moreBtn").setVisible(PhotoStation.Auth.is_admin);this.getComponent("moreBtn").menu.getComponent("editProperty").setVisible(true);this.getComponent("moreBtn").menu.getComponent("editProperty").setText(_PST("photo","photo_str_change_visibilily"));this.getComponent("moreBtn").menu.getComponent("resetManualSort").setVisible(false)},updateAddBtn:function(e){var g=this.getComponent("addBtn").menu,h=PhotoStation.Util.hasSmartCategoryPriv(),d=PhotoStation.Util.hasAlbumPriv("upload"),f=e?false:(h||d);this.getComponent("addBtn").setVisible(f);g.getComponent("createSmartBtn").setVisible(h);g.getComponent("enableDefaultSmartAlbum").setVisible(h);g.getComponent("createEmptyAlbum").setVisible(d);g.getComponent("uploadBtn").setVisible(d)},updateCreateBtn:function(d){var e=d?false:PhotoStation.Util.hasSmartCategoryPriv();this.getComponent("createSmartBtn").setVisible(e)},updateSaveAsSmartBtn:function(){this.getComponent("saveAsSmartBtn").setVisible(PhotoStation.Auth.is_admin&&PhotoStation.CurrentBrowse.isSearchCategory())},updateShareBtn:function(e){var f=this.getComponent("shareBtn"),j=[];if(!PhotoStation.Util.isSpecialView()){j=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords()}var n=0===PhotoStation.HistoryManager.getToken().indexOf("Search/")||PhotoStation.CurrentBrowse.isSearchCategory();var p=PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG===PhotoStation.CurrentBrowse.getId();var m=PhotoStation.CurrentBrowse.isSharedAlbumCategory();var h=j.length===1&&PhotoStation.Util.isRecSharedAlbum(j[0])&&j[0].get("id")!==PhotoStation.Define.DEFAULT_SHARE_SINGLE_ITEM&&j[0].get("share_status")==="valid";var k=PhotoStation.CurrentBrowse.isSingleItemSharedAlbum();var d=!n&&!p&&(PhotoStation.Auth.is_admin||PhotoStation.Info.allow_social_share)&&!e&&!m;d=d||(m&&h);var o=this.isPublicShareVisible();if(PhotoStation.CurrentBrowse.isSharedAlbum()){var g=PhotoStation.CurrentBrowse.getRecord().get("share_status");d=g&&"valid"===g&&j.length===0&&!k}f.menu.getComponent("link").setVisible(d);if(PhotoStation.CurrentBrowse.isSharedAlbum()||PhotoStation.CurrentBrowse.isSharedAlbumCategory()){f.menu.getComponent("link").setText(_PST("photo","photo_str_get_sharing_link"))}else{f.menu.getComponent("link").setText(_PST("photo","photo_str_share_link_menu"))}f.menu.getComponent("publicShare").setVisible(o);f.menu.getComponent("addToSharedAlbum").setVisible(o);f.menu.getComponent("facebook").setVisible(false);f.menu.getComponent("picasa").setVisible(false);f.menu.getComponent("youtube").setVisible(false);f.menu.getComponent("flickr").setVisible(false);var i=this.isSocialNetworkVisible();f.setVisible(i||d||o);if(!i){return}if(j.length==1&&j[0].get("type")==="video"){f.menu.getComponent("youtube").setVisible(PhotoStation.Info.social_network_list[6].enable)}else{f.menu.getComponent("facebook").setVisible(PhotoStation.Info.social_network_list[0].enable);f.menu.getComponent("picasa").setVisible(PhotoStation.Info.social_network_list[3].enable);f.menu.getComponent("flickr").setVisible(PhotoStation.Info.social_network_list[7].enable)}},isPublicShareVisible:function(){if(!PhotoStation.Auth.username||!PhotoStation.Auth.allow_public_share){return false}if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()||PhotoStation.CurrentBrowse.isSharedAlbum()){return false}var e=Main.getScope("PhotoStation.SimplePathBar").pathItemList;var d;for(d=1;d<3&&d1)}},doLoad:function(d){var c=Ext.apply({},PhotoStation.Util.getContainerLoadParams()),b=this.getParams();c[b.start]=d;c[b.limit]=this.pageSize;if(this.fireEvent("beforechange",this,c)!==false){this.store.load({params:c})}},onClickDisplayAll:function(){Main.getScope("PhotoStation.ViewCard").containerReLoad(true)}});var a;a=new Ext.Container({flex:14,items:this.pagingBar});return this.pagingBar},onClickDisplayPage:function(){Main.getScope("PhotoStation.ViewCard").containerReLoad()},getFbar:function(){var a=new Ext.Toolbar({height:38,layout:"hbox",style:{padding:"4px 4px 0"},listeners:{scope:this,afterlayout:function(){this.adjustDisplayPageLeft()}},items:[{flex:3,style:"padding-top: 18px;",itemId:"count",xtype:"label"},this.getPagingToolbar().ownerCt,{flex:1,itemId:"display_page",cls:"syno-btn-display-page",xtype:"button",style:"visibility: hidden;",text:_PST("photo","photo_str_display_page"),handler:this.onClickDisplayPage,scope:this},{flex:3,xtype:"label",style:"float: right; text-align: right; padding-top: 18px;",text:_PST("photo","photo_str_ap_name_6")},{itemId:"rssBtn",xtype:"button",cls:"rss-btn",handler:this.clickRSS}],updateContainerItemCount:function(){var d=this.getComponent("count");if(PhotoStation.CurrentBrowse.isAboutMe()||PhotoStation.Util.isSpecialView()){d.setText("");return}var c=Main.getScope("PhotoStation.ViewCard").store,f=c.getTotalCount(),e=[PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG,PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG,PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG,PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG];if(PhotoStation.CurrentBrowse.isSmartCategory()||PhotoStation.CurrentBrowse.isDefaultSmart()){c.each(function(g){if(PhotoStation.Util.inArray(g.get("id"),e)){f++}else{return false}})}if(PhotoStation.CurrentBrowse.isAlbum()||PhotoStation.CurrentBrowse.isAlbumCategory()){var b="album_sorting";if(PhotoStation.CurrentBrowse.isAlbum()){b+=",item_count"}if(null!==this.albumInfoAjax){Ext.Ajax.abort(this.albumInfoAjax)}this.albumInfoAjax=SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","getinfo",1,{id:PhotoStation.Util.getContainerLoadParams().id,additional:b},function(m,k,j,h){if(!m||!k||!Ext.isArray(k.items)||1!==k.items.length||!k.items[0].info){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var i=k.items[0],n=this.ownerCt.getTopToolbar();if(i.additional.album_sorting){n.updateMoreBtn(false,i.additional.album_sorting.has_preference_sort)}if(i.additional.item_count){n.setAlbumItemCount(parseInt(i.additional.item_count.photo,10)+parseInt(i.additional.item_count.video,10))}if(PhotoStation.Info.show_album_hit&&i.additional.item_count){d.setText(String.format("{0} {1}, {2} {3}",f,_PST("photo","photo_str_items"),i.info.hits,_PST("photo","photo_str_hits")))}else{d.setText(String.format("{0} {1}",f,_PST("photo","photo_str_items")))}PhotoStation.CurrentBrowse.setConversion(i.info.conversion);var g=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;if(Ext.isFunction(g.showSelectionWindow)){g.showSelectionWindow(g.getSelectedRecords().length>0)}this.albumInfoAjax=null},this)}else{d.setText(String.format("{0} {1}",f,_PST("photo","photo_str_items")))}}});return a},clickHelp:function(){window.open("help.php")},onLogIn:function(a){var b=Main.getScope("PhotoStation.LoginWindow");if(!b){b=new PhotoStation.LoginWindow()}b.redirectOnCancel=!!a;b.show()},onLogOut:function(){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Auth","logout",1,{},function(d,c,b,a){window.location=""},this)},toggleLogIn:function(b,d){var c=this.getTopToolbar();var a=c.getComponent("account");if(gIsDemoMode){c.getComponent("logIn").setVisible(false)}else{c.getComponent("logIn").setVisible(!b)}a.setVisible(!!b);a.setText(b?Ext.util.Format.htmlEncode(d):"")},clickEditAboutMe:function(){var b,a;b=Main.getScope("PhotoStation.AboutMePanel").getHtml();a=new PhotoStation.AboutMeDialog({aboutHtml:b});a.show()},clickShare:function(){var d={from:"album"};if(PhotoStation.CurrentBrowse.isSharedAlbum()||PhotoStation.CurrentBrowse.isSharedAlbumCategory()){var a;if(PhotoStation.CurrentBrowse.isSharedAlbum()){a=PhotoStation.CurrentBrowse.getRecord().get("additional").public_share.shareid}else{var c=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();a=c[0].get("additional").public_share.shareid}d={from:"shared_album",shareid:a,title:String.format(_PST("photo","photo_str_link_to"),PhotoStation.CurrentBrowse.getRecord().get("name"))}}var b=new PhotoStation.ShareWindow(d);b.show()},clickUploadSocialNetwork:function(a){var n=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();if(a==="youtube"){var e=n[0];var c=e.get("id");var m=e.data.info.title;var j=e.json.thumbnail_status;var b=PhotoStation.Util.getImgUrl("White/"+(e.json.type==="video"?"image_default_video_dark.png":"image_default_photo_dark.png"),true);if(0<=j.indexOf("small")||0<=j.indexOf("preview")){b=this.getThumbUrl("small",e.json)}var o=e.data.info.description;var k=new PhotoStation.SocialNetworkSingleUploader({renderTo:Ext.getBody(),website:a,imgurl:b,title:m,id:c,description:o});k.show();return}var p=[];for(var g=0;gb.thumbnail_status.indexOf(a)&&0<=b.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(b,{size:"preview"})}else{return PhotoStation.Util.getThumbUrl(b,{size:a})}},clickSlideshow:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.store;var b=PhotoStation.Util.getContainerLoadParams();Ext.apply(b,a.baseParams);b.id=PhotoStation.CurrentBrowse.getId();b.type="photo,video";b.limit="1";delete b.additional;PhotoStation.Util.launchFullScreen(document.documentElement);Ext.Ajax.request({url:a.proxy.url,method:"post",params:b,success:function(f,g){var c={};try{c=Ext.decode(f.responseText)}catch(h){}if(!c.success){Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),c.msg||_PST("photo","photo_theme_server_error"));return}if(0===c.data.items.length){return}var d=c.data.items[0].id;Main.getScope("PhotoStation.ViewCard").openSingleLightBox(d,"slideshow")},failure:function(c,d){Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),_PST("photo","photo_theme_server_error"))},scope:this})},clickDownload:function(){var c=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();var a=[];for(var b=0;b0)?a.cursor:Math.max(0,a.cursor-a.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(g,e)}Main.unmask()},clickDelete:function(){var d=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();if(0===d.length){return}var c={photo:0,album:0,video:0},e=["","","","",""];for(var b=0;b0){e[0]=c.album;e[1]=" "+_PST("photo","photo_str_albums")}if(c.files>0){e[3]=c.files;e[4]=" "+_PST("photo","photo_str_files")}if(c.files>0&&c.album>0){e[2]=" "+_PST("photo","photo_str_conjunction_and")+" "}var a=_PST("photo","photo_str_man_delete_confirm").replace("{@}",d.length);if(""!==e[0]||""!==e[3]){a=String.format(_PST("photo","photo_str_man_delete_detail_confirm"),e[0],e[1],e[2],e[3],e[4])}if(PhotoStation.CurrentBrowse.isSharedAlbum()){a=String.format(_PST("photo","photo_str_remove_confirm"),d.length)}Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),a,function(f){if(f==="yes"){if(PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isAlbum()||PhotoStation.CurrentBrowse.isSearchCategory()){this.deleteAlbumAndFile()}else{if(PhotoStation.CurrentBrowse.isSmartCategory()){this.deleteSmart()}else{if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()){this.deleteSharedAlbum()}else{if(PhotoStation.CurrentBrowse.isSharedAlbum()){this.deleteSharedAlbumItems()}}}}}},this)},clickEditDescTag:function(){var a=new PhotoStation.EditTagDialog({owner:this,ids:this.getSelectedPhotoId()});a.show()},clickEditGeoTag:function(){var a=this.getSelectedRecords();if(!this.geoTagDialog){this.geoTagDialog=new PhotoStation.GeoTagDialog({owner:this,multiSel:(a.length>1),currentRec:a})}this.geoTagDialog.setCurrentRecords(a);this.initFullStore("geo");this.tagType="geo"},initFullStore:function(a){this.fullStore=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("tag.php"),method:"POST"}),autoLoad:true,baseParams:{api:"SYNO.PhotoStation.Tag",version:1,method:"list",additional:"info",offset:0,limit:-1,type:a},reader:new Ext.data.JsonReader({root:"data.tags"},[{name:"id"},{name:"type",mapping:"tag_type"},{name:"name"},{name:"info",mapping:"additional.info"}]),fields:["id","type","name","info"],sortInfo:{field:"name",direction:"ASC"},listeners:{scope:this,add:function(d,c,b){d.singleSort("name","ASC")},load:function(c,b,d){if(a=="geo"){this.getSelectedGeoTags(true)}}}})},getSelectedRecords:function(){return Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords()},getSelectedPhotoId:function(){var c=this.getSelectedRecords();var a=[];for(var b=0;b0){var j=f.tags[0];c.push(f.tags[0].id);var e=j.additional;delete j.additional;var n=j;n.info=e.info;this.geoTagDialog.oriTagRec=new Ext.data.Record(n,n.item_tag_id)}else{if(k.length>1){for(var h=0;h0){c.push(d[h].tags[0].id)}}}}if(a){this.geoTagDialog.show();this.geoTagDialog.selTagArr=c}},this)},findTagFromFullStore:function(c,d){var a=-1;var b=(d)?d.name:c;if("geo"!==this.tagType){a=this.fullStore.findExact("name",b)}else{this.fullStore.each(function(f,e){if(b===f.get("name")&&d.place_id===f.get("info").place_id){a=e;return false}},this)}return a},deletePhotoTag:function(b,a){SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.PhotoTag","delete",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:this.getSelectedPhotoId(),tag_id:b},function(f,e,d,c){if(!f){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"));return}if(a){a()}},this)},addPhotoTag:function(c,d,e,b){if(Ext.isEmpty(c)){return}if(!d||-1===d){var a=this.findTagFromFullStore(c,e);if(-1==a){this.createTag(c,e,b);return}d=this.fullStore.getAt(a).get("id")}var f={id:this.getSelectedPhotoId(),tag_id:d};if(e){Ext.apply(f,e)}SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.PhotoTag",this.tagType+"_tag",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},f,function(j,i,h,g){if(!j){if(468==i.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_label_duplicate"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}if(b){b(false)}return}if(b){b(true)}},this)},createTag:function(b,c,a){var d={name:b,type:this.tagType};if(c){Ext.apply(d,c)}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Tag","create",1,d,function(j,i,h,g){var f,e;if(!j||!i||Ext.isEmpty(i.id)){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"));return}f={id:i.id,name:b,type:this.tagType,info:c};e=new this.fullStore.recordType(f,i.id);this.fullStore.add(e);this.addPhotoTag(b,i.id,c,a)},this)},deleteAlbumAndFile:function(){var e=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords();var b=[];var g=[];for(var c=0;c0)?d.cursor:Math.max(0,d.cursor-d.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(false,f)}if(Main.getScope("PhotoStation.PhotowallView")===m){m.resizeImages()}if(!k){this.fbar.updateContainerItemCount()}PhotoStation.Util.closeWaitMsg()},this)},doDeleteFile:function(b,a){if(!b.length){return}this.doingDeleteFile=true;PhotoStation.Util.showWaitMsg({scope:this,fn:this.cancelAjax});this.fileList=b.join(",");this.ajaxIdPhoto=SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Photo","delete",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:b.join(",")},function(o,g,h,c){this.doingDeleteFile=false;if(!o){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),PhotoStation.Util.getErrMsg(g));return}var e=Main.getScope("PhotoStation.ViewCard"),n=e.store,m=e.getLayout().activeItem,d=this.getPagingToolbar(),k=PhotoStation.Info.paging_use_bar&&!d.inDisplayAll;if(!k){for(var j=0;j0)?d.cursor:Math.max(0,d.cursor-d.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(false,f)}if(Main.getScope("PhotoStation.PhotowallView")===m){m.resizeImages()}if(!k){this.fbar.updateContainerItemCount()}PhotoStation.Util.closeWaitMsg()},this)},deleteSmart:function(){var c=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem.getSelectedRecords(),b=[];for(var a=0;a0)?c.cursor:Math.max(0,c.cursor-c.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(false,e)}else{for(var h=0;h0)?c.cursor:Math.max(0,c.cursor-c.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(false,e)}else{for(var h=0;h0)?c.cursor:Math.max(0,c.cursor-c.pageSize);Main.getScope("PhotoStation.ViewCard").containerReLoad(false,e)}else{for(var h=0;h'+_PST("photo","photo_str_no_photo")+"",store:this.getStore(),cls:"imgChooserDataView image-picker",listeners:{resize:function(){this.updateScrollbar()}},prepareData:this.formatData.createDelegate(this)};this.store=this.getStore();this.store.on("beforeload",function(){this.el.mask(_PST("photo","photo_str_loading")).addClass("center-transparent-mask")},this);this.store.on("load",function(){this.el.unmask()},this);this.loader=new PhotoStation.ImageLoadManager();this.loader.delegate=this;this.imageStyleUpdater=new PhotoStation.ImageStyleUpdater();this.imageStyleUpdater.delegate=this;this.delayedCheckLoadMore=new Ext.util.DelayedTask(this.checkLoadMore,this);Ext.apply(a,b);PhotoStation.ImageLoaderDataView.superclass.constructor.call(this,a)},getTemplateTarget:function(){var a=this;a.scrollBar=a.scrollBar||a.el.createChild({tag:"div",style:"display:inline-block;width:100%;"});return a.scrollBar},getImageItems:function(a,b){Ext.each(a,function(f,d,e){var c=Ext.fly(f).select("img").elements;if(0a.scrollPosition[1][1]-a.scrollPosition[1][0]){this.loadMore()}},onItemClick:function(b,a,c){return PhotoStation.LazyDataView.superclass.onItemClick.call(this,b,a,c)},loadMore:function(){if(this.appending||!this.more){return}this.appending=true;var c=this.store.getTotalCount(),b=this.store.getCount();if(c<=b){this.appending=false;this.more=false;return}if(this.store2){this.store2.destroy()}var d=this.store.lastOptions.params;this.store2=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:this.store.proxy.url,listeners:{beforeload:function(e,f){var g=e.activeRequest.read;if(g){Ext.Ajax.abort(g)}}}}),baseParams:d,root:this.store.root,idProperty:this.store.idProperty,totalProperty:this.store.totalProperty,fields:this.store.fields.keys});d.offset=b;var a={params:d,callback:this.loadMoreCallback.createDelegate(this,[d.offset],true),scope:this};this.store2.removeAll();this.store2.load(a)},loadMoreCallback:function(c,b,a,d){if(!a||!c.length||!this.store){this.appending=false;this.more=false;return}this.store.add(c);this.appending=false;this.updateScrollbar()},getTemplate:function(){if(!this.template){this.template=new Ext.XTemplate('
','
','style="max-height:120px;max-width:120px"'," ",'','width="{thumb_width}" height="{thumb_height}"'," ",'src="{Ext.BLANK_IMAGE_URL}" thumbnails="{url}" title="{display_info}">
','
{shortName}
',{isZero:function(b,a){return 0===b||0===a}});this.template.compile()}return this.template},reloadView:function(a){if(this.store2){this.store2.destroy()}this.more=true;this.appending=false;this.updateScrollbar(true);this.store.removeAll();this.store.load(a)}});PhotoStation.DsmGridView=Ext.extend(PhotoStation.CommonGridPanel,{fileType:null,pageSize:10,constructor:function(b){this.fileType=b.fileType?b.fileType:"photo,video,music";var a={border:false,stripeRows:true,height:382,ds:this.createStore(),style:{margin:"0 0 0 10px"},cm:new Ext.grid.ColumnModel({columns:[{menuDisabled:true,header:_PST("photo","photo_str_photoalbum_title"),dataIndex:"name",id:"label_name",renderer:function(g,f,c,h,e,d){f.attr='title="'+(g)+'"';return g}}]}),sm:new Ext.grid.RowSelectionModel(),viewConfig:{forceFit:true},bbar:new SYNO.ux.PagingToolbar({store:this.createStore(),pageSize:this.pageSize,displayInfo:true})};Ext.apply(a,b);PhotoStation.DsmGridView.superclass.constructor.call(this,a)},createStore:function(){this.store=this.store||new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("dsm_share.php")}),root:"data.items",idProperty:"id",totalProperty:"data.total",method:"POST",paramNames:{start:"offset"},baseParams:{id:null,api:"SYNO.PhotoStation.DsmShare",method:"list",version:1,offset:0,limit:this.pageSize,type:this.fileType},fields:["name","id","type"]});return this.store},reloadView:function(a){this.store.removeAll();this.store.load(a);this.store.setBaseParam("id",a.params.id)}});PhotoStation.DsmDataView=Ext.extend(PhotoStation.ImageLoaderDataView,{fileType:null,constructor:function(b){this.fileType=b.fileType?b.fileType:"photo,video,music";var a={emptyText:'
'+_PST("photo","photo_str_no_search_result")+"
",multiSelect:true};Ext.apply(a,b);PhotoStation.DsmDataView.superclass.constructor.call(this,a)},formatData:function(a){a.display_info=Ext.util.Format.htmlEncode(a.name);a.shortName=Ext.util.Format.htmlEncode(Ext.util.Format.ellipsis(a.name),15);var b=PhotoStation.Upload.getThumbWidthHeight(50,50,75,75);if("photo"===a.type){a.url="./webapi/thumb.php?api=SYNO.PhotoStation.Thumb&method=get_dsm_thumb&version=1&id="+a.id;a.thumb_width=a.thumb_height=0}else{a.url=PhotoStation.Util.getImgUrl("White/image_default_video_dark.png",true);a.thumb_width=b.width;a.thumb_height=b.height}return a},getStore:function(){this.store=this.store||new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("dsm_share.php")}),root:"data.items",idProperty:"id",totalProperty:"data.total",method:"POST",baseParams:{api:"SYNO.PhotoStation.DsmShare",method:"list",version:1,offset:0,limit:this.pageSize,type:this.fileType},fields:["name","id","type"],listeners:{scope:this,load:function(){this.preloadItems()}}});return this.store}});PhotoStation.PhotoDataView=Ext.extend(PhotoStation.ImageLoaderDataView,{fileType:null,constructor:function(b){this.fileType=b.fileType?b.fileType:"photo";var a={singleSelect:true};Ext.apply(a,b);PhotoStation.PhotoDataView.superclass.constructor.call(this,a)},formatData:function(a){a.shortName=Ext.util.Format.htmlEncode(Ext.util.Format.ellipsis(a.info.name,15));var b=PhotoStation.Upload.getThumbWidthHeight(a.additional.thumb_size.small.resolutionx,a.additional.thumb_size.small.resolutiony,120,120);a.thumb_width=b.width;a.thumb_height=b.height;a.url=this.getThumbUrl("small",a);a.display_info=Ext.util.Format.htmlEncode(a.info.name);return a},getThumbUrl:function(a,b){if(0>b.thumbnail_status.indexOf(a)&&0<=b.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(b,{size:"preview"})}else{return PhotoStation.Util.getThumbUrl(b,{size:a})}},getStore:function(){this.store=this.store||new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("album.php")}),baseParams:{api:"SYNO.PhotoStation.Album",method:"list",version:1,offset:0,limit:this.pageSize,recursive:false,type:this.fileType,additional:"thumb_size"},root:"data.items",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"]});return this.store}});PhotoStation.DefaultWallpaperDataView=Ext.extend(PhotoStation.ImageLoaderDataView,{fileType:null,constructor:function(b){var a={singleSelect:true};Ext.apply(a,b);PhotoStation.DefaultWallpaperDataView.superclass.constructor.call(this,a)},formatData:function(a){a.display_info=a.shortName="Wallpaper"+String.leftPad(a.id+1,2,"0");a.thumb_width=120;a.thumb_height=86;a.url=a.name;return a},getTemplate:function(){this.template=this.template||new Ext.XTemplate('
','
','
','
{shortName}
');this.template.compile();return this.template},getStore:function(){this.store=this.store||new Ext.data.JsonStore({url:PhotoStation.Util.getThemeRequestFile(),method:"POST",root:"images",baseParams:{action:"photo",type:"photo"},fields:["name","id","type"]});return this.store}});Ext.ns("PhotoStation");PhotoStation.DsmSelector=Ext.extend(Ext.tree.TreePanel,{rootId:"fm_root",constructor:function(a){PhotoStation.DsmSelector.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={collapsable:true,useArrows:true,border:false,cls:"photo-fileselector filechooser",animate:true,loader:this.createLoader(b),root:new Ext.tree.AsyncTreeNode({text:_PST("photo","photo_str_upload_source_ds"),draggable:false,allowDrop:false,expanded:true,leaf:false,id:this.rootId,listeners:{expand:{fn:this.onTreeRootExpand,scope:this,single:true}}}),selModel:new Ext.tree.DefaultSelectionModel()};return Ext.apply(a,b)},createLoader:function(){if(!this.treeLoader){this.treeLoader=new Ext.tree.TreeLoader({dataUrl:PhotoStation.Util.getWebAPIUrl("dsm_share.php"),requestMethod:"POST",nodeParameter:"id",baseParams:{api:"SYNO.PhotoStation.DsmShare",method:"list",version:1,offset:0,limit:-1,id:"",type:"folder"},createNode:function(a){a.record=new Ext.data.Record(Ext.apply({},a));a.text=Ext.util.Format.htmlEncode(a.name);a.qtip=a.text;return Ext.tree.TreeLoader.prototype.createNode.call(this,a)},processResponse:function(a,c,f,b){try{a.responseData=Ext.decode(a.responseText).data.items}catch(d){this.handleFailure(a);return}return Ext.tree.TreeLoader.prototype.processResponse.call(this,a,c,f,b)}})}return this.treeLoader},onTreeRootExpand:function(a){if(a.firstChild){a.firstChild.select()}}});PhotoStation.FileSelector=Ext.extend(Ext.tree.TreePanel,{constructor:function(a){a.fileType=a.fileType||"album";a.additional="";if(this.isUserPrivilegeParamValid(a.userPrivilege)){a.additional="album_permission"}PhotoStation.FileSelector.superclass.constructor.call(this,this.fillConfig(a));a.disableInvalidNode=typeof(a.disableInvalidNode)=="undefined"?true:a.disableInvalidNode;if(this.isUserPrivilegeParamValid(a.userPrivilege)){this.on("load",function(b){if(b===this.getRootNode()){if(!PhotoStation.Auth.permission||!PhotoStation.Auth.permission[a.userPrivilege]){if(a.disableInvalidNode){b.disable()}}}if(a.disableInvalidNode){Ext.each(b.childNodes,function(c){if(!c.attributes.additional.album_permission[a.userPrivilege]){c.disable()}})}})}},fillConfig:function(b){var a={cls:"photo-fileselector",border:false,rootVisible:false,useArrows:true,animate:true,loader:this.createLoader(b),root:new Ext.tree.AsyncTreeNode({id:PhotoStation.Define.ALBUM_CATEGORY,cls:"file-selector-root",leaf:false,expanded:true,record:new Ext.data.Record({hidden:true,id:PhotoStation.Define.ALBUM_CATEGORY,name:_PST("photo","photo_str_category_albums"),text:_PST("photo","photo_str_category_albums"),info:{conversion:true}}),text:_PST("photo","photo_str_category_albums")})};if(!b.useNativeScrollbar){a.plugins=new PhotoStation.TreeFleXcroll()}if(b.enableTip){a.root.setTooltip(a.root.text)}if(b.showCheck){a.listeners={click:function(c,d){c.getUI().toggleCheck()}}}return Ext.apply(a,b)},createLoader:function(a){return new Ext.tree.TreeLoader({dataUrl:PhotoStation.Util.getWebAPIUrl("album.php"),nodeParameter:"id",baseParams:{api:"SYNO.PhotoStation.Album",method:"list",version:1,offset:0,limit:-1,recursive:false,type:a.fileType,additional:a.additional,sort_direction:a.sort_direction||"asc",sort_by:a.sort_by||"preference",ignore:"thumbnail"},createNode:function(b){if(a.showPublic&&"public"!==b.info.type){return}b.record=new Ext.data.Record(Ext.apply({},b));b.showCheck=a.showCheck;b.text=b.info.title;if(a.enableTip){b.qtip=b.text}if(a.showCheck){b.checked=false}if(b.additional&&!b.additional.album_permission[a.userPrivilege]){b.invalid=true}b.uiProvider=PhotoStation.TreeNodeUI;return Ext.tree.TreeLoader.prototype.createNode.call(this,b)},getParams:function(c){var b=Ext.apply({},c);if(PhotoStation.Define.ALBUM_CATEGORY===c.id){b.id=""}return Ext.tree.TreeLoader.prototype.getParams.call(this,b)},processResponse:function(b,d,g,c){try{b.responseData=Ext.decode(b.responseText).data.items}catch(f){this.handleFailure(b);return}return Ext.tree.TreeLoader.prototype.processResponse.call(this,b,d,g,c)}})},getCheckedIdList:function(){var a=[];Ext.each(this.getChecked(),function(b){a.push(b.id)},this);return a},isUserPrivilegeParamValid:function(a){return PhotoStation.Util.inArray(a,["upload","manage"])}});PhotoStation.SharedAlbumSelector=Ext.extend(Ext.tree.TreePanel,{constructor:function(a){Main.addScope("PhotoStation.SharedAlbumSelector",this);PhotoStation.SharedAlbumSelector.superclass.constructor.call(this,this.fillConfig(a));this.sharedAlbumList=new Ext.data.ArrayStore({idIndex:0,fields:["id","name"]});this.getLoader().load(this.getRootNode())},fillConfig:function(b){var a={cls:"photo-fileselector",border:false,rootVisible:false,useArrows:true,animate:true,loader:this.createLoader(b),root:new Ext.tree.AsyncTreeNode({id:PhotoStation.Define.SHARED_ALBUM_CATEGORY,cls:"file-selector-root",leaf:false,expanded:false,record:new Ext.data.Record({hidden:true,id:PhotoStation.Define.SHARED_ALBUM_CATEGORY,name:_PST("photo","photo_str_shared_album"),text:_PST("photo","photo_str_shared_album")}),text:_PST("photo","photo_str_shared_album")})};if(!b.useNativeScrollbar){a.plugins=new PhotoStation.TreeFleXcroll()}if(b.enableTip){a.root.setTooltip(a.root.text)}if(b.showCheck){a.listeners={click:function(c,d){c.getUI().toggleCheck()}}}return Ext.apply(a,b)},createLoader:function(a){return new Ext.tree.TreeLoader({dataUrl:PhotoStation.Util.getWebAPIUrl("shared_album.php"),nodeParameter:"id",baseParams:{api:"SYNO.PhotoStation.SharedAlbum",method:"list",version:1,offset:0,limit:-1,additional:"public_share"},createNode:function(b){if(b.id===PhotoStation.Define.DEFAULT_SHARE_SINGLE_ITEM){b.name=_PST("photo","photo_str_single_item_shared_album")}else{Main.getScope("PhotoStation.SharedAlbumSelector").sharedAlbumList.loadData([[b.id,Ext.util.Format.htmlEncode(b.name)]],true)}b.record=new Ext.data.Record(Ext.apply({},b));b.showCheck=a.showCheck;b.text=b.name;if(a.enableTip){b.qtip=b.text}if(a.showCheck){b.checked=false}b.uiProvider=PhotoStation.TreeNodeUI;b.loaded=true;return Ext.tree.TreeLoader.prototype.createNode.call(this,b)},getParams:function(c){var b=Ext.apply({},c);if(PhotoStation.Define.SHARED_ALBUM_CATEGORY===c.id){b.id=""}return Ext.tree.TreeLoader.prototype.getParams.call(this,b)},processResponse:function(b,d,g,c){try{b.responseData=Ext.decode(b.responseText).data.items}catch(f){this.handleFailure(b);return}return Ext.tree.TreeLoader.prototype.processResponse.call(this,b,d,g,c)}})}});PhotoStation.TreeNodeUI=Ext.extend(Ext.tree.TreeNodeUI,{renderElements:function(e,c,d,b){PhotoStation.TreeNodeUI.superclass.renderElements.call(this,e,c,d,b);if(!c.showCheck){return}this.fakeCheckbox=Ext.DomHelper.insertBefore(this.checkbox,{tag:"img",alt:"",src:this.emptyIcon,cls:"x-tree-node-cb-fake"},true)},onCheckChange:function(){PhotoStation.TreeNodeUI.superclass.onCheckChange.call(this);if(!this.fakeCheckbox){return}var a=this.checkbox.checked;if(a){this.fakeCheckbox.addClass("x-tree-node-cb-fake-check")}else{this.fakeCheckbox.removeClass("x-tree-node-cb-fake-check")}}});PhotoStation.TreeFleXcroll=function(){return{init:function(a){var b=function(){var c=this.body.dom;if(c&&c.fleXcroll){c.fleXcroll.updateScrollBars()}else{if(c){fleXenv.fleXcrollMain(c)}}c=null};a.on("load",b);a.on("expandnode",b);a.on("collapsenode",b)}}};Ext.ns("PhotoStation");PhotoStation.FileSelectorWindow=Ext.extend(PhotoStation.BaseWindow,{dsmTreeItemId:"dsm-tree",wallPaperItemId:"default-tree",photoTreeItemId:"photo-tree",uploadItemId:"upload-tree",uploadMusicItemId:"upload-music-tree",mapping:{},constructor:function(b){Main.addScope("PhotoStation.FileSelectorWindow",this);this.mode=b.mode?b.mode.split(","):["upload","default","photo_station"];this.fileType=b.fileType||"photo";this.dsmFileType=b.dsmFileType||"photo,video";this.dsmViewType=b.dsmViewType||"dataview";var a={width:800,height:500,title:_PST("photo","photo_str_ds_copy_window_title"),layout:"border",items:[{region:"west",itemId:"westPanel",border:false,split:true,style:{padding:"10px 0 0 10px"},width:220,height:340,autoScroll:false,items:this.getTreeItems(b),listeners:{afterlayout:function(){this.updateScrollbar()}},updateScrollbar:function(){var h=this;if(h.isVisible()){var m=h.getContentTarget().dom;var k=m.childNodes;if(m&&m.fleXcroll&&2===k.length){fleXenv.updateScrollBars()}else{if(m&&m.fleXcroll){var d=m.childNodes;var c=[];for(var f=0,e=0;f';var b=Ext.get(this.iframeId);b.on("load",this.formMusicUploadActionComplete.createDelegate(this,[this.iframeId]));return a},formMusicUploadActionComplete:function(b){if(this.isVisible()){this.clearStatusBusy()}var i=Ext.get(b).dom.contentWindow.document.body.innerHTML,j,d=_PST("photo","photo_str_upload_fail");if(!i){return}var f=i.match(/(.*?)<\/pre>/i),h;if(f){h=f[1]}try{j=Ext.decode(h)}catch(g){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),d);return}if(!j.success){var c,a;if(Ext.isArray(j.error.code)){c=j.error.code[0];a=j.error.code[1]}else{c=j.error.code}if(541===c){d=String.format(_PST("photo","photo_str_music_maximum_num"),a)}else{if(538===c){d=_PST("photo","photo_str_music_support_format")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),d);return}this.fireEvent("finishupload")},getMyImageContentConfig:function(){var a=function(b){b.url=b.name;this.myimageData=b;return b};return{cls:"myimage-content",itemId:"upload",border:false,items:[{xtype:"dataview",id:this.imageUploadViewId=Ext.id(),cls:"myimage-preview",autoScroll:false,store:new Ext.data.ArrayStore({data:[[PhotoStation.Util.getThemeRequestFile()+"?type=photo&action=preview_bkg_custom&big=1",0,"img-upload-view"]],fields:["name","id","type"]}),tpl:new Ext.XTemplate('','
','',"
","
",'
'),singleSelect:true,overClass:"x-view-over",itemSelector:"div.thumb-wrap",emptyText:'
'+_PST("photo","photo_str_no_photo")+"
",prepareData:a.createDelegate(this)},{xtype:"form",id:this.uploadFormID=Ext.id(),border:false,fileUpload:true,trackRestOnLoad:true,autoFlexcroll:false,items:[{xtype:"syno_filebutton",name:"file",id:this.fileBtnId=Ext.id(),hideLabel:true,fieldLabel:_PST("photo","photo_theme_from_computer"),buttonOnly:true,buttonText:_PST("photo","photo_theme_from_computer"),disabled:gIsDemoMode,listeners:{scope:this,render:function(b){b.el.on("change",function(){var c=Ext.getCmp(this.uploadFormID);this.uploadBtn=b;if(b.el.dom.value){c.getForm().submit({url:"./include/synotheme_upload.php",params:{action:"bkg_upload",type:"photo"},waitMsg:_PST("photo","photo_str_uploading"),success:function(f,g){var e=Ext.getCmp(this.imageUploadViewId);var d=this.myimageData;d.name+="&cv="+Math.random();e.update(d);e.refresh();e.select(0)},failure:function(d,e){Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),e.result.message)},scope:this})}},this)}}}]}],listeners:{activate:function(){var b=Ext.getCmp(this.fileBtnId);b.updateFileInputStyle()},scope:this}}},getDefaultView:function(){this.defaultDataView=new PhotoStation.DefaultWallpaperDataView({itemId:"default",singleSelect:true});return this.defaultDataView},getDataView:function(){this.dataView=new PhotoStation.PhotoDataView({itemId:"photo_station",fileType:this.fileType});return this.dataView},getDsmView:function(){if("gridview"===this.dsmViewType){this.dsmView=new PhotoStation.DsmGridView({itemId:"dsm",fileType:this.dsmFileType})}else{this.dsmView=new PhotoStation.DsmDataView({itemId:"dsm",fileType:this.dsmFileType})}return this.dsmView},onMyMusicBeforeSelect:function(c,a,b){this.changeState("upload_music")},onMyImageBeforeSelect:function(c,a,b){this.changeState("upload")},onDefaultTreeBeforeSelect:function(c,a,b){this.changeState("default")},onTreeBeforeSelect:function(c,a,b){this.changeState("photo_station")},onDsmTreeBeforeSelect:function(c,a,b){if(c.tree.rootId===a.id){return false}this.changeState("dsm")},onTreeSelectionChange:function(b,a){if(a){this.mapping[b.tree.itemId].reloadView({params:{id:a.id}})}},changeState:function(b){for(var a in this.treePanels){if(a&&this.treePanels[a]&&a!=b){this.treePanels[a].getSelectionModel().clearSelections()}}this.state=b;this.centerPanel.layout.setActiveItem(b)},applyHandler:function(){var a={photo_station:this.dataView,"default":this.defaultDataView,upload:Ext.getCmp(this.imageUploadViewId),dsm:this.dsmView}[this.state];var b;if(!a){this.hide();return}if(a instanceof Ext.grid.GridPanel){b=a.getSelectionModel().getSelections();this.fireEvent("choose",b.length?b:null,this.state)}else{if(a instanceof PhotoStation.ImageLoaderDataView){if(a.multiSelect){b=a.getSelectedRecords();this.fireEvent("choose",b.length?b:null,this.state)}else{if(a.singleSelect){b=a.getSelectedRecords()[0];this.fireEvent("choose",b?b.data:null,this.state)}}}else{if(a instanceof Ext.DataView){b=a.getSelectedRecords()[0];this.fireEvent("choose",b?b.data:null,this.state)}}}this.hide()},cancelHandler:function(){this.fireEvent("cancel",null,this.state);this.hide()}});Ext.ns("PhotoStation");PhotoStation.GeoTagDialog=Ext.extend(PhotoStation.BaseWindow,{oriTagRec:null,currentLatlng:null,gpsChange:false,constructor:function(a){Ext.apply(this,a);Main.addScope("PhotoStation.GeoTagDialog",this);PhotoStation.GeoTagDialog.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={title:_PST("photo","photo_str_location_tag"),layout:"fit",resizable:true,buttonAlign:"left",useStatusBar:false,width:650,height:450,items:this.getPanelCfg(),buttons:[{itemId:"removeBtn",cls:"photo-red-button photo-button",text:_PST("photo","photo_str_album_delete_loaction_tag"),handler:this.clickRemove,scope:this},"->",{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:this.clickCancel,scope:this}],listeners:{scope:this,hide:function(){this.gmapMarker.setVisible(false);this.tagMarker.setVisible(false);this.geoTagCombo.setValue("");this.oriTagRec=null;this.currentLatlng=null;this.clearStatusBusy()},afterlayout:{fn:function(){this.initGMap();this.removeBtn=this.getFooterToolbar().getComponent("removeBtn")},single:true}}};return Ext.apply(a,b)},initGMap:function(){var a=this.getDefaultGPS();var b={zoom:12,center:a,streetViewControl:true,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},navigationControlOptions:{style:google.maps.NavigationControlStyle.SMALL}};this.gmap=new google.maps.Map(Ext.get(this.gmapDivId).dom,b);this.gmapMarker=new google.maps.Marker({map:this.gmap,clickable:true,visible:false,icon:"photo_new/images/Window/icon_map_red.png"});this.tagMarker=new google.maps.Marker({map:this.gmap,clickable:true,visible:false,icon:"photo_new/images/Window/icon_map_blue.png",position:a});this.defMarker=new google.maps.Marker({map:this.gmap,clickable:true,visible:false,icon:"photo_new/images/Window/icon_map_green.png",position:a});this.on("resize",this.onResizeMap);google.maps.event.addListener(this.gmap,"center_changed",this.onMapCenterChanged.createDelegate(this));google.maps.event.addListener(this.gmap.getStreetView(),"position_changed",this.onStreetViewPositionChanged.createDelegate(this));this.gmap.setCenter(a);this.initGmapMenu()},initGmapMenu:function(){this.gmap.ctxMenu=new Ext.menu.Menu({items:[{icon:"images/White/timeline/menu_icon_map_red.png",text:_PST("photo","photo_str_set_coordinates"),handler:function(){this.currentLatlng=this.gmap.rightClickPos.latLng;this.onSetMap(this.gmap.rightClickPos.latLng)},scope:this},{icon:"images/White/timeline/menu_icon_map_red.png",text:_PST("photo","photo_str_set_def_coordinates"),handler:function(){this.setDefaultGPS(this.gmap.rightClickPos.latLng)},scope:this}]});google.maps.event.addListener(this.gmap,"rightclick",function(b){var a=Ext.fly(this.getDiv());var c=[a.getX()+b.pixel.x,a.getY()+b.pixel.y];this.rightClickPos=b;this.ctxMenu.showAt(c)})},getDefaultGPS:function(){var a=PhotoStation.Info.default_geo_location;if(!Ext.isEmpty(a.lat)&&!Ext.isEmpty(a.lng)){return new google.maps.LatLng(parseFloat(a.lat),parseFloat(a.lng))}return new google.maps.LatLng(25.050433,121.518649)},setDefaultGPS:function(a){Ext.Ajax.request({url:"ajax_handler.php",params:{action:"set_def_gps",lat:a.lat(),lng:a.lng()},method:"POST",scope:this,success:function(b,c){var d=Ext.util.JSON.decode(b.responseText);if(d.success!==true){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_failed"));return}PhotoStation.Info.default_geo_location.lat=a.lat();PhotoStation.Info.default_geo_location.lng=a.lng()}})},onResizeMap:function(){if(Ext.isEmpty(this.gmap)){return}var a=this.gmap.getCenter();google.maps.event.trigger(this.gmap,"resize");google.maps.event.trigger(this.gmap.getStreetView(),"resize");this.gmap.setCenter(a)},onMapCenterChanged:function(){this.centerChange=true},onStreetViewPositionChanged:function(){var a=this.gmap.getStreetView().getPosition();this.gmap.setCenter(a)},onSetMap:function(a){this.gpsChange=true;this.gmapMarker.setPosition(a);this.gmapMarker.setVisible(true);this.gmapMarker.setTitle(_PST("photo","photo_str_taken_location"));this.gmap.panTo(a)},checkAndPanToTagGps:function(){var a=this.geoTagCombo.getValue().trim();var d=this.checkbox.getValue();var g=null;var f=false;var e,b;if(this.lastSelectRec&&a===this.lastSelectRec.get("name")){f=true;b=this.lastSelectRec.get("gps");if(b){e=new google.maps.LatLng(b.lat,b.lng,true)}}if(f&&e){if(d||(this.currentLatlng&&this.currentLatlng.equals(e))){g=e;this.gmapMarker.setPosition(g);this.gmapMarker.setVisible(true);this.gmapMarker.setTitle(this.lastSelectRec.get("name")+" ("+this.lastSelectRec.get("address")+")");this.tagMarker.setVisible(false);this.gmap.panTo(g)}else{this.tagMarker.setPosition(e);this.tagMarker.setVisible(true);this.tagMarker.setTitle(this.lastSelectRec.get("name")+" ("+this.lastSelectRec.get("address")+")");if(this.currentLatlng){this.gmapMarker.setPosition(this.currentLatlng);this.gmapMarker.setVisible(true);this.gmapMarker.setTitle(_PST("photo","photo_str_taken_location"));var c=new google.maps.LatLngBounds();c.extend(this.gmapMarker.getPosition());c.extend(e);this.gmap.fitBounds(c)}else{this.gmap.panTo(e)}}}else{if(this.currentLatlng){g=this.currentLatlng;this.gmapMarker.setPosition(g);this.gmapMarker.setVisible(true);this.gmapMarker.setTitle(_PST("photo","photo_str_taken_location"))}else{g=this.defMarker.getPosition()}this.gmap.panTo(g);this.tagMarker.setVisible(false)}},getPanelCfg:function(){this.gmapDivId=Ext.id();this.comboTpl=new Ext.XTemplate('',"",'','
{[_PST("photo","photo_str_tag_existing")]}
',"
",'
','
','
{name:htmlEncode}
','
{address:htmlEncode}
',"
","
","
","",'','
',"
",'','
{[_PST("photo","photo_str_tag_online_search")]}
',"
",'
','
','
{name:htmlEncode}
','
{address:htmlEncode}
',"
","
","
","
",{existTag:0,searchTag:0,isLastExistTag:function(){if(this.existTag>0&&0===this.searchTag){return true}return false}});this.comboStore=new Ext.data.Store({autoDestroy:true,proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("tag.php"),listeners:{scope:this,beforeload:function(b,c){c.location=this.gmap.getCenter().lat()+","+this.gmap.getCenter().lng()}}}),reader:new Ext.data.JsonReader({root:"data"},["name","address","gps","placeId","tagId","type"]),baseParams:{api:"SYNO.PhotoStation.Tag",method:"searchplace",version:1,format:true,radius:500}});var a={border:false,layout:"border",items:[{border:false,region:"north",layout:"fit",height:60,cls:"geo-tag-dialog-upper",items:[{id:this.comboId=Ext.id(),xtype:"combo",title:'
'+_PST("photo","photo_str_use")+'
',store:this.comboStore,listClass:"geo-tag-combo-list",hideLabel:true,tpl:this.comboTpl,editable:true,emptyText:this.multiSel?_PST("photo","photo_str_edit_multiple_location_tag"):"",displayField:"name",hideTrigger:true,enableKeyEvents:true,maxLength:64,autoSelect:false,listEmptyText:_PST("photo","photo_str_no_search_result"),loadingText:_PST("photo","photo_str_searching"),queryParam:"query",queryDelay:1000,minChars:1,onKeyUp:function(c){var b=c.getKey();if(Ext.isEmpty(this.getValue().trim())){this.collapse()}else{if(Main.getScope("PhotoStation.GeoTagDialog").forceDoQuery||(this.editable!==false&&this.readOnly!==true&&(b==c.BACKSPACE||!c.isSpecialKey()))){this.lastKey=b;this.dqTask.delay(this.queryDelay);Main.getScope("PhotoStation.GeoTagDialog").centerChange=false;Main.getScope("PhotoStation.GeoTagDialog").forceDoQuery=false}}Ext.form.ComboBox.superclass.onKeyUp.call(this,c)},listeners:{scope:this,beforequery:function(b){var d=b.combo,c=b.query;d.header.update('
'+String.format(_PST("photo","photo_str_use"),''+Ext.util.Format.htmlEncode(c)+'')+"
")},keydown:function(d,c){var b=c.getKey();d.tpl.existTag=0;d.tpl.searchTag=0;if(!d.isExpanded()&&40==b&&this.centerChange){this.forceDoQuery=true;this.geoTagCombo.lastQuery=""}},select:function(d,b,c){this.lastSelectRec=b;this.checkAndPanToTagGps()}}},{id:this.checkId=Ext.id(),synotype:"check",boxLabel:_PST("photo","photo_str_use_location_tag_gps"),listeners:{scope:this,check:function(c,b){this.checkAndPanToTagGps();if(b){this.gmap.ctxMenu.items.first().setDisabled(true)}else{this.gmap.ctxMenu.items.first().setDisabled(false)}}}}]},{border:false,region:"center",layout:"border",items:{itemId:"gmap_panel",border:true,region:"center",html:"
"}}]};SYNO.LayoutConfig.fill(a);return a},getRecInfo:function(b){var a;if("video"==b.get("type")){a=b.get("info")}else{a=b.get("additional").photo_exif}return a},onShow:function(){if(this.isLightBox){this.removeBtn.hide()}this.geoTagCombo=Ext.getCmp(this.comboId);this.checkbox=Ext.getCmp(this.checkId);if(this.oriTagRec){this.geoTagCombo.setValue(this.oriTagRec.get("name"))}this.lastSelectRec=this.getTagRecFromOriginalTag();if(this.currentRec.length==1){var b=this.getRecInfo(this.currentRec[0]);var a=b.gps;if(a){this.currentLatlng=new google.maps.LatLng(a.lat,a.lng,true)}}this.checkAndPanToTagGps()},getTagRecFromOriginalTag:function(){var a;if(this.oriTagRec&&!Ext.isEmpty(this.oriTagRec.get("info").lat)&&!Ext.isEmpty(this.oriTagRec.get("info").lng)){a={id:-1,name:this.oriTagRec.get("name"),address:this.oriTagRec.get("info").address,place_id:this.oriTagRec.get("info").placeId,gps:{lat:this.oriTagRec.get("info").lat,lng:this.oriTagRec.get("info").lng}};return new this.comboStore.recordType(a,0)}return null},saveGps:function(){var b=this.geoTagCombo.getValue().trim();var f=this.gmapMarker.getPosition();var a=this.checkbox.getValue();var d=[];if(!f&&(!this.lastSelectRec||!this.lastSelectRec.get("gps"))){return false}for(var c=0;c0){d=Ext.unique(this.selTagArr);this.owner.deletePhotoTag(d.join(","),this.deleteTagDone.createDelegate(this,[c],false))}else{var b=(this.lastSelectRec)?this.lastSelectRec.get("tagId"):null;this.owner.addPhotoTag(this.geoTagCombo.getValue().trim(),b,c,this.addTagDone.createDelegate(this))}}},deleteTagDone:function(a){this.owner.addPhotoTag(this.geoTagCombo.getValue().trim(),null,a,this.addTagDone.createDelegate(this))},addTagDone:function(){this.hide()},checkTagIsChange:function(){if(this.geoTagCombo.getValue().trim()===""){return false}if((this.oriTagRec&&this.oriTagRec.get("name")!==this.geoTagCombo.getValue())||!this.oriTagRec){return true}return false},clickRemove:function(){this.setStatusBusy();if(this.selTagArr&&this.selTagArr.length>0){var a=Ext.unique(this.selTagArr);this.owner.deletePhotoTag(a.join(","),this.removeDone.createDelegate(this))}else{this.removeDone()}},removeDone:function(){this.clearStatusBusy();this.hide();Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_tags_removed"))},clickOK:function(){this.setStatusBusy();if(this.gpsChange||(this.lastSelectRec&&this.checkbox.getValue())){if(false!==this.saveGps()){return}}if(this.checkTagIsChange()){this.saveGeoTag();return}this.hide()},clickCancel:function(){this.hide()},setCurrentRecords:function(a){this.currentRec=a}});Ext.ns("PhotoStation");PhotoStation.GotoRealAlbumPlugin=Ext.extend(Ext.util.Observable,{id:null,constructor:function(a){PhotoStation.GotoRealAlbumPlugin.superclass.constructor.call(this,a)},init:function(a){this.cmp=a;a.on("click",this.onClick,this)},setId:function(a){this.id=a},onClick:function(){if(!this.id){return}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Path","getpath",1,{id:this.id,ignore:"thumbnail",additional:"album_permission"},function(g,f,e,d){if(!g){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),PhotoStation.Util.getErrMsg(f));return}var c,b=f.items,a=[];for(c=0;c=0?n.substr(o+2):(p>=0?n.substr(p+1):null);if(Ext.isGecko){q=decodeURIComponent(q)}return q}function a(){d.value=e}function h(n){e=n;PhotoStation.History.fireEvent("change",n)}function i(o){var n=['
',Ext.util.Format.htmlEncode(o),"
"].join("");try{var q=f.contentWindow.document;q.open();q.write(n);q.close();return true}catch(p){return false}}function c(){if(!f.contentWindow||!f.contentWindow.document){setTimeout(c,10);return}var q=f.contentWindow.document;var o=q.getElementById("state");var n=o?o.innerText:null;var p=g();setInterval(function(){q=f.contentWindow.document;o=q.getElementById("state");var s=o?o.innerText:null;var r=g();if(s!==n){h(s);n=s;location.hash="!"+n;p=n;a()}else{if(r!==p){p=r;i(r)}}},50);k=true;PhotoStation.History.fireEvent("ready",PhotoStation.History)}function j(){e=d.value?d.value:g();if(b){c()}else{var n=g();setInterval(function(){var o=g();if(o!==n){n=o;h(n);a()}},50);k=true;m=0;PhotoStation.History.fireEvent("ready",PhotoStation.History)}}return{fieldId:"x-history-field",iframeId:"x-history-frame",events:{},oldIEMode:b,historyBound:undefined,init:function(o,n){if(k){Ext.callback(o,n,[this]);return}if(!Ext.isReady){Ext.onReady(function(){PhotoStation.History.init(o,n)});return}d=Ext.getDom(PhotoStation.History.fieldId);if(b){f=Ext.getDom(PhotoStation.History.iframeId)}else{window.onpopstate=function(r){if(!r||!r.state){return}var p=r.state.token,q=Main.getScope("PhotoStation.LightBox");if(q&&(p.indexOf("/photo_")||p.indexOf("/video_"))){q.historyCount=r.state.lightboxCount}PhotoStation.History.currentToken=p}}this.addEvents("ready","change");if(o){this.on("ready",o,n,{single:true})}j()},add:function(n,o){if(o!==false){if(this.getToken()==n){return true}}if(b){return i(n)}else{var p=Main.getScope("PhotoStation.LightBox"),q;if(p){if(p.historyCount>0){q=p.historyCount-1}else{q=0}}m+=1;history.pushState({token:n,seq:m,lightboxCount:q},document.title,location.pathname+location.search+"#!"+n);return true}},back:function(){history.go(-1)},forward:function(){history.go(1)},getToken:function(){return k?e:g()}}})();Ext.apply(PhotoStation.History,new Ext.util.Observable());PhotoStation._HistoryManager=Ext.extend(Ext.util.Observable,{init:function(){PhotoStation.History.init();if("undefined"===typeof(PhotoStation.History.historyBound)){PhotoStation.History.historyBound=history.length}this.token=PhotoStation.History.getToken();this.currentHistory=history.length;this.loadFromUrl=true;PhotoStation.History.on("change",this.changeHandler,this)},add:function(a){this.loadFromUrl=false;if(!this.isValidToken(a)){return false}PhotoStation.History.add(a);this.token=a;return true},getToken:function(){return this.token},loadCheck:function(){var b=PhotoStation.History.getToken()||"",c=b.split("/"),a=c[c.length-1];if(a=="slideshow"){a=c[c.length-2]}if(!b||!a){this.jumpToDefault();return}this.loadFromUrl=true;this.jumpTo(b)},albumPermissionHandler:function(c,a){if(!c||!PhotoStation.Util.inArray(c.code,[416,417])){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}if(416===c.code){var b=Main.getScope("PhotoStation.PasswordWindow");if(!b){b=new PhotoStation.PasswordWindow()}b.albumId=a;b.on("password",function(d){if(d){this.jumpTo(PhotoStation.History.getToken())}else{this.jumpToPasswordCancel(PhotoStation.History.getToken())}},this,{single:true});b.show()}else{if(417===c.code){if(PhotoStation.Auth.username){this.jumpToDefault()}else{Main.getScope("PhotoStation.CenterPanel").onLogIn(true)}}}},changeHandler:function(b){SYNO.Debug("changeHandler: goto "+b);this.loadFromUrl=true;if(null!==Ext.WindowMgr.getActive()){this.add(this.getToken());return}Main.getScope("PhotoStation.CenterPanel").updateRSSBtn();if(b===this.getToken()){return}if(this.currentHistory===50){if(PhotoStation.History.historyBound>1){PhotoStation.History.historyBound--}}else{this.currentHistory++}var c=Main.getScope("PhotoStation.LightBox"),j=b,f;if(c){c.stopSlideShow(true);var d=b.split("/");if("slideshow"===d[d.length-1]){f="slideshow";d.pop();j=d.join("/")}}var i=Math.max(j.indexOf("/photo_"),j.indexOf("/video_"));var e=Math.max(this.getToken().indexOf("/photo_"),this.getToken().indexOf("/video_"));if(0<=i&&0<=e){var h=c.store;var a=j.substr(i+1,j.length);if(h.getById(a)){c.show(a,null,f);return}c.hide()}var g=this.matchToken(this.getToken(),b);if(g>=0){if(c&&-1!==c.index){c.hide(true)}if(0<=e&&this.getToken().substr(0,e)===b){this.token=b;return}Main.getScope("PhotoStation.SimplePathBar").clickPathItem(g)}else{this.jumpTo(b)}},matchToken:function(e,h){var c,g,d,f,b,a=-1;c=e.split("/");g=h.split("/");d=c.length;f=g.length;if(d<=f){return -1}for(b=0;b1){Main.getScope("PhotoStation.LeftContent").clearSelections(Main.getScope("PhotoStation.CategoryList"));Main.getScope("PhotoStation.CategoryList").highlightCategoryByRecord(a);this.on("filldone",function(c){Main.getScope("PhotoStation.ViewCard").containerLoad(c)},this,{single:true});this.fillPathBar(b)}else{Main.getScope("PhotoStation.CategoryList").loadCategoryByRecord(a)}}},jumpToDefault:function(){var a=PhotoStation.Info.home_category;if(Ext.isEmpty(a)||!Main.getScope("PhotoStation.CategoryList").store.getById(PhotoStation.Info.home_category)){this.jumpToAlbumsRoot()}else{this.jumpToCategory(a.split("/"))}},jumpToAlbumsRoot:function(){Main.getScope("PhotoStation.LeftContent").loadAlbums()},jumpToSharedAlbum:function(b){if(!PhotoStation.Auth.username){Main.getScope("PhotoStation.CenterPanel").onLogIn(true);return}else{if(!PhotoStation.Auth.allow_public_share){this.jumpToDefault();return}}if(b.length>1){var a=Main.getScope("PhotoStation.LeftContent");a.clearSelections(a.shareAlbumSelector);a.highlightSharedAlbums();this.on("filldone",function(c){var d=c.get("id")===PhotoStation.Define.SHARED_ALBUM_CATEGORY;Main.getScope("PhotoStation.ViewCard").containerLoad(c,d)},this,{single:true});this.fillPathBar(b)}else{Main.getScope("PhotoStation.LeftContent").loadSharedAlbums()}},jumpToPasswordCancel:function(b){var c=b.split("/"),a;if(this.loadFromUrl||c.length===1){this.jumpToDefault();return}c.pop();a=c.join("/");this.jumpTo(a)}});Ext.ns("PhotoStation");PhotoStation.TextEditWindow=Ext.extend(PhotoStation.BaseWindow,{constructor:function(a){this.text=a.text;Main.addScope("PhotoStation.TextEditWindow",this);PhotoStation.TextEditWindow.superclass.constructor.call(this,this.fillConfig(a));this.addEvents("cancel","confirm");this.on("show",function(b){b.getComponent("text").focus(false,50)})},fillConfig:function(b){var a={title:_PST("photo","photo_str_description"),layout:"fit",resizable:true,buttonAlign:"left",useStatusBar:false,width:650,height:450,items:[{itemId:"text",xtype:"textarea",value:this.text,listeners:{focus:function(c){var d=c.getRawValue();c.setRawValue("");c.setRawValue(d)}}}],buttons:["->",{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:this.clickCancel,scope:this}]};return Ext.apply(a,b)},clickOK:function(){this.fireEvent("confirm",this.getComponent("text").getValue());this.close()},clickCancel:function(){this.fireEvent("cancel");this.close()}});PhotoStation.LabelTextField=Ext.extend(Ext.BoxComponent,{text:"",allowEdit:true,baseCls:"label-textfield",emptyClass:"label-textfield-empty",emptyText:"",allowBlank:true,editType:"input",editInPopWindow:false,constructor:function(b){var a={editType:"input"};PhotoStation.LabelTextField.superclass.constructor.call(this,Ext.apply(a,b))},onRender:function(c,a){var b;if("textarea"===this.editType){b=new Ext.Template('
','
',"
",'
','','',"
","
")}else{b=new Ext.Template('
','
',"
",'
','',"
","
")}this.el=a?b.insertBefore(a,{cls:this.baseCls},true):b.append(c,{cls:this.baseCls},true);if(this.id){this.el.dom.id=this.id}this.labelEl=Ext.get(this.el.dom.firstChild);this.textfieldEl=Ext.get(this.el.dom.lastChild.firstChild);this.shadowTextfieldEl=Ext.get(this.el.dom.lastChild.lastChild);this.labelEl.setVisibilityMode(Ext.Element.DISPLAY);this.textfieldEl.setVisibilityMode(Ext.Element.DISPLAY);this.labelEl.on("click",this.clickLabel,this);if("textarea"===this.editType){this.keyMap={};this.keyMap[Ext.EventObject.ENTER]=false;this.keyMap[Ext.EventObject.SHIFT]=false;this.textfieldEl.on("keydown",this.keydownTextareaField,this);this.textfieldEl.on("keyup",this.keyupTextareaField,this);this.textfieldEl.on("blur",this.blurTextField,this)}else{this.textfieldEl.on("keydown",this.keydownTextField,this);this.textfieldEl.on("blur",this.blurTextField,this)}this.toggleVisibility(true)},afterRender:function(){PhotoStation.LabelTextField.superclass.afterRender.call(this);this.labelEl.setWidth(this.width);this.textfieldEl.setWidth(this.width);this.setText(this.text)},getErrors:function(a){var b;b=PhotoStation.LabelTextField.superclass.getErrors.apply(this,arguments)},setText:function(a){this.text=Ext.isEmpty(a)?"":a;this.setRawText(Ext.isEmpty(this.text)?this.emptyText:this.text);this.toggleVisibility(true)},getText:function(){return this.text},setRawText:function(b){var a=Ext.isEmpty(b)?"":b;this.el.dom.title=a;this.labelEl.update(Ext.util.Format.htmlEncode(a));this.textfieldEl.dom.value=(a)},toggleVisibility:function(b){if(this.editInPopWindow&&!b){var a=new PhotoStation.TextEditWindow({text:this.text,listeners:{confirm:function(c){this.setRawText(c);this.confirm()},cancel:function(){this.cancel()},scope:this}});a.show()}else{if(this.isEmpty()){this.el.addClass(this.emptyClass);if(b){this.setRawText(this.emptyText)}else{this.setRawText("")}}else{this.el.removeClass(this.emptyClass);this.setRawText(this.text)}this.textfieldEl.setVisible(!b);this.labelEl.setVisible(!!b);if(!b){this.textfieldEl.focus();if("textarea"===this.editType){this.updateTextHeight()}}}if(b){this.fireEvent("hideTextField",this)}else{this.fireEvent("showTextField",this)}},isEmpty:function(){return Ext.isEmpty(this.text)},clickLabel:function(){if(!this.allowEdit){return}this.toggleVisibility(false)},keydownTextField:function(b,a,c){switch(b.getKey()){case b.ENTER:this.confirm();break;case b.ESC:b.stopPropagation();this.cancel();break}},blurTextField:function(){if(!this.cancelBlur){this.confirm()}this.cancelBlur=false},keydownTextareaField:function(c,b,d){var a=c.getKey();if(a in this.keyMap){this.keyMap[a]=true;if(this.keyMap[Ext.EventObject.ENTER]&&this.keyMap[Ext.EventObject.SHIFT]){}else{if(this.keyMap[Ext.EventObject.ENTER]&&!this.keyMap[Ext.EventObject.SHIFT]){this.confirm()}}}this.updateTextHeight()},keyupTextareaField:function(b){var a=b.getKey();if(a in this.keyMap){this.keyMap[a]=false}},updateTextHeight:function(){this.shadowTextfieldEl.dom.value=this.textfieldEl.getValue();this.textfieldEl.setHeight(this.shadowTextfieldEl.dom.scrollHeight+10)},confirm:function(){this.cancelBlur=true;this.textfieldEl.blur();var a=this.textfieldEl.getValue().trim();this.toggleVisibility(true);if(!this.allowBlank&&Ext.isEmpty(a)){this.fireEvent("confirmblank",this);return}if(this.text===a){return}this.setText(a);this.fireEvent("confirm",this,this.text)},cancel:function(){this.cancelBlur=true;this.textfieldEl.blur();this.toggleVisibility(true);this.fireEvent("cancel",this,this.text)}});Ext.reg("labeltextfield",PhotoStation.LabelTextField);Ext.ns("PhotoStation");PhotoStation.AboutMeList=Ext.extend(Ext.list.ListView,{constructor:function(a){Main.addScope("PhotoStation.AboutMeList",this);PhotoStation.AboutMeList.superclass.constructor.call(this,this.fillConfig(a));Ext.override(SYNO.TriCheckbox,{initEvents:function(){Ext.form.Checkbox.superclass.initEvents.call(this);this.mon(this.checkbox,{scope:this,click:this.onClick});this.mon(this.container.child("label"),{scope:this,click:this.onClick})}})},fillConfig:function(b){this.owner=b.owner;var a={cls:"aboutme-list",store:this.createStore(),hideHeaders:true,singleSelect:true,hidden:true,internalTpl:this.getXTemplate(),columns:[{dataIndex:"name",tpl:"{name:htmlEncode}"}],listeners:{scope:this,selectionchange:this.onSelectionChange,beforeselect:this.beforeSelect}};return Ext.apply(a,b)},createStore:function(){var a=new Ext.data.JsonStore({idProperty:"id",fields:["id","name","hidden"]});return a},getXTemplate:function(){var a=new Ext.XTemplate('
','','
',"{header}","
","
",'
',"
",'
',"
");return a},beforeSelect:function(b,e,d){var a=b.getRecord(e);var f=true;if("settings"==a.get("id")){window.location="admin_index.php";f=false}else{if("theme"==a.get("id")){this.owner.hideOuterContainer();var c=Main.getScope("PhotoStation.CustomizePanel");c.expand();f=false}}if(!f&&PhotoStation.Define.ABOUT_ME==PhotoStation.HistoryManager.getToken()){this.select(0,false,true)}return f},onSelectionChange:function(b,c){if(1!==c.length){return}PhotoStation.Util.checkAuth();var a=b.getRecord(c[0]);if(PhotoStation.Define.ABOUT_ME==a.get("id")){Main.getScope("PhotoStation.LeftContent").clearSelections(this);Main.getScope("PhotoStation.ViewCard").switchTo("PhotoStation.AboutMePanel");PhotoStation.HistoryManager.add(a.get("id"))}this.owner.hideOuterContainer()},setTitle:function(c,b){var a=this.store.getById(c);a.set("name",b)},updateVisibility:function(){var e=PhotoStation.Util.isLeftPanelCollapsed();var a=[{id:PhotoStation.Define.ABOUT_ME,name:PhotoStation.Info.about_me_title,hidden:!PhotoStation.Auth.is_admin&&PhotoStation.Info.disable_aboutme},{id:"settings",name:_PST("photo","photo_str_management"),hidden:e||!PhotoStation.Auth.username},{id:"theme",name:_PST("photo","photo_theme_btnTheme"),hidden:e||!PhotoStation.Auth.is_admin}];var d=[];Ext.each(a,function(g){if(!g.hidden){d.push(g)}});this.setVisible(0
','','
',"{header}","
","
",'
',"
",'
',"
");return a},onBeforeSelect:function(b,e,d){var a=b.getRecord(e);if(PhotoStation.Define.BLOG==a.get("id")){window.open("../blog");var c=PhotoStation.HistoryManager.getToken();if(PhotoStation.Define.SMART_CATEGORY==c){this.select(0,false,true)}return false}if(b.isSelected(e)){return false}return true},onSelectionChange:function(b,c){if(1!==c.length){return}PhotoStation.Util.checkAuth();var a=b.getRecord(c[0]);Main.getScope("PhotoStation.LeftContent").clearSelections(this);Main.getScope("PhotoStation.ViewCard").containerLoad(a,true);PhotoStation.HistoryManager.add(a.get("id"));this.owner.hideOuterContainer()},getSmartAlbumsRecord:function(){return this.store.getAt(0)},highlightSmartAlbums:function(){this.select(0,false,true)},loadSmartAlbums:function(){this.select(0)},updateVisibility:function(){var a=[PhotoStation.DefaultData[PhotoStation.Define.SMART_CATEGORY]];this.store.loadData(a)}});PhotoStation.BottomDefaultList=Ext.extend(Ext.list.ListView,{constructor:function(a){Main.addScope("PhotoStation.BottomDefaultList",this);PhotoStation.BottomDefaultList.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){this.owner=b.owner;var a={cls:"default-list",store:this.createStore(),hideHeaders:true,singleSelect:true,internalTpl:this.getXTemplate(),columns:[{dataIndex:"name",tpl:"{name:htmlEncode}"}],listeners:{beforeselect:this.onBeforeSelect}};return Ext.apply(a,b)},createStore:function(){var a=new Ext.data.JsonStore({idProperty:"id",fields:["id","name","hidden"]});return a},getXTemplate:function(){var a=new Ext.XTemplate('
','','
',"{header}","
","
",'
',"
",'
',"
",'');return a},onBeforeSelect:function(b,d,c){var a=b.getRecord(d);if(PhotoStation.Define.BLOG==a.get("id")){window.open("../blog");return false}if(b.isSelected(d)){return false}return true},updateVisibility:function(){var a=[];if(PhotoStation.Info.enable_blog){a.push({id:PhotoStation.Define.BLOG,name:_PST("photo","photo_str_blog"),hidden:!PhotoStation.Info.enable_blog})}this.store.loadData(a)}});PhotoStation.CategoryList=Ext.extend(Ext.list.ListView,{constructor:function(a){Main.addScope("PhotoStation.CategoryList",this);PhotoStation.CategoryList.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){this.owner=b.owner;var a={cls:"category-list",store:this.createStore(),hideHeaders:true,singleSelect:true,tpl:this.getXTemplate(),columns:[{dataIndex:"name",tpl:"{name:htmlEncode}"},{align:"right",dataIndex:"id",width:0.4,isVisible:false}],listeners:{scope:this,beforeselect:this.onBeforeSelect,selectionchange:{fn:this.onSelectionChange,buffer:200},afterrender:{single:true,fn:function(c){this.dragZone=new PhotoStation.CategoryDragZone(c,{containerScroll:true,ddGroup:"CategoryDDGroup"});this.dropTarget=new PhotoStation.CategoryDropTarget(c,{ddGroup:"CategoryDDGroup"});this.mon(this.store,"load",this.updateScrollbar,this);this.mon(this.store,"remove",this.updateScrollbar,this)}}}};return Ext.apply(a,b)},updateScrollbar:function(b,a,c){this.owner.updateScrollbar()},createStore:function(){var a=new Ext.data.JsonStore({url:PhotoStation.Util.getWebAPIUrl("category.php"),baseParams:{api:"SYNO.PhotoStation.Category",method:"list",version:1,offset:0,limit:1000},root:"data.categories",idProperty:"id",totalProperty:"data.total",fields:["id","name","hidden"],listeners:{scope:this,beforeload:function(){this.el.mask()},load:function(c,b,e){if(0',"
",'',"",'
',' class="{cls}">',"{[values.tpl.apply(parent)]}","
","
","",'
','
','
',"
","
",'
',"
","");return a},clickDeleteCategory:function(b,d){var a=this.getRecordById(d);var c=Main.getScope("PhotoStation.SettingWindow");if(!c){c=new PhotoStation.SettingWindow()}this.owner.hideOuterContainer();Main.getScope("PhotoStation.SettingCategoryPanel").clickDeleteCategory(a);this.stopClickEvent(b)},clickEditCategory:function(b,d){var a=this.getRecordById(d);var c=Main.getScope("PhotoStation.SettingWindow");if(!c){c=new PhotoStation.SettingWindow()}this.owner.hideOuterContainer();c.show(a);this.stopClickEvent(b)},stopClickEvent:function(a){if(a.stopPropagation){a.stopPropagation()}else{if(window.event){window.event.cancelBubble=true}}},onBeforeSelect:function(a,c,b){if(a.isSelected(c)){return false}return true},onSelectionChange:function(b,c){if(1!==c.length){return}PhotoStation.Util.checkAuth();var a=b.getRecord(c[0]);log(a);Main.getScope("PhotoStation.LeftContent").clearSelections(this);Main.getScope("PhotoStation.ViewCard").containerLoad(a,true);this.owner.hideOuterContainer()},loadCategories:function(a){if(Ext.isFunction(a)){this.store.on("load",a,this,{single:true})}this.store.removeAll();this.store.load()},getRecordById:function(a){return this.store.getById(a)},loadCategoryByRecord:function(a){this.select(a)},highlightCategoryByRecord:function(a){this.select(a,false,true)},updateVisibility:function(){this.columns[1].isVisible=PhotoStation.Auth.is_admin;this.refresh()}});PhotoStation.LeftContent=Ext.extend(Ext.Container,{constructor:function(b){Main.addScope("PhotoStation.LeftContent",this);var a=this.fillConfig(b);PhotoStation.LeftContent.superclass.constructor.call(this,a)},fillConfig:function(b){this.owner=b.owner;var c={owner:this};var a={itemId:"leftContent",width:"100%",items:[this.searchField=this.createSearchField(),{itemId:"content",xtype:"panel",border:false,padding:"0 27px 0 0",items:[this.aboutMeList=new PhotoStation.AboutMeList(c),this.defaultList=new PhotoStation.DefaultList(c),this.bottomDefaultList=new PhotoStation.BottomDefaultList(c),{xtype:"box",itemId:"categoryPorfolio",cls:"category-porfolio",html:_PST("photo","photo_str_portfolio"),hidden:true},this.categoryList=new PhotoStation.CategoryList(c),new PhotoStation.LabelTextField({itemId:"addCategoryField",allowBlank:false,hidden:true,listeners:{scope:this,confirm:this.addCategory,cancel:function(d){d.setVisible(false)},confirmblank:function(d){d.setVisible(false)}}}),{itemId:"addCategoryBtn",xtype:"button",cls:"category-btn",tooltip:_PST("photo","photo_str_category_add_tip"),handler:this.clickAddCategory,scope:this}]}]};Ext.apply(a,b);return a},moveTo:function(a){this.owner.remove(this,false);a.add(this);this.owner=a;this.aboutMeList.updateVisibility()},resizeList:function(c){var b=this.owner,a=0;if(Main.getScope("PhotoStation.LeftPanel")===b){a=Ext.getBody().getViewSize().height-20;a-=b.getComponent("logoContainer").getOuterSize().height;a-=b.fbar.getOuterSize().height;this.setHeight(a);this.getComponent("content").bwrap.setHeight(a-this.searchField.getOuterSize().height-10)}else{a=Main.getScope("PhotoStation.CenterPanel").getContentTarget().getHeight();var d;if(a>670){d=670}else{d=a}this.setHeight(d);this.getComponent("content").bwrap.setHeight(d-this.searchField.getOuterSize().height-10)}this.updateScrollbar(c)},updateScrollbar:function(a){var b=this;var c=b.getComponent("content").bwrap.dom;if(this.isVisible()){if(c&&c.fleXcroll){if(a){c.fleXcroll.setScrollPos(false,0)}c.fleXcroll.updateScrollBars();if(!a){c.fleXcroll.setScrollPos(0,0,true)}}else{if(c){fleXenv.fleXcrollMain(c)}}}},createSearchField:function(){var a=new SYNO.ux.SearchField({width:188,hidden:true,listeners:{scope:this,keydown:this.keydownSearch},onSearchTriggerClick:function(b){Main.getScope("PhotoStation.LeftContent").clickAdvancedSearch()}});return a},clickAdvancedSearch:function(){var a=Main.getScope("PhotoStation.AdvancedSearchWindow");if(!a){a=new PhotoStation.AdvancedSearchWindow();a.on("search",this.doSearch,this);a.on("loadTag",function(){var b=this.searchField.getValue().trim(),c={};if(b){c.keyword=b;c.keyword_op="all"}a.smartPanel.setSmartValue(c);a.smartPanel.showDateRange()},this)}this.hideOuterContainer();a.show()},keydownSearch:function(c,b){if(Ext.EventObject.ENTER!==b.getKey()){return}var a=c.getValue().trim();if(!a){return}this.doSearch({keyword:a,keyword_op:"all"})},doSearch:function(c){if(!c){return}var b=PhotoStation.DefaultData[PhotoStation.Define.SEARCH_CATEGORY];b.search_params=c;var a=new Ext.data.Record(b,PhotoStation.Define.SEARCH_CATEGORY);this.hideOuterContainer();Main.getScope("PhotoStation.ViewCard").containerLoad(a,true)},clearSelections:function(b,a){var c=this.getComponent("content");c.items.each(function(d){if(d.clearSelections&&d!==b){d.clearSelections(a)}else{if(d.selModel&&d.selModel.clearSelections&&d!==b){d.selModel.clearSelections(a)}}})},clickAddCategory:function(){this.getComponent("content").getComponent("addCategoryField").show();this.getComponent("content").getComponent("addCategoryField").clickLabel()},addCategory:function(b,a){b.setText("");b.setVisible(false);if(!a){return}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Category","create",1,{name:a,hidden:false},this.addCategoryDone,this)},addCategoryDone:function(d,c,b,a){if(!d||!c){if(487==c.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_category_duplicated"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"))}return}Main.getScope("PhotoStation.CategoryList").loadCategories(function(){var e=Main.getScope("PhotoStation.LeftContent");if(e.owner.parentId){Ext.getCmp(e.owner.parentId).doLayout()}})},updateVisibility:function(){this.searchField.setVisible(!PhotoStation.Info.hide_search);this.getComponent("content").getComponent("addCategoryBtn").setVisible(!!PhotoStation.Auth.is_admin);this.aboutMeList.updateVisibility();this.defaultList.updateVisibility();this.bottomDefaultList.updateVisibility();if(this.selector&&PhotoStation.Auth.is_admin){this.getComponent("content").remove(1);this.selector=null}if(!this.selector){this.getComponent("content").insert(1,this.getFileSelector());this.doLayout()}else{this.reloadAlbums()}if(PhotoStation.Auth.username&&PhotoStation.Auth.allow_public_share){if(this.sharedAlbumSelector){this.getComponent("content").remove(3);this.sharedAlbumSelector=null}this.getComponent("content").insert(3,this.getSharedAlbumSelector());this.doLayout()}},doArrangeAlbums:function(){if(this.selector&&PhotoStation.Auth.is_admin){this.getComponent("content").remove(1);this.selector=null}if(!this.selector){this.getComponent("content").insert(1,this.getFileSelector());this.doLayout()}else{this.reloadAlbums()}},hideOuterContainer:function(){if(this.owner.parentId){Ext.getCmp(this.owner.parentId).hide()}},mask:function(){if(this.owner.isVisible()){this.getContentTarget().addClass("center-transparent-mask");this.owner.el.mask(_PST("photo","photo_str_loading")).addClass("transparent-mask")}},unmask:function(){this.getContentTarget().removeClass("center-transparent-mask");this.owner.el.unmask()},getFileSelector:function(){var b={ctCls:"album-panel",rootVisible:true,showCheck:false,useNativeScrollbar:true,sort_direction:PhotoStation.Util.getSortOrder(),sort_by:PhotoStation.Util.getSortType()};var a=PhotoStation.DefaultData[PhotoStation.Define.ALBUM_CATEGORY];if(!PhotoStation.Info.use_album_explorer){b=Ext.apply(b,{loader:new Ext.tree.TreeLoader(),root:new Ext.tree.AsyncTreeNode({id:PhotoStation.Define.ALBUM_CATEGORY,cls:"file-selector-root",draggable:false,allowDrop:false,children:[],expanded:true,record:new Ext.data.Record(Ext.apply({},{hidden:true,info:{conversion:true}},a)),text:_PST("photo","photo_str_category_albums")}),listeners:{scope:this,afterrender:{fn:function(c){var d="/"+PhotoStation.HistoryManager.getToken();c.selectPath(d)},single:true},click:this.onFileSelectorClick}})}else{b=Ext.apply(b,{enableDrop:true,ddGroup:"CategoryDDGroup",userPrivilege:"upload",disableInvalidNode:false,ddAppendOnly:true,enableTip:true,listeners:{scope:this,afterrender:{fn:function(c){this.mask();var d="/"+PhotoStation.HistoryManager.getToken();c.selectPath(d);c.dropZone.onNodeOut=function(i,f,h,g){f.setDefaultMessage()};c.dropZone.onContainerOver=function(h,i,g){var f=this.tree.nodeHash,j;if(f&&!PhotoStation.Auth.is_admin){Ext.iterate(f,function(e,m,k){if((PhotoStation.Define.ALBUM_CATEGORY===j&&!PhotoStation.Auth.is_admin)||m.attributes.invalid){m.getUI().addClass("photo-tree-node-invalid")}},this)}if(this.allowContainerDrop&&this.isValidDropPoint({ddel:this.tree.getRootNode().ui.elNode,node:this.tree.getRootNode()},"append",undefined,i,g)){return this.dropAllowed}return this.dropNotAllowed}},single:true},load:{fn:function(){this.resizeList();this.unmask()},single:true},expandnode:function(c){this.updateScrollbar()},collapsenode:function(c){this.updateScrollbar()},click:this.onFileSelectorClick,beforenodedrop:this.beforeNodeDrop,nodedragover:this.nodeDragOver}})}this.selector=new PhotoStation.FileSelector(b);return this.selector},getSharedAlbumSelector:function(){var a={ctCls:"album-panel",rootVisible:true,showCheck:false,useNativeScrollbar:true,sort_direction:"asc",sort_by:"filename",enableDrop:true,ddGroup:"CategoryDDGroup",disableInvalidNode:false,ddAppendOnly:true,enableTip:true,listeners:{scope:this,expandnode:function(b){this.updateScrollbar()},collapsenode:function(b){this.updateScrollbar()},click:this.onFileSelectorClick,beforenodedrop:this.beforeNodeDrop,nodeDragOver:this.nodeDragOver}};this.sharedAlbumSelector=new PhotoStation.SharedAlbumSelector(a);return this.sharedAlbumSelector},getAlbumsRecord:function(){return this.selector.getRootNode().attributes.record},getSharedAlbumsRecord:function(){return this.sharedAlbumSelector.getRootNode().attributes.record},highlightAlbums:function(){return this.selector.selectPath(this.selector.getRootNode().getPath())},highlightSharedAlbums:function(){return this.sharedAlbumSelector.selectPath(this.sharedAlbumSelector.getRootNode().getPath())},loadAlbums:function(){this.onFileSelectorClick(this.selector.getRootNode(),null)},loadSharedAlbums:function(){this.onFileSelectorClick(this.sharedAlbumSelector.getRootNode(),null)},onFileSelectorClick:function(b,d){this.clearSelections(this.selector);this.clearSelections(this.sharedAlbumSelector);var f=b.getDepth();var c=[b.attributes.record],g=b,a;for(a=0;a',cls:"logo-container",listeners:{afterrender:function(){this.getEl().on("click",function(){PhotoStation.HistoryManager.jumpToDefault()})},single:true}},this.leftContent=new PhotoStation.LeftContent({owner:this})],listeners:{scope:this,afterrender:function(){this.on("beforeexpand",function(){this.addClass("transition-effect")},this,{single:true})},beforeexpand:function(){this.doLayout();Main.getScope("PhotoStation.CenterPanel").hideLeftPanelBtns();this.addClass("left-panel-expand-collapse")},expand:function(){Main.getScope("PhotoStation.LeftContent").resizeList();var d=Main.getScope("PhotoStation.CenterPanel");d.updateLeftPanelBtns();this.removeClass("left-panel-expand-collapse");this.fbar.show()},beforecollapse:function(){Main.getScope("PhotoStation.CenterPanel").hideLeftPanelBtns();this.addClass("left-panel-expand-collapse")},collapse:function(){var d=Main.getScope("PhotoStation.CenterPanel");d.updateLeftPanelBtns();this.removeClass("left-panel-expand-collapse")},resize:function(e,i,g,f,h){var d=Main.getScope("PhotoStation.LeftContent");if(d.searchField.getWidth()>0){d.searchField.setWidth(i-32)}d.updateFleXcroll()}}};Ext.apply(b,c);return b},getFbar:function(){var a=new Ext.Toolbar({height:28,hideMode:"visibility",style:{padding:"4px 27px 0 0"},items:["->",{xtype:"button",cls:"left-panel-switch-btn photo-icon-btn",text:"",tooltip:_PST("photo","photo_str_left_panel_collapse"),handler:this.clickCollapseLeftPanel,scope:this}]});return a},clickCollapseLeftPanel:function(){Ext.util.Cookies.set("left-panel-visibility","hide");this.collapse();this.fbar.hide()},updateLogo:function(b){var a=function(){var c=Main.getScope("PhotoStation.LeftContent");Ext.defer(c.resizeList,100,c)};this.getComponent("logoContainer").update('',false,a)},updateVisibility:function(){if(this.leftContent){this.leftContent.updateVisibility()}},doArrangeAlbums:function(){if(this.leftContent){this.leftContent.doArrangeAlbums()}}});PhotoStation.CategoryDragZone=function(b,a){this.component=b;PhotoStation.CategoryDragZone.superclass.constructor.call(this,b.getEl(),a)};Ext.extend(PhotoStation.CategoryDragZone,Ext.dd.DragZone,{getDragData:function(c){if(!PhotoStation.Auth.is_admin){return false}var b=c.getTarget("dl");if(!b){return false}var d=document.createElement("div");d.className="rearrange-category-dd-preview-proxy";d.appendChild(b.cloneNode(true));var a={source:"category",target:b,index:Array.prototype.indexOf.call(b.parentNode.childNodes,b),ddel:d};Main.getScope("PhotoStation.ThumbnailView").dropTarget.lock();return a},getRepairXY:function(a){return Ext.Element.fly(this.dragData.target).getXY()},onInvalidDrop:function(a){PhotoStation.CategoryDragZone.superclass.onInvalidDrop.call(this,a);this.component.dropTarget.removeCategoryClass()},endDrag:function(a){Main.getScope("PhotoStation.ThumbnailView").dropTarget.unlock()}});PhotoStation.CategoryDropTarget=function(b,a){this.ddTarget=b;PhotoStation.CategoryDropTarget.superclass.constructor.call(this,b.getEl(),a)};Ext.extend(PhotoStation.CategoryDropTarget,Ext.dd.DropTarget,{ddTarget:null,notifyOver:function(a,c,b){if("category"===b.source){return this.notifyCategoryOver(a,c,b)}else{if("album"===b.source){return this.notifyAlbumOver(a,c,b)}}return false},notifyCategoryOver:function(k,i,g){var c=g.index,j=this.getCategoryDropIndex(i.getXY(),c);this.removeCategoryClass();var b=Ext.fly(this.ddTarget.getNode(g.index));if(!b){return false}b.addClass("drag-node");var d=j-1,h=j+1;if(jc){d++}var a=Ext.fly(this.ddTarget.getNode(d));if(a){a.addClass("prev-node")}var f=Ext.fly(this.ddTarget.getNode(h));if(f){f.addClass("next-node")}return true},notifyAlbumOver:function(c,f,d){if(!PhotoStation.Auth.is_admin){return false}var b=Ext.get(c.dragElId);b.removeClass("x-tree-drop-ok-append");var a=Ext.fly(f.getTarget()).parent("dl");if(a&&this.checkAlbumAllowDrop(a,d)){b.removeClass("x-dd-drop-ok").addClass("x-tree-drop-ok-append");return true}return false},notifyDrop:function(a,c,b){if("category"===b.source){return this.notifyCategoryDrop(a,c,b)}else{if("album"===b.source){return this.notifyAlbumDrop(a,c,b)}}a.endDrag();return false},notifyCategoryDrop:function(n,j,g){var b=g.index,k=this.getCategoryDropIndex(j.getXY(),b);this.removeCategoryClass();if(b===k){n.endDrag();return true}var m=this.ddTarget.store,h=[],a=Math.min(b,k),d=a;if(kb){h.push(m.getAt(b).get("id"))}this.doArrangeCategories(d,h,b,k);n.endDrag();return true},notifyAlbumDrop:function(c,h,g){if(!PhotoStation.Auth.is_admin){c.endDrag();return false}var b=Ext.fly(h.getTarget()).parent("dl");if(!b||false===this.checkAlbumAllowDrop(b,g)){c.endDrag();return false}var f=this.ddTarget.getRecord(b.dom).get("id");var a=[];for(var d=0;db){a--}if(a>=this.ddTarget.store.getCount()){a=this.ddTarget.store.getCount()-1}return a},removeCategoryClass:function(){var c=this.ddTarget.getEl().child(".drag-node");if(c){c.removeClass("drag-node")}var b=this.ddTarget.getEl().child(".prev-node");if(b){b.removeClass("prev-node")}var a=this.ddTarget.getEl().child(".next-node");if(a){a.removeClass("next-node")}},doArrangeCategories:function(d,c,b,a){this.mask();SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Category","arrangecategory",1,{offset:d,limit:c.length,category_id:c.join(",")},function(h,g,f,e){this.unmask();if(!h){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"));return}this.updateCategoryList(d,c,b,a)},this)},updateCategoryList:function(h,e,c,b){var a=this.ddTarget.store,d=a.getAt(c),g=a.getAt(c).copy(),f=this.ddTarget.isSelected(this.ddTarget.getNode(c));a.remove(d);a.insert(b,g);if(f){this.ddTarget.select(b,false,true)}this.ddTarget.owner.resizeList(false)},mask:function(){this.ddTarget.innerBody.addClass("center-transparent-mask");this.ddTarget.el.mask(_PST("photo","photo_str_processing")).addClass("transparent-mask")},unmask:function(){this.ddTarget.innerBody.removeClass("center-transparent-mask");this.ddTarget.el.unmask()}});Ext.ns("PhotoStation");PhotoStation.LightBox=Ext.extend(Ext.util.Observable,{panel:null,store:null,mouseStopTimer:null,aviaryReady:false,mousePos:[0,0],fullScreen:false,thumbScrollerHeight:88,slideshowSpeedTime:{fast:3500,medium:7000,slow:10000},slideshowDelayTime:3500,defaultEffect:(!Ext.isIE||Ext.isIE10||Ext.isIE11)?"dissolve":"fade",defaultMusicId:"off",dataPanelWidth:300,bbarHeight:40,constructor:function(a){this.effect=this.defaultEffect;this.dataStart=0;Main.addScope("PhotoStation.LightBox",this);PhotoStation.LightBox.superclass.constructor.call(this,a);l=this;this.lightBox=Ext.DomHelper.append(Ext.getBody(),{tag:"div",id:this.lightBoxId=Ext.id(),cls:"lightbox"});this.closeBtn=new Ext.Button({cls:"lightbox-close-btn",renderTo:this.lightBoxId,handler:this.clickHide,scope:this});this.panel=this.getMainPanel();this.flux=new flux.init("#"+this.photoPanelId,{width:this.displayPanel.getWidth(),height:this.displayPanel.getHeight(),displayWidth:this.displayPanel.getWidth()-4,"background-color":"rgb(20,20,20)",removeNode:false,onTransitionBegin:function(){var b=Main.getScope("PhotoStation.LightBox");b.isTransition=true}});Ext.get(this.lightBoxId).on("mousedown",this.onMouseDown,this);this.speedPanel=this.getSpeedPanel();this.scroller=this.getThumbScroller();this.getMusic();this.musicPlayer=new PhotoStation.MusicPlayer({container:this.panel});Ext.EventManager.onWindowResize(function(){this.resizeLightBox()},this,{buffer:200});this.createHotKeys();this.addEvents("startslideshow","stopslideshow","pauseslideshow","startzoom","stopzoom")},onMouseDown:function(b,d,c){var a=d.className;if(a=="lightbox"){this.clickHide()}},createHotKeys:function(){var b=Ext.getBody();var a=[];a.push(b.addKeyListener([37],this.clickPrev,this));a.push(b.addKeyListener([39],this.clickNext,this));a.push(b.addKeyListener([27],this.clickHide,this));this.keyMaps=a},disableHotKeys:function(a){if(!this.keyMaps){return}for(var b=0;b",{itemId:"showOnScreenDisplay",xtype:"button",cls:"lightbox-info-btn",style:{marginRight:"16px"},scope:this,handler:function(g,h){var f=!PhotoStation.Util.isShowSlideshowInfo();if(f){g.el.addClass("lightbox-info-btn-down")}else{g.el.removeClass("lightbox-info-btn-down")}this.updateOnScreenDisplay(this.store.getAt(this.index));this.clickInfo(g,f)}},{itemId:"viewOriginal",xtype:"button",cls:"lightbox-fullsize-btn",handler:this.clickViewOriginal,scope:this}]}]},{itemId:"dataPanel",xtype:"panel",cls:"lightbox-data-panel",layout:"table",layoutConfig:{columns:1},region:"east",defaults:{width:280},border:false,width:this.dataPanelWidth,padding:10,items:[{itemId:"title",cls:"lightbox-data-title",xtype:"labeltextfield",allowBlank:false,listeners:{scope:this,confirm:this.modifyTitle,showTextField:function(){this.disableHotKeys(true)},hideTextField:function(){this.disableHotKeys(false)}}},{itemId:"desc",cls:"lightbox-data-desc",xtype:"labeltextfield",emptyText:"",editType:"textarea",editInPopWindow:PhotoStation.Info.use_pop_window_to_edit_desc,listeners:{scope:this,confirm:this.modifyDesc,showTextField:function(){this.disableHotKeys(true)},hideTextField:function(){this.disableHotKeys(false)}}},this.tagPanel=new PhotoStation.LightBoxTagPanel({lightBoxId:this.lightBoxId,imgCls:"lightbox-img"}),new PhotoStation.LightBoxInfoPanel(),new PhotoStation.LightBoxCommentPanel()],listeners:{buffer:200,collapse:this.resizeLightBox.createDelegate(this),expand:this.resizeLightBox.createDelegate(this),afterlayout:{fn:function(f){var g=f.updateScrollbar.createDelegate(f,[],true,{buffer:200});f.on("resize",g);f.mon(f.getComponent("tagPanel").geoTagArea,"rendertag",g);f.mon(f.getComponent("tagPanel").peopleTagArea,"rendertag",g);f.mon(f.getComponent("tagPanel").descTagArea,"rendertag",g);f.mon(f.getComponent("tagPanel"),"expand",g);f.mon(f.getComponent("tagPanel"),"collapse",g);f.mon(f.getComponent("commentPanel"),"expand",g);f.mon(f.getComponent("commentPanel"),"collapse",g);f.mon(f.getComponent("commentPanel"),"afterlayout",g);f.mon(f.getComponent("commentPanel"),"destroy",g);f.mon(f.getComponent("infoPanel"),"expand",g);f.mon(f.getComponent("infoPanel"),"collapse",g)},single:true}},updateScrollbar:function(){if(this.isVisible()){var f=this.body.dom;if(f&&f.fleXcroll){f.fleXcroll.updateScrollBars();f.fleXcroll.setScrollPos(0,0,true)}else{if(f){fleXenv.fleXcrollMain(f)}}f=null}}}],listeners:{resize:{fn:this.resizeLightBox,scope:this,buffer:200},afterrender:{fn:function(f){this.displayPanel=f.getComponent("displayPanel");this.loading=this.displayPanel.getComponent("loading");this.img=this.displayPanel.getComponent("photoPanel").getComponent("img");this.videoPanel=this.displayPanel.getComponent("videoPanel");this.prevBtn=this.displayPanel.getComponent("prevBtn");this.nextBtn=this.displayPanel.getComponent("nextBtn");this.slideshowInfo=this.displayPanel.getComponent("onScreenDisplay");this.actionBar=this.displayPanel.getComponent("actionBar");this.dataPanel=f.getComponent("dataPanel");this.title=this.dataPanel.getComponent("title");this.desc=this.dataPanel.getComponent("desc");this.infoPanel=this.dataPanel.getComponent("infoPanel");this.commentPanel=this.dataPanel.getComponent("commentPanel");this.qualitySelector=this.actionBar.getComponent("qualitySelector");this.bbar=f.getBottomToolbar();this.slideshowPanel=this.displayPanel.getComponent("slideshowPanel");this.fullScreenBtn=this.displayPanel.getComponent("fullScreenBtn");this.videoPlayer=new PhotoStation.VideoPlayer({container:this.videoPanel});this.videoPlayer.on("playerready",this.videoPlayerReady,this);this.qualitySelector.on("changequality",function(h){this.updateVideoRotateBtns(true,h.container,h.profile_name);this.videoPlayer.startPlay(this.store.getAt(this.index),h)},this);this.videoPanel.on("resize",function(){var h=this.videoPlayer.quality?this.videoPlayer.quality.container:undefined;this.videoPlayerReady(h,this.videoRotateAngle)},this,{buffer:100});this.img.el.on("load",function(){this.imgLoadEnd=true;this.loading.el.hide();this.resizeImageEl();var h=this;if(!this.flux.options.onTransitionEnd){this.flux.options.onTransitionEnd=function(){h.fluxTransitionEnd()};this.tagPanel.peopleTagArea.resize();this.renewSlideShowTimer("photo");this.flux.setupImages();this.img.show()}},this);this.img.el.on("click",function(){if("play"!==this.slideMode){this.clickNext()}},this);this.img.el.on("mousewheel",function(i,k){var m=i.getWheelDelta(),h=this.store.getAt(this.index),j=this.useImageOriginalDimensions(h);if(!j){j={width:h.get("additional").thumb_size.large.resolutionx,height:h.get("additional").thumb_size.large.resolutiony}}if(j.width!==this.img.getWidth()&&!this.zoomMode&&m>0){this.enterZoomMode(m,i.getXY())}},this);f.doLayout();var g=this;this.actionBar.el.on("transitionend",function(h){g.alignOnScreenDisplay()});this.slideshowInfo.getComponent("general").getComponent("readAll").el.on("click",this.descriptionExpandCollapse,this);this.displayPanel.el.on("mouseout",function(h,i){if(!this.displayPanel.el.hasClass("lightbox-display-panel-over")&&(this.actionBar.getComponent("share").menu.isVisible()||this.actionBar.getComponent("action").menu.isVisible()||this.actionBar.getComponent("editor").menu.isVisible())){this.displayPanel.el.addClass("lightbox-display-panel-over")}},this)},scope:this,single:true}}})},descriptionExpandCollapse:function(){var b=this.slideshowInfo.getComponent("general");var a=b.getComponent("readAll");if(a.expanded){b.getComponent("desc").update(a.desc);a.update(_PST("photo","blog_article_read_all"))}else{var c=b.getComponent("desc");a.desc=c.body.dom.innerHTML;c.update(Ext.util.Format.htmlEncode(this.store.getAt(this.index).data.info.description));a.update(_PST("photo","photo_str_collapse"))}a.expanded=!a.expanded;this.alignOnScreenDisplay()},getBbar:function(){return new Ext.Toolbar({height:this.bbarHeight,hideMode:"visibility",items:[{itemId:"containerTitle",cls:"container-title",xtype:"tbtext"}," ",{itemId:"containerCount",cls:"container-count",xtype:"tbtext"},"->",{itemId:"thumbScrollerBtn",text:_PST("photo","photo_str_view_all"),cls:"thumb-scroller-btn",enableToggle:true,toggleHandler:function(a,b){this.scroller.setVisible(b);this.scroller.el.setVisible(b,{duration:0.2});if(b){this.loadNearThumbnails();if(this.bbar.isVisible()){this.actionBar.toggleUp=true;this.actionBar.el.setBottom(""+this.thumbScrollerHeight+"px");this.scroller.el.alignTo(this.bbar.el,"b-t")}else{this.scroller.el.alignTo(Ext.getBody(),"b-b")}this.updateThumbScroller()}else{this.actionBar.toggleUp=false;this.actionBar.el.setBottom("0")}this.alignOnScreenDisplay()},scope:this}]})},getSpeedPanel:function(){var b;var e=Ext.util.Cookies.get("slideshow-speed")||"fast";this.slideshowDelayTime=this.slideshowSpeedTime[e]||this.slideshowSpeedTime.fast;var d=[],a;var c={bars:_PST("photo","photo_str_bars"),bars3d:_PST("photo","photo_str_bars3d"),blinds:_PST("photo","photo_str_blinds"),blinds3d:_PST("photo","photo_str_blinds3d"),zip:_PST("photo","photo_str_zip"),blocks:_PST("photo","photo_str_blocks"),blocks2:_PST("photo","photo_str_blocks2"),concentric:_PST("photo","photo_str_concentric"),warp:_PST("photo","photo_str_warp"),cube:_PST("photo","photo_str_cube"),tiles3d:_PST("photo","photo_str_tiles3d"),turn:_PST("photo","photo_str_turn"),slide:_PST("photo","photo_str_slide"),swipe:_PST("photo","photo_str_swipe"),dissolve:_PST("photo","photo_str_dissolve"),fade:_PST("photo","photo_str_dissolve")};if(this.flux){d.push({itemId:"random",text:_PST("photo","photo_str_random"),group:"effect",checked:this.effect==="random",checkHandler:this.clickTransitionEffect.createDelegate(this,["random"]),scope:this});for(b=0;b0;if(0.2*b<250&&h){d=0.6*b;this.prevBtn.setHeight(d);this.nextBtn.setHeight(d);m.getComponent("prevBtn").el.alignTo(m.el,"bl-bl",[0,-200]);m.getComponent("nextBtn").el.alignTo(m.el,"br-br",[-4,-200]);Ext.get(this.prevBtn.el.query("button")[0]).setStyle("bottom",(b/2-231)+"px");Ext.get(this.nextBtn.el.query("button")[0]).setStyle("bottom",(b/2-231)+"px")}else{if(!h){d=64}else{d=0.6*b}this.prevBtn.setHeight(d);this.nextBtn.setHeight(d);m.getComponent("prevBtn").el.alignTo(m.el,"l-l");m.getComponent("nextBtn").el.alignTo(m.el,"r-r");Ext.get(this.prevBtn.el.query("button")[0]).setStyle("bottom","0px");Ext.get(this.nextBtn.el.query("button")[0]).setStyle("bottom","0px")}m.getComponent("actionBar").el.alignTo(m.el,"b-b");var j=Ext.isChrome&&Ext.isWindows&&PhotoStation.Util.isFullScreen()?75:0;m.getComponent("slideshowPanel").el.alignTo(m.el,"t-t",[0,j]);m.getComponent("fullScreenBtn").el.alignTo(m.el,"tr-tr",[-8,0]);if(this.isZoomMode()){this.zoomResize()}Main.getScope("PhotoStation.LightBoxTagPanel").resize()},resizeImageEl:function(){var f=Main.getScope("PhotoStation.LightBox"),b=f.panel;var k=b.getComponent("displayPanel"),a=k.getWidth(),j=k.getHeight(),d=this.img.el;var m=a-4,e=j,i,n;i=this.store.getAt(this.index);if(!i){return}n=this.useImageOriginalDimensions(i);var h="photo"===i.get("type")?this.getRotateAngle(i):0;if(n){var c=e,g=m;if(90===h||270===h){c=m;g=e}d.applyStyles("max-width: "+Math.min(g,n.width)+"px; max-height: "+Math.min(c,n.height)+"px;")}else{d.applyStyles("max-width: "+m+"px; max-height: "+e+"px;")}this.applyRotation(h,d);d.setXY(this.getImageAlignXY(d,k.el,h));if(this.flux&&(this.flux.width!=m||this.flux.height!=e)){this.flux.resize(a,j,m,e)}},videoPlayerReady:function(b,c){var a=this.store.getAt(this.index);if(!a||"video"!==a.get("type")){return}if("mp4"!==b){this.videoPlayer.resizeVideoPlayer()}else{this.rotateVideoEl(a,c)}},rotateVideoEl:function(a,f){var d=0,b=this.displayPanel.getWidth(),e=this.displayPanel.getHeight(),c=this.videoPlayer.getVideoEl();d=undefined!==f?f:this.getRotateAngle(a);if(!c){return}this.videoRotateAngle=d;if(90===d||270===d){c.setSize(e-46,b-4)}else{c.setSize(b-4,e-46)}this.videoPlayer.resizeVideoPlayer();this.applyRotation(d,c);c.setXY(this.getImageAlignXY(c,Ext.fly(c.dom.parentElement),d))},updateVideoRotateBtns:function(e,b,d){var a=e&&"html5"===this.videoPlayer.getPlayMode(b,d),c=this.actionBar.getComponent("action");c.menu.getComponent("videoRotate90").setVisible(a);c.menu.getComponent("videoRotate270").setVisible(a);c.menu.getComponent("videoRotate180").setVisible(a);if(c.menu.el){c.menu.el.show();c.menu.doLayout(true)}},removeEmptyDoms:function(){if(!this.dataPanel){return}var c=this.dataPanel.getEl().query("td.x-table-layout-cell");var b;for(var a=0;a0||b.isShowConversionPrompt())){b.show()}a.focus(false,true)},show:function(g,c,f){if(this.store){this.store.destroy()}if(Ext.isEmpty(c)){c=Main.getScope("PhotoStation.ViewCard").store}this.store=new Ext.data.Store({recordType:c.recordType,totalLength:c.totalLength});c.each(function(h){this.store.add(h)},this);var b=Main.getScope("PhotoStation.CenterPanel").getPagingToolbar();if(PhotoStation.Info.paging_use_bar){this.windowStart=b.cursor;this.windowSize=this.store.getCount()}else{this.windowStart=0;this.windowSize=this.store.getCount()}this.filterRemoveCount=0;this.store.filterBy(this.lightBoxFilter);var a=this.store.getById(g);if(!a){return}if(Ext.isIE){this.panel.show()}this.slideMode="stop";this.clearFluxEffect();this.effect=this.defaultEffect;var e=PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("manage");this.prevIndex=this.index=this.store.indexOf(a);this.title.allowEdit=e;this.desc.allowEdit=e;this.bbar.getComponent("containerTitle").setText(Ext.util.Format.htmlEncode(PhotoStation.CurrentBrowse.getTitle()));this.initThumbScroller();this.imgLoadEnd=false;this.showLoadingImage();this.setImagesToFlux([this.index,this.index+1,this.index-1]);Ext.get(this.lightBoxId).applyStyles("opacity: 1; filter: 'Alpha(opacity=100)';");Ext.get(this.lightBoxId).setVisible(true);this.fireEvent("show");this.disableHotKeys(false);var d=Main.getScope("PhotoStation.SelectAllWindow");if(d){d.hide()}if(PhotoStation.Util.isHideInformation()){this.setDataPanelVisible(false,false)}else{this.setDataPanelVisible(true,false)}this.removeEmptyDoms();if("slideshow"===f||PhotoStation.LightBox.AutoSlideShow===true){PhotoStation.LightBox.AutoSlideShow=false;this.startSlideShow();this.backToAlbum=true}else{this.updateComponents()}this.resizeLightBox();if(PhotoStation.Util.isShowSlideshowInfo()){this.actionBar.getComponent("showOnScreenDisplay").el.addClass("lightbox-info-btn-down")}else{this.actionBar.getComponent("showOnScreenDisplay").el.removeClass("lightbox-info-btn-down")}this.updateOnScreenDisplay(a)},loadMore:function(){var e=Math.round(this.scroller.getWidth()/84/2);e=Math.max(e,5);if(PhotoStation.Util.isSpecialView()){if(Ext.isFunction(Main.getScope("PhotoStation.ViewCard").layout.activeItem.needLoadMore)){if(Main.getScope("PhotoStation.ViewCard").layout.activeItem.needLoadMore(this.index,e)){Main.getScope("PhotoStation.ViewCard").layout.activeItem.loadMore({index:this.index,windowSize:e})}}}else{var b=this.store.getTotalCount(),c=0,a=0;if(b<=this.windowSize){return}if(this.windowStart+this.windowSize<=b&&this.windowStart+this.index=this.windowSize-b+this.windowStart){a=(this.index-this.windowSize+b-e)%b;c=(this.index-this.windowSize+b+e)%b}else{a=(this.index-e+b)%b;c=(this.index+e+b)%b}}var d={offset:0,limit:PhotoStation.Info.paging_use_bar?PhotoStation.Info.paging_item_count:PhotoStation.Define.MAX_ITEM_LIMIT};if((this.windowStart+this.windowSize>=b&&c>=(this.windowStart+this.windowSize)%b&&c=this.windowStart+this.windowSize)){d.offset=(this.windowStart+this.windowSize)%b;d.insertOffset=(this.windowStart+this.windowSize>=b)?d.offset:this.store.getCount();Main.getScope("PhotoStation.ViewCard").layout.activeItem.loadMore(d)}else{if(a>0&&((this.windowStart+this.windowSize>=b&&a(this.windowStart+this.windowSize)%b)||(this.windowStart+this.windowSizeb?this.windowSize+this.windowStart-b:0;Main.getScope("PhotoStation.ViewCard").layout.activeItem.loadMore(d)}}}},loadMoreCallback:function(f,c,b){var e=this.store.getCount();var d;var g=this.store.getAt(this.index).get("id");if(!c){c=Main.getScope("PhotoStation.ViewCard").layout.activeItem.store;for(d=f;da.get("thumbnail_status").indexOf("large")){Main.getScope("PhotoStation.LightBox").filterRemoveCount++;return false}return true}else{if("video"===a.get("type")){if(PhotoStation.VideoPlayer.Util.filterQualities(a.get("additional").video_quality).length){return true}else{if("flv"===a.get("additional").video_codec.container){return true}}Main.getScope("PhotoStation.LightBox").filterRemoveCount++;return false}}Main.getScope("PhotoStation.LightBox").filterRemoveCount++;return false},initThumbScroller:function(){Ext.get(this.scrollerInnerId).update("");var a=0;this.store.each(function(b){var c=Ext.get(this.scrollerInnerId).createChild({tag:"div",cls:"thumb-scroller-div"});c.addClassOnOver("thumb-scroller-div-over");c.dom.onclick=this.gotoId.createDelegate(this,[b.get("id")]);c.createChild({tag:"img",cls:"thumb-scroller-img "+this.getScrollerImgClass(b.get("id")),src:Ext.BLANK_IMAGE_URL,thumbnails:this.getThumbUrl("small",b.json)});if("video"===b.get("type")){c.createChild({tag:"img",cls:"thumb-scroller-videoicon",src:PhotoStation.Util.getImgUrl("icon_video.png")})}a++},this);Ext.get(this.scrollerInnerId).setWidth(this.store.getCount()*84)},loadNearThumbnails:function(){var a,c=Math.round(this.scroller.getWidth()/84/2);c=c===0?8:c;var d=Ext.get(this.scrollerInnerId);for(a=this.index-c;a<=this.index+c;a++){if(a<0||a>=this.store.getCount()){continue}var b=d.child(":nth-child("+(a+1)+")");this.onLoadItem(b)}},onLoadItem:function(c){var b=c.select("img"),a;if(b.select("img").elements.length>0){a=b.select("img").elements[0];if(!a.loaded){this.setImgURL(a)}}},setImgURL:function(b){var d;Ext.fly(b).on("load",function c(){this.onImageLoad(b);Ext.fly(b).removeListener("load",c)},this);Ext.fly(b).on("error",function a(){this.onImageError(b);Ext.fly(b).removeListener("error",a)},this);d=b.getAttribute("thumbnails");if(d){b.src=d;b.removeAttribute("thumbnails")}},onImageLoad:function(a){if(a.loaded){return}if(a.height>a.width){a.style.width="72px";a.style.height=""}else{a.style.width="";a.style.height="72px"}a.loaded=true},onImageError:function(a){a.src=Ext.BLANK_IMAGE_URL},clickFullScreen:function(){if(this.fullScreen){this.setDataPanelVisible(true,true)}else{this.setDataPanelVisible(false,true)}},setDataPanelVisible:function(a,b){if(a){this.dataPanel.expand(false);this.fullScreenBtn.setIconClass("lightbox-fullscreen-icon");this.fullScreen=false;if(b){Ext.util.Cookies.set("photo-lightbox-fullscreen",false)}this.dataPanel.doLayout();this.clickInfo(null,false);this.actionBar.getComponent("showOnScreenDisplay").hide().getEl().removeClass("lightbox-info-btn-down")}else{this.dataPanel.collapse(false);this.fullScreenBtn.setIconClass("lightbox-close-fullscreen-icon");this.fullScreen=true;if(b){Ext.util.Cookies.set("photo-lightbox-fullscreen",true)}this.actionBar.getComponent("showOnScreenDisplay").show()}},startSlideShow:function(){if(!this.slideshowTask){this.slideshowTask=new Ext.util.DelayedTask((this.slideshowPlay).createDelegate(this,[],true),this)}if(!this.updateSlideshowButtonsVisibleTask){this.updateSlideshowButtonsVisibleTask=new Ext.util.DelayedTask(this.updateSlideshowButtonsVisible,this)}this.slideMode="play";PhotoStation.Util.launchFullScreen(document.documentElement);Ext.getDoc().on("mousemove",this.mouseMoveFunc=(this.onMouseMove).createDelegate(this,[],true));Ext.getDoc().on("mouseenter",this.onMouseEnter,this);this.closeBtn.setVisible(false);this.setDataPanelVisible(false,false);this.bbar.setVisible(false);this.actionBar.setVisible(false);this.bbar.getComponent("thumbScrollerBtn").toggle(true);this.slideshowPanel.setVisible(true);this.slideshowPanel.getComponent("playBtn").setVisible(false);this.slideshowPanel.getComponent("pauseBtn").setVisible(true);this.speedPanel.setVisible(true);var b=Ext.getCmp(this.musicId),f=null===this.musicPlayer.getLastMusicId()?this.defaultMusicId:this.musicPlayer.getLastMusicId();b.menu.items.get(f).setChecked(true,true);this.musicPlayer.setMusic(f);if("photo"===this.store.getAt(this.index).get("type")){this.musicPlayer.play()}this.effect=this.getEffect();var d,e=Ext.getCmp(this.effectId);if(!(d=e.menu.items.get(this.effect))){d=e.menu.items.get(this.defaultEffect);this.effect=this.defaultEffect}d.setChecked(true);var a=Ext.getCmp(this.slideshowInfoBtnId),c=PhotoStation.Util.isShowSlideshowInfo();a.setChecked(c);this.slideshowInfo.setVisible(c);this.fullScreenBtn.setVisible(false);this.gotoIndex(this.index);this.fireEvent("startslideshow")},clickPlayPause:function(){if("play"===this.slideMode){this.slideMode="pause";this.slideshowTask.cancel();this.slideshowPanel.getComponent("playBtn").setVisible(true);this.slideshowPanel.getComponent("pauseBtn").setVisible(false);this.musicPlayer.pause();this.img.show();this.fireEvent("pauseslideshow")}else{this.slideMode="play";var a=this.store.getAt(this.index);if("photo"===a.get("type")||("video"===a.get("type")&&!this.videoPlayer.isPlay)){this.slideshowTask.delay(0,undefined,undefined,[true])}this.slideshowPanel.getComponent("playBtn").setVisible(false);this.slideshowPanel.getComponent("pauseBtn").setVisible(true);this.musicPlayer.play();this.fireEvent("startslideshow")}this.slideshowPanel.doLayout()},stopSlideShow:function(a){var b=this;this.slideMode="stop";this.effect=this.defaultEffect;clearTimeout(this.mouseStopTimer);Ext.getDoc().removeListener("mousemove",this.mouseMoveFunc);Ext.getDoc().removeListener("mouseenter",this.onMouseEnter);if(this.slideshowTask){this.slideshowTask.cancel()}if(this.updateSlideshowButtonsVisibleTask){this.updateSlideshowButtonsVisibleTask.cancel()}this.musicPlayer.stop();if(this.isTransition){this.flux.options.onTransitionEnd=function(){b.clearFluxEffect();b.hideSlideShowLayout(a);b.flux.options.onTransitionEnd=function(){b.fluxTransitionEnd()}}}else{this.hideSlideShowLayout(a)}},hideSlideShowLayout:function(a){PhotoStation.Util.exitFullScreen();if(!PhotoStation.Util.isHideInformation()){this.setDataPanelVisible(true,false)}this.closeBtn.setVisible(true);this.nextBtn.setVisible(true);this.prevBtn.setVisible(true);this.bbar.setVisible(true);this.actionBar.setVisible(true);this.flux.setCursorVisible(true);this.bbar.getComponent("thumbScrollerBtn").toggle(false);this.fullScreenBtn.setVisible(true);this.slideshowPanel.setVisible(false);this.speedPanel.setVisible(false);this.slideshowInfo.setVisible(PhotoStation.Util.isShowSlideshowInfo());if(!a){this.gotoIndex(this.index);this.resizeLightBox()}this.fireEvent("stopslideshow")},closeSlideShow:function(){if(this.backToAlbum){this.clickHide()}else{this.stopSlideShow()}this.backToAlbum=false},slideshowPlay:function(){if("play"===this.slideMode){this.gotoIndex((this.index+1)%this.store.getCount())}},clickInfo:function(a,b){Ext.util.Cookies.set("slideshow-info",b?"true":"false");this.slideshowInfo.setVisible(b);this.updateOnScreenDisplay(this.store.getAt(this.index))},clickReadAll:function(){},clickCollapseDescription:function(){},setSlideshowInfoCollapse:function(c){var b=this.slideshowInfo.getComponent("description"),g=b.getSize(),d=b.getValue(),a=false;if(c){b.removeClass("share-lightbox-description-readall").setHeight(this.slideshowInfoDescHeight)}else{this.slideshowInfoDescHeight=b.getHeight();this.slideshowInfoHeight=this.slideshowInfo.getHeight();b.addClass("share-lightbox-description-readall");var f=PhotoStation.TextMetrics.measure(b.getEl(),d,g.width);b.setHeight(f.height)}var e=PhotoStation.TextMetrics.measure(b.el,d);if(e.width>g.width){a=true}else{a=false}this.slideshowInfo.getComponent("readAll").setVisible(a&&c);this.slideshowInfo.getComponent("collapseDesc").setVisible(a&&!c);this.slideshowInfo.doLayout()},clickSpeed:function(a,b){if(b){var c=Main.getScope("PhotoStation.LightBox");c.slideshowDelayTime=c.slideshowSpeedTime[a.itemId];Ext.util.Cookies.set("slideshow-speed",a.itemId)}},onMouseEnter:function(a){this.alignOnScreenDisplay()},onMouseMove:function(a){if(!a){return}if(undefined!==this.mousePos&&this.mousePos[0]==a.getPageX()&&this.mousePos[1]==a.getPageY()){return}this.updateSlideshowButtonsVisibleTask.delay(50,this.updateSlideshowButtonsVisible,this,[true]);this.renewMouseTimer();this.mousePos=a.getXY()},updateSlideshowButtonsVisible:function(a){if(!a){this.alignOnScreenDisplay()}this.flux.setCursorVisible(a);this.nextBtn.setVisible(a);this.prevBtn.setVisible(a);this.slideshowPanel.setVisible(a);this.speedPanel.setVisible(a);this.bbar.getComponent("thumbScrollerBtn").toggle(a)},onMouseStop:function(){this.updateSlideshowButtonsVisible(false)},renewMouseTimer:function(){if(this.mouseStopTimer){clearTimeout(this.mouseStopTimer)}this.mouseStopTimer=setTimeout((this.onMouseStop).createDelegate(this,[],true),2000)},clickJumpPrev:function(){var b=Math.round(this.scroller.getWidth()/84/2);var a=this.index-b;if(a<0){a=0}this.gotoIndex(a)},clickJumpNext:function(){var b=Math.round(this.scroller.getWidth()/84/2);var a=this.index+b;if(a>=this.store.getCount()){a=this.store.getCount()-1}this.gotoIndex(a)},clickPrev:function(){if("stop"!==this.slideMode){this.renewMouseTimer()}this.gotoIndex(this.index-1)},clickNext:function(){if("stop"!==this.slideMode){this.renewMouseTimer()}this.gotoIndex(this.index+1)},gotoIndex:function(b){if(0>b||this.store.getCount()-11){g.setImagesToFlux([g.prevIndex,b])}g.prevIndex=b;g.loading.el.hide()}return h}};var f=this.store.getAt(d),e=this.store.getAt(this.index);if("video"===e.get("type")){this.prevIndex=null;this.clearFluxEffect()}else{var c=this.effect;if(!Ext.isIE8&&!Ext.isIE9&&(this.useOriginalAsLargeThumb(f)||this.useOriginalAsLargeThumb(e))){c="dissolve"}if(f&&"photo"!==f.get("type")){this.setImagesToFlux([this.index,this.index+1,this.index-1]);this.flux.setupImages()}else{if(b-d===1){this.setImagesToFlux([d,this.index,this.index+1,d-1]);this.flux.next(c,a)}else{if(d-b===1){this.setImagesToFlux([d,d+1,this.index-1,this.index]);this.flux.prev(c,a)}else{if(Math.abs(b-d)>1){this.setImagesToFlux([d,this.index]);this.flux.next(c,a)}else{this.flux.setupImages();this.img.show()}}}}}this.updateComponents();this.updateOnScreenDisplay(e)},gotoId:function(b){for(var a=0;athis.index){this.img.setVisible(false);if(!this.isTransition){this.clearFluxEffect()}this.videoPanel.setVisible(false);this.bbar.getComponent("containerTitle").setText("");this.bbar.getComponent("containerCount").setText("");this.bbar.getComponent("thumbScrollerBtn").toggle(false);return}var a=this.store.getAt(this.index);this.updateUrl(a);if("photo"===a.get("type")){this.videoPanel.setVisible(false);this.qualitySelector.updateMenu();var h=this.getThumbUrl("large",a.json);var f=this.img.el.dom.src;var g=this;if(h.substr(h.lastIndexOf("/"))==f.substr(f.lastIndexOf("/"))){this.imgLoadEnd=true;if(!this.flux.options.onTransitionEnd){this.flux.options.onTransitionEnd=function(){g.fluxTransitionEnd()};this.flux.setupImages();this.img.show()}this.resizeImageEl();this.renewSlideShowTimer("photo")}else{this.img.el.dom.src=h}}else{if("video"===a.get("type")){this.loading.hide();this.renewSlideShowTimer("video");this.img.setVisible(false);if(!this.videoPanel.isVisible()){this.videoPanel.setVisible(true);this.resizeLightBox.defer(100,this)}this.qualitySelector.updateMenu(a.get("additional").video_quality,a.get("additional").video_codec);this.qualitySelector.changeQuality()}}this.tagPanel.updateTagPanel(a.get("id"));var d=a.get("info");var c=d.description?d.description.trim():"",e=d.title.trim();if("stop"===this.slideMode){this.commentPanel.updateCommentList(a.id);if("photo"===a.get("type")){this.infoPanel.setTitle(_PST("photo","photo_str_image_information"));this.infoPanel.updateExifList(a.get("id"));this.infoPanel.exifBtn.show();if(this.exifShow){this.infoPanel.exifList.show()}}else{if("video"===a.get("type")){this.infoPanel.setTitle(_PST("photo","photo_str_video_information"));this.infoPanel.exifBtn.hide();this.infoPanel.exifList.hide()}}this.desc.emptyText=b?_PST("photo","photo_str_add_description"):"";this.title.setText(e);this.desc.setText(c);if(a.get("additional")){this.infoPanel.updateInfoList(a)}this.updateActionBar();this.updateControlAndThumbnails()}else{this.updateOnScreenDisplay(a)}},updateControlAndThumbnails:function(){this.prevBtn.setDisabled(0>=this.index);this.nextBtn.setDisabled(this.store.getCount()-1<=this.index);var c=this.store.getTotalCount(),a=0;if(this.windowStart+this.windowSize<=c&&this.windowStart+this.indexc&&this.index>=this.windowSize-c+this.windowStart){a=this.windowStart-this.windowSize+c-this.windowStart}else{a=0}}var b=(PhotoStation.Util.isSpecialView()?this.dataStart:a)+this.index+1;this.bbar.getComponent("containerCount").setText(String.format("{0} / {1}",b,c-this.filterRemoveCount));if(this.scroller.isVisible()){this.updateThumbScroller();this.loadNearThumbnails()}if(this.slideshowInfo.isVisible()){this.alignOnScreenDisplay()}this.loadMore()},updateUrl:function(a){var b=Main.getScope("PhotoStation.SimplePathBar").getPathItemString()+"/"+a.get("id");if("stop"!==this.slideMode){b=b+"/slideshow"}if(b===PhotoStation.HistoryManager.getToken()&&!this.historyCount){this.historyCount=1}else{if(b!==PhotoStation.HistoryManager.getToken()){this.historyCount=(this.historyCount||0)+1}}PhotoStation.HistoryManager.add(b)},updateThumbScroller:function(){var b=Ext.get(this.scrollerInnerId);while(b.child(".thumb-scroller-div-selected")){b.child(".thumb-scroller-div-selected").removeClass("thumb-scroller-div-selected")}if(b.dom.children[this.index]){b.dom.children[this.index].className+=" thumb-scroller-div-selected "}var a=Math.round((Ext.get(this.scrollerWrapperId).getWidth()/2)-42-(this.index*84));b.dom.style.left=a+"px"},updateActionBar:function(){var j=PhotoStation.Auth.is_admin,f=PhotoStation.Util.hasAlbumPriv("manage"),k="photo"===this.store.getAt(this.index).get("type"),e=this.store.getAt(this.index).get("info").name.match(/\.gif$/i)?true:false,c=this.store.getAt(this.index).get("thumbnail_status").split(","),b=false,a=false;if(-1==c.indexOf("small")||-1==c.indexOf("large")){b=true}if(-1!==c.indexOf("disable")){a=true}var h=k&&!e&&!b&&!a&&(j||f);var d=this.actionBar.getComponent("action");d.setVisible(j||(!PhotoStation.CurrentBrowse.isAlbumCategory()&&f)||PhotoStation.CurrentBrowse.isSharedAlbum());d.menu.getComponent("delete").setVisible(j||f||PhotoStation.CurrentBrowse.isSharedAlbum());if(PhotoStation.CurrentBrowse.isSharedAlbum()){d.menu.getComponent("delete").setText(_PST("photo","photo_str_remove_from_shared_album"))}else{d.menu.getComponent("delete").setText(_PST("photo","photo_str_delete"))}d.menu.getComponent("setCover").setVisible(!PhotoStation.CurrentBrowse.isAlbumCategory()&&f);d.menu.getComponent("rotate90").setVisible(h);d.menu.getComponent("rotate270").setVisible(h);d.menu.getComponent("rotate180").setVisible(h);if(this.videoPlayer.quality){this.updateVideoRotateBtns(!k,this.videoPlayer.quality.container,this.videoPlayer.quality.profile_name)}else{this.updateVideoRotateBtns(!k,null,null)}d.menu.getComponent("faceRecognition").setVisible(k&&!e&&!b&&!a&&PhotoStation.Auth.enable_face_recog);if(d.menu.el){d.menu.el.show();d.menu.doLayout()}this.updateEditorBtn(k,j,f);var i=this.actionBar.getComponent("download");i.setVisible(PhotoStation.Auth.is_admin||(k&&PhotoStation.Info.allow_download_orig)||(!k&&PhotoStation.Info.allow_download_video));var g=this.actionBar.getComponent("viewOriginal");g.setVisible(k&&PhotoStation.Info.allow_download_orig);this.updateShareBtn()},updateEditorBtn:function(d,a,c){var b=this.actionBar.getComponent("editor");b.menu.getComponent("Aviary").setVisible(PhotoStation.Util.checkAviaryEditor());b.setVisible(d&&(a||c))},updateShareBtn:function(){var c=this.actionBar.getComponent("share");var f=true;var o="photo"===this.store.getAt(this.index).get("type");var k=PhotoStation.Info.social_network_list;var g=PhotoStation.Auth.is_admin||(PhotoStation.Auth.username&&PhotoStation.Info.allow_social_upload)||(!PhotoStation.Auth.username&&PhotoStation.Info.allow_social_upload_guest);var n=this.isPublicShareVisible();for(var d=0;dthis.index){this.hide()}this.setImagesToFlux([this.index,this.index+1,this.index-1]);this.gotoIndex(this.index);var f=Main.getScope("PhotoStation.ViewCard").store;f.remove(f.getById(a));f.totalLength--;Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount();var g=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;if(Ext.isFunction(g.onLightBoxDelete)){g.onLightBoxDelete(a)}this.disableHotKeys(false);Ext.fly(this.lightBoxId).unmask()},this)},clickUpload:function(a){this.disableHotKeys(true);var g=null;if(this.videoPlayer.player){this.videoPlayer.player.pause(true)}if("link"===a){var d={from:"album"};if(PhotoStation.CurrentBrowse.isSharedAlbum()){d={from:"shared_album",shareid:PhotoStation.CurrentBrowse.getRecord().get("additional").public_share.shareid}}g=new PhotoStation.ShareWindow(d);g.show()}else{var e=this.store.getAt(this.index);var c=e.get("id");var h=e.data.info.title;var f=e.json.thumbnail_status;var b=PhotoStation.Util.getImgUrl("White/"+(e.json.type==="video"?"image_default_video_dark.png":"image_default_photo_dark.png"),true);if(0<=f.indexOf("small")||0<=f.indexOf("preview")){b=this.getThumbUrl("small",e.json)}var i=e.data.info.description;g=new PhotoStation.SocialNetworkSingleUploader({renderTo:Ext.getBody(),website:a,imgurl:b,title:h,id:c,description:i});g.show()}},clickEmbedVideo:function(){var c=this.store.getAt(this.index),b=PhotoStation.Info.external_host+PhotoStation.Util.getUrlPrefix(),f=this.qualitySelector.qualities[this.qualitySelector.getQuality()].profile_name;var a=b+"/photo/webapi/embed.php?id="+c.get("id")+"&quality="+f;var e='';var d=new PhotoStation.BaseWindow({title:_PST("photo","photo_str_ap_name_6"),width:560,height:260,html:'",buttons:[{text:_PST("photo","photo_str_btnClose"),cls:"photo-grey-button photo-button",handler:function(){d.close()}}]});d.show()},clickDownload:function(){var a=Main.getScope("PhotoStation.CenterPanel");a.doDownload.createDelegate(a,[[this.store.getAt(this.index).get("id")],false])()},clickViewOriginal:function(){var a="webapi/download.php?api=SYNO.PhotoStation.Download&method=getphoto&version=1&id="+this.store.getAt(this.index).get("id");window.open(Ext.urlAppend(a))},clickEditor:function(d){var e=this.store.getAt(this.index).id;var a=this.store.getAt(this.index).data.info.name;var c="";if(d==="aviary"){c=PhotoStation.Info.external_host_external_ip+PhotoStation.Util.getUrlPrefix()+"/"+this.getEditUrlLink(e);this.initAviary(e,c,a)}else{c=this.getEditUrlLink(e);var b={type:d,image:c,title:a,id:e,hostname:"PhotoStation",referrer:"PhotoStation"};this.launchPixlrEditor(b)}SYNO.Debug(c)},clickPublicShare:function(){var a=new PhotoStation.ShareWindow({from:"single_public_share",single_share_itemid:this.store.getAt(this.index).id,title:_PST("photo","photo_str_public_share")});a.show()},clickCreateSharedAlbum:function(){var a=Main.getScope("PhotoStation.SettingWindow");if(!a){a=new PhotoStation.SettingWindow()}a.showCreateSharedAlbum({item_id:this.store.getAt(this.index).id,public_share:false,createCallback:function(b,c){Main.getScope("PhotoStation.LeftContent").reloadSharedAlbums();if(b){var d=new PhotoStation.ShareWindow({from:"shared_album_create",shareid:b,title:String.format(_PST("photo","photo_str_link_to"),c)});d.show()}}})},clickAddToSharedAlbum:function(b,a){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.SharedAlbum","add_items",1,{id:b,item_id:this.store.getAt(this.index).id},function(f,e,d,c){if(!f){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"));return}a=Ext.util.Format.htmlDecode(a);PhotoStation.Notify.showNotifyText(String.format(_PST("photo","photo_str_add_to_shared_album_success"),a))},this)},updateSharedAlbumMenu:function(e){e.removeAll();e.add(new Ext.menu.Item({itemId:"addToNewSharedAlbum",text:_PST("photo","photo_str_create_shared_album"),handler:this.clickCreateSharedAlbum,scope:this}));e.addSeparator();var a=Main.getScope("PhotoStation.SharedAlbumSelector").sharedAlbumList;var c;for(c=0;cb.thumbnail_status.indexOf(a)&&0<=b.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(b,{size:"preview"})}else{return PhotoStation.Util.getThumbUrl(b,{size:a})}},getEditUrlLink:function(b){var a;if(PhotoStation.Info.allow_download_orig){a="photo/webapi/download.php?api=SYNO.PhotoStation.Download&method=getphoto&version=1&id="+b+"&PHPSESSID="+Ext.util.Cookies.get("PHPSESSID")}else{a="photo/webapi/thumb.php?api=SYNO.PhotoStation.Thumb&method=get&version=1&id="+b+"&size=large&PHPSESSID="+Ext.util.Cookies.get("PHPSESSID")}return Ext.urlAppend(a)},initAviary:function(h,g,f){var e=h.split("_")[1];var d=h.split("_")[2];var c={name:d,dir:e};this.disableHotKeys(true);var b=new Aviary.Feather({apiKey:"p5iepr9syy19tm1s",apiVersion:2,maxSize:5000,displayImageSize:true,fileFormat:"jpg",postUrl:PhotoStation.Util.getUrlPrefix()+"/photo/include/file_upload.php",onSaveButtonClicked:function(i){var j=f;j=j.substr(0,j.lastIndexOf("."));while(1){var k=prompt("Please enter a file name",j);if(k===""||k===null){return false}if(!PhotoStation.Upload.isFolderFileNameValid(k)){alert(_PST("photo","photo_str_upload_invalid_folder_name"))}else{Ext.apply(c,{fname:k,action:"aviary_add"});break}}Ext.apply(c,{sid:Ext.util.Cookies.get("PHPSESSID")})},onSave:function(i,j){SYNO.Debug("edited url is "+j);Ext.Ajax.request({url:this.postUrl,method:"GET",params:Ext.apply(c,{url:j}),success:function(k,n){var p,o;try{p=Ext.decode(k.responseText)}catch(m){}if(p&&false===p.success&&Ext.isString(p.msg)){if(p.msg==="Write failed"){o=_PST("photo","photo_str_err_write")}else{o=p.msg}}if(!Ext.isEmpty(o)){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),o)}b.close()}})},onLoad:function(){Main.getScope("PhotoStation.LightBox").aviaryReady=true;var i=Main.getScope("PhotoStation.LightBox").mainImgId;b.launch({image:i,url:g})},onClose:function(){Main.getScope("PhotoStation.LightBox").disableHotKeys(false)},onError:function(i){if(3==i.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_no_external_ip"))}else{if(2==i.code||4==i.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_browser_not_support"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_load_aviary_fail"))}}}});if(false===this.aviaryReady){return}var a=this.mainImgId;b.launch({image:a,url:g})},launchPixlrEditor:function(c){var a,d={editor:"PixlrEditorHandler.php?action=editor&mode=pixlr&type=editor&",express:"PixlrEditorHandler.php?action=editor&mode=pixlr&type=express&"};var b=d[c.type];delete c.type;for(a in c){if(c.hasOwnProperty(a)){b+=String.format("&{0}={1}",a,encodeURIComponent(c[a]))}}window.open(b)},getScrollerImgClass:function(a){return String.format("thumb-scroller-img-{0}",a)},updateRotatedPhoto:function(g,f){var d,e,a,b;e=g.get("info");if(!e){return}if(f===90||f===270){d=e.resolutionx;e.resolutionx=e.resolutiony;e.resolutiony=d;e.rotate_version+=1}else{e.rotate_version+=2}var c=new Date().getTime();a=g.get("additional").thumb_size;for(b in a){if("preview"===b||"small"===b||"large"===b){a[b].mtime=c;if(90===f||270===f){d=a[b].resolutionx;a[b].resolutionx=a[b].resolutiony;a[b].resolutiony=d}}}},updateScrollerPhoto:function(g,e){var d,b,a,f,c;d=Ext.get(this.scrollerInnerId);b=this.getScrollerImgClass(g.get("id"));a=d.child("."+b);if(a){f=a.dom;f.style.width="auto";f.style.height="auto";c=g.json.info;if(c.resolutionx>c.resolutiony){f.style.height="72px"}else{f.style.width="72px"}f.src=this.getThumbUrl("small",g.json)}},hideAllToolBar:function(a){if(a){this.actionBar.hide();this.prevBtn.hide();this.nextBtn.hide();this.bbar.getComponent("thumbScrollerBtn").toggle(false)}else{this.actionBar.show();this.prevBtn.show();this.nextBtn.show()}},clickTransitionEffect:function(a){if(a){this.effect=a;Ext.util.Cookies.set("slideshow-effect",a)}},clearFluxEffect:function(){this.isTransition=false;if(this.flux){this.flux.options.onTransitionEnd=null;this.flux.clearImages()}},setImagesToFlux:function(c){var e,b,d,a=[];for(e=0;e0&&this.zoomImgObj.getWidth()===s.width){return}var m=this.img.getWidth(),k=this.img.getHeight();if(b>0){for(q=0;q<=b;q++){p=Math.min(s.width,Math.pow(1.1,this.zoomLevel+q)*m);i=Math.min(s.height,Math.pow(1.1,this.zoomLevel+q)*k);if(s.width===p&&s.height===i){break}}this.zoomLevel+=q;n={width:p+"px",height:i+"px"}}else{if(b<0){q=-1;p=Math.max(m,Math.pow(1.1,this.zoomLevel-1)*m);i=Math.max(k,Math.pow(1.1,this.zoomLevel-1)*k);if(m!==p&&k!==i){this.zoomLevel-=1}n={width:p+"px",height:i+"px"}}}var g=this.zoomImgObj.getBox();var e=this.zoomImgObj.getOffsetsTo(this.zoomObjs);if(p===m&&i===k){this.leaveZoomMode();return}else{this.zoomImgObj.setStyle(n)}if(a){d=this.getZoomOffset(a,this.zoomMoveTargetXY,this.zoomImgObj.getSize(),f);this.zoomImgObj.setStyle({left:d[0]+"px",top:d[1]+"px"})}if(q!==0&&this.zoomLevel>0){c=1-Math.pow(1.1,q);var o=c*(this.zoomXY[0]-g.x),r=c*(this.zoomXY[1]-g.y);d=this.getZoomOffset([o,r],e,{width:p,height:i},f);this.zoomImgObj.setStyle({left:d[0]+"px",top:d[1]+"px"})}},getZoomOffset:function(c,b,m,h){var f=b[1],g=b[0],o=this.zoomObjs.getWidth()-m.width,j=this.zoomObjs.getHeight()-m.height;var a=(0===h)?{left:0,top:0}:this.zoomImgObj.translatePoints([30,30]),p={left:a.left+this.zoomObjs.getWidth(),top:a.top+this.zoomObjs.getHeight()};var d=c[0]+g+a.left,n=c[1]+f+a.top;var k=m.width,e=m.height;if(90==h||270==h){o=this.zoomObjs.getWidth()-m.height;j=this.zoomObjs.getHeight()-m.width;k=m.height;e=m.width}var i=[0,0];if(o>=0){i[0]=d>p.left-k?p.left-k:(da.left?a.left:(d=0){i[1]=np.top-e?p.top-e:n)}else{i[1]=na.top?a.top:n)}return i},leaveZoomMode:function(){this.zoomMoveStart=null;this.zoomMoveTargetXY=null;this.zoomMode=false;this.zoomObjs.remove();this.zoomImgObj=null;this.zoomObjs=null;this.img.show();this.flux.imageContainer.show();this.prevBtn.show();this.nextBtn.show();this.actionBar.show();this.fullScreenBtn.show();if(this.zoomNeedResize){this.zoomNeedResize=false;this.resizeLightBox()}this.fireEvent("stopzoom")},updateOnScreenDisplay:function(a){if(!PhotoStation.Util.isShowSlideshowInfo()){this.slideshowInfo.setVisible(false);return}var h=function(t,k){var x=this.slideshowInfo;var v=x.getComponent("general");v.el.setStyle({marginLeft:((this.slideMode==="stop")?"9px":"-14px")});var m=a.get("info");v.getComponent("title").update(Ext.util.Format.htmlEncode(m.title));var y=m.description?Ext.util.Format.htmlEncode(m.description.trim()):"";var z=v.getComponent("ruler").el.dom;var u=v.getComponent("desc");z.innerHTML=y;if(z.offsetHeight>64){v.getComponent("readAll").setVisible(true).update(_PST("photo","blog_article_read_all"));var p=0,j=y.length;while(p48){j=s}else{p=s+1}}y=y.substr(0,p-4)+"..."}else{v.getComponent("readAll").setVisible(false)}u.update(y);v=x.getComponent("info");v.el.setStyle({marginRight:((this.slideMode==="stop")?"9px":"-14px")});var q=v.getComponent("takendate");q.el.child("table").setStyle({marginBottom:(t?"4px":"0")});var o=m.takendate.split(" ");var n=o[1].split(":");o=o[0].split("-");q.getComponent("date").update(String.format(_PST("photo","date_format_without_week"),_PST("photo","mon_"+parseInt(o[1],10)),parseInt(o[2],10)));q.getComponent("year").update(o[0]);q.getComponent("time").update(n[0]+":"+n[1]);t=t||"";k=k||{borderTop:0,paddingTop:0};var w=v.getComponent("location");w.update(t);w.el.setStyle(k);this.updateControlAndThumbnails()};var f,b;var c=a.get("gps"),e=a.get("info");if(c){f=c.lat;b=c.lng}else{if((e.lat)&&(e.lng)){f=e.lat;b=e.lng}else{h.call(this);return}}var g=this;var d=new google.maps.Geocoder();d.geocode({location:{lat:f,lng:b}},function(k,j){var n=null,m=null;if(j===google.maps.GeocoderStatus.OK){var i=(function(t){var x={};for(var s=0,u=t.length;s'},{xtype:"label",cls:"comment-date",text:g.comments[d].date}]},{xtype:"button",hidden:!a,cls:"comment-delete-btn",handler:this.commentDeleteHandler.createDelegate(this,[g.comments[d].id]),scope:this}]};this.add(c)}if(this.checkAlbumCommentable()){c={id:this.commentAddId=Ext.id(),width:290,buttons:[{cls:"comment-add-btn",text:_PST("photo","photo_str_comment_add"),handler:this.commentAddHandler,scope:this}]};this.add(c)}this.doLayout();this.ajax=null},this)},checkAlbumCommentable:function(){return PhotoStation.Auth.allow_comment},updateCommentList:function(a){this.removeAll(true);this.fileId=a;this.getCommentList()},validatorText:function(a){if(""===a.trim()){return false}return true},commentAddHandler:function(){Ext.getCmp(this.commentAddId).destroy();var a=(null===PhotoStation.Auth.username)?true:false;var c="include/magic_number.php";var b={border:false,cls:"comment-form",padding:"8px 8px 0 8px",items:[{id:this.nameId=Ext.id(),xtype:"textfield",hideLabel:true,value:a?undefined:PhotoStation.Auth.username,emptyText:_PST("photo","photo_str_comment_name"),allowBlank:false,width:250,validator:this.validatorText.createDelegate(this),enableKeyEvents:true,listeners:{scope:this,keydown:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT){f.stopPropagation()}},keypress:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT){f.stopPropagation()}}}},{id:this.emailId=Ext.id(),xtype:"textfield",hideLabel:true,emptyText:_PST("photo","photo_str_comment_email"),vtype:"email",width:250,allowBlank:true,enableKeyEvents:true,listeners:{scope:this,keydown:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT){f.stopPropagation()}},keypress:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT){f.stopPropagation()}}}},{id:this.commentId=Ext.id(),xtype:"textarea",hideLabel:true,emptyText:_PST("photo","photo_str_comment"),width:250,allowBlank:false,validator:this.validatorText.createDelegate(this),enableKeyEvents:true,listeners:{scope:this,keydown:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT||f.getKey()==f.UP||f.getKey()==f.DOWN){f.stopPropagation()}},keypress:function(d,f){if(f.getKey()==f.ESC||f.getKey()==f.RIGHT||f.getKey()==f.LEFT||f.getKey()==f.UP||f.getKey()==f.DOWN){f.stopPropagation()}}}}]};this.add(b);if(a){Ext.Ajax.request({url:c,params:{action:"gen_rand"},method:"POST",scope:this,callback:this.onValidateGen})}b={border:false,padding:"0 0 0 8px",cls:"comment-btn-panel",items:[{buttons:[{itemId:"commentPost",text:_PST("photo","photo_str_submit"),buttonAlign:"end",handler:this.commentPostHandler,autoWidth:false,scope:this},{cls:"lightbox-comment-dot"},{itemId:"commentCancel",text:_PST("photo","photo_str_btnCancel"),handler:this.commentCancelHandler,autoWidth:false,scope:this}]}]};this.add(b);this.doLayout()},onValidateGen:function(a,e,c){var d="include/magic_number.php";var i=String.format("{0}?n={1}&r={2}",d,"1",Math.random());var h=String.format("{0}?n={1}&r={2}",d,"2",Math.random());var g=String.format("{0}?n={1}&r={2}",d,"3",Math.random());var f=String.format("{0}?n={1}&r={2}",d,"4",Math.random());var b={padding:"0 0 0 8px",cls:"comment-captcha-form",items:[{id:this.validId=Ext.id(),xtype:"textfield",width:250,emptyText:_PST("photo","photo_str_comment_magic_num"),allowBlank:false},{xtype:"label",html:"
"},{xtype:"label",html:String.format('',f)},{xtype:"label",html:String.format('',g)},{xtype:"label",html:String.format('',h)},{xtype:"label",html:String.format('',i)}]};this.insert(this.commentCount+1,b);this.doLayout()},commentDeleteHandler:function(b){var a={id:this.fileId,comment_id:b};SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Comment","delete",1,a,function(f,e,d,c){if(!f){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"));return}this.updateCommentList(this.fileId)},this)},commentPostHandler:function(){var a=(null===PhotoStation.Auth.username)?true:false;var d=Ext.getCmp(this.nameId);var f=Ext.getCmp(this.emailId);var b=Ext.getCmp(this.commentId);var c=Ext.getCmp(this.validId);if(!d.isValid()||!f.isValid()||!b.isValid()){return}if(a&&!c.isValid()){return}var e={id:this.fileId,name:d.getValue(),email:f.getValue(),comment:b.getValue(),validate_number:a?c.getValue():"",url:window.location.toString()};Ext.MessageBox.show({title:_PST("photo","photo_str_ap_name_6"),msg:_PST("photo","photo_str_common_processing"),closable:false});SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Comment","create",1,e,function(k,j,i,h){Ext.MessageBox.hide();if(!k||!j){var g="";if(491===j.code){g=_PST("photo","photo_str_comment_magic_num_err")}else{if(492===j.code){g=_PST("photo","photo_login_noprivilege")}else{g=_PST("photo","photo_str_error_unknown_desc")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),g);return}this.updateCommentList(this.fileId)},this)},commentCancelHandler:function(){this.updateCommentList(this.fileId)}});Ext.ns("PhotoStation");PhotoStation.LightBoxInfoPanel=Ext.extend(Ext.Panel,{currentItemId:null,constructor:function(a){Main.addScope("PhotoStation.LightBoxInfoPanel",this);PhotoStation.LightBoxInfoPanel.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={itemId:"infoPanel",cls:"lightbox-data-info-panel",border:false,padding:8,title:_PST("photo","photo_str_image_information"),collapsible:true,items:[{itemId:"infoList",xtype:"listview",cls:"lightbox-data-info-list selectabletext",width:270,selectedClass:"",hideHeaders:true,store:new Ext.data.ArrayStore({idProperty:"name",fields:["name","value"]}),columns:[{dataIndex:"name",width:0.4,tpl:new Ext.XTemplate('')},{dataIndex:"value",tpl:new Ext.XTemplate('')}]},{itemId:"exifBtn",xtype:"button",cls:"lightbox-exif-btn",hidden:true,text:(Main.getScope("PhotoStation.LightBox").exifShow)?_PST("photo","photo_str_hide_exif"):_PST("photo","photo_str_show_exif"),listeners:{scope:this,click:this.exifShowHide}},{itemId:"exifList",xtype:"listview",cls:"lightbox-data-info-list selecttabletext",width:270,selectedClass:"",hideHeaders:true,hidden:(Main.getScope("PhotoStation.LightBox").exifShow)?false:true,store:new Ext.data.Store({reader:new Ext.data.JsonReader({root:"",idProperty:"label"},[{name:"label"},{name:"value"}]),fields:["label","value"]}),columns:[{dataIndex:"label",width:0.4,tpl:new Ext.XTemplate('')},{dataIndex:"value",tpl:new Ext.XTemplate('')}]}],listeners:{scope:this,afterrender:function(){this.infoList=this.getComponent("infoList");this.exifBtn=this.getComponent("exifBtn");this.exifList=this.getComponent("exifList")}}};return Ext.apply(a,b)},organizePhotoInfos:function(e){var c=[],b;var d=e.get("additional").photo_exif,a=e.get("additional").file_location;if(!PhotoStation.Util.isHideGPS()&&d.gps&&d.gps.lat&&d.gps.lng){b=this.formatLatlng(parseFloat(d.gps.lat))+", "+this.formatLatlng(parseFloat(d.gps.lng))}else{b=""}c=[[_PST("photo","photo_str_sort_type_filename"),e.get("info").name],[_PST("photo","photo_str_image_size"),Math.round(e.get("info").size/1024)+" KB"],[_PST("photo","photo_str_image_resolution"),this.formatResolution(e.get("info").resolutionx,e.get("info").resolutiony)],[_PST("photo","photo_str_image_date"),("1970-01-01 00:00:00"==d.takendate)?"":d.takendate],[_PST("photo","photo_str_image_camera"),d.camera],[_PST("photo","photo_str_image_model"),d.camera_model],[_PST("photo","photo_str_image_exposure"),d.exposure],[_PST("photo","photo_str_image_aperature"),d.aperture],[_PST("photo","photo_str_image_iso"),!d.iso?"":d.iso],[_PST("photo","photo_str_image_focal_length"),d.focal_length],[_PST("photo","photo_str_image_lens"),d.lens],[_PST("photo","photo_str_image_flash"),d.flash],["GPS",b]];if(PhotoStation.CurrentBrowse.inSearch()){c.splice(1,0,[_PST("photo","photo_str_file_location"),a])}return c},organizeVideoInfos:function(g){var e=[];var f=g.get("additional").video_codec,b=g.get("additional").file_location;var d;if(!PhotoStation.Util.isHideGPS()&&g.get("info").gps&&g.get("info").gps.lat&&g.get("info").gps.lng){d=this.formatLatlng(parseFloat(g.get("info").gps.lat))+", "+this.formatLatlng(parseFloat(g.get("info").gps.lng))}else{d=""}var a=g.get("info").duration;var c="";if(a>=3600){c+=(Math.floor(a/3600)+":");a%=3600}if(a/60<10){c+="0"+(Math.floor(a/60)+":")}else{c+=(Math.floor(a/60)+":")}a%=60;if(a<10){c+="0"+a}else{c+=a}e=[[_PST("photo","photo_str_sort_type_filename"),g.get("info").name],[_PST("photo","photo_str_video_container"),f.container],[_PST("photo","photo_str_video_size"),Math.round(g.get("info").size/1024)+" KB"],[_PST("photo","photo_str_video_resolution"),this.formatResolution(f.resolutionx,f.resolutiony)],[_PST("photo","photo_str_video_date"),g.get("info").takendate],[_PST("photo","photo_str_video_duration"),c],["GPS",d]];if(PhotoStation.CurrentBrowse.inSearch()){e.splice(1,0,[_PST("photo","photo_str_file_location"),b])}return e},updateInfoList:function(b){this.infoList.store.removeAll();if(!b||!b.get("additional")){return}var c=b.get("type"),a=b.get("additional"),d=[];if("photo"===c&&a.photo_exif){d=this.organizePhotoInfos(b)}else{if("video"===c&&a.video_codec){d=this.organizeVideoInfos(b)}}this.infoList.store.loadData(d)},updateExifList:function(a){this.exifList.store.removeAll();SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Photo","getexif",1,{id:a,version:1},this.getExifCallback,this)},formatLatlng:function(a){return Math.round(1000000*a)/1000000},formatResolution:function(a,b){return(a||0)+" x "+(b||0)},exifShowHide:function(){var a=Main.getScope("PhotoStation.LightBox");if(!a.exifShow){a.exifShow=true;this.getComponent("exifBtn").setText(_PST("photo","photo_str_hide_exif"));this.exifList.show()}else{a.exifShow=false;this.getComponent("exifBtn").setText(_PST("photo","photo_str_show_exif"));this.exifList.hide()}a.panel.getComponent("dataPanel").updateScrollbar()},getExifCallback:function(c,b){if(!c||!b){return}this.exifList.store.loadData(b.exifs);var a=Main.getScope("PhotoStation.LightBox");a.panel.getComponent("dataPanel").updateScrollbar()}});Ext.ns("PhotoStation");PhotoStation.LightBoxTagPanel=Ext.extend(Ext.Panel,{currentItemId:null,photoId:"",hasPriv:false,constructor:function(a){Main.addScope("PhotoStation.LightBoxTagPanel",this);PhotoStation.LightBoxTagPanel.superclass.constructor.call(this,this.fillConfig(a));this.mon(Main.getScope("PhotoStation.LightBox"),"hide",function(){this.peopleTagArea.setPeopleTagEditMode(false);this.clearTags();this.needReloadDescStore=true},this);this.mon(Main.getScope("PhotoStation.LightBox"),"show",function(){this.updateActionBtnPrivilege();this.descTagArea.reloadFullStore()},this)},fillConfig:function(b){this.curTagStore=new Ext.data.Store({reader:new Ext.data.JsonReader({root:"",idProperty:"item_tag_id"},[{name:"id"},{name:"item_tag_id"},{name:"type"},{name:"name"},{name:"info",mapping:"additional.info"}]),fields:["id","item_tag_id","type","name","info"],sortInfo:{field:"name",direction:"ASC"}});var a={itemId:"tagPanel",cls:"lightbox-data-tag-panel",padding:"8px 10px",title:_PST("photo","photo_str_add_label"),collapsible:true,border:false,items:[this.geoTagArea=new PhotoStation.LightBoxTagArea({type:"geo",owner:this}),this.peopleTagArea=new PhotoStation.LightBoxTagArea({type:"people",owner:this}),this.descTagArea=new PhotoStation.LightBoxTagArea({type:"desc",owner:this})],listeners:{scope:this,expand:function(){this.doLayout();this.geoTagArea.updateMap()}}};return Ext.apply(a,b)},updateTagPanel:function(a){var c=Main.getScope("PhotoStation.LightBox"),b=c.store.getAt(c.index);this.photoId=a;this.checkActionBtnPrivilege();this.clearTags();if("video"==b.get("type")){this.peopleTagArea.hide()}else{this.peopleTagArea.show();this.peopleTagArea.doLayout()}},requestTagList:function(){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.PhotoTag","list",1,{id:this.photoId,type:"people,geo,desc",additional:"info"},this.requestTagsCallback,this)},clearTags:function(){this.geoTagArea.clearTagList();this.peopleTagArea.clearTagList();this.descTagArea.clearTagList()},updateTags:function(){this.geoTagArea.updateTagList();this.peopleTagArea.updateTagList();this.descTagArea.updateTagList()},requestTagsCallback:function(d,c,b,a){if(!d||!c||!Ext.isArray(c.tags)){return}if(b.id!==this.photoId){return}this.tags=c.tags;this.curTagStore.loadData(c.tags);this.updateTags()},resize:function(){this.peopleTagArea.resize();this.geoTagArea.updateMap()},checkActionBtnPrivilege:function(){if(PhotoStation.CurrentBrowse.isSearchCategory()){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Path","getpath",1,{id:this.photoId,ignore:"thumbnail",additional:"album_permission"},function(e,d,c,b){if(!e){return}var a=d.items;this.hasPriv=a[a.length-1].additional.album_permission.manage;this.updateActionBtnPrivilege();this.requestTagList()},this)}else{this.updateActionBtnPrivilege();this.requestTagList()}},updateActionBtnPrivilege:function(){if(PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("manage")||this.hasPriv){this.geoTagArea.setActionBtnVisible(true);this.peopleTagArea.setActionBtnVisible(true);this.descTagArea.setActionBtnVisible(true)}else{this.geoTagArea.setActionBtnVisible(false);this.peopleTagArea.setActionBtnVisible(false);this.descTagArea.setActionBtnVisible(false)}if(!PhotoStation.Util.checkGoogleMap()){this.geoTagArea.setActionBtnVisible(false)}}});PhotoStation.LightBoxTagArea=Ext.extend(Ext.Panel,{tagTitleStr:{people:_PST("photo","photo_str_person_label"),geo:_PST("photo","photo_str_location_tag"),desc:_PST("photo","photo_str_general_tag")},isAddingTag:false,peopleTagMgr:null,geoTagDialog:null,constructor:function(a){this.type=a.type;this.owner=a.owner;this.tagList=[];this.tagTextTpl=new Ext.XTemplate('");this.tagTextTpl.compile();this.createStore();this.addEvents("rendertag");PhotoStation.LightBoxTagArea.superclass.constructor.call(this,this.fillConfig(a))},createStore:function(){this.fullStore=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("tag.php"),method:"POST"}),autoLoad:true,baseParams:{api:"SYNO.PhotoStation.Tag",version:1,method:"list",additional:"info",offset:0,limit:-1,type:this.type},reader:new Ext.data.JsonReader({root:"data.tags"},[{name:"id"},{name:"type",mapping:"tag_type"},{name:"name"},{name:"info",mapping:"additional.info"}]),fields:["id","type","name","info"],sortInfo:{field:"name",direction:"ASC"},listeners:{scope:this,add:function(c,b,a){c.singleSort("name","ASC")},load:function(b,a,c){this.updateComboStore()}}});this.comboStore=new Ext.data.Store({fields:["id","type","name","info"],sortInfo:{field:"name",direction:"ASC"}})},fillConfig:function(b){var c=new Ext.XTemplate('
{name:htmlEncode}
');this.gmapDivId=Ext.id();var a={itemId:this.type+"_tagPanel",cls:"lightbox-"+this.type+"-tag-area",border:false,items:[{itemId:"tagField",xtype:"compositefield",items:[{xtype:"container",cls:"lightbox-"+this.type+"-tag-area-header lightbox-text-with-image",html:this.tagTitleStr[this.type]},{id:this.leftId=Ext.id(),xtype:"container",html:"(",hidden:true},{id:this.ActionBtnId=Ext.id(),xtype:"container",cls:"lightbox-tag-action-btn",html:"people"===this.type?_PST("photo","photo_str_enter_edit_people_tag_mode"):_PST("photo","photo_str_add"),hidden:true},{id:this.rightId=Ext.id(),xtype:"container",html:")",hidden:true}]},{itemId:"tag_desc_combo",cls:"lightbox-tag-combo",xtype:"syno_combobox",store:this.comboStore,hideLabel:true,tpl:c,editable:true,allowBlank:false,displayField:"name",hideTrigger:true,enableKeyEvents:true,autoSelect:false,hidden:true,maxLength:64,mode:"local",width:200,getListParent:function(){return Main.getScope("PhotoStation.LightBox").lightBox},listeners:{scope:this,show:function(){Main.getScope("PhotoStation.LightBox").disableHotKeys(true)},hide:function(){Main.getScope("PhotoStation.LightBox").disableHotKeys(false)},expand:function(){this.updateComboStore()},keypress:function(g,e){if(e.getKey()===e.ENTER){if(!g.isValid()){return}var f=g.getValue();var d=f.split(",");if(1==d.length){this.addPhotoTag(f.trim())}else{this.batchAddDescTag(d)}}},specialkey:function(f,d){if(d.getKey()==d.ESC){d.stopPropagation();this.endDescTagEdit();Ext.getBody().focus()}},select:function(g,d,e){var f=g.getValue();this.addPhotoTag(f)},blur:function(d){this.endDescTagEdit()},focus:function(d){if(""===d.getValue()){(function(){if(!d.isDestroyed){d.doQuery("",true)}}).defer(100,this)}}}},{itemId:"tag_list_div",xtype:"container",html:""},{itemId:"tag_map_div",xtype:"container",cls:"lightbox-tag-map-div",hidden:"geo"!==this.type,width:260,height:180,html:"
"}],listeners:{scope:this,single:true,afterlayout:function(){this.actionBtn=Ext.getCmp(this.ActionBtnId);this.leftBracket=Ext.getCmp(this.leftId);this.rightBracket=Ext.getCmp(this.rightId);if(this.actionBtn){this.actionBtn.el.on("click",this.onTagActionClick,this)}if("geo"===this.type){this.initGMap()}}}};return Ext.apply(a,b)},initGMap:function(){if(!PhotoStation.Util.checkGoogleMap()){this.getComponent("tag_map_div").hide();return}var a=new google.maps.LatLng(25.050433,121.518649);var b={zoom:16,center:a,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControl:false,streetViewControl:false};this.gmap=new google.maps.Map(Ext.get(this.gmapDivId).dom,b);this.marker=new google.maps.Marker({map:this.gmap,clickable:true,visible:false,icon:"photo_new/images/Window/icon_map_red.png",position:a});this.tagMarker=new google.maps.Marker({map:this.gmap,clickable:true,visible:false,icon:"photo_new/images/Window/icon_map_blue.png",position:a});this.gmap.setCenter(a)},updateTagList:function(){var a=Main.getScope("PhotoStation.LightBox");if(!Ext.get(a.lightBoxId).isVisible()){return}if("people"==this.type&&!this.peopleTagMgr){this.initPeopleTagDisplay()}this.owner.curTagStore.filter("type",this.type);this.renderTag(this.owner.curTagStore.getRange());this.owner.curTagStore.clearFilter();if("geo"===this.type){this.updateMap()}this.updateComboStore();this.updateActionBtnText();this.setPeopleTagEditMode(this.isPeopleTagEditMode());this.fireEvent("rendertag")},renderTag:function(e){for(var d=0;dc.index||!PhotoStation.Util.checkGoogleMap()){return}var e=null,d=null,b=null,a=c.store.getAt(c.index);if(!this.marker){this.initGMap()}this.owner.curTagStore.filter("type",this.type);if(this.owner.curTagStore.getCount()>0){d=this.owner.curTagStore.getAt(0)}this.owner.curTagStore.clearFilter();if("photo"===a.get("type")){if(a.get("additional").photo_exif){b=a.get("additional").photo_exif.gps}}else{b=a.get("info").gps}if(b){e=new google.maps.LatLng(b.lat,b.lng);this.marker.setPosition(e);this.marker.setVisible(true);this.tagMarker.setVisible(false)}else{if(d&&d.get("info").lat&&d.get("info").lng){e=new google.maps.LatLng(d.get("info").lat,d.get("info").lng);this.tagMarker.setPosition(e);this.tagMarker.setVisible(true);this.marker.setVisible(false)}}if(PhotoStation.Util.isHideGPS()||!e){this.getComponent("tag_map_div").hide()}else{this.getComponent("tag_map_div").show();google.maps.event.trigger(this.gmap,"resize");this.gmap.panTo(e);if((PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("manage")||this.owner.hasPriv)&&b){this.getComponent("tag_map_div").el.child(".lightbox-gmap-el-del-btn").show();this.getComponent("tag_map_div").el.child(".lightbox-gmap-el-del-btn").on("click",this.confirmDeleteGps.createDelegate(this,[a]),this)}else{this.getComponent("tag_map_div").el.child(".lightbox-gmap-el-del-btn").hide()}}},clearTagList:function(a){Ext.each(this.tagList,function(c,b){c.remove()},this);this.tagList.length=0;if(this.peopleTagMgr){this.peopleTagMgr.stopDrag();this.peopleTagMgr.clearTag(a)}},setActionBtnVisible:function(a){this.actionBtn.setVisible(a);this.leftBracket.setVisible(a);this.rightBracket.setVisible(a);this.getComponent("tagField").doLayout()},updateActionBtnText:function(){var a;if("geo"==this.type){a=(this.tagList.length===0)?_PST("photo","photo_str_add"):_PST("photo","photo_str_edit");this.actionBtn.update(a)}else{if("people"==this.type){a=this.isPeopleTagEditMode()?_PST("photo","photo_str_finish_edit_people_tag_mode"):_PST("photo","photo_str_enter_edit_people_tag_mode");this.actionBtn.update(a);this.doLayout()}}},isPeopleTagEditMode:function(){return this.peopleTagEditMode===true},initPeopleTagDisplay:function(){var b=Ext.get(this.owner.lightBoxId);var a=b.child(".lightbox-img");this.peopleTagMgr=new PhotoStation.PeopleTagManager({elImg:a,owner:this,hasPriv:this.owner.hasPriv})},resize:function(){if(!this.peopleTagMgr){return}this.peopleTagMgr.resize()},getOrigGeoTag:function(){var a=Main.getScope("PhotoStation.LightBoxTagPanel");var b=null;a.curTagStore.filter("type","geo");if(a.curTagStore.getCount()>0){b=a.curTagStore.getAt(0)}a.curTagStore.clearFilter();return b},getCurrentRec:function(){var a=Main.getScope("PhotoStation.LightBox");var b=a.store.getAt(a.index);return[b]},onTagActionClick:function(){if("desc"==this.type){this.reloadFullStore();var b=this.getComponent("tag_desc_combo");b.show();b.clearInvalid();b.focus()}else{if("geo"==this.type){if(!this.geoTagDialig){this.geoTagDialog=new PhotoStation.GeoTagDialog({owner:this});this.geoTagDialog.on("show",function(){Main.getScope("PhotoStation.LightBox").disableHotKeys(true)},this);this.geoTagDialog.on("hide",function(){Main.getScope("PhotoStation.LightBox").disableHotKeys(false)},this)}this.geoTagDialog.isLightBox=true;this.geoTagDialog.oriTagRec=this.getOrigGeoTag();this.geoTagDialog.currentRec=this.getCurrentRec();this.geoTagDialog.show()}else{if(Main.getScope("PhotoStation.LightBox").isZoomMode()){Main.getScope("PhotoStation.LightBox").leaveZoomMode()}var a=!this.isPeopleTagEditMode();if(a){this.peopleTagMgr.showPeopleTagMsg();this.peopleTagMgr.hasPriv=this.owner.hasPriv}this.setPeopleTagEditMode(a)}}},endDescTagEdit:function(){var a=this.getComponent("tag_desc_combo");a.hide();a.clearValue();a.clearInvalid()},findTagFromFullStore:function(c,d){var a=-1;var b=(d)?d.name:c;if("geo"!==this.type){a=this.fullStore.findExact("name",b)}else{this.fullStore.each(function(f,e){if(b===f.get("name")&&d.place_id===f.get("info").place_id){a=e;return false}},this)}return a},batchAddDescTag:function(a){Ext.fly(Main.getScope("PhotoStation.LightBox").lightBox).mask(_PST("photo","photo_str_common_processing"));this.batchTagList=[];Ext.each(a,function(c,b){if(""!==c.trim()){this.batchTagList.push(c.trim())}},this);this.addPhotoTag(this.batchTagList[0],null,null,this.addPhotoDescTagDone.createDelegate(this,[0],true))},addPhotoDescTagDone:function(c,a){if(!c||(this.batchTagList.length-1)==a){this.batchTagList=[];Ext.fly(Main.getScope("PhotoStation.LightBox").lightBox).unmask();return}var b=this.batchTagList[a+1];this.addPhotoTag(b,null,null,this.addPhotoDescTagDone.createDelegate(this,[a+1],true))},addPhotoTag:function(c,d,e,b){if(Ext.isEmpty(c)||this.isAddingTag){Ext.fly(Main.getScope("PhotoStation.LightBox").lightBox).unmask();return}this.endDescTagEdit();if(!d||-1===d){var a=this.findTagFromFullStore(c,e);if(-1==a){this.createTag(c,e,b);return}d=this.fullStore.getAt(a).get("id")}this.isAddingTag=true;var f={id:this.owner.photoId,tag_id:d};if(e){Ext.apply(f,e)}SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.PhotoTag",this.type+"_tag",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},f,function(m,k,j,h){this.isAddingTag=false;if(!m){if(468==k.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_label_duplicate"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}if(b){b(false)}return}if(k&&Ext.isArray(k.item_tag_ids)){for(var g=0;g','
','','','
','','
','
','
','
','','{name:htmlEncode}','','',"
",'
','
',"","
");this.peopleTagBoxTpl.compile();if("play"===this.slideMode){this.deregisterImageEvent()}else{this.registerImageEvent()}},resize:function(){if(!this.imgProxy){return}var a=this.img.getBox(),b={left:this.img.getX()-this.displayPanelXY[0],top:this.img.getY()-this.displayPanelXY[1]};this.imgProxy.setBox(a);Ext.each(this.tagList,function(d,c){var e=this.adjustTagConfig(d.config,a,b);d.setSize(e.width,e.height);d.setLeftTop(e.left,e.top);this.setTagContentPosition(d,false)},this)},registerImageEvent:function(){if(this.registered){return}Ext.getDoc().on("mouseup",this.onDocMouseUp,this);var a=this.img.parent();a.on("mousedown",this.onImageMouseDown,this);a.on("mouseup",this.onImageMouseUp,this);a.on("mousemove",this.onImageMouseMove,this);a.on("mouseout",this.onImageMouseOut,this);this.registered=true},deregisterImageEvent:function(){Ext.getDoc().un("mouseup",this.onDocMouseUp,this);var a=this.img.parent();a.un("mousedown",this.onImageMouseDown,this);a.un("mouseup",this.onImageMouseUp,this);a.un("mousemove",this.onImageMouseMove,this);a.un("mouseout",this.onImageMouseOut,this);this.updateTagVisible(false);this.registered=false},setPeopleTagEditMode:function(a){if(a){this.registerImageEvent();this.imgProxy.show()}else{this.imgProxy.hide()}},showPeopleTagMsg:function(){var a;if(null===this.msgEl){this.msgEl=this.imgProxy.createChild({tag:"div",cls:"lightbox-tag-people-msg",html:_PST("photo","photo_str_person_label_remind")})}a=this.msgEl;a.alignTo(this.imgProxy,"c-c");a.fadeIn({endOpacity:0.75,easing:"easeOut",duration:0.5});setTimeout(function(){a.fadeOut()},3000)},saveTag:function(b){var e=b.tagCombo.getValue();if(!b.tagCombo.validate()||""===e.trim()){return}if(-1!=b.tagId){this.deleteTag(b.config)}var a=(b.getLeft()-(this.imgProxy.getXY())[0])/this.imgProxy.getWidth();var g=(b.getTop()-(this.imgProxy.getXY())[1])/this.imgProxy.getHeight();var c=b.getWidth()/this.imgProxy.getWidth();var d=b.getHeight()/this.imgProxy.getHeight();var f={x:a,y:g,width:c,height:d};this.owner.addPhotoTag(e,null,f,this.addTagDone.createDelegate(this))},addTagDone:function(){this.editing=false;this.editingTag=null},deleteTag:function(a){this.owner.deletePhotoTag(a.itemTagId,null,true)},addTagConfig:function(a){if(this.img.dom.complete||this.imgLoaded||this.img.dom.src===this.prevImgSrc){var b=this.img.getBox(),d={left:this.img.getX()-this.displayPanelXY[0],top:this.img.getY()-this.displayPanelXY[1]};for(var c=0;c
{name:htmlEncode}
'),displayField:"name",listeners:{scope:this,expand:function(){this.owner.updateComboStore()},beforequery:function(c){delete c.combo.lastQuery},specialkey:function(d,c){if(c.getKey()==c.ESC){c.stopPropagation();this.cancelTag(a)}},keypress:function(d,c){if(c.getKey()==c.ENTER){this.saveTag(a)}},select:function(e,c,d){this.saveTag(a)},blur:function(d,c){if(a.hasClass("people-tag-edit")){this.cancelTag(a)}},focus:function(){if(""===a.tagCombo.getValue()){(function(){if(!a.tagCombo.isDestroyed){a.tagCombo.doQuery("",true)}}).defer(100,this)}}}});return b},onTagClick:function(a){if(this.editing||"stop"!==this.slideMode){return}this.setTagEditable(a)},onNameTagOver:function(a){var b;if(!a.hasClass("people-tag-edit")&&!this.editing){b=parseInt(a.child(".people-tag-content").dom.style.left,10)-10;a.child(".people-tag-content").dom.style.left=b+"px"}},onNameTagOut:function(a){var b;if(!a.hasClass("people-tag-edit")&&!this.editing){b=parseInt(a.child(".people-tag-content").dom.style.left,10)+10;a.child(".people-tag-content").dom.style.left=b+"px"}},clearTag:function(a){if(this.editingTag){this.cancelTag(this.editingTag)}Ext.each(this.tagList,function(c,b){c.tagCombo.destroy();c.remove()},this);this.tagList.length=0;if(!a){this.imgLoaded=false}},setTagContentPosition:function(a,e){var f=0;if(e){f=(a.getWidth()-200)/2;a.child(".people-tag-content").dom.style.left=f+"px";return}var b=Ext.util.TextMetrics.createInstance(a.child(".people-tag-content")),d=a.child(".people-name-tag-text").dom.innerHTML,c=Math.min(b.getWidth(d),250)+24;if(a.hasClass("people-tag-not-confirm")){c+=16}if(a.child(".people-tag-delete-btn").isVisible()){c+=16}f=(a.getWidth()-c)/2;a.child(".people-tag-content").dom.style.left=f+"px";if("stop"===this.slideMode&&(this.actionBar.isVisible()&&a.getHeight()+a.getTop()>this.actionBar.getBox().y)){a.child(".people-tag-content").addClass("upper")}},isInImage:function(c){var d=this.imgProxy.getXY(),b=this.imgProxy.getWidth(),a=this.imgProxy.getHeight();return(c[0]>d[0]&&c[0]d[1]&&c[1]=20||Math.abs(e[1]-this.startPosi[1])>=20){var c={tagId:-1,mode:"people-tag-edit",name:"",width:20,height:20,left:this.startPosi[0]-this.displayPanelXY[0],top:this.startPosi[1]-this.displayPanelXY[1]};this.DraggingTag=this.addTag(c);this.DraggingTag.child(".people-tag-content").dom.style.visibility="hidden";this.dragTag=true;Main.getScope("PhotoStation.LightBox").hideAllToolBar(true)}}else{this.resizeDragArea(e)}},onImageMouseOut:function(b,d){var c=Ext.fly(d),a=c.hasClass("people-tag-content")?c:c.parent(".people-tag-content");this.updateTagVisibleTask.delay(50,this.updateTagVisible,this,[a||this.isInImage(b.getXY())])},updateTagVisible:function(a){if(a){Ext.util.CSS.updateRule(".people-tag-box","visibility","visible")}else{Ext.util.CSS.updateRule(".people-tag-box","visibility","hidden")}},resizeDragArea:function(c){var d=this.imgProxy.getXY(),a=this.imgProxy.getHeight(),b=this.imgProxy.getWidth();if(c[1]>d[1]+a){c[1]=d[1]+a}else{if(c[1]d[0]+b){c[0]=d[0]+b}else{if(c[0]=this.startPosi[0]){this.DraggingTag.setWidth(c[0]-this.startPosi[0]);if(c[1]>=this.startPosi[1]){this.DraggingTag.setHeight(c[1]-this.startPosi[1])}else{this.DraggingTag.setTop(c[1]-this.displayPanelXY[1]);this.DraggingTag.setHeight(this.startPosi[1]-c[1])}}else{this.DraggingTag.setWidth(this.startPosi[0]-c[0]);this.DraggingTag.setLeft(c[0]-this.displayPanelXY[0]);if(c[1]>=this.startPosi[1]){this.DraggingTag.setHeight(c[1]-this.startPosi[1])}else{this.DraggingTag.setTop(c[1]-this.displayPanelXY[1]);this.DraggingTag.setHeight(this.startPosi[1]-c[1])}}},stopDrag:function(){if(this.dragTag){this.DraggingTag.isNew=true;this.DraggingTag.tagCombo.resumeEvents();this.DraggingTag.child(".people-tag-content").dom.style.visibility="";this.setTagEditable(this.DraggingTag);Main.getScope("PhotoStation.LightBox").hideAllToolBar(false)}this.startDrag=false;this.dragTag=false;this.startPosi=null;this.DraggingTag=null},setTagEditable:function(a){Main.getScope("PhotoStation.LightBox").disableHotKeys(true);this.editing=true;this.editingTag=a;a.addClass("people-tag-edit");a.child(".people-name-tag-text").dom.style.display="none";a.child(".people-tag-content").setWidth(200);a.child(".people-name-tag-mc").setWidth(175);a.tagCombo.setValue(Ext.util.Format.htmlDecode(a.child(".people-name-tag-text").dom.innerHTML));this.setTagContentPosition(a,true);this.setOtherActive(a,false);a.tagCombo.focus(true,100)},setTagNonEditable:function(a){a.removeClass("people-tag-edit");a.child(".people-name-tag-text").dom.style.display="inline-block";a.child(".people-tag-content").dom.style.width="";a.child(".people-name-tag-mc").dom.style.width="";this.setTagContentPosition(a,false);this.setOtherActive(a,true);a.child("input").dom.blur()},cancelTag:function(a){Main.getScope("PhotoStation.LightBox").disableHotKeys(false);if(a.isNew){this.setOtherActive(a,true);a.tagCombo.destroy();a.remove();this.tagList.pop()}else{this.setTagNonEditable(a)}this.editing=false;this.editingTag=null},setOtherActive:function(a,c){var b=this.img.parent().select(".people-tag-box");b.each(function(f,g,d){var e=Ext.get(f.id);if(e.tagId===a.tagId){return true}if(c){e.child(".people-tag-delete-btn").dom.style.display="";e.child(".people-tag-box-wrapper").dom.style.display=""}else{e.child(".people-tag-delete-btn").dom.style.display="none";e.child(".people-tag-box-wrapper").dom.style.display="none"}},this)}});Ext.ns("PhotoStation");PhotoStation.LoginWindow=Ext.extend(PhotoStation.BaseWindow,{constructor:function(a){Main.addScope("PhotoStation.LoginWindow",this);PhotoStation.LoginWindow.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={cls:"photo-login-window photo-window",layout:"form",bodyStyle:"padding: 20px 30px;",width:372,height:307,closable:true,closeAction:"hide",useStatusBar:false,items:[{hideLabel:true,cls:"photo-login-username",itemId:"username",xtype:"textfield",width:300},{hideLabel:true,cls:"photo-login-password",itemId:"password",xtype:"textfield",width:300,inputType:"password"},{itemId:"rememberMe",xtype:"syno_checkbox",hideLabel:true,boxLabel:_PST("photo","photo_str_remember_login")},{itemId:"statusMsg",cls:"photo-login-msg",xtype:"label",text:""},{itemId:"loginBtn",cls:"photo-login-button photo-button photo-blue-button",xtype:"button",text:_PST("photo","photo_mobile_Login"),handler:this.onClickLogin,scope:this}],keys:[{key:Ext.EventObject.ENTER,scope:this,fn:this.onClickLogin}],listeners:{single:true,scope:this,afterrender:function(){this.header.child(".x-tool-close").on("click",this.closeHandler,this)}}};Ext.apply(a,b);return a},onShow:function(){var b,a;b=this.getComponent("username");a=this.getComponent("password");b.reset();a.reset();this.getRememberedFieldValue();b.focus(true,300);this.setLoginStatusMsg("")},closeHandler:function(){if(this.redirectOnCancel){PhotoStation.HistoryManager.jumpToDefault()}},getRememberedFieldValue:function(){var d,a,c,b;c=this.getComponent("username");b=this.getComponent("password");d=Ext.get("login_username").dom.value;a=Ext.get("login_password").dom.value;if(d){c.setValue(d)}if(a){b.setValue(a)}},onClickLogin:function(){var c,a,b;c=this.getComponent("username").getValue();a=this.getComponent("password").getValue();b=this.getComponent("rememberMe").getValue();if(!c){this.setLoginStatusMsg(_PST("photo","photo_str_no_username"));return}this.setStatusBusy(_PST("photo","photo_str_logging"));this.submitLoginForm(c,a,b)},cancelHandler:function(){this.hide()},submitLoginForm:function(c,a,b){Ext.get("login_api").dom.value="SYNO.PhotoStation.Auth";Ext.get("login_method").dom.value="login";Ext.get("login_version").dom.value=1;Ext.get("login_username").dom.value=c;Ext.get("login_password").dom.value=a;if(b===true){Ext.get("login_remember_me").dom.checked=true}Ext.get("login_form").dom.submit()},showLoginErrorMessage:function(a){this.setLoginStatusMsg(PhotoStation.Error(a))},setLoginStatusMsg:function(a){Main.getScope("PhotoStation.LoginWindow").getComponent("statusMsg").setText(a)}});Ext.ns("PhotoStation");Ext.QuickTip.prototype.maxWidth=500;PhotoStation.MainPanel=Ext.extend(Ext.Panel,{panelList:{},constructor:function(a){Main=this;PhotoStation.MainPanel.superclass.constructor.call(this,this.fillConfig(a));this.initIFrameEvent()},fillConfig:function(b){var a={cls:"main-panel",layout:"border",border:false,items:[new PhotoStation.CustomizePanel(),{cls:"main-center-panel",region:"center",layout:"border",border:false,style:"padding: 16px 30px 12px",items:[new PhotoStation.LeftPanel(),new PhotoStation.CenterPanel()]}]};return Ext.apply(a,b)},addScope:function(b,a){this.panelList[b]=a},getScope:function(a){if(a in this.panelList){return this.panelList[a]}return null},initIFrameEvent:function(){log(">> initIFrameEvent");var a=Ext.get("login_iframe");if(Ext.isIE){a.dom.onreadystatechange=function(){if("complete"!==this.readyState&&"loaded"!==this.readyState){return}Main.onIFrameCallback()}}else{a.dom.onload=function(){Main.onIFrameCallback()}}},onIFrameCallback:function(){log(">> onIFrameCallback");var c,a;if(!Main.getScope("PhotoStation.LoginWindow")){return}Main.getScope("PhotoStation.LoginWindow").clearStatusBusy();try{c=Ext.decode(Ext.util.Format.htmlDecode(Ext.get("login_iframe").dom.contentWindow.document.body.firstChild.innerHTML))}catch(b){a="json decode error"}if(!c){window.location.reload()}else{if(!c.success||!c.data){a=(c.error&&c.error.code)?c.error.code:"request failed"}}if(a){Main.getScope("PhotoStation.LoginWindow").showLoginErrorMessage(a);return}PhotoStation.Auth=c.data;Main.getScope("PhotoStation.LoginWindow").hide();Main.delayConstructor()},requestAuth:function(){SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Auth","checkauth",1,{},function(d,c,b,a){if(!d||!c){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),PhotoStation.Error(c.code,_PST("photo","photo_str_error_load_data")));return}PhotoStation.Auth=c;this.delayConstructor()},this)},adjustInfo:function(){if(PhotoStation.Define.FORCE_PAGING_MODE){PhotoStation.Info.paging_use_bar=true;PhotoStation.Info.paging_item_count=50}},delayConstructor:function(){document.title=PhotoStation.Info.title||"Photo Station 6";PhotoStation.Util.setIsHideContextmenu(PhotoStation.Info.disable_right_button);Main.getScope("PhotoStation.LeftPanel").updateVisibility();Main.getScope("PhotoStation.CategoryList").updateVisibility();Main.getScope("PhotoStation.CustomizePanel").setVisible(!!PhotoStation.Auth.is_admin);Main.getScope("PhotoStation.StatusTopArea").updateVisibility();if(PhotoStation.Info.paging_use_bar){Main.getScope("PhotoStation.CenterPanel").getPagingToolbar().pageSize=PhotoStation.Info.paging_item_count;Ext.iterate(Main.getScope("PhotoStation.ViewCard").stores,function(c,d,b){b[c].baseParams.limit=PhotoStation.Info.paging_item_count},this)}this.updateLoginStatus();var a=document.documentElement;if(a&&a.addEventListener){a.addEventListener("DOMSubtreeModified",function(b){var c=document.getElementsByTagName("title")[0];var d=b.target;if(d===c||(d.parentNode&&d.parentNode===c)){Main.refreshTitle()}},false)}else{document.onpropertychange=function(){if(window.event.propertyName=="title"){Main.refreshTitle()}}}},updateLoginStatus:function(){var a=PhotoStation.History.getToken()||"";if(!!PhotoStation.Auth.username){Main.getScope("PhotoStation.CenterPanel").toggleLogIn(true,PhotoStation.Auth.username)}else{Main.getScope("PhotoStation.CenterPanel").toggleLogIn(false)}Main.getScope("PhotoStation.CategoryList").loadCategories(function(){PhotoStation.HistoryManager.loadCheck();if(0===a.indexOf("fromDsm")){PhotoStation.Notify.showNotifyText(String.format(_PST("photo","photo_str_login_from_dsm_account"),PhotoStation.Auth.username))}})},mask:function(a){Main.getEl().addClass("center-transparent-mask");Ext.getBody().mask(a).addClass("transparent-mask")},unmask:function(){Main.getEl().removeClass("center-transparent-mask");Ext.getBody().unmask()},refreshTitle:function(){var a=PhotoStation.Info.title.trim()||"Photo Station 6";if(a!==document.title){document.title=a}}});Ext.onReady(function(){PhotoStation.TimelineContainer.prototype.useFloatingBtn=(PhotoStation.Util._GET("timeline_usefloatingbtn")==="true");PhotoStation.Util.initDebug();PhotoStation.Util.fixExtInIE();PhotoStation.Util.overrideMask();PhotoStation.Util.disableSelect();PhotoStation.HistoryManager=new PhotoStation._HistoryManager();PhotoStation.HistoryManager.init();PhotoStation.Info={};PhotoStation.Auth={};Ext.QuickTips.init();PhotoStation.Util.loadGoogleMapScript();PhotoStation.Util.loadAviaryEditorScript();var a;SYNO.API.currentManager=new SYNO.API.Manager();SYNO.API.currentManager.queryAPI("all",function(e,d,c,b){if(!e){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Info","getinfo",1,{},function(i,h,g,f){if(!i||!h){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}PhotoStation.Info=h;a=new Ext.Viewport({layout:"fit",items:new PhotoStation.MainPanel(),listeners:{afterrender:{fn:function(){Main.adjustInfo();Main.requestAuth();if(PhotoStation.Util._GET("timeline_autoenter")==="true"){vc.switchTo.createDelegate(vc,["PhotoStation.TimelineView"]).defer(3000)}},scope:this,single:true}}})},this)})});Ext.ns("PhotoStation");PhotoStation.MapView=Ext.extend(Ext.Panel,{gpsData:[],defGpsData:{},lastZoom:-1,markerWidth:20,currThumbInfo:[],markers:[],selected:[],pageWidth:320+16,infoWin:null,infoTpl:null,infoContainer:null,infoThumb:null,defGPSInfo:null,lightboxStores:{},constructor:function(b){Main.addScope("PhotoStation.MapView",this);this.lightboxStores={};this.scale=1;var a={autoScroll:false,padding:"0 10px",border:false,layout:"fit",items:[{xtype:"panel",id:"gmapPanel",border:true,style:{border:"solid 1px rgb(160, 170, 180)"}}],listeners:{activate:this.onActive}};Ext.apply(a,b);PhotoStation.MapView.superclass.constructor.call(this,SYNO.LayoutConfig.fill(a))},onActive:function(){if(PhotoStation.CurrentBrowse.getRecord()&&PhotoStation.CurrentBrowse.isAlbum()){this.setAlbumDesc(PhotoStation.CurrentBrowse.getRecord().get("info").description)}if(this.infoWin){this.infoWin.close()}this.scale=1;this.mapCenter=null;this.firstLoad=true;this.isOpenInfoWin=true;this.lightboxStores={};this.loadGpsPhotoData()},initGMap:function(){this.defGPSInfo=this.getDefGPSInfo();if(this.gmap){this.triggerCenterEvent();return}var a={minZoom:1,zoom:12,center:this.defGPSInfo.center,streetViewControl:true,mapTypeId:google.maps.MapTypeId.ROADMAP,mapTypeControlOptions:{style:google.maps.MapTypeControlStyle.DROPDOWN_MENU},navigationControlOptions:{style:google.maps.NavigationControlStyle.BIG}};Ext.get("gmapPanel").setHeight(Ext.get("gmapPanel").getHeight());this.gmap=new google.maps.Map(Ext.get("gmapPanel").dom,a);this.gmap.overlay=new google.maps.OverlayView();this.gmap.overlay.draw=Ext.emptyFn;this.gmap.overlay.setMap(this.gmap);this.initInfoWindow();this.on("resize",this.onResizeMap);google.maps.event.addListener(this.gmap,"bounds_changed",this.onMapBoundsChangedDelay.createDelegate(this));google.maps.event.addListener(this.gmap,"click",this.onMapClick.createDelegate(this));google.maps.event.addListener(this.gmap.getStreetView(),"position_changed",this.onStreetViewPositionChanged.createDelegate(this));this.triggerCenterEvent.defer(500,this)},triggerCenterEvent:function(){this.gmap.setCenter(this.defGPSInfo.center);if(this.defGPSInfo.bounds){if(this.gpsData.length>1){this.gmap.fitBounds(this.defGPSInfo.bounds)}else{this.gmap.setZoom(5)}}else{this.gmap.setZoom(5)}},initInfoWindow:function(){this.infoWin=new google.maps.InfoWindow({map:this.gmap,content:this.el.createChild({id:"map-info-window",style:"position: relative; height: 268px; width: 100%"},null,true),maxWidth:283,pixelOffset:new google.maps.Size(0,-20,"px","px")});this.infoWin.close();this.infoThumb=Ext.get("map-info-window");this.infoTpl=new Ext.XTemplate('
{values.item.title:htmlEncode}
{[this.getCount(values)]}{[_PST("photo", "photo_str_view_all")]}{[_PST("photo", "photo_str_album_edit_gps_label")]}
',{getCount:function(b){return String.format("{0} {1}",b.count,_PST("photo","photo_str_items"))},getItemField:function(b,c){return b.item[c]}});this.infoTpl.compile();var a=this;google.maps.event.addListener(this.infoWin,"closeclick",this.onInfoWinCloseClick.createDelegate(this));google.maps.event.addListener(this.infoWin,"domready",function(){var c=Ext.get(a.infoWin.getContent());Ext.fly(c.parent().parent().parent().dom.childNodes[2]).addClass("mapview-gmap-close-btn");function b(d){function g(j){var i=j.target;a[i.getAttribute("ps:onclick")]({lat:i.getAttribute("ps:lat"),lng:i.getAttribute("ps:lng"),zoom:i.getAttribute("ps:zoom")},i.getAttribute("ps:arg"))}var f=document.querySelectorAll(d);for(var e=0,h=f.length;ef?d:f;e=eb?g:b;c=cc.indexOf("preview")&&0>c.indexOf("small"))){return}if(!d.get("additional").photo_exif.gps){return}f=d.get("additional").photo_exif.gps;a=d.get("additional").photo_exif.version%2===1;h=f.lat;j=f.lng;if(isNaN(h)||isNaN(j)){return}if(0===d.get("info").resolutionx||0===d.get("info").resolutiony){return}var n=PhotoStation.ThumbnailView.prototype.getImageSize.call(this,d);k=n.width;i=n.height;var g=212;if(k>320||i>g){if(k/320>i/g){i=Math.ceil(i*320/k);k=320}else{k=Math.ceil(k*g/i);i=g}}e=(320-k)/2;b=(g-i)/2;m.style=String.format("width:{0}px; height: {1}px; margin: {2}px {3}px;",k,i,b,e);m["wrap-style"]=String.format("background-image: none;");m.src=Main.getScope("PhotoStation.MapView").getImgSrc(d.data);m.title=Ext.util.Format.ellipsis(d.get("info").title,24);m.usepreview=Main.getScope("PhotoStation.MapView").getPreviewVisibility(d.data);m.gps=new google.maps.LatLng(parseFloat(h),parseFloat(j));m.id=d.get("id");return m},loadPhotoStoreCallback:function(b){var d,c,g,f,e;this.gpsData=[];var a=new Ext.data.JsonReader({idProperty:"gps_idx",fields:["gps_idx","count","item"]});for(d=0;da.thumbnail_status.indexOf("small")&&0<=a.thumbnail_status.indexOf("preview")){return true}return false},getImgSrc:function(a){if(0>a.thumbnail_status.indexOf("small")&&0<=a.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(a,{size:"preview"})}return PhotoStation.Util.getThumbUrl(a,{size:"small"})},refresh:function(){this.setGpsData(true)},loadMore:function(b){var c=50;if(this.appending){return}this.appending=true;var a=this.getLightboxStore(this.groupIdx.lat,this.groupIdx.lng);var f=a.getTotalCount(),e=a.getCount();if(f<=e){this.appending=false;return}this.addMoreMode="append";if(this.store2){this.store2.destroy()}this.store2=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:a.proxy.url,listeners:{beforeload:function(h,i){var j=h.activeRequest.read;if(j){Ext.Ajax.abort(j)}}}}),baseParams:a.baseParams,root:a.root,idProperty:a.idProperty,totalProperty:a.totalProperty,fields:a.fields.keys});var g=PhotoStation.Util.appendCurrentFilter({offset:e,limit:c,zoom:this.gmap.getZoom(),gps_idx:Ext.encode(this.groupIdx)});var d={params:g,callback:this.loadMoreCallback.createDelegate(this,[g.offset,b],true),scope:this};this.store2.load(d)},needLoadMore:function(a,e){var b=this.getLightboxStore(this.groupIdx.lat,this.groupIdx.lng);var d=b.getTotalCount(),c=b.getCount();if(d>c&&a+e>c){return true}return false},loadMoreCallback:function(f,e,a,g,c){var h=this.addMoreMode;this.addMoreMode=undefined;this.appending=false;var b=this.getLightboxStore(this.groupIdx.lat,this.groupIdx.lng);if(!b||!a||!f.length){return}var d=Main.getScope("PhotoStation.LightBox");if("append"===h){b.add(this.store2.getRange())}else{return}if(!Ext.isEmpty(d)&&-1!==d.index){d.loadMoreCallback(g,this.store2,{addMode:h})}if(Ext.isFunction(c.callback)){c.callback()}},updateScrollbar:function(){},setAlbumDesc:function(a){Main.getScope("PhotoStation.AlbumDescBar").setDescText(a)},clickMapThumb:function(c,g){if("true"===Ext.get(g).getAttribute("usepreview")){return}var b=this.getLightboxStore(c.lat,c.lng),e;this.groupIdx=c;e=Main.getScope("PhotoStation.LightBox");if(!e){e=new PhotoStation.LightBox();e.hide()}if(b.getCount()){var a=b.getById(g.substr(14)),d;if(e.lightBoxFilter(a)){e.show(g.substr(14),b)}else{if((d=b.queryBy(e.lightBoxFilter))&&d.getCount()){e.show(d.get(0).id,b)}}}else{var f=PhotoStation.Util.appendCurrentFilter();f.zoom=c.zoom;f.gps_idx=Ext.encode({lat:c.lat,lng:c.lng});f.limit=50;f.offset=0;b.load({params:f,callback:function(i,j,m){if(!m){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("phtot","photo_str_error_load_data"));return}var h=b.getById(g.substr(14)),k;if(e.lightBoxFilter(h)){e.show(g.substr(14),b)}else{if((k=b.queryBy(e.lightBoxFilter))&&k.getCount()){e.show(k.get(0).id,b)}}},scope:this})}},clickEditGeoTag:function(b,e){var a=this.getLightboxStore(b.lat,b.lng),c;if(a.getCount()){c=a.getRange();this.setSelectedRecords(c);Main.getScope("PhotoStation.CenterPanel").clickEditGeoTag()}else{var d=PhotoStation.Util.appendCurrentFilter();d.zoom=b.zoom;d.gps_idx=Ext.encode({lat:b.lat,lng:b.lng});d.limit=-1;d.offset=0;a.load({params:d,callback:function(f,g,h){if(!h){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("phtot","photo_str_error_load_data"));return}c=a.getRange();this.setSelectedRecords(c);Main.getScope("PhotoStation.CenterPanel").clickEditGeoTag()},scope:this})}},getLightboxStore:function(a,b){if(undefined===typeof(a)||undefined===typeof(b)){return}this.lightboxStores[a+","+b]=this.lightboxStores[a+","+b]||new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("photo.php"),listeners:{beforeload:function(c,d){var e=c.activeRequest.read;if(e){Ext.Ajax.abort(e)}}}}),baseParams:{api:"SYNO.PhotoStation.Photo",method:"listgpsgroupeditem",version:1,type:"photo",additional:"photo_exif,thumb_size",zoom:5},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail","thumbnail_status","info","additional","pos"]});return this.lightboxStores[a+","+b]},clearLightboxStores:function(){var a;for(a in this.lightboxStores){if(this.lightboxStores[a]){this.lightboxStores[a].destroy();delete this.lightboxStores[a]}}},setSelectedRecords:function(a){this.selected=a},getSelectedRecords:function(){return this.selected}});Ext.ns("PhotoStation");PhotoStation.CopyDestinationWindow=Ext.extend(PhotoStation.BaseWindow,{albumList:"",fileList:"",form:null,constructor:function(b){Main.addScope("PhotoStation.MoveCopyWindow",this);this.showRoot=b.showRoot;this.albumList=b.albumList;this.isCopy=b.isCopy;this.fileList=b.fileList;this.selector=new PhotoStation.FileSelector({itemId:"albumTreePanel",width:400,height:420,rootVisible:true,showCheck:false,userPrivilege:"upload",border:true,listeners:{single:true,scope:this,afterrender:function(c){this.el.mask(_PST("photo","photo_str_loading"));c.selectPath("/"+PhotoStation.History.getToken())},load:function(){this.el.unmask()}}});var a={title:_PST("photo","photo_str_man_choose_location"),width:600,height:480,minWidth:500,minHeight:300,layout:"fit",items:this.selector,cls:"photo-window copy-move-window photo-fileselector",listeners:{close:PhotoStation.Util.closeWaitMsg},tbar:{style:"padding: 2px 20px;",items:this.getTbarItems()},buttons:[{text:_PST("photo","photo_str_arrange_album_order_save"),scope:this,cls:"photo-blue-button photo-button",handler:this.saveAllSetting},{text:_PST("photo","photo_str_btnClose"),scope:this,cls:"photo-grey-button photo-button",handler:function(){this.close()}}]};Ext.apply(a,b);PhotoStation.CopyDestinationWindow.superclass.constructor.call(this,a);this.addEvents("moveSuccess")},getTbarItems:function(){var a=[["ignore",_PST("photo","photo_str_upload_skip")],["overwrite",_PST("photo","photo_str_upload_overwrite")]];if(!this.albumList){a.push(["rename",_PST("photo","photo_str_upload_rename")])}return[{xtype:"button",text:_PST("photo","photo_str_create_folder"),cls:"photo-grey-button photo-button",scope:this,handler:this.clickCreate},{xtype:"tbfill"},{xtype:"tbtext",text:_PST("photo","photo_str_upload_file_exist")+": "},{xtype:"combo",id:this.writeStrategyComboId=Ext.id(),store:new Ext.data.SimpleStore({fields:["value","strategy"],data:a}),displayField:"strategy",valueField:"value",triggerAction:"all",value:"ignore",editable:false,width:110,mode:"local"}]},clickCreate:function(){var a=this.selector.getSelectionModel().getSelectedNode();if(!a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_man_choose_location_first"));return}var b=Main.getScope("PhotoStation.SettingWindow");if(!b){b=new PhotoStation.SettingWindow()}b.showCreateAlbum({record:a.attributes.record,createCallback:(function(d,c){Main.getScope("PhotoStation.LeftContent").reloadAlbums(c);if(c===PhotoStation.CurrentBrowse.getId()){Main.getScope("PhotoStation.ViewCard").containerReLoad()}a.reload(function(){this.selector.selectPath(this.selector.getSelectionModel().getSelectedNode().getPath()+"/"+d)},this)}).createDelegate(this)})},saveAllSetting:function(){var c=this.selector.getSelectionModel().getSelectedNode();if(!c){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_man_choose_location_first"));return}this.isMoveAction=false;PhotoStation.Util.showWaitMsg({scope:this,fn:this.cancelAjax});var b=Ext.getCmp(this.writeStrategyComboId).getValue();var d="";if(this.isCopy){d="copy"}else{d="move";this.isMoveAction=true}var a=PhotoStation.Define.ALBUM_CATEGORY===c.id?"":c.id;if(!this.fileList){this.copyFileCallback(true,null,null,null,b,a);return}this.photoAjaxId=SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Photo","copy",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:this.fileList,mode:d,duplicate:b,sharepath:a},this.copyFileCallback.createDelegate(this,[b,a],true),this);this.hide()},copyFileCallback:function(g,f,e,b,c,a){if(!g){var d=PhotoStation.Util.getErrMsg(f);if(457==f.code){d=_PST("photo","photo_permission_denied_upload")}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),d);this.close();return}if(this.isCopy){this.close();return}if(this.albumList){this.albumAjaxId=SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Album","move",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:this.albumList,duplicate:c,sharepath:a},function(u,n,o,h){if(!u){var k=PhotoStation.Util.getErrMsg(n);if(419==n.code){k=_PST("photo","photo_permission_denied_upload")}else{if(425===n.code){k=_PST("photo","photo_str_select_conflict")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),k);return}var s=[],q=0,p=0,m,t=false;var r=this.albumList.split(",");for(q=0;q",this.getUserFilter(),this.getGroupFilter()]},items:[{xtype:"panel",region:"west",width:230,padding:10,cls:"permission-setting-window-west",border:false,items:[{xtype:"button",id:this.userBtnId=Ext.id(),width:200,height:30,text:_PST("photo","photo_str_privilege_user_privilege"),scope:this,handler:function(){this.getComponent("albumEditTabPanel").getLayout().setActiveItem(0);Ext.get(this.userBtnId).removeClass("x-btn-unselected");Ext.get(this.groupBtnId).removeClass("x-btn-selected");Ext.get(this.userBtnId).addClass("x-btn-selected");Ext.get(this.groupBtnId).addClass("x-btn-unselected");this.getUserFilter().setVisible(true);this.getGroupFilter().setVisible(false)}},{xtype:"button",id:this.groupBtnId=Ext.id(),width:200,height:30,text:_PST("photo","photo_str_privilege_group_privilege"),scope:this,handler:function(){this.getComponent("albumEditTabPanel").getLayout().setActiveItem(1);Ext.get(this.userBtnId).removeClass("x-btn-selected");Ext.get(this.groupBtnId).removeClass("x-btn-unselected");Ext.get(this.userBtnId).addClass("x-btn-unselected");Ext.get(this.groupBtnId).addClass("x-btn-selected");this.getUserFilter().setVisible(false);this.getGroupFilter().setVisible(true)}}]},{xtype:"panel",region:"center",itemId:"albumEditTabPanel",activeTab:0,plain:true,frame:false,layout:"card",activeItem:0,deferredRender:false,border:false,padding:20,style:{"background-color":"white"},items:[this.getUserPermissionTabConf(),this.getGroupPermissionTabConf()]}],buttons:[{text:_PST("photo","photo_str_btnOK"),scope:this,cls:"photo-blue-button photo-button",handler:function(){this.saveAllSetting()}},{text:_PST("photo","photo_str_btnCancel"),scope:this,cls:"photo-grey-button photo-button",handler:function(){this.close()}}]};Ext.apply(a,b);PhotoStation.PermissionSettingWindow.superclass.constructor.call(this,a);this.tabPanel=this.getComponent("albumEditTabPanel");this.userPermissionTab=this.tabPanel.getComponent("userPermissionTab");this.groupPermissionTab=this.tabPanel.getComponent("groupPermissionTab");this.addEvents("updatepermission");this.on("show",function(){Ext.get(this.userBtnId).addClass("x-btn-selected");Ext.get(this.groupBtnId).addClass("x-btn-unselected");this.userStore.load();this.groupStore.load()},this)},getUserFilter:function(){if(!this.userFilter){this.userFilter=new SYNO.TextFilter({itemId:"user_filter",width:220,hidden:false,emptyText:_PST("photo","photo_str_search"),store:this.getUserStore(),pageSize:this.pageSize})}return this.userFilter},getGroupFilter:function(){if(!this.groupFilter){this.groupFilter=new SYNO.TextFilter({itemId:"group_filter",width:220,hidden:true,emptyText:_PST("photo","photo_str_search"),store:this.getGroupStore(),pageSize:this.pageSize})}return this.groupFilter},getUserStore:function(){if(!this.userStore){this.userStore=new Ext.data.JsonStore({baseParams:{api:"SYNO.PhotoStation.Permission",method:"getalbum",version:1,id:this.albumID,type:"user_permission"},paramNames:{start:"offset"},proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("permission.php"),method:"POST",listeners:{scope:this,exception:function(g,d,f,c,b,a){var e=Ext.util.JSON.decode(b.responseText);Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data")+" ("+e.error.code+")");this.close()}}}),root:"data.user_permission",totalProperty:"data.total_user_count",id:"id",fields:["id","name","description",{name:"browse",mapping:"permission.browse"},{name:"browse_orig",mapping:"permission.browse"},{name:"upload",mapping:"permission.upload"},{name:"upload_orig",mapping:"permission.upload"},{name:"manage",mapping:"permission.manage"},{name:"manage_orig",mapping:"permission.manage"},"disabled"],listeners:{beforeload:{fn:function(){this.body.mask(_PST("photo","photo_str_loading"));this.updateRecordLists(this.userStore,false)},scope:this},load:{fn:function(){if(this.isAdd){if(false===this.firstOpen){this.updateRecord(this.userStore,this.uBrowseList,this.uUploadList,this.uManageList)}else{this.updateAccessRight(this.userStore)}}this.updateModifiedRecord(this.userStore,this.userRecordList);this.checkAllRecord(0,false);this.checkAllRecord(1,false);this.checkAllRecord(2,false);this.body.unmask()},scope:this}}})}return this.userStore},getGroupStore:function(){if(!this.groupStore){this.groupStore=new Ext.data.JsonStore({baseParams:{api:"SYNO.PhotoStation.Permission",method:"getalbum",version:1,id:this.albumID,type:"group_permission"},paramNames:{start:"offset"},proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("permission.php"),method:"POST"}),root:"data.group_permission",totalProperty:"data.total_group_count",id:"id",fields:["id","name","description",{name:"browse",mapping:"permission.browse"},{name:"browse_orig",mapping:"permission.browse"},{name:"upload",mapping:"permission.upload"},{name:"upload_orig",mapping:"permission.upload"},{name:"manage",mapping:"permission.manage"},{name:"manage_orig",mapping:"permission.manage"},"disabled"],listeners:{beforeload:{fn:function(){this.body.mask(_PST("photo","photo_str_loading"));this.updateRecordLists(this.groupStore,true)},scope:this},load:{fn:function(){if(this.isAdd){if(false===this.firstOpen){this.updateRecord(this.groupStore,this.gBrowseList,this.gUploadList,this.gManageList)}else{this.updateAccessRight(this.groupStore)}}this.updateModifiedRecord(this.groupStore,this.groupRecordList);this.checkAllRecord(0,true);this.checkAllRecord(1,true);this.checkAllRecord(2,true);this.body.unmask()},scope:this}}})}return this.groupStore},getUserPermissionTabConf:function(){this.userPermission=this.userPermission||new Ext.grid.GridPanel({pageSize:this.pageSize,itemId:"userPermissionTab",store:this.getUserStore(),border:false,cls:"syno-ux-gridpanel permission-setting-window",enableColumnMove:false,viewConfig:{autoFill:true,forceFit:true},columns:[{header:_PST("photo","photo_username"),dataIndex:"name",menuDisabled:true,sortable:true,width:190,renderer:function(e,b,a,f,d,c){e=Ext.util.Format.htmlEncode(e);return'  '+e+""}},{header:_PST("photo","photo_str_description"),dataIndex:"description",menuDisabled:true,sortable:false,width:150,renderer:"htmlEncode",id:"account_man_description"},{header:" "+_PST("photo","photo_str_privilege_browse"),width:110,dataIndex:"browse",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderCheckBoxForBrowse,scope:this}},{header:" "+_PST("photo","photo_str_privilege_upload"),width:110,dataIndex:"upload",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderCheckBoxForUpload,scope:this}},{header:" "+_PST("photo","photo_str_privilege_manage"),width:120,dataIndex:"manage",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderCheckBoxForManage,scope:this}}],bbar:new SYNO.ux.PagingToolbar({store:this.userStore,pageSize:this.pageSize,displayInfo:true}),listeners:{headerclick:{fn:function(c,a,b){return onClickHeaderCheckBox(b,a-2)},scope:this},cellclick:{fn:function(b,h,a,c){if(0===a||1==a){return}var g=this.userStore.getAt(h);var f="";if(2===a){f="checkbox_album_"}else{if(3===a){f="checkbox_album_for_upload_"}else{f="checkbox_album_for_manage_"}}var d=Ext.getDom(f+g.get("id"));if(d.disabled){return}if(2===a){this.setGridCheckBoxForBowse(g.id,!g.get("browse")?1:0,false)}else{if(3===a){this.setGridCheckBoxForUpload(g.id,!g.get("upload")?1:0,false)}else{if(4===a){this.setGridCheckBoxForManage(g.id,!g.get("manage")?1:0,false)}}}},scope:this}}});return this.userPermission},getGroupPermissionTabConf:function(){this.groupPermission=this.groupPermission||new Ext.grid.GridPanel({pageSize:this.pageSize,itemId:"groupPermissionTab",store:this.getGroupStore(),border:false,cls:"syno-ux-gridpanel permission-setting-window",enableColumnMove:false,viewConfig:{autoFill:true,forceFit:true},columns:[{header:_PST("photo","photo_str_group"),dataIndex:"name",menuDisabled:true,sortable:true,width:190,renderer:function(e,b,a,f,d,c){e=Ext.util.Format.htmlEncode(e);return'  '+e+""}},{header:_PST("photo","photo_str_description"),dataIndex:"description",menuDisabled:true,sortable:false,width:150,renderer:"htmlEncode",id:"group_man_description"},{header:" "+_PST("photo","photo_str_privilege_browse"),width:110,dataIndex:"browse",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderGroupCheckBoxForBrowse,scope:this}},{header:" "+_PST("photo","photo_str_privilege_upload"),width:110,dataIndex:"upload",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderGroupCheckBoxForUpload,scope:this}},{header:" "+_PST("photo","photo_str_privilege_manage"),width:120,dataIndex:"manage",align:"center",sortable:false,menuDisabled:true,renderer:{fn:this.renderGroupCheckBoxForManage,scope:this}}],bbar:new SYNO.ux.PagingToolbar({store:this.groupStore,pageSize:this.pageSize,displayInfo:true}),listeners:{headerclick:{fn:function(b,a,c){return onClickHeaderCheckBox(c,a-2,true)},scope:this},cellclick:{fn:function(b,h,a,c){if(0===a||1==a){return}var g=this.groupStore.getAt(h);var f="";if(2===a){f="group_checkbox_album_"}else{if(3===a){f="group_checkbox_album_for_upload_"}else{f="group_checkbox_album_for_manage_"}}var d=Ext.getDom(f+g.get("id"));if(d.disabled){return}if(2===a){this.setGridCheckBoxForBowse(g.id,!g.get("browse")?1:0,true)}else{if(3===a){this.setGridCheckBoxForUpload(g.id,!g.get("upload")?1:0,true)}else{if(4===a){this.setGridCheckBoxForManage(g.id,!g.get("manage")?1:0,true)}}}},scope:this}}});return this.groupPermission},renderCheckBoxForBrowse:function(f,a,c,e,i,h){SYNO.Debug("Privilege User Browse = "+f);var g="";var b="";var d="";if("public"===this.privilege){g="checked";b="disabled";d='class="photo-grid-checked photo-grid-disabled"'}else{g=f?"checked":"";b="";d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):""}if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},renderCheckBoxForUpload:function(f,a,c,e,i,h){SYNO.Debug("Privilege User Upload = "+f);var g=f?"checked":"";var b="";var d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):"";if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},renderCheckBoxForManage:function(f,a,c,e,i,h){SYNO.Debug("Privilege User Manage = "+f);var g=f?"checked":"";var b="";var d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):"";if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},renderGroupCheckBoxForBrowse:function(f,a,c,e,i,h){SYNO.Debug("Privilege Group Browse = "+f);var g="";var b="";var d="";if("public"===this.privilege){g="checked";b="disabled";d='class="photo-grid-checked photo-grid-disabled"'}else{g=f?"checked":"";b="";d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):""}if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},renderGroupCheckBoxForUpload:function(f,a,c,e,i,h){SYNO.Debug("Privilege Group Upload = "+f);var g=f?"checked":"";var b="";var d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):"";if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},renderGroupCheckBoxForManage:function(f,a,c,e,i,h){SYNO.Debug("Privilege Group Manage = "+f);var g=f?"checked":"";var b="";var d=f||c.get("disabled")?String.format('class="{0} {1}"',f?"photo-grid-checked":"",c.get("disabled")?"photo-grid-disabled":""):"";if(c.get("disabled")){g="";b="disabled"}return String.format('',c.id,g,b,d)},setGridCheckBoxAll:function(b,c,d){var a=null;if(!d){a=this.userStore}else{a=this.groupStore}a.suspendEvents();a.each(function(e){if(1===c){this.updateRecordForUpload(e,b)}else{if(2===c){this.updateRecordForManage(e,b)}else{this.updateRecordForBrowse(e,b)}}},this);if(!d){this.userPermission.getView().refresh()}else{this.groupPermission.getView().refresh()}a.resumeEvents();this.checkAllRecord(0,d);this.checkAllRecord(1,d);this.checkAllRecord(2,d)},setGridCheckBoxForBowse:function(c,a,b){if(!b){this.updateRecordForBrowse(this.userStore.getById(c),a)}else{this.updateRecordForBrowse(this.groupStore.getById(c),a)}this.checkAllRecord(0,b);this.checkAllRecord(1,b);this.checkAllRecord(2,b)},setGridCheckBoxForUpload:function(c,a,b){if(!b){this.updateRecordForUpload(this.userStore.getById(c),a)}else{this.updateRecordForUpload(this.groupStore.getById(c),a)}this.checkAllRecord(0,b);this.checkAllRecord(1,b);this.checkAllRecord(2,b)},setGridCheckBoxForManage:function(c,a,b){if(!b){this.updateRecordForManage(this.userStore.getById(c),a)}else{this.updateRecordForManage(this.groupStore.getById(c),a)}this.checkAllRecord(0,b);this.checkAllRecord(1,b);this.checkAllRecord(2,b)},updateRecordForBrowse:function(a,d){if(a.get("disabled")){return}a.set("browse",d);if(d==a.get("browse_orig")){a.commit();var b=a.get("upload");if(b!=a.get("upload_orig")){a.set("upload",!b);a.set("upload",b)}var c=a.get("manage");if(c!=a.get("manage_orig")){a.set("manage",!c);a.set("manage",c)}}if(!d){this.updateRecordForUpload(a,0);this.updateRecordForManage(a,0)}},updateRecordForUpload:function(a,c){if(a.get("disabled")){return}a.set("upload",c);if(c==a.get("upload_orig")){a.commit();var d=a.get("browse");if(d!=a.get("browse_orig")){a.set("browse",!d);a.set("browse",d)}var b=a.get("manage");if(b!=a.get("manage_orig")){a.set("manage",!b);a.set("manage",b)}}if(!c){this.updateRecordForManage(a,0)}if(c){this.updateRecordForBrowse(a,1)}},updateRecordForManage:function(a,c){if(a.get("disabled")){return}a.set("manage",c);if(c==a.get("manage_orig")){a.commit();var d=a.get("browse");if(d!=a.get("browse_orig")){a.set("browse",!d);a.set("browse",d)}var b=a.get("upload");if(b!=a.get("upload_orig")){a.set("upload",!b);a.set("upload",b)}}if(c){this.updateRecordForBrowse(a,1);this.updateRecordForUpload(a,1)}},checkAllRecord:function(f,g){g=typeof g!=="undefined"?g:false;var e="";var d="";var i="";var a=true;var c=true;var b=true;if(0===f){e="access_permission_grid_checkbox";d="checkbox_album_";i="browse"}else{if(1===f){e="upload_permission_grid_checkbox";d="checkbox_album_for_upload_";i="upload"}else{e="manage_permission_grid_checkbox";d="checkbox_album_for_manage_";i="manage"}}if(g){e="group_"+e;d="group_"+d}if(!g&&0===this.userStore.getTotalCount()){Ext.getDom(e).checked=false;return}else{if(g&&0===this.groupStore.getTotalCount()){Ext.getDom(e).checked=false;return}}var h=null;if(!g){h=this.userStore}else{h=this.groupStore}h.each(function(j){var k=Ext.getDom(d+j.get("id"));if(0===j.get(i)){c=false}if(!k.disabled){b=false;if(0===j.get(i)){a=false;return false}}});if((b&&c)||(!b&&a)){Ext.get(e).addClass("photo-grid-checked")}else{Ext.get(e).removeClass("photo-grid-checked")}if(b){Ext.getDom(e).checked=c;Ext.getDom(e).disabled=true;Ext.get(e).addClass("photo-grid-disabled")}else{Ext.getDom(e).checked=(a)?true:false;Ext.getDom(e).disabled=false;Ext.get(e).removeClass("photo-grid-disabled")}},updateRecord:function(c,b,d,a){c.each(function(e){e.set("browse",0);e.set("upload",0);e.set("manage",0);e.set("browse_orig",0);e.set("upload_orig",0);e.set("manage_orig",0);var f=0;for(f=0;f','','
','
','
','
',"
","
",'
',"
","
","
",'
','','
',"
","
","
",'
','
','
{[this.getTitle(values)]}
',"
","
","
","
",'
',{getImgUrl:function(b){return PhotoStation.Util.getTemplateImgUrl(b)},getPreviewClass:function(b){if("defaultsmart"===b.type){return""}if(((0>b.thumbnail_status.indexOf("small"))&&(0<=b.thumbnail_status.indexOf("preview")))||(0<=b.thumbnail_status.indexOf("watermark"))){return"thumb-preview"}return""},getAlbumInfoVisibility:function(b){if(-1!==["album","smart","defaultsmart","tag","sharedalbum"].indexOf(b.type)){return"visible"}return"hidden"},getTitle:function(b){var c;if(-1!==["smart","defaultsmart","tag","sharedalbum"].indexOf(b.type)){c=b.name}else{c=b.info.title}return Ext.util.Format.htmlEncode(c)},getVideoIconClass:function(b){if("video"!==b.type){return""}if(-1!==["broken",""].indexOf(b.thumbnail_status)){return""}if(-1===b.thumbnail_status.indexOf("small")&&-1!==b.thumbnail_status.indexOf("disable")){return""}return"thumb-video-icon"},getPublicShareStatusClass:function(b){if("sharedalbum"!==b.type){return""}if("none"===b.share_status){return""}else{if("valid"===b.share_status){return"public-share-valid"}else{if("invalid"===b.share_status||"expired"===b.share_status){return"public-share-invalid"}}}return""}});a.compile();return a},getTemplateTarget:function(){var a=this;a.scrollBar=a.scrollBar||a.el.createChild({tag:"div",style:"display:inline-block;width:100%;"});return a.scrollBar},refresh:function(){PhotoStation.PhotowallView.superclass.refresh.apply(this,arguments);this.loader.clear();this.resizeImages();this.preloadItems()},getImageItems:function(a,b){Ext.each(a,function(f,d,e){var c=Ext.fly(f).select("img").elements;if(0a.scrollPosition[1][1]-a.scrollPosition[1][0]){this.loadMore()}},onUpdate:function(){PhotoStation.PhotowallView.superclass.onUpdate.call(this);this.delayedCheckLoadMore.delay(250)},loadMore:function(a,e){if(this.appending||!this.more){return}this.appending=true;var d=this.store.getTotalCount(),c=this.store.getCount();c-=PhotoStation.Util.getManualInsertCount(this.store);if(d<=c){this.appending=false;this.more=false;return}if(!e){Main.getScope("PhotoStation.LoadMoreBar").show()}if(this.store2){this.store2.destroy()}var f=Ext.apply({},PhotoStation.Util.getContainerLoadParams(),this.store.baseParams);this.store2=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:this.store.proxy.url,listeners:{beforeload:function(g,h){var i=g.activeRequest.read;if(i){Ext.Ajax.abort(i)}}}}),baseParams:f,root:this.store.root,idProperty:this.store.idProperty,totalProperty:this.store.totalProperty,fields:this.store.fields.keys});if(PhotoStation.Info.paging_use_bar){f.offset=Math.max(0,a.offset)}else{f.offset=c}var b={params:f,callback:this.loadMoreCallback.createDelegate(this,[f.offset,a],true),scope:this};this.store2.removeAll();this.store2.load(b)},loadMoreCallback:function(g,f,a,h,b){if(!this.store){return}Main.getScope("PhotoStation.LoadMoreBar").hide();if(!this.ownerCt.firstLoadMoreFinished){this.ownerCt.firstLoadMoreFinished=true}if(!a||!g.length){this.appending=false;this.more=false;return}function e(){return false}if(!PhotoStation.Info.paging_use_bar){this.store.add(g);for(var d=0;d=u||0>=F){K=u;g=F}else{if(u*o=t||(0=s)){if(0o){v[B].style.width=D+"px";v[B].style.height=f+"px";v[B].style.marginTop="auto";v[B].style.marginLeft=(I-D)/2+"px"}else{if(q<1/o){v[B].style.width=I+"px";v[B].style.height=d+"px";v[B].style.marginTop=(f-d)/2+"px"}else{v[B].style.width=I+"px";v[B].style.height=f+"px";v[B].style.marginTop="auto"}}}else{v[B].style.width="auto";v[B].style.maxWidth=d?I+"px":"none";v[B].style.height="auto";v[B].style.maxHeight=D?f+"px":"none";v[B].style.marginTop=(1===q||I>D)?this.getMarginTopValue(f,e[B].get("additional").thumb_size)+"px":(f-d)/2+"px"}z[B].style.width=I+"px";z[B].style.height=f+"px";k[B].style.width=(I-A)+"px";k[B].style.height=(f-A)+"px"}}else{if(0o){v[B].style.width=D+"px";v[B].style.height=a+"px";v[B].style.marginTop="auto";v[B].style.marginLeft=(I-D)/2+"px"}else{if(q<1/o){v[B].style.width=I+"px";v[B].style.height=d+"px";v[B].style.marginTop=(f-d)/2+"px";v[B].style.marginLeft="none"}else{v[B].style.width=I+"px";v[B].style.height=a+"px";v[B].style.marginTop="auto";v[B].style.marginLeft="none"}}}else{v[B].style.width="auto";v[B].style.maxWidth=d?I+"px":"none";v[B].style.height="auto";v[B].style.maxHeight=D?a+"px":"none";v[B].style.marginTop=(1===q||I>D)?this.getMarginTopValue(a,e[B].get("additional").thumb_size)+"px":(a-d)/2+"px"}z[B].style.width=I+"px";z[B].style.height=a+"px";k[B].style.width=(I-A)+"px";k[B].style.height=(a-A)+"px"}}else{J=-1*t/(C-p+1);t=G-(C-p+1)*x;for(B=p;B<=C;B++){if(C===B){I=t}else{I=Math.round(e[B].get("newW")-J,0);t-=I}q=e[B].get("realRatio");D=Math.floor(a*q);d=Math.floor(I/q);v[B].style.width="auto";v[B].style.maxWidth=d?I+"px":"none";v[B].style.height="auto";v[B].style.maxHeight=D?a+"px":"none";v[B].style.marginTop=this.getMarginTopValue(a,e[B].get("additional").thumb_size)+"px";z[B].style.width=I+"px";z[B].style.height=a+"px";k[B].style.width=(I-A)+"px";k[B].style.height=(a-A)+"px"}}}p=B;H=0;s=Number.MAX_VALUE;t=G+0;y=0}}if(0=s){f=s}else{f=b}}else{f=a}for(B=p;Bo){v[B].style.width=D+"px";v[B].style.height=f+"px";v[B].style.marginTop="auto";v[B].style.marginLeft=(I-D)/2+"px"}else{if(q<1/o){v[B].style.width=I+"px";v[B].style.height=d+"px";v[B].style.marginTop=(f-d)/2+"px"}else{v[B].style.width=I+"px";v[B].style.height=f+"px";v[B].style.marginTop="auto"}}z[B].style.width="auto";z[B].style.height=f+"px"}else{I=e[B].get("newW");v[B].style.width="auto";v[B].style.maxWidth=I+"px";v[B].style.height="auto";v[B].style.maxHeight="none";v[B].style.marginTop=this.getMarginTopValue(f,e[B].get("additional").thumb_size)+"px";z[B].style.width=I+"px";z[B].style.height=f+"px"}k[B].style.width=(I-A)+"px";k[B].style.height=(f-A)+"px"}this.offset=p;Ext.util.CSS.updateRule(".thumbnail-view .album-info","width","100%");this.delayedUpdateScrollbar.delay(500)},getMarginTopValue:function(a,c){var b=c.small.resolutiony===0?c.preview.resolutiony:c.small.resolutiony;return(a-(b||50))/2},setAlbumDesc:function(b){var a=Ext.fly(this.albumDescId);if(!a){return}if(b){a.addClass("album-desc-bar").update(Ext.util.Format.htmlEncode(b))}else{a.removeClass("album-desc-bar").update("")}Main.getScope("PhotoStation.AlbumDescBar").setVisible(false)}});Ext.ns("PhotoStation");PhotoStation.PinHereWindow=Ext.extend(PhotoStation.BaseWindow,{constructor:function(a){Main.addScope("PhotoStation.PinHereWindow",this);PhotoStation.PinHereWindow.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={title:_PST("photo","photo_str_pin_here"),width:400,height:600,minWidth:400,minHeight:600,layout:"fit",buttons:[{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:this.clickCancel,scope:this}],items:this.selector=new PhotoStation.FileSelector({showCheck:true})};return Ext.apply(a,b)},clickOK:function(){var c=this.selector.getCheckedIdList();if(!c.length){return}var b=PhotoStation.CurrentBrowse.getRecord(),a=Main.getScope("PhotoStation.ViewCard");Main.getScope("PhotoStation.CenterPanel").doPin(b.get("id"),c,a.containerLoad.createDelegate(a,[b,true]));this.close()},clickCancel:function(){this.close()}});Ext.ns("PhotoStation.Puny");PhotoStation.Puny.getPunyHostname=function(){var a=[],c=location.hostname.split(".");var b;for(b=0;b65535){u-=65536;r.push(String.fromCharCode(((u>>>10)&1023)|55296));u=56320|(u&1023)}r.push(String.fromCharCode(u))}return r.join("")}function k(q){return q-48<10?q-22:q-65<26?q-65:q-97<26?q-97:c}function o(r,q){return r+22+75*(r<26)-((q!==0)<<5)}function j(t,s,r){var q;t=r?Math.floor(t/e):(t>>1);t+=Math.floor(t/s);for(q=0;t>(((c-b)*h)>>1);q+=c){t=Math.floor(t/(c-b))}return Math.floor(q+(c-b+1)*t/(t+p))}function i(r,q){r-=(r-97<26)<<5;return r+((!q&&(r-65<26))<<5)}return{decode:function(y,s){var v=[];var J=[];var D=y.length;var C,H,G,u,r,F,B,q,x,E,A,z,I;C=g;G=0;u=m;r=y.lastIndexOf(a);if(r<0){r=0}for(F=0;F=128){throw new RangeError("Illegal input >= 0x80")}v.push(y.charCodeAt(F))}for(B=r>0?r+1:0;B=D){throw new RangeError("punycode_bad_input(1)")}A=k(y.charCodeAt(B++));if(A>=c){throw new RangeError("punycode_bad_input(2)")}if(A>Math.floor((d-G)/x)){throw new RangeError("punycode_overflow(1)")}G+=A*x;z=E<=u?b:E>=u+h?h:E-u;if(AMath.floor(d/(c-z))){throw new RangeError("punycode_overflow(2)")}x*=(c-z)}H=v.length+1;u=j(G-q,H,q===0);if(Math.floor(G/H)>d-C){throw new RangeError("punycode_overflow(3)")}C+=Math.floor(G/H);G%=H;if(s){J.splice(G,0,y.charCodeAt(B-1)-65<26)}v.splice(G,0,C);G++}if(s){for(G=0,I=v.length;G=w&&GMath.floor((d-H)/(B+1))){throw new RangeError("punycode_overflow (1)")}H+=(x-w)*(B+1);w=x;for(A=0;Ad){return Error("punycode_overflow(2)")}}if(G==w){for(u=H,z=c;;z+=c){I=z<=C?b:z>=C+h?h:z-C;if(u",{text:_PST("photo","photo_str_btnOK"),id:"btn_send",scope:this,cls:"photo-blue-button photo-button",handler:this.sendMessage},{text:_PST("photo","photo_str_btnCancel"),id:"btn_cancel",cls:"photo-grey-button photo-button",scope:this,handler:function(){this.close()}}]};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);PhotoStation.SendSocialMessageWindow.superclass.constructor.call(this,a);this.on("show",function(){this.delToken=Ext.get("fb_deletetoken");this.updateStatusImg=Ext.get("fb_status_loading");this.fbPic=Ext.get("fb_pic");this.fbAuthorize=Ext.get("fb_authorize");this.fbAuthorizeUsername=Ext.get("fb_authorize_username");this.fbProviderIcon=Ext.get("fb_provider_icon");this.superbox=Ext.getCmp("send_to_superbox");this.message=Ext.getCmp("message");this.message.setValue(this.page_link);this.label_status=Ext.get("fb_status");this.superbox.disable();this.delToken.dom.innerHTML=_PST("photo","photo_logout");this.delToken.hide();this.fbAuthorize.dom.innerHTML="";this.fbAuthorizeUsername.dom.innerHTML="";this.setFacebookUserPicture("");this.mon(this.delToken,"click",function(){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_confirm_logout"),function(c){if(c!="yes"){return}this.deleteToken()},this)},this);this.updateFacebookStatus()},this)},setFacebookUserPicture:function(b){var a="images/White/defalut_image.png";if(b){a=String.format("https://graph.facebook.com/{0}/picture",b.uid)}this.fbPic.dom.src=a},getItemConfig:function(){var b="fb_utils.php";this.friend_store=new Ext.data.JsonStore({autoLoad:false,proxy:new Ext.data.HttpProxy({url:b,method:"POST"}),baseParams:{action:"get_user_friends"},root:"friends.data",fields:["id","name"]});this.friend_store.setDefaultSort("name","asc");var a={layout:"form",autoScroll:true,border:false,cls:"share_to_social_messenger",items:[{id:"facebook_login_info",html:"      ",cls:"facebook_form_container_cell",border:false},{xtype:"superboxselect",id:"send_to_superbox",fieldLabel:_PST("photo","photo_str_send_to"),allowBlank:false,renderFieldBtns:true,allowQueryAll:true,minChars:1,width:500,mode:"local",store:this.friend_store,displayField:"name",valueField:"id",triggerAction:"all",tpl:new Ext.XTemplate('
  {name}
')},{xtype:"textarea",allowBlank:false,fieldLabel:_PST("photo","photo_str_permanent_link"),width:500,id:"message",cls:"facebook_upload_field",colspan:1,cellCls:"fb_form_container_textarea_cell"}]};return a},updateFacebookStatus:function(){var b="";var a="";Ext.getCmp("btn_send").disable();this.fbAuthorize.hide();b=Ext.util.Cookies.get("facebook_token");a="fb_utils.php";if(!b){return this.updateFacebookUIInfo(false,null)}this.updateStatusImg.show();Ext.Ajax.request({url:a,params:{action:"get_user",token:b,send_message:true},method:"POST",success:function(d){var c=Ext.decode(d.responseText);this.updateFacebookUIInfo(null!==c.user,c.user);this.updateStatusImg.hide()},scope:this})},updateFacebookUIInfo:function(a,b){if(!a){Ext.getCmp("btn_send").disable();this.fbAuthorize.dom.innerHTML=_PST("photo","photo_fb_auth_allow_btn");this.fbAuthorizeUsername.dom.innerHTML="";this.fbAuthorize.addClass("facebook_login_option");this.mon(this.fbAuthorize,"click",this.onLoginFacebook,this);this.setFacebookUserPicture("");this.delToken.hide();this.fbAuthorize.show()}else{b.uid=Ext.util.Cookies.get("facebook_uid");Ext.getCmp("btn_send").enable();this.fbAuthorize.dom.innerHTML="";this.fbAuthorizeUsername.dom.innerHTML=b.name;this.fbAuthorize.removeClass("facebook_login_option");this.setFacebookUserPicture(b);this.delToken.show();this.initSuperbox();this.fbAuthorize.hide()}this.updateStatusImg.hide()},onFacebookLogin:function(b,a){var c=String.format("https://graph.facebook.com/{0}/picture",a);this.fbPic.dom.src=c;Ext.util.Cookies.set("facebook_token",b);Ext.util.Cookies.set("facebook_uid",a);this.mun(this.fbAuthorize,"click",this.onLoginFacebook,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookStatus()},onLoginFacebook:function(){window._onFacebookLogin=this.onFacebookLogin.createDelegate(this);var b=window.location.href.indexOf("/",window.location.protocol.length+2);var f="_onFacebookLogin";var d="178470495541647";var c=String.format("http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/index.php?callback={0}&ps5host=",f);var e=window.location.href.slice(0,b)+PhotoStation.Util.getUrlPrefix()+"/photo/admin/photo_setting.php&response_type=token";var a=String.format("http://www.facebook.com/dialog/oauth/?scope=offline_access%2Cxmpp_login&client_id={0}&display=popup&redirect_uri={1}{2}",d,encodeURIComponent(c),e);window.open(a,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300")},deleteToken:function(){var a=new Date();a.setDate(a.getDate()-365);Ext.util.Cookies.set("facebook_token","",a);Ext.util.Cookies.set("facebook_uid","",a);var b="http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/logout_facebook.php";window.open(b,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300");this.updateFacebookUIInfo(false,null)},initSuperbox:function(){var a=Ext.util.Cookies.get("facebook_token");if(!a){return this.updateFacebookUIInfo(false,null)}this.friend_store.baseParams.token=a;this.friend_store.on("load",function(c,b,e,d){this.superbox.removeClass("loading-indicator");this.superbox.enable()},this);this.superbox.addClass("loading-indicator");this.friend_store.load()},sendMessage:function(){var a=Ext.util.Cookies.get("facebook_token");if(!a){return this.updateFacebookUIInfo(false,null)}if(!this.superbox.isValid()||!this.message.isValid()){return}var d=Ext.util.Cookies.get("facebook_uid");var c=this.superbox.getValue();var b=this.message.getValue();this.setStatusBusy();Ext.Ajax.request({url:"fb_utils.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,params:{action:"send_message",from:d,to:c,message:b,token:a},success:function(e,f){this.close()},failure:function(e,f){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_fb"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})}});Ext.ns("PhotoStation");PhotoStation.SettingWindow=Ext.extend(PhotoStation.BaseWindow,{currentSelect:null,constructor:function(a){Main.addScope("PhotoStation.SettingWindow",this);PhotoStation.SettingWindow.superclass.constructor.call(this,this.fillConfig(a));setting=this},fillConfig:function(b){var a={title:_PST("photo","photo_str_management"),width:400,height:200,minWidth:400,minHeight:200,layout:"fit",buttonAlign:"left",useStatusBar:false,footer:true,show:this.show,buttons:[{itemId:"deleteBtn",xtype:"button",hidden:true,cls:"photo-red-button photo-button",handler:this.clickDelete,scope:this},"->",{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this},{cls:"photo-grey-button photo-button",text:_PST("photo","photo_str_btnCancel"),handler:this.clickCancel,scope:this}],items:new Ext.Panel({itemId:"cardPanel",layout:"card",activeItem:0,border:false,items:[new PhotoStation.SettingAboutMePanel(),new PhotoStation.SettingCategoryPanel(),new PhotoStation.SettingAlbumPanel(),new PhotoStation.SettingSmartPanel(),new PhotoStation.SettingSharedAlbumPanel()]}),listeners:{scope:this,beforehide:function(){this.isCreateAlbum=false;this.isCreateSmart=false;this.isCreateSharedAlbum=false;this.isPublicShare=false;this.createCallback=null;this.cancelCallback=null}}};return Ext.apply(a,b)},switchTo:function(a){this.getComponent("cardPanel").getLayout().setActiveItem(Main.getScope(a))},initCurrentSelect:function(a){this.currentSelect={};Ext.apply(this.currentSelect,PhotoStation.CurrentBrowse);if(a){this.currentSelect.setRecord(a);this.currentSelect.isAboutMe=function(){return false}}return this.currentSelect},show:function(a){this.initCurrentSelect(a);PhotoStation.BaseWindow.prototype.show.apply(this,arguments);return this},showCreateAlbum:function(a){if(!a){a={}}if(Ext.isFunction(a.createCallback)){this.createCallback=a.createCallback}if(Ext.isFunction(a.cancelCallback)){this.cancelCallback=a.cancelCallback}this.isCreateAlbum=true;this.show(a.record)},showCreateSmartAlbum:function(a){this.setTitle(a?_PST("photo","photo_str_smart_album_title_save_as"):_PST("photo","photo_str_create"));this.isCreateSmart=true;Main.getScope("PhotoStation.SettingSmartPanel").smartPanel.on("loadtag",function(){Main.getScope("PhotoStation.SettingSmartPanel").smartPanel.setSmartValue(a)},this,{single:true});this.show()},showCreateSharedAlbum:function(a){if(Ext.isFunction(a.createCallback)){this.createCallback=a.createCallback}this.isCreateSharedAlbum=true;this.isPublicShare=a.public_share;this.selectItemId=a.item_id;this.show(a.record)},onShow:function(){var a=this.getActivePanel();if(!a){this.hide();return}this.activedPanel=a;this.switchTo(this.activedPanel);this.doLayout();Main.getScope(this.activedPanel).layoutHandler();this.setSize(Main.getScope(this.activedPanel).expectWidth,Main.getScope(this.activedPanel).expectHeight);this.center();Main.getScope(this.activedPanel).loadHandler()},getActivePanel:function(){var a=false;if(this.currentSelect.isAboutMe()){a="PhotoStation.SettingAboutMePanel"}else{if(this.isCreateSharedAlbum){a="PhotoStation.SettingSharedAlbumPanel"}else{if(this.currentSelect.isAlbumCategory()||this.currentSelect.isCategory()){if(this.isCreateAlbum){a="PhotoStation.SettingAlbumPanel"}else{a="PhotoStation.SettingCategoryPanel"}}else{if(this.currentSelect.isSmartCategory()){if(this.isCreateSmart){a="PhotoStation.SettingSmartPanel"}else{a="PhotoStation.SettingCategoryPanel"}}else{if(this.currentSelect.isAlbum()){a="PhotoStation.SettingAlbumPanel"}else{if(this.currentSelect.isSmart()||this.currentSelect.isSearchCategory()){a="PhotoStation.SettingSmartPanel"}else{if(this.currentSelect.isSharedAlbum()){a="PhotoStation.SettingSharedAlbumPanel"}}}}}}}return a},clickOK:function(){Main.getScope(this.activedPanel).saveHandler()},clickCancel:function(){Main.getScope(this.activedPanel).cancelHandler()},clickDelete:function(){if(this.currentSelect.isAlbum()){Main.getScope("PhotoStation.SettingAlbumPanel").clickDeleteAlbum()}else{if(this.currentSelect.isCategory()){Main.getScope("PhotoStation.SettingCategoryPanel").clickDeleteCategory()}else{if(this.currentSelect.isSharedAlbum()){Main.getScope("PhotoStation.SettingSharedAlbumPanel").clickDeleteSharedAlbum()}}}}});PhotoStation.SettingPanel=Ext.extend(Ext.Panel,{constructor:function(b){var a=Ext.apply({layout:"form",border:false},b);PhotoStation.SettingPanel.superclass.constructor.call(this,a);this.window=Main.getScope("PhotoStation.SettingWindow");this.expectWidth=832;this.expectHeight=212},layoutHandler:Ext.emptyFn,loadHandler:Ext.emptyFn,saveHandler:Ext.emptyFn,cancelHandler:Ext.emptyFn});PhotoStation.SettingCategoryPanel=Ext.extend(PhotoStation.SettingPanel,{constructor:function(a){Main.addScope("PhotoStation.SettingCategoryPanel",this);PhotoStation.SettingCategoryPanel.superclass.constructor.call(this,this.fillConfig(a));settingcate=this},fillConfig:function(b){var a={items:[{itemId:"fixedTitle",xtype:"displayfield",width:420,fieldLabel:_PST("photo","photo_str_photoalbum_title")},{itemId:"title",xtype:"textfield",width:420,fieldLabel:_PST("photo","photo_str_photoalbum_title"),allowBlank:false},{itemId:"visibility",xtype:"radiogroup",width:420,fieldLabel:_PST("photo","photo_str_visibility"),items:[new SYNO.CustRadio({name:"category-radio",boxLabel:_PST("photo","photo_str_show"),inputValue:"show"}),new SYNO.CustRadio({name:"category-radio",boxLabel:_PST("photo","photo_str_hide"),inputValue:"hide"})]},{xtype:"tricheckbox",triMode:false,itemId:"defaultLocationTag",fieldLabel:_PST("photo","photo_str_default_smart_album"),boxLabel:_PST("photo","photo_str_location_tag")},{xtype:"tricheckbox",triMode:false,itemId:"defaultPeopleTag",ctCls:"x-form-indent-formfield-ct",boxLabel:_PST("photo","photo_str_person_label")},{xtype:"tricheckbox",triMode:false,itemId:"defaultGeneralTag",ctCls:"x-form-indent-formfield-ct",boxLabel:_PST("photo","photo_str_general_tag")},{itemId:"setAsHomeCheckbox",xtype:"checkbox",ctCls:"set-as-home-checkbox",fieldLabel:_PST("photo","photo_str_set_as_home")}]};SYNO.LayoutConfig.fill(a);return Ext.apply(a,b)},layoutHandler:function(){this.currentSelect=this.window.currentSelect;this.isAlbumCategory=this.currentSelect.isAlbumCategory();this.isSmartCategory=this.currentSelect.isSmartCategory();this.isCategory=this.currentSelect.isCategory();this.getComponent("fixedTitle").setVisible(this.isAlbumCategory||this.isSmartCategory);this.getComponent("title").setVisible(!this.isAlbumCategory&&!this.isSmartCategory);this.getComponent("defaultLocationTag").setVisible(this.isSmartCategory);this.getComponent("defaultPeopleTag").setVisible(this.isSmartCategory);this.getComponent("defaultGeneralTag").setVisible(this.isSmartCategory);this.getComponent("setAsHomeCheckbox").setVisible(this.isCategory);this.expectHeight=this.isSmartCategory?282:262;this.getComponent("visibility").setVisible(!this.isSmartCategory);var a=this.window.getFooterToolbar().getComponent("deleteBtn");if(this.isSmartCategory){a.hide();this.window.setTitle(_PST("photo","photo_str_enable_default_smart_album"))}else{this.window.setTitle(_PST("photo","photo_str_edit_category_properties"));a.setText(_PST("photo","photo_str_delete_category"));a.setDisabled(!PhotoStation.Auth.is_admin);a.show()}},loadHandler:function(){this.window.setStatusBusy();if(this.isAlbumCategory){this.getComponent("fixedTitle").setValue(this.currentSelect.getTitle());this.getComponent("visibility").setValue("show");this.getComponent("visibility").setDisabled(true);this.window.clearStatusBusy()}else{if(this.isSmartCategory){this.getComponent("fixedTitle").setValue(this.currentSelect.getTitle());this.getComponent("visibility").setValue("show");this.getComponent("visibility").setDisabled(true);Ext.Ajax.request({url:"admin/photo_setting.php",params:{action:"get_virtual_album_setting"},callback:this.loadDefaultSmartCallback,scope:this})}else{this.getComponent("visibility").setDisabled(false);SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Category","getinfo",1,{id:this.currentSelect.getId()},this.loadCallback,this)}}},loadDefaultSmartCallback:function(c,h,b){this.window.clearStatusBusy();if(!h||!b){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var d,a,f;try{d=Ext.util.JSON.decode(b.responseText);a=d.success;f=d.data}catch(g){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}if(!a||!f){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}this.getComponent("defaultLocationTag").setValue(f.place_label_album==="on"?true:false);this.getComponent("defaultPeopleTag").setValue(f.person_label_album==="on"?true:false);this.getComponent("defaultGeneralTag").setValue(f.general_label_album==="on"?true:false)},loadCallback:function(f,e,d,b){this.window.clearStatusBusy();var a="";if(!f||!e){a=_PST("photo","photo_str_error_load_data")}else{if(this.isAlbumCategory||this.isSmartCategory){}else{if(!Ext.isArray(e.categories)||1!==e.categories.length){a=_PST("photo","photo_str_error_load_data")}}}if(a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),a);return}var c=e.categories[0];this.getComponent("title").setValue(c.name);this.getComponent("visibility").setValue(!c.hidden?"show":"hide");this.getComponent("setAsHomeCheckbox").setValue(c.home)},saveHandler:function(){if(this.currentSelect.isCategory()&&!this.getComponent("title").isValid()){return}this.window.setStatusBusy(_PST("photo","photo_str_saving"));var a={};if(this.isAlbumCategory){this.window.clearStatusBusy();this.window.hide()}else{if(this.isSmartCategory){a.action="set_virtual_album_setting";if("true"===this.getComponent("defaultPeopleTag").getValue()){a.person_label_album="on"}if("true"===this.getComponent("defaultGeneralTag").getValue()){a.general_label_album="on"}if("true"===this.getComponent("defaultLocationTag").getValue()){a.place_label_album="on"}Ext.Ajax.request({url:"admin/photo_setting.php",params:a,callback:this.saveDefaultSmartCallback,scope:this})}else{var b=this.getComponent("title").getValue().trim();if(""===b){this.window.clearStatusBusy();return}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Category","edit",1,{id:this.currentSelect.getId(),name:b,home:this.getComponent("setAsHomeCheckbox").getValue(),hidden:"hide"===this.getComponent("visibility").getValue().inputValue},this.saveCallback,this)}}},saveDefaultSmartCallback:function(c,h,b){this.window.clearStatusBusy();if(!h||!b){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"));return}var d,a;try{d=Ext.util.JSON.decode(b.responseText);a=d.success}catch(f){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}if(!a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var g=false;if(PhotoStation.Info.virtual_tag.geo_tag!==this.getComponent("defaultLocationTag").getValue()){g=true;PhotoStation.Info.virtual_tag.geo_tag=this.convertToBoolean(this.getComponent("defaultLocationTag").getValue())}if(PhotoStation.Info.virtual_tag.people_tag!==this.getComponent("defaultPeopleTag").getValue()){g=true;PhotoStation.Info.virtual_tag.people_tag=this.convertToBoolean(this.getComponent("defaultPeopleTag").getValue())}if(PhotoStation.Info.virtual_tag.desc_tag!==this.getComponent("defaultGeneralTag").getValue()){g=true;PhotoStation.Info.virtual_tag.desc_tag=this.convertToBoolean(this.getComponent("defaultGeneralTag").getValue())}if(g){Main.getScope("PhotoStation.ViewCard").containerLoad(this.currentSelect.getRecord(),true)}this.window.hide()},saveCallback:function(f,e,d,b){this.window.clearStatusBusy();if(!f){if(487===e.code){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_category_duplicated"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"))}return}var c,g,a;if(this.isAlbumCategory||this.isSmartCategory){}else{c=this.getComponent("title").getValue();if(this.currentSelect.getId()===PhotoStation.CurrentBrowse.getId()){PhotoStation.CurrentBrowse.setTitle(c);a=Main.getScope("PhotoStation.SimplePathBar");a.updatePathItem(a.getPathItemLength()-1,c)}g=Main.getScope("PhotoStation.CategoryList").store.getById(this.currentSelect.getId());g.set("name",c);g.set("hidden","hide"===this.getComponent("visibility").getValue().inputValue);g.commit()}if(this.getComponent("setAsHomeCheckbox").getValue()){PhotoStation.Info.home_category=PhotoStation.CurrentBrowse.getId()}else{if(PhotoStation.Info.home_category===PhotoStation.CurrentBrowse.getId()){PhotoStation.Info.home_category=""}}this.window.hide()},cancelHandler:function(){this.window.hide()},clickDeleteCategory:function(a){if(a){this.currentSelect=this.window.initCurrentSelect(a)}Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_delete_category_confirm"),function(b){if("yes"!==b){return}if(this.window.el){this.window.setStatusBusy(_PST("photo","photo_str_processing"))}else{Ext.getBody().mask(_PST("photo","photo_str_processing"))}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Category","delete",1,{id:this.currentSelect.getId()},this.deleteCategoryCallback,this)},this)},deleteCategoryCallback:function(e,d,c,b){if(this.window.el){this.window.clearStatusBusy()}else{Ext.getBody().unmask()}if(!this.currentSelect.isAboutMe()&&this.currentSelect.getId()===PhotoStation.CurrentBrowse.getId()){Main.getScope("PhotoStation.LeftContent").clearSelections();Main.getScope("PhotoStation.DefaultList").selectRange(0,0)}var a=Main.getScope("PhotoStation.CategoryList").store;a.remove(a.getById(this.currentSelect.getId()));this.window.hide()},convertToBoolean:function(a){return"true"===a?true:false}});PhotoStation.SettingAlbumPanel=Ext.extend(PhotoStation.SettingPanel,{constructor:function(a){Main.addScope("PhotoStation.SettingAlbumPanel",this);PhotoStation.SettingAlbumPanel.superclass.constructor.call(this,this.fillConfig(a));settingalbum=this},fillConfig:function(b){var a={layout:"column",items:[{xtype:"container",cls:"album-cover",itemId:"coverPanel",border:false,defaults:{scope:this,listeners:{afterrender:function(c){var d=Main.getScope("PhotoStation.SettingAlbumPanel");c.el.on("click",d.clickCoverSetting,d);c.el.addClassOnClick("clicked")}}},items:[{xtype:"container",itemId:"cover",items:[{xtype:"container",itemId:"background",cls:"cover-background",items:[{xtype:"box",id:this.coverId=Ext.id(),autoEl:{tag:"img",src:""}}]}]},{xtype:"box",cls:"album-cover-setting-text",itemId:"coverText",html:_PST("photo","photo_str_set_album_cover")}]},{itemId:"info",layout:"form",border:false,width:454,items:[{itemId:"parentFolder",xtype:"label",width:415,fieldLabel:_PST("photo","photo_str_upload_parent_folder")},{itemId:"nameAdd",xtype:"textfield",width:415,fieldLabel:_PST("photo","photo_str_folder_name"),allowBlank:false,maxLength:1000},{itemId:"nameEdit",xtype:"label",width:261,fieldLabel:_PST("photo","photo_str_folder_name")},{itemId:"title",xtype:"textfield",width:261,fieldLabel:_PST("photo","photo_str_dir_name"),maxLength:1000},{itemId:"desc",xtype:"textfield",width:261,fieldLabel:_PST("photo","photo_str_photoalbum_desc"),maxLength:5000},{itemId:"permission",xtype:"combo",width:261,fieldLabel:_PST("photo","photo_str_permission_type"),forceSelection:true,mode:"local",triggerAction:"all",editable:false,store:new Ext.data.ArrayStore({fields:["value","text"],data:[["public",_PST("photo","photo_str_photoalbum_public2")],["private",_PST("photo","photo_str_private")],["password",_PST("photo","photo_password")]]}),valueField:"value",displayField:"text",value:(PhotoStation.Info.default_album_public?"public":"private")},{itemId:"privilegeBtn",xtype:"button",cls:"photo-button photo-grey-button x-form-indent-button",text:_PST("photo","photo_str_man_album_access"),handler:this.clickAccessPermission,scope:this},Ext.apply({itemId:"password1",fieldLabel:_PST("photo","photo_password")},this.fillPasswordConfig()),Ext.apply({itemId:"password2",fieldLabel:_PST("photo","photo_str_confirmpassword")},this.fillPasswordConfig()),{xtype:"tricheckbox",triMode:false,itemId:"disableConversion",fieldLabel:_PST("photo","photo_str_conversion"),boxLabel:_PST("photo","photo_str_disable_conversion"),scope:this,handler:this.onCheckboxChanged},{xtype:"label",itemId:"watermark-title",width:261,fieldLabel:_PST("photo","watermark_str_watermark"),cls:"syno-photo-watermark-title"},{itemId:"watermark-buttons",border:false,style:{marginLeft:"183px"},items:[{xtype:"button",itemId:"watermark-button-edit",cls:"photo-button photo-grey-button",text:_PST("photo","watermark_str_edit"),style:"margin-right:10px;float:left;",scope:this,handler:this.editWatermark},{xtype:"button",itemId:"watermark-button-remove",cls:"photo-button photo-grey-button",text:_PST("photo","watermark_str_remove"),style:"float:left",scope:this,handler:this.removeWatermark}]}]}]};return Ext.apply(a,b)},fillPasswordConfig:function(){return{xtype:"textfield",width:420,inputType:"password",hidden:true,maxLength:1000,msgTarget:"qtip",validateOnBlur:true,validationEvent:"blur",listeners:{scope:this,blur:this.validatePassword}}},onCreatePermissionSelect:function(b,a){this.toggleFieldVisible("password"===a.get("value"))},onEditPermissionSelect:function(d,a){var b=d.originalValue;var c=a.get("value");if(-1!==["public","private"].indexOf(c)&&b!==c){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_album_permission_message"),function(e){if("yes"===e){this.doSavePermission();this.toggleFieldVisible("password"===c)}else{d.setValue(b);this.toggleFieldVisible("password"===b)}},this)}else{this.toggleFieldVisible("password"===a.get("value"))}},layoutHandler:function(){this.currentSelect=this.window.currentSelect;var g=this.window.getFooterToolbar().getComponent("deleteBtn"),d=0,f=this.getComponent("info"),b,a,h,e;if(!this.currentSelect.isAlbumCategory()){var c=this.currentSelect.getRecord().get("info").sharepath.match(/\//g)||[];d=c.length+1}if(this.window.isCreateAlbum){b=415;a=700;d++}else{b=261;a=554}this.isPermissionSetable=d<3&&PhotoStation.Auth.is_admin;this.isConversionSetable=d===1&&PhotoStation.Auth.is_admin;f.setWidth(a);if(this.window.isCreateAlbum){this.getComponent("coverPanel").setVisible(false);h=e=_PST("photo","photo_str_category_albums");if(this.currentSelect.isAlbum()){h=this.currentSelect.getRecord().get("info").name;e+="/"+this.currentSelect.getRecord().get("info").sharepath}f.getComponent("parentFolder").setVisible(true).setText(h);f.getComponent("parentFolder").el.dom.title=e;f.getComponent("nameAdd").setVisible(true).setValue("");f.getComponent("nameAdd").clearInvalid();f.getComponent("nameAdd").focus(false,200);f.getComponent("nameEdit").setVisible(false);f.getComponent("title").setVisible(false);f.getComponent("title").setWidth(b).setValue("");f.getComponent("title").clearInvalid();f.getComponent("desc").setWidth(b).setValue("");f.getComponent("permission").removeListener("select",this.onEditPermissionSelect,this);f.getComponent("permission").setWidth(b).setVisible(this.isPermissionSetable).addListener("select",this.onCreatePermissionSelect,this);f.getComponent("password1").setValue("").setWidth(b).setVisible(false);f.getComponent("password2").setValue("").setWidth(b).setVisible(false);f.getComponent("privilegeBtn").setVisible(this.isPermissionSetable);f.getComponent("disableConversion").setValue(PhotoStation.Info.def_album_disable_conversion).setVisible(this.isConversionSetable);f.getComponent("watermark-title").setVisible(false);f.getComponent("watermark-buttons").setVisible(false);g.hide();this.expectHeight=247;if(this.isPermissionSetable){this.expectHeight+=110}if(this.isConversionSetable){this.expectHeight+=35}this.window.setTitle(_PST("photo","photo_str_man_album_add"))}else{this.getComponent("coverPanel").setVisible(true);f.getComponent("parentFolder").setVisible(false);f.getComponent("nameAdd").setVisible(false);f.getComponent("nameEdit").setVisible(true);f.getComponent("title").setVisible(true);f.getComponent("title").setWidth(b);f.getComponent("title").clearInvalid();f.getComponent("desc").setWidth(b);f.getComponent("permission").removeListener("select",this.onCreatePermissionSelect,this);f.getComponent("permission").setWidth(b).setVisible(this.isPermissionSetable).addListener("select",this.onEditPermissionSelect,this);if(this.isPermissionSetable){f.getComponent("password1").setValue("").setWidth(b);f.getComponent("password2").setValue("").setWidth(b)}f.getComponent("password1").setVisible(false);f.getComponent("password2").setVisible(false);f.getComponent("privilegeBtn").setVisible(this.isPermissionSetable);f.getComponent("disableConversion").setVisible(this.isConversionSetable);f.getComponent("watermark-title").setVisible(this.isConversionSetable);f.getComponent("watermark-buttons").setVisible(this.isConversionSetable);g.setText(_PST("photo","photo_str_delete_album"));g.setDisabled(!PhotoStation.Auth.is_admin);g.show();this.expectHeight=288;if(this.isPermissionSetable){this.expectHeight+=70}if(this.isConversionSetable){this.expectHeight+=105}this.window.setTitle(_PST("photo","photo_str_edit_album_properties"))}},loadHandler:function(){if(this.window.isCreateAlbum){this.uBrowseList=[];this.uUploadList=[];this.uManageList=[];this.gBrowseList=[];this.gUploadList=[];this.gManageList=[];this.hasAssignedPermission=false;return}this.window.setStatusBusy();this.imageChooser=new PhotoStation.FileSelectorWindow({resizable:true,boxMinWidth:800,boxMinHeight:500,mode:"photo_station",initMode:"photo_station",fileType:"photo,video",record:this.currentSelect.getRecord(),choose:this.setCoverCallback,cancel:this.setCoverCallback});SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","getinfo",1,{id:this.currentSelect.getId(),additional:"album_permission"},this.loadCallback,this)},loadCallback:function(e,d,c,a){this.window.clearStatusBusy();if(!e||!d||!Ext.isArray(d.items)||1!==d.items.length||!d.items[0].info){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var b=d.items[0];this.updateCoverImage(b);this.getComponent("info").getComponent("nameEdit").setText(b.info.name);this.getComponent("info").getComponent("title").setValue(b.info.title);this.getComponent("info").getComponent("desc").setValue(b.info.description);if(this.isPermissionSetable){if(-1!==["public","private","password"].indexOf(b.info.type)){this.getComponent("info").getComponent("permission").setValue(b.info.type);this.getComponent("info").getComponent("permission").originalValue=b.info.type;this.toggleFieldVisible("password"===b.info.type)}else{this.getComponent("info").getComponent("permission").setValue("public");this.getComponent("info").getComponent("permission").originalValue="public"}}if(this.isConversionSetable){this.defaultConversion=b.info.conversion;this.getComponent("info").getComponent("disableConversion").setValue(!b.info.conversion);this.watermark=b.watermark;this.album={id:b.id,width:b.cover.w,height:b.cover.h,hash:b.cover.hash};this.getComponent("info").getComponent("watermark-title").setText(this.watermark?this.watermark.title:_PST("photo","watermark_str_not_selected"));this.getComponent("info").getComponent("watermark-buttons").getComponent("watermark-button-remove").setDisabled(!b.info.conversion||!b.watermark)}},toggleFieldVisible:function(a){this.getComponent("info").getComponent("privilegeBtn").setVisible(!a);this.getComponent("info").getComponent("password1").setVisible(a);this.getComponent("info").getComponent("password2").setVisible(a)},validatePassword:function(){var b=this.getComponent("info").getComponent("password1"),a=this.getComponent("info").getComponent("password2");if(b.getValue()!==a.getValue()){a.markInvalid(_PST("photo","photo_str_confirm_usr_pass"));return false}return true},saveHandler:function(){if(this.window.isCreateAlbum){this.doCreate()}else{this.doEdit()}},isParamsError:function(){var b=this.getComponent("info"),a=false;if(this.window.isCreateAlbum&&(!b.getComponent("nameAdd").isValid()||!PhotoStation.Upload.isFolderFileNameValid(b.getComponent("nameAdd").getValue().trim()))){a=_PST("photo","photo_str_upload_invalid_folder_name")}else{if(!b.getComponent("title").isValid()){a=_PST("photo","article_no_title")}else{if(this.isPermissionSetable&&"password"===b.getComponent("permission").getValue()){if("password"!==b.getComponent("permission").originalValue&&(""===b.getComponent("password1").getValue().trim()||""===b.getComponent("password2").getValue().trim())){a=_PST("photo","photo_str_no_password")}else{if(b.getComponent("password1").getValue()!==b.getComponent("password2").getValue()){a=_PST("photo","photo_str_confirm_usr_pass")}}}}}return a},doCreate:function(){var a=this.isParamsError();if(a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),a);return}var b=this.getComponent("info");var c={name:b.getComponent("nameAdd").getValue().trim(),title:b.getComponent("title").getValue().trim(),description:b.getComponent("desc").getValue().trim()};if(!this.currentSelect.isAlbumCategory()){c.id=this.currentSelect.getId()}if(this.isPermissionSetable){c.type=b.getComponent("permission").getValue();if("password"===c.type){c.password=b.getComponent("password1").getValue()}else{if(!this.hasAssignedPermission){c.inheritParent=true}}}if(this.isConversionSetable){c.conversion=b.getComponent("disableConversion").getValue()!=="true"}this.window.setStatusBusy();SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","create",1,c,this.createAlbumCallback,this)},createAlbumCallback:function(j,c,d,a){if(!j||!c){var b=PhotoStation.Util.getErrMsg(c);if(421==c.code){b=_PST("photo","photo_str_man_album_existed")}else{if(418==c.code){b=_PST("photo","photo_permission_denied_upload")}else{if(422==c.code){b=_PST("photo","photo_str_create_album_failed")}}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),b);this.window.clearStatusBusy();return}if(!this.isPermissionSetable||!this.hasAssignedPermission){if(Ext.isFunction(this.window.createCallback)){this.window.createCallback(c.id,d.id)}this.window.clearStatusBusy();this.closeAlbumSetting();return}var f=this.uBrowseList.join(",");var h=this.uUploadList.join(",");var k=this.uManageList.join(",");var e=this.gBrowseList.join(",");var g=this.gUploadList.join(",");var i=this.gManageList.join(",");SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Permission","editalbum",1,{id:c.id,user_browse_add:f,user_upload_add:h,user_manage_add:k,group_browse_add:e,group_upload_add:g,group_manage_add:i},this.setPermissionCallback,this)},setPermissionCallback:function(e,d,c,b){if(!e){var a="set permission failed";Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),a);this.window.clearStatusBusy();return}if(Ext.isFunction(this.window.createCallback)){this.window.createCallback(c.id,this.currentSelect.getId())}this.window.clearStatusBusy();this.closeAlbumSetting()},doEdit:function(){var a=this.isParamsError();if(a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),a);return}if(this.isPermissionSetable&&this.getComponent("info").getComponent("permission").isDirty()){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_album_permission_message"),function(b){if("yes"===b){this.doSave()}},this)}else{this.doSave()}},doSavePermission:function(){if(!this.isPermissionSetable){return}this.window.setStatusBusy(_PST("photo","photo_str_saving"));var a={id:this.currentSelect.getId(),type:this.getComponent("info").getComponent("permission").getValue()};SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","edit",1,a,this.saveCallback.createDelegate(this,[true],true))},doSave:function(){this.window.setStatusBusy(_PST("photo","photo_str_saving"));var a={id:this.currentSelect.getId(),title:this.getComponent("info").getComponent("title").getValue().trim(),description:this.getComponent("info").getComponent("desc").getValue().trim()};if(this.isPermissionSetable&&"password"===this.getComponent("info").getComponent("permission").getValue()){a.type=this.getComponent("info").getComponent("permission").getValue();a.password=this.getComponent("info").getComponent("password1").getValue()}if(this.isConversionSetable){a.conversion=this.getComponent("info").getComponent("disableConversion").getValue()!=="true";if(!this.defaultConversion&&a.conversion){this.watermarkChanged=true}if(a.conversion&&this.watermark){a.watermark_path=this.watermark.path;a.watermark_opacity=this.watermark.opacity;a.watermark_gravity=this.watermark.gravity;a.watermark_size=this.watermark.size}}SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","edit",1,a,this.saveCallback,this)},saveCallback:function(k,d,e,a,f){this.window.clearStatusBusy();if(!k){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"));return}var b=this.getComponent("info");if(f){b.getComponent("permission").originalValue=this.getComponent("info").getComponent("permission").getValue();this.currentSelect.getRecord().get("info").type=this.getComponent("info").getComponent("permission").getValue();return}var i=b.getComponent("title").getValue();var g=b.getComponent("desc").getValue();var c="true"===b.getComponent("disableConversion").getValue()?false:true;if(this.currentSelect.getId()===PhotoStation.CurrentBrowse.getId()){PhotoStation.CurrentBrowse.setTitle(i);PhotoStation.CurrentBrowse.setDesc(g);PhotoStation.CurrentBrowse.setConversion(c);var j=Main.getScope("PhotoStation.SimplePathBar"),h=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;j.updatePathItem(j.getPathItemLength()-1,i);h.setAlbumDesc(g);if(Ext.isFunction(h.showSelectionWindow)){h.showSelectionWindow(h.getSelectedRecords().length>0)}Main.getScope("PhotoStation.CenterPanel").doLayout()}else{this.needReload=true}Main.getScope("PhotoStation.LeftContent").setAlbumName(this.currentSelect.getId(),i);if(!this.coverParams){this.closeAlbumSetting()}else{SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Cover","set",1,this.coverParams,function(q,p,o,n){if(q){var m=Main.getScope("PhotoStation.SettingAlbumPanel");m.coverParams=null;m.closeAlbumSetting()}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"))}})}},cancelHandler:function(){if(Ext.isFunction(this.window.cancelCallback)){this.window.cancelCallback()}this.watermarkChanged=false;this.closeAlbumSetting()},clickDeleteAlbum:function(){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_delete_current_album_confirm"),function(a){if("yes"!==a){return}this.window.setStatusBusy(_PST("photo","photo_str_processing"));SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.Album","delete",1,{id:this.currentSelect.getId()},this.deleteAlbumCallback,this)},this)},clickAccessPermission:function(){var c="",b;if(this.currentSelect.isAlbum()){c=this.currentSelect.getId()}if(this.window.isCreateAlbum){b=this.getComponent("info").getComponent("permission").getValue();this.permissionDialog=new PhotoStation.PermissionSettingWindow({isAdd:true,albumID:c,privilege:b,firstOpen:!this.hasAssignedPermission,uBrowseList:this.uBrowseList,uUploadList:this.uUploadList,uManageList:this.uManageList,gBrowseList:this.gBrowseList,gUploadList:this.gUploadList,gManageList:this.gManageList});this.mon(this.permissionDialog,"updatepermission",this.onUpdatePermission,this);this.permissionDialog.show()}else{b=this.currentSelect.getRecord().get("info").type;var a=new PhotoStation.PermissionSettingWindow({albumID:c,privilege:b});a.show()}},onUpdatePermission:function(d,h,j,i,m,c,k,f,b,g,a,e){this.hasAssignedPermission=true;this.uBrowseList=this.arrayRemove(this.uBrowseList,k);this.uUploadList=this.arrayRemove(this.uUploadList,f);this.uManageList=this.arrayRemove(this.uManageList,b);this.gBrowseList=this.arrayRemove(this.gBrowseList,g);this.gUploadList=this.arrayRemove(this.gUploadList,a);this.gManageList=this.arrayRemove(this.gManageList,e);if(""!==d[0]){this.uBrowseList=this.arrayUnique(this.uBrowseList.concat(d))}if(""!==h[0]){this.uUploadList=this.arrayUnique(this.uUploadList.concat(h))}if(""!==j[0]){this.uManageList=this.arrayUnique(this.uManageList.concat(j))}if(""!==i[0]){this.gBrowseList=this.arrayUnique(this.gBrowseList.concat(i))}if(""!==m[0]){this.gUploadList=this.arrayUnique(this.gUploadList.concat(m))}if(""!==c[0]){this.gManageList=this.arrayUnique(this.gManageList.concat(c))}},arrayRemove:function(f,e){var b=f;if(""===e[0]){return b}for(var d=0;d=0){b.splice(c,1)}}return b},arrayUnique:function(e){var b=e;for(var d=0;db){return _PST("photo","photo_str_exp_before_avail")}}return true},dateSelectHandler:function(){this.dateValueEnd.isValid()},layoutHandler:function(){this.currentSelect=this.window.currentSelect;var c=this.window.getFooterToolbar().getComponent("deleteBtn");this.nameField=this.getComponent("name");this.publicShareCheck=this.getComponent("public_share");this.publicShareCheck.on("check",this.checkHandler,this);this.enableDurationCheck.on("check",this.checkHandler,this);this.enableDurationCheck.on("enable",this.enableToggleHandler,this);this.enableDurationCheck.on("disable",this.enableToggleHandler,this);this.dateValueStart.on("select",this.dateSelectHandler,this);this.dateValueEnd.on("select",this.dateSelectHandler,this);this.nameField.on("keyup",this.nameChangeHandler,this);this.publicShareCheck.show();this.enableDurationCheck.show();this.dateValueStart.show();this.dateValueEnd.show();this.expectHeight=this.window.isPublicShare?310:340;this.getComponent("durationCheckIndent").addClass("field-indent");if(this.window.isCreateSharedAlbum){var a=_PST("photo","photo_str_untitled_shared_album");var b=1;while(this.checkSharedAlbumNameExisted(a)){a=_PST("photo","photo_str_untitled_shared_album")+" ("+b+")";b++}this.publicShareCheck.setVisible(!this.window.isPublicShare);this.nameField.setValue(a);this.nameField.clearInvalid();this.publicShareCheck.setValue(true);this.enableDurationCheck.setValue(false);this.dateValueStart.setValue(new Date());this.dateValueEnd.setValue(new Date().add(Date.DAY,6));c.hide();if(this.window.isPublicShare){this.window.setTitle(_PST("photo","photo_str_public_share"));this.getComponent("durationCheckIndent").removeClass("field-indent")}else{this.window.setTitle(_PST("photo","photo_str_create_shared_album"))}}else{c.show();c.setText(_PST("photo","photo_str_delete_shared_album"));this.window.setTitle(_PST("photo","photo_str_edit_shared_album_properties"))}this.nameField.focus(true,200)},loadHandler:function(){if(this.window.isCreateSharedAlbum){return}this.window.setStatusBusy();SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.SharedAlbum","getinfo",1,{id:this.currentSelect.getId(),additional:"public_share"},this.loadCallback,this)},loadCallback:function(g,f,e,b){this.window.clearStatusBusy();var a;if(!g||!f){a=_PST("photo","photo_str_error_load_data")}else{if(!Ext.isArray(f.shared_albums)||1!==f.shared_albums.length){a=_PST("photo","photo_str_error_load_data")}}var c=f.shared_albums[0];var d=c.additional.public_share;this.nameField.originalValue=c.name;this.nameField.setValue(c.name);this.publicShareCheck.setValue("none"!==d.share_status);if(d.start_time&&d.end_time){this.enableDurationCheck.setValue(true);if(Date.parse(d.start_time)
Enable your social networks in setting page.',listeners:{scope:this,afterrender:function(){function e(g){PhotoStation.onClickSocialShare(g.target.getAttribute("ps:onclick"))}var d=document.querySelectorAll("#"+this.id+" .photo-share-icon");for(var c=0,f=d.length;cthis.finishCount){return}else{if(11!==this.successCount){this.fireEvent("loadtag",false)}else{this.fireEvent("loadtag",true)}}},addRuleRow:function(c){var a;var d=new Ext.form.FormPanel({border:false,id:a=Ext.id(),height:55,layout:"hbox",hideLabel:true,defaults:{panelId:a,margins:"0 3 0 0"},items:[this.createRuleCombo(),this.createOperatorCombo(),this.createSuperBoxSelect(),this.createDeleteRuleBtn(),this.createAddRuleBtn()]});var b=d.getComponent("combo_field");this.updateComboFilter(b);if(!c){c={combo:b.store.getAt(0).get("value"),op:"any"}}d.getComponent("combo_field").setValue(c.combo);d.getComponent("operator_field").setValue(c.op);this.selectedLabel[c.combo]=true;this.ruleComboChange(b,c.combo);if(c.value){d.getComponent("super_box_select_field").setValue(c.value)}this.rulePanel.add(d);this.updateRuleBtn();this.updateAllComboFilter();this.rulePanel.doLayout()},updateComboFilter:function(b){var a=b.store;a.clearFilter();a.filterBy(function(c){var d=c.get("value");if(d===b.getValue()){return true}else{if(true===this.selectedLabel[d]){return false}}return true},this)},updateAllComboFilter:function(){for(var a=0;ab){return String.format(_JSLIBSTR("extlang","minnumber"),1)}else{if(250",new Ext.Container({id:this.sliderId=Ext.id(),cls:"thumb-slider",width:80}),this.getTimelineConfig(),{itemId:"spacer",xtype:"tbspacer",width:30},this.getViewmodeConfig()],listeners:{scope:this,single:true,afterrender:function(){this.timelineBtn=this.getComponent("timelineBtn");this.viewmodeBtn=this.getComponent("viewmodeBtn");var c=this.getComponent("spacer");c.mon(this.timelineBtn,"show",function(){c.setWidth(10)});c.mon(this.timelineBtn,"hide",function(){c.setWidth(30)})}}};return Ext.apply(a,b)},getTimelineConfig:function(){return{itemId:"timelineBtn",cls:"timeline-btn photo-icon-btn",hidden:true,menu:new SYNO.ux.Menu({autoScroll:true,items:[],listeners:{beforeshow:function(){Main.getScope("PhotoStation.StatusTopArea").timelineBtn.updateSelectedItem()},itemclick:function(a){Main.getScope("PhotoStation.StatusTopArea").timelineBtn.onItemClick(a)}}}),initIndex:function(f){var d=f.data.items;var g=[];var h=[];var c=[];var e,b,j,a;for(a=0;a=this.pathItemList.length){return}for(var c=this.pathItemList.length-1;c>=b;c--){if(!this.pathItemList[c]){continue}if(this.pathItemList[c].separator){this.pathItemList[c].separator.destroy()}this.pathItemList[c].button.destroy();this.pathItemList.splice(c,1)}this.doLayout()},cleanPathItems:function(){this.removePathItem(0)},clickPathItem:function(b){if(b+1===this.pathItemList.length){Main.getScope("PhotoStation.ViewCard").containerReLoad();return}var a=this.pathItemList[b].record;this.removePathItem(b);Main.getScope("PhotoStation.ViewCard").containerLoad(a)},maskPathBar:function(a,b){if(a){this.getContentTarget().addClass("center-transparent-mask");this.getEl().mask(b).addClass("transparent-mask")}else{this.getContentTarget().removeClass("center-transparent-mask");this.getEl().unmask()}},getPathItemLength:function(){return this.pathItemList.length},updatePathItem:function(b,d){if(0>b||this.pathItemList.length<=b){return}var c=this.pathItemList[b];var a=c.record;this.setRecordTitle(a,d);c.button.setText(Ext.util.Format.htmlEncode(Ext.util.Format.ellipsis(d,30)));c.button.setTooltip(Ext.util.Format.htmlEncode(d))},getPathItemString:function(){var a=[];Ext.each(this.pathItemList,function(b){a.push(b.record.get("id"))});return a.join("/")}});PhotoStation.AlbumDescBar=Ext.extend(Ext.Panel,{constructor:function(a){Main.addScope("PhotoStation.AlbumDescBar",this);PhotoStation.AlbumDescBar.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={cls:"album-desc-bar",height:28,border:false,padding:"1px 7px 9px",hidden:true,items:{itemId:"desc",xtype:"label"},listeners:{show:function(){Main.getScope("PhotoStation.CenterPanel").doLayout()}}};return Ext.apply(a,b)},setDescText:function(c){var b=this.getComponent("desc"),a=c||"";b.setText(a);b.el.dom.title=a;this.setVisible(a)}});Ext.ns("PhotoStation");PhotoStation.SuperBoxAlbumSelector=Ext.extend(Ext.ux.form.SuperBoxSelect,{constructor:function(a){Main.addScope("PhotoStation.SuperBoxAlbumSelector",this);PhotoStation.SuperBoxAlbumSelector.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={width:400,height:53,valueField:"id",displayField:"name",mode:"local",renderFieldBtns:true,allowQueryAll:true,triggerAction:"all",allowAddNewData:true,removeValuesFromStore:"false",store:this.createStore(),menu:new PhotoStation.AlbumMenuSelector({owner:this})};return Ext.apply(a,b)},onTriggerClick:function(){this.menu.show(this.outerWrapEl)},onSelectNode:function(b){var a={id:b.id,name:b.text};this.addItem(a)},createStore:function(){var a=new Ext.data.JsonStore({idProperty:"id",fields:["id","name"]});return a},loadMenu:function(){this.store.removeAll();this.menu.reload()}});PhotoStation.AlbumMenuSelector=Ext.extend(Ext.menu.Menu,{constructor:function(a){Main.addScope("PhotoStation.AlbumMenuSelector",this);PhotoStation.AlbumMenuSelector.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={cls:"upload-folder-menu",items:[this.selector=new PhotoStation.FileSelector({width:392,height:420,rootVisible:false,showCheck:false,userPrivilege:"upload",listeners:{scope:this,click:function(c){this.owner.onSelectNode(c);this.hide()}}})]};return Ext.apply(a,b)},reload:function(){if(this.selector.getEl()){this.selector.getRootNode().reload()}}});Ext.ns("PhotoStation");PhotoStation.EditTagDialog=Ext.extend(PhotoStation.BaseWindow,{constructor:function(a){Main.addScope("PhotoStation.EditTagDialog",this);Ext.apply(this,a);PhotoStation.EditTagDialog.superclass.constructor.call(this,this.fillConfig())},fillConfig:function(){var a={width:400,height:500,title:_PST("photo","photo_str_album_edit_desc_label"),items:[this.tagPanel=new PhotoStation.DescTagPanel()],buttons:[{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_man_done"),handler:this.close,scope:this}],listeners:{beforeshow:{fn:function(){this.tagPanel.updateTagPanel(this.ids)},scope:this}}};return a}});PhotoStation.DescTagPanel=Ext.extend(Ext.Panel,{currentItemId:null,constructor:function(a){Main.addScope("PhotoStation.DescTagPanel",this);PhotoStation.DescTagPanel.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){this.curTagStore=new Ext.data.Store({reader:new Ext.data.JsonReader({root:""},[{name:"id"},{name:"type"},{name:"name"},{name:"info",mapping:"additional.info"}]),fields:["id","type","name","info"],sortInfo:{field:"name",direction:"ASC"}});var a={itemId:"tagPanel",border:false,items:[this.descTagArea=new PhotoStation.DescTagArea({type:"desc",owner:this})]};return Ext.apply(a,b)},updateTagPanel:function(a){this.photoId=a;this.clearTags();SYNO.API.currentManager.requestAPI("SYNO.PhotoStation.PhotoTag","list",1,{id:this.photoId,type:"desc",additional:"info"},this.requestTagsCallback,this)},clearTags:function(){this.descTagArea.clearTagList()},requestTagsCallback:function(e,d,c,b){if(!e||!d||!Ext.isArray(d.tags)){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var a=this.parseRespTags(d.tags);this.curTagStore.loadData(a);this.descTagArea.updateTagList()},parseRespTags:function(g){var c=(g.length>0&&g[0].photoId);var b=[],e=[];var f;if(!c){return g}for(var d=0;d','
','
{name:htmlEncode}
','
',"
","");this.tagTextTpl.compile();this.createStore();this.addEvents("rendertag");PhotoStation.LightBoxTagArea.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var c=new Ext.XTemplate('
{name:htmlEncode}
');var a={itemId:this.type+"_tagPanel",cls:"lightbox-"+this.type+"-tag-area",border:false,items:[{itemId:"desc",xtype:"box",autoEl:{html:_PST("photo","photo_str_general_tag"),style:"font-size: 14px;"}},{itemId:"tag_comp_field",xtype:"compositefield",items:[{itemId:"tag_desc_combo",cls:"lightbox-tag-combo",xtype:"syno_combobox",store:this.comboStore,hideLabel:true,tpl:c,editable:true,displayField:"name",hideTrigger:true,maxLength:64,enableKeyEvents:true,autoSelect:false,width:200,listeners:{scope:this,expand:function(){this.updateComboStore()},keypress:function(g,e){if(e.getKey()===e.ENTER){var f=g.getValue();this.endDescTagEdit();var d=f.split(",");if(1==d.length){this.addDescTag(f.trim())}else{this.batchAddDescTag(d)}}},select:function(g,d,e){var f=g.getValue();this.addDescTag(f)},focus:function(d){if(""===d.getValue()){(function(){if(!d.isDestroyed){d.doQuery("",true)}}).defer(100,this)}}}},{itemId:"add_tag_btn",xtype:"button",text:_PST("photo","photo_str_add"),cls:"photo-blue-button photo-button",handler:function(){if(!this.comboBox.isValid()){return}var e=this.comboBox.getValue();var d=e.split(",");if(1==d.length){this.addDescTag(e.trim())}else{this.batchAddDescTag(d)}},scope:this}]},{itemId:"tag_list_container",xtype:"container",autoFlexcroll:true,height:310,items:{itemId:"tag_list_div",xtype:"container",autoEl:{style:"overflow: hidden"}}}],listeners:{scope:this,single:true,afterlayout:function(){this.comboBox=this.getComponent("tag_comp_field").items.itemAt(0)}}};return Ext.apply(a,b)},batchAddDescTag:function(a){this.batchTagList=[];Ext.each(a,function(c,b){if(""!==c.trim()){this.batchTagList.push(c.trim())}},this);if(this.batchTagList.length===0){return}Main.getScope("PhotoStation.EditTagDialog").setStatusBusy(_PST("photo","photo_str_plz_wait"));this.addPhotoTag(this.batchTagList[0],null,null,this.addPhotoDescTagDone.createDelegate(this,[0],true))},addPhotoDescTagDone:function(c,a){if(!c||(this.batchTagList.length-1)==a){this.batchTagList=[];Main.getScope("PhotoStation.EditTagDialog").clearStatusBusy();return}var b=this.batchTagList[a+1];this.addPhotoTag(b,null,null,this.addPhotoDescTagDone.createDelegate(this,[a+1],true))},addDescTag:function(a){this.endDescTagEdit();if(a.trim()===""){return}Main.getScope("PhotoStation.EditTagDialog").setStatusBusy(_PST("photo","photo_str_plz_wait"));this.addPhotoTag(a,null,null,this.addTagDone.createDelegate(this))},addTagDone:function(){Main.getScope("PhotoStation.EditTagDialog").clearStatusBusy()},updateTagList:function(){this.clearTagList();this.owner.curTagStore.each(function(a){this.renderTag(a)},this);this.updateComboStore();this.updateActionBtnText();this.getComponent("tag_list_container").updateFleXcroll()},renderTag:function(c){var a,b;if(!Ext.isEmpty(c.get("name"))){b={name:c.get("name"),tip:c.get("name")};a=this.tagTextTpl.append(this.getComponent("tag_list_container").getComponent("tag_list_div").el,b,true);if(PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("manage")){a.child(".edit-dialog-tag-el-del-btn").show();a.child(".edit-dialog-tag-el-del-btn").on("click",this.deletePhotoTag.createDelegate(this,[c.get("id")],false),this)}else{a.child(".edit-dialog-tag-el-del-btn").hide()}this.tagList.push(a);this.fireEvent("rendertag")}},endDescTagEdit:function(){this.comboBox.clearValue();this.comboBox.clearInvalid()}});Ext.ns("PhotoStation");PhotoStation.ThemeTemplate=Ext.extend(Ext.Panel,{constructor:function(a){Main.addScope("PhotoStation.ThemeTemplate",this);PhotoStation.ThemeTemplate.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={itemId:"themeTemplate",title:""+_PST("photo","photo_theme_btnTheme")+"",padding:"16px 16px 0 16px",items:[{xtype:"radiogroup",itemId:"theme_template",cls:"theme-panel-no-radio-icon",columns:1,items:[new SYNO.CustRadio({name:"theme_template",itemId:"radioThemeWhite",boxLabel:'
',inputValue:"White",handler:function(c,d){if(d&&this.holder.inited){PhotoStation.Util.removeCssFile("photo_new/css/style_black.css");if(!this.holder.restore){this.holder.dataRequest({action:"v6_template",value:"White"})}}},listeners:{afterrender:function(d){var c=Ext.get(this.whiteMoreBtnId);c.dom.title=_PST("photo","photo_str_theme_more_setting");c.addClassOnOver("btn-over").addClassOnClick("btn-click");c.on("click",function(f){this.nextToDetail();f.stopPropagation()},this)},scope:this},scope:this}),new SYNO.CustRadio({name:"theme_template",itemId:"radioThemeBlack",boxLabel:'
',inputValue:"Black",handler:function(c,d){if(d&&this.holder.inited){PhotoStation.Util.loadCssFile("photo_new/css/style_black.css");if(!this.holder.restore){this.holder.dataRequest({action:"v6_template",value:"Black"})}}},listeners:{afterrender:function(){var c=Ext.get(this.blackMoreBtnId);c.dom.title=_PST("photo","photo_str_theme_more_setting");c.addClassOnOver("btn-over").addClassOnClick("btn-click");c.on("click",function(d){this.nextToDetail();d.stopPropagation()},this)},scope:this},scope:this}),{xtype:"container",width:268,items:[{xtype:"button",cls:"theme-reset-text",iconCls:"text-button",text:_PST("photo","photo_str_theme_more_setting"),handler:function(){this.nextToDetail()},scope:this}]}]}]};return Ext.apply(a,b)},initData:function(a){this.getComponent("theme_template").setValue(a.v6_template)},clearData:Ext.emptyFn,nextToDetail:function(){this.holder.getLayout().setActiveItem("themeDetail")}});PhotoStation.ThemeDetailSetting=Ext.extend(Ext.Panel,{constructor:function(a){Main.addScope("PhotoStation.ThemeDetailSetting",this);PhotoStation.ThemeDetailSetting.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={itemId:"themeDetail",cls:"theme-other-panel",title:"
"+_PST("photo","photo_str_customize")+"",padding:"0px 16px 10px 16px",layout:"vbox",items:[{xtype:"box",html:_PST("photo","photo_theme_logo_img"),cls:"theme-text-left"},{cls:"theme-inner-panel",itemId:"logoPanel",border:false,items:[new SYNO.CustRadio({name:"theme_logo",itemId:"radioThemeDefault",fieldLabel:_PST("photo","photo_theme_logo_img"),boxLabel:_PST("photo","photo_theme_default_image"),inputValue:1,handler:function(c,d){if(d&&this.holder.inited){this.holder.dataRequest({action:"v6_logo",value:"1"})}},scope:this}),{xtype:"box",cls:"theme-separator"},{layout:"table",itemId:"logoCustom",layoutConfig:{columns:2},border:false,width:256,items:[new SYNO.CustRadio({name:"theme_logo",itemId:"radioThemeCustom",boxLabel:_PST("photo","photo_str_my_image"),inputValue:2,width:178,handler:function(c,e){var d=Ext.getCmp(this.logoUploadBtn);if(e){if(!gIsDemoMode){d.updateFileInputStyle();d.enable()}}else{d.disable()}if(e&&this.holder.inited){this.holder.dataRequest({action:"v6_logo",value:"2"})}},listeners:{afterrender:function(c){Ext.QuickTips.register({target:c.boxEl,text:String.format(_PST("photo","photo_str_upload_size_recommendation"),"200x70 ~ 200x200")})},scope:this},scope:this}),this.getUploadFormConfig()]}]},{xtype:"box",html:_PST("photo","theme_background"),cls:"theme-text-left"},{cls:"theme-inner-panel",itemId:"bkgPanel",border:false,items:[this.getColorChooserConfig(_PST("photo","photo_str_color"),"v6_bkg_color"),{xtype:"box",cls:"theme-separator"},{layout:"table",border:false,layoutConfig:{columns:2},items:[{border:false,height:140,width:120,cls:"theme-inner-text",html:_PST("photo","photo_str_wallpaper")},this.getBackgroundPanelConfig()]}]},{xtype:"box",html:_PST("photo","photo_str_color"),cls:"theme-text-left"},{cls:"theme-inner-panel",border:false,items:[this.getColorChooserConfig(_PST("photo","photo_str_main_text_color"),"v6_font_color"),{xtype:"box",cls:"theme-separator"},this.getColorChooserConfig(_PST("photo","photo_str_secordary_text_color"),"v6_sec_color"),{xtype:"box",cls:"theme-separator"},this.getColorChooserConfig(_PST("photo","photo_str_hightlight_color"),"v6_hl_color")]},{xtype:"spacer",width:268,flex:1},{xtype:"container",width:268,items:[{xtype:"button",cls:"theme-reset-text",iconCls:"text-button",text:_PST("photo","photo_theme_make_default"),handler:function(){this.holder.dataRequest({action:"default"})},scope:this}]}],listeners:{afterrender:{fn:function(){var c=Ext.get(this.header.dom.firstChild.firstChild);c.on("click",this.backToTemplate,this)},scope:this,single:true}}};return Ext.apply(a,b)},getBackgroundPanelConfig:function(){var a={cls:"bkg-image-panel",width:130,border:false,defaults:{border:false,width:120},padding:"0 6px 0 0",items:[{height:80,cls:"bkg-window",style:"float: right",id:this.imagePreviewBkgId=Ext.id(),items:[{xtype:"box",ctCls:"photo-preview",overCls:"btn-over",cls:"photo-preview-border",id:this.imageId=Ext.id()}],listeners:{afterrender:{fn:function(){var b=this.getContentTarget().dom.childNodes[0];Ext.get(b).addClassOnClick("btn-click");this.el.on("click",function(){Main.getScope("PhotoStation.ThemeDetailSetting").bkgImageChooser.show()})},single:true}}},{xtype:"button",id:"btn_bkg_remove",text:_PST("photo","photo_str_remove"),iconCls:"remove",handler:function(b,c){this.bkgImage="0";this.holder.dataRequest({action:"v6_show_bkg_img",value:"0"})},scope:this}]};return a},getColorChooserConfig:function(b,c){var a={layout:"table",border:false,layoutConfig:{columns:2},defaults:{border:false},items:[{height:32,width:120,cls:"theme-inner-text",html:b},{width:130,items:[new PhotoStation.ColorChooser({id:c,callback:this.colorCb})]}]};return a},getUploadFormConfig:function(){var a={xtype:"form",id:this.logoUploadFormId=Ext.id(),cls:"logo-upload-form",fileUpload:true,trackRestOnLoad:true,border:false,items:[{xtype:"syno_filebutton",id:this.logoUploadBtn=Ext.id(),hideLabel:true,buttonOnly:true,buttonText:_PST("photo","photo_str_upload"),fieldLabel:_PST("photo","photo_str_upload"),name:"file",disabled:true,listeners:{render:{fn:function(b){b.getEl().addListener("change",function(d){var c=Ext.getCmp(this.logoUploadFormId).getForm();c.submit({url:"include/synotheme_upload.php",method:"post",params:{action:"logo_upload",type:"photo"},waitMsg:_PST("photo","photo_str_uploading"),success:function(f,g){var e=Main.getScope("PhotoStation.CustomizePanel");e.photo_theme_myLogImag=g.result.file;e.configChange=true;Main.getScope("PhotoStation.LeftPanel").updateLogo(true)},failure:function(e,f){Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),f.result.message)}})},this)},scope:this}}}]};return a},initData:function(b){var d=this.getComponent("logoPanel"),a={},c;for(c in b){if(b.hasOwnProperty(c)){switch(c){case"v6_bkg_color":case"v6_font_color":case"v6_hl_color":case"v6_sec_color":a[c]=(b[c]&&b[c].length>0)?"#"+b[c]:"#FFFFFF";break}}}this.updateColor(a);d.getComponent("radioThemeDefault").setValue(false);d.getComponent("logoCustom").getComponent("radioThemeCustom").setValue(false);if("1"===b.v6_logo){d.getComponent("radioThemeDefault").setValue(true)}else{if("2"===b.v6_logo){d.getComponent("logoCustom").getComponent("radioThemeCustom").setValue(true)}}this.bkgImage=b.v6_show_bkg_img;this.show_thumb_mode=this.getBkgSelectMode(b.v6_show_bkg,b.bkg_width);this.updateBkg({color:a.v6_bkg_color,image:this.bkgImage},{width:b.bkg_width,height:b.bkg_height});if(!this.bkgImageChooser){this.bkgImageChooser=new PhotoStation.FileSelectorWindow({mode:"upload,default,photo_station",initMode:"default",fileType:"photo",choose:this.bkgImageChooserCb,cancel:this.bkgImageChooserCb})}},clearData:function(){if(this.bkgImageChooser){this.bkgImageChooser.close();delete this.bkgImageChooser}},colorCb:function(b,c){if(!c||0>=c.length){return}var a={};a[b.refer]="#"+c;Main.getScope("PhotoStation.ThemeDetailSetting").updateColor(a);Main.getScope("PhotoStation.CustomizePanel").dataRequest({action:b.refer,value:c})},bkgImageChooserCb:function(a,b){var c=Main.getScope("PhotoStation.ThemeDetailSetting");if(!a||c.bkgImage===a.url){return}Ext.getCmp("btn_bkg_remove").enable();c.show_thumb_mode=b;c.bkgImage=a.url;if("photo_station"===b){c.bkgRecord=a;Ext.MessageBox.show({title:_PST("photo","photo_str_ap_name_6"),msg:"Converting your photo...",wait:true});Ext.Ajax.request({url:PhotoStation.Util.getUrlPrefix()+"/photo/include/synotheme_upload.php",params:{action:"bkg_upload_from_photo",id:a.id,type:"photo"},method:"POST",scope:c,success:function(e,f){var d=Ext.util.JSON.decode(e.responseText);Ext.MessageBox.hide();if(d.success){this.holder.dataRequest({action:"save_bkg_custom"});this.holder.dataRequest({action:"v6_show_bkg_img",value:this.bkgRecord.id})}else{Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),d.message)}},failure:function(d,e){Ext.MessageBox.hide();Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}})}else{c.holder.dataRequest({action:"save_bkg_custom"});c.holder.dataRequest({action:"v6_show_bkg_img",value:a.url})}},getBkgSelectMode:function(a,b){var c;if("2"===a){c="upload"}else{if("4"===a){c="photo_station"}else{c="default"}}return c},updateBkg:function(b,c){var d={},f={};var a=new Ext.XTemplate('
');if(b.color){f["background-color"]=d["background-color"]=b.color}if("0"===b.image){f["background-image"]="none";Ext.getCmp("btn_bkg_remove").setDisabled(true);Ext.getCmp(this.imageId).update("
")}else{if(b.image){var e=!this.holder.restore;f["background-image"]=e?"url("+PhotoStation.Util.getThemeRequestFile()+"?type=photo&action=bkg&cv="+Math.random()+")":"url("+b.image+")";if(c&&19200||f.isShowConversionPrompt())){f.show()}}}};return Ext.apply(a,b)},dataRequest:function(a){a.type="photo";if("init"===a.action){this.el.mask(_PST("photo","photo_str_loading"))}if("save"===a.action){this.el.mask(_PST("photo","photo_str_saving"));a.logo_name=this.photo_theme_myLogImag;this.configChange=false}else{if("init"!==a.action){this.configChange=true}}Ext.Ajax.request({url:"include/synotheme.php",params:a,success:function(c,g){var d={};try{d=Ext.decode(c.responseText)}catch(h){}if("init"===a.action){this.el.unmask();this.items.each(function(e){e.initData(d)});if("0"!==d.show_bkg){d.v6_show_bkg_img=PhotoStation.Util.getThemeRequestFile()+"?type=photo&action=bkg&cv=1&rnd"+Math.random()}this.initConfig=d;this.inited=true}if("v6_logo"===a.action){var i=!this.restore;Main.getScope("PhotoStation.LeftPanel").updateLogo(i)}if("v6_template"===a.action){this.setCSS(d)}if("save"===a.action){this.el.unmask();this.collapse();PhotoStation.Util.reloadCssFile("include/custom_css.php")}if("default"===a.action){this.setCSS(d)}if("v6_show_bkg_img"===a.action){var b=this.detailSettingPanel;var f=b.bkgRecord?{width:b.bkgRecord.info.resolutionx,height:b.bkgRecord.info.resolutiony}:{};b.updateBkg({image:b.bkgImage},f)}},failure:function(b,c){Ext.MessageBox.alert(_PST("photo","photo_str_common_error"),_PST("photo","photo_theme_server_error"))},scope:this})},saveAllSetting:function(){this.dataRequest({action:"save"})},setCSS:function(a){this.items.each(function(b){b.initData(a)},this)}});Ext.ns("PhotoStation");PhotoStation.ThumbnailView=Ext.extend(PhotoStation.BasicView,{appending:false,more:true,scale:1,imgMinWidth:80,imgMaxWidth:310,itemWidth:{},minWidthList:{},ratioList:[1,(3/2),(4/3),(16/9)],margin:5,constructor:function(a){Main.addScope("PhotoStation.ThumbnailView",this);PhotoStation.ThumbnailView.superclass.constructor.call(this,this.fillConfig(a));detail=this;this.minWidthList[this.ratioList[0]]=180+10;this.minWidthList[this.ratioList[1]]=200+10;this.minWidthList[this.ratioList[2]]=200+10;this.minWidthList[this.ratioList[3]]=240+10;this.delayedUpdateScrollbar=new Ext.util.DelayedTask(this.updateScrollbar,this);this.delayedCheckLoadMore=new Ext.util.DelayedTask(this.checkLoadMore,this);this.imageStyleUpdater=new PhotoStation.ImageStyleUpdater();this.imageStyleUpdater.delegate=this;this.loader=new PhotoStation.ImageLoadManager();this.loader.delegate=this;this.loadImages=[]},fillConfig:function(b){var a={store:null,tpl:this.createXTemplate(),cls:"thumbnail-view detail-view",overClass:"x-view-over",selectedClass:"x-view-selected",multiSelect:true,itemSelector:"div.thumb-wrap",ddGroup:"CategoryDDGroup",listeners:{buffer:80,scope:this,click:this.onNodeClick,activate:function(){this.loader.delegate=this;this.imageStyleUpdater.delegate=this;this.bindStore(Main.getScope("PhotoStation.ViewCard").store);this.initCtxMenu();if(this.store.lastOptions&&this.store.lastOptions.params.id!==PhotoStation.CurrentBrowse.getId()){Main.getScope("PhotoStation.ViewCard").containerReLoad();return}if(Main.getScope("PhotoStation.AboutMePanel")!==Main.getScope("PhotoStation.ViewCard").panelFrom){this.updateEmptyText(PhotoStation.Util.getDefaultEmptyText())}if(PhotoStation.CurrentBrowse.getRecord()&&PhotoStation.CurrentBrowse.isAlbum()){this.setAlbumDesc(PhotoStation.CurrentBrowse.getRecord().get("info").description)}Main.getScope("PhotoStation.CenterPanel").doLayout()},deactivate:function(){this.updateEmptyText("");this.loader.clear();this.loader.delegate=null;this.imageStyleUpdater.clear();this.imageStyleUpdater.delegate=null;this.bindStore(null)},afterrender:function(c){if(!this.dragZone){this.dragZone=new PhotoStation.AlbumDragZone(c,{containerScroll:true,ddGroup:"CategoryDDGroup"})}if(!this.dropTarget){this.dropTarget=new PhotoStation.AlbumDropTarget(c,{ddGroup:"CategoryDDGroup"})}},selectionchange:this.onSelectionChange,mouseenter:this.onNodeMouseEnter,contextmenu:function(c,d,f,g){this.showCtxMenu(d,g.xy[0],g.xy[1]);g.stopPropagation()}}};return Ext.apply(a,b)},updateEmptyText:function(a){this.emptyText=a;this.refresh();Main.getScope("PhotoStation.ViewCard").addEmptyTextOnClickHandler()},createXTemplate:function(){this.albumDescId=Ext.id();var a=new Ext.XTemplate('
','','
','
','
','
',"
","
",'
',"
","
","
",'
','','
',"
","
","
",'
','
','
{[this.getTitle(values)]}
',"
",'
','
{[this.getTitle(values)]}
',"
","
","
","
",'
',{getImgUrl:function(b){return PhotoStation.Util.getTemplateImgUrl(b)},getPreviewClass:function(b){if("defaultsmart"===b.type){return""}if(((0>b.thumbnail_status.indexOf("small"))&&(0<=b.thumbnail_status.indexOf("preview")))||(0<=b.thumbnail_status.indexOf("watermark"))){return"thumb-preview"}return""},getAlbumInfoVisibility:function(b){if(-1!==["album","smart","defaultsmart","tag","sharedalbum"].indexOf(b.type)){return"visible"}return"hidden"},getPhotoInfoVisibility:function(b){if(-1!==["photo","video"].indexOf(b.type)){return"visible"}return"hidden"},getTitle:function(b){var c;if(-1!==["smart","defaultsmart","tag","sharedalbum"].indexOf(b.type)){c=b.name}else{c=b.info.title}return Ext.util.Format.htmlEncode(c)},getVideoIconClass:function(b){if("video"!==b.type){return""}if(-1!==["broken",""].indexOf(b.thumbnail_status)){return""}if(-1===b.thumbnail_status.indexOf("small")&&-1!==b.thumbnail_status.indexOf("disable")){return""}return"thumb-video-icon"},getPublicShareStatusClass:function(b){if("sharedalbum"!==b.type){return""}if("none"===b.share_status){return""}else{if("valid"===b.share_status){return"public-share-valid"}else{if("invalid"===b.share_status||"expired"===b.share_status){return"public-share-invalid"}}}return""}});a.compile();return a},getTemplateTarget:function(){var a=this;a.scrollBar=a.scrollBar||a.el.createChild({tag:"div",style:"display:inline-block;width:100%;"});return a.scrollBar},refresh:function(){PhotoStation.ThumbnailView.superclass.refresh.apply(this,arguments);this.loader.clear();this.loadImages=[];this.preloadItems();this.delayedUpdateScrollbar.delay(500)},getImageItems:function(a,b){Ext.each(a,function(f,d,e){var c=Ext.fly(f).select("img").elements;if(02*this.getHeight()&&this.loadImages[c.id]){Ext.fly(c).select("img").each(function(d){var e=d.dom.getAttribute("src");if(e!==Ext.BLANK_IMAGE_URL){d.dom.setAttribute("src",Ext.BLANK_IMAGE_URL);d.dom.setAttribute("src2",e)}})}else{if(this.loadImages[c.id]){this.loadItem(c)}}},updateAllImageStyle:function(){var b=Ext.select(".detail-view img",Main.getScope("PhotoStation.ThumbnailView").id).elements;Ext.each(b,function(c){if(c.loaded){this.imageStyleUpdater.appendJob(c)}},this);var a=6;Ext.util.CSS.updateRule(".detail-view .thumb-border","width",(this.dstWidth-a)+"px");Ext.util.CSS.updateRule(".detail-view .thumb-border","height",(this.dstHeight-a)+"px");Ext.util.CSS.updateRule(".detail-view .thumb","width",this.dstWidth+"px");Ext.util.CSS.updateRule(".detail-view .thumb","height",this.dstHeight+"px");Ext.util.CSS.updateRule(".detail-view .album-info","width",this.dstWidth+"px");Ext.util.CSS.updateRule(".detail-view .photo-info","width",this.dstWidth+"px");Ext.util.CSS.updateRule(".detail-view .thumb-wrap","margin-left",this.marginW+"px");Ext.util.CSS.updateRule(".detail-view .thumb-wrap","margin-right",this.marginW+"px")},onImageLoad:function(a){a.loaded=true;this.imageStyleUpdater.appendJob(a)},onImageError:function(a){a.src=Ext.BLANK_IMAGE_URL;this.imageStyleUpdater.appendJob(a)},updateImageStyle:function(h){var i=this.store.getById(h.getAttribute("thumbid"));var g=Ext.fly(h);if(!g||!i){return}if(!h.appeared){var b=g.parent(".thumb-loading");if(b){b.removeClass("thumb-loading")}b=g.parent(".thumb-opacity");if(b){b.addClass("fadein")}h.appeared=true}var f=0,j=0;var q=this.getImageSize(i);var c=q.width,o=q.height;if(this.dstWidth>=c&&this.dstHeight>=o){var d=c||50,n=o||50;j=(this.dstWidth-d)/2;f=(this.dstHeight-n)/2;h.style.width=d+"px";h.style.height=n+"px"}else{var m=this.dstWidth/c,k=this.dstHeight/o;if((m>k&&o/c<=12)||c/o>12){var a=o*m;f=(this.dstHeight-a)/2;h.style.width=this.dstWidth+"px";h.style.height=(a<1?1:a)+"px"}else{var e=c*k;j=(this.dstWidth-e)/2;h.style.width=(e<1?1:e)+"px";h.style.height=this.dstHeight+"px"}}h.style.marginTop=f+"px";h.style.marginLeft=j+"px"},getImageSize:function(e){var a,m;if(!e.data||!e.data.additional||!e.data.additional.thumb_size){return}var b=e.data.info,h=e.data.additional.thumb_size;var g=h.preview?h.preview:{resolutionx:0,resolutiony:0},d=h.small?h.small:{resolutionx:0,resolutiony:0};if("photo"===e.data.type||"video"===e.data.type){var c=b.rotated,f=d.resolutionx||g.resolutionx,k=d.resolutiony||g.resolutiony;var j,n;var i=false;j=c?b.resolutiony:b.resolutionx;n=c?b.resolutionx:b.resolutiony;i=j&&n&&ja.scrollPosition[1][1]-a.scrollPosition[1][0]){this.loadMore()}},onUpdate:function(){PhotoStation.ThumbnailView.superclass.onUpdate.call(this);this.delayedCheckLoadMore.delay(250)},onResize:function(){this.calItemDefaultWidth();this.doUpdateThumbWidth()},onSliderChangeComplete:function(b,c,a){Ext.util.Cookies.set("slider-value",c);this.calculateScale(c);this.updateThumbWidth()},calculateScale:function(c){var d,b,a,e;d=Main.getScope("PhotoStation.StatusTopArea").slider;b=this.itemWidth[this.ratio];if(this.imgMaxWidth-b>b-this.imgMinWidth){a=this.imgMinWidth+(c-d.minValue)*(b-this.imgMinWidth)/(d.defaultValue-d.minValue)}else{a=this.imgMaxWidth-(d.maxValue-c)*(this.imgMaxWidth-b)/(d.maxValue-d.defaultValue)}this.scale=Math.floor(a)/b;this.itemInRow=this.calculateItemInRow(e);return this.scale},calculateItemInRow:function(c){var b=this.getWidth()-8,a=this.minWidthList[this.ratio];return Math.round(b/a)},loadMore:function(a,e){if(this.appending||!this.more){return}this.appending=true;var d=this.store.getTotalCount(),c=this.store.getCount();c-=PhotoStation.Util.getManualInsertCount(this.store);if(d<=c){this.appending=false;this.more=false;return}if(!e){Main.getScope("PhotoStation.LoadMoreBar").show()}if(this.store2){this.store2.destroy()}var f=Ext.apply({},PhotoStation.Util.getContainerLoadParams(),this.store.baseParams);this.store2=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:this.store.proxy.url,listeners:{beforeload:function(g,h){var i=g.activeRequest.read;if(i){Ext.Ajax.abort(i)}}}}),baseParams:f,root:this.store.root,idProperty:this.store.idProperty,totalProperty:this.store.totalProperty,fields:this.store.fields.keys});if(PhotoStation.Info.paging_use_bar){f.offset=Math.max(0,a.offset)}else{f.offset=c}var b={params:f,callback:this.loadMoreCallback.createDelegate(this,[f.offset,a],true),scope:this};this.store2.removeAll();this.store2.load(b)},loadMoreCallback:function(g,f,a,h,b){if(!this.store){return}Main.getScope("PhotoStation.LoadMoreBar").hide();if(!this.ownerCt.firstLoadMoreFinished){this.ownerCt.firstLoadMoreFinished=true}if(!a||!g.length){this.appending=false;this.more=false;return}function e(){return false}if(!PhotoStation.Info.paging_use_bar){this.store.add(g);for(var d=0;d=0;--v){q.appendChild(r[v])}j=document.createElement("div");j.className="count";j.innerHTML=String.format(_PST("photo","photo_str_num_items_selected"),g.records.length);q.appendChild(j);g.ddel=q;g.offset=(function(H,J){var d=0,I=H.length;while(d=0;--g){if(f.indexes[g]===f.index){Ext.fly(j.getNode(f.index)).addClass("drag-node")}else{m.remove(m.getAt(f.indexes[g]))}}if(j===Main.getScope("PhotoStation.PhotowallView")){j.resizeImages()}var k=function(e){if(!e.target.style.transform){e.target.style.display="none"}};for(var c=document.querySelector("."+f.ddel.className).firstElementChild;c&&(c.className==="thumb");c=c.nextElementSibling){c.addEventListener("transitionend",k);c.style.left="0";c.style.top="-136px"}for(var d=f.ddel.firstElementChild;d&&(d.className==="thumb");d=d.nextElementSibling){d.style.left="0";d.style.top="-136px"}var b=document.createElement("div");j.getNode(0).offsetParent.appendChild(b)},notifyOver:function(q,p,t){if(this.lastOverNode){this.lastOverNode.removeClass("photo-thumb-dragover")}var g=this.ddTarget.getNode(0).offsetParent.lastElementChild;if(g.className!=="x-clear"){g.className=""}var b=Ext.get(q.dragElId);b.removeClass("x-tree-drop-ok-append");if(!this.checkAllowDrop(t)){this.removeClass();return false}var r=t.index-t.offset;var c=this.getDropIndex(p.getXY(),r);if(c<0){return false}if(typeof(c)!=="number"){if(PhotoStation.Util.hasCategoryPriv()||(c.viewIndex===r)){return false}else{b.addClass("x-tree-drop-ok-append");this.lastOverNode=Ext.get(c);this.lastOverNode.addClass("photo-thumb-dragover");return true}}var n=PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isAlbum();if(n){if(!this.checkAllowDropAlbumItem(t,c)){this.removeClass();return false}}var s=this.ddTarget;var j=s.getEl();var d=j.child(".prev-node");var f=c-1;if(f===r){--f}var k=Ext.fly(s.getNode(f));if(d!==k){if(d){d.removeClass("prev-node")}if(k){k.addClass("prev-node")}}var o=j.child(".next-node");var i=c;if(i===r){++i}var a=Ext.fly(s.getNode(i));if(o!==a){if(o){o.removeClass("next-node")}if(a){a.addClass("next-node")}}if(c>r){--c}if(c===r){return false}else{if(g.className!=="x-clear"){g.className="photo-drop-indicator";k=s.getNode(f);a=s.getNode(i);s=(k?k.offsetParent:a.offsetParent);var m=(k?(k.offsetLeft+k.offsetWidth):0);if(!a||(k&&(k.offsetTop===a.offsetTop))){g.style.left=""+(m+2)+"px";g.style.top=""+k.offsetTop+"px";g.style.right=""+(s.offsetWidth-m-4)+"px";g.style.bottom=""+(s.offsetHeight-k.offsetTop-k.offsetHeight)+"px"}else{var h=p.getPageY()-j.getY()+j.dom.fleXdata.scrollPosition[1][0];if(k&&(h>=k.offsetTop)&&(h<=(k.offsetTop+k.offsetHeight))){g.style.left=""+m+"px";g.style.top=""+k.offsetTop+"px";g.style.right=""+(s.offsetWidth-m-2)+"px";g.style.bottom=""+(s.offsetHeight-k.offsetTop-k.offsetHeight)+"px"}else{if((h>=a.offsetTop)&&(h<=(a.offsetTop+a.offsetHeight))){g.style.left="0";g.style.top=""+a.offsetTop+"px";g.style.right=""+(s.offsetWidth-2)+"px";g.style.bottom=""+(s.offsetHeight-a.offsetTop-a.offsetHeight)+"px"}else{}}}}return true}},doCopyOrMove:function(d,a,b,c){var f=Main.getScope("PhotoStation.CopyMoveMenu");if(!f){f=new PhotoStation.CopyMoveMenu();f.on("aftercopymove",PhotoStation.LeftContent.prototype.copyMoveDone,Main.getScope("PhotoStation.LeftContent"))}f.setItems({albums:a,files:b},d.id,d.data.info.title);f.showAt(c.getXY())},doCreateAndMove:function(d,b,c){var a=function(h,g){SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Album","move",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:b.join(","),duplicate:"overwrite",sharepath:h},function(n,m,k,i){if(!n){var j=PhotoStation.Util.getErrMsg(m);if(419===m.code){j=_PST("photo","photo_permission_denied_upload")}else{if(425===m.code){j=_PST("photo","photo_str_select_conflict")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),j);return}Main.getScope("PhotoStation.LeftContent").reloadAlbums(g);Main.getScope("PhotoStation.ViewCard").containerReLoad()},this)};var e=function(h,g){SYNO.API.currentManager.requestAjaxAPI("SYNO.PhotoStation.Photo","copy",1,{timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT},{id:c.join(","),mode:"move",duplicate:"overwrite",sharepath:h},function(n,i,m,j){if(!n){var k=PhotoStation.Util.getErrMsg(i);if(457===i.code){k=_PST("photo","photo_permission_denied_upload")}else{if(458===i.code){k=_PST("photo","photo_str_select_conflict")}}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),k);return}if(b.length){a(h,g)}else{Main.getScope("PhotoStation.LeftContent").reloadAlbums(g);Main.getScope("PhotoStation.ViewCard").containerReLoad()}},this)};c.push(d.id);var f=Main.getScope("PhotoStation.SettingWindow");if(!f){f=new PhotoStation.SettingWindow()}f.showCreateAlbum({createCallback:function(i,h,g){e(i,h)}})},doDrop:function(n,k,f){this.removeClass();var c=f.index-f.offset;var m=this.getDropIndex(k.getXY(),c);if(m<0){return true}if(typeof(m)!=="number"){if(m.viewIndex===c){this.ddTarget.triggeredByDrop=true}else{if(!PhotoStation.Util.hasCategoryPriv()&&this.checkAllowDrop(f)){var d=[],a=[];for(var g=0;gc){--m}if(m===c){return true}var b=PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isAlbum();if(b){if(!this.checkAllowDropAlbumItem(f,m)){return true}}this.updateView(f,m);this.doArrangeItems(Math.min(f.indexes[0],m),Math.max(f.indexes[f.indexes.length-1],m),b);f.records=[];return true},finalize:function(e){if(this.lastOverNode){this.lastOverNode.removeClass("photo-thumb-dragover")}var f=this.ddTarget;var c=f.store;for(var d=0;d0)&&(f===Main.getScope("PhotoStation.PhotowallView"))){f.resizeImages()}},notifyDrop:function(a,d,c){var b=this.doDrop(a,d,c);this.finalize(c);a.endDrag();return b},notifyOut:function(b,c,a){this.removeClass();this.finalize(a);a.isRemoved=false},removeClass:function(){var c=this.ddTarget.getEl();var b=c.child(".prev-node");if(b){b.removeClass("prev-node")}var a=c.child(".next-node");if(a){a.removeClass("next-node")}},getDropIndex:function(b,a){var c=this.ddTarget.el;return this.getBinaySearchrIndex(c.select(".thumb-wrap").elements,{x:b[0]-c.getX(),y:b[1]-c.getY()+c.dom.fleXdata.scrollPosition[1][0]})},getBinaySearchrIndex:function(e,h){var g=this.ddTarget.margin,n=this.ddTarget.marginW||this.ddTarget.margin;var f=0,d=e.length-1,b,o,i,a,c,k;while(f<=d){b=Math.floor((f+d)/2);o=e[b];i=o.offsetTop-g;a=o.offsetTop+o.offsetHeight+g*2;c=o.offsetLeft-n;k=o.offsetLeft+o.offsetWidth+n*2;var j=o.offsetLeft+20,m=o.offsetLeft+o.offsetWidth-20;if(ah.y||(a>=h.y&&c>h.x)){d=b-1}else{if((h.x>j)&&(h.x(c+k)/2){return b+1}return b}}}return -1},checkAllowDrop:function(a){if(!PhotoStation.Util.hasAlbumPriv("manage")&&!PhotoStation.Util.hasCategoryPriv()){return false}if("album"!==a.source){return false}return true},checkAllowDropAlbumItem:function(e,b){var a=this.ddTarget.store,d=e.record.get("type")==="album",c=a.query("type","album").length;return(d&&(b<=c))||(!d&&(b>=c))},updateView:function(f,b){function e(){return false}var g=this.ddTarget;var a=g.store;a.remove(a.getAt(f.index-f.offset));var h=f.records;for(var c=h.length-1;c>=0;--c){a.insert(b,h[c]);var d=g.getNode(b);d.oncontextmenu=e;g.onLoadItem(Ext.fly(d))}if(g===Main.getScope("PhotoStation.PhotowallView")){g.resizeImages()}},doArrangeItems:function(g,a,b){var e=[];for(var c=g;c<=a;c++){var f=this.ddTarget.store.getAt(c);if(f){e.push(f.get("id"))}}if(!e.length){return}var d=b?"SYNO.PhotoStation.Album":"SYNO.PhotoStation.Category";SYNO.API.currentManager.requestAPI(d,"arrangeitem",1,{id:PhotoStation.Util.getContainerLoadParams().id,offset:this.ddTarget.store.lastOptions.params.offset+g,limit:e.length,item_id:e.join(",")},Ext.createDelegate(this.doArrangeItemsCallback,this,[e.join(",")],true));if(b){Ext.util.Cookies.set("photo-sort-by","preference");Main.getScope("PhotoStation.StatusTopArea").sorType="preference";Main.getScope("PhotoStation.StatusTopArea").updateViewModeBtn()}},doArrangeItemsCallback:function(e,d,c,b,a){if(!e){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_save_data"));Main.getScope("PhotoStation.ViewCard").containerReLoad();return}if(0===a.indexOf("album_")){Main.getScope("PhotoStation.LeftPanel").doArrangeAlbums()}Main.getScope("PhotoStation.CenterPanel").getTopToolbar().updateMoreBtn(false,true)}});Ext.ns("PhotoStation");PhotoStation.TimelineView=Ext.extend(PhotoStation.LazyDataView,{expectedImageWidth:200,constructor:function(a){Main.addScope("PhotoStation.TimelineView",this);PhotoStation.TimelineView.superclass.constructor.call(this,this.fillConfig(a));time=this;this.delayedUpdateScrollbar=new Ext.util.DelayedTask(this.updateScrollbar,this);this.imageStyleUpdater=new PhotoStation.ImageStyleUpdater();this.imageStyleUpdater.delegate=this;this.loader=new PhotoStation.ImageLoadManager();this.loader.delegate=this},fillConfig:function(b){this.expectedImageWidth=200;var a={store:this.createStore(),tpl:this.createXTemplate(),cls:"thumbnail-view timeline-view",itemSelector:"div.timeline-wrap",listeners:{buffer:80,scope:this,activate:this.onActive,deactivate:this.onDeactive,afterrender:function(){this.updateScrollbar()}}};this.timelineContainers=new Ext.util.MixedCollection();return Ext.apply(a,b)},onActive:function(){this.updateScrollbar(true);this.calcLayout();this.store.load({params:PhotoStation.Util.appendCurrentFilter(),callback:function(a,b,c){if(PhotoStation.CurrentBrowse.getRecord()&&PhotoStation.CurrentBrowse.isAlbum()){this.setAlbumDesc(PhotoStation.CurrentBrowse.getRecord().get("info").description)}},scope:this});Main.getScope("PhotoStation.StatusTopArea").timelineBtn.show()},onDeactive:function(){this.clearTimelineContainers();Main.getScope("PhotoStation.StatusTopArea").timelineBtn.hide()},createStore:function(){return new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("timeline.php"),listeners:{beforeload:function(a,b){var c=a.activeRequest.read;if(c){Ext.Ajax.abort(c)}}}}),baseParams:{api:"SYNO.PhotoStation.Timeline",method:"getindex",version:1,type:"photo,video",recursive:true},root:"data.date_objs",idProperty:"date",totalProperty:"data.total",fields:["date","year","month","day","index","count","combined_dates","combined_count"],listeners:{scope:this,beforeload:function(){this.mask();this.clearTimelineContainers()},load:function(b,a,c){this.unmask();Main.getScope("PhotoStation.StatusTopArea").timelineBtn.initIndex(b)}},loadRecords:function(c,a,b){if(c){this.combineNearRecords(c.records)}Ext.data.JsonStore.superclass.loadRecords.apply(this,arguments)},combineNearRecords:function(h){var j=Main.getScope("PhotoStation.TimelineView");var g=Math.floor(j.itemCountInRow/2),e=0,c,a,b,d,k,f;while(ej.itemCountInRow){e++;continue}c.get("combined_dates").push(a.get("date"));c.set("combined_count",c.get("combined_count")+a.get("count"));h.splice(e+1,1)}}})},createXTemplate:function(){this.albumDescId=Ext.id();var a=new Ext.XTemplate('
','','
','
','
','
','
{[this.getDate(values)]}
',"
",'
',"
",'
','
',"
","
","
",{getDate:function(b){var e=b.combined_dates[0],d,c;if(1===b.combined_dates.length){c="1970-01-01"!==e?e.replace(/-/g,"/"):_PST("photo","photo_str_unknown_takendate")}else{d=b.combined_dates[b.combined_dates.length-1];if(e>d){e=b.combined_dates[b.combined_dates.length-1];d=b.combined_dates[0]}c=e.replace(/-/g,"/")+" - "+d.substr(5).replace(/-/g,"/")}return Ext.util.Format.htmlEncode(c)},getId:function(){return Ext.id()}});a.compile();return a},getTemplateTarget:function(){var a=this;a.scrollBar=a.scrollBar||a.el.createChild({tag:"div",style:"display:inline-block;width:100%;"});return a.scrollBar},refresh:function(){this.loadImages=[];PhotoStation.TimelineView.superclass.refresh.apply(this,arguments);this.loader.clear();this.delayedUpdateScrollbar.delay(500)},onResize:function(){this.updateAllImageStyle()},onUpdate:function(){this.heightThreshold=this.getEl().getHeight()*2;PhotoStation.TimelineView.superclass.onUpdate.call(this)},onLoadItem:function(c){var a=this.store.getAt(this.indexOf(c));if(this.loadImages[c.id]){this.loadItem(c);return}if(c.dom.loaded||!a){return}c.dom.loaded=true;var b={view:this,renderTo:c.child("div.timeline-container-wrap"),date:a.get("date"),combinedDates:a.get("combined_dates"),combinedCount:a.get("combined_count")};this.timelineContainers.add(a.get("date"),new PhotoStation.TimelineContainer(b));this.loadImages[c.id]=1},onImageLoad:function(a){a.loaded=true;this.imageStyleUpdater.appendJob(a)},onUnLoadItem:function(c){if(!c||!c.id){return}var b=this.el.dom.fleXdata.scrollPosition[1][0]||0,a=c.getOffsetsTo(this.scrollBar.dom)[1];if(Math.abs(b-a)>2*this.getHeight()&&this.loadImages[c.id]){Ext.fly(c).select("img").each(function(d){var e=d.dom.getAttribute("src");if(e!==Ext.BLANK_IMAGE_URL){d.dom.setAttribute("src",Ext.BLANK_IMAGE_URL);d.dom.setAttribute("src2",e)}})}else{if(this.loadImages[c.id]){this.loadItem(c)}}},onImageError:function(a){a.src=Ext.BLANK_IMAGE_URL;this.imageStyleUpdater.appendJob(a)},loadItem:function(a){Ext.fly(a).select("img").each(function(b){var c=b.dom.getAttribute("src2");if(c&&c!==Ext.BLANK_IMAGE_URL){b.dom.removeAttribute("src2");b.dom.setAttribute("src",c)}})},updateImageStyle:function(C){var m=Ext.get(C),u=m.parent(".thumb"),c=u.prev(".thumb-border"),b=m.parent(".thumb-wrap"),n=m.parent("div.timeline-container");if(!n){return}var A=Ext.getCmp(n.id);if(!m||!A){return}var d=A.store;var a=d.getById(C.getAttribute("thumbid"));if(!a){return}if(!C.appeared){var r=m.parent(".thumb-loading");if(r){r.removeClass("thumb-loading")}r=m.parent(".thumb-opacity");if(r){r.addClass("fadein")}C.appeared=true}var q=a.size;var o=this.margin;var t,k,i,f,B=a.get("layout");if("L"===B){t=this.imageHeight*2+o;k=this.imageWidth;u.addClass("timeline-long-thumb");c.addClass("timeline-long-thumb");i=a.coordx*(this.imageWidth+o)-o;b.setLeft(i)}else{if("B"===B){t=this.imageHeight*2+o;k=this.imageWidth*2+o;u.addClass("timeline-big-thumb");c.addClass("timeline-big-thumb");i=a.coordx*(this.imageWidth+o)-o;b.setLeft(i)}else{if("S"===B){t=this.imageHeight;k=this.imageWidth;u.addClass("timeline-small-thumb");c.addClass("timeline-small-thumb");i=a.coordx*(this.imageWidth+o)-o;f=a.coordy*(this.imageHeight+o);b.setLeft(i);b.setTop(f)}else{return}}}if(!q.width&&!q.height){C.style.height=C.style.width="auto";C.style.marginLeft=(k-50)/2+"px";C.style.marginTop=(t-50)/2+"px"}else{var g=k/q.width,e=t/q.height,z=0,v=0;if(g>e){var s=q.height*g;v=(t-s)/2;C.style.width=k+"px";C.style.height=s+"px"}else{var j=q.width*e;z=(k-j)/2;C.style.width=j+"px";C.style.height=t+"px"}C.style.marginTop=v+"px";C.style.marginLeft=z+"px"}},calcLayout:function(){var e=this.getWidth()-23,d=this.expectedImageWidth,b=Math.floor(e/d);this.itemCountInRow=b;var a=Math.floor((e-b*3)/b);this.imageWidth=a;this.imageHeight=Math.floor(a*3/4);this.margin=Math.floor((e-a*b)/(b-1));this.containerWidth=e;this.itemWidth=this.imageWidth+this.margin;var c=this.imageHeight*2+10;Ext.util.CSS.updateRule(".timeline-view .timeline-container","height",c+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-container-wrap","height",c+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-small-thumb","width",this.imageWidth+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-small-thumb","height",this.imageHeight+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-big-thumb","width",this.imageWidth*2+this.margin+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-big-thumb","height",this.imageHeight*2+this.margin+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-long-thumb","width",this.imageWidth+"px");Ext.util.CSS.updateRule(".timeline-view .timeline-long-thumb","height",this.imageHeight*2+this.margin+"px");this.delayedUpdateScrollbar.delay(500)},updateAllImageStyle:function(){this.calcLayout();Ext.each(this.timelineContainers.items,function(c){var b=this.itemCountInRow*2;if(b>c.store.getCount()&&b<=c.store.getTotalCount()){c.loadItems()}else{c.redrawItems()}},this);var a=Ext.select(".timeline-view img",Main.getScope("PhotoStation.TimelineView").id).elements;Ext.each(a,function(b){if(b.loaded){this.imageStyleUpdater.appendJob(b)}},this)},clearTimelineContainers:function(){var a;while((a=this.timelineContainers.removeAt(0))){a.destroy()}this.store.removeAll()},getCurrentBrowseDateIndex:function(){var b=0,c=this.el.dom.fleXdata,a;if(c&&c.scrollPosition[1][1]){a=c.scrollPosition[1][0];for(b=0;b1){b.combinedDates.sort();this.combinedDatesStr=b.combinedDates[0]+","+b.combinedDates[b.combinedDates.length-1]}this.store=this.createFeaturedStore();this.lightboxStore=this.createStore();this.lightboxBeginOffset=undefined;this.lightboxEndOffset=undefined;this.itemTpl=this.createItemXTemplate();return Ext.apply(a,b)},createFeaturedStore:function(){return new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("photo.php"),listeners:{beforeload:function(a,b){var c=a.activeRequest.read;if(c){Ext.Ajax.abort(c)}}}}),baseParams:{api:"SYNO.PhotoStation.Photo",method:"listfeatureditem",version:1,count:50,type:"photo,video",additional:"photo_exif,video_codec,video_quality,thumb_size"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail","thumbnail_status","info","additional","pos"],listeners:{scope:this,beforeload:function(a,b){this.mask()},load:function(b,a,c){this.unmask()}}})},createStore:function(){return new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("photo.php"),listeners:{beforeload:function(a,b){var c=a.activeRequest.read;if(c){Ext.Ajax.abort(c)}}}}),baseParams:{api:"SYNO.PhotoStation.Photo",method:"list",version:1,offset:0,limit:50,type:"photo,video",sort_by:"takendate",sort_direction:"asc",additional:"photo_exif,video_codec,video_quality,thumb_size"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail","thumbnail_status","info","additional","pos"]})},createItemXTemplate:function(){var a=new Ext.XTemplate("",'
','
','
','
',"
","
","
",'
','',"
","
","
","
",{getImgUrl:function(b){var c="video"===b.type;if("broken"===b.thumbnail_status){return PhotoStation.Util.getImgUrl("White/"+(c?"image_default_video.png":"image_broken_file.png"),true)}else{if(""===b.thumbnail_status||(0>b.thumbnail_status.indexOf("small")&&0<=b.thumbnail_status.indexOf("disable"))){return PhotoStation.Util.getImgUrl("White/"+(c?"image_default_video.png":"image_default_photo.png"),true)}else{if(0>b.thumbnail_status.indexOf("small")&&0<=b.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(b,{size:"preview"})}}}return PhotoStation.Util.getThumbUrl(b,{size:"small"})},getPreviewClass:function(b){if("defaultsmart"===b.type){return""}if(((0>b.thumbnail_status.indexOf("small"))&&(0<=b.thumbnail_status.indexOf("preview")))||(0<=b.thumbnail_status.indexOf("watermark"))){return"thumb-preview"}return""},getTitle:function(b){var c;if(-1!==["smart","defaultsmart","tag"].indexOf(b.type)){c=b.name}else{c=b.info.title}return Ext.util.Format.htmlEncode(c)},getVideoIconClass:function(b){if("video"!==b.type){return""}if(-1!==["broken",""].indexOf(b.thumbnail_status)){return""}if(-1===b.thumbnail_status.indexOf("small")&&-1!==b.thumbnail_status.indexOf("disable")){return""}return"thumb-video-icon"}});a.compile();return a},getImageItems:function(a,b){Ext.each(a,function(f,d,e){var c=Ext.fly(f).select("img").elements;if(0=g){c.setPagingDataStart(this.lightboxBeginOffset);Main.getScope("PhotoStation.ViewCard").photoLoad(f,this.lightboxStore)}else{if(undefined===this.lightboxEndOffset&&undefined===this.lightboxBeginOffset){d=this.lightboxBeginOffset=Math.max(0,g-b);a=g+b;this.lightboxEndOffset=a}else{this.loadMore({pos:g,windowSize:0,callback:function(){c.setPagingDataStart(this.lightboxBeginOffset);Main.getScope("PhotoStation.ViewCard").photoLoad(f,this.lightboxStore)}.createDelegate(this)});return}e=PhotoStation.Util.appendCurrentFilter({taken_date:this.combinedDatesStr,offset:d,limit:a-d+1});e.sort_direction="asc";this.view.lightBoxDate=this.date;this.lightboxStore.load({params:e,callback:function(h,i,k){if(!k){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_load_data"));return}var j=this.lightboxStore.getTotalCount();this.lightboxEndOffset=Math.min(this.lightboxEndOffset,j-1);c.setPagingDataStart(this.lightboxBeginOffset);Main.getScope("PhotoStation.ViewCard").photoLoad(f,this.lightboxStore)},scope:this})}},loadItems:function(){var a=-1,b;if(this.combinedCount>this.view.itemCountInRow*4){a=this.view.itemCountInRow*2;if(false&&!this.useFloatingBtn){a--}}b=PhotoStation.Util.appendCurrentFilter({taken_date:this.combinedDatesStr,count:a});delete b.offset;this.store.load({params:b,callback:this.loadItemsCallback,scope:this})},loadItemsCallback:function(a,b,c){if(!c){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("phtot","photo_str_error_load_data"));return}if(!this.el.dom){return}this.redrawItems()},needLoadMore:function(b,e){var f=this.lightboxStore.getAt(b).get("pos");var d=this.lightboxStore.getTotalCount(),c=Math.max(0,f-e),a=Math.min(d-1,f+e);if(!this.more){return false}if(f+e>=d&&((f+e)%d)c||this.lightboxEndOffsetthis.lightboxEndOffset){this.addMoreMode="append";j=Math.min(h-1,b+i);d=this.lightboxEndOffset+1;this.lightboxEndOffset=j}else{if(g+k.windowSize>=h&&((g+k.windowSize)%h)=0)&&(b=this.view.imageWidth){g="L"}else{g="N"}}else{if(d>=this.view.imageWidth*2&&!this.hLayoutImageCount){g="B";this.hLayoutImageCount++}else{if(d>=this.view.imageWidth){if(e-b===1&&!a[b].get("layout")){g="S";a[b].set("layout","S")}c.push(a[e]);b=e}else{g="N"}}}f.set("layout",g);d-=g?h[g]:0}for(e=0;e=0)&&!c[e].get("layout")){c[e].set("layout","B");d-=h.B}else{if(!c[e].get("layout")){c[e].set("layout","N")}}}if(a.length<=this.view.itemCountInRow/2){for(e=0;e",{cls:"photo-blue-button photo-button",text:_PST("photo","photo_str_btnOK"),handler:this.clickOK,scope:this}]}]};return Ext.apply(a,b)},clickCreate:function(){var a=this.selector.getSelectionModel().getSelectedNode();if(!a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_man_choose_location_first"));return}var b=Main.getScope("PhotoStation.SettingWindow");if(!b){b=new PhotoStation.SettingWindow()}b.showCreateAlbum({record:a.attributes.record,createCallback:(function(d,c){Ext.getCmp(Main.getScope("PhotoStation.UploadWindow").albumNameButtonId).showMenu();Main.getScope("PhotoStation.LeftContent").reloadAlbums(c);a.reload(function(){this.selector.selectPath(this.selector.getSelectionModel().getSelectedNode().getPath()+"/"+d)},this)}).createDelegate(this),cancelCallback:function(){Ext.getCmp(Main.getScope("PhotoStation.UploadWindow").albumNameButtonId).showMenu()}});this.hide()},clickOK:function(){var a=this.selector.getSelectionModel().getSelectedNode();if(!a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_man_choose_location_first"));return}var b=Main.getScope("PhotoStation.UploadWindow");if(PhotoStation.Define.ALBUM_CATEGORY===a.id){b.albumID="";b.currentDir="";Ext.getCmp(b.albumNameButtonId).setText(Ext.util.Format.htmlEncode(a.attributes.record.get("name")))}else{b.albumID=a.id;b.currentDir=a.attributes.info.sharepath;Ext.getCmp(b.albumNameButtonId).setText(Ext.util.Format.htmlEncode(a.attributes.record.get("info").title))}b.currentPathForChangeFolder=a.getPath();this.hide()}});Ext.ns("PhotoStation");PhotoStation.SocialNetworkSingleUploader=Ext.extend(PhotoStation.BaseWindow,{isUploading:false,website:"",constructor:function(b){this.website=b.website;this.imgurl=b.imgurl;this.imgtitle=b.title;this.imgid=b.id;this.description=b.description;var a={title:_PST("photo","photo_str_upload_to_fb"),modal:true,animateTarget:null,autoScroll:false,resizable:false,layout:"fit",border:false,width:642,height:(this.website==="youtube"?402:372),shadow:true,buttonAlign:"left",fbar:[{xtype:"label",id:"fb_status",text:""},{xtype:"label",id:"upload_progress",text:""},"->",{text:_PST("photo","photo_str_btnUpload"),id:"btn_upload",cls:"photo-blue-button photo-button",scope:this,handler:this.onBtnUpload},{text:_PST("photo","photo_str_btnCancel"),id:"btn_cancel",cls:"photo-grey-button photo-button",scope:this,handler:this.onBtnCancel}],items:this.getItemConfig()};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);PhotoStation.SocialNetworkSingleUploader.superclass.constructor.call(this,a);this.imgContainer=Ext.get("imgContainer");this.fb_img=Ext.get("fb_img");this.btn_cancel=Ext.get("btn_cancel");this.btn_upload=Ext.get("btn_upload");this.video_title=Ext.getCmp("video_title");this.title_field=Ext.get("title");this.video_privacy=Ext.getCmp("video_privacy");this.label_status=Ext.get("fb_status");this.label_progress=Ext.getCmp("upload_progress");this.loadingImg=Ext.get("fb_loading_img");this.delToken=Ext.get("fb_deletetoken");this.updateStatusImg=Ext.get("fb_status_loading");this.fbPic=Ext.get("fb_pic");this.fbAuthorize=Ext.get("fb_authorize");this.fbAuthorizeUsername=Ext.get("fb_authorize_username");this.fbProviderIcon=Ext.get("fb_provider_icon");this.combo=Ext.getCmp("album_combo");this.imgContainer.addClass("facebook_upload_image_container");this.fbPic.dom.src="images/White/defalut_image.png";this.delToken.dom.innerHTML=_PST("photo","photo_logout");this.delToken.hide();this.video_privacy.setValue(this.privacy_store.getAt(0).get("value"));this.mon(this.delToken,"click",function(){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_confirm_logout"),function(c){if(c!="yes"){return}this.deleteToken()},this)},this);this.mon(this.fb_img,"load",function(){this.loadingImg.hide();this.fb_img.show();if(this.fb_img.dom.width>this.fb_img.dom.height){this.fb_img.setStyle("max-width","");this.fb_img.setStyle("max-height","100%")}else{this.fb_img.setStyle("max-width","100%");this.fb_img.setStyle("max-height","")}this.fb_img.alignTo.defer(100,this.fb_img,[this.imgContainer,"c-c"]);this.title_field.focus.defer(1000,this.title_field)},this);this.fb_img.setVisibilityMode(Ext.Element.VISIBILITY);this.on("show",function(){this.updateWindowTitleIcon();this.loadingImg.show();this.loadingImg.alignTo(this.imgContainer,"c-c");this.fb_img.dom.src=this.imgurl;if(this.website!="youtube"){this.title_field.dom.value=this.imgtitle}else{this.title_field.dom.value=this.description;this.video_title.setValue(this.imgtitle.substring(0,100))}this.alignTo(Ext.getBody(),"c-c");this.title_field.focus();this.fbAuthorize.dom.innerHTML="";this.fbAuthorizeUsername.dom.innerHTML="";this.setFacebookUserPicture("");this.updateFacebookStatus()},this);this.on("beforehide",this.onBeforeHide,this)},afterRender:function(){PhotoStation.SocialNetworkSingleUploader.superclass.afterRender.call(this)},onBeforeHide:function(){Ext.getCmp("btn_upload").enable();this.fb_img.dom.src="";this.label_status.removeClass("loading-indicator");this.label_status.dom.innerHTML=""},updateWindowTitleIcon:function(){this.setTitle(_PST("photo","photo_str_upload_to_fb"));if(this.website=="twitter"){this.setTitle(_PST("photo","photo_str_upload_to_twitter"))}else{if(this.website=="picasa"){this.setTitle(_PST("photo","photo_str_upload_to_picasa"))}else{if(this.website==="weibo"){this.setTitle(_PST("photo","photo_str_upload_to_weibo"))}else{if(this.website=="qq"){this.setTitle(_PST("photo","photo_str_upload_to_qq"))}else{if(this.website=="youtube"){this.setTitle(_PST("photo","photo_str_upload_to_youtube"))}else{if(this.website=="flickr"){this.setTitle(_PST("photo","photo_str_upload_to_flickr"))}}}}}}if(this.website==="weibo"){this.fbProviderIcon.dom.src="images/SocialNetwork/weibo.png"}else{if(this.website==="qq"){this.fbProviderIcon.dom.src="images/SocialNetwork/qq.png"}else{this.fbProviderIcon.hide()}}},deleteToken:function(){var a=new Date();a.setDate(a.getDate()-365);this.updateFacebookUIInfo(false,null);if(this.website=="facebook"){Ext.util.Cookies.set("facebook_token","",a);Ext.util.Cookies.set("facebook_uid","",a);var b="http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/logout_facebook.php";window.open(b,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300")}else{if(this.website=="twitter"){Ext.util.Cookies.set("twitter_token","",a);Ext.util.Cookies.set("twitter_secret","",a);Ext.util.Cookies.set("twitter_screen_name","",a)}else{if(this.website=="picasa"){Ext.util.Cookies.set("picasa_token","",a)}else{if(this.website==="weibo"){Ext.util.Cookies.set("weibo_token","",a);Ext.util.Cookies.set("weibo_uid","",a);Ext.util.Cookies.set("weibo_name","",a);Ext.util.Cookies.set("weibo_image","",a)}else{if(this.website=="qq"){Ext.util.Cookies.set("qq_token","",a)}else{if(this.website==="youtube"){Ext.util.Cookies.set("youtube_token","",a);Ext.util.Cookies.set("youtube_token_create","",a);Ext.util.Cookies.set("youtube_token_expire","",a)}else{if(this.website=="flickr"){Ext.util.Cookies.set("flickr_token","",a);Ext.util.Cookies.set("flickr_id","",a);Ext.util.Cookies.set("flickr_secret","",a)}}}}}}}},setFacebookUserPicture:function(b){var a="images/White/defalut_image.png";if(b){switch(this.website){case"facebook":a=String.format("https://graph.facebook.com/{0}/picture",b.uid);break;case"twitter":a=b.profile_image_url;break;case"picasa":case"weibo":case"qq":case"youtube":case"flickr":a=b.image;break}}this.fbPic.dom.src=a},updateFacebookUIInfo:function(a,b){if(!a){Ext.getCmp("btn_upload").disable();this.fbAuthorize.dom.innerHTML=_PST("photo","photo_fb_auth_allow_btn");this.fbAuthorizeUsername.dom.innerHTML="";this.fbAuthorize.addClass("facebook_login_option");if(this.website=="facebook"){this.mon(this.fbAuthorize,"click",this.onLoginFacebook,this)}else{if(this.website=="twitter"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_twitter_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginTwitter,this)}else{if(this.website=="picasa"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_picasa_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginPicasa,this)}else{if(this.website==="weibo"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_weibo_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginWeibo,this)}else{if(this.website=="qq"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_qq_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginQQ,this)}else{if(this.website=="youtube"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_youtube_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginYouTube,this)}else{if(this.website=="flickr"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_flickr_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginFlickr,this)}}}}}}}this.setFacebookUserPicture("");this.delToken.hide();this.fbAuthorize.show()}else{if(this.website=="facebook"){b.uid=Ext.util.Cookies.get("facebook_uid")}Ext.getCmp("btn_upload").enable();this.fbAuthorize.dom.innerHTML="";this.fbAuthorizeUsername.dom.innerHTML=b.name;this.fbAuthorize.removeClass("facebook_login_option");this.setFacebookUserPicture(b);this.delToken.show();this.initCombo();this.fbAuthorize.hide()}this.updateStatusImg.hide()},updateFacebookStatus:function(){var c="";var a="";var b="";var d="";Ext.getCmp("btn_upload").disable();this.fbAuthorize.hide();if(this.website=="facebook"){c=Ext.util.Cookies.get("facebook_token");b="fb_utils.php"}else{if(this.website=="twitter"){c=Ext.util.Cookies.get("twitter_token");a=Ext.util.Cookies.get("twitter_secret");b="twitter_utils.php"}else{if(this.website=="picasa"){c=Ext.util.Cookies.get("picasa_token");b="SocialNetwork/picasa.php"}else{if(this.website==="weibo"){c=Ext.util.Cookies.get("weibo_token")}else{if(this.website=="qq"){c=Ext.util.Cookies.get("qq_token");b="SocialNetwork/qq.php"}else{if(this.website==="youtube"){c=Ext.util.Cookies.get("youtube_token");b="SocialNetwork/youtube.php"}else{if(this.website==="flickr"){c=Ext.util.Cookies.get("flickr_token");a=Ext.util.Cookies.get("flickr_secret");d=Ext.util.Cookies.get("flickr_id");b="SocialNetwork/flickr.php"}}}}}}}if(!c){return this.updateFacebookUIInfo(false,null)}if(this.website==="weibo"){this.updateFacebookUIInfo(true,{name:Ext.util.Cookies.get("weibo_name"),image:Ext.util.Cookies.get("weibo_image")});return}this.updateStatusImg.show();Ext.Ajax.request({url:b,params:{action:"get_user",token:c,secret:a,id:d},method:"POST",success:function(f){var e=Ext.decode(f.responseText);this.updateFacebookUIInfo(!!e.user,e.user);this.updateStatusImg.hide()},scope:this})},onFacebookLogin:function(b,a){var c=String.format("https://graph.facebook.com/{0}/picture",a);this.fbPic.dom.src=c;Ext.util.Cookies.set("facebook_token",b);Ext.util.Cookies.set("facebook_uid",a);this.mun(this.fbAuthorize,"click",this.onLoginFacebook,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookStatus()},onLoginFacebook:function(){window._onFacebookLogin=this.onFacebookLogin.createDelegate(this);var b=window.location.href.indexOf("/",window.location.protocol.length+2);var f="_onFacebookLogin";var d="178470495541647";var c=String.format("http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/index.php?callback={0}&ps5host=",f);var e=window.location.href.slice(0,b)+encodeURI(encodeURI(PhotoStation.Util.getUrlPrefix()))+"/photo/admin/photo_setting.php&response_type=token";var a=String.format("http://www.facebook.com/dialog/oauth/?scope=user_photos&client_id={0}&display=popup&redirect_uri={1}{2}",d,encodeURIComponent(c),e);window.open(a,"mywindow","menubar=1,resizable=0,width=630,height=300, top=100, left=300")},onTwitterLogin:function(c,a,b,d){Ext.util.Cookies.set("twitter_token",c);Ext.util.Cookies.set("twitter_secret",a);Ext.util.Cookies.set("twitter_uid",b);Ext.util.Cookies.set("twitter_screen_name",d);this.mun(this.fbAuthorize,"click",this.onLoginTwitter,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookStatus()},onLoginTwitter:function(){window._onTwitterLogin=this.onTwitterLogin.createDelegate(this);var a="twitter_utils.php?action=start_twitter_oauth";window.open(a,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300")},onPicasaLogin:function(b,a,c){var d={name:a,image:c};this.fbPic.dom.src=c;Ext.util.Cookies.set("picasa_token",b);this.mun(this.fbAuthorize,"click",this.onLoginPicasa,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,d)},onLoginPicasa:function(){window._onPicasaLogin=this.onPicasaLogin.createDelegate(this);var b={response_type:"code",client_id:"924346750041-d18el4uen4ue7aegjn8s09ubkk2khihn.apps.googleusercontent.com",scope:"https://picasaweb.google.com/data/ https://www.googleapis.com/auth/userinfo.profile",redirect_uri:"https://update.synology.com/PhotoStation/OAuth2.0/getAccessToken.php",access_type:"offline",approval_prompt:"force",state:JSON.stringify({website:"picasa",ds:window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/picasa.php",callback:"_onPicasaLogin"})};var a=Ext.urlAppend("https://accounts.google.com/o/oauth2/auth",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=1,width=650,height=500, top=100, left=300")},onWeiboLogin:function(e,b,f,c,a){var h=new Date();h.setTime(h.getTime()+(parseInt(a,10)||0));var g={name:b,image:f};this.fbPic.dom.src=f;Ext.util.Cookies.set("weibo_token",e,h);Ext.util.Cookies.set("weibo_uid",c,h);Ext.util.Cookies.set("weibo_name",b,h);Ext.util.Cookies.set("weibo_image",f,h);this.mun(this.fbAuthorize,"click",this.onLoginWeibo,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,g)},onLoginWeibo:function(){window._onWeiboLogin=this.onWeiboLogin.createDelegate(this);var b={response_type:"code",client_id:"4201062284",redirect_uri:"https://update.synology.com/PhotoStation/OAuth2.0/getAccessToken.php",state:JSON.stringify({website:"weibo",ds:window.location.protocol+"//"+window.location.host+encodeURI(PhotoStation.Util.getUrlPrefix())+"/photo/SocialNetwork/weibo.php",callback:"_onWeiboLogin"})};var a=Ext.urlAppend("https://api.weibo.com/oauth2/authorize",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=0,width=650,height=450, top=100, left=300")},onQQLogin:function(b,a,c){var d={name:a,image:c};this.fbPic.dom.src=c;Ext.util.Cookies.set("qq_token",b);this.mun(this.fbAuthorize,"click",this.onLoginQQ,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,d)},onLoginQQ:function(){window._onQQLogin=this.onQQLogin.createDelegate(this);var a=Ext.urlAppend("https://graph.qq.com/oauth2.0/authorize?response_type=code",Ext.urlEncode({client_id:"100330727",scope:"get_user_info,list_album,upload_pic,add_album",state:"synology_photo_station",redirect_uri:"http://update.synology.com/PhotoStation/QQ/getQQAccessToken.php?ds="+window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/qq.php"}));window.open(a,"mywindow","menubar=1,resizable=0,width=650,height=450, top=100, left=300")},onYouTubeLogin:function(d,b,e,c,a){var f={name:b,image:e};Ext.util.Cookies.set("youtube_token",d);Ext.util.Cookies.set("youtube_token_create",c);Ext.util.Cookies.set("youtube_token_expire",a);this.mun(this.fbAuthorize,"click",this.onLoginYouTube,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,f)},onLoginYouTube:function(){window._onYouTubeLogin=this.onYouTubeLogin.createDelegate(this);var b={response_type:"code",client_id:"933144811772-hoerbk300n8qnt7obuotacv9gqub606f.apps.googleusercontent.com",scope:"https://www.googleapis.com/auth/youtube.upload https://www.googleapis.com/auth/userinfo.profile",redirect_uri:"https://update.synology.com/PhotoStation/OAuth2.0/getAccessToken.php",access_type:"offline",approval_prompt:"force",state:JSON.stringify({website:"google",ds:window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/youtube.php",callback:"_onYouTubeLogin"})};var a=Ext.urlAppend("https://accounts.google.com/o/oauth2/auth",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=1,width=650,height=500, top=100, left=300")},onFlickrLogin:function(c,b,d,a,f){var e={name:b,image:d};Ext.util.Cookies.set("flickr_token",c);Ext.util.Cookies.set("flickr_secret",a);Ext.util.Cookies.set("flickr_id",f);this.mun(this.fbAuthorize,"click",this.onLoginFlickr,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,e)},onLoginFlickr:function(){window._onFlickrLogin=this.onFlickrLogin.createDelegate(this);var b={action:"request_token",state:JSON.stringify({ds:window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/flickr.php",website:"flickr",callback:"_onFlickrLogin"})};if(PhotoStation.Util.getUrlPrefix()){b.state=JSON.stringify({ds:window.location.protocol+"//"+window.location.host+"/photo/SocialNetwork/flickr_redirect.php",website:"flickr",callback:"_onFlickrLogin",user:encodeURI(encodeURI(encodeURI(PhotoStation.Util.getUrlPrefix().toString().substring(2))))})}var a=Ext.urlAppend("http://update.synology.com/PhotoStation/OAuth1.0a/getAccessToken.php",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=1,width=1100,height=650, top=100, left=300")},close:function(){if(Main.getScope("PhotoStation.LightBox")){Main.getScope("PhotoStation.LightBox").disableHotKeys(false)}PhotoStation.SocialNetworkSingleUploader.superclass.close.call(this)},onBtnCancel:function(){if(this.isUploading){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_cancel_confirm"),function(a){if("yes"!=a){return}this.doCancelUpload()},this);return false}else{this.close()}},onBtnUpload:function(){if(this.website!=="twitter"&&this.website!=="weibo"&&this.website!=="youtube"&&this.website!=="flickr"&&this.combo.getValue()===""){this.combo.markInvalid(_JSLIBSTR("extlang","fieldblank"));return}if(this.website==="youtube"){if(!this.video_title.isValid()){return}}this.delToken.hide();this.label_status.addClass("loading-indicator");Ext.getCmp("btn_upload").disable();Ext.getCmp("title").disable();this.combo.setDisabled(true);var a={id:this.imgid,message:this.title_field.dom.value};if(this.website=="twitter"){this.doTwitterUpload(a)}else{if(this.website=="picasa"){this.doPicasaUpload(a)}else{if(this.website==="weibo"){this.doWeiboUpload(a)}else{if(this.website==="qq"){this.doQQUpload(a)}else{if(this.website==="youtube"){a.video_title=this.video_title.getValue();a.video_privacy=this.video_privacy.getValue();this.doYouTubeUpload(a)}else{if(this.website==="flickr"){this.doFlickrUpload(a)}else{this.doFBUpload(a)}}}}}}},doFBUpload:function(b){this.prog_id=Math.random();this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_fb");var a=Ext.util.Cookies.get("facebook_token");Ext.Ajax.request({url:"fb_utils.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,params:{action:"upload_new",prog_id:this.prog_id,id:this.imgid,photoList:b.id,message:b.message,type:this.getUploadType(),token:a,newAlbumName:this.combo.getValue(),albumId:this.combo.getValue()},success:function(c,d){var e=Ext.util.JSON.decode(c.responseText);if(!e.success){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_fb"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}this.isUploading=true;this.pollTask=new PhotoStation.UploadSocialNetwork.PollTask({url:"fb_utils.php",params:{action:"get_upload_status",prog_id:this.prog_id},handler:this.onPollTaskDone,scope:this});this.pollTask.startAutoRefresh(2,false)},failure:function(c,d){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_fb"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},doTwitterUpload:function(c){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_twitter");var b=Ext.util.Cookies.get("twitter_token");var a=Ext.util.Cookies.get("twitter_secret");Ext.Ajax.request({url:"twitter_utils.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,timeout:86400000,params:{action:"upload_new",id:this.imgid,token:b,secret:a,message:c.message},success:function(d,e){var f=Ext.util.JSON.decode(d.responseText);if(!f.success){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_twitter"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}this.onUploadFinishHandler()},failure:function(d,e){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_twitter"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},doPicasaUpload:function(b){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_picasa");var a=Ext.util.Cookies.get("picasa_token");Ext.Ajax.request({url:"SocialNetwork/picasa.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,timeout:86400000,params:{action:"upload_new",id:this.imgid,token:a,message:b.message,type:this.getUploadType(),newAlbumName:this.combo.getValue(),albumId:this.combo.getValue()},success:function(d,f){var g=Ext.util.JSON.decode(d.responseText);var e=_PST("photo","photo_str_upload_fail");if(!g.success){var c=g.error.split("\n")[1];if(c=="Insufficient storage quota"){e=_PST("photo","photo_str_picasa_no_space")}Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_picasa"),e,function(){this.close()},this);return}this.onUploadFinishHandler()},failure:function(c,d){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_picasa"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},doWeiboUpload:function(b){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_weibo");var a=Ext.util.Cookies.get("weibo_token");Ext.Ajax.request({url:"SocialNetwork/weibo.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,timeout:86400000,params:{action:"upload_new",id:this.imgid,token:a,client_id:"4201062284",message:b.message},success:function(c,d){var e=Ext.util.JSON.decode(c.responseText);if(!e.success){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_weibo"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}this.onUploadFinishHandler()},failure:function(c,d){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_weibo"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},doQQUpload:function(b){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_weibo");var a=Ext.util.Cookies.get("qq_token");Ext.Ajax.request({url:"SocialNetwork/qq.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,params:{action:"upload",id:this.id,token:a,message:b.message,type:this.getUploadType(),albumId:this.combo.getValue()},success:function(c,d){var e=Ext.util.JSON.decode(c.responseText);if(!e.success){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_qq"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}this.onUploadFinishHandler()},failure:function(c,d){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_qq"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},doYouTubeUpload:function(d){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_youtube");var a=Ext.util.Cookies.get("youtube_token");var c=Ext.util.Cookies.get("youtube_token_create");var b=Ext.util.Cookies.get("youtube_token_expire");this.prog_id=Math.random();this.isUploading=true;Ext.Ajax.request({url:"SocialNetwork/youtube.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,timeout:86400000,params:{action:"upload",id:d.id,token:a,token_create:c,token_expire:b,title:d.video_title,privacy:d.video_privacy,message:d.message,prog_id:this.prog_id},success:function(f,h){this.pollTask.stopAutoRefresh();this.isUploading=false;var i=null;try{i=Ext.util.JSON.decode(f.responseText)}catch(j){i={success:false}}if(i.success){if(i.youtubeId===false){this.onUploadFinishHandler();return}var g="http://www.youtube.com/watch?v="+i.youtubeId;var k=_PST("photo","photo_str_upload")+_PST("photo","photo_str_upload_success")+"
"+g+"";Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_youtube"),k,function(){this.close()},this);this.onUploadFinishHandler()}else{Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_youtube"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}},failure:function(e,f){this.pollTask.stopAutoRefresh();this.isUploading=false;Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_youtube"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}});this.pollTask=new PhotoStation.UploadSocialNetwork.PollTask({url:"SocialNetwork/youtube.php",params:{action:"get_upload_status",token:a,prog_id:this.prog_id},handler:this.updateUploadStatus,scope:this});this.pollTask.startAutoRefresh(5,false)},doFlickrUpload:function(c){this.label_status.dom.innerHTML=_PST("photo","photo_str_upload_to_flickr");var b=Ext.util.Cookies.get("flickr_token");var a=Ext.util.Cookies.get("flickr_secret");Ext.Ajax.request({url:"SocialNetwork/flickr.php",waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,timeout:86400000,params:{action:"upload",id:c.id,token:b,secret:a,description:c.message},success:function(d,f){var g=null;try{g=Ext.util.JSON.decode(d.responseText)}catch(h){g={success:false}}if(!g.success){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_flickr"),_PST("photo","photo_str_upload_fail"),function(){this.close()},this);return}this.onUploadFinishHandler()},failure:function(d,e){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_flickr"),_PST("photo","photo_str_error_unknown_desc"),function(){this.close()},this)}})},restoreUIState:function(){this.getEl().removeClass("facebook_upload_success");this.getEl().setOpacity(1);this.close()},onUploadFinishHandler:function(){if(!this.isVisible()){return}this.getEl().shadow.hide();if(Ext.isIE){this.getEl().shift({y:-200,opacity:0,easing:"easeOut",duration:1,callback:function(){this.restoreUIState()},scope:this})}else{this.getEl().addClass("facebook_upload_success");this.getEl().setOpacity(0);this.getEl().setTop(-200);this.restoreUIState.defer(1000,this)}},updateUploadStatus:function(b,a){if(!a.success||!this.isUploading){return}this.label_progress.setText(a.text)},onPollTaskDone:function(b,a){if(!b){return}if(a.success=="canceling"){this.pollTask.stopAutoRefresh();return}if(a.success=="finish"){this.isUploading=false;this.pollTask.stopAutoRefresh();this.onUploadFinishHandler();return}},doYouTubeCancel:function(){var a=Ext.util.Cookies.get("youtube_token");this.setStatusBusy();Ext.Ajax.request({url:"SocialNetwork/youtube.php",scope:this,params:{action:"cancel_upload",token:a,prog_id:this.prog_id},success:function(b,c){this.isUploading=false;this.clearStatusBusy();this.close()},failure:function(b,c){this.clearStatusBusy();Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_youtube"),_PST("photo","photo_str_error_unknown_desc"))}})},doCancelUpload:function(){if(false===this.isUploading){return}if(this.website==="youtube"){return this.doYouTubeCancel()}Ext.Ajax.request({url:"fb_utils.php",scope:this,params:{action:"cancel_upload",prog_id:this.prog_id},success:function(a,b){this.isUploading=false;this.close()},failure:function(a,b){Ext.MessageBox.alert(_PST("photo","photo_str_upload_to_fb"),_PST("photo","photo_str_error_unknown_desc"))}})},getItemConfig:function(){var b="fb_utils.php";if(this.website=="picasa"){b="SocialNetwork/picasa.php"}else{if(this.website==="qq"){b="SocialNetwork/qq.php"}}this.store=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:b,method:"POST"}),baseParams:{action:"get_album"},reader:new Ext.data.JsonReader({root:"albums"},[{name:"id"},{name:"name"},{name:"count"}]),fields:["id","name","count"]});this.privacy_store=new Ext.data.SimpleStore({fields:["name","value"],data:[[_PST("photo","photo_str_youtube_public"),"public"],[_PST("photo","photo_str_youtube_unlisted"),"unlisted"],[_PST("photo","photo_str_youtube_private"),"private"]]});var a=[{xtype:"panel",border:false,id:"facebookPanel",layout:"table",layoutConfig:{extraCls:"",tableAttrs:{style:{width:"100%",height:"100%"}},columns:2},items:[{id:"imgContainer",bodyCssClass:"facebook_upload_image_container_body",html:"",rowspan:9,cellCls:"facebook_image_container_cell"},{id:"facebook_login_info",html:"      ",colspan:1,border:false,cellCls:"facebook_form_container_cell"},{xtype:"label",text:_PST("photo","photo_str_video_title")+_PST("photo","photo_str_colon"),colspan:1,hidden:(this.website!=="youtube"),valign:"bottom",cellCls:"fb_form_container_label_cell"},{xtype:"textfield",text:"",id:"video_title",cls:"facebook_upload_field",hidden:(this.website!=="youtube"),colspan:1,width:300,maxLength:100,cellCls:"fb_form_container_textarea_cell"},{xtype:"label",text:(this.website!=="youtube")?_PST("photo","photo_str_photoalbum_title"):_PST("photo","photo_str_message"),colspan:1,valign:"bottom",cellCls:"fb_form_container_label_cell"},{xtype:"textarea",fieldLabel:"message",width:300,id:"title",cls:"facebook_upload_field",colspan:1,cellCls:"fb_form_container_textarea_cell"},{xtype:"label",text:_PST("photo","photo_str_upload_to_subfolder"),hidden:(this.website==="twitter"||this.website==="weibo"||this.website==="youtube"||this.website==="flickr"),colspan:1,valign:"bottom",cellCls:"fb_form_container_label_cell"},{synotype:"combo",id:"album_combo",store:this.store,displayField:"name",valueField:"id",emptyText:_PST("photo","photo_str_dir_name"),disabled:true,allowBlank:false,editable:true,mode:"remote",hidden:(this.website==="twitter"||this.website==="weibo"||this.website==="youtube"||this.website==="flickr"),width:320,colspan:1,border:false,cellCls:"fb_form_container_combo_cell"},{xtype:"label",text:_PST("photo","photo_str_youtube_privacy_setting")+_PST("photo","photo_str_colon"),colspan:1,hidden:(this.website!=="youtube"),valign:"bottom",cellCls:"fb_form_container_label_cell"},{xtype:"combo",id:"video_privacy",store:this.privacy_store,displayField:"name",valueField:"value",disabled:false,editable:false,allowBlank:false,mode:"local",hidden:(this.website!=="youtube"),width:300,colspan:1,triggerAction:"all",border:false,cellCls:"fb_form_container_combo_cell"}]}];return a},initCombo:function(){if(this.website==="twitter"||this.website==="weibo"||this.website==="youtube"||this.website==="flickr"){return}var a=Ext.util.Cookies.get("facebook_token");if(this.website=="picasa"){a=Ext.util.Cookies.get("picasa_token")}else{if(this.website==="qq"){a=Ext.util.Cookies.get("qq_token")}}if(!a){return this.updateFacebookUIInfo(false,null)}this.combo.store.baseParams.token=a;this.combo.setDisabled(false)},getUploadType:function(){var b=this.combo.getValue();var a=false;this.store.each(function(c){if(b==c.get("id")){a=true;return}},this);return(a)?"1":"0"}});Ext.ns("PhotoStation");PhotoStation.SocialNetworkUploadDialog=Ext.extend(PhotoStation.BaseWindow,{isUploading:false,isNeedToRedirect:false,website:"",constructor:function(b){this.website=b.website;var a={title:_PST("photo","photo_str_upload_to_fb"),width:612,height:270,resizable:false,modal:true,shadow:true,layout:"fit",border:false,items:[this.getFormConf()],buttons:[{text:_PST("photo","photo_str_btnOK"),id:"fbUploadBtnId",cls:"photo-blue-button photo-button",scope:this,handler:this.onClickOK},{text:_PST("photo","photo_str_btnCancel"),id:"fbUploadCloseBtnId",cls:"photo-grey-button photo-button",scope:this,handler:function(){this.close()}}]};Ext.apply(a,b);SYNO.LayoutConfig.fill(a);PhotoStation.SocialNetworkUploadDialog.superclass.constructor.call(this,a);this.formPanel=this.getComponent("uploadForm");this.on("show",function(){this.setTitle(_PST("photo","photo_str_upload_to_fb"));if(this.website=="picasa"){this.setTitle(_PST("photo","photo_str_upload_to_picasa"))}else{if(this.website==="flickr"){this.setTitle(_PST("photo","photo_str_upload_to_flickr"));this.setHeight(200)}}this.updateFacebookStatus()},this);this.on("afterlayout",function(){this.initUI()},this,{single:true});this.on("beforeclose",function(){if(this.isUploading){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_cancel_confirm"),function(c){if("yes"!=c){return}this.doCancelUpload()},this);return false}},this);this.on("close",function(){if(this.pollTask){this.pollTask.stopAutoRefresh()}if(this.isNeedToRedirect){PhotoStation.UploadSocialNetwork.setSelectList("",location.href.split(/[\?|\&]man=\d{1,}/g)[0])}},this)},getFormConf:function(){var b,c;if(this.website=="facebook"){b="fb_utils.php";c=Ext.util.Cookies.get("facebook_token")}else{b="SocialNetwork/picasa.php";c=Ext.util.Cookies.get("picasa_token")}this.store=new Ext.data.Store({proxy:new Ext.data.HttpProxy({url:b,method:"POST"}),baseParams:{action:"get_album",token:c},reader:new Ext.data.JsonReader({root:"albums"},[{name:"id"},{name:"name"},{name:"count"}]),fields:["id","name","count"]});var a={xtype:"form",itemId:"uploadForm",hideLabels:true,border:false,items:[{id:"facebook_login_info",html:"
    
",colspan:1,border:false,cellCls:"facebook_form_container_cell"},{xtype:"compositefield",hideLabel:true,hidden:this.website==="flickr",items:[{synotype:"radio",id:"typeRadioNewAlbum",boxLabel:_PST("photo","photo_str_create_new_album"),name:"type",inputValue:"0",checked:true,width:260},{synotype:"text",fieldLabel:_PST("photo","photo_str_search_name"),name:"new_album_name",width:290,maxlength:64,allowBlank:false}]},{xtype:"compositefield",hideLabel:true,hidden:this.website==="flickr",items:[{synotype:"radio",id:"typeRadioExisting",boxLabel:_PST("photo","photo_str_upload_to_existing_album"),name:"type",inputValue:"1",width:260},{synotype:"combo",name:"album_id",store:this.store,displayField:"name",valueField:"id",width:290,disabled:true,allowBlank:false,mode:"remote"}]},{synotype:"desc"},this.progreeBar=new Ext.ProgressBar({id:this.progressBarId=Ext.id(),text:_PST("photo","photo_str_init"),hidden:true})]};return a},initUI:function(){var a;a=new PhotoStation.EnableRadioGroup(this.formPanel.form,"type",{0:["new_album_name"],1:["album_id"]});this.fbPic=Ext.get("multi_upload_fb_pic");this.fbAuthorize=Ext.get("multi_upload_fb_authorize");this.fbAuthUser=Ext.get("multi_upload_fb_username");this.updateStatusImg=Ext.get("multi_upload_fb_loading_img");this.delToken=Ext.get("multi_upload_fb_deletetoken");this.delToken.dom.innerHTML=_PST("photo","photo_logout");this.delToken.hide();this.mon(this.delToken,"click",function(){Ext.MessageBox.confirm(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_confirm_logout"),function(b){if(b!="yes"){return}this.deleteToken()},this)},this);Ext.getCmp("typeRadioNewAlbum").disable();Ext.getCmp("typeRadioExisting").disable()},deleteToken:function(){var a=new Date();a.setDate(a.getDate()-365);if(this.website=="picasa"){Ext.util.Cookies.set("picasa_token","",a)}else{if(this.website==="flickr"){Ext.util.Cookies.set("flickr_token","",a);Ext.util.Cookies.set("flickr_id","",a);Ext.util.Cookies.set("flickr_secret","",a)}else{Ext.util.Cookies.set("facebook_token","",a);Ext.util.Cookies.set("facebook_uid","",a);var b="http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/logout_facebook.php";window.open(b,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300")}}this.updateFacebookUIInfo(false,null)},setFacebookUserPicture:function(b){var a="photo_new/images/Window/defalut_profile.png";if(b){if(this.website=="facebook"){a=b.uid?String.format("https://graph.facebook.com/{0}/picture",b.uid):"photo_new/images/Window/defalut_profile.png"}else{a=b.image}}this.fbPic.dom.src=a},updateFacebookStatus:function(){Ext.getCmp("fbUploadBtnId").disable();this.fbAuthorize.hide();var c=Ext.util.Cookies.get("facebook_token");var b="fb_utils.php";var a="";var d="";if(this.website=="picasa"){c=Ext.util.Cookies.get("picasa_token");b="SocialNetwork/picasa.php"}else{if(this.website==="flickr"){c=Ext.util.Cookies.get("flickr_token");a=Ext.util.Cookies.get("flickr_secret");d=Ext.util.Cookies.get("flickr_id");b="SocialNetwork/flickr.php"}}if(!c){return this.updateFacebookUIInfo(false,null)}this.updateStatusImg.setVisible(true);Ext.Ajax.request({url:b,params:{action:"get_user",token:c,secret:a,id:d},method:"POST",success:function(f){if(null===Ext.getCmp("fbUploadBtnId")){return}var e=Ext.decode(f.responseText);this.updateFacebookUIInfo(!!e.user,e.user);this.updateStatusImg.setVisible(false)},scope:this})},updateFacebookUIInfo:function(a,d){if(!a){this.fbAuthUser.dom.innerHTML="";this.fbAuthorize.addClass("facebook_login_option");if(this.website=="picasa"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_picasa_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginPicasa,this)}else{if(this.website==="flickr"){this.fbAuthorize.dom.innerHTML=_PST("photo","photo_str_flickr_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginFlickr,this)}else{this.fbAuthorize.dom.innerHTML=_PST("photo","photo_fb_auth_allow_btn");this.mon(this.fbAuthorize,"click",this.onLoginFacebook,this)}}this.setFacebookUserPicture("");this.fbAuthorize.show()}else{var b;this.fbAuthorize.removeClass("facebook_login_option");if(this.website=="facebook"){this.mun(this.fbAuthorize,"click",this.onLoginFacebook,this);b=Ext.util.Cookies.get("facebook_token");d.uid=Ext.util.Cookies.get("facebook_uid")}else{if(this.website==="flickr"){this.mun(this.fbAuthorize,"click",this.onLoginFlickr,this)}else{this.mun(this.fbAuthorize,"click",this.onLoginPicasa,this);b=Ext.util.Cookies.get("picasa_token")}}this.setFacebookUserPicture(d);var c=this.formPanel.form.findField("album_id");c.reset();c.lastQuery=null;this.store.baseParams.token=b;this.fbAuthorize.dom.innerHTML="";this.fbAuthUser.dom.innerHTML=d.name;this.fbAuthorize.hide()}Ext.getCmp("fbUploadBtnId").setDisabled(!a);Ext.getCmp("typeRadioNewAlbum").setDisabled(!a);Ext.getCmp("typeRadioExisting").setDisabled(!a);this.delToken.setVisible(a);this.updateStatusImg.setVisible(false)},onFacebookLogin:function(b,a){var c=String.format("https://graph.facebook.com/{0}/picture",a);this.fbPic.dom.src=c;Ext.util.Cookies.set("facebook_token",b);Ext.util.Cookies.set("facebook_uid",a);this.updateFacebookStatus()},onLoginFacebook:function(){window._onFacebookLogin=this.onFacebookLogin.createDelegate(this);var b=window.location.href.indexOf("/",window.location.protocol.length+2);var f="_onFacebookLogin";var d="178470495541647";var c=String.format("http://update.synology.com/PhotoStation/FaceBook/ps5/canvas/index.php?callback={0}&ps5host=",f);var e=window.location.href.slice(0,b)+PhotoStation.Util.getUrlPrefix()+"/photo/admin/photo_setting.php&response_type=token";var a=String.format("http://www.facebook.com/dialog/oauth/?scope=user_photos&client_id={0}&display=popup&redirect_uri={1}{2}",d,encodeURIComponent(c),e);window.open(a,"mywindow","menubar=1,resizable=0,width=630,height=250, top=100, left=300")},onPicasaLogin:function(b,a,c){var d={name:a,image:c};this.fbPic.dom.src=c;Ext.util.Cookies.set("picasa_token",b);this.mun(this.fbAuthorize,"click",this.onLoginPicasa,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,d)},onLoginPicasa:function(){window._onPicasaLogin=this.onPicasaLogin.createDelegate(this);var b={response_type:"code",client_id:"924346750041-d18el4uen4ue7aegjn8s09ubkk2khihn.apps.googleusercontent.com",scope:"https://picasaweb.google.com/data/ https://www.googleapis.com/auth/userinfo.profile",redirect_uri:"https://update.synology.com/PhotoStation/OAuth2.0/getAccessToken.php",access_type:"offline",approval_prompt:"force",state:JSON.stringify({website:"picasa",ds:window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/picasa.php",callback:"_onPicasaLogin"})};var a=Ext.urlAppend("https://accounts.google.com/o/oauth2/auth",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=1,width=650,height=500, top=100, left=300")},onFlickrLogin:function(c,b,d,a,f){var e={name:b,image:d};Ext.util.Cookies.set("flickr_token",c);Ext.util.Cookies.set("flickr_secret",a);Ext.util.Cookies.set("flickr_id",f);this.mun(this.fbAuthorize,"click",this.onLoginFlickr,this);this.fbAuthorize.removeClass("facebook_login_option");this.updateFacebookUIInfo(true,e)},onLoginFlickr:function(){window._onFlickrLogin=this.onFlickrLogin.createDelegate(this);var b={action:"request_token",state:JSON.stringify({ds:window.location.protocol+"//"+window.location.host+PhotoStation.Util.getUrlPrefix()+"/photo/SocialNetwork/flickr.php",website:"flickr",callback:"_onFlickrLogin"})};if(PhotoStation.Util.getUrlPrefix()){b.state=JSON.stringify({ds:window.location.protocol+"//"+window.location.host+"/photo/SocialNetwork/flickr_redirect.php",website:"flickr",callback:"_onFlickrLogin",user:PhotoStation.Util.getUrlPrefix().toString().substring(2)})}var a=Ext.urlAppend("http://update.synology.com/PhotoStation/OAuth1.0a/getAccessToken.php",Ext.urlEncode(b));window.open(a,"mywindow","menubar=1,resizable=1,width=1100,height=650, top=100, left=300")},onClickOK:function(){if(!this.formPanel.form.isValid()&&this.website!=="flickr"){return}var a=200;var e=_PST("photo","photo_str_fb_upload_amount_exceed");if(this.website=="picasa"){a=1000;e=_PST("photo","photo_str_picasa_upload_amount_exceed")}else{if(this.website==="flickr"){a=-1}}var c=this.formPanel.form.findField("type").getGroupValue();if("0"===c){if(a>0&&this.selectCount>a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),e,function(){this.doUpload()},this);return}this.doUpload();return}var b=this.formPanel.form.findField("album_id").getValue();var d=this.store.getById(b).get("count");if(a>0&&this.selectCount>(a-d)){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),e,function(){this.doUpload()},this)}else{this.doUpload()}},doUpload:function(){this.isUploading=true;this.delToken.hide();var b,c,a;if(this.website=="facebook"){b="fb_utils.php";c=Ext.util.Cookies.get("facebook_token")}else{if(this.website==="flickr"){b="SocialNetwork/flickr.php";c=Ext.util.Cookies.get("flickr_token");a=Ext.util.Cookies.get("flickr_secret")}else{b="SocialNetwork/picasa.php";c=Ext.util.Cookies.get("picasa_token")}}Ext.getCmp("fbUploadBtnId").disable();Ext.getCmp("typeRadioNewAlbum").disable();Ext.getCmp("typeRadioExisting").disable();this.formPanel.form.findField("new_album_name").disable();this.formPanel.form.findField("album_id").disable();this.setHeight(this.website==="flickr"?250:320);Ext.getCmp(this.progressBarId).setVisible(true);this.prog_id=Math.random();if(this.website==="flickr"||this.website==="picasa"){this.pollTask=new PhotoStation.UploadSocialNetwork.PollTask({url:b,params:{action:"get_upload_status",prog_id:this.prog_id},handler:this.onPollTaskDone,scope:this});this.pollTask.startAutoRefresh(3,false);var d={action:"multi_upload",prog_id:this.prog_id,photoList:this.photoList,token:c};if(this.website==="flickr"){d.secret=a}else{if(this.website==="picasa"){d.type=this.formPanel.form.findField("type").getGroupValue();d.newAlbumName=this.formPanel.form.findField("new_album_name").getValue();d.albumId=this.formPanel.form.findField("album_id").getValue()}}Ext.Ajax.request({url:b,timeout:86400000,waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,params:d,success:function(f,g){var h;try{h=Ext.util.JSON.decode(f.responseText)}catch(i){h={success:false}}if(!h.success){this.pollTask.stopAutoRefresh()}},failure:function(e,f){this.pollTask.stopAutoRefresh()}});return}Ext.Ajax.request({url:b,waitTitle:_PST("photo","photo_str_ap_name_6"),waitMsg:_PST("photo","photo_str_plz_wait"),scope:this,params:{action:this.website=="facebook"?"upload_new":"multi_upload_new",prog_id:this.prog_id,albumName:this.albumName,photoList:this.photoList,type:this.formPanel.form.findField("type").getGroupValue(),newAlbumName:this.formPanel.form.findField("new_album_name").getValue(),albumId:this.formPanel.form.findField("album_id").getValue(),token:c},success:function(e,f){var g=Ext.util.JSON.decode(e.responseText);if(!g.success){var h=_PST("photo","photo_str_error_unknown_desc");if(g.msg){h=g.msg}Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),h);this.close();return}this.pollTask=new PhotoStation.UploadSocialNetwork.PollTask({url:b,params:{action:"get_upload_status",prog_id:this.prog_id,token:c},handler:this.onPollTaskDone,scope:this});this.pollTask.startAutoRefresh(2,false)},failure:function(e,f){this.isUploading=false;Ext.getCmp("fbUploadBtnId").enable();Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}})},onPollTaskDone:function(c,b){if(!c){return}if(b.success=="canceling"){this.progreeBar.updateProgress(1,_PST("photo","photo_str_canceling"));return}if(b.success=="finish"){this.isUploading=false;this.progreeBar.updateProgress(1,_PST("photo","photo_str_man_done"));this.pollTask.stopAutoRefresh();this.isNeedToRedirect=true;Ext.getCmp("fbUploadCloseBtnId").setText(_PST("photo","photo_str_btnClose"));if(b.message){var a=b.message.split("\n")[1];if(a=="Insufficient storage quota"){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_picasa_no_space"))}else{if(a=="Photo limit reached."){return}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}}}return}this.progreeBar.updateProgress(b.percent,b.name)},doCancelUpload:function(){this.progreeBar.updateProgress(1,_PST("photo","photo_str_canceling"));var a;if(this.website==="picasa"){a="SocialNetwork/picasa.php"}else{if(this.website==="flickr"){a="SocialNetwork/flickr.php"}else{a="fb_utils.php"}}Ext.Ajax.request({url:a,scope:this,params:{action:"cancel_upload",prog_id:this.prog_id},success:function(b,c){this.isUploading=false;this.close()},failure:function(b,c){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_error_unknown_desc"))}})}});PhotoStation.EnableRadioGroup=Ext.extend(Object,{constructor:function(e,d,a){this.form=e;this.members=a;var g=PhotoStation.UploadSocialNetwork.getRadioGroup(e,d);for(var c=0;c120||d>120){var a=g>d?120:120*g/d;var f=guploadMaxSize){dragDropRecursiveUpload(b,j+1);return}var i=c+b[j].size+(b[j].lastModifiedDate).getTime();var h="photo";var m=PhotoStation.Util.getImgUrl("Window/image_default_photo_dark.png",true);if(PhotoStation.Upload.isVideo(c)){h="video";m=PhotoStation.Util.getImgUrl("Window/image_default_video_dark.png",true)}var k=Ext.get(i);if(n>showThumbMaxSize||"video"==h||!PhotoStation.Upload.isInExtList(c,PhotoStation.Upload.UploadThumbnailFormats)){k.dom.innerHTML="";var d;d=k.createChild({tag:"img",src:m,width:"50px",height:"50px",draggable:false});dragDropRecursiveUpload(b,j+1)}else{var a=window.URL||window.webkitURL,g=a.createObjectURL||false;if(g){var e=new Image();e.onload=function(){if(this.src===Ext.BLANK_IMAGE_URL){return}getThumbFromCanvas(this,i);this.src=Ext.BLANK_IMAGE_URL;dragDropRecursiveUpload(b,j+1)};e.onerror=function(o){if(this.src===Ext.BLANK_IMAGE_URL){return}k.dom.innerHTML="";k.createChild({tag:"img",src:m,width:"50px",height:"50px",draggable:false});this.src=Ext.BLANK_IMAGE_URL;dragDropRecursiveUpload(b,j+1)};e.src=a.createObjectURL(b[j])}else{var f=new FileReader();f.onloadend=(function(o,q,r,s){var p=new Image();p.onload=function(){if(this.src===Ext.BLANK_IMAGE_URL){return}getThumbFromCanvas(this,s);this.src=Ext.BLANK_IMAGE_URL;dragDropRecursiveUpload(b,j+1)};p.onerror=function(t){if(this.src===Ext.BLANK_IMAGE_URL){return}k.dom.innerHTML="";k.createChild({tag:"img",src:m,width:"50px",height:"50px",draggable:false});this.src=Ext.BLANK_IMAGE_URL;dragDropRecursiveUpload(b,j+1)};p.src=o.target.result}).createDelegate(this,[b[j],h,i],true);f.readAsDataURL(b[j])}}}PhotoStation.UploadWindow=Ext.extend(PhotoStation.BaseWindow,{uploadMode:null,selectedFileStore:null,html5xhr:null,uploadFormArray:[],flashFiles:[],flashUploadFileStatus:[],compactUploadFormArray:[],uploadFormMaxCount:10,uploading:false,constructor:function(b){this.init(b);var a={id:this.uploadDialogId=Ext.id(),width:1218,cls:"photo-window upload-photo-window",height:600,minWidth:600,minHeight:400,layout:"fit",padding:0,headerCfg:{},items:[this.getUploadBodyConf()],buttonAlign:"left",fbar:[{text:_PST("photo","photo_str_upload_add_more_files"),ctCls:"upload-window-footer",cls:"add-more-photo-text",scope:this,id:this.addMorePhotoId=Ext.id(),handler:this.onClickUploadFromPC,hidden:true},{id:this.reachMaxNumId=Ext.id(),xtype:"label",text:"",hidden:true,style:{"font-size":"13px",color:"rgb(80, 90, 100)"}},{id:this.uploadingId=Ext.id(),ctCls:"upload-progress-bar",xtype:"progress",width:180,height:10,hidden:true},{id:this.uploadTextId=Ext.id(),xtype:"label",hidden:true,margins:{left:8}},{id:this.dsmUploadingId=Ext.id(),xtype:"label",text:_PST("photo","photo_str_uploading"),hidden:true,style:{background:"url("+PhotoStation.Util.getImgUrl("loading.gif",false)+") no-repeat","padding-left":"20px","font-size":"13px","z-index":3}},"->",{text:_PST("photo","photo_str_btnOK"),id:this.submitButtonId=Ext.id(),scope:this,cls:"photo-blue-button photo-button",handler:function(){if(null===this.uploadMode||("flash"===this.uploadMode&&0===this.flashUploadFileStore.getCount())||("form"===this.uploadMode&&1===this.uploadFormArray.length)||(("dsm"===this.uploadMode||"html5"===this.uploadMode)&&0===this.selectedFileStore.getCount())){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_select_one"));return}this.setStatusUploading(true);this.uploadSubmit()}},{text:_PST("photo","photo_str_btnCancel"),scope:this,cls:"photo-grey-button photo-button",handler:function(){this.removeMultiPowUpload();this.isClose=true;if(this.html5xhr){this.html5xhr.abort()}this.close()}}],listeners:{scope:this,show:function(){this.cardPanel=Ext.getCmp(this.cardPanelId);if(this.hasHtml5){this.el.on("dragover",PhotoStation.UploadFileEvent.handleDragOver);this.el.on("drop",PhotoStation.UploadFileEvent.handleFileSelect);this.createHtmlFileInput()}else{if(this.hasFlash){this.flashDataView=this.getFlashDataView();this.createFlashObject()}else{this.addUploadForm()}}},close:function(){this.removeMultiPowUpload();if(this.dsmFileChooserDialog){this.dsmFileChooserDialog.close()}var c="traditionalUploadIframe_";for(var d=0;d> create multipowupload holder");var c=Main.getScope("PhotoStation.UploadWindow");c.maxNumUploadFile=c.getMaxNumUploadFile("flash");var e=Ext.getBody();e.createChild({tag:"div",id:"MultiPowUpload_Holder"});SYNO.Debug(">> createFlashObject");var d={wmode:"transparent"};var b={id:"MultiPowUpload",name:"MultiPowUpload",style:"position: absolute; cursor: pointer;",title:_PST("photo","photo_str_upload_pc_tip")};var a={serialNumber:"0081331142712262712114518817612928371410179",uploadUrl:"webapi/file.php","fileFilter.types":PhotoStation.Upload.getMultiPowUploadFileFormats(),overlayObjectId:"flashUploadBrowseBtntId",hiddenMode:"true",useExternalInterface:"true","fileFilter.maxCount":c.maxNumUploadFile,"thumbnail.autoRotate":true,"thumbnail.jpgQuality":"90"};SYNO.Debug(">> embedSWF");swfobject.embedSWF("ElementITMultiPowUpload.swf?v=3.3-2011.07.14","MultiPowUpload_Holder","160","40","10.0.0",null,a,d,b);this.setStatusBusy()},setStatusUploading:function(c){this.uploading=c;this.unselectAllItem();var b=c;var a=0;if("flash"===this.uploadMode){a=this.flashUploadFileStore.getCount()}else{if("html5"===this.uploadMode){a=this.selectedFileStore.getCount()}else{if("form"===this.uploadMode){a=this.compactUploadFormArray.length}else{if("dsm"===this.uploadMode){a=this.selectedFileStore.getCount()}}}}Ext.getCmp(this.thumbSelectionBarId).setVisible(false);Ext.getCmp(this.uploadingId).setVisible(b);Ext.getCmp(this.uploadTextId).setText(String.format(_PST("photo","photo_str_html5_upload_text_uploading"),1,a)).setVisible(b);Ext.getCmp(this.dsmUploadingId).setVisible(c&&!b);Ext.getCmp(this.addMorePhotoId).setVisible(!c).setDisabled(c);Ext.getCmp(this.submitButtonId).setDisabled(c);Ext.getCmp(this.albumNameButtonId).setDisabled(c);Ext.getCmp(this.duplicateComboId).setDisabled(c);if(null!==Ext.get("MultiPowUpload")){Ext.get("MultiPowUpload").setWidth(c?1:Ext.getCmp(this.addMorePhotoId).getWidth()+4);Ext.get("MultiPowUpload").setHeight(c?1:Ext.getCmp(this.addMorePhotoId).getHeight()+4)}if(c){Ext.getCmp(this.reachMaxNumId).setVisible(false)}else{this.checkReachMax()}},uploadSubmit:function(){if("flash"===this.uploadMode){this.flashFiles=MultiPowUpload.getFiles();this.uploadFromFlashSubmit(0)}else{if("dsm"===this.uploadMode){this.uploadFromDsmSubmit(0,0)}else{if("html5"===this.uploadMode){this.uploadFromPcSubmit(0,0,this.getUploadPath())}else{if("form"===this.uploadMode){this.uploadFromFormSubmit()}}}}},checkReachMax:function(){var b=this.getMaxNumUploadFile(this.uploadMode);var c=(this.selectedFileStore.getCount()>=b||(this.flashUploadFileStore&&this.flashUploadFileStore.getCount()>=b));var a=Ext.getCmp(this.addMorePhotoId);if("form"!==this.uploadMode){a.setVisible(!c)}Ext.getCmp(this.reachMaxNumId).setText(String.format(_PST("photo","photo_str_upload_max_num"),b)).setVisible(c);if("flash"===this.uploadMode){if(a.isVisible()){Ext.get("MultiPowUpload").setVisible(true).setSize(a.getWidth()+4,a.getHeight()+4).alignTo(a.el,"c-c")}else{Ext.get("MultiPowUpload").setVisible(false)}}},getSelectionBar:function(b,c){var a={xtype:"toolbar",id:b,hidden:true,cls:"selection-bar",layout:{type:"hbox",align:"center",pack:"center"},style:{"background-color":"#E2FCFF","border-radius":"7px",border:"solid 1px #00BFFF",height:"25px",width:"500px",position:"absolute",top:"50px",left:"350px","z-index":1},items:[{id:c,xtype:"label",cls:"select-item-text",text:_PST("photo","photo_str_num_items_selected"),style:{"padding-top":"4px","padding-left":"5px","padding-right":"10px"}},{xtype:"button",cls:"select-item-text",text:_PST("photo","photo_str_select_all"),scope:this,style:{"padding-left":"5px","padding-right":"5px"},handler:this.selectAllItem},"-",{xtype:"button",cls:"select-item-text",text:_PST("photo","photo_str_unselect_all"),scope:this,style:{"padding-left":"5px","padding-right":"5px"},handler:this.unselectAllItem},"-",{xtype:"button",cls:"select-item-text",text:_PST("photo","photo_str_upload_delete_selected_files"),scope:this,style:{"padding-left":"5px","padding-right":"5px"},handler:this.deleteSelectedItem}]};return a},getUploadBodyConf:function(){var a=new Ext.form.ComboBox({id:this.duplicateComboId=Ext.id(),cls:"file-exists-combobox",typeAhead:true,triggerAction:"all",lazyRender:true,editable:false,autoSelect:true,forceSelection:true,mode:"local",value:"rename",store:new Ext.data.ArrayStore({fields:["mode","text"],data:[["rename",_PST("photo","photo_str_upload_rename")],["ignore",_PST("photo","photo_str_upload_skip")],["overwrite",_PST("photo","photo_str_upload_overwrite")]]}),valueField:"mode",displayField:"text"});var b={xtype:"panel",layout:"card",cls:"upload-window",id:this.cardPanelId=Ext.id(),activeItem:4,tbar:{height:44,style:{"border-width":"0px",padding:"10px 20px 6px"},items:[{xtype:"label",style:"padding-right: 8px;",text:_PST("photo","photo_str_upload_to_subfolder")},{xtype:"button",id:this.albumNameButtonId=Ext.id(),cls:"photo-upload-album-name",text:Ext.util.Format.htmlEncode(PhotoStation.CurrentBrowse.getTitle()),menu:new PhotoStation.UploadFolderMenu()},"->",{xtype:"label",style:"padding-right: 8px;",text:_PST("photo","photo_str_upload_file_exist")+":"},a,""]},bodyStyle:{"border-width":"0px","border-top":"solid 2px #00BFFF"},items:[this.getFlashAreaConf(),this.getThumbConf(),this.getDropPhotosConf(),this.getFormConf(),this.getSourceConf()]};return b},setActivePanel:function(b){var a=[["ignore",_PST("photo","photo_str_upload_skip")],["overwrite",_PST("photo","photo_str_upload_overwrite")]];var d=[["rename",_PST("photo","photo_str_upload_rename")],["ignore",_PST("photo","photo_str_upload_skip")],["overwrite",_PST("photo","photo_str_upload_overwrite")]];var c=Ext.getCmp(this.duplicateComboId);c.store.loadData("form"===b||"dsm"===b?a:d);if("flash"===b){this.removeDragDropEvent();this.cardPanel.getLayout().setActiveItem(0)}else{if("html5"===b){this.removeMultiPowUpload();this.cardPanel.getLayout().setActiveItem(1)}else{if("dsm"===b){c.setValue("overwrite");this.removeMultiPowUpload();this.removeDragDropEvent();this.cardPanel.getLayout().setActiveItem(1)}else{if("drop"===b){this.cardPanel.getLayout().setActiveItem(2)}else{if("form"===b){c.setValue("overwrite");this.removeMultiPowUpload();this.removeDragDropEvent();this.cardPanel.getLayout().setActiveItem(3)}else{if("source"===b){this.cardPanel.getLayout().setActiveItem(4)}}}}}}},removeMultiPowUpload:function(){if(null!==Ext.get("MultiPowUpload")){Ext.get("MultiPowUpload").remove()}},removeDragDropEvent:function(){this.el.un("dragover",PhotoStation.UploadFileEvent.handleDragOver);this.el.un("drop",PhotoStation.UploadFileEvent.handleFileSelect)},getUploadPath:function(){return this.currentDir},getSourceConf:function(){var a={xtype:"panel",bodyStyle:{"border-width":"0px"},layout:{type:"vbox",align:"center",pack:"center"},items:[{xtype:"label",cls:"source-logo",html:''},{text:this.hasHtml5?_PST("photo","photo_str_html5_upload_drop_zone"):_PST("photo","photo_str_upload_from"),xtype:"label",cls:"source-main-text",hidden:false},{text:_PST("photo","photo_str_upload_other_upload"),xtype:"label",cls:"source-second-text",hidden:!this.hasHtml5},{id:"flashUploadBrowseBtntId",xtype:"button",text:_PST("photo","photo_str_upload_source_computer"),cls:"photo-blue-button photo-button photo-upload-button",tooltip:_PST("photo","photo_str_upload_pc_tip"),style:{"padding-bottom":"2px"},handler:this.onClickUploadFromPC,scope:this,autoWidth:false},{xtype:"button",text:_PST("photo","photo_str_upload_source_ds"),cls:"photo-blue-button photo-button photo-upload-button",tooltip:_PST("photo","photo_str_upload_ds_tip"),tooltipType:"title",handler:this.onClickUploadFromDS,hidden:(!PhotoStation.Info.use_dsm_account&&PhotoStation.Auth.reg_syno_user),scope:this,autoWidth:false},{id:this.uploadFromPCFormId=Ext.id(),xtype:"panel",border:false}]};return a},getThumbConf:function(){this.selectedFileStore=new Ext.data.Store({reader:new Ext.data.JsonReader({root:"upload_files",id:"item_id"},[{name:"item_id"},{name:"type"},{name:"source"},{name:"name"},{name:"cls"},{name:"url"},{name:"src"},{name:"thumb_width"},{name:"thumb_height"}])});var b=new Ext.XTemplate('','
','
','
','','
',"",'',"","",'',"","
","
",'
{shortName}
');b.compile();var a=function(c){c.shortName=Ext.util.Format.htmlEncode(c.name);c.display_info=Ext.util.Format.htmlEncode(c.name);var d=PhotoStation.Upload.getThumbWidthHeight(c.thumb_width,c.thumb_height,120,120);c.thumb_width=d.width;c.thumb_height=d.height;return c};this.dataView=new Ext.DataView({tpl:b,overClass:"x-view-over",itemSelector:"div.thumb-wrap",emptyText:'
'+_PST("photo","photo_str_search_no_entries")+"
",store:this.selectedFileStore,cls:"flashUploadDataView",multiSelect:true,prepareData:a.createDelegate(this),listeners:{scope:this,selectionchange:function(c,d){this.moveSelectionBar();if(0===d.length||this.uploading){Ext.getCmp(this.thumbSelectionBarId).setVisible(false)}else{Ext.getCmp(this.thumbSelectedTextId).setText(String.format(_PST("photo","photo_str_num_items_selected"),d.length));Ext.getCmp(this.thumbSelectionBarId).setVisible(true)}}}});return{region:"center",autoScroll:true,border:false,cls:"photo-upload-card-flash-panel",items:[this.getSelectionBar(this.thumbSelectionBarId=Ext.id(),this.thumbSelectedTextId=Ext.id()),this.dataView]}},getFlashDataView:function(){var c=function(d){d.shortName=Ext.util.Format.htmlEncode(d.file_name);return d};var a=new Ext.XTemplate('','
','
','
','','","
','',"
","
","
",'
',"{shortName}","
","
","
");a.compile();this.flashUploadFileStore=new Ext.data.Store({reader:new Ext.data.JsonReader({root:"upload_files",id:"id"},[{name:"file_name"},{name:"size"},{name:"id"}])});var b=new Ext.DataView({store:this.flashUploadFileStore,tpl:a,multiSelect:true,overClass:"x-view-over",itemSelector:"div.thumb-wrap",emptyText:'
'+_PST("photo","photo_str_search_no_entries")+"
",cls:"flashUploadDataView",renderTo:"flashUploadDataViewPanel",prepareData:c.createDelegate(this),listeners:{scope:this,selectionchange:function(d,e){this.moveSelectionBar();if(0===e.length||this.uploading){Ext.getCmp(this.flashSelectionBarId).setVisible(false)}else{Ext.getCmp(this.flashSelectedTextId).setText(String.format(_PST("photo","photo_str_num_items_selected"),e.length));Ext.getCmp(this.flashSelectionBarId).setVisible(true)}}}});return b},getFlashAreaConf:function(){return[{xtype:"panel",border:false,autoScroll:true,cls:"photo-upload-card-flash-panel",items:[this.getSelectionBar(this.flashSelectionBarId=Ext.id(),this.flashSelectedTextId=Ext.id()),{xtype:"panel",border:false,autoScroll:true,id:"flashUploadDataViewPanel"}]}]},getDropPhotosConf:function(){var a={xtype:"panel",layout:{type:"vbox",align:"center",pack:"center"},bodyStyle:{"background-color":"rgb(217, 246, 255)"},items:[{xtype:"label",text:_PST("photo","photo_str_html5_upload_drop_zone"),cls:"drop-zone-text"}]};return a},getFormConf:function(){return[{id:this.formPanelId=Ext.id(),xtype:"panel",border:false,style:{"margin-top":"50px"},items:[{id:this.traditionalUploadFormAreaId=Ext.id(),xtype:"panel",border:false}]}]},addUploadForm:function(){SYNO.Debug("Traditional add Upload Form");if(this.uploadFormArray.length>=this.uploadFormMaxCount){return}SYNO.Debug("Traditional new form panel");var e=null;var a=false;var c=new Ext.form.FormPanel(SYNO.LayoutConfig.fill({url:"./include/file_upload.php",fileUpload:true,border:false,hideLabels:true,renderTo:a?this.uploadFromPCFormId:this.traditionalUploadFormAreaId,style:a?{position:"absolute",top:"-72px",left:"235px",opacity:0}:"",items:[{xtype:"compositefield",width:800,items:[{synotype:"text",inputType:"file",id:e=Ext.id(),name:"Filedata",focusClass:"",width:a?155:530,height:30,autoCreate:{tag:"input",width:a?155:530,type:"file",size:"75",autocomplete:"off",onchange:"onFieldChange("+this.uploadFormArray.length+");"}},{width:20,synotype:"desc",id:"traditionalUploadField_"+this.uploadFormArray.length},{xtype:"hidden",name:"fileModificationDate",id:"traditionalUploadHidden_"+this.uploadFormArray.length}]}]}));this.firstFormId=c.id;var g="traditionalUploadIframe_"+this.uploadFormArray.length;var f=document.createElement("div");f.style.position="absolute";f.style.top="-1000px";document.body.appendChild(f);f.innerHTML='';var b=Ext.get(g);b.on("load",this.formUploadActionComplete.createDelegate(this,[g]));Main.getScope("PhotoStation.UploadWindow").uploadMode="form";if(a){var d=Ext.getCmp("flashUploadBrowseBtntId");Main.getScope("PhotoStation.UploadWindow").uploadMode="form";Ext.get(e).on("mousemove",function(h){d.addClass("x-btn-over")});Ext.get(e).on("mouseout",function(h){d.removeClass("x-btn-over")})}this.uploadFormArray.push(c.getForm())},formUploadActionComplete:function(d){var b=Ext.get(d).dom.contentWindow.document.body.innerHTML;if(b===""){return}var c=Ext.decode(b);var f=Ext.getDom("traditionalUploadFieldImg_"+this.currentSumitFormId);if(c===null){var e=this.compactUploadFormArray[this.currentSumitFormId].findField("Filedata").getValue();e=Ext.util.Format.htmlEncode(e).replace("C:\\fakepath\\","");e=e.replace("C:\\fake_path\\","");this.finalResult+=e;this.finalResult+=_PST("photo","photo_str_upload_fail")}else{this.finalResult+=c.name+": ";if(c.result=="success"){this.finalResult+=_PST("photo","photo_str_upload_success");f.src=PhotoStation.Util.getImgUrl("information.gif",false)}else{this.finalResult+=c.error;f.src=PhotoStation.Util.getImgUrl("exclamation.gif",false)}}this.finalResult+="
";var a=this.currentSumitFormId+1;if(athis.compactUploadFormArray.length){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_select_one"));this.clearStatusBusy();return}this.setStatusUploading(true);this.submitForm(0)},submitForm:function(b){this.currentSumitFormId=b;this.updateProgressBar(b+1,this.compactUploadFormArray.length);var c=this.getUploadPath();var a={ignore:0,overwrite:1}[Ext.getCmp(this.duplicateComboId).getValue()]||1;var d={overwrite:a,path:c,create_subfolder:""};var e="traditionalUploadIframe_"+b;this.addHiddenParam(this.compactUploadFormArray[b].el.dom,d);this.compactUploadFormArray[b].el.dom.target=e;this.compactUploadFormArray[b].el.dom.action=Ext.urlAppend("./include/file_upload.php");this.compactUploadFormArray[b].el.dom.submit()},addHiddenParam:function(c,d){var a;for(a in d){if(d.hasOwnProperty(a)){var b=document.createElement("input");b.type="hidden";b.name=a;b.value=d[a];c.appendChild(b)}}},onClickUploadFromPC:function(){if(this.hasHtml5){Ext.get(this.uploadFileInputId).dom.click();return}if(this.hasFlash){return}this.setActivePanel("form")},onClickUploadFromDS:function(){this.dsmFileChooserDialog=this.dsmFileChooserDialog||new PhotoStation.FileSelectorWindow({mode:"dsm",initMode:"dsm",dsmFileType:"photo,video"});this.dsmFileChooserDialog.on("choose",this.onChooserSelect,this);this.dsmFileChooserDialog.show()},onChooserSelect:function(a,c){if(!a){return}this.uploadMode="dsm";this.maxNumUploadFile=this.getMaxNumUploadFile("dsm");for(var b=0;b=this.maxNumUploadFile){break}this.selectedFileStore.add(new SelectedFileRecord({item_id:Ext.util.Format.htmlDecode(a[b].get("id")),name:Ext.util.Format.htmlDecode(a[b].get("name")),src:a[b].get("url"),url:a[b].get("url"),thumb_width:a[b].get("thumb_width"),thumb_height:a[b].get("thumb_height"),type:a[b].get("type"),source:"DSM",file_obj:null}))}this.setActivePanel("dsm");this.checkReachMax();Ext.getCmp(this.addMorePhotoId).setHandler((this.onClickUploadFromDS).createDelegate(this,[],true))},selectAllItem:function(){if("flash"===this.uploadMode){this.flashDataView.selectRange(0,this.flashUploadFileStore.getCount()-1)}else{this.dataView.selectRange(0,this.selectedFileStore.getCount()-1)}},unselectAllItem:function(){if("flash"===this.uploadMode){this.flashDataView.clearSelections()}else{this.dataView.clearSelections()}},deleteSelectedItem:function(){var c,b,a;if("flash"===this.uploadMode){c=this.flashDataView.getSelectedRecords();for(b=0;b=this.flashFiles.length){this.uploadComplete();return}var c=this.flashFiles[a].id;if(2==this.flashUploadFileStatus[c]){a=a+1;this.uploadFromFlashSubmit(a);return}this.updateProgressBar(a+1,this.flashFiles.length);if(0===this.flashUploadFileStatus[c]){this.flashUploadFileStatus[c]=1;changeStatusIcon(c,1)}var e=this.getUploadPath();var g=new Date(this.flashFiles[a].modificationDate).getTime();var b=this.flashFiles[a].name;var f=PhotoStation.Upload.isVideo(b)?"uploadvideo":"uploadphoto";var d=Ext.getCmp(this.duplicateComboId).getValue();MultiPowUpload.addPostField("api","SYNO.PhotoStation.File");MultiPowUpload.addPostField("method",f);MultiPowUpload.addPostField("version",1);MultiPowUpload.addPostField("dest_folder_path",e||"/");MultiPowUpload.addPostField("duplicate",d);MultiPowUpload.addPostField("filename",b);MultiPowUpload.addPostField("mtime",g);MultiPowUpload.addPostField("ctime",g);MultiPowUpload.addPostField("atime",g);MultiPowUpload.setParameter("postFields.file","original");MultiPowUpload.setParameter("sendOriginalImages","true");MultiPowUpload.setParameter("sendThumbnails","false");(function(){MultiPowUpload.uploadFiles([a])}).defer(50)},uploadFromDsmSubmit:function(b,a){if(b===this.selectedFileStore.getCount()){if(0!==a){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),String.format(_PST("photo","photo_str_html5_upload_text_fail"),a));this.close()}else{this.uploadComplete()}return}this.updateProgressBar(b+1,this.selectedFileStore.getCount());var d=this.getUploadPath();var c=this.selectedFileStore.getAt(b);var e={api:"SYNO.PhotoStation.DsmShare",method:"copy",version:1,id:c.get("item_id"),sharepath:d,duplicate:Ext.getCmp(this.duplicateComboId).getValue()};changeStatusIcon(c.get("item_id"),1);Ext.Ajax.request({url:PhotoStation.Util.getWebAPIUrl("dsm_share.php"),timeout:PhotoStation.Define.FILE_OPERATION_TIMEOUT,params:e,method:"POST",scope:this,failure:function(f,g){this.uploadFromDsmSubmit(b+1,a+1)},success:function(f,g){changeStatusIcon(c.get("item_id"),2);this.uploadFromDsmSubmit(b+1,a)}})},checkFileExist:function(d){SYNO.Debug("check file id exist");var a=this.selectedFileStore;for(var b=0;b=0){b.splice(c,1)}}return b},updateDragTaskRefreshTime:function(){this.dragTaskRefreshTime=new Date().getTime()},startDragTask:function(){this.dragTaskRunner=this.dragTaskRunner||new Ext.util.TaskRunner();this.dragTaskRunner.stopAll();this.dragTaskRunner.start({scope:this,interval:200,run:function(){if(500";f=f+String.format(_PST("photo","photo_str_upload_num_error_files"),this.failFileCount)}if(f!==""){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),f)}dragDropRecursiveUpload(this.filterFiles,0);e.clearStatusBusy();e.checkReachMax();return}var c=this.itemList[a];if(!c){PhotoStation.UploadFileEvent.traverseFileTree(a+1);return}if(c.isFile){c.file(function(i){var g=i.name;var h=i.size;if(e.maxNumUploadFile<=Main.getScope("PhotoStation.UploadWindow").selectedFileStore.getCount()){PhotoStation.UploadFileEvent.traverseFileTree(a+1);return}if(!PhotoStation.Upload.isUploadable(g)){if(auploadMaxSize){if(auploadMaxSize){h++;continue}}k=b[g].name+b[g].size+(b[g].lastModifiedDate).getTime();if(Main.getScope("PhotoStation.UploadWindow").checkFileExist(k)){continue}j="photo";n=PhotoStation.Util.getImgUrl("Window/loading_16_white.gif",true);if(PhotoStation.Upload.isVideo(c)){j="video";n=PhotoStation.Util.getImgUrl("White/image_default_video_dark.png",true)}Main.getScope("PhotoStation.UploadWindow").selectedFileStore.add(new SelectedFileRecord({name:c,src:n,url:n,thumb_width:"photo"==j?16:50,thumb_height:"photo"==j?16:50,item_id:k,source:"LOCAL",type:j,file_obj:b[g],cls:"default-images"}));m.push(b[g])}if(f){a=a+_PST("photo","photo_str_browser_cannot_upload_folder")}if(h){a=(""===a)?a:a+"
";a=a+String.format(_PST("photo","photo_str_upload_num_exceed_given_size"),h,uploadMaxGB+"GB")}if(d){a=(a==="")?a:a+"
";a=a+String.format(_PST("photo","photo_str_upload_num_error_files"),d)}if(a!==""){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),a)}dragDropRecursiveUpload(m,0);Main.getScope("PhotoStation.UploadWindow").clearStatusBusy();Main.getScope("PhotoStation.UploadWindow").checkReachMax();Ext.get(e.uploadFileInputId).dom.value=""},checkDirectory:function(b){if(Ext.isGecko){try{var c;if(!!(File&&File.prototype.slice)){c=b.slice(0,1)}else{if(!!(File&&File.prototype.webkitSlice)){c=b.webkitSlice(0,1)}else{if(!!(File&&File.prototype.mozSlice)){c=b.mozSlice(0,1)}else{return false}}}if(c&&window.FileReader){var a=new FileReader();a.readAsBinaryString(c)}}catch(d){return true}}return false}};function MultiPowUpload_onImageLoaded(c){SYNO.Debug("MultiPowUpload: on Image Loaded");Main.getScope("PhotoStation.UploadWindow").flashThumbCount++;var g=Main.getScope("PhotoStation.UploadWindow").flashThumbCount;var a=Main.getScope("PhotoStation.UploadWindow").flashTotalThumbCount;if(a===g){Main.getScope("PhotoStation.UploadWindow").clearStatusBusy()}var d=Ext.get("img_src_"+c.id);if(null!==d){return}if(c.imageWidth>8191||c.imageHeight>8191){var f=Ext.get("img_"+c.id);var b=PhotoStation.Util.getImgUrl("icon_raw.png",false);f.dom.innerHTML="";d=f.createChild({tag:"img",id:"img_src_"+c.id,src:b});return}var h=MultiPowUpload.getFileThumbnail(c.id);if(null===h){return}var e=Ext.get("img_"+c.id);e.dom.innerHTML="";d=e.createChild({tag:"img",id:"img_src_"+c.id,src:"data:image/png;base64,"+h});Ext.get("img_src_"+c.id).dom.onerror=onThumbnailError.createCallback("img_src_"+c.id)}function MultiPowUpload_onAddFiles(e){SYNO.Debug("MultiPowUpload: on add Files");var b=0;Main.getScope("PhotoStation.UploadWindow").uploadMode="flash";Main.getScope("PhotoStation.UploadWindow").setActivePanel("flash");Main.getScope("PhotoStation.UploadWindow").flashThumbCount=0;Main.getScope("PhotoStation.UploadWindow").flashTotalThumbCount=0;var f=Main.getScope("PhotoStation.UploadWindow").flashUploadFileStore;for(b=0;be||0>d||0>b){return}var a=c.substring(e,d);Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),String.format(_PST("photo","photo_str_upload_num_error_files"),a))}function MultiPowUpload_onFileComplete(a){SYNO.Debug("MultiPowUpload: on File Complete");Main.getScope("PhotoStation.UploadWindow").flashUploadFileStatus[a.id]=2;changeStatusIcon(a.id,2);Main.getScope("PhotoStation.UploadWindow").uploadFromFlashSubmit(0)}function onFieldChange(c){if(!onCheckFileSize(c)){return}var b=Main.getScope("PhotoStation.UploadWindow").uploadFromPCFormId;var a=Main.getScope("PhotoStation.UploadWindow").traditionalUploadFormAreaId;if(c===0){Ext.get(a).insertFirst(Ext.get(b));Ext.get(b).removeClass("x-box-item");Ext.get(Main.getScope("PhotoStation.UploadWindow").firstFormId).setStyle({opacity:1,position:"relative",top:"0px",left:"0px"});Main.getScope("PhotoStation.UploadWindow").setActivePanel("form")}Main.getScope("PhotoStation.UploadWindow").uploadFormArray[c].findField("Filedata").getEl().set({onchange:"onCheckFileSize("+c+")"});Main.getScope("PhotoStation.UploadWindow").addUploadForm()}onCheckFileSize=function(b){var a=-1;var c=Main.getScope("PhotoStation.UploadWindow").uploadFormArray[b].findField("Filedata").getEl().dom.files;if(c&&c[0]){a=c[0].fileSize;if(c[0].lastModifiedDate){Main.getScope("PhotoStation.UploadWindow").uploadFormArray[b].findField("fileModificationDate").setValue(c[0].lastModifiedDate.getTime())}}if(a>2147483648){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_size_error"));Main.getScope("PhotoStation.UploadWindow").uploadFormArray[b].findField("Filedata").setValue("");return false}return true};Ext.ns("PhotoStation");Ext.data.Connection.prototype.timeout=120000;Ext.form.BasicForm.prototype.timeout=120;(function(){var a=Ext.urlAppend;Ext.urlAppend=function(d,e,c){var b=Ext.urlDecode(e);c=typeof c!=="undefined"?c:true;if(c&&d.indexOf("SynoToken")===-1){b.SynoToken=decodeURIComponent(Ext.util.Cookies.get("PHPSESSID"))}return a(d,Ext.urlEncode(b))}})();Ext.Ajax.on("beforerequest",function(b,a){if(Ext.isEmpty(a.skipSynoToken)){if(Ext.isEmpty(a.headers)){a.headers={}}a.headers["X-SYNO-TOKEN"]=Ext.util.Cookies.get("PHPSESSID")}});Ext.util.Observable.observeClass(Ext.form.BasicForm);Ext.form.BasicForm.on("beforeaction",function(a,b){if(a.url){a.url=Ext.urlAppend(a.url)}});Ext.util.Observable.observeClass(Ext.data.Connection);Ext.data.Connection.on("beforerequest",function(a,b){if(Ext.isEmpty(b.skipSynoToken)){if(Ext.isEmpty(b.headers)){b.headers={}}b.headers["X-SYNO-TOKEN"]=Ext.util.Cookies.get("PHPSESSID")}});if(Ext.isIE&&!Ext.isIE10){window.attachEvent("onbeforeunload",function(){__flash__removeCallback=function(a,b){if(a){a[b]=null}}})}PhotoStation.Util={initDebug:function(){log=SYNO.Debug},fixExtInIE:function(){Ext.override(Ext.dd.DragTracker,{onMouseMove:function(f,d){var b=Ext.isIE&&(/msie 9/.test(navigator.userAgent.toLowerCase())||/msie 10/.test(navigator.userAgent.toLowerCase()))&&document.documentMode!=6;if(this.active&&Ext.isIE&&!b&&!f.browserEvent.button){f.preventDefault();this.onMouseUp(f);return}f.preventDefault();var c=f.getXY(),a=this.startXY;this.lastXY=c;if(!this.active){if(Math.abs(a[0]-c[0])>this.tolerance||Math.abs(a[1]-c[1])>this.tolerance){this.triggerStart(f)}else{return}}this.fireEvent("mousemove",this,f);this.onDrag(f);this.fireEvent("drag",this,f)}})},isSmallScreen:function(){if(typeof this._isSmallScreen==="undefined"){this._isSmallScreen=Ext.isFunction(window.matchMedia)&&window.matchMedia("not all and (min-width: 600px) and (min-height: 450px)").matches}return this._isSmallScreen},isHandheldDeviceBrowser:function(){return(/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini|IEMobile|windows phone os 7|windows phone 8/i.test(navigator.userAgent))},getMobileType:function(){var b=navigator.userAgent,a="none";if(b.match(/iPad|iPhone|iPod/i)!==null){a="ios"}else{if(b.match(/Android/i)!==null){a="android"}else{if(b.match(/Windows NT 6.2/i)!==null&&b.match(/Touch/i)!==null){a="windows"}}}return a},overrideMask:function(){Ext.override(Ext.Element,{mask:function(b,h){var e="x-masked",i="x-masked-relative",f=Ext.Element.data;var k=this,d=k.dom,j=Ext.DomHelper,g="ext-el-mask-msg loading-mask",a,m;if(!/^body/i.test(d.tagName)&&k.getStyle("position")=="static"){k.addClass(i)}if((a=f(d,"maskMsg"))){a.remove()}if((a=f(d,"mask"))){a.remove()}m=j.append(d,{cls:"ext-el-mask"},true);f(d,"mask",m);k.addClass(e);m.setDisplayed(true);if(typeof b=="string"){var c=j.append(d,{cls:g,cn:{tag:"div"}},true);f(d,"maskMsg",c);c.dom.className=h?g+" "+h:g;c.dom.firstChild.innerHTML=b;c.setDisplayed(true);c.center(k)}if(Ext.isIE&&!(Ext.isIE7&&Ext.isStrict)&&k.getStyle("height")=="auto"){m.setSize(undefined,k.getHeight())}return m}})},initMCE:function(b,a,d,c){tinyMCE.init({selector:"#"+b,theme:"modern",height:d,language:PhotoStation.Util.tinyMCELanguageCode(),resize:false,plugins:["advlist autolink link image lists charmap print preview hr anchor","wordcount visualblocks visualchars code media nonbreaking","table contextmenu directionality template textcolor compat3x"],content_css:"tinymce/skins/lightgray/content.min.css",menubar:false,toolbar_items_size:"small",toolbar1:"fontselect fontsizeselect | bold italic underline strikethrough | forecolor backcolor | subscript superscript",toolbar2:"alignleft aligncenter alignright alignjustify | outdent indent | bullist numlist | link unlink | hr | table | image | removeformat | code | preview ",formats:{bold:{inline:"span",styles:{"font-weight":"bold"}},italic:{inline:"span",styles:{"font-style":"italic"}}},file_browser_callback:c,setup:function(e){e.on("init",a)}})},inArray:function(b,a){if(!Ext.isArray(a)||-1===a.indexOf(b)){return false}return true},getUrlPrefix:function(){return location.pathname.match(/\/~[^\/]+/)?location.pathname.match(/\/~[^\/]+/):""},getTemplateImgUrl:function(a){if("defaultsmart"===a.type){if(PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG===a.id){return PhotoStation.Util.getImgUrl("White/image_location_tag.png",true)}else{if(PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG===a.id){return PhotoStation.Util.getImgUrl("White/image_people_tag.png",true)}else{if(PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG===a.id){return PhotoStation.Util.getImgUrl("White/image_people_tag.png",true)}else{return PhotoStation.Util.getImgUrl("White/image_general_tag.png",true)}}}}var b="video"===a.type;if(0<=a.thumbnail_status.indexOf("default")){if("album"===a.type){if("password"===a.info.type){return PhotoStation.Util.getImgUrl("White/image_album_password.png",true)}else{return PhotoStation.Util.getImgUrl("White/image_album_empty.png",true)}}else{if("smart"===a.type){return PhotoStation.Util.getImgUrl("White/image_album_empty.png",true)}else{if("sharedalbum"===a.type){return PhotoStation.Util.getImgUrl("White/image_album_empty.png",true)}}}}else{if("broken"===a.thumbnail_status){return PhotoStation.Util.getImgUrl("White/"+(b?"image_default_video.png":"image_broken_file.png"),true)}else{if(""===a.thumbnail_status||(0>a.thumbnail_status.indexOf("small")&&0<=a.thumbnail_status.indexOf("disable"))){return PhotoStation.Util.getImgUrl("White/"+(b?"image_default_video.png":"image_default_photo.png"),true)}else{if(0>a.thumbnail_status.indexOf("small")&&0<=a.thumbnail_status.indexOf("preview")){return PhotoStation.Util.getThumbUrl(a,{size:"preview"})}}}}return PhotoStation.Util.getThumbUrl(a,{size:"small"})},getImgUrl:function(b,a){return(a?"/photo/photo_new/":"/photo/")+"images/"+b},getWebAPIUrl:function(a){return Ext.urlAppend(this.getUrlPrefix()+"/photo/webapi/"+a)},getThumbUrl:function(c,a){var b,d;d={api:"SYNO.PhotoStation.Thumb",method:"get",version:"1"};Ext.apply(d,a);d.id=c.id;if(c.info&&Ext.isDefined(c.info.rotate_version)){d.rotate_version=c.info.rotate_version}if(c.additional&&c.additional.thumb_size){b=c.additional.thumb_size;if(b.sig){d.thumb_sig=b.sig}if(d.size==="small"&&b.small&&b.small.mtime){d.mtime=b.small.mtime}if(d.size==="large"&&b.large&&b.large.mtime){d.mtime=b.large.mtime}}if(c.watermark&&c.watermark.hash){d.wh=c.watermark.hash;d.wt=c.watermark.mtime}return PhotoStation.Util.getWebAPIUrl(Ext.urlAppend("thumb.php",Ext.urlEncode(d)))},getThemeRequestFile:function(){return PhotoStation.Util.getUrlPrefix()+"/photo/include/synotheme.php"},getLogoImage:function(a){var b=a?Math.random():1;return PhotoStation.Util.getThemeRequestFile()+"?type=photo&action=logo&cv="+b},isTimeline:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;return a===Main.getScope("PhotoStation.TimelineView")},isMap:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;return a===Main.getScope("PhotoStation.MapView")},isSpecialView:function(){var a=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;return a===Main.getScope("PhotoStation.MapView")||a===Main.getScope("PhotoStation.TimelineView")},hasAlbumPriv:function(c,b){var d=PhotoStation;if(!d.Util.inArray(c,["browse","upload","manage"])){return false}var a=d.CurrentBrowse;return(a.isAlbum()&&a.getRecord().get("additional").album_permission[c])||(!b&&a.isAlbumCategory()&&d.Auth.permission[c])},hasSmartCategoryPriv:function(){var b=PhotoStation,a=b.CurrentBrowse;return a.isSmartCategory()&&b.Auth.is_admin},hasCategoryPriv:function(){var b=PhotoStation,a=b.CurrentBrowse;return a.isCategory()&&b.Auth.is_admin},disableSelect:function(){var a=function(d){if(d.getTarget(".selectabletext")){return true}if(d.getTarget("textarea")){return true}var c=d.getTarget("input"),b=(c&&c.type)?c.type.toLowerCase():"";if("text"!==b&&"textarea"!==b&&"password"!==b){return false}if(c.readOnly){return false}return true};if(Ext.isIE){Ext.getDoc().on("selectstart",function(b){if(!a(b)){b.stopEvent()}})}Ext.getDoc().on("keydown",function(b){if(b.ctrlKey&&b.A===b.getKey()&&!a(b)){b.stopEvent()}})},toMonthName:function(c){var b=parseInt(c,10);var a=new Array("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");var d=_JSLIBSTR("extlang",a[b]);return d},getSortOrder:function(){return Ext.util.Cookies.get("photo-sort-order")||PhotoStation.Info.sort_direction||"asc"},getSortType:function(){return Ext.util.Cookies.get("photo-sort-by")||"preference"},getTimelineSortOrder:function(){return Ext.util.Cookies.get("photo-timeline-sort-order")||"desc"},appendCurrentFilter:function(c){c=c||{};var a=PhotoStation.CurrentBrowse.getRecord();var b=(PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isSmartCategory());if(b){c.filter_album=null}else{if(a.get("type")==="album"){c.filter_album=a.get("id")}else{if(a.get("type")==="smart"){c.filter_smart=a.get("id")}else{if(a.get("type")==="tag"){c.filter_tag=a.get("id")}}}}if(PhotoStation.Util.isTimeline()){c.sort_direction=this.getTimelineSortOrder()}return c},getContainerLoadParams:function(){var c=Main.getScope("PhotoStation.ViewCard");var d=c.getLayout().activeItem;var a=PhotoStation.CurrentBrowse.getRecord();var g={};if(PhotoStation.CurrentBrowse.isSearchCategory()){Ext.apply(g,a.get("search_params"))}else{if(PhotoStation.CurrentBrowse.isCategory()){g.id=a.get("id")}else{if(PhotoStation.CurrentBrowse.isSmartCategory()){}else{if(PhotoStation.CurrentBrowse.isSmart()){g.filter_smart=a.get("id")}else{if(PhotoStation.CurrentBrowse.isDefaultSmart()){if(PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG===PhotoStation.CurrentBrowse.getId()){g.filter_tag="tag_unconfirm"}else{g.type=a.get("tag_type")}}else{if(PhotoStation.CurrentBrowse.isTag()){g.filter_tag=a.get("id")}else{if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()){}else{if(PhotoStation.CurrentBrowse.isSharedAlbum()){g.filter_shared_album=a.get("id")}else{g.id="";if(PhotoStation.Define.ALBUM_CATEGORY!==a.get("id")){g.id=a.get("id")}}}}}}}}}if((PhotoStation.CurrentBrowse.isAlbum()||PhotoStation.CurrentBrowse.isAlbumCategory()||PhotoStation.CurrentBrowse.isSmart()||PhotoStation.CurrentBrowse.isSmartCategory()||PhotoStation.CurrentBrowse.isDefaultSmart()||PhotoStation.CurrentBrowse.isTag()||PhotoStation.CurrentBrowse.isSharedAlbumCategory()||PhotoStation.CurrentBrowse.isSharedAlbum())&&(d===Main.getScope("PhotoStation.PhotowallView")||d===Main.getScope("PhotoStation.ThumbnailView"))){var b=Main.getScope("PhotoStation.SimplePathBar");var e=PhotoStation.Util.getSortOrder();var f=b?(b.sortType||PhotoStation.Util.getSortType()):PhotoStation.Util.getSortType();if("share_status"===f&&!PhotoStation.CurrentBrowse.isSharedAlbumCategory()){f="preference"}if(PhotoStation.CurrentBrowse.isSmartCategory()||PhotoStation.CurrentBrowse.isDefaultSmart()){g.sort_by="title";g.sort_direction=Ext.isEmpty(e)?PhotoStation.Info.folder_sort_direction:e}else{g.sort_by=Ext.isEmpty(f)?"preference":f;if((PhotoStation.CurrentBrowse.isSmart()||PhotoStation.CurrentBrowse.isTag())&&("preference"===g.sort_by)){g.sort_by=PhotoStation.Info.sort_by}g.sort_direction=Ext.isEmpty(e)?PhotoStation.Info.sort_direction:e}}return g},setIsHideContextmenu:function(a){var b=function(f){var c;var d=f||window.event;if(a===false){return true}if(d.target){c=d.target}else{if(d.srcElement){c=d.srcElement}}if(c.nodeType==3){c=c.parentNode}if(c.nodeName=="INPUT"){return true}else{return false}};if(a){document.oncontextmenu=b;if(document.addEventListener){document.addEventListener("contextmenu",b,false)}if(document.attachEvent){document.attachEvent("oncontextmenu",b)}}else{if(document.removeEventListener){document.removeEventListener("contextmenu",b,false)}if(document.detachEvent){document.detachEvent("oncontextmenu",b)}}},oldSynoindexDSMVersion:3734,isOldSynoindex:function(){return PhotoStation.Info.dsm_version'+_PST("photo","photo_login")+"")}else{if(PhotoStation.CurrentBrowse.isSmartCategory()){d="empty-album-content empty-smart-album-content";a='ps:onclick="clickCreateSmart"';f=_PST("photo","photo_str_create");h=_PST("photo","photo_str_empty_text_smart_album");e=_PST("photo","photo_str_guest_empty_text_smart_album")}else{if(PhotoStation.CurrentBrowse.isSmart()){d="empty-album-content empty-smart-album-content";a='ps:onclick="clickSetting"';f=_PST("photo","photo_str_edit_album_properties");h=_PST("photo","photo_str_empty_text_in_smart_album");e=_PST("photo","photo_str_guest_empty_text_smart_album")}else{if(PhotoStation.CurrentBrowse.isCategory()){d="empty-album-content empty-cat-album-content";a='ps:onclick="clickPinHere"';f=_PST("photo","photo_str_pin_here");h=_PST("photo","photo_str_empty_text_category");e=_PST("photo","photo_str_guest_empty_text_category")}else{if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()||PhotoStation.CurrentBrowse.isSharedAlbum()){d="empty-album-content empty-shared-album-content";a="";f="";h=_PST("photo","photo_str_empty_text_shared_album");e=_PST("photo","photo_str_guest_empty_text_shared_album ")}else{return""}}}}}if(PhotoStation.Auth.is_admin||PhotoStation.Util.hasAlbumPriv("upload")){b=String.format('{1}',a,f);c=String.format(h,b);g=String.format('
{2}
',d,a,c)}else{g=String.format('
{1}
',d,e)}return g},loadCssFile:function(a){var c=document.createElement("link");c.type="text/css";c.rel="stylesheet";c.href=a;var b=document.getElementsByTagName("head")[0];PhotoStation.Util.removeCssFile(a);b.appendChild(c);Ext.util.CSS.refreshCache()},removeCssFile:function(d){var a=document.getElementsByTagName("link"),c=new RegExp(d),b;for(b=a.length;b>=0;b--){if(a[b]&&a[b].getAttribute("href")!==null&&c.test(a[b].getAttribute("href"))){a[b].parentNode.removeChild(a[b])}}Ext.util.CSS.refreshCache()},reloadCssFile:function(d){var a=document.getElementsByTagName("link"),c=new RegExp(d),b;for(b=a.length;b>=0;b--){if(a[b]&&a[b].getAttribute("href")!==null&&c.test(a[b].getAttribute("href"))){a[b].href+="&"+(new Date()).getTime()}}Ext.util.CSS.refreshCache()},downloadFiles:function(a,e){var c,d,b="dlform";c=PhotoStation.Util.getDownloadHtml(b,Ext.urlAppend(a),e);d=PhotoStation.Util.getDownloadIframe(function(){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_common_error"))});PhotoStation.Util.submitDownload(d,c,b)},getDownloadIframe:function(a){var f="download_iframe",b=Ext.fly(f);if(b){b.removeAllListeners();b=b.dom;try{var d=Ext.isIE?b.contentWindow.document:(b.contentDocument||window.frames[b.id].document);d.open();d.close()}catch(c){a();Ext.destroy(Ext.get(f));return null}}else{b=Ext.DomHelper.append(document.body,{tag:"iframe",id:f,frameBorder:0,width:0,height:0,css:"display:none;visibility:hidden;height:1px;"});b.src=Ext.SSL_SECURE_URL}return b},getDownloadHtml:function(b,a,d){var e,c=[];Ext.iterate(d,function(f,g,h){c.push(String.format('',f,g))});e=new Ext.Template(["",'',"",'
',c.join(""),"
",""]);return e.apply({formName:b,url:a})},submitDownload:function(c,a,b){var d=Ext.isIE?c.contentWindow.document:(c.contentDocument||window.frames[c.id].document);d.open("text/html");d.write(a);d.close();d[b].submit()},checkAviaryEditor:function(){try{Ext.isEmpty(Aviary.Feather)}catch(a){return false}return true},checkGoogleMap:function(){try{Ext.isEmpty(google.maps.Map)}catch(a){return false}return !!PhotoStation.Util.googleMapLoaded},isFlashReservedPort:function(a){var b=[1,7,9,11,13,15,17,19,20,21,22,23,25,37,42,43,53,77,79,87,95,101,102,103,104,109,110,111,113,115,117,119,123,135,139,143,179,389,465,512,513,514,515,526,530,531,532,540,556,563,587,601,636,993,995,2049,4045,6000];if("string"===typeof(a)){a=parseInt(a,10)}return(-1!==b.indexOf(a))},isSupportFlash:function(a){return PhotoStation.Puny.getPunyHostname()==location.hostname&&!this.isFlashReservedPort(location.port)&&swfobject.hasFlashPlayerVersion("9.0.115")&&!(Ext.isSecure&&!Ext.isIE&&!a)},googleMapLoadCallback:function(){PhotoStation.Util.googleMapLoaded=true},loadGoogleMapScript:function(){PhotoStation.Util.loadExternalScript("https://maps.google.com/maps/api/js?sensor=false&libraries=places&callback=PhotoStation.Util.googleMapLoadCallback")},loadAviaryEditorScript:function(){PhotoStation.Util.loadExternalScript("https://dme0ih8comzn4.cloudfront.net/js/feather.js")},loadExternalScript:function(b){var a=document.createElement("script");a.type="text/javascript";a.src=b;document.body.appendChild(a)},showWaitMsg:function(a){Ext.MessageBox.show(Ext.apply({title:_PST("photo","photo_str_ap_name_6"),msg:_PST("photo","photo_str_common_processing"),buttons:{cancel:true},wait:true},a))},closeWaitMsg:function(){Ext.MessageBox.hide()},isRecHasManage:function(b){var a;if(!b||!b.data){return false}a=b.data;if(a.additional&&a.additional.album_permission){return !!a.additional.album_permission.manage}return false},isRecSmart:function(b){var a;if(!b||!b.data){return false}a=b.data;if(a.type&&a.type==="smart"){return true}return false},isRecSharedAlbum:function(b){var a;if(!b||!b.data){return false}a=b.data;if(a.type&&a.type==="sharedalbum"){return true}return false},getManualInsertCount:function(a){var d=[PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG,PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG,PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG,PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG],c=0,b,e;for(b=0;b<3;b++){e=a.getAt(b);if(e&&PhotoStation.Util.inArray(e.get("id"),d)){c++}}return c},isHideGPS:function(){return !PhotoStation.Auth.is_admin&&!PhotoStation.Util.hasAlbumPriv("manage")&&PhotoStation.Info.hide_gps_from_normal_user},launchFullScreen:function(a){if(a.requestFullscreen){a.requestFullscreen()}else{if(a.mozRequestFullScreen){a.mozRequestFullScreen()}else{if(a.webkitRequestFullscreen){a.webkitRequestFullscreen();document.onwebkitfullscreenchange=function(){if(null===document.webkitFullscreenElement){Main.el.alignTo(Ext.getBody(),"tl-tl")}}}else{if(a.msRequestFullscreen){a.msRequestFullscreen();document.onmsfullscreenchange=function(){if(null===document.msFullscreenElement){Ext.getBody().focus()}}}}}}},exitFullScreen:function(){if(document.exitFullscreen){document.exitFullscreen()}else{if(document.mozCancelFullScreen){document.mozCancelFullScreen()}else{if(document.webkitExitFullscreen){document.webkitCancelFullScreen()}else{if(document.msExitFullscreen){document.msExitFullscreen()}}}}},isFullScreen:function(){var a=window.navigator.standalone||(document.fullScreenElement&&document.fullScreenElement!==null)||(document.mozFullScreen||document.webkitIsFullScreen);return a},_GET:function(a){a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var c=new RegExp("[\\?&]"+a+"=([^&#]*)"),b=c.exec(location.search);return b===null?"":decodeURIComponent(b[1].replace(/\+/g," "))},isLeftPanelCollapsed:function(){var a=Ext.util.Cookies.get("left-panel-visibility");return a?("hide"===a?true:false):(true===PhotoStation.Info.collapse_left_panel?true:false)},isHideInformation:function(){var a=Ext.util.Cookies.get("photo-lightbox-fullscreen");return a?("true"===a?true:false):(true===PhotoStation.Info.hide_lightbox_information?true:false)},isShowSlideshowInfo:function(){var a=Ext.util.Cookies.get("slideshow-info")||"false";return"true"===a?true:false}};PhotoStation.Error=function(b,d){var a={406:_PST("photo","photo_login_noprivilege"),407:_PST("photo","photo_str_login_error"),408:_PST("photo","photo_str_login_account_disable"),409:_PST("photo","photo_str_error_guest"),410:_PST("photo","photo_str_max_tries"),416:_PST("photo","photo_str_password_error")};var c=a[b];if(c){return c}else{if(d){return d}else{return _PST("photo","photo_str_error_unknown_desc")}}};PhotoStation.Define={ABOUT_ME:"AboutMe",BLOG:"Blog",ALBUM_CATEGORY:"Albums",SMART_CATEGORY:"SmartAlbums",CATEGORY:"Category",SMART:"Smart",DEFAULT_SMART:"DefaultSmart",TAG:"Tag",SEARCH_CATEGORY:"Search",LOGIN:"Login",TIMELINE:"Timeline",DEFAULT_SMART_LOCATION_TAG:"defaultsmart_Location",DEFAULT_SMART_PEOPLE_TAG:"defaultsmart_People",DEFAULT_SMART_GENERAL_TAG:"defaultsmart_General",DEFAULT_SMART_UNCONFIRM_TAG:"defaultsmart_Unconfirm",GENERAL_SETTING:"GeneralSetting",PHOTO_SETTING:"PhotoSetting",SHARE_SETTING:"ShareSetting",BLOG_SETTING:"BlogSetting",USER_SETTING:"UserSetting",GROUP_SETTING:"GroupSetting",LOG_SETTING:"LogSetting",SHARED_ALBUM_CATEGORY:"SharedAlbums",SHARED_ALBUM:"SharedAlbum",DEFAULT_SHARE_SINGLE_ITEM:"sharedalbum_single",MAX_ITEM_LIMIT:250,FIRST_ITEM_LIMIT_PAGELESS:50,FILE_OPERATION_TIMEOUT:1800000,SOCIAL_NETWORK_URL_PREFIX:["http://www.facebook.com/sharer.php?u=","https://plus.google.com/share?url=","http://twitter.com/share?url=","http://www.plurk.com/?qualifier=shares&status=","http://service.weibo.com/share/share.php?url=","http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url="],ACL_STATUS_READY:"ready",ACL_STATUS_FINISH:"finish",ACL_STATUS_RUNNING:"running",ACL_STATUS_DISABLED:"disabled",FORCE_PAGING_MODE:(Ext.isIE6||Ext.isIE7||Ext.isIE8)};PhotoStation.DefaultData={};PhotoStation.DefaultData[PhotoStation.Define.ALBUM_CATEGORY]={id:PhotoStation.Define.ALBUM_CATEGORY,text:_PST("photo","photo_str_category_albums"),name:_PST("photo","photo_str_category_albums"),info:[]};PhotoStation.DefaultData[PhotoStation.Define.SMART_CATEGORY]={id:PhotoStation.Define.SMART_CATEGORY,name:_PST("photo","photo_str_category_smart_albums"),hidden:false};PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG]={id:PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG,type:"defaultsmart",name:_PST("photo","photo_str_location_tag"),tag_type:"geo"};PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG]={id:PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG,type:"defaultsmart",name:_PST("photo","photo_str_person_label"),tag_type:"people"};PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG]={id:PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG,type:"defaultsmart",name:_PST("photo","photo_str_general_tag"),tag_type:"desc"};PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG]={id:PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG,type:"defaultsmart",name:_PST("photo","photo_str_non_confirm_album")};PhotoStation.DefaultData[PhotoStation.Define.SEARCH_CATEGORY]={id:PhotoStation.Define.SEARCH_CATEGORY,type:"search",name:_PST("photo","photo_str_search")};PhotoStation.DefaultData[PhotoStation.Define.SHARED_ALBUM_CATEGORY]={id:PhotoStation.Define.SHARED_ALBUM_CATEGORY,name:_PST("photo","photo_str_shared_album"),hidden:false};PhotoStation.DefaultData[PhotoStation.Define.LOGIN]={id:PhotoStation.Define.LOGIN};PhotoStation.CurrentBrowse={record:null,setRecord:function(a){this.record=Ext.apply({},a)},getRecord:function(){return this.record},getId:function(){return this.record?this.record.get("id"):null},setId:function(a){this.getRecord().set("id",a);this.getRecord().commit()},getTitle:function(){var a="unknown";if(this.isAlbumCategory()||PhotoStation.CurrentBrowse.isSmartCategory()||this.isCategory()||PhotoStation.CurrentBrowse.isSmart()||this.isTag()||PhotoStation.CurrentBrowse.isSearchCategory()||PhotoStation.CurrentBrowse.isSharedAlbumCategory()||PhotoStation.CurrentBrowse.isSharedAlbum()){a=this.getRecord().get("name")}else{if(this.isAlbum()){a=this.getRecord().get("info").title}}return a},setTitle:function(a){if(this.isAlbumCategory()||this.isSmartCategory()||this.isCategory()||this.isSmart()||this.isSharedAlbum()){this.getRecord().set("name",a)}else{if(this.isAlbum()){this.getRecord().get("info").title=a}}this.getRecord().commit()},setDesc:function(a){if(this.isAlbum()){this.getRecord().get("info").description=a;this.getRecord().commit()}},setConversion:function(a){if(this.isAlbumCategory()||this.isAlbum()){this.getRecord().get("info").conversion=a}this.getRecord().commit()},setPublicShare:function(a){if(this.isSharedAlbum()){this.getRecord().set("share_status",a.share_status);if(this.getRecord().get("additional").public_share){this.getRecord().get("additional").public_share=a}}this.getRecord().commit()},getType:function(){return this.getRecord()?this.getRecord().get("type"):null},isAboutMe:function(){return !!Main.getScope("PhotoStation.AboutMeList").getSelectionCount()},isCategory:function(){return 0===this.getId().indexOf("category_")},isAlbumCategory:function(){return PhotoStation.Define.ALBUM_CATEGORY===this.getId()},isAlbum:function(){return"album"===this.getType()},isSmartCategory:function(){return PhotoStation.Define.SMART_CATEGORY===this.getId()},isSmart:function(){return"smart"===this.getType()},isDefaultSmart:function(){return"defaultsmart"===this.getType()},isTag:function(){return"tag"===this.getType()},isSearchCategory:function(){return PhotoStation.Define.SEARCH_CATEGORY===this.getId()},inSearch:function(){return 0===PhotoStation.HistoryManager.getToken().indexOf(PhotoStation.Define.SEARCH_CATEGORY)},inLogin:function(){return 0===PhotoStation.HistoryManager.getToken().indexOf(PhotoStation.Define.LOGIN)},isSharedAlbumCategory:function(){return PhotoStation.Define.SHARED_ALBUM_CATEGORY===this.getId()},isSharedAlbum:function(){return"sharedalbum"==this.getType()},isSingleItemSharedAlbum:function(){return PhotoStation.Define.DEFAULT_SHARE_SINGLE_ITEM===this.getId()}};PhotoStation.Upload={getThumbWidthHeight:function(d,b,e,c){var a=[];a.width=d;a.height=b;if(d>e&&b>c){if((b/c)<(d/e)){a.width=e;a.height=Math.floor(b*(e/d))}else{a.height=c;a.width=Math.floor(d*(c/b))}}else{if(b>c){a.height=c;a.width=Math.floor(d*(c/b))}else{if(d>e){a.width=e;a.height=Math.floor(b*(e/d))}}}return a},isUploadable:function(a){return PhotoStation.Upload.isInExtList(a,PhotoStation.Upload.getUploadFileFormats())},isVideo:function(a){return PhotoStation.Upload.isInExtList(a,PhotoStation.Upload.getUploadVideoFormats())},isInExtList:function(d,c){if(!d||!Ext.isArray(c)||c.length<1){return false}var b=d.lastIndexOf(".");if(-1===b||d.length<=b){return false}var a=d.substr(b+1,d.length).toLowerCase();if(-1===c.indexOf(a)){return false}return true},UploadThumbnailFormats:["jpg","jpeg","jpe","bmp","png"],MultiPowUploadFileFormats:"Image and Video Files - Max Size 2G|*.jpg:*.jpeg:*.jpe:*.bmp:*.gif:*.png:*.tif:*.tiff:*.arw:*.srf:*.sr2:*.dcr:*.k25:*.kdc:*.cr2:*crw:*.nef:*.mrw:*.ptx:*.pef:*.raf:*.3fr:*.erf:*.mef:*.mos:*.orf:*.rw2:*.dng:*.x3f:*.raw:*.asf:*.wmv:*.mpg:*.mpeg:*.mp4:*.mov:*.dat:*.avi:*.divx:*.xvid:*.flv:*.m4v:*.3gp:*.3g2:*.qt:*.m2ts:*.m2t:*.mts:*.JPG:*.JPEG:*.JPE:*.BMP:*.GIF:*.PNG:*.TIF:*.TIFF:*.ARW:*.SRF:*.SR2:*.DCR:*.K25:*.KDC:*.CR2:*CRW:*.NEF:*.MRW:*.PTX:*.PEF:*.RAF:*.3FR:*.ERF:*.MEF:*.MOS:*.ORF:*.RW2:*.DNG:*.X3F:*.RAW:*.ASF:*.WMV:*.MPG:*.MPGE:*.MP4:*.MOV:*.DAT:*.AVI:*.DIVX:*.XVID:*.FLV:*.M4V:*.3GP:*.3G2:*.QT:*.M2TS:*.M2T:*.MTS",getMultiPowUploadFileFormats:function(){var a=PhotoStation.Upload.MultiPowUploadFileFormats;if(!PhotoStation.Util.isOldSynoindex()){a+=":*.f4v:*.F4V"}return a},UploadFileFormats:["jpg","jpeg","jpe","bmp","png","tif","tiff","gif","arw","srf","sr2","dcr","k25","kdc","cr2","crw","nef","mrw","ptx","pef","raf","3fr","erf","mef","mos","orf","rw2","dng","x3f","raw","mpg","mpeg","avi","wmv","asf","mov","flv","3gp","3g2","mp4","m4v","qt","divx","xvid","dat","m2ts","m2t","mts"],getUploadFileFormats:function(){log(">> getUploadFileFormats");var a=Ext.apply([],PhotoStation.Upload.UploadFileFormats);if(!PhotoStation.Util.isOldSynoindex()){a.push("f4v")}log(a);return a},UploadVideoFormats:["mpg","mpeg","avi","wmv","asf","mov","flv","3gp","3g2","mp4","m4v","qt","divx","xvid","dat","m2ts","m2t","mts"],getUploadVideoFormats:function(){var a=Ext.apply([],PhotoStation.Upload.UploadVideoFormats);if(!PhotoStation.Util.isOldSynoindex()){a.push("f4v")}return a},UploadFlashThumbnailFormats:["jpg","jpeg","jpe","bmp","png"],isFolderFileNameValid:function(a){if(!a){return false}if("@eadir"==a.toLowerCase()){return false}if(a[0]=="."){return false}if(/[\:\/\\\?\|\*<>]/.test(a)){return false}return true},HTML5Utils:function(){var a=(!window.XMLHttpRequest)?{}:new XMLHttpRequest();return{HTML5Progress:!!(a.upload),HTML5SendBinary:!!(a.sendAsBinary||a.upload),HTML5ReadBinary:!!(window.FileReader||window.File&&window.File.prototype.getAsBinary),HTML5Slice:(!!(window.File&&(window.File.prototype.slice||window.File.prototype.mozSlice||window.File.prototype.webkitSlice))),isSupportHTML5Upload:function(){if(!window.FormData||!window.FileReader){return false}return true},isDragFile:function(d){try{if(Ext.isWebKit){var b=!(d.dataTransfer.types&&d.dataTransfer.types.indexOf("Files")==-1);if(!b&&Ext.isMac){b=(null===d.dataTransfer.types&&d.dataTransfer.files&&0===d.dataTransfer.files.length)}return b}else{if(Ext.isGecko){return d.dataTransfer.types.contains("application/x-moz-file")}else{if(Ext.isIE10){return d.dataTransfer.files&&d.dataTransfer.types&&d.dataTransfer.types.contains("Files")}}}}catch(c){}return false}}}};Ext.define("PhotoStation.TextMetrics",{statics:{shared:null,measure:function(a,d,e){var b=this,c=b.shared;if(!c){c=b.shared=new PhotoStation.TextMetrics(a,e)}c.bind(a);c.setFixedWidth(e||"auto");return c.getSize(d)},destroy:function(){var a=this;Ext.destroy(a.shared);a.shared=null}},constructor:function(a,d){var c=this,b=Ext.getBody().createChild({role:"presentation",cls:Ext.baseCSSPrefix+"textmetrics"});c.measure=b;if(a){c.bind(a)}b.position("absolute");b.setLeftTop(-1000,-1000);b.hide();if(d){b.setWidth(d)}},getSize:function(c){var b=this.measure,a;b.update(c);a=b.getSize();b.update("");return a},bind:function(a){var b=this;b.el=a;b.measure.setStyle(b.el.getStyles("font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing","white-space","word-break","word-wrap","text-overflow"))},setFixedWidth:function(a){this.measure.setWidth(a)},getWidth:function(a){this.measure.dom.style.width="auto";return this.getSize(a).width},getHeight:function(a){return this.getSize(a).height},destroy:function(){var a=this;a.measure.remove();delete a.el;delete a.measure}});Ext.ns("PhotoStation");jwplayer.key="ADrNpyYVQ13xVOfDuZpCXl4Bioq40D0Omx8S/CIM46w=";PhotoStation.MusicPlayer=Ext.extend(Ext.BoxComponent,{blankMP3:"/photo/photo_new/mp3/blank.mp3",lastMusicId:null,constructor:function(a){this.playerId=Ext.id();this.container=a.container;Main.addScope("PhotoStation.MusicPlayer",this);PhotoStation.VideoPlayer.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={cls:"music-player",autoEl:{html:'
'},renderTo:this.container.el,listeners:{scope:this,afterrender:function(){this.renderPlayer()}}};Ext.apply(a,b);return a},getMusicUrl:function(a){if(!a){return this.blankMP3}else{return PhotoStation.Util.getUrlPrefix()+"/photo/webapi/slideshow_music.php/1.mp3?api=SYNO.PhotoStation.SlideshowMusic&method=get&version=1&id="+a}},renderPlayer:function(){var a={file:this.getMusicUrl(),width:640,height:30,repeat:true,autostart:false,analytics:{enabled:false}};this.player=jwplayer(this.playerId).setup(a)},pause:function(){if("off"===this.lastMusicId||null===this.lastMusicId){return}if("PAUSED"!==this.player.getState()){this.player.pause(true)}},play:function(){if("off"===this.lastMusicId||null===this.lastMusicId){return}if("PLAYING"!==this.player.getState()){this.player.play()}},stop:function(){this.player.stop()},changeMusic:function(a){this.setMusic(a);this.play()},setMusic:function(b){this.lastMusicId=b;if("off"===b){this.player.stop();return}var a=this.getMusicUrl(b);this.player.load([{file:a}])},getLastMusicId:function(){return this.lastMusicId}});PhotoStation.VideoPlayer=Ext.extend(Ext.BoxComponent,{constructor:function(a){this.util=PhotoStation.VideoPlayer.Util;this.container=a.container;this.playerId=Ext.id();this.isPlay=false;this.shareLightbox=a.shareLightbox;this.public_share_id=a.public_share_id;this.addEvents("playerready","playing","pause","stop","notsupport");Main.addScope("PhotoStation.VideoPlayer",this);PhotoStation.VideoPlayer.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={autoEl:{html:'
'},renderTo:this.container.el};Ext.apply(a,b);return a},resizeVideoPlayer:function(){if(this.player){this.player.resize(this.container.getWidth()-4,this.container.getHeight()-46)}else{if(this.container){var a=this.container.getHeight()-46;this.el.setStyle({height:a+"px","line-height":a+"px"})}}},getVideoEl:function(){return Ext.get(this.el.select(".jwvideo").elements[0])},startPlay:function(a,b){this.record=a;this.quality=b;this.stopPlayer();this.renderPlayer(a,b);this.isPlay=true},stopPlayer:function(){if(Ext.isEmpty(this.player)){return}if(this.player){this.player.stop();if(this.player.isReady){this.player.remove()}this.player=null}this.isPlay=false},renderPlayer:function(c,f){var e="flv"===f.id?"":("&quality_id="+f.id);var b="flv"===f.container?"1.flv":"1.mp4";var d=Ext.urlAppend(PhotoStation.Util.getUrlPrefix()+"/photo/webapi/download.php/"+b+"?api=SYNO.PhotoStation.Download&method=getvideo&version=1&id="+c.get("id")+e);var a=Ext.urlAppend(PhotoStation.Util.getUrlPrefix()+"/photo/webapi/thumb.php?api=SYNO.PhotoStation.Thumb&method=get&version=1&id="+c.get("id")+"&size=large");if(typeof(this.public_share_id)!=="undefined"){d+="&public_share_id="+this.public_share_id;a+="&public_share_id="+this.public_share_id}this.renderWithFlashPlayer(d,a,f.container)},renderWithFlashPlayer:function(d,a,g){var f=this.getPlayMode(g,this.quality.profile_name);var k;try{k=parseInt(this.record.data.info.size,10)}catch(c){}if("flash"===f){d+="&move_moov=true"}if("flash"===f&&!this.detectFlash()){if(PhotoStation.Util.isHandheldDeviceBrowser()){Main.getScope("PhotoStation.VideoPlayer").fireEvent("notsupport")}else{this.update('
'+String.format(_PST("photo","photo_str_no_flash_player"),'',"")+"
")}}else{var i=this.container.getWidth()-4,e=this.container.getHeight()-46;var b={file:d,image:a,controls:true,autostart:true,width:i,height:e,primary:f,stretching:"uniform",skin:"/photo/jwplayer/skin/bekle.xml",analytics:{enabled:false},events:{onError:function(h){if(h.message!=="Error loading media: File could not be played"){return}if(Ext.isNumber(k)&&k>2147483648){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_upload_size_error"))}}}};var j=jwplayer(this.playerId).setup(b);j.onReady(function(){Main.getScope("PhotoStation.VideoPlayer").fireEvent("playerready",g);this.isReady=true});j.onPlay(function(){Main.getScope("PhotoStation.VideoPlayer").fireEvent("playing")});j.onPause(function(){Main.getScope("PhotoStation.VideoPlayer").fireEvent("pause");var h=document.getElementsByTagName("video")[0];h.addEventListener("webkitendfullscreen",function(){Main.getScope("PhotoStation.VideoPlayer").player.stop()})});j.onIdle(function(){Main.getScope("PhotoStation.VideoPlayer").fireEvent("stop");var h=document.getElementsByTagName("video")[0];h.removeEventListener("webkitendfullscreen")});j.onComplete(function(){Main.getScope("PhotoStation.VideoPlayer").isPlay=false;if(Main.getScope("PhotoStation.VideoPlayer").shareLightbox){Main.getScope("PhotoStation.ShareLightBox").slideshowPlay()}else{Main.getScope("PhotoStation.LightBox").slideshowPlay()}});this.player=j}},getPlayMode:function(a,b){var c="flash";if("flv"===a){c="flash"}else{if(Ext.isIE8){c="flash"}else{if((Ext.isIE||Ext.isIE11)&&("high"===b||("medium"===b)||("low"===b))){c="flash"}else{c="html5"}}}return c},detectFlash:function(){var b,d,a,c=navigator.plugins||[],f=["ShockwaveFlash.ShockwaveFlash","Shockwave","Flash"];if(Ext.isIE){try{if((new ActiveXObject(f[0]))){return true}}catch(g){}return false}for(b=0;bc.indexOf(d.profile_name)});return Ext.apply([],a)}};Ext.ns("PhotoStation");PhotoStation.LoadMoreBar=Ext.extend(Ext.Toolbar,{constructor:function(a){Main.addScope("PhotoStation.LoadMoreBar",this);PhotoStation.LoadMoreBar.superclass.constructor.call(this,this.fillConfig(a))},fillConfig:function(b){var a={buttonAlign:"center",height:30,hidden:true,items:[{icon:PhotoStation.Util.getImgUrl("White/loading_16.gif",true),text:_PST("photo","photo_str_loading")}],listeners:{hide:function(){this.ownerCt.doLayout()}}};return Ext.apply(a,b)}});PhotoStation.ViewCard=Ext.extend(Ext.Panel,{firstLoadMoreFinished:false,constructor:function(c){Main.addScope("PhotoStation.ViewCard",this);var d={type:"defaultsmart",additional:{thumb_size:{preview:{resolutionx:0,resolutiony:0},small:{resolutionx:0,resolutiony:0},large:{resolutionx:0,resolutiony:0}}}};var e=PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG],f=PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG],b=PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG],a=PhotoStation.DefaultData[PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG];this.defaultSmartRecs=[new Ext.data.Record(Ext.apply({},e,d),PhotoStation.Define.DEFAULT_SMART_LOCATION_TAG),new Ext.data.Record(Ext.apply({},f,d),PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG),new Ext.data.Record(Ext.apply({},b,d),PhotoStation.Define.DEFAULT_SMART_GENERAL_TAG)];this.unconfirmRec=new Ext.data.Record(Ext.apply({},a,d),PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG);this.createStores();PhotoStation.ViewCard.superclass.constructor.call(this,this.fillConfig(c));Main.getScope("PhotoStation.CenterPanel").on("rotate",this.browseRotateHandler,this);vc=this},fillConfig:function(b){var a={layout:"card",padding:"0px 5px 10px",border:false,bbar:new PhotoStation.LoadMoreBar(),items:[new PhotoStation.AboutMePanel(),new PhotoStation.ThumbnailView(),new PhotoStation.PhotowallView(),new PhotoStation.MapView(),new PhotoStation.TimelineView()],listeners:{afterrender:{fn:function(){var c=Ext.util.Cookies.get("photo-view-mode-thumb");if(!Ext.isEmpty(c)){var d=c.match(/(\d+)-(\d+)/);var e=Main.getScope("PhotoStation.StatusTopArea").viewmodeBtn.menu;e.getComponent("detail").menu.getComponent(d[0]).setChecked(true);e.getComponent("detail").setChecked(true);this.getLayout().setActiveItem(Main.getScope("PhotoStation.ThumbnailView"));Main.getScope("PhotoStation.ThumbnailView").doUpdateThumbWidth(parseInt(d[1],10)/parseInt(d[2],10))}else{this.getLayout().setActiveItem(Main.getScope("PhotoStation.PhotowallView"))}},scope:this,single:true},resize:{fn:function(c,h,f,e,g){var d=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;if(Main.getScope("PhotoStation.TimelineView")&&d!=Main.getScope("PhotoStation.TimelineView")){Main.getScope("PhotoStation.TimelineView").initialWidth=h-10}},buffer:1000}}};return Ext.apply(a,b)},switchTo:function(g){var e=Main.getScope("PhotoStation.StatusTopArea").viewmodeBtn.menu;e.getComponent("detail").menu.getComponent("16-9").setChecked(true);var d=false,a=false;Main.getScope("PhotoStation.StatusArea").setVisible("PhotoStation.AboutMePanel"!==g);if("PhotoStation.AboutMePanel"===g){Main.getScope("PhotoStation.AlbumDescBar").setVisible(false)}else{if("PhotoStation.ThumbnailView"===g){e.getComponent("detail").setChecked(true);d=true;a=true}else{if("PhotoStation.PhotowallView"===g){e.getComponent("photowall").setChecked(true);e.getComponent("detail").menu.getComponent("16-9").setChecked(false);d=true}else{if("PhotoStation.MapView"===g){e.getComponent("map").setChecked(true);e.getComponent("detail").menu.getComponent("16-9").setChecked(false);Main.getScope(g).setGpsData(false)}else{if("PhotoStation.TimelineView"===g){e.getComponent("timeline").setChecked(true);e.getComponent("detail").menu.getComponent("16-9").setChecked(false)}}}}}var f=Main.getScope("PhotoStation.CenterPanel").getPagingToolbar();f.setVisible(PhotoStation.Info.paging_use_bar&&d&&!f.inDisplayAll&&this.store.getTotalCount()>f.pageSize);Main.getScope("PhotoStation.CenterPanel").setDisplayPageVisible(f.inDisplayAll);Main.getScope("PhotoStation.StatusTopArea").slider.setVisible(a);var c=Main.getScope("PhotoStation.SelectAllWindow");if(c){c.hide()}var b=Main.getScope("PhotoStation.ViewCard").getLayout().activeItem;this.panelFrom=b;if(b===Main.getScope("PhotoStation.ThumbnailView")||b===Main.getScope("PhotoStation.PhotowallView")){b.clearAllSelections(true)}this.getLayout().setActiveItem(Main.getScope(g));Main.getScope("PhotoStation.CenterPanel").doLayout();Main.getScope("PhotoStation.CenterPanel").getTopToolbar().updateButtons();Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount()},createStores:function(){if(this.stores){return this.stores}this.stores={};var d={listeners:{beforeload:function(f,g){var h=f.activeRequest.read;if(h){Ext.Ajax.abort(h)}}}};var a={scope:this,beforeload:function(){this.mask(_PST("photo","photo_str_loading"),"loading-mask")},load:function(g,f,h){this.unmask();this.updateEmptyText();Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount()}};this.stores[PhotoStation.Define.ALBUM_CATEGORY]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy({url:PhotoStation.Util.getWebAPIUrl("album.php"),listeners:{beforeload:function(f,g){var h=f.activeRequest.read;if(h){Ext.Ajax.abort(h)}},exception:function(i,j,k,h,g,f){var n={};try{n=Ext.decode(g.responseText).error}catch(m){}if(0!==g.status){PhotoStation.HistoryManager.albumPermissionHandler(n,h.params.id)}}}}),baseParams:{api:"SYNO.PhotoStation.Album",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,recursive:false,type:"album,photo,video",additional:"album_permission,photo_exif,video_codec,video_quality,thumb_size,file_location"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail","thumbnail_status","info","additional"],listeners:a});var b=Ext.apply({},{load:function(){this.unmask();this.insertDefaultSmart();this.updateEmptyText();Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount()}},a);this.stores[PhotoStation.Define.SMART_CATEGORY]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("smart_album.php")},d)),baseParams:{api:"SYNO.PhotoStation.SmartAlbum",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,additional:"thumb_size"},paramNames:{start:"offset"},root:"data.smart_albums",idProperty:"id",totalProperty:"data.total",fields:["id","name","type","thumbnail_status","tag_type","additional"],listeners:b});this.stores[PhotoStation.Define.SMART]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("photo.php")},d)),baseParams:{api:"SYNO.PhotoStation.Photo",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,type:"photo,video",additional:"photo_exif,video_codec,video_quality,thumb_size"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"],listeners:a});var e=Ext.apply({},{load:function(f){this.unmask();this.insertUnconfirm();f.remove(f.getAt(f.findExact("name","")))}},a);this.stores[PhotoStation.Define.DEFAULT_SMART]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("tag.php")},d)),baseParams:{api:"SYNO.PhotoStation.Tag",method:"list",version:1,offset:0,thumbnail_status:true,limit:PhotoStation.Define.MAX_ITEM_LIMIT,additional:"info,thumb_size"},paramNames:{start:"offset"},root:"data.tags",idProperty:"id",totalProperty:"data.total",fields:["id","type","name","additional","thumbnail_status"],listeners:e});this.stores[PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("photo.php")},d)),baseParams:{api:"SYNO.PhotoStation.Photo",method:"list",version:1,offset:0,filter_tag:"tag_unconfirm",limit:PhotoStation.Define.MAX_ITEM_LIMIT,type:"photo",additional:"photo_exif,thumb_size"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"],listeners:a});this.stores[PhotoStation.Define.TAG]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("photo.php")},d)),baseParams:{api:"SYNO.PhotoStation.Photo",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,type:"photo,video",additional:"photo_exif,video_codec,video_quality,thumb_size"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"],listeners:a});this.stores[PhotoStation.Define.CATEGORY]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("category.php")},d)),baseParams:{api:"SYNO.PhotoStation.Category",method:"listitem",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,additional:"album_permission,thumb_size"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","name","thumbnail_status","info","additional"],listeners:a});this.stores[PhotoStation.Define.SEARCH_CATEGORY]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("album.php")},d)),baseParams:{api:"SYNO.PhotoStation.Album",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,recursive:true,type:"album,photo,video",additional:"album_permission,photo_exif,video_codec,video_quality,thumb_size,file_location"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"],listeners:a});var c=Ext.apply({},{load:function(g,f){if(f[0].id===PhotoStation.Define.DEFAULT_SHARE_SINGLE_ITEM){f[0].data.name=_PST("photo","photo_str_single_item_shared_album")}this.unmask();this.updateEmptyText();Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount()}},a);this.stores[PhotoStation.Define.SHARED_ALBUM_CATEGORY]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("shared_album.php")},d)),baseParams:{api:"SYNO.PhotoStation.SharedAlbum",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,additional:"thumb_size,public_share"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","name","thumbnail_status","share_status","additional"],listeners:c});this.stores[PhotoStation.Define.SHARED_ALBUM]=new Ext.data.JsonStore({proxy:new Ext.data.HttpProxy(Ext.apply({url:PhotoStation.Util.getWebAPIUrl("photo.php")},d)),baseParams:{api:"SYNO.PhotoStation.Photo",method:"list",version:1,offset:0,limit:PhotoStation.Define.MAX_ITEM_LIMIT,type:"photo,video",additional:"photo_exif,video_codec,video_quality,thumb_size"},paramNames:{start:"offset"},root:"data.items",idProperty:"id",totalProperty:"data.total",fields:["id","type","thumbnail_status","info","additional"],listeners:a});this.store=this.stores[PhotoStation.Define.ALBUM_CATEGORY];return this.stores},insertDefaultSmart:function(){if(PhotoStation.Info.paging_use_bar&&0!==this.store.lastOptions.params.offset){return}var b=PhotoStation.Info.virtual_tag,a=[];if(b.geo_tag){a.push(this.defaultSmartRecs[0])}if(b.people_tag){a.push(this.defaultSmartRecs[1])}if(b.desc_tag){a.push(this.defaultSmartRecs[2])}if(a.length){this.store.insert(0,a)}},insertUnconfirm:function(){if(PhotoStation.Info.paging_use_bar&&0!==this.store.lastOptions.params.offset){return}if(PhotoStation.Define.DEFAULT_SMART_PEOPLE_TAG===PhotoStation.CurrentBrowse.getId()){this.store.insert(0,[this.unconfirmRec])}},containerReLoad:function(b,c){var a=Main.getScope("PhotoStation.SimplePathBar");a.removePathItem(a.pathItemList.length-1);this.containerLoad(PhotoStation.CurrentBrowse.getRecord(),false,b,c)},pathContainerLoad:function(b){var a=Main.getScope("PhotoStation.SimplePathBar");a.setPath(b.slice(0,-1));this.containerLoad(b[b.length-1])},containerLoad:function(g,e,d,a){Main.getScope("PhotoStation.StatusTopArea").maskBars();Main.getScope("PhotoStation.CenterPanel").maskBars();var j=Main.getScope("PhotoStation.SelectAllWindow");if(j){j.showPrompt=true;j.hide()}PhotoStation.CurrentBrowse.setRecord(g);var c=Main.getScope("PhotoStation.ViewCard"),b=c.getLayout().activeItem;Main.getScope("PhotoStation.LoadMoreBar").hide();if(b===Main.getScope("PhotoStation.AboutMePanel")){c.switchTo("PhotoStation.PhotowallView");b=Main.getScope("PhotoStation.PhotowallView")}if(b!==Main.getScope("PhotoStation.MapView")){b.updateScrollbar(true)}if(!PhotoStation.Util.isSpecialView()){this.store.removeAll()}this.firstLoadMoreFinished=false;if(PhotoStation.CurrentBrowse.isSmartCategory()||PhotoStation.CurrentBrowse.isDefaultSmart()||PhotoStation.CurrentBrowse.isCategory()||PhotoStation.CurrentBrowse.isSearchCategory()||PhotoStation.CurrentBrowse.isSharedAlbumCategory()||PhotoStation.CurrentBrowse.isSharedAlbum()){if(PhotoStation.Util.isSpecialView()){c.switchTo("PhotoStation.PhotowallView");b=Main.getScope("PhotoStation.PhotowallView");Main.getScope("PhotoStation.StatusTopArea").viewmodeBtn.menu.items.get("photowall").setChecked(true)}}var f=Main.getScope("PhotoStation.CenterPanel").getPagingToolbar();f.setVisible(PhotoStation.Info.paging_use_bar&&!PhotoStation.Util.isSpecialView()&&!d);Main.getScope("PhotoStation.CenterPanel").setDisplayPageVisible(d);Main.getScope("PhotoStation.StatusTopArea").slider.setVisible(b===Main.getScope("PhotoStation.ThumbnailView"));Main.getScope("PhotoStation.AlbumDescBar").setDescText("");var h={params:PhotoStation.Util.getContainerLoadParams(),callback:this.containerLoadDone.createDelegate(this,[e])};if(d){f.inDisplayAll=true;h.params.limit=-1}else{f.inDisplayAll=false;if(Ext.isDefined(a)){h.params.offset=a}}if(b===Main.getScope("PhotoStation.ThumbnailView")||b===Main.getScope("PhotoStation.PhotowallView")){b.appending=false;b.more=true;b.clearAllSelections();b.emptyText="";if(!PhotoStation.Info.paging_use_bar){h.params.limit=PhotoStation.Define.FIRST_ITEM_LIMIT_PAGELESS}}if(PhotoStation.CurrentBrowse.isSearchCategory()){this.store=this.stores[PhotoStation.Define.SEARCH_CATEGORY]}else{if(PhotoStation.CurrentBrowse.isCategory()){this.store=this.stores[PhotoStation.Define.CATEGORY]}else{if(PhotoStation.CurrentBrowse.isSmartCategory()){this.store=this.stores[PhotoStation.Define.SMART_CATEGORY]}else{if(PhotoStation.CurrentBrowse.isSmart()){this.store=this.stores[PhotoStation.Define.SMART]}else{if(PhotoStation.CurrentBrowse.isDefaultSmart()){if(PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG===PhotoStation.CurrentBrowse.getId()){this.store=this.stores[PhotoStation.Define.DEFAULT_SMART_UNCONFIRM_TAG]}else{this.store=this.stores[PhotoStation.Define.DEFAULT_SMART]}}else{if(PhotoStation.CurrentBrowse.isTag()){this.store=this.stores[PhotoStation.Define.TAG]}else{if(PhotoStation.CurrentBrowse.isSharedAlbumCategory()){this.store=this.stores[PhotoStation.Define.SHARED_ALBUM_CATEGORY]}else{if(PhotoStation.CurrentBrowse.isSharedAlbum()){this.store=this.stores[PhotoStation.Define.SHARED_ALBUM]}else{this.store=this.stores[PhotoStation.Define.ALBUM_CATEGORY]}}}}}}}}if(PhotoStation.Util.isSpecialView()){b.onActive();this.containerLoadDone()}else{c.getLayout().activeItem.bindStore(this.store);if(PhotoStation.Info.paging_use_bar){f.bindStore(this.store)}this.store.load(h)}var i=Main.getScope("PhotoStation.PhotowallView").store2;if(i&&i.proxy.activeRequest.read&&this.store!=i){Ext.Ajax.abort(i.proxy.activeRequest.read)}i=Main.getScope("PhotoStation.ThumbnailView").store2;if(i&&i.proxy.activeRequest.read&&this.store!=i){Ext.Ajax.abort(i.proxy.activeRequest.read)}PhotoStation.Notify.hideNotify(true)},containerLoadDone:function(c){var a=Main.getScope("PhotoStation.SimplePathBar"),d;Main.getScope("PhotoStation.StatusTopArea").unMaskBars();Main.getScope("PhotoStation.CenterPanel").unMaskBars();if(c){a.cleanPathItems()}a.addPathItem(PhotoStation.CurrentBrowse.getRecord());var b=a.getPathItemString();Main.getScope("PhotoStation.LeftContent").updateSelector(b);var e=PhotoStation.CurrentBrowse.getRecord().get("fid");PhotoStation.CurrentBrowse.getRecord().set("fid",undefined);if(!e){PhotoStation.HistoryManager.add(b)}if(PhotoStation.CurrentBrowse.isAlbum()){this.getLayout().activeItem.setAlbumDesc(PhotoStation.CurrentBrowse.getRecord().get("info").description)}Main.getScope("PhotoStation.CenterPanel").getTopToolbar().updateButtons();if(PhotoStation.CurrentBrowse.isTag()||PhotoStation.CurrentBrowse.isSmart()||PhotoStation.CurrentBrowse.isSharedAlbum()){Main.getScope("PhotoStation.CenterPanel").getTopToolbar().setAlbumItemCount(this.store.getCount())}else{if(!PhotoStation.CurrentBrowse.isAlbum()){Main.getScope("PhotoStation.CenterPanel").getTopToolbar().updateSlideshowBtn()}}Main.getScope("PhotoStation.CenterPanel").getFooterToolbar().updateContainerItemCount();if(e){this.openSingleLightBox(e)}if(!PhotoStation.Util.isSpecialView()&&!PhotoStation.Info.paging_use_bar){d=this.store.getCount()-PhotoStation.Util.getManualInsertCount(this.store);if(this.store.getTotalCount()>d&&d<=PhotoStation.Define.FIRST_ITEM_LIMIT_PAGELESS){this.getLayout().activeItem.loadMore(undefined,true)}}Main.getScope("PhotoStation.CenterPanel").doLayout()},openSingleLightBox:function(f,c){var a=this.store.getById(f);if(a){var d=Main.getScope("PhotoStation.LightBox");if(!d){d=new PhotoStation.LightBox()}if(!d.lightBoxFilter(a)){d.hide();return}d.show(f,this.store,c);return}var e={api:"SYNO.PhotoStation.Photo",method:"getinfo",version:1,additional:"photo_exif,video_codec,video_quality",id:f};var b;b=new Ext.data.JsonStore({url:PhotoStation.Util.getWebAPIUrl("photo.php"),baseParams:e,root:"data",idProperty:"id",autoLoad:true,fields:["id","type","thumbnail_status","info","additional"],listeners:{scope:this,beforeload:function(){this.mask(_PST("photo","photo_str_loading"),"loading-mask")},load:function(h,g,i){this.unmask();var j;j=Main.getScope("PhotoStation.LightBox");if(!j){j=new PhotoStation.LightBox()}a=h.getAt(0);if(!j.lightBoxFilter(a)){j.hide();return}h.insert(1,this.store.getRange(0,this.store.getCount()-1));h.totalLength=this.store.getTotalCount();j.show(f,h,c)}}})},photoLoad:function(a,b){var d=Main.getScope("PhotoStation.LightBox");if(!d){d=new PhotoStation.LightBox()}if(!d.lightBoxFilter(a)){var c=PhotoStation.CurrentBrowse.record.get("info");if(c&&false===c.conversion){Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_format_cannot_playback"))}else{Ext.MessageBox.alert(_PST("photo","photo_str_ap_name_6"),_PST("photo","photo_str_format_cannot_playback_or_converting"))}d.hide();return}d.show(a.get("id"),b||Main.getScope("PhotoStation.ViewCard").store)},browseRotateHandler:function(a,b,c){Ext.each(b,function(d){var e;e=this.store.getById(d);if(!e){return}this.updateRotatedPhoto(e,c)},this)},updateRotatedPhoto:function(e,d){var a,c,b;c=e.json.info;if(!c){return}if(!e.json.additional||!e.json.additional.thumb_size||!e.json.additional.thumb_size.small){return}b=e.json.additional.thumb_size.small;if(d===90||d===270){a=b.resolutionx;b.resolutionx=b.resolutiony;b.resolutiony=a;c.rotate_version+=1}else{c.rotate_version+=2}c.rotated=(0===c.rotate_version%2)?false:true},updateEmptyText:function(){var a=Main.getScope("PhotoStation.ViewCard"),b=a.getLayout().activeItem;if(!PhotoStation.Util.isSpecialView()&&!PhotoStation.CurrentBrowse.isAboutMe()){b.emptyText=PhotoStation.Util.getDefaultEmptyText();b.refresh();this.addEmptyTextOnClickHandler()}},mask:function(b,a){this.getContentTarget().addClass("center-transparent-mask");this.getEl().mask(_PST("photo","photo_str_loading"),"loading-mask").addClass("transparent-mask")},unmask:function(){this.getContentTarget().removeClass("center-transparent-mask");this.getEl().unmask()},addEmptyTextOnClickHandler:function(){function a(c,b){function d(i){var h=i.getAttribute("ps:onclick");if(h){i.onclick=function(){Main.getScope("PhotoStation.CenterPanel")[h](b)}}}var f=document.querySelectorAll(c);for(var e=0,g=f.length;e