This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
/
app.js
3 lines (3 loc) · 36.7 KB
/
app.js
1
2
3
!function(){"use strict";angular.module("app",["ngResource","ngAnimate","ui.router","templates","cfp.hotkeys","focusOn","monospaced.elastic","gettext"])}(),function(){"use strict";function t(t,e,n,o){var r=["$q","$rootScope",function(t,e){return{request:function(t){return e.$broadcast("loadingInitiated"),t},requestError:function(e){return console.log("Request error due to ",e),t.reject(e)},response:function(n){return e.$broadcast("loadingComplete"),n||t.when(n)},responseError:function(e){return 401===e.status?console.error("Unauthorized access. Please login"):404===e.status?console.error("Service end point not found- ",e.config.url):console.error("Error in response ",e),t.reject(e)}}}];n.interceptors.push(r),e.otherwise("/"),t.state("editor",{url:"/:projectSlug/:versionSlug/translate",templateUrl:"editor/editor.html",controller:"EditorCtrl as editor",resolve:{url:["UrlService",function(t){return t.init()}]}}).state("editor.selectedContext",{url:"/:docId/:localeId",views:{"editor-content":{templateUrl:"editor/editor-content.html",controller:"EditorContentCtrl as editorContent"},"editor-suggestions":{templateUrl:"editor/editor-suggestions.html",controller:"EditorSuggestionsCtrl as editorSuggestions"},"editor-details":{templateUrl:"editor/editor-details.html",controller:"EditorDetailsCtrl as editorDetails"}}}).state("editor.selectedContext.tu",{url:"/?id&selected?states",reloadOnSearch:!1}),o.template='<div class="Modal" ng-class="{\'is-active\': helpVisible}"><div class="Modal-dialog"><div class="Modal-header"><h2 class="Modal-title">Keyboard Shortcuts</h2><button class="Modal-close Link Link--neutral" ng-click="toggleCheatSheet()"><icon name="cross" title="Close"></icon></button></div><div class="Modal-content u-sP-1"><ul><li class="Grid" ng-repeat="hotkey in hotkeys | filter:{ description: \'!$$undefined$$\' }"><div class="Grid-cell u-sm-size1of2 u-size1of3 u-sPR-1-4 u-sPV-1-4 u-textRight"><kbd ng-repeat="key in hotkey.format() track by $index">{{ key }}</kbd></div><div class="Grid-cell u-sm-size1of2 u-size2of3 u-sPL-1-4 u-sPV-1-4">{{ hotkey.description }}</div></li><li class="Grid"><div class="Grid-cell u-sm-size1of2 u-size1of3 u-sPR-1-4 u-sPV-1-4 u-textRight"><kbd>Tab + U</kbd></div><div class="Grid-cell u-sm-size1of2 u-size2of3 u-sPL-1-4 u-sPV-1-4">Save and go to next untranslated string</div></li></ul></div></div></div>'}t.$inject=["$stateProvider","$urlRouterProvider","$httpProvider","hotkeysProvider"],angular.module("app").config(t)}(),function(){"use strict";angular.module("app").constant("_",window._).constant("str",window._.string).constant("Mousetrap",window.Mousetrap).constant("PRODUCTION",!0)}(),function(){"use strict";function t(t,e,n,o,r,i,a,c){function s(){return o.getAllLocales()}function u(){return e.getMyInfo().then(function(t){d.myInfo=t,d.myInfo.locale=o.DEFAULT_LOCALE,d.myInfo.gravatarUrl=n.gravatarUrl(d.myInfo.gravatarHash,72)},function(t){r.displayError("Error loading my info: "+t)})}function l(){o.getUILocaleList().then(function(t){for(var e in t.locales){var n={localeId:t.locales[e],name:""};d.uiLocaleList.push(n)}d.myInfo.locale=o.getLocaleByLocaleId(d.uiLocaleList,o.DEFAULT_LOCALE.localeId),d.myInfo.locale||(d.myInfo.locale=o.DEFAULT_LOCALE)},function(t){r.displayInfo("Error loading UI locale. Default to '"+o.DEFAULT_LOCALE.name+"': "+t),d.myInfo.locale=o.DEFAULT_LOCALE})}var d=this;d.PRODUCTION=c,d.settings=e.settings,d.uiLocaleList=[o.DEFAULT_LOCALE],d.loading=!0,t.$on("$stateChangeStart",function(t,e){d.loading=!0,e.resolve}),t.$on("$stateChangeSuccess",function(t,e){d.loading=!1,e.resolve}),n.init().then(s).then(u).then(l),d.onChangeUILocale=function(t){d.myInfo.locale=t;var e=d.myInfo.locale.localeId;a.startsWith(e,o.DEFAULT_LOCALE.localeId,!0)?i.setCurrentLanguage(o.DEFAULT_LOCALE.localeId):i.loadRemote(n.uiTranslationURL(e)).then(function(){i.setCurrentLanguage(e)},function(t){r.displayInfo("Error loading UI locale. Default to '"+o.DEFAULT_LOCALE.name+"': "+t),i.setCurrentLanguage(o.DEFAULT_LOCALE),d.myInfo.locale=o.DEFAULT_LOCALE})},d.dashboardPage=function(){return n.DASHBOARD_PAGE}}t.$inject=["$scope","UserService","UrlService","LocaleService","MessageHandler","gettextCatalog","StringUtil","PRODUCTION"],angular.module("app").controller("AppCtrl",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a){function c(t){u(t),i.emitEvent(i.EVENT.CANCEL_EDIT)}function s(){i.emitEvent(i.EVENT.REFRESH_STATISTIC,{projectSlug:e.context.projectSlug,versionSlug:e.context.versionSlug,docId:e.context.docId,localeId:e.context.localeId}),n.getPhraseCount(e.context,E).then(function(t){e.maxPageIndex=parseInt(t/d),t>d&&(e.maxPageIndex=t%d!==0?e.maxPageIndex+=1:e.maxPageIndex),e.maxPageIndex=e.maxPageIndex-1<0?0:e.maxPageIndex-1,u(e.currentPageIndex)})}function u(t){var o=t*d;n.fetchAllPhrase(e.context,E,o,d).then(l)}function l(t){f.phrases=t}var d=50,f=this,p=r.readValue("states"),E={states:p?p.split(" "):p};return f.phrases=[],e.updateContext(a.projectSlug,a.versionSlug,o.decodeDocId(a.docId),a.localeId),s(),t.$on(i.EVENT.GOTO_FIRST_PAGE,function(){e.currentPageIndex>0&&(e.currentPageIndex=0,c(e.currentPageIndex))}),t.$on(i.EVENT.GOTO_PREV_PAGE,function(){e.currentPageIndex>0&&(e.currentPageIndex-=1,c(e.currentPageIndex))}),t.$on(i.EVENT.GOTO_NEXT_PAGE,function(){e.currentPageIndex<e.maxPageIndex&&(e.currentPageIndex+=1,c(e.currentPageIndex))}),t.$on(i.EVENT.GOTO_LAST_PAGE,function(){e.currentPageIndex<e.maxPageIndex&&(e.currentPageIndex=e.maxPageIndex,c(e.currentPageIndex))}),f}t.$inject=["$rootScope","EditorService","PhraseService","DocumentService","UrlService","EventService","$stateParams"],angular.module("app").controller("EditorContentCtrl",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a,c,s,u,l,d,f,p,E){function g(){S()&&u.go("editor.selectedContext",{docId:v.context.docId,localeId:v.context.localeId})}function S(){return v.context.docId&&v.context.localeId}function T(t,n,o,r){e.getStatistics(t,n,o,r).then(function(t){v.wordStatistic=a.getWordStatistic(t),v.messageStatistic=a.getMsgStatistic(t),v.messageStatistic[i.getId("needswork")]=v.messageStatistic.needReview||0},function(t){l.displayError("Error loading statistic: "+t)})}var v=this;v.pageNumber=1,v.context=r.initContext(s.projectSlug,s.versionSlug,e.decodeDocId(s.docId),n.DEFAULT_LOCALE,n.DEFAULT_LOCALE.localeId,"READ_WRITE"),v.toggleKeyboardShortcutsModal=function(){E.toggleCheatSheet()},v.versionPage=function(){return c.PROJECT_PAGE(v.context.projectSlug,v.context.versionSlug)},v.encodeDocId=function(t){return e.encodeDocId(t)},o.getProjectInfo(s.projectSlug).then(function(t){v.projectInfo=t},function(t){l.displayError("Error getting project information:"+t)}),n.getSupportedLocales(v.context.projectSlug,v.context.versionSlug).then(function(t){if(v.locales=t,!v.locales||v.locales.length<=0)l.displayError("No supported locales in "+v.context.projectSlug+" : "+v.context.versionSlug);else{var e=u.params.localeId,o=v.context;e?(o.localeId=e,n.containsLocale(v.locales,e)||(o.localeId=v.locales[0].localeId)):(o.localeId=v.locales[0].localeId,g())}},function(t){l.displayError("Error getting locale list: "+t)}),e.findAll(v.context.projectSlug,v.context.versionSlug).then(function(t){if(v.documents=t,!v.documents||v.documents.length<=0)l.displayError("No documents in "+v.context.projectSlug+" : "+v.context.versionSlug);else{var n=u.params.docId,o=v.context;n?(o.docId=e.decodeDocId(n),e.containsDoc(v.documents,o.docId)||(o.docId=v.documents[0].name)):(o.docId=v.documents[0].name,g())}},function(t){l.displayError("Error getting document list: "+t)}),d.$on(f.EVENT.SELECT_TRANS_UNIT,function(t,e){v.unitSelected=e.id,v.focused=e.focus}),d.$on(f.EVENT.CANCEL_EDIT,function(){v.unitSelected=!1,v.focused=!1}),d.$on(f.EVENT.REFRESH_STATISTIC,function(t,e){T(e.projectSlug,e.versionSlug,e.docId,e.localeId),v.context.docId=e.docId,v.context.localeId=e.localeId}),v.pageNumber=function(){return 0===r.maxPageIndex?r.currentPageIndex+1:r.currentPageIndex+1+" of "+(r.maxPageIndex+1)},v.getLocaleName=function(t){return n.getName(t)},v.firstPage=function(){f.emitEvent(f.EVENT.GOTO_FIRST_PAGE)},v.lastPage=function(){f.emitEvent(f.EVENT.GOTO_LAST_PAGE)},v.nextPage=function(){f.emitEvent(f.EVENT.GOTO_NEXT_PAGE)},v.previousPage=function(){f.emitEvent(f.EVENT.GOTO_PREV_PAGE)},this.settings=t.settings.editor,p.enableEditorKeys()}t.$inject=["UserService","DocumentService","LocaleService","ProjectService","EditorService","TransStatusService","StatisticUtil","UrlService","$stateParams","$state","MessageHandler","$rootScope","EventService","EditorShortcuts","hotkeys"],angular.module("app").controller("EditorCtrl",t)}(),function(){"use strict";function t(){var t=this;return t}angular.module("app").controller("EditorDetailsCtrl",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a,c,s,u){function l(t){var u=n.cloneDeep(f.context),l=p[t],d=e(o.TRANSLATION_URL,{},{update:{method:"PUT",params:{localeId:l.locale}}}),E={id:l.phrase.id,revision:l.phrase.revision?l.phrase.revision:0,content:l.phrase.newTranslation,contents:l.phrase.newTranslations,status:s.getServerId(l.status.ID),plural:l.phrase.plural};d.update(E).$promise.then(function(t){var e=l.phrase.status;i.onTransUnitUpdated(u,E.id,l.locale,t.revision,t.status,l.phrase.newTranslation),a.updateStatistic(l.docId,l.locale,e,t.status,l.phrase.wordCount),r.emitEvent(r.EVENT.SAVE_COMPLETED,l.phrase)},function(t){c.displayWarning("Update translation failed for "+E.id+" -"+t),i.onTransUnitUpdateFailed(E.id),r.emitEvent(r.EVENT.SAVE_COMPLETED,l.phrase)}),delete p[t]}function d(t,e){return""===t.newTranslation?s.getStatusInfo("UNTRANSLATED"):e}var f=this,p={};return f.context={},f.currentPageIndex=0,f.maxPageIndex=0,f.initContext=function(t,e,n,o,r,i){return f.context={projectSlug:t,versionSlug:e,docId:n,srcLocale:o,localeId:r,mode:i},f.context},f.updateContext=function(t,e,n,o){f.context.projectSlug!==t&&(f.context.projectSlug=t),f.context.versionSlug!==e&&(f.context.versionSlug=e),f.context.docId!==n&&(f.context.docId=n),f.context.localeId!==o&&(f.context.localeId=o)},t.$on(r.EVENT.SAVE_TRANSLATION,function(t,e){var o=e.phrase,i=e.status;if(o.translation!==o.newTranslation||i!==o.status)if(r.emitEvent(r.EVENT.SAVE_INITIATED,e),n.has(p,o.id)){var a=p[o.id];a.phrase=o,a.status=i,l(o.id)}else(u.isTranslationModified(o)||o.status!==i)&&(i=d(o,i),p[o.id]={phrase:o,status:i,locale:e.locale,docId:e.docId},l(o.id))}),f}t.$inject=["$rootScope","$resource","_","UrlService","EventService","PhraseService","DocumentService","MessageHandler","TransStatusService","TransUnitService"],angular.module("app").factory("EditorService",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a){function c(e){I.selectedTUCtrl&&(e.preventDefault(),t.emitEvent(t.EVENT.COPY_FROM_SOURCE,I.selectedTUCtrl.getPhrase()))}function s(e){var n=9;e.which===n&&h||!I.selectedTUCtrl||(e.preventDefault(),e.stopPropagation(),t.emitEvent(t.EVENT.GOTO_NEXT_ROW,T()))}function u(e){I.selectedTUCtrl&&(e.preventDefault(),e.stopPropagation(),t.emitEvent(t.EVENT.GOTO_PREVIOUS_ROW,T()))}function l(e){if(e.preventDefault(),e.stopPropagation(),m)I.cancelSaveAsModeIfOn(),I.selectedTUCtrl&&I.selectedTUCtrl.focusTranslation();else if(I.selectedTUCtrl){var n=I.selectedTUCtrl.getPhrase();n.newTranslation!==n.translation?t.emitEvent(t.EVENT.UNDO_EDIT,n):t.emitEvent(t.EVENT.CANCEL_EDIT,n)}}function d(n){if(I.selectedTUCtrl){n.preventDefault();var o=I.selectedTUCtrl.getPhrase();t.emitEvent(t.EVENT.SAVE_TRANSLATION,{phrase:o,status:o.status,locale:e.localeId,docId:e.docId})}}function f(e){I.cancelSaveAsModeIfOn();var n=I.selectedTUCtrl.getPhrase();n&&(e.preventDefault(),t.emitEvent(t.EVENT.TOGGLE_SAVE_OPTIONS,{id:n.id,open:!0}),v(n,"n","needsWork"),v(n,"t","translated"),v(n,"a","approved"),m=!0)}function p(e){e.preventDefault(),e.stopPropagation(),I.selectedTUCtrl&&t.emitEvent(t.EVENT.GOTO_NEXT_UNTRANSLATED,T()),h=!0}function E(t,e,n,o,r){return this.defaultKey=t,this.keyCombos=[g(t,n,r,e)],o&&(this.otherKeys=o instanceof Array?o:[o],this.keyCombos.push(g(this.otherKeys,"",r,e))),this}function g(t,e,n,o){var r={allowIn:["TEXTAREA"],callback:o};return r.combo=t,e&&(r.description=e),n&&(r.action=n),r}function S(t){o.get(t.defaultKey)||n.forEach(t.keyCombos,function(t){o.add(t)})}function T(){return{currentId:I.selectedTUCtrl.getPhrase().id}}function v(n,i,c){var s=r.getStatusInfo(c);return o.add({combo:i,description:a.sprintf("Save as %s",c),allowIn:["INPUT","TEXTAREA"],action:"keydown",callback:function(o){o.preventDefault(),o.stopPropagation(),t.emitEvent(t.EVENT.SAVE_TRANSLATION,{phrase:n,status:s,locale:e.localeId,docId:e.docId}),I.cancelSaveAsModeIfOn()}})}var I=this,h=!1,m=!1;return I.selectedTUCtrl=null,i.bind("tab",function(){event.preventDefault(),h=!1},"keydown"),I.SHORTCUTS={COPY_SOURCE:new E("alt+c",c,"Copy source as translation","alt+g"),CANCEL_EDIT:new E("esc",l,"Cancel edit"),SAVE_AS_CURRENT_STATUS:new E("mod+s",d,"Save"),SAVE_AS_MODE:new E("mod+shift+s",f,"Save as…"),GOTO_NEXT_ROW:new E("tab",s,"Save and go to next string",[],"keyup"),GOTO_NEXT_ROW_FAST:new E("mod+enter",s,"",["alt+k","alt+down"]),GOTO_PREVIOUS_ROW:new E("shift+tab",u,"Save and go to previous string",["mod+shift+enter","alt+j","alt+up"]),GOTO_NEXT_UNTRANSLATED:new E("tab+u",p)},I.enableEditorKeys=function(){o.get(I.SHORTCUTS.COPY_SOURCE.defaultKey)||n.forOwn(I.SHORTCUTS,function(t){S(t)})},I.disableEditorKeys=function(){n.forOwn(I.SHORTCUTS,function(t){n.forEach(t.keyCombos,function(t){I.deleteKeys(t.combo,t.action)})})},I.cancelSaveAsModeIfOn=function(){m&&I.selectedTUCtrl&&(m=!1,I.deleteKeys(["n","t","a"]),t.emitEvent(t.EVENT.TOGGLE_SAVE_OPTIONS,{id:I.selectedTUCtrl.getPhrase().id,open:!1}))},I.deleteKeys=function(t,e){var r=t instanceof Array?t:[t];e=e||"keydown",n.forEach(r,function(t){o.del(t),i.unbind(t,e)})},I}t.$inject=["EventService","$stateParams","_","hotkeys","TransStatusService","Mousetrap","str"],angular.module("app").factory("EditorShortcuts",t)}(),function(){"use strict";function t(){var t=this;return t}angular.module("app").controller("EditorSuggestionsCtrl",t)}(),function(){"use strict";function t(){return{restrict:"A",link:function(t,e,n){return t.$on("blurOn",function(t,o){return o===n.blurOn?e[0].blur():void 0})}}}angular.module("app").directive("blurOn",t)}(),function(){"use strict";function t(t){return{restrict:"A",scope:{callback:"&clickElsewhere"},link:function(e,n){var o=function(t){n[0].contains(t.target)||e.$apply(e.callback(t))};t.on("click",o),e.$on("$destroy",function(){t.off("click",o)})}}}t.$inject=["$document"],angular.module("app").directive("clickElsewhere",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a){function c(t,e){return t+"-"+e}function s(t,e,n,o){var i=r.getWordStatistic(t),a=r.getMsgStatistic(t);if(o=parseInt(o),i){var c=parseInt(i[e])-o;i[e]=0>c?0:c,i[n]=parseInt(i[n])+o}if(a){var s=parseInt(a[e])-1;a[e]=0>s?0:s,a[n]=parseInt(a[n])+1}}var u=this,l={};return u.findAll=function(t,o){var r=e(n.DOCUMENT_LIST_URL,{},{query:{method:"GET",params:{projectSlug:t,versionSlug:o},isArray:!0}});return r.query().$promise},u.getStatistics=function(o,r,i,s){if(i&&s){var d=c(i,s);if(a.has(l,d))return t.when(l[d]);var f=u.encodeDocId(i),p=e(n.DOC_STATISTIC_URL,{},{query:{method:"GET",params:{projectSlug:o,versionSlug:r,docId:f,localeId:s},isArray:!0}});return p.query().$promise.then(function(t){return l[d]=t,l[d]})}},u.encodeDocId=function(t){return t?t.replace(/\//g,","):t},u.decodeDocId=function(t){return t?t.replace(/\,/g,"/"):t},u.containsDoc=function(t,e){return a.any(t,function(t){return o.equals(t.name,e,!0)})},u.updateStatistic=function(t,e,n,o,r){var u=c(t,e);a.has(l,u)&&(s(l[u],n,o,r),i.emitEvent(i.EVENT.REFRESH_STATISTIC,{projectSlug:"tiny-project",versionSlug:"1",docId:t,localeId:e}))},u}t.$inject=["$q","$resource","UrlService","StringUtil","StatisticUtil","EventService","_"],angular.module("app").factory("DocumentService",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a){var c,s=this,u=t.$new(),l=o.openClass,d=angular.noop,f=e.onToggle?n(e.onToggle):angular.noop;this.init=function(o){s.$element=o,e.isOpen&&(c=n(e.isOpen),d=c.assign,t.$watch(c,function(t){u.isOpen=!!t}))},this.toggle=function(t){return u.isOpen=arguments.length?!!t:!u.isOpen,u.isOpen},this.isOpen=function(){return u.isOpen},u.getToggleElement=function(){return s.toggleElement},u.focusToggleElement=function(){s.toggleElement&&s.toggleElement[0].focus()},u.$watch("isOpen",function(e,n){i[e?"addClass":"removeClass"](s.$element,l),e?(a(function(){u.focusToggleElement()}),r.open(u)):r.close(u),d(t,e),angular.isDefined(e)&&e!==n&&f(t,{open:!!e})}),t.$on("$locationChangeSuccess",function(){u.isOpen=!1}),t.$on("$destroy",function(){u.$destroy()}),t.$on("openDropdown",function(){u.isOpen=!0}),t.$on("closeDropdown",function(){u.isOpen=!1})}t.$inject=["$scope","$attrs","$parse","dropdownConfig","DropdownService","$animate","$timeout"],angular.module("app").controller("DropdownCtrl",t)}(),function(){"use strict";function t(t){var e=null,n=this;n.open=function(n){e||(t.bind("click",o),t.bind("keydown",r)),e&&e!==n&&(e.isOpen=!1),e=n},n.close=function(n){e===n&&(e=null,t.unbind("click",o),t.unbind("keydown",r))};var o=function(t){if(e){var n=e.getToggleElement();t&&n&&n[0].contains(t.target)||e.$apply(function(){e.isOpen=!1})}},r=function(t){27===t.which&&(e.focusToggleElement(),o())}}t.$inject=["$document"],angular.module("app").service("DropdownService",t)}(),function(){"use strict";var t={openClass:"is-active"};angular.module("app").constant("dropdownConfig",t)}(),function(){"use strict";function t(){return{restrict:"EA",controller:"DropdownCtrl",link:function(t,e,n,o){o.init(e)}}}function e(){return{restrict:"A",require:"?^dropdown",scope:{callback:"&onCloseDropdown"},link:function(t,e,n,o){o.onCloseDropdown=t.callback}}}function n(){return{restrict:"EA",require:"?^dropdown",link:function(t,e,n,o){if(o){o.toggleElement=e;var r=function(r){r.preventDefault(),e.hasClass("disabled")||n.disabled||t.$apply(function(){o.toggle()})};e.bind("click",r),e.attr({"aria-haspopup":!0,"aria-expanded":!1}),t.$watch(o.isOpen,function(n){e.attr("aria-expanded",!!n),o.onCloseDropdown&&!n&&t.$applyAsync(o.onCloseDropdown)}),t.$on("$destroy",function(){e.unbind("click",r)})}}}}angular.module("app").directive("dropdown",t).directive("onCloseDropdown",e).directive("dropdownToggle",n)}(),function(){"use strict";function t(t){var e=this;return e.EVENT={LOADING_INITIATED:"loadingInitiated",LOADING_COMPLETE:"loadingStarted",SELECT_TRANS_UNIT:"selectTransUnit",COPY_FROM_SOURCE:"copyFromSource",UNDO_EDIT:"undoEdit",CANCEL_EDIT:"cancelEdit",FOCUS_TRANSLATION:"focusTranslation",SAVE_TRANSLATION:"saveTranslation",SAVE_INITIATED:"saveInitiated",SAVE_COMPLETED:"saveCompleted",TRANSLATION_TEXT_MODIFIED:"translationTextModified",REFRESH_STATISTIC:"refreshStatistic",GOTO_PREV_PAGE:"gotoPreviousPage",GOTO_NEXT_PAGE:"gotoNextPage",GOTO_FIRST_PAGE:"gotoFirstPage",GOTO_LAST_PAGE:"gotoLastPage",GOTO_NEXT_ROW:"gotoNextRow",GOTO_PREVIOUS_ROW:"gotoPreviousRow",GOTO_NEXT_UNTRANSLATED:"gotoNextUntranslated",TOGGLE_SAVE_OPTIONS:"openSaveOptions"},e.broadcastEvent=function(e,n,o){o=o||t,o.$broadcast(e,n)},e.emitEvent=function(e,n,o){o=o||t,o.$emit(e,n)},e}t.$inject=["$rootScope"],angular.module("app").factory("EventService",t)}(),function(){"use strict";function t(t){return{restrict:"E",required:["name"],scope:{name:"@",title:"@",size:"@"},link:function(e,n){var o="",r="";n.addClass("Icon"),e.title&&(r="<title>"+e.title+"</title>"),o='<svg class="Icon-item"><use xlink:href="#Icon-'+e.name+'" />'+r+"</svg>",n.html(t.trustAsHtml(o))}}}t.$inject=["$sce"],angular.module("app").directive("icon",t)}(),function(){"use strict";function t(t,e,n,o,r){function i(e,n){var r=o(t.LOCALE_LIST_URL,{},{query:{method:"GET",params:{projectSlug:e,versionSlug:n},isArray:!0}});return r.query().$promise}function a(){var e=o(t.ALL_LOCALE_URL,{},{query:{method:"GET",isArray:!0}});return e.query().$promise.then(function(t){d=n.cleanResourceList(t)})}function c(){var e=o(t.uiTranslationListURL,{},{query:{method:"GET"}});return e.query().$promise}function s(t,n){return t?r.find(t,function(t){return e.equals(t.localeId,n,!0)}):void 0}function u(t,n){return r.any(t,function(t){return e.equals(t.localeId,n,!0)})}function l(t){var e=s(d,t);return e?e.name:t}var d=[];return{getSupportedLocales:i,getUILocaleList:c,getLocaleByLocaleId:s,getAllLocales:a,containsLocale:u,getName:l,DEFAULT_LOCALE:{localeId:"en-US",name:"English"}}}t.$inject=["UrlService","StringUtil","FilterUtil","$resource","_"],angular.module("app").factory("LocaleService",t)}(),function(){"use strict";function t(){return{restrict:"EA",scope:{loading:"=",inverted:"="},link:function(t){t.classes="",t.$on("loadingInitiated",function(){t.classes+=" is-loading"}),t.$on("loadingComplete",function(){t.classes=t.classes.replace("is-loading","")}),t.$watch("inverted",function(e){e?t.classes+=" LogoLoader--inverted":t.classes=t.classes.replace("LogoLoader--inverted","")})},templateUrl:"components/logo-loader/logo-loader.html"}}angular.module("app").directive("logoLoader",t)}(),function(){"use strict";function t(){return{displayError:function(t){console.error(t)},displayWarning:function(t){console.warn(t)},displayInfo:function(t){console.info(t)}}}angular.module("app").factory("MessageHandler",t)}(),function(){"use strict";function t(){}angular.module("app").factory("NotificationService",t)}(),function(){"use strict";function t(t,e,n,o,r,i){function a(t,e,n,o){return t+"-"+e+"-"+n+"-"+o}var c=this,s={},u={};return c.getStates=function(c,u,l,d){var f=a(c,u,l,d);if(i.has(s,f))return t.when(s[f]);var p=r.encodeDocId(l),E={query:{method:"GET",params:{projectSlug:c,versionSlug:u,docId:p,localeId:d},isArray:!0}},g=e(o.TRANSLATION_STATUS_URL,{},E);return g.query().$promise.then(function(t){return t=n.cleanResourceList(t),s[f]=t,s[f]})},c.getTransUnits=function(r,a){function c(t){t=n.cleanResourceMap(t);for(var e in t)u[e][a]=t[e][a],l[e]=u[e];return l}function s(t){t=n.cleanResourceMap(t);for(var e in t)u[e]=t[e],l[e]=u[e];return l}var l={},d=[],f=[];if(r.forEach(function(t){i.has(u,t)?u[t][a]?l[t]=u[t]:f.push(t):d.push(t)}),i.isEmpty(d)&&i.isEmpty(f))return t.when(l);var p,E;return i.isEmpty(d)||(p=e(o.TEXT_FLOWS_URL,{},{query:{method:"GET",params:{localeId:a,ids:d.join(",")}}})),i.isEmpty(f)||(E=e(o.TRANSLATION_URL,{},{query:{method:"GET",params:{localeId:a,ids:f.join(",")}}})),p&&E?p.query().$promise.then(s).then(E.query().$promise.then(c)):p?p.query().$promise.then(s):E?E.query().$promise.then(c):void 0},c.onTransUnitUpdated=function(t,e,n,o,r,c,l){var d=a(t.projectSlug,t.versionSlug,t.docId,n),f=i.find(s[d],function(t){return t.id===e});f&&(f.state=r);var p=u[e][n];p||(p={}),p.revision=parseInt(o),p.state=r,p.content=c,p.contents=l},c}t.$inject=["$q","$resource","FilterUtil","UrlService","DocumentService","_"],angular.module("app").factory("PhraseCache",t)}(),function(){"use strict";function t(t,e,n,o,r){function i(t,e){return o.find(e,function(e){return e.id===t})}function a(e,n){return n&&(e=t.filterResources(e,["state"],n)),o.map(e,function(t){return t.id})}var c={};return c.phrases=[],c.getPhraseCount=function(t,n){return e.getStates(t.projectSlug,t.versionSlug,t.docId,t.localeId).then(function(t){var e=a(t,n.states);return e.length})},c.fetchAllPhrase=function(t,r,i,s){function u(t){var n=a(t,r.states);return isNaN(i)||(n=isNaN(s)?n.slice(i):n.slice(i,i+s)),e.getTransUnits(n,f).then(l).then(d)}function l(t){return o.map(t,function(t,e){var o=t.source,r=t[f];return{id:parseInt(e),source:o.content,sources:o.contents,translation:r?r.content:"",translations:r?r.contents:[],newTranslation:r?r.content:"",newTranslations:r?r.contents:[],plural:o.plural,status:n.getStatusInfo(r?r.state:"untranslated"),revision:r?parseInt(r.revision):0,wordCount:parseInt(o.wordCount)}})}function d(n){return e.getStates(t.projectSlug,t.versionSlug,t.docId,f).then(function(t){return c.phrases=o.sortBy(n,function(e){var r=o.findIndex(t,function(t){return t.id===e.id});return r>=0?r:n.length}),c.phrases})}var f=t.localeId;return e.getStates(t.projectSlug,t.versionSlug,t.docId,f).then(u)},c.onTransUnitUpdated=function(t,o,r,a,s,u,l){e.onTransUnitUpdated(t,o,r,a,s,u,l);var d=i(o,c.phrases);d&&(d.translation=u,d.revision=a,d.status=n.getStatusInfo(s))},c.onTransUnitUpdateFailed=function(t){var e=i(t,c.phrases);e&&(e.newTranslation=e.translation)},c.findNextId=function(t){return e.getStates(r.projectSlug,r.versionSlug,r.docId,r.localeId).then(function(e){var n,r;return n=o.findIndex(e,function(e){return e.id===t}),r=n+1<e.length?n+1:e.length-1,e[r].id})},c.findPreviousId=function(t){return e.getStates(r.projectSlug,r.versionSlug,r.docId,r.localeId).then(function(e){var n,r;return n=o.findIndex(e,function(e){return e.id===t}),r=n-1>=0?n-1:0,e[r].id})},c.findNextStatus=function(t,i){return e.getStates(r.projectSlug,r.versionSlug,r.docId,r.localeId).then(function(e){var r,a,c=n.getStatusInfo(i);r=o.findIndex(e,function(e){return e.id===t});for(var s=r+1;s<e.length;s++)if(a=n.getStatusInfo(e[s].state),a.ID===c.ID)return e[s].id;return t})},c}t.$inject=["FilterUtil","PhraseCache","TransStatusService","_","$stateParams"],angular.module("app").factory("PhraseService",t)}(),function(){"use strict";function t(){return{restrict:"E",required:"progressbarStatistic",scope:{statistic:"=progressbarStatistic",size:"@"},templateUrl:"components/progressbar/progressbar.html",controller:["$scope",function(t){t.$watch("statistic",function(n){n&&(t.style=e(n))},!0)}]}}function e(t){var e=t.total,o=n(t.approved,e),r=n(t.translated,e),i=o,a=n(t.needswork,e),c=o+r,s=n(t.untranslated,e),u=o+r+a,l={};return l.approved={width:o+"%",marginLeft:0},l.translated={width:r+"%",marginLeft:i+"%"},l.needsWork={width:a+"%",marginLeft:c+"%"},l.untranslated={width:s+"%",marginLeft:u+"%"},l}function n(t,e){var n=0;return t&&(n=t/e*100),n}angular.module("app").directive("progressbar",t)}(),function(){"use strict";function t(t,e){function n(n){var o={query:{method:"GET",params:{projectSlug:n}}},r=e(t.PROJECT_URL,{},o);return r.query().$promise}return{getProjectInfo:n}}t.$inject=["UrlService","$resource"],angular.module("app").factory("ProjectService",t)}(),function(){"use strict";function t(){var t=this;t.init=function(){var e=t.container[0],n=t.child[0],o=n.offsetWidth-e.offsetWidth;t.width=o/2}}angular.module("app").controller("ScrollbarWidthCtrl",t)}(),function(){"use strict";function t(){return{restrict:"A",controller:"ScrollbarWidthCtrl as scrollbarWidthCtrl",link:function(t,e,n,o){o.init(e)}}}function e(){return{restrict:"A",require:"?^scrollbarWidth",link:function(t,e,n,o){o&&e.css(n.scrollbarWidthElement,o.width)}}}function n(){return{restrict:"A",require:"?^scrollbarWidth",link:function(t,e,n,o){o&&(o.container=e)}}}function o(){return{restrict:"A",require:"?^scrollbarWidth",link:function(t,e,n,o){o&&(o.child=e)}}}angular.module("app").directive("scrollbarWidth",t).directive("scrollbarWidthElement",e).directive("scrollbarWidthContainer",n).directive("scrollbarWidthChild",o)}(),function(){"use strict";function t(){return{restrict:"A",link:function(t,e){e.after('<span class="Toggle-fakeCheckbox"></span>')}}}angular.module("app").directive("toggleCheckbox",t)}(),function(){"use strict";function t(t){function e(t){return t=angular.uppercase(t),t&&"NEW"!==t?"NEEDREVIEW"===t&&(t="NEEDSWORK"):t="UNTRANSLATED",t}function n(t){return t=angular.lowercase(t),t&&"untranslated"!==t?"needswork"===t?"NeedReview":t.charAt(0).toUpperCase()+t.slice(1).toLowerCase():"New"}var o=this,r={UNTRANSLATED:{ID:"untranslated",NAME:"Untranslated",CSSCLASS:"neutral"},NEEDSWORK:{ID:"needswork",NAME:"Needs Work",CSSCLASS:"unsure"},TRANSLATED:{ID:"translated",NAME:"Translated",CSSCLASS:"success"},APPROVED:{ID:"approved",NAME:"Approved",CSSCLASS:"highlight"}};return o.getAll=function(){return r},o.getAllAsArray=function(){return t.values(r)},o.getStatusInfo=function(t){return r[e(t)]},o.getId=function(t){return r[e(t)].ID},o.getServerId=function(t){return n(t)},o.getName=function(t){return r[e(t)].NAME},o.getCSSClass=function(t){return r[e(t)].CSSCLASS},o}t.$inject=["_"],angular.module("app").factory("TransStatusService",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a,c,s){function u(){l.selected||t.$apply(function(){i.emitEvent(i.EVENT.SELECT_TRANS_UNIT,{id:t.phrase.id,updateURL:!0,focus:!0},t)})}var l=this;return l.selected=!1,l.isTranslationModified=r.isTranslationModified,l.focusTranslation=function(){c("phrase-"+t.phrase.id)},l.translationTextModified=function(t){i.emitEvent(i.EVENT.TRANSLATION_TEXT_MODIFIED,t)},l.getPhrase=function(){return t.phrase},l.init=function(){r.addController(t.phrase.id,l),n.id&&parseInt(n.id)===t.phrase.id&&i.emitEvent(i.EVENT.SELECT_TRANS_UNIT,{id:n.id,updateURL:!1,focus:n.selected},null)},l.copySource=function(e,n){e.stopPropagation(),i.emitEvent(i.EVENT.COPY_FROM_SOURCE,n,t)},l.undoEdit=function(e,n){e.stopPropagation(),i.emitEvent(i.EVENT.UNDO_EDIT,n,t)},l.cancelEdit=function(e,n){e.stopPropagation(),i.emitEvent(i.EVENT.CANCEL_EDIT,n,t)},l.saveAs=function(e,o,r){i.emitEvent(i.EVENT.SAVE_TRANSLATION,{phrase:o,status:r,locale:n.localeId,docId:n.docId},t)},l.getLocaleName=function(t){return a.getName(t)},l.toggleSaveAsOptions=function(e){i.broadcastEvent(e?"openDropdown":"closeDropdown",{},t)},l.cancelSaveAsMode=function(){s.cancelSaveAsModeIfOn()},t.$on("$destroy",function(){e.unbind("click",u),e.unbind("focus",u)}),l.updateSaveButton=function(e){l.saveButtonStatus=r.getSaveButtonStatus(t.phrase),l.saveButtonOptions=r.getSaveButtonOptions(l.saveButtonStatus),l.saveButtonText=l.saveButtonStatus.NAME,l.saveButtonDisabled=!r.isTranslationModified(e),l.loadingClass="",l.savingStatus=""},l.phraseSaving=function(t){l.loadingClass="is-loading",l.saveButtonStatus=l.savingStatus=t.status,l.saveButtonOptions=r.getSaveButtonOptions(l.saveButtonStatus),l.saveButtonText="Saving…",l.saveButtonDisabled=!0},l.saveButtonOptionsAvailable=function(){return!o.isEmpty(l.saveButtonOptions)},l.selectTransUnit=function(e){i.emitEvent(i.EVENT.SELECT_TRANS_UNIT,{id:e.id,updateURL:!0,focus:!0},t)},l}t.$inject=["$scope","$element","$stateParams","_","TransUnitService","EventService","LocaleService","focus","EditorShortcuts"],angular.module("app").controller("TransUnitCtrl",t)}(),function(){"use strict";function t(t,e,n,o,r,i,a,c,s,u,l,d){function f(t,e){t.newTranslation=e,a.emitEvent(a.EVENT.TRANSLATION_TEXT_MODIFIED,t),a.emitEvent(a.EVENT.FOCUS_TRANSLATION,t)}function p(t,e){var n=N[e.id];n.updateSaveButton(e)}function E(t,e){var n=N[e.phrase.id];n.phraseSaving(e),a.emitEvent(a.EVENT.FOCUS_TRANSLATION,e.phrase)}function g(t,e){t.selected=e||!1}function S(t,e){var n=N[e.id];n.focusTranslation()}function T(t){var e=[];return"untranslated"===t.ID?[]:(e=r("filter")(c.getAllAsArray(),{ID:"!untranslated"}),s&&(e=r("filter")(e,{ID:"!approved"})),r("filter")(e,{ID:"!"+t.ID}))}function v(t){var e=N[t.currentId].getPhrase();O.isTranslationModified(e)&&a.emitEvent(a.EVENT.SAVE_TRANSLATION,{phrase:e,status:c.getStatusInfo("TRANSLATED"),locale:t.localeId,docId:t.docId}),a.emitEvent(a.EVENT.CANCEL_EDIT,e)}function I(t,e){u.findNextId(e.currentId).then(function(t){t!==e.currentId?a.emitEvent(a.EVENT.SELECT_TRANS_UNIT,{id:t,updateURL:!0,focus:!0},null):v(e)})}function h(t,e){u.findPreviousId(e.currentId).then(function(t){t!==e.currentId?a.emitEvent(a.EVENT.SELECT_TRANS_UNIT,{id:t,updateURL:!0,focus:!0},null):v(e)})}function m(t,e){u.findNextStatus(e.currentId,"untranslated").then(function(t){t!==e.currentId?a.emitEvent(a.EVENT.SELECT_TRANS_UNIT,{id:t,updateURL:!0,focus:!0},null):v(e)})}var A,O=this,N={};return O.addController=function(t,e){N[t]=e},O.isTranslationModified=function(t){return t.newTranslation!==t.translation},O.getSaveButtonStatus=function(t){return""===t.newTranslation?c.getStatusInfo("untranslated"):t.translation!==t.newTranslation?c.getStatusInfo("translated"):t.status},O.getSaveButtonOptions=function(t){return T(t)},e.$on(a.EVENT.TOGGLE_SAVE_OPTIONS,function(t,e){var n=N[e.id];
n&&n.toggleSaveAsOptions(e.open)}),e.$on(a.EVENT.SELECT_TRANS_UNIT,function(e,r){var s=N[r.id],u=N[A],d=r.updateURL;s?(l.selectedTUCtrl=s,A&&A!==r.id&&(O.isTranslationModified(u.getPhrase())&&a.emitEvent(a.EVENT.SAVE_TRANSLATION,{phrase:u.getPhrase(),status:c.getStatusInfo("TRANSLATED"),locale:o.localeId,docId:o.docId}),g(u,!1)),p(e,s.getPhrase()),A=r.id,g(s,!0),a.emitEvent(a.EVENT.FOCUS_TRANSLATION,r),d&&("editor.selectedContext.tu"!==n.current.name?n.go("editor.selectedContext.tu",{id:r.id,selected:r.focus.toString()}):(t.search("id",r.id),t.search("selected",r.focus.toString())))):i.displayWarning("Trans-unit not found:"+r.id)}),e.$on(a.EVENT.COPY_FROM_SOURCE,function(t,e){f(e,e.source)}),e.$on(a.EVENT.UNDO_EDIT,function(t,e){O.isTranslationModified(e)&&f(e,e.translation)}),e.$on(a.EVENT.CANCEL_EDIT,function(n,o){A&&(g(N[A],!1),A=!1,l.selectedTUCtrl=null),t.search("selected",null),o||t.search("id",null),d(function(){return e.$broadcast("blurOn","phrase-"+o.id)})}),e.$on(a.EVENT.TRANSLATION_TEXT_MODIFIED,p),e.$on(a.EVENT.FOCUS_TRANSLATION,S),e.$on(a.EVENT.SAVE_INITIATED,E),e.$on(a.EVENT.GOTO_NEXT_ROW,I),e.$on(a.EVENT.GOTO_PREVIOUS_ROW,h),e.$on(a.EVENT.GOTO_NEXT_UNTRANSLATED,m),e.$on(a.EVENT.SAVE_COMPLETED,p),O}t.$inject=["$location","$rootScope","$state","$stateParams","$filter","MessageHandler","EventService","TransStatusService","PRODUCTION","PhraseService","EditorShortcuts","$timeout"],angular.module("app").factory("TransUnitService",t)}(),function(){"use strict";function t(){return{restrict:"E",required:["phrase","editorContext"],scope:{phrase:"=",firstPhrase:"=",editorContext:"="},controller:"TransUnitCtrl as transUnitCtrl",templateUrl:"components/transUnit/trans-unit.html",link:function(t,e,n,o){o.init()}}}angular.module("app").directive("transUnit",t)}(),function(){"use strict";function t(t,e){function n(n){var o=t(e.USER_INFO_URL,{},{query:{method:"GET",params:{username:n}}});return o.query().$promise}function o(){var n=t(e.MY_INFO_URL,{},{query:{method:"GET"}});return n.query().$promise}return{settings:{editor:{hideMainNav:!1}},getUserInfo:n,getMyInfo:o}}t.$inject=["$resource","UrlService"],angular.module("app").factory("UserService",t)}(),function(){"use strict";function t(t,e){function n(t,n,o){return t&&n&&o?e.filter(t,function(t){return i(t,n,o)}):t}function o(t){var e={},n=Object.keys(t).filter(function(t){return-1===t.indexOf("$")});return n.forEach(function(n){e[n]=t[n]}),e}function r(t){var e=[],n=Object.keys(t).filter(function(t){return-1===t.indexOf("$")});return n.forEach(function(n){e.push(t[n])}),e}function i(n,o,r){return n&&o&&r?e.any(o,function(o){return e.any(r,function(e){return t.equals(n[o],e,!0)})}):!1}return{filterResources:n,cleanResourceList:r,cleanResourceMap:o}}t.$inject=["StringUtil","_"],angular.module("app").factory("FilterUtil",t)}(),function(){"use strict";function t(){return{getWordStatistic:function(t){return"WORD"===t[0].unit?t[0]:t[1]},getMsgStatistic:function(t){return"MESSAGE"===t[0].unit?t[0]:t[1]}}}angular.module("app").factory("StatisticUtil",t)}(),function(){"use strict";function t(){function t(t,e,n){return n&&t&&e&&(t=t.toUpperCase(),e=e.toUpperCase()),0===t.lastIndexOf(e,0)}function e(t,e,n){return n&&t&&e&&(t=t.toUpperCase(),e=e.toUpperCase()),-1!==t.indexOf(e,t.length-e.length)}function n(t,e,n){return n&&t&&e&&(t=t.toUpperCase(),e=e.toUpperCase()),t===e}return{startsWith:t,endsWith:e,equals:n}}angular.module("app").factory("StringUtil",t)}(),function(){"use strict";function t(t,e,n,o,r){function i(){return l+Array.prototype.join.call(arguments,"")}function a(t){return function(e){return t(e)}}location.origin||(location.origin=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:""));var c=this,s="http://www.gravatar.com/avatar",u="config.json",l="",d={},f=location.origin+location.pathname+"translations";return c.serverContextPath="",c.init=function(){return l?n.when(l):e.get(u).then(function(t){var e=t.data;if(e.baseUrl)l=e.baseUrl;else{var n=e.appPath.replace(/^\//g,""),o=location.href.indexOf(n);c.serverContextPath=location.origin+location.pathname,o>=0&&(c.serverContextPath=location.href.substring(0,o)),c.serverContextPath=c.serverContextPath.replace(/\/?$/,"/"),l=c.serverContextPath+"rest"}d=r.mapValues({project:"/project/:projectSlug",docs:"/project/:projectSlug/version/:versionSlug/docs",locales:"/project/:projectSlug/version/:versionSlug/locales",status:"/project/:projectSlug/version/:versionSlug/doc/:docId/status/:localeId",textFlows:"/source+trans/:localeId",docStats:"/stats/project/:projectSlug/version/:versionSlug/doc/:docId/locale/:localeId",myInfo:"/user",userInfo:"/user/:username",translation:"/trans/:localeId",allLocales:"/locales"},a(i)),c.PROJECT_URL=d.project,c.LOCALE_LIST_URL=d.locales,c.DOCUMENT_LIST_URL=d.docs,c.TRANSLATION_STATUS_URL=d.status,c.TEXT_FLOWS_URL=d.textFlows,c.DOC_STATISTIC_URL=d.docStats,c.MY_INFO_URL=d.myInfo,c.USER_INFO_URL=d.userInfo,c.TRANSLATION_URL=d.translation,c.ALL_LOCALE_URL=d.allLocales,c.PROJECT_PAGE=function(t,e){return c.serverContextPath+"iteration/view/"+t+"/"+e},c.DASHBOARD_PAGE=c.serverContextPath+"dashboard"})},c.readValue=function(e){return t.search()[e]},c.gravatarUrl=function(t,e){return s+"/"+t+"?d=mm&r=g&s="+e},c.uiTranslationURL=function(t){return f+"/"+t+".json"},c.uiTranslationListURL=f+"/locales",c}t.$inject=["$location","$http","$q","$stateParams","_"],angular.module("app").factory("UrlService",t)}();
//# sourceMappingURL=../maps/app.js.map