/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2013 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by all applicable intellectual property laws,
* including trade secret and or copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/

/*************************************************************************
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2014 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and are protected by all applicable intellectual property laws,
* including trade secret and or copyright laws.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/

/*************************************************************************
*
* ADOBE CONFIDENTIAL
* ___________________
*
*  Copyright 2013 Adobe Systems Incorporated
*  All Rights Reserved.
*
* NOTICE:  All information contained herein is, and remains
* the property of Adobe Systems Incorporated and its suppliers,
* if any.  The intellectual and technical concepts contained
* herein are proprietary to Adobe Systems Incorporated and its
* suppliers and may be covered by U.S. and Foreign Patents,
* patents in process, and are protected by trade secret or copyright law.
* Dissemination of this information or reproduction of this material
* is strictly forbidden unless prior written permission is obtained
* from Adobe Systems Incorporated.
**************************************************************************/

define("pdmplugins/my-computer/js/ac-my-computer",["plugins-common/ac-plugins"],function(e){var t=e.MyComputer;return t||(t=e.MyComputer={}),t.PLUGIN_ID||(t.PLUGIN_ID="my_computer"),t}),define("pdmplugins/my-computer/js/ops/op-factory",["core/ac-core-init","pdmplugins/my-computer/js/ac-my-computer"],function(e,t){t.OpFactory=e.Op.extend({create:function(e,i){var n=t[e];return n?new n(i):void LOG(0,"AcMyComputer.OpFactory.create: Unrecognized class: "+e)}})}),define("pdmplugins/my-computer/js/templates/mycomputer-folder-template",[],function(){return'<div class = "collection-item recentFolder theme-border theme-list-item-row theme-file-list-row-border" tabIndex="-1" aria-label="<%= folderName %> <%= folderPath %>" ><div class="folderImg"></div><div class="folderName theme-list-item-text theme-virgo-basic-text" ><%= folderName %></div><div class="folderPath theme-list-item-text theme-file-list-row-value" ><%= folderPath %></div></div>'}),define("pdmplugins/my-computer/js/templates/mycomputer-custom-dialog-template",[],function(){return'<div class = "recentFolder theme-list-item" tabIndex="0" aria-label="<%= folderName %> <%= folderPath %>" ><div class="folderImg"></div><div class="folderName theme-list-item-text"><%= folderName %></div><div class="folderPath theme-list-item-text"><%= folderPath %></div></div>'}),define("pdmplugins/my-computer/js/views/mycomputer-folder-view",["core/ac-core-init","pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/templates/mycomputer-folder-template","pdmplugins/my-computer/js/templates/mycomputer-custom-dialog-template","core/utils/view-util","core/utils/focus-util","core/utils/truncate","core/utils/css-util","core/views/plugin-content-view"],function(e,t,i,n,o,s,r){return t.FolderView=e.View.extend({events:{"click .folderImg":"_onClick","click .folderName":"_onClick","click .recentFolder":"_onClickVirgo","focusin .recentFolder":"_onFolderFocusInHC","focusout .recentFolder":"_onFolderFocusOutHC","click .folderPath":"_onClick","keydown .recentFolder":"_onKeyDown"},initialize:function(){e.View.prototype.initialize.call(this),this._template=_.template(this.options.isCustomSaveOpenDialogView?n:i),this.listenTo(this.model,"remove",this.teardown),this._shouldIgnoreClick=!1},render:function(){return 0===this.$el.children().length&&this.$el.html(this._template({folderName:this._getName(),folderPath:this._getPath()})),this._initWrappers(),o.setElementFontByLocale(this.$el,"div"),this},truncateToFit:function(){r.truncateElementText(this.$name),r.truncateElementText(this.$path),this.$name.attr("title",this._getName()),this.$path.attr("title",this._getPath())},teardown:function(){this.remove()},setFocus:function(){this.$(".recentFolder").focus()},_initWrappers:function(){this.$name=this.$(".folderName"),this.$path=this.$(".folderPath")},_onKeyDown:function(e){(13===e.which||32===e.which)&&(this.options.isCustomSaveOpenDialogView?this._onClick():this._onClickVirgo())},_getName:function(){var e=this.model.get("name");if(""===e){var t=this.model.get("diPath");if(t){var i=t.split("/");i.pop(),i&&i.pop&&(e=i.pop())}}return e},_getPath:function(){return this.model.get("path")},_onClick:function(){this.options.isCustomSaveOpenDialogView&&Backbone.Events.trigger(this.options.clickEvent,this.model)},_onClickVirgo:function(){if(!this.options.isCustomSaveOpenDialogView){if(this._shouldIgnoreClick)return;this._shouldIgnoreClick=!0,Backbone.Events.trigger(this.options.clickEvent,this.model),setTimeout(_.bind(function(){this._shouldIgnoreClick=!1},this),550)}},_onFolderFocusInHC:function(e){$(e.target)},_onFolderFocusOutHC:function(e){$(e.target)}}),t.FolderView}),define("pdmplugins/my-computer/js/nls/ui-strings",{root:!0,"xx-xx":!0,"ar-ae":!0,"ca-es":!0,"cs-cz":!0,"da-dk":!0,"de-de":!0,"en-ae":!0,"en-gb":!0,"en-il":!0,"es-es":!0,"eu-es":!0,"fi-fi":!0,"fr-fr":!0,"fr-ma":!0,"he-il":!0,"hr-hr":!0,"hu-hu":!0,"it-it":!0,"ja-jp":!0,"ko-kr":!0,"nb-no":!0,"nl-nl":!0,"pl-pl":!0,"pt-br":!0,"ro-ro":!0,"ru-ru":!0,"sk-sk":!0,"sl-si":!0,"sl-sl":!0,"sv-se":!0,"tr-tr":!0,"uk-ua":!0,"zh-cn":!0,"zh-tw":!0,"bg-bg":!0}),define("pdmplugins/my-computer/js/nls/root/ui-strings",{MY_COMPUTER:"Your computer",SELECT_FILES:"Choose Files from My Computer",NO_RECENT_FOLDERS_SELECT:"Click 'Browse' to open a file from your computer.",HEADING_RECENT_LOCATIONS:"Recent Locations",HEADING_SELECT_FROM_RECENT_FOLDER:"Select from Recent Folder...",HEADING_SELECT_FOLDER:"Save in Recent Folder...",BROWSE_BUTTON:"Browse",BROWSE_DIALOG_BUTTON:"Browse...",CHOOSE_A_DIFFERENT_FOLDER_BUTTON:"Choose a Different Folder...",BROWSE_FOLDER_TEXT:"Select a different folder",NO_RECENT_FOLDERS_SAVE_AS:"No Recent Folders",NO_FOLDERS_MYCOMPUTER_PROMPT:"There aren't any files here yet.",NO_FOLDERS_MYCOMPUTER_SUBPROMPT:"When you open files from your computer, you’ll see their folders here."}),define("pdmplugins/my-computer/js/views/mycomputer-folders-view",["core/ac-core-init","backbone","pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/views/mycomputer-folder-view","i18n!pdmplugins/my-computer/js/nls/ui-strings","core/utils/view-util","core/utils/css-util"],function(e,t,i,n,o,s,r){return i.FoldersView=e.View.extend({children:[],initialize:function(){e.View.prototype.initialize.call(this),this._addListeners(),this._addAppApiCallbacks(),this._addKeyEventListener(),this._addFocusEventListener()},render:function(){this.children=[];var e=this.options.appApi;return this._isCustomSaveOpenDialogView=!1,(e.saveAsApi.isRunningInFileSaveAs()||e.selectionApi.isRunningInFileSelection())&&(this._isCustomSaveOpenDialogView=!0),this._isCustomSaveOpenDialogView?this.$el.children(":not(.no-recentfolder-placeholder)").remove():this.$el.children().remove(),this._initWrappers(),_.each(this.collection.models,this._renderItem,this),this._isCustomSaveOpenDialogView||(this.collection.length>0?(this.$recentFolders.show(),this.$(".openBrowseButton").attr("aria-label",o.BROWSE_BUTTON)):this.$recentFolders.hide()),this._setTabbableItem(),this},_addListeners:function(){this.collection.on("change",this.render),this.collection.bind("reset",this.render,this),this.collection.bind("add",this._renderItem,this)},_addAppApiCallbacks:function(){this.options.appApi.windowApi.addWindowResizeCallback(this.updateChildViewSizes)},_removeListeners:function(){this.collection.off("change",this.render),this.collection.unbind("reset",this.render,this),this.collection.unbind("add",this._renderItem,this)},_renderItem:function(e){if(e){var t=_.extend({},this.options,{model:e}),i=new n({model:e,clickEvent:this.options.clickEvent,isCustomSaveOpenDialogView:this._isCustomSaveOpenDialogView});this.children.push(i),this.$el.append(i.render().el),i.truncateToFit(),t.appApi.saveAsApi.isRunningInFileSaveAs()&&1===this.children.length&&i.setFocus()}},teardown:function(){this&&this._removeListeners()},_initWrappers:function(){this.$recentFolders=this.$(".recentFolders")},_setTabbableItem:function(){var e=this.$(".recentFolder:focusable"),t=this.$(":tabbable");0===t.length&&e.attr("tabindex","0")},_addKeyEventListener:function(){this.options.appApi.keyApi.pushKeyHandler(this)},_removeKeyEventListener:function(){this.options.appApi.keyApi.popKeyHandler(this)},_getContainingRowOrRowGroup:function(e){return e.closest(".recentFolder")},_onFocusIn:function(e){var t,i,n,o=$(e.target);return t=this.$(".recentFolder"),i=this._getContainingRowOrRowGroup(o),n=t.index(i),this._lastActiveRowIndex===n&&this._consumeEvent(e),0===i.length?!0:(t.attr("tabindex",-1),i.hasClass("focused")||(i.addClass("focused").attr("tabindex",0),o.attr("tabindex",0)),this._lastActiveRowIndex!=t.index(i)&&(this._lastActiveRowIndex=t.index(i)),this._consumeEvent(e),this._scrollItemIntoView(i.parent()),this.$el.scrollLeft(0),!0)},_onFocusOut:function(e){var t,i=$(e.target);return t=this._getContainingRowOrRowGroup(i),t.removeClass("focused").attr("tabindex",-1),!0},_scrollItemIntoView:function(e){function t(e){i.stop(!0,!0),i.animate({scrollTop:e},250)}{var i,n,o,s,r,l;this.options.collectionsUiModel}e.length&&(i=this.$el,n=e.position().top,o=e.height(),s=i.height(),this._isMouseWheel||(0>n||n+o>s)&&(r=i.scrollTop(),l=n-(s-o)/2,t(Math.max(r+l,0))))},_getChildViewHeight:function(){var e=this.$el.children();return e.length>0?r.getFullHeight(e.eq(0)):void 0},_getChildViewWidth:function(){var e=this.$el.children();return e.length>0?r.getFullWidth(e.eq(0)):void 0},_onKeyDown:function(e){function t(e){o.stop(!0,!0),o.animate({scrollTop:e},250)}var i,n=$(e.target),o=this.$el,r=o[0],l=(this.options,e.which),c=o.height(),a=o.width(),p=o?o.scrollTop():0,h=this._getChildViewHeight(),d=this._getChildViewWidth(),u=0,m=(0===h?0:Math.floor(c/h),0===d?0:Math.floor(a/d),!1),_=this.$(".recentFolder"),g=this._getContainingRowOrRowGroup(n),f=_.first(),w=_.last(),y=o.find(":tabbable").first(),v=n.is(g),C=!g.is(n),F=(n.is("a[href], [role=link]"),_.index(g)),E=$.Event("click"),O=($.Event("dblclick"),s.descendantHasFocus(".recentFolders")),R=s.descendantHasFocus(o),b=!R&&O,T=g.hasClass("expanded"),S=!1;if(s.isElementHidden(o))return m;if(n.is(":focusable")&&!O)return m;switch(E.shiftKey=e.shiftKey,l){case 9:this._setTabbableItem(),b&&(i=y?y:f,S=!0);break;case 27:break;case 33:R?(i=_.eq(Math.max(0,F-u)),S=!0):(t(p-c),m=!0);break;case 34:R?(i=_.eq(Math.min(_.length-1,F+u)),S=!0):(t(p+c),m=!0);break;case 35:t(r.scrollHeight),m=!0,g.is(w)||(i=w,S=!0);break;case 36:t(0),m=!0,g.is(f)||(i=f,S=!0);break;case 38:R?(T&&C&&(i=s.getNextFocusableDescendant(_,!0)),i&&i.length||(C?i=g:v&&(F>0&&(i=_.eq(F-1),S=!0),i&&i.hasClass("expanded")&&(i=i.find(":focusable:last"))))):h&&!b&&(t(p-h),m=!0);break;case 40:R?(T&&(i=s.getNextFocusableDescendant(_)),i&&i.length||F<_.length-1&&(i=_.eq(F+1),S=!0)):h&&!b&&(t(p+h),m=!0)}return void 0!==i&&i.length>0&&(m=!0,i.focus()),m}}),i.FoldersView}),define("pdmplugins/my-computer/js/templates/mycomputer-empty-template",[],function(){return'<div id="folders-no-files-prompt" class="mycomputer-no-folders"><div class="mycomputer-empty-state-icon"></div><div class="mycomputer-empty-heading-prompt theme-virgo-text"><%= NO_FOLDERS_MYCOMPUTER_PROMPT %></div><div class="mycomputer-empty-sub-heading-prompt theme-file-list-row-value"><%= NO_FOLDERS_MYCOMPUTER_SUBPROMPT %></div></div>'}),define("pdmplugins/my-computer/js/views/mycomputer-empty-view",["core/ac-core-init","pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/templates/mycomputer-empty-template","i18n!pdmplugins/my-computer/js/nls/ui-strings","core/views/view"],function(e,t,i,n){return t.EmptyView=e.View.extend({events:{},initialize:function(){e.View.prototype.initialize.call(this),this._template=_.template(i),this._addModelEventListeners()},render:function(){return e.View.prototype.render.call(this),0===this.$el.children().length&&(this.$el.html(this._template({NO_FOLDERS_MYCOMPUTER_PROMPT:n.NO_FOLDERS_MYCOMPUTER_PROMPT,NO_FOLDERS_MYCOMPUTER_SUBPROMPT:n.NO_FOLDERS_MYCOMPUTER_SUBPROMPT})),this._initWrappers(),this.collection.length<=0?(this.$noFoldersMyComputerPrompt.show(),this.$browserButton.attr("aria-label",n.NO_FOLDERS_MYCOMPUTER_PROMPT+" "+n.NO_FOLDERS_MYCOMPUTER_SUBPROMPT+" "+n.BROWSE_BUTTON),this._createMinWidthCSSClass()):this.$noFoldersMyComputerPrompt.hide()),$(".page-main-container").addClass("myComputerEmptyViewContainer"),this},_initWrappers:function(){this.$noFoldersMyComputerPrompt=this.$("#folders-no-files-prompt"),this.$browserButton=this.$(".openBrowseButton")},_createMinWidthCSSClass:function(){var e=document.createElement("style");e.type="text/css",e.innerHTML=".myComputerEmptyViewContainer { min-width: "+this.$(".mycomputer-empty-sub-heading-prompt").outerWidth()+"px; }",document.getElementsByTagName("head")[0].appendChild(e)},_addModelEventListeners:function(){this.listenTo(this.collection,"change",this._onShowEmptyChange),this.listenTo(this.collection,"reset",this._onShowEmptyChange)},_onShowEmptyChange:function(){this.collection.length<=0?(this.render(),this.$noFoldersMyComputerPrompt.show()):this.$noFoldersMyComputerPrompt.hide()}}),t.EmptyView}),define("pdmplugins/my-computer/js/templates/mycomputer-template",[],function(){return'<div class="recentFoldersHeading recentFoldersHeadingText ui-theme theme-container theme-page-header theme-border theme-file-list-row-border" id = "recentFoldersHeading"><%= heading %></div><div class="recentFolders"></div><div class="emptyView"></div><button type="button" tabindex="0" class="theme-button button browseButton openBrowseButton control-button navigable theme-button-label" role="button" ><%- buttonLabel %></button>'}),define("pdmplugins/my-computer/js/views/plugin-view",["core/ac-core-init","pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/views/mycomputer-folders-view","pdmplugins/my-computer/js/views/mycomputer-empty-view","pdmplugins/my-computer/js/templates/mycomputer-template","core/utils/view-util","i18n!pdmplugins/my-computer/js/nls/ui-strings","core/utils/focus-util","core/utils/sc-analytics","core/views/plugin-content-view"],function(e,t,i,n,o,s,r,l,c){return t.PluginView=e.PluginContentView.extend({events:{"click .openBrowseButton":"_OnBrowseBtnClick","keydown .openBrowseButton":"_onKeyDown"},initialize:function(){e.PluginContentView.prototype.initialize.call(this),Backbone.Events.on(this._getRecentFolderClickEvent(),this._onRecentFolderClick,this),this._template=_.template(o)},teardown:function(){Backbone.Events.off(this._getRecentFolderClickEvent()),this.$el.empty()},render:function(){var t=r.MY_COMPUTER,i=r.NO_RECENT_FOLDERS_SELECT,n=r.BROWSE_BUTTON,o=this.options.appApi;return this._isCustomSaveOpenDialogView=!1,e.PluginContentView.prototype.render.call(this),o.saveAsApi.isRunningInFileSaveAs()?(t=r.HEADING_SELECT_FOLDER,i=r.NO_RECENT_FOLDERS_SAVE_AS,n=r.CHOOSE_A_DIFFERENT_FOLDER_BUTTON,this._isCustomSaveOpenDialogView=!0):o.selectionApi.isRunningInFileSelection()&&(t=r.HEADING_SELECT_FROM_RECENT_FOLDER,n=r.BROWSE_DIALOG_BUTTON,this._isCustomSaveOpenDialogView=!0),0===this.$el.children().length&&(this.$el.html(this._isCustomSaveOpenDialogView?this._template({heading:t,noRecentLabel:i,buttonLabel:n}):this._template({heading:t,buttonLabel:n})),this._initWrappers(),this.$el.addClass("my-computer-container theme-container"),this.options.appApi.selectionApi.isRunningInFileSelection()&&this.options.appApi.rnaApi.done(function(e){e.logAnayticsCustomOpenSave("Time_To_Show_Dialog_View_My_Computer")})),this._renderChildViews(),this},_initWrappers:function(){this.$heading=this.$(".recentFoldersHeading"),this.$browserButton=this.$(".openBrowseButton"),this.$noRecentPlaceHolder=this.$(".no-recentfolder-placeholder"),this.$recentFolders=this.$(".recentFolders"),this.$emptyView=this.$(".emptyView")},_getRecentFolderClickEvent:function(){return"mycomputer-plugin-recentFolder:click"},_renderChildViews:function(){this._renderRecentFoldersView(),s.setElementFontByLocale(this.$el,"button")},_renderRecentFoldersView:function(){var i=!1;this.options.appApi.saveAsApi.isRunningInFileSaveAs()&&(i=!0),this.options.appApi.rnaApi.done(_.bind(function(n){n.fileApi({methodName:"recentFolders",methodArgs:i}).done(_.bind(function(i){i&&(this._recentFolders=new e.RNACollection(void 0,_.extend({_proxy:i,shouldCache:!0})),this._isCustomSaveOpenDialogView?(this._renderChildView("_recentFoldersView",t.FoldersView,this.$recentFolders,{collection:this._recentFolders,clickEvent:this._getRecentFolderClickEvent()}),this._recentFolders.length>0?this.$noRecentPlaceHolder.hide():this.$noRecentPlaceHolder.show()):this._recentFolders.length>0?(this._renderChildView("_recentFoldersView",t.FoldersView,this.$recentFolders,{collection:this._recentFolders,clickEvent:this._getRecentFolderClickEvent()}),this.$heading.hasClass("collection-header")||this.$heading.addClass("collection-header"),this.$browserButton.hasClass("recentListButton")||this.$browserButton.addClass("recentListButton"),this.$recentFolders.show(),this.$emptyView.hide(),this.$browserButton.attr("aria-label",r.BROWSE_BUTTON),$(".page-main-container").removeClass("myComputerEmptyViewContainer")):(this._renderChildView("_emptyFoldersView",t.EmptyView,this.$emptyView,{collection:this._recentFolders,clickEvent:this._getRecentFolderClickEvent()}),this.$heading.removeClass("collection-header"),this.$browserButton.hasClass("recentListButton")&&this.$browserButton.removeClass("recentListButton"),this.$recentFolders.hide(),this.$emptyView.show(),this.$browserButton.attr("aria-label",r.NO_FOLDERS_MYCOMPUTER_PROMPT+" "+r.NO_FOLDERS_MYCOMPUTER_SUBPROMPT+" "+r.BROWSE_BUTTON)),this.listenTo(this._recentFolders,"reset",this._onRecentFoldersChange),this.listenTo(this._recentFolders,"change",this._onRecentFoldersChange)),this.options.appApi.selectionApi.isRunningInFileSelection()?this.$browserButton.hide():this.$browserButton.show()},this))},this))},_selectAndOpenFile:function(e){var t={};e&&(t.initialLocation=e._proxy);var i=($.Deferred(),this.options);i.appApi.rnaApi.done(function(e){e.selectAndOpenFile(t)})},selectPlugin:function(e){var t=this.options,i=t.appApi,n=i.displayApi,o=$.Deferred();return n.applyUIThemeStyles(this.$el).done(_.bind(function(){i.selectionApi.isRunningInFileSelection()?e&&e.scContext&&(this._scContext=e.scContext):i.siteCatalystApi.logScEvent([c.FILE_LIST,c.MY_COMPUTER,c.CLICKED]),this.render(),o.resolve(),this.options.appApi.displayApi.showSpinner(!1)},this)),o},deselectPlugin:function(){e.Util.isCEF()&&$(".page-main-container").removeClass("myComputerEmptyViewContainer"),e.PluginContentView.prototype.deselectPlugin.call(this)},getSiteCatalystName:function(){return c.MY_COMPUTER},_onKeyDown:function(e){l.nextElem(e)},_OnBrowseBtnClick:function(){this._selectAndOpenFile(),this.options.appApi.siteCatalystApi.logVirgoEvent(this.options.appApi.siteCatalystApi._getLogSubCategory(this.options.pluginId),"Browse")},_onRecentFolderClick:function(e){this._selectAndOpenFile(e),this.options.appApi.siteCatalystApi.logVirgoFileOpenEvent(this.options.appApi.siteCatalystApi._getLogSubCategory(this.options.pluginId))},_onRecentFoldersChange:function(){this._recentFolders&&(this._isCustomSaveOpenDialogView?this._recentFolders.length>0?this.$noRecentPlaceHolder.hide():this.$noRecentPlaceHolder.show():this.render())}}),t.PluginView}),define("pdmplugins/my-computer/js/my-computer",["pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/ops/op-factory","pdmplugins/my-computer/js/views/plugin-view"],function(e){_.extend(e,{init:function(){e.opFactory=new e.OpFactory}})}),define("pdmplugins/my-computer/js/plugin",["core/ac-core-init","files/ac-files-init","pdmplugins/my-computer/js/ac-my-computer","pdmplugins/my-computer/js/my-computer"],function(e,t,i){i.init()});