1 line
274 KiB
Plaintext
1 line
274 KiB
Plaintext
{"version":3,"sources":["Common/utils.js","Common/Common.app.js","Common/mdColors.app.js","Common/decodeUri.filter.js","Common/encodeUri.filter.js","Common/ensureTarget.filter.js","Common/ln2br.filter.js","Common/loc.filter.js","Common/range.filter.js","Common/AclController.js","Common/navController.js","Common/Acl.service.js","Common/Alarm.service.js","Common/Authentication.service.js","Common/Dialog.service.js","Common/Gravatar.service.js","Common/Resource.service.js","Common/sgFocus.service.js","Common/sgHotkeys.service.js","Common/User.service.js","Common/sgAvatarImage.directive.js","Common/sgCheckmark.directive.js","Common/sgColorPicker.directive.js","Common/sgCompile.directive.js","Common/sgDatepickerReadonlyInput.directive.js","Common/sgDraggable.directive.js","Common/sgDroppable.directive.js","Common/sgEnter.directive.js","Common/sgEscape.directive.js","Common/sgFocus.directive.js","Common/sgFolderStylesheet.directive.js","Common/sgPlaceholder.directive.js","Common/sgResetOnDisabled.directive.js","Common/sgRippleClick.directive.js","Common/sgSearch.directive.js","Common/sgSelectOnly.directive.js","Common/sgSubscribe.directive.js","Common/sgTimepicker.directive.js","Common/sgToggleGrid.directive.js","Common/sgTransformOnBlur.directive.js"],"names":["l","i","j","key","arguments","value","args","labels","clabels","length","replace","m","val","parseFloat","isNaN","hexToRgb","hex","result","exec","r","parseInt","g","b","contrast","color","c","Math","pow","guid","S4","random","toString","substring","substr","toLowerCase","configure","$logProvider","$compileProvider","$httpProvider","$mdThemingProvider","$mdAriaProvider","definePalette","50","100","200","300","400","500","600","700","800","900","A100","A200","A400","A700","contrastDefaultColor","contrastLightColors","contrastDarkColors","1000","theme","primaryPalette","default","hue-1","hue-2","hue-3","accentPalette","backgroundPalette","DebugEnabled","debugEnabled","debugInfoEnabled","disableWarnings","generateThemesOnDemand","interceptors","push","AuthInterceptor","$window","$q","response","test","config","headers","Accept","data","location","reload","reject","ErrorInterceptor","$rootScope","responseError","rejection","$broadcast","angular","module","isPopup","document","body","classList","contains","baseURL","ApplicationBaseURL","resourcesURL","ResourcesURL","activeUser","param","settings","login","UserLogin","identification","UserIdentification","email","UserEmail","language","UserLanguage","folderURL","UserFolderURL","isSuperUser","IsSuperUser","path","calendar","UserCalendarPath","contacts","UserContactsPath","mail","UserMailPath","preferences","UserPreferencesPath","administration","UserAdministrationPath","help","HelpURL","logoff","UserLogoffPath","minimumSearchLength","isNumber","constant","selection","xs","gt-xs","sm","gt-sm","md","gt-md","lg","gt-lg","xl","print","factory","$inject","_$mdThemingProvider","runBlock","$interpolate","$document","$log","buildCssSelectors","selectors","join","addRule","fgInterpolate","bgInterpolate","themeName","paletteName","colorArray","hueName","colorValue","colorContrast","context","palette","hue","customSheet","insertRule","index","addBorderRule","bdrInterpolate","getStyleSheet","style","head","querySelector","createElement","title","appendChild","createTextNode","sheet","fgDefault","bgDefault","bdrDefault","fgDefaultHue","bgDefaultHue","fgColor","bgColor","bdrColor","fgHue","bgHue","cssRules","deleteRule","forEach","_THEMES","_PALETTES","colors","primary","name","hues","run","decodeUri","decodeURIComponent","filter","encodeUri","encodeURIComponent","ensureTarget","$sce","element","tree","find","attr","trustAs","html","ln2br","text","String","undefined","loc","range","n","res","AclController","$timeout","$mdDialog","Dialog","usersWithACL","User","folder","userFilter","$query","$filter","$acl","users","closeModal","$resetUsersRights","hide","saveModal","$saveUsersRights","then","status","alert","confirmChange","user","confirmation","$confirmRights","vm","showing","message","removeUser","$removeUser","uid","addUser","$addUser","userToAdd","searchText","selectedUid","selectUser","selectAllRights","$selectAllRights","$event","target","parentNode","selectedUser","$rights","this","controller","navController","$scope","$interval","$http","$mdSidenav","$mdToast","$mdMedia","sgConstant","sgSettings","Alarm","leftIsClose","isOpen","onHttpError","event","isString","statusText","show","template","hideDelay","position","debug","centerIsClose","currentDay","window","get","secondsBeforeTomorrow","toggleLeft","isGtMedium","triggerHandler","toggle","toggleRight","toggleCenter","$watch","newVal","$on","getAlarms","Acl","folderId","Settings","Resource","extend","$$resource","$User","prototype","$users","owner","_this","deferred","defer","acls","isDefined","userResource","fetch","canSubscribeUser","isSubscribed","wasSubscribed","bind","resolve","promise","_","indexOf","map","userClass","isGroup","$shadowRights","splice","rights","right","$resetRights","deferredSave","deferredSubscribe","action","$rightsAreDirty","$omit","save","copy","uids","all","currentAlarm","AlarmService","$toast","now","Date","browserTime","floor","getTime","alarms","sort","a","x","y","next","pop","utc","url","alarmTime","delay","f","showAlarm","cancel","AlarmController","scope","$sanitize","summary","reminder","ok","locals","Authentication","redirectUrl","username","domain","userName","address","baseAddress","altBaseAddress","parts","hostpart","protocol","newAddress","href","split","startsWith","endsWith","getService","$cookies","passwordPolicyConfig","readLoginCookie","loginValues","cookie","base64decode","service","d","password","rememberLogin","loginSuffix","method","loginCookie","expire","grace","cn","msg","perr","LDAPPasswordPolicyError","PolicyNoError","PolicyAccountLocked","error","changePassword","newPassword","xsrfCookie","remove","X-XSRF-TOKEN","PolicyPasswordModNotAllowed","PolicyInsufficientPasswordQuality","PolicyPasswordTooShort","PolicyPasswordTooYoung","PolicyPasswordInHistory","formatted","PolicyPasswordUnknown","PolicyPasswordSystemUnknown","put","$get","PolicyPasswordChangeUnsupported","PolicyPasswordExpired","PolicyChangeAfterReset","PolicyMustSupplyOldPassword","provider","DialogService","$modal","content","htmlContent","confirm","options","prompt","label","PromptDialogController","o","id","asCSSIdentifier","parent","clickOutsideToClose","escapeToClose","inputType","Gravatar","size","alternate_avatar","hash","s","md5","no_404","_http","_q","_path","_activeUser","$factory","compact","escape","params","flatten","newguid","create","post","newValue","download","getFileNameFromHeader","header","trim","type","accept","responseType","cache","transformResponse","fileName","blob","Blob","saveAs","Error","sgFocus","$sgHotkeys","wrapWithApply","fn","$apply","call","HotKey","description","callback","preventInClass","onKeyUp","lkey","clone","Hotkeys","_hotkeys","_hotkeysUp","_preventIn","_preventInClass","_onKeydown","_onKeyup","_onKeypress","initialize","registerHotkey","createHotkey","_toggleCheatSheet","addEventListener","_invokeHotkeyHandlers","keyString","hotkeys","hotkey","srcElement","nodeName","toUpperCase","includes","intersection","e","console","keyStringFromEvent","charCode","keyCode","which","CHAR_CODES","KEY_CODES","fromCharCode","ctrlKey","altKey","shiftKey","metaKey","uniq","_deregisterHotkey","ret","table","callbackArray","callbackData","deregisterHotkey","_validateHotkey","isArray","TypeError","_registerKey","_registerKeys","registerHotkeyUp","match","eventHotkey","Boolean","CheatSheetController","closeDialog","_cheatSheet","finally","8","9","13","16","17","18","19","20","27","32","33","34","35","36","37","38","39","40","45","46","96","97","98","99","101","102","103","104","105","106","107","109","110","111","112","113","114","115","116","117","118","119","120","121","122","123","42","63","sgHotkeys","userData","init","search","excludedUsers","dry","when","results","compareUids","isUndefined","$$shortFormat","$shortFormat","$$image","image","empty","fullname","c_email","no_email","$isAnonymous","$isSpecial","$confirmation","some","values","constructor","isEqual","zero","keys","$folders","$$folders","folders","sgAvatarImage","restrict","bindToController","src","link","controllerAs","attrs","imgElement","mdIconElement","css","img","genericImg","sgAvatarImageController","$element","Preferences","getGravatar","defaults","SOGoAlternateAvatar","urlEmail","hideGenericAvatar","showGenericAvatar","addClass","removeClass","configureZoomableAvatar","toggleZoomFcn","toggleClass","on","off","ready","old","SOGoGravatarEnabled","attributes","directive","sgCheckmarkDirective","$parse","$mdAria","$mdTheming","$mdUtil","compile","tElement","tAttrs","hasAttribute","stopImmediatePropagation","ngModelCtrl","parseConstantExpr","expression","fallback","parseFn","listener","ev","viewValue","$viewValue","trueValue","falseValue","$setViewValue","$render","render","CHECKED_CSS","sgTrueValue","sgFalseValue","fakeNgModel","expectWithText","transclude","require","sgColorPicker","iElement","iAttr","ngModelController","sgColor","sgIconColor","sgColorPickerController","sgColors","setColor","currentTarget","parentElement","children","tile","add","sgCompile","$compile","sgCompileLink","ensureCompileRunsOnce","$eval","contents","sgDatepickerReadonlyInput","postLink","datepickerCtrl","getInput","eq","input","prop","sgDraggable","sgDraggableObject","dragStart","count","helper","bindedOnDragDetect","onDragDetect","bindedOnDrag","onDrag","sgDragStart","sgDragCount","$destroy","dragHasStarted","getDistanceFromStart","delta","startPosition","clientX","clientY","sqrt","stopPropagation","one","onDragEnd","counter","$emit","top","pageY","left","pageX","sgDroppable","onEnter","overElement","onLeave","dropAction","droppable","deregisterFolderDragStart","deregisterFolderDragEnd","sgDrop","dragFolder","mode","dragMode","sgEnter","ENTER_KEY","preventDefault","sgEscape","ESCAPE_KEY","elem","sgFocusOn","focus","select","sgFolderStylesheet","sgFolderStylesheetController","ngModel","sgPlaceholder","placeholder","sgResetOnDisabled","isDisabled","$invalid","date","sgRippleClick","coordinates","getBoundingClientRect","container","overflow","scrollTop","ripple","offsetTop","offsetLeft","height","width","containerId","sgSearchPreTransclude","tAttr","inputEl","selectEl","buttonEl","removeAttr","compiledButtonEl","formName","inputName","allowDot","doSearch","cancelSearch","priority","sgSearch","append","sgSearchController","searchTextOptions","updateOn","debounce","blur","onChange","form","rawSearchText","$valid","$setValidity","searchField","sgSelectOnly","autoComplete","selectedItem","$applyAsync","sgSubscribe","folderType","onFolderSelect","sgSubscribeDialogController","showDialog","templateUrl","sgSubscribeController","$setTouched","selectFolder","folderData","close","timePaneDirective","TimePaneCtrl","controllers","sgTimePaneCtrl","mdInputContainer","configureNgModel","$$mdDateUtil","$mdConstant","$$rAF","$attrs","$mdDateLocale","dateUtil","KEY_CODE","timePaneElement","SELECTED_TIME_CLASS","FOCUSED_TIME_CLASS","nextUniqueId","displayTime","selectedTime","isInitialized","hours","displayName","selected","min5","min1","ii","show5min","getToggleBtnLbl","is5min","toggleManual5min","manual5min","tabindex","self","hourClickHandler","displayVal","updated","setHours","Number","setNgModelValue","minuteClickHandler","setMinutes","boundKeyHandler","handleKeyEvent","nextTick","changeSelectedTime","previousSelectedTime","prevH","getHours","prevHCell","getElementById","setAttribute","prevM","getMinutes","prevMCell","prevM5Cell","mCell","newH","hCell","newM","changed","ESCAPE","TAB","ENTER","opt_date","today","previousFocus","timePickerDirective","ariaLabelValue","ariaLabel","mdPlaceholder","TimePickerCtrl","mdTimePickerCtrl","parentForm","parseAttributeBoolean","mdNoAsterisk","parentSubmittedWatcher","$submitted","isSubmitted","updateErrorState","dateLocale","documentElement","inputElement","ngInputElement","inputContainer","timePane","timeButton","inputMask","isFocused","setDisabled","disabled","isTimeOpen","timePaneOpenedFrom","timePaneId","nextUid","bodyClickHandler","handleBodyClick","windowEventName","IS_MOBILE_REGEX","navigator","userAgent","vendor","opera","windowEventHandler","closeTimePane","windowBlurHandler","handleWindowBlur","leftMargin","topMargin","$set","installPropertyInterceptors","attachChangeListeners","attachInteractionListeners","detachTimePane","EXTRA_INPUT_SIZE","INVALID_CLASS","OPEN_CLASS","DEFAULT_DEBOUNCE_INTERVAL","TIME_PANE_HEIGHT","MIN5","GTXS","XS","MIN1","TIME_PANE_WIDTH","$formatters","time","formatTime","resizeInputElement","$viewChangeListeners","unshift","debounceInterval","handleInputEvent","keyCodes","DOWN_ARROW","openTimePane","$digest","ngDisabled","$parent","Object","defineProperty","set","clearErrorState","isValidDate","field","inputString","parsedTime","parseTime","isValidInput","attachTimePane","transform","elementRect","bodyRect","paneTop","paneLeft","viewportTop","viewportLeft","scrollLeft","viewportBottom","innerHeight","viewportRight","innerWidth","paneWidth","scale","min","paneHeight","enableScrolling","removeChild","disableScrollAround","evalAttr","removeEventListener","getTimePaneCtrl","focusTime","ctrl","setFocused","isInTime","getClosest","inputFocusedOnWindowBlur","activeElement","sgToggleGrid","flattenedDays","modelDays","sgToggleGridAttr","modelAttr","tiles","day","findIndex","$setDirty","sgTransformOnBlur","mdChipsCtrl","mouseUpActions","onInputBlur","appendFcn","inputHasFocus","chipBuffer","getChipBuffer","validateModel","isModelValid","userInputNgModelCtrl","appendChip","resetChipBuffer","autocompleteCtrl","suffix","pattern","lastIndexOf","_base64_keyStr","base64encode","chr1","chr2","chr3","enc1","enc2","enc3","enc4","output","utf8encode","charCodeAt","charAt","L","k","K","G","I","F","H","q","p","u","aa","Z","D","t","Array","B","J","P","h","E","v","Y","X","W","V","C","S","Q","N","M","A","z","w","U","T","R","O","capitalize","slice","asDate","newDate","newString","isValidEmail","emailRE","characters","escapeds","re","RegExp","timeInterval","interval","parseDate","localeProvider","format","string","formattingTokens","tokens","token","regexes","parsedInput","matchesCount","year","getYear","month","getMonth","getDate","hour","minute","%d","%e","%m","%b","shortMonths","toLower","%B","months","%y","nearFuture","getFullYear","%Y","%H","%I","%M","%p","linput","am","pm","NaN","daysUpTo","otherDate","days","day1","day2","tmp","nbrDays","round","setTime","minutesTo","dstOffset","valueOf","getTimezoneOffset","stringWithSeparator","separator","str","addDays","initialDate","milliSeconds","addHours","nbrHours","addMinutes","nbrMinutes","beginOfDay","setSeconds","setMilliseconds","firstWeekOfYearForDate","firstWeekRule","dayOfWeek","januaryFirst","firstWeek","firstWeekOfYear","setMonth","setDate","getDay","firstDayOfWeek","beginOfWeek","getWeek","previousWeek","weekNumber","offset","endOfWeek","getDayString","getHourString","separators","max","validParts","%a","shortDays","%A","%U","shift"],"mappings":"AA0dA,QAASA,KACP,GAAuDC,GAAGC,EAAtDC,EAAMC,UAAU,GAAIC,EAAQF,EAAKG,EAAOF,SAW5C,KARIG,OAAOJ,GACTE,EAAQE,OAAOJ,GAERK,QAAQL,KACfE,EAAQG,QAAQL,IAIbF,EAAI,EAAGC,EAAI,EAAGD,EAAIK,EAAKG,OAAQR,IAAKC,IACvCG,EAAQA,EAAMK,QAAQ,KAAOR,EAAI,IAAKI,EAAKL,GA4B7C,OAxBAA,GAAI,EACAK,EAAKG,OAAS,IAChBJ,EAAQA,EAAMK,QAAQ,cAAe,SAASC,GAE5C,GAAIC,GAAM,IACV,IAAID,EAAE,GACJC,EAAMD,EAAE,OAEL,CAGH,OAFAC,EAAMN,EAAKL,GAEHU,GACR,IAAK,KACHC,EAAMC,WAAWD,GACbE,MAAMF,KACRA,EAAM,GAGVX,IAEF,MAAOW,MAIJP,EAGT,QAASU,UAASC,GAChB,GAAIC,GAAS,4CAA4CC,KAAKF,EAC9D,OAAOC,IACLE,EAAGC,SAASH,EAAO,GAAI,IACvBI,EAAGD,SAASH,EAA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KAAMv5B,KAAK04B,QAAQzE,GACnB4B,KAAM71B,KAAKqmB,WACX0P,KAAM/1B,KAAK0mB,aAajB,KAZAz2B,EAAI,MAAQA,EAAI,MAAQ,GAAKA,EAAI,MAAQ,GAAKA,EAAI,MAClDA,EAAI,MAAyBZ,EAAjBY,EAAI,MAAQ,GAAO,KAAU,MAEzCA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAC9CA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAC9CA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAC9CA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAC9CA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAC9CA,EAAI,OAASA,EAAI,MAAQ,GAAK,IAAM,IAAMA,EAAI,MAE9CgpC,EAAa/E,EAAOnkC,QAAQopC,EAAY,MAAMzxB,MAAM,MACpDL,EAAQ6sB,EAAO3iB,MAAM4nB,GAChB7pC,EAAI,EAAG4pC,EAAM7xB,EAAMvX,OAAQR,GAAK4pC,EAAK5pC,IACpC2pC,EAAWnpC,QACbkwB,EAAKjsB,KAAKklC,EAAWO,SACvBxZ,EAAKjsB,KAAK9D,EAAIoX,EAAM/X,IAGtB,OAAO0wB,GAAK/mB,KAAK","file":"Common.js","sourcesContent":["/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\nString.prototype.endsWith = function(suffix) {\n return this.indexOf(suffix, this.length - suffix.length) !== -1;\n};\n\nString.prototype.startsWith = function(pattern, position) {\n position = angular.isNumber(position) ? position : 0;\n return this.lastIndexOf(pattern, position) === position;\n};\n\nString.prototype._base64_keyStr = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\nString.prototype.base64encode = function () {\n var output = \"\";\n var chr1, chr2, chr3, enc1, enc2, enc3, enc4;\n var i = 0;\n \n var input = this.utf8encode();\n\n while (i < input.length) {\n chr1 = input.charCodeAt(i++);\n chr2 = input.charCodeAt(i++);\n chr3 = input.charCodeAt(i++);\n \n enc1 = chr1 >> 2;\n enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);\n enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);\n enc4 = chr3 & 63;\n \n if (isNaN(chr2)) {\n enc3 = enc4 = 64;\n } else if (isNaN(chr3)) {\n enc4 = 64;\n }\n \n output = output +\n this._base64_keyStr.charAt(enc1) + this._base64_keyStr.charAt(enc2) +\n this._base64_keyStr.charAt(enc3) + this._base64_keyStr.charAt(enc4);\n }\n \n return output;\n};\n\nString.prototype.base64decode = function() { \n var output = \"\";\n var chr1, chr2, chr3;\n var enc1, enc2, enc3, enc4;\n var i = 0;\n \n var input = \"\" + this; // .replace(/[^A-Za-z0-9\\+\\/\\=]/g, \"\")\n while (i < input.length) {\n enc1 = this._base64_keyStr.indexOf(input.charAt(i++));\n enc2 = this._base64_keyStr.indexOf(input.charAt(i++));\n enc3 = this._base64_keyStr.indexOf(input.charAt(i++));\n enc4 = this._base64_keyStr.indexOf(input.charAt(i++));\n\n chr1 = (enc1 << 2) | (enc2 >> 4);\n chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);\n chr3 = ((enc3 & 3) << 6) | enc4;\n \n output = output + String.fromCharCode(chr1);\n \n if (enc3 != 64) {\n output = output + String.fromCharCode(chr2);\n }\n if (enc4 != 64) {\n output = output + String.fromCharCode(chr3);\n }\n }\n\n return output;\n};\n\nString.prototype.md5 = function() {\n if (!this.length) { return; }\n // MD5 (Message-Digest Algorithm) by WebToolkit\n var md5 = function(s){function L(k,d){return(k<<d)|(k>>>(32-d));}function K(G,k){var I,d,F,H,x;F=(G&2147483648);H=(k&2147483648);I=(G&1073741824);d=(k&1073741824);x=(G&1073741823)+(k&1073741823);if(I&d){return(x^2147483648^F^H);}if(I|d){if(x&1073741824){return(x^3221225472^F^H);}else{return(x^1073741824^F^H);}}else{return(x^F^H);}}function r(d,F,k){return(d&F)|((~d)&k);}function q(d,F,k){return(d&k)|(F&(~k));}function p(d,F,k){return(d^F^k);}function n(d,F,k){return(F^(d|(~k)));}function u(G,F,aa,Z,k,H,I){G=K(G,K(K(r(F,aa,Z),k),I));return K(L(G,H),F);}function f(G,F,aa,Z,k,H,I){G=K(G,K(K(q(F,aa,Z),k),I));return K(L(G,H),F);}function D(G,F,aa,Z,k,H,I){G=K(G,K(K(p(F,aa,Z),k),I));return K(L(G,H),F);}function t(G,F,aa,Z,k,H,I){G=K(G,K(K(n(F,aa,Z),k),I));return K(L(G,H),F);}function e(G){var Z;var F=G.length;var x=F+8;var k=(x-(x%64))/64;var I=(k+1)*16;var aa=Array(I-1);var d=0;var H=0;while(H<F){Z=(H-(H%4))/4;d=(H%4)*8;aa[Z]=(aa[Z]|(G.charCodeAt(H)<<d));H++;}Z=(H-(H%4))/4;d=(H%4)*8;aa[Z]=aa[Z]|(128<<d);aa[I-2]=F<<3;aa[I-1]=F>>>29;return aa;}function B(x){var k=\"\",F=\"\",G,d;for(d=0;d<=3;d++){G=(x>>>(d*8))&255;F=\"0\"+G.toString(16);k=k+F.substr(F.length-2,2);}return k;}function J(k){k=k.replace(/rn/g,\"n\");var d=\"\";for(var F=0;F<k.length;F++){var x=k.charCodeAt(F);if(x<128){d+=String.fromCharCode(x);}else{if((x>127)&&(x<2048)){d+=String.fromCharCode((x>>6)|192);d+=String.fromCharCode((x&63)|128);}else{d+=String.fromCharCode((x>>12)|224);d+=String.fromCharCode(((x>>6)&63)|128);d+=String.fromCharCode((x&63)|128);}}}return d;}var C=Array();var P,h,E,v,g,Y,X,W,V;var S=7,Q=12,N=17,M=22;var A=5,z=9,y=14,w=20;var o=4,m=11,l=16,j=23;var U=6,T=10,R=15,O=21;s=J(s);C=e(s);Y=1732584193;X=4023233417;W=2562383102;V=271733878;for(P=0;P<C.length;P+=16){h=Y;E=X;v=W;g=V;Y=u(Y,X,W,V,C[P+0],S,3614090360);V=u(V,Y,X,W,C[P+1],Q,3905402710);W=u(W,V,Y,X,C[P+2],N,606105819);X=u(X,W,V,Y,C[P+3],M,3250441966);Y=u(Y,X,W,V,C[P+4],S,4118548399);V=u(V,Y,X,W,C[P+5],Q,1200080426);W=u(W,V,Y,X,C[P+6],N,2821735955);X=u(X,W,V,Y,C[P+7],M,4249261313);Y=u(Y,X,W,V,C[P+8],S,1770035416);V=u(V,Y,X,W,C[P+9],Q,2336552879);W=u(W,V,Y,X,C[P+10],N,4294925233);X=u(X,W,V,Y,C[P+11],M,2304563134);Y=u(Y,X,W,V,C[P+12],S,1804603682);V=u(V,Y,X,W,C[P+13],Q,4254626195);W=u(W,V,Y,X,C[P+14],N,2792965006);X=u(X,W,V,Y,C[P+15],M,1236535329);Y=f(Y,X,W,V,C[P+1],A,4129170786);V=f(V,Y,X,W,C[P+6],z,3225465664);W=f(W,V,Y,X,C[P+11],y,643717713);X=f(X,W,V,Y,C[P+0],w,3921069994);Y=f(Y,X,W,V,C[P+5],A,3593408605);V=f(V,Y,X,W,C[P+10],z,38016083);W=f(W,V,Y,X,C[P+15],y,3634488961);X=f(X,W,V,Y,C[P+4],w,3889429448);Y=f(Y,X,W,V,C[P+9],A,568446438);V=f(V,Y,X,W,C[P+14],z,3275163606);W=f(W,V,Y,X,C[P+3],y,4107603335);X=f(X,W,V,Y,C[P+8],w,1163531501);Y=f(Y,X,W,V,C[P+13],A,2850285829);V=f(V,Y,X,W,C[P+2],z,4243563512);W=f(W,V,Y,X,C[P+7],y,1735328473);X=f(X,W,V,Y,C[P+12],w,2368359562);Y=D(Y,X,W,V,C[P+5],o,4294588738);V=D(V,Y,X,W,C[P+8],m,2272392833);W=D(W,V,Y,X,C[P+11],l,1839030562);X=D(X,W,V,Y,C[P+14],j,4259657740);Y=D(Y,X,W,V,C[P+1],o,2763975236);V=D(V,Y,X,W,C[P+4],m,1272893353);W=D(W,V,Y,X,C[P+7],l,4139469664);X=D(X,W,V,Y,C[P+10],j,3200236656);Y=D(Y,X,W,V,C[P+13],o,681279174);V=D(V,Y,X,W,C[P+0],m,3936430074);W=D(W,V,Y,X,C[P+3],l,3572445317);X=D(X,W,V,Y,C[P+6],j,76029189);Y=D(Y,X,W,V,C[P+9],o,3654602809);V=D(V,Y,X,W,C[P+12],m,3873151461);W=D(W,V,Y,X,C[P+15],l,530742520);X=D(X,W,V,Y,C[P+2],j,3299628645);Y=t(Y,X,W,V,C[P+0],U,4096336452);V=t(V,Y,X,W,C[P+7],T,1126891415);W=t(W,V,Y,X,C[P+14],R,2878612391);X=t(X,W,V,Y,C[P+5],O,4237533241);Y=t(Y,X,W,V,C[P+12],U,1700485571);V=t(V,Y,X,W,C[P+3],T,2399980690);W=t(W,V,Y,X,C[P+10],R,4293915773);X=t(X,W,V,Y,C[P+1],O,2240044497);Y=t(Y,X,W,V,C[P+8],U,1873313359);V=t(V,Y,X,W,C[P+15],T,4264355552);W=t(W,V,Y,X,C[P+6],R,2734768916);X=t(X,W,V,Y,C[P+13],O,1309151649);Y=t(Y,X,W,V,C[P+4],U,4149444226);V=t(V,Y,X,W,C[P+11],T,3174756917);W=t(W,V,Y,X,C[P+2],R,718787259);X=t(X,W,V,Y,C[P+9],O,3951481745);Y=K(Y,h);X=K(X,E);W=K(W,v);V=K(V,g);}var i=B(Y)+B(X)+B(W)+B(V);return i.toLowerCase();};\n return md5(this.toLowerCase());\n};\n\nString.prototype.capitalize = function() {\n return this.charAt(0).toUpperCase() + this.slice(1);\n};\n\nString.prototype.asDate = function () {\n var newDate;\n var date = this.split(\"/\");\n if (date.length == 3)\n newDate = new Date(date[2], date[1] - 1, date[0]); // dd/mm/yyyy\n else {\n date = this.split(\"-\");\n if (date.length == 3)\n newDate = new Date(date[0], date[1] - 1, date[2]); // yyyy-mm-dd\n else {\n if (this.length == 8) {\n newDate = new Date(this.substring(0, 4),\n this.substring(4, 6) - 1,\n this.substring(6, 8)); // yyyymmdd\n }\n }\n }\n\n return newDate;\n};\n\nString.prototype.formatted = function() {\n var newString = this;\n\n for (var i = 0; i < arguments.length; i++) {\n newString = newString.replace(\"%{\" + i + \"}\", arguments[i], \"g\");\n }\n\n return newString;\n};\n\nString.prototype.isValidEmail = function() {\n var emailRE = /^([\\w\\!\\#$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+\\.)*[\\w\\!\\#$\\%\\&\\'\\*\\+\\-\\/\\=\\?\\^\\`{\\|\\}\\~]+@((((([a-z0-9]{1}[a-z0-9\\-]{0,62}[a-z0-9]{1})|[a-z])\\.)+[a-z]{2,})|(\\d{1,3}\\.){3}\\d{1,3}(\\:\\d{1,5})?)$/i;\n return emailRE.test(this);\n};\n\nString.prototype.asCSSIdentifier = function() {\n var characters = [ '_' , '\\\\.', '#' , '@' , '\\\\*', ':' , ',' , ' ', \"'\", '&', '\\\\+' ];\n var escapeds = [ '_U_', '_D_', '_H_', '_A_', '_S_', '_C_', '_CO_', '_SP_', '_SQ_', '_AM_', '_P_' ];\n\n var newString = this;\n for (var i = 0; i < characters.length; i++) {\n var re = new RegExp(characters[i], 'g');\n newString = newString.replace(re, escapeds[i]);\n }\n\n if (/^\\d+/.test(newString)) {\n newString = '_' + newString;\n }\n\n return newString;\n};\n\nString.prototype.timeInterval = function () {\n var interval;\n if (this == \"once_per_hour\")\n interval = 3600;\n else if (this == \"every_minute\")\n interval = 60;\n else {\n interval = parseInt(this.substr(6)) * 60;\n }\n\n return interval;\n};\n\nString.prototype.parseDate = function(localeProvider, format) {\n var string, formattingTokens, tokens, token, now, date, regexes, i, parsedInput, matchesCount;\n\n string = '' + this;\n formattingTokens = /%[dembByYHIMp]/g;\n now = new Date();\n date = {\n year: now.getYear() + 1900,\n month: now.getMonth(),\n day: now.getDate(),\n hour: 0,\n minute: 0\n };\n regexes = {\n '%d': [/\\d\\d/, function(input) {\n date.day = parseInt(input);\n return (date.day < 32);\n }],\n '%e': [/ ?\\d?\\d/, function(input) {\n date.day = parseInt(input);\n return (date.day < 32);\n }],\n '%m': [/\\d\\d/, function(input) {\n date.month = parseInt(input) - 1;\n return (date.month < 12);\n }],\n '%b': [/[^\\d\\s\\.\\/\\-]{2,}/, function(input) {\n var i = _.indexOf(_.map(localeProvider.shortMonths, _.toLower), _.toLower(input));\n if (i >= 0)\n date.month = i;\n return (i >= 0);\n }],\n '%B': [/[^\\d\\s\\.\\/\\-]{2,}/, function(input) {\n var i = _.indexOf(_.map(localeProvider.months, _.toLower), _.toLower(input));\n if (i >= 0)\n date.month = i;\n return (i >= 0);\n }],\n '%y': [/\\d\\d/, function(input) {\n var nearFuture = parseInt(now.getFullYear().toString().substring(2)) + 5;\n date.year = parseInt(input);\n if (date.year < nearFuture) date.year += 2000;\n else date.year += 1900;\n return true;\n }],\n '%Y': [/[12]\\d\\d\\d/, function(input) {\n date.year = parseInt(input);\n return true;\n }],\n '%H': [/\\d{1,2}/, function(input) {\n date.hour = parseInt(input);\n return (date.hour < 24);\n }],\n '%I': [/\\d{1,2}/, function(input) {\n date.hour = parseInt(input);\n return (date.hour <= 12);\n }],\n '%M': [/[0-5]\\d/, function(input) {\n date.minute = parseInt(input);\n return (date.minute < 60 );\n }],\n '%p': [/[^\\d\\s\\/\\-]+/, function(input) {\n var linput = _.toLower(input), am = _.toLower(l('AM')), pm = _.toLower(l('PM'));\n if (linput == pm)\n date.hour += 12;\n return (linput == am || linput == pm);\n }],\n };\n tokens = format.match(formattingTokens) || [];\n matchesCount = 0;\n\n for (i = 0; i < tokens.length; i++) {\n token = tokens[i];\n parsedInput = (string.match(regexes[token][0]) || [])[0];\n if (parsedInput) {\n string = string.slice(string.indexOf(parsedInput) + parsedInput.length);\n if (regexes[token][1](parsedInput))\n matchesCount++;\n }\n }\n\n if (tokens.length === matchesCount) {\n // console.debug(this + ' + ' + format + ' = ' + JSON.stringify(date));\n return new Date(date.year, date.month, date.day, date.hour, date.minute);\n }\n else\n return new Date(NaN);\n};\n\nDate.prototype.daysUpTo = function(otherDate) {\n var days = [];\n\n var day1 = this.getTime();\n var day2 = otherDate.getTime();\n if (day1 > day2) {\n var tmp = day1;\n day1 = day2;\n day2 = tmp;\n }\n\n var nbrDays = Math.round((day2 - day1) / 86400000) + 1;\n for (var i = 0; i < nbrDays; i++) {\n var newDate = new Date();\n newDate.setTime(day1 + (i * 86400000));\n days.push(newDate);\n }\n\n return days;\n};\n\nDate.prototype.minutesTo = function(otherDate) {\n var delta, dstOffset;\n\n delta = Math.floor(otherDate.valueOf() - this.valueOf())/1000/60;\n dstOffset = otherDate.getTimezoneOffset() - this.getTimezoneOffset();\n\n return delta - dstOffset;\n};\n\nDate.prototype.stringWithSeparator = function(separator) {\n var month = '' + (this.getMonth() + 1);\n var day = '' + this.getDate();\n var year = this.getYear();\n if (year < 1000)\n year = '' + (year + 1900);\n if (month.length == 1)\n month = '0' + month;\n if (day.length == 1)\n day = '0' + day;\n\n if (separator == '-')\n str = year + '-' + month + '-' + day;\n else\n str = day + '/' + month + '/' + year;\n\n return str;\n};\n\nDate.prototype.addDays = function(nbrDays) {\n var initialDate, milliSeconds, dstOffset;\n\n milliSeconds = this.getTime();\n initialDate = new Date(milliSeconds);\n milliSeconds += 86400000 * nbrDays;\n this.setTime(milliSeconds);\n\n dstOffset = this.getTimezoneOffset() - initialDate.getTimezoneOffset();\n if (dstOffset !== 0) {\n milliSeconds = this.getTime() + dstOffset*60*1000;\n this.setTime(milliSeconds);\n }\n\n return this;\n};\n\nDate.prototype.addHours = function(nbrHours) {\n var milliSeconds = this.getTime();\n milliSeconds += 3600000 * nbrHours;\n this.setTime(milliSeconds);\n};\n\nDate.prototype.addMinutes = function(nbrMinutes) {\n var milliSeconds = this.getTime();\n milliSeconds += 60000 * nbrMinutes;\n this.setTime(milliSeconds);\n};\n\nDate.prototype.beginOfDay = function() {\n var beginOfDay = new Date(this.getTime());\n beginOfDay.setHours(0);\n beginOfDay.setMinutes(0);\n beginOfDay.setSeconds(0);\n beginOfDay.setMilliseconds(0);\n\n return beginOfDay;\n};\n\n/**\n * See [SOGoUser firstWeekOfYearForDate:]\n */\nDate.prototype.firstWeekOfYearForDate = function(localeProvider) {\n var firstWeekRule, dayOfWeek, januaryFirst, firstWeek;\n\n firstWeekRule = localeProvider.firstWeekOfYear;\n\n januaryFirst = new Date(this.getTime());\n januaryFirst.setMonth(0);\n januaryFirst.setDate(1);\n dayOfWeek = januaryFirst.getDay();\n\n if (firstWeekRule == 'First4DayWeek') {\n if ((dayOfWeek + localeProvider.firstDayOfWeek) % 7 < 4)\n firstWeek = januaryFirst.beginOfWeek(localeProvider.firstDayOfWeek);\n else\n firstWeek = januaryFirst.addDays(7).beginOfWeek(localeProvider.firstDayOfWeek);\n }\n else if (firstWeekRule == 'FirstFullWeek') {\n if (dayOfWeek === 0)\n firstWeek = januaryFirst.beginOfWeek(localeProvider.firstDayOfWeek);\n else\n firstWeek = januaryFirst.addDays(7).beginOfWeek(localeProvider.firstDayOfWeek);\n }\n else {\n firstWeek = januaryFirst.beginOfWeek(localeProvider.firstDayOfWeek);\n }\n\n return firstWeek;\n};\n\n/**\n * See [SOGoUser weekNumberForDate:]\n */\nDate.prototype.getWeek = function(localeProvider) {\n var firstWeek, previousWeek, weekNumber, clone;\n\n clone = new Date(this.getTime());\n clone.addDays(6);\n firstWeek = clone.firstWeekOfYearForDate(localeProvider);\n if (firstWeek.getTime() < clone.getTime()) {\n weekNumber = 1 + Math.floor((clone.getTime() - firstWeek.getTime()) / (86400000 * 7));\n }\n else\n {\n // Date is within the last week of the previous year;\n // Compute the previous week number to find the week number of the requested date.\n // The number will either be 52 or 53.\n previousWeek = new Date(clone.getTime());\n previousWeek.addDays(-7);\n firstWeek = previousWeek.firstWeekOfYearForDate(localeProvider);\n weekNumber = 2 + Math.floor((previousWeek.getTime() - firstWeek.getTime()) / (86400000 * 7));\n }\n\n return weekNumber;\n};\n\nDate.prototype.beginOfWeek = function(firstDayOfWeek) {\n var offset = firstDayOfWeek - this.getDay();\n if (offset > 0)\n offset -= 7;\n\n var beginOfWeek = this.beginOfDay();\n beginOfWeek.setHours(12);\n beginOfWeek.addDays(offset);\n\n return beginOfWeek;\n};\n\nDate.prototype.endOfWeek = function(firstDayOfWeek) {\n var endOfWeek = this.beginOfWeek(firstDayOfWeek);\n endOfWeek.addDays(6);\n\n endOfWeek.setHours(23);\n endOfWeek.setMinutes(59);\n endOfWeek.setSeconds(59);\n endOfWeek.setMilliseconds(999);\n\n return endOfWeek;\n};\n\n// YYYYMMDD\nDate.prototype.getDayString = function() {\n var newString = this.getYear();\n if (newString < 1000) newString += 1900;\n var month = '' + (this.getMonth() + 1);\n if (month.length == 1)\n month = '0' + month;\n newString += month;\n var day = '' + this.getDate();\n if (day.length == 1)\n day = '0' + day;\n newString += day;\n\n return newString;\n};\n\n// MMHH\nDate.prototype.getHourString = function() {\n var newString = this.getHours() + '00';\n if (newString.length == 3)\n newString = '0' + newString;\n\n return newString;\n};\n\nDate.prototype.format = function(localeProvider, format) {\n var separators, parts, i, max,\n date = [],\n validParts = /%[deaAmbByYUHIMp]/g,\n val = {\n '%d': this.getDate(), // day of month (e.g., 01)\n '%e': this.getDate(), // day of month, space padded\n '%a': localeProvider.shortDays[this.getDay()], // locale's abbreviated weekday name (e.g., Sun)\n '%A': localeProvider.days[this.getDay()], // locale's full weekday name (e.g., Sunday)\n '%m': this.getMonth() + 1, // month (01..12)\n '%b': localeProvider.shortMonths[this.getMonth()], // locale's abbreviated month name (e.g., Jan)\n '%B': localeProvider.months[this.getMonth()], // locale's full month name (e.g., January)\n '%y': this.getFullYear().toString().substring(2), // last two digits of year (00..99)\n '%Y': this.getFullYear(), // year\n '%U': this.getWeek(localeProvider), // week of the year\n '%H': this.getHours(), // hour (00..23)\n '%M': this.getMinutes() }; // minute (00..59)\n val['%I'] = val['%H'] > 12 ? val['%H'] % 12 : val['%H']; // hour (01..12)\n val['%p'] = val['%H'] < 12 ? l('AM') : l('PM'); // locale's equivalent of either AM or PM\n\n val['%d'] = (val['%d'] < 10 ? '0' : '') + val['%d'];\n val['%e'] = (val['%e'] < 10 ? ' ' : '') + val['%e'];\n val['%m'] = (val['%m'] < 10 ? '0' : '') + val['%m'];\n val['%H'] = (val['%H'] < 10 ? '0' : '') + val['%H'];\n val['%I'] = (val['%I'] < 10 ? '0' : '') + val['%I'];\n val['%M'] = (val['%M'] < 10 ? '0' : '') + val['%M'];\n\n separators = format.replace(validParts, '\\0').split('\\0');\n parts = format.match(validParts);\n for (i = 0, max = parts.length; i <= max; i++){\n if (separators.length)\n date.push(separators.shift());\n date.push(val[parts[i]]);\n }\n\n return date.join('');\n};\n\n/* Functions */\n\nfunction l() {\n var key = arguments[0], value = key, args = arguments, i, j;\n\n // Retrieve translation\n if (labels[key]) {\n value = labels[key];\n }\n else if (clabels[key]) {\n value = clabels[key];\n }\n\n // Format placeholders %{0}, %{1], %{2}, ...\n for (i = 1, j = 0; i < args.length; i++, j++) {\n value = value.replace('%{' + j + '}', args[i]);\n }\n\n // Format placeholders %d and %s\n i = 1;\n if (args.length > 1) {\n value = value.replace(/%((%)|s|d)/g, function(m) {\n // m is the matched format, e.g. %s, %d\n var val = null;\n if (m[2]) {\n val = m[2];\n }\n else {\n val = args[i];\n // A switch statement so that the formatter can be extended. Default is %s\n switch (m) {\n case '%d':\n val = parseFloat(val);\n if (isNaN(val))\n val = 0;\n break;\n }\n i++;\n }\n return val;\n });\n }\n\n return value;\n}\n\nfunction hexToRgb(hex) {\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec(hex);\n return result ? {\n r: parseInt(result[1], 16),\n g: parseInt(result[2], 16),\n b: parseInt(result[3], 16)\n } : null;\n}\n\n// Respect contrast ratio recommendation from W3C:\n// http://www.w3.org/TR/WCAG20/#contrast-ratiodef\nfunction contrast(hex) {\n var color, c, l = 1;\n\n color = hexToRgb(hex);\n if (color) {\n c = [color.r / 255, color.g / 255, color.b / 255];\n\n for (var i = 0; i < c.length; ++i) {\n if (c[i] <= 0.03928) {\n\tc[i] = c[i] / 12.92;\n }\n else {\n\tc[i] = Math.pow((c[i] + 0.055) / 1.055, 2.4);\n }\n }\n\n l = 0.2126 * c[0] + 0.7152 * c[1] + 0.0722 * c[2];\n }\n\n if (l > 0.179) {\n return 'black';\n }\n else {\n return 'white';\n }\n}\n\nfunction guid() {\n function S4() {\n return (((1+Math.random())*0x10000)|0).toString(16).substring(1); \n }\n \n return (S4() + S4() + \"-\" + S4() + \"-4\" + S4().substr(0,3) + \"-\" + S4() + \"-\" + S4() + S4() + S4()).toLowerCase();\n}\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n angular.module('SOGo.Common', ['ngAnimate', 'ngMessages', 'ngSanitize', 'ngMaterial', 'mdColors'])\n .value('sgSettings', {\n isPopup: document.body.classList.contains('popup'),\n baseURL: function() {\n return ApplicationBaseURL || null;\n },\n resourcesURL: function() {\n return ResourcesURL || null;\n },\n activeUser: function(param) {\n var settings = {\n login: UserLogin || null,\n identification: UserIdentification || null,\n email: UserEmail || null,\n language: UserLanguage || null,\n folderURL: UserFolderURL || null,\n isSuperUser: IsSuperUser || null,\n path: {\n calendar: UserCalendarPath || null,\n contacts: UserContactsPath || null,\n mail: UserMailPath || null,\n preferences: UserPreferencesPath || null,\n administration: (IsSuperUser ? UserAdministrationPath : null),\n help: HelpURL || null,\n logoff: UserLogoffPath || null\n }\n };\n if (param)\n return settings[param];\n else\n return settings;\n },\n minimumSearchLength: function() {\n return angular.isNumber(minimumSearchLength)? minimumSearchLength : 2;\n }\n })\n\n .constant('sgColors', {\n selection: [\n '#FFFFFF',\n '#330033',\n '#C0C0C0',\n '#999999',\n '#666666',\n '#333333',\n '#000000',\n '#FFCCCC',\n '#FF6666',\n '#FF0000',\n '#CC0000',\n '#990000',\n '#660000',\n '#330000',\n '#FFCC99',\n '#FF9966',\n '#FF9900',\n '#FF6600',\n '#CC6600',\n '#993300',\n '#663300',\n '#FFFF99',\n '#FFFF66',\n '#FFCC66',\n '#FFCC33',\n '#CC9933',\n '#996633',\n '#663333',\n '#FFFFCC',\n '#FFFF33',\n '#FFFF00',\n '#FFCC00',\n '#999900',\n '#666600',\n '#333300',\n '#CCCCCC',\n '#66FF99',\n '#33FF33',\n '#33CC00',\n '#009900',\n '#006600',\n '#003300',\n '#99FFFF',\n '#33FFFF',\n '#66CCCC',\n '#00CCCC',\n '#339999',\n '#336666',\n '#003333',\n '#CCFFFF',\n '#66FFFF',\n '#33CCFF',\n '#3366FF',\n '#3333FF',\n '#000099',\n '#000066',\n '#CCCCFF',\n '#9999FF',\n '#6666CC',\n '#6633FF',\n '#6600CC',\n '#333399',\n '#330099',\n '#FFCCFF',\n '#FF99FF',\n '#CC66CC',\n '#CC33CC',\n '#993399',\n '#663366',\n '#99FF99'\n ]\n })\n\n // md break-points values are hard-coded in angular-material/src/core/util/constant.js\n // $mdMedia has a built-in support for those values but can also evaluate others.\n // The following breakpoints match our CSS breakpoints in scss/core/variables.scss\n .constant('sgConstant', {\n 'xs' : '(max-width: 599px)' ,\n 'gt-xs' : '(min-width: 600px)' ,\n 'sm' : '(min-width: 600px) and (max-width: 959px)' ,\n 'gt-sm' : '(min-width: 960px)' ,\n 'md' : '(min-width: 960px) and (max-width: 1023px)' ,\n 'gt-md' : '(min-width: 1024px)' ,\n 'lg' : '(min-width: 1024px) and (max-width: 1279px)',\n 'gt-lg' : '(min-width: 1280px)' ,\n 'xl' : '(min-width: 1920px)' ,\n 'print' : 'print'\n })\n\n .config(configure)\n\n .factory('AuthInterceptor', AuthInterceptor)\n .factory('ErrorInterceptor', ErrorInterceptor);\n\n /**\n * @ngInject\n */\n configure.$inject = ['$logProvider', '$compileProvider', '$httpProvider', '$mdThemingProvider', '$mdAriaProvider'];\n function configure($logProvider, $compileProvider, $httpProvider, $mdThemingProvider, $mdAriaProvider) {\n // Accent palette\n $mdThemingProvider.definePalette('sogo-green', {\n '50': 'eaf5e9',\n '100': 'cbe5c8',\n '200': 'aad6a5',\n '300': '88c781',\n '400': '66b86a',\n '500': '56b04c',\n '600': '4da143',\n '700': '388e3c',\n '800': '367d2e',\n '900': '225e1b',\n // 'A100': 'b9f6ca',\n 'A100': 'fafafa', // assigned to md-hue-1\n 'A200': '69f0ae',\n 'A400': '00e676',\n 'A700': '00c853',\n 'contrastDefaultColor': 'dark',\n // 'contrastDarkColors': ['50', '100', '200', 'A100'],\n 'contrastLightColors': ['300', '400', '500', '600', '700', '800', '900']\n });\n // Primary palette\n $mdThemingProvider.definePalette('sogo-blue', {\n '50': 'f0faf9',\n '100': 'e1f5f3',\n '200': 'ceebe8',\n '300': 'bfe0dd',\n '400': 'b2d6d3',\n '500': 'a1ccc8',\n '600': '8ebfbb',\n '700': '7db3b0',\n '800': '639997',\n '900': '4d8080',\n 'A100': 'd4f7fa',\n 'A200': 'c3f5fa',\n 'A400': '53e3f0',\n 'A700': '00b0c0',\n 'contrastDefaultColor': 'light',\n 'contrastDarkColors': ['50', '100', '200'],\n // 'contrastLightColors': ['300', '400', '500', '600', '700', '800', '900', 'A100', 'A200', 'A400', 'A700']\n });\n // Background palette\n $mdThemingProvider.definePalette('sogo-paper', {\n '50': 'fcf7f8',\n '100': 'f7f1dc',\n '200': 'ede5ca',\n '300': 'e6d8ba',\n '400': 'e2d2a3',\n '500': 'd6c48d',\n '600': 'baa870',\n '700': '857545',\n '800': '524517',\n '900': '433809',\n '1000': '000000',\n 'A100': 'ffffff',\n 'A200': 'eeeeee',\n 'A400': 'bdbdbd',\n 'A700': '616161',\n 'contrastDefaultColor': 'dark',\n 'contrastLightColors': ['800', '900']\n });\n // Default theme definition\n $mdThemingProvider.theme('default')\n .primaryPalette('sogo-blue', {\n 'default': '900',\n 'hue-1': '400',\n 'hue-2': '800',\n 'hue-3': 'A700'\n })\n .accentPalette('sogo-green', {\n 'default': '500',\n // 'hue-1': '200',\n 'hue-1': 'A100', // background-50\n 'hue-2': '300',\n 'hue-3': 'A700'\n })\n .backgroundPalette('grey', {\n 'default': '50',\n 'hue-1': '200',\n 'hue-2': '300',\n 'hue-3': '500'\n });\n\n if (!DebugEnabled) {\n // Disable debugging information\n $logProvider.debugEnabled(false);\n $compileProvider.debugInfoEnabled(false);\n // Disable warnings\n $mdAriaProvider.disableWarnings();\n // Disable theme generation but keep definition in config (required by mdColors)\n $mdThemingProvider.generateThemesOnDemand(true);\n // Disable theming completely\n //$mdThemingProvider.disableTheming();\n }\n\n $httpProvider.interceptors.push('AuthInterceptor');\n $httpProvider.interceptors.push('ErrorInterceptor');\n }\n\n /**\n * @ngInject\n */\n AuthInterceptor.$inject = ['$window', '$q'];\n function AuthInterceptor($window, $q) {\n return {\n response: function(response) {\n // When expecting JSON but receiving HTML, assume session has expired and reload page\n if (response && /^application\\/json/.test(response.config.headers.Accept) &&\n /^<!DOCTYPE html>/.test(response.data)) {\n $window.location.reload(true);\n return $q.reject();\n }\n return response;\n }\n };\n }\n\n /**\n * @ngInject\n */\n ErrorInterceptor.$inject = ['$rootScope', '$q'];\n function ErrorInterceptor($rootScope, $q) {\n return {\n responseError: function(rejection) {\n if (/^application\\/json/.test(rejection.config.headers.Accept)) {\n // Broadcast the response error\n $rootScope.$broadcast('http:Error', rejection);\n }\n return $q.reject(rejection);\n }\n };\n }\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/*\n * https://github.com/angular/material/issues/1269\n * https://gist.github.com/senthilprabhut/dd2147ebabc89bf223e7\n */\n\n(function() {\n 'use strict';\n\n var _$mdThemingProvider;\n\n angular\n .module('mdColors', ['ngMaterial'])\n .config(configure)\n .run(runBlock);\n\n /**\n * @ngInject\n */\n configure.$inject = ['$mdThemingProvider'];\n function configure($mdThemingProvider) {\n _$mdThemingProvider = $mdThemingProvider;\n }\n \n /**\n * @ngInject\n */\n runBlock.$inject = ['$interpolate', '$document', '$log'];\n function runBlock($interpolate, $document, $log) {\n\n function buildCssSelectors(selectors) {\n var result = selectors.join('');\n return result;\n }\n\n var fgDefault = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-fg']) + ' { color:{{value}};}'),\n bgDefault = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-bg']) + ' { background-color:{{value}};}'),\n bdrDefault = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-bdr']) + ' { border-color:{{value}};}'),\n fgDefaultHue = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{hue}}','.md-fg']) + ' { color:{{value}};}'),\n bgDefaultHue = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{hue}}','.md-bg']) + ' { background-color:{{value}};}'),\n fgColor = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{palette}}','.md-fg']) + ' { color:{{value}};}'),\n bgColor = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{palette}}','.md-bg']) + ' { background-color:{{value}}; color:{{contrast}} !important; }'),\n bdrColor = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{palette}}','.md-bdr']) + ' { border-color:{{value}};}'),\n fgHue = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{palette}}.md-{{hue}}','.md-fg']) + ' { color:{{value}};}'),\n bgHue = $interpolate(buildCssSelectors(['.md-{{theme}}-theme','.md-{{palette}}.md-{{hue}}','.md-bg']) + ' { background-color:{{value}};}'),\n customSheet = getStyleSheet(),\n index = 0;\n\n // Clear out old rules from stylesheet\n while (customSheet.cssRules.length > 0 ) {\n customSheet.deleteRule(0);\n }\n angular.forEach(_$mdThemingProvider._THEMES, function(theme, themeName){\n // Add default selectors - primary is the default palette\n addRule(fgDefault, bgDefault, themeName, 'primary',\n _$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues.default]);\n addRule(fgDefaultHue, bgDefaultHue, themeName, 'primary',\n _$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues['hue-2'] ], 'hue-2');\n addRule(fgDefaultHue, bgDefaultHue, themeName, 'primary',\n _$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues['hue-3'] ], 'hue-3');\n addRule(fgDefaultHue, bgDefaultHue, themeName, 'primary',\n _$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues['hue-1'] ], 'hue-1');\n addBorderRule(bdrDefault, themeName, 'primary',\n _$mdThemingProvider._PALETTES[theme.colors.primary.name][theme.colors.primary.hues.default]);\n\n // Add selectors for palettes - accent, background, primary and warn\n angular.forEach(theme.colors, function(color, paletteName){\n addRule(fgColor, bgColor, themeName, paletteName, _$mdThemingProvider._PALETTES[color.name][color.hues.default]);\n addBorderRule(bdrColor, themeName, paletteName, _$mdThemingProvider._PALETTES[color.name][color.hues.default]);\n addRule(fgHue, bgHue, themeName, paletteName, _$mdThemingProvider._PALETTES[color.name][color.hues['hue-2'] ], 'hue-2');\n addRule(fgHue, bgHue, themeName, paletteName, _$mdThemingProvider._PALETTES[color.name][color.hues['hue-3'] ], 'hue-3');\n addRule(fgHue, bgHue, themeName, paletteName, _$mdThemingProvider._PALETTES[color.name][color.hues['hue-1'] ], 'hue-1');\n });\n\n //$log.debug(_.map(customSheet.cssRules, 'cssText').join(\"\\n\"));\n });\n\n function addRule(fgInterpolate, bgInterpolate, themeName, paletteName, colorArray, hueName){\n // Set up interpolation functions to build css rules.\n if (!colorArray) return;\n var colorValue = 'rgb(' + colorArray.value[0] + ',' + colorArray.value[1] + ',' + colorArray.value[2] + ')',\n colorContrast = 'rgb(' + colorArray.contrast[0] + ',' + colorArray.contrast[1] + ',' + colorArray.contrast[2] + ')',\n context = {\n theme: themeName,\n palette: paletteName,\n value: colorValue,\n contrast: colorContrast,\n hue: hueName\n };\n\n // Insert foreground color rule\n customSheet.insertRule(fgInterpolate(context), index);\n index += 1;\n\n // Insert background color rule\n customSheet.insertRule(bgInterpolate(context), index);\n index += 1;\n }\n\n function addBorderRule(bdrInterpolate, themeName, paletteName, colorArray, hueName){\n // Set up interpolation functions to build css rule for border color.\n if (!colorArray) return;\n var colorValue = 'rgb(' + colorArray.value[0] + ',' + colorArray.value[1] + ',' + colorArray.value[2] + ')';\n\n customSheet.insertRule(bdrInterpolate({\n theme: themeName,\n palette: paletteName,\n value: colorValue,\n hue: hueName\n }), index);\n index += 1;\n }\n\n function getStyleSheet() {\n // function to add a dynamic style-sheet to the document\n var style = $document[0].head.querySelector('style[title=\"Dynamic-Generated-by-mdColors\"]');\n if (style === null) {\n style = $document[0].createElement('style');\n style.title = 'Dynamic-Generated-by-mdColors';\n // WebKit hack... (not sure if still needed)\n style.appendChild($document[0].createTextNode(''));\n $document[0].head.appendChild(style);\n }\n return style.sheet;\n }\n }\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * @type {angular.Module}\n */\n(function () {\n 'use strict';\n\n /**\n * @ngInject\n */\n decodeUri.$inject = ['$window'];\n function decodeUri($window) {\n return $window.decodeURIComponent;\n }\n\n angular.module('SOGo.Common')\n .filter('decodeUri', decodeUri);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * @type {angular.Module}\n */\n(function () {\n 'use strict';\n\n /**\n * @ngInject\n */\n encodeUri.$inject = ['$window'];\n function encodeUri($window) {\n return $window.encodeURIComponent;\n }\n\n angular.module('SOGo.Common')\n .filter('encodeUri', encodeUri);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function () {\n 'use strict';\n\n /**\n * ensureTarget - A filter to set a blank target to all links.\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <div ng-bind-html=\"part.content | ensureTarget\"><!-- msg --></div>\n */\n ensureTarget.$inject = ['$sce'];\n function ensureTarget($sce) {\n return function(element) {\n var tree = angular.element('<div>' + element + '</div>');\n tree.find('a').attr('target', '_blank');\n return $sce.trustAs('html', tree.html());\n };\n }\n\n angular.module('SOGo.Common')\n .filter('ensureTarget', ensureTarget);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * ln2br - A filter to convert line feeds and carriage returns to html line breaks\n * @memberof SOGo.Common\n */\n(function () {\n 'use strict';\n\n /**\n * @ngInject\n */\n function ln2br() {\n return function(text) {\n return text ? String(text).replace(/\\r?\\n/gm, '<br>') : undefined;\n };\n }\n\n angular.module('SOGo.Common')\n .filter('ln2br', ln2br);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * loc - A simple filter to return the localized version of a string.\n * @memberof SOGo.Common\n */\n(function () {\n 'use strict';\n\n /**\n * @ngInject\n */\n function loc() {\n return l;\n }\n\n angular.module('SOGo.Common')\n .filter('loc', loc);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * range - A simple filter that will return an array of the size of its argument.\n * @memberof SOGo.Common\n */\n(function () {\n 'use strict';\n\n function range() {\n return function(n) {\n var res = [];\n for (var i = 0; i < parseInt(n); i++) {\n res.push(i);\n }\n return res;\n };\n }\n\n angular.module('SOGo.Common')\n .filter('range', range);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @ngInject\n */\n AclController.$inject = ['$timeout', '$mdDialog', 'Dialog', 'usersWithACL', 'User', 'folder'];\n function AclController($timeout, $mdDialog, Dialog, usersWithACL, User, folder) {\n var vm = this;\n\n vm.users = usersWithACL; // ACL users\n vm.folder = folder;\n vm.selectedUser = null;\n vm.selectedUid = null;\n vm.userToAdd = '';\n vm.searchText = '';\n vm.userFilter = userFilter;\n vm.closeModal = closeModal;\n vm.saveModal = saveModal;\n vm.confirmChange = confirmChange;\n vm.removeUser = removeUser;\n vm.addUser = addUser;\n vm.selectAllRights = selectAllRights;\n vm.selectUser = selectUser;\n vm.confirmation = { showing: false,\n message: ''};\n\n function userFilter($query) {\n return User.$filter($query, folder.$acl.users);\n }\n\n function closeModal() {\n folder.$acl.$resetUsersRights(); // cancel changes\n $mdDialog.hide();\n }\n\n function saveModal() {\n folder.$acl.$saveUsersRights().then(function() {\n $mdDialog.hide();\n }, function(data, status) {\n Dialog.alert(l('Warning'), l('An error occured please try again.'));\n });\n }\n\n function confirmChange(user) {\n var confirmation = user.$confirmRights(vm.folder);\n if (confirmation) {\n vm.confirmation.showing = true;\n vm.confirmation.message = confirmation;\n }\n }\n\n function removeUser(user) {\n $timeout(function() {\n folder.$acl.$removeUser(user.uid);\n }, 500); // wait for CSS transition to complete (see card.scss)\n }\n\n function addUser(data) {\n if (data) {\n folder.$acl.$addUser(data).then(function(user) {\n vm.userToAdd = '';\n vm.searchText = '';\n vm.selectedUid = null;\n if (user)\n selectUser(user);\n });\n }\n }\n\n function selectAllRights(user) {\n folder.$acl.$selectAllRights(user);\n }\n\n function selectUser(user, $event) {\n if ($event && $event.target.parentNode.classList.contains('md-secondary'))\n return false;\n if (vm.selectedUid == user.uid) {\n vm.selectedUid = null;\n }\n else {\n vm.selectedUid = user.uid;\n vm.selectedUser = user;\n vm.selectedUser.$rights();\n }\n }\n }\n\n angular\n .module('SOGo.Common')\n .controller('AclController', AclController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n/**\n * @type {angular.Module}\n */\n(function () {\n 'use strict';\n\n /**\n * @ngInject\n */\n navController.$inject = ['$rootScope', '$scope', '$timeout', '$interval', '$http', '$window', '$mdSidenav', '$mdToast', '$mdMedia', '$log', 'sgConstant', 'sgSettings', 'Alarm'];\n function navController($rootScope, $scope, $timeout, $interval, $http, $window, $mdSidenav, $mdToast, $mdMedia, $log, sgConstant, sgSettings, Alarm) {\n\n $scope.isPopup = sgSettings.isPopup;\n $scope.activeUser = sgSettings.activeUser();\n $scope.baseURL = sgSettings.baseURL();\n $scope.leftIsClose = !$mdMedia(sgConstant['gt-md']);\n $scope.centerIsClose = false;\n\n // Show current day in top bar\n $scope.currentDay = window.currentDay;\n $timeout(function() {\n // Update date when day ends\n $interval(function() {\n $http.get('../date').then(function(data) {\n $scope.currentDay = data;\n });\n }, 24 * 3600 * 1000);\n }, window.currentDay.secondsBeforeTomorrow * 1000);\n\n $scope.toggleLeft = function() {\n if ($scope.isGtMedium) {\n // Left sidenav is toggled while sidenav is locked open; bypass $mdSidenav\n $scope.leftIsClose = !$scope.leftIsClose;\n }\n else {\n $scope.leftIsClose = leftIsClose();\n // Fire a window resize when opening the sidenav on a small device.\n // This is a fix until the following issue is officially resolved:\n // https://github.com/angular/material/issues/7309\n if ($scope.leftIsClose)\n angular.element($window).triggerHandler('resize');\n $mdSidenav('left').toggle()\n .then(function () {\n $log.debug(\"toggle left is done\");\n });\n }\n };\n $scope.toggleRight = function() {\n $mdSidenav('right').toggle()\n .then(function () {\n $log.debug(\"toggle right is done\");\n });\n };\n $scope.toggleCenter = function() {\n $scope.centerIsClose = !$scope.centerIsClose;\n };\n // $scope.openBottomSheet = function() {\n // $mdBottomSheet.show({\n // parent: angular.element(document.getElementById('left-sidenav')),\n // templateUrl: 'bottomSheetTemplate.html'\n // });\n // };\n // $scope.toggleDetailView = function() {\n // var detail = angular.element(document.getElementById('detailView'));\n // detail.toggleClass('sg-close');\n // };\n $scope.$watch(function() {\n return $mdMedia(sgConstant['gt-md']);\n }, function(newVal) {\n $scope.isGtMedium = newVal;\n if (newVal) {\n $scope.leftIsClose = false;\n }\n });\n\n function leftIsClose() {\n return !$mdSidenav('left').isOpen();\n }\n\n function onHttpError(event, response) {\n var message;\n if (response.data && response.data.message && angular.isString(response.data.message))\n message = response.data.message;\n else if (response.status)\n message = response.statusText;\n\n if (message)\n $mdToast.show({\n template: [\n '<md-toast>',\n ' <div class=\"md-toast-content\">',\n ' <md-icon class=\"md-warn md-hue-1\">error_outline</md-icon>',\n ' <span flex>' + l(message) + '</span>',\n ' </div>',\n '</md-toast>'\n ].join(''),\n hideDelay: 5000,\n position: 'top right'\n });\n else\n $log.debug('untrap error');\n }\n\n // Listen to HTTP errors broadcasted from HTTP interceptor\n $rootScope.$on('http:Error', onHttpError);\n\n Alarm.getAlarms();\n }\n\n angular.module('SOGo.Common')\n .controller('navController', navController);\n})();\n","(function() {\n 'use strict';\n\n /**\n * @name Acl\n * @constructor\n * @param {String} folderId - the folder ID associated to the ACLs\n */\n function Acl(folderId) {\n this.folderId = folderId;\n }\n\n /**\n * @memberof Acl\n * @desc The factory we'll use to register with Angular.\n * @return the Acl constructor\n */\n Acl.factory = ['$q', '$timeout', 'sgSettings', 'Resource', 'User', function($q, $timeout, Settings, Resource, User) {\n angular.extend(Acl, {\n $q: $q,\n $timeout: $timeout,\n $$resource: new Resource(Settings.activeUser('folderURL'), Settings.activeUser()),\n $User: User\n });\n\n return Acl;\n }];\n\n /**\n * @module SOGo.Common\n * @desc Factory registration of User in Angular module.\n */\n angular.module('SOGo.Common').factory('Acl', Acl.factory);\n\n /**\n * @function $users\n * @memberof Acl.prototype\n * @param {Object} owner - the owner to use when fetching the ACL as it might not be the Settings.activeUser\n * @desc Fetch the list of users that have specific rights for the current folder.\n * @return a promise of an array of User objects\n */\n Acl.prototype.$users = function(owner) {\n var _this = this,\n deferred = Acl.$q.defer(),\n user;\n if (this.users) {\n deferred.resolve(this.users);\n }\n else {\n var acls;\n if (angular.isDefined(owner))\n acls = Acl.$$resource.userResource(owner).fetch(this.folderId, 'acls');\n else\n acls = Acl.$$resource.fetch(this.folderId, 'acls');\n\n return acls.then(function(response) {\n _this.users = [];\n //console.debug(JSON.stringify(users, undefined, 2));\n angular.forEach(response.users, function(data) {\n user = new Acl.$User(data);\n user.canSubscribeUser = user.isSubscribed;\n user.wasSubscribed = user.isSubscribed;\n user.$rights = angular.bind(user, user.$acl, _this.folderId, owner);\n _this.users.push(user);\n });\n deferred.resolve(_this.users);\n return _this.users;\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $addUser\n * @memberof Acl.prototype\n * @param {Object} user - a User object with minimal set of attributes (uid, isGroup, cn, c_email)\n * @param {Object} owner - the owner to use when fetching the ACL as it might not be the Settings.activeUser\n * @see {@link User.$filter}\n */\n Acl.prototype.$addUser = function(user, owner) {\n var _this = this,\n deferred = Acl.$q.defer(),\n param = {uid: user.uid};\n if (!user.uid || _.indexOf(_.map(this.users, 'uid'), user.uid) > -1) {\n // No UID specified or user already in ACLs\n deferred.resolve();\n }\n else {\n var acls;\n\n if (angular.isDefined(owner))\n acls = Acl.$$resource.userResource(owner).fetch(this.folderId, 'addUserInAcls', param);\n else\n acls = Acl.$$resource.fetch(this.folderId, 'addUserInAcls', param);\n\n acls.then(function() {\n user.wasSubscribed = false;\n user.userClass = user.isGroup ? 'normal-group' : 'normal-user';\n user.$rights = angular.bind(user, user.$acl, _this.folderId, owner);\n _this.users.push(user);\n deferred.resolve(user);\n }, function(data, status) {\n deferred.reject(l('An error occured please try again.'));\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $removeUser\n * @memberof Acl.prototype\n * @desc Remove a user from the folder's ACL\n * @return a promise of the server call to remove the user from the folder's ACL\n */\n Acl.prototype.$removeUser = function(uid, owner) {\n var _this = this,\n param = {uid: uid},\n acls;\n\n if (angular.isDefined(owner))\n acls = Acl.$$resource.userResource(owner).fetch(this.folderId, 'removeUserFromAcls', param);\n else\n acls = Acl.$$resource.fetch(this.folderId, 'removeUserFromAcls', param);\n\n return acls.then(function() {\n var i = _.indexOf(_.map(_this.users, 'uid'), uid);\n if (i >= 0) {\n _this.users[i].$shadowRights = null;\n _this.users.splice(i, 1);\n }\n });\n };\n\n /**\n * @function $selectAllRights\n * @memberof Acl.prototype\n * @desc Select all rights of an user\n */\n Acl.prototype.$selectAllRights = function(user) {\n _.forEach(user.rights, function(value, right) {\n if (angular.isNumber(user.rights[right]))\n user.rights[right] = 1;\n });\n };\n\n /**\n * @function $resetUsersRights\n * @memberof Acl.prototype\n * @desc Restore initial rights of all users.\n */\n Acl.prototype.$resetUsersRights = function() {\n angular.forEach(this.users, function(user) {\n user.$resetRights();\n });\n };\n\n /**\n * @function $saveUsersRights\n * @memberof Acl.prototype\n * @desc Save user rights that have changed and subscribe users that have been selected.\n * @param {Object} owner - the owner to use when fetching the ACL as it might not be the Settings.activeUser\n * @return a promise that resolved only if the modifications and subscriptions were successful\n */\n Acl.prototype.$saveUsersRights = function(owner) {\n var _this = this,\n deferredSave = Acl.$q.defer(),\n deferredSubscribe = Acl.$q.defer(),\n param = {action: 'saveUserRights'},\n users = [];\n\n // Save user rights\n angular.forEach(this.users, function(user) {\n if (user.$rightsAreDirty()) {\n users.push(user.$omit());\n // console.debug('save ' + JSON.stringify(user.$omit(), undefined, 2));\n }\n });\n if (users.length) {\n var acls;\n\n if (angular.isDefined(owner))\n acls = Acl.$$resource.userResource(owner).save(this.folderId, users, param);\n else\n acls = Acl.$$resource.save(this.folderId, users, param);\n\n acls.then(function() {\n // Save was successful; copy rights to shadow rights\n angular.forEach(_this.users, function(user) {\n if (user.$rightsAreDirty()) {\n user.$shadowRights = angular.copy(user.rights);\n }\n });\n deferredSave.resolve();\n }, deferredSave.reject);\n }\n else {\n deferredSave.resolve();\n }\n\n // Subscribe users\n users = [];\n angular.forEach(this.users, function(user) {\n if (!user.wasSubscribed && user.isSubscribed) {\n users.push(user.uid);\n // console.debug('subscribe ' + user.uid);\n }\n });\n if (users.length) {\n param = {uids: users.join(',')};\n Acl.$$resource.fetch(this.folderId, 'subscribeUsers', param)\n .then(function() {\n // Subscribe was successful; reset \"wasSubscribed\" attribute\n angular.forEach(_this.users, function(user) {\n user.wasSubscribed = user.isSubscribed;\n });\n deferredSubscribe.resolve();\n }, deferredSubscribe.reject);\n }\n else {\n deferredSubscribe.resolve();\n }\n return Acl.$q.all([deferredSave.promise, deferredSubscribe.promise]);\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Alarm\n * @constructor\n */\n function Alarm() {\n this.currentAlarm = null;\n }\n\n /**\n * @name getAlarms\n * @desc Fetch the list of alarms from the server and use the last one\n */\n Alarm.getAlarms = function() {\n var _this = this;\n var now = new Date();\n var browserTime = Math.floor(now.getTime()/1000);\n\n this.$$resource.fetch('', 'alarmslist?browserTime=' + browserTime).then(function(data) {\n \n var alarms = data.alarms.sort(function reverseSortByAlarmTime(a, b) {\n var x = parseInt(a[2]);\n var y = parseInt(b[2]);\n return (y - x);\n });\n\n if (alarms.length > 0) {\n var next = alarms.pop();\n var now = new Date();\n var utc = Math.floor(now.getTime()/1000);\n var url = next[0] + '/' + next[1];\n var alarmTime = parseInt(next[2]);\n var delay = alarmTime;\n if (alarmTime > 0) delay -= utc;\n var d = new Date(alarmTime*1000);\n //console.log (\"now = \" + now.toUTCString());\n //console.log (\"next event \" + url + \" in \" + delay + \" seconds (on \" + d.toUTCString() + \")\");\n\n var f = angular.bind(_this, Alarm.showAlarm, url);\n\n if (_this.currentAlarm)\n _this.$timeout.cancel(_this.currentAlarm);\n\n _this.currentAlarm = _this.$timeout(f, delay*1000);\n }\n });\n };\n \n /**\n * @name showAlarm\n * @desc Show the latest alarm using a toast\n * @param url The URL of the calendar component for snoozing\n */\n Alarm.showAlarm = function(url) {\n var _this = this;\n\n this.$$resource.fetch(url, '?resetAlarm=yes').then(function(data) {\n _this.$toast.show({\n position: 'top right',\n hideDelay: 0,\n template: [\n '<md-toast>',\n ' <div class=\"md-toast-content\">',\n ' <md-input-container>',\n ' <label style=\"color: white;\">{{ summary }}</label>',\n ' <md-select ng-model=\"reminder\">',\n ' <md-option value=5>',\n l('5 minutes'),\n ' </md-option>',\n ' <md-option value=10>',\n l('10 minutes'),\n ' </md-option>',\n ' <md-option value=15>',\n l('15 minutes'),\n ' </md-option>',\n ' <md-option value=30>',\n l('30 minutes'),\n ' </md-option>',\n ' <md-option value=45>',\n l('45 minutes'),\n ' </md-option>',\n ' <md-option value=60>',\n l('1 hour'),\n ' </md-option>',\n ' <md-option value=1440>',\n l('1 day'),\n ' </md-option>',\n ' </md-select>',\n ' </md-input-container>',\n ' <md-button ng-click=\"cancel()\">',\n l('Cancel'),\n ' </md-button>',\n ' <md-button ng-click=\"ok()\">',\n l('Ok'),\n ' </md-button>',\n ' </div>',\n '</md-toast>'\n ].join(''),\n locals: {\n url: url\n },\n controller: AlarmController\n });\n\n /**\n * @ngInject\n */\n AlarmController.$inject = ['scope', '$sanitize', '$mdToast', 'url'];\n function AlarmController(scope, $sanitize, $mdToast, url) {\n scope.summary = $sanitize(data.summary);\n scope.reminder = '10';\n scope.cancel = function() {\n $mdToast.hide();\n };\n scope.ok = function() {\n _this.$$resource.fetch(url, 'view?snoozeAlarm=' + scope.reminder);\n $mdToast.hide();\n };\n }\n });\n };\n\n /**\n * @memberof Alarm\n * @desc The factory we'll register as Alarm in the Angular module SOGo.Common\n * @ngInject\n */\n AlarmService.$inject = ['$timeout', 'sgSettings', 'Resource', '$mdToast'];\n function AlarmService($timeout, Settings, Resource, $mdToast) {\n angular.extend(Alarm, {\n $timeout: $timeout,\n $$resource: new Resource(Settings.activeUser('folderURL') + 'Calendar', Settings.activeUser()),\n $toast: $mdToast\n });\n\n return Alarm; // return constructor\n }\n\n /* Factory registration in Angular module */\n angular\n .module('SOGo.Common')\n .factory('Alarm', AlarmService);\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n/* JavaScript for Authentication */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n angular.module('SOGo.Authentication', ['ngCookies'])\n\n .constant('passwordPolicyConfig', {\n PolicyPasswordChangeUnsupported: -3,\n PolicyPasswordSystemUnknown: -2,\n PolicyPasswordUnknown: -1,\n PolicyPasswordExpired: 0,\n PolicyAccountLocked: 1,\n PolicyChangeAfterReset: 2,\n PolicyPasswordModNotAllowed: 3,\n PolicyMustSupplyOldPassword: 4,\n PolicyInsufficientPasswordQuality: 5,\n PolicyPasswordTooShort: 6,\n PolicyPasswordTooYoung: 7,\n PolicyPasswordInHistory: 8,\n PolicyNoError: 65535\n })\n\n .provider('Authentication', Authentication);\n\n function Authentication() {\n function redirectUrl(username, domain) {\n var userName, address, baseAddress, altBaseAddress, parts, hostpart, protocol, newAddress;\n\n userName = username;\n if (domain)\n userName += '@' + domain.value;\n address = '' + window.location.href;\n baseAddress = ApplicationBaseURL + '/' + encodeURIComponent(userName);\n if (baseAddress[0] == '/') {\n parts = address.split('/');\n hostpart = parts[2];\n protocol = parts[0];\n baseAddress = protocol + '//' + hostpart + baseAddress;\n }\n parts = baseAddress.split('/');\n parts.splice(0, 3);\n altBaseAddress = parts.join('/');\n if ((address.startsWith(baseAddress) || address.startsWith(altBaseAddress)) &&\n !address.endsWith('/logoff')) {\n newAddress = address;\n }\n else {\n newAddress = baseAddress;\n }\n\n return newAddress;\n }\n\n this.$get = getService;\n\n /**\n * @ngInject\n */\n getService.$inject = ['$q', '$http', '$cookies', 'passwordPolicyConfig'];\n function getService($q, $http, $cookies, passwordPolicyConfig) {\n var service;\n\n function readLoginCookie() {\n var loginValues = null,\n cookie = $cookies.get('0xHIGHFLYxSOGo'),\n value;\n if (cookie && cookie.length > 8) {\n value = decodeURIComponent(cookie.substr(8));\n loginValues = value.base64decode().split(':');\n }\n\n return loginValues;\n }\n\n service = {\n login: function(data) {\n var d = $q.defer(),\n username = data.username,\n password = data.password,\n domain = data.domain,\n language,\n rememberLogin = data.rememberLogin ? 1 : 0;\n\n if (data.loginSuffix && !username.endsWith(data.loginSuffix)) {\n username += loginSuffix;\n domain = false;\n }\n if (data.language && data.language != 'WONoSelectionString') {\n language = data.language;\n }\n\n $http({\n method: 'POST',\n url: '/SOGo/connect',\n data: {\n userName: username,\n password: password,\n domain: domain,\n language: language,\n rememberLogin: rememberLogin\n }\n }).then(function(response) {\n var data = response.data;\n // Make sure browser's cookies are enabled\n var loginCookie = readLoginCookie();\n if (!loginCookie) {\n d.reject(l('cookiesNotEnabled'));\n }\n else {\n // Check password policy\n if (typeof data.expire != 'undefined' && typeof data.grace != 'undefined') {\n if (data.expire < 0 && data.grace > 0) {\n d.reject({grace: data.grace});\n //showPasswordDialog('grace', createPasswordGraceDialog, data['grace']);\n } else if (data.expire > 0 && data.grace == -1) {\n d.reject({expire: data.expire});\n //showPasswordDialog('expiration', createPasswordExpirationDialog, data['expire']);\n }\n else {\n d.resolve({ cn: data.cn, url: redirectUrl(username, domain) });\n }\n }\n else {\n d.resolve(redirectUrl(username, domain));\n }\n }\n }, function(response) {\n var msg, perr, data = response.data;\n if (data && data.LDAPPasswordPolicyError) {\n perr = data.LDAPPasswordPolicyError;\n if (perr == passwordPolicyConfig.PolicyNoError) {\n msg = l('Wrong username or password.');\n }\n else if (perr == passwordPolicyConfig.PolicyAccountLocked) {\n msg = l('Your account was locked due to too many failed attempts.');\n }\n else {\n msg = l('Login failed due to unhandled error case: ') + perr;\n }\n }\n else {\n msg = l('Unhandled error response');\n }\n d.reject({error: msg});\n });\n return d.promise;\n }, // login: function(data) { ...\n\n changePassword: function(newPassword) {\n var d = $q.defer(),\n loginCookie = readLoginCookie(),\n xsrfCookie = $cookies.get('XSRF-TOKEN');\n\n $cookies.remove('XSRF-TOKEN', {path: '/SOGo/'});\n\n $http({\n method: 'POST',\n url: '/SOGo/so/changePassword',\n headers: {\n 'X-XSRF-TOKEN' : xsrfCookie\n },\n data: {\n userName: loginCookie[0],\n password: loginCookie[1],\n newPassword: newPassword }\n }).then(d.resolve, function(response) {\n var error,\n data = response.data,\n perr = data.LDAPPasswordPolicyError;\n\n if (!perr) {\n perr = passwordPolicyConfig.PolicyPasswordSystemUnknown;\n error = _(\"Unhandled error response\");\n }\n else if (perr == passwordPolicyConfig.PolicyNoError) {\n error = l(\"Password change failed\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordModNotAllowed) {\n error = l(\"Password change failed - Permission denied\");\n } else if (perr == passwordPolicyConfig.PolicyInsufficientPasswordQuality) {\n error = l(\"Password change failed - Insufficient password quality\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordTooShort) {\n error = l(\"Password change failed - Password is too short\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordTooYoung) {\n error = l(\"Password change failed - Password is too young\");\n } else if (perr == passwordPolicyConfig.PolicyPasswordInHistory) {\n error = l(\"Password change failed - Password is in history\");\n } else {\n error = l(\"Unhandled policy error: %{0}\").formatted(perr);\n perr = passwordPolicyConfig.PolicyPasswordUnknown;\n }\n\n // Restore the cookie\n $cookies.put('XSRF-TOKEN', xsrfCookie, {path: '/SOGo/'});\n d.reject(error);\n });\n return d.promise;\n }\n };\n return service;\n }\n }\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Dialog\n * @constructor\n */\n function Dialog() {\n }\n\n /**\n * @name alert\n * @desc Show an alert dialog box with a single \"OK\" button\n * @param {string} title\n * @param {string} content\n */\n Dialog.alert = function(title, content) {\n var alert = this.$modal.alert()\n .title(title)\n .htmlContent(content)\n .ok(l('OK'));\n this.$modal.show(alert);\n };\n\n /**\n * @name confirm\n * @desc Show a confirmation dialog box with buttons 'Cancel' and 'OK'\n * @param {string} title\n * @param {string} content\n * @returns a promise that resolves if the user has clicked on the 'OK' button\n */\n Dialog.confirm = function(title, content, options) {\n var confirm = this.$modal.confirm()\n .title(title)\n .htmlContent(content)\n .ok((options && options.ok)? options.ok : l('OK'))\n .cancel((options && options.cancel)? options.cancel : l('Cancel'));\n return this.$modal.show(confirm);\n };\n\n /**\n * @name prompt\n * @desc Show a primpt dialog box with a input text field and the 'Cancel' and 'OK' buttons\n * @param {string} title\n * @param {string} label\n * @param {object} [options] - use a different input type by setting 'inputType'\n * @returns a promise that resolves with the input field value\n */\n Dialog.prompt = function(title, label, options) {\n var o = options || {},\n id = title.asCSSIdentifier(),\n d = this.$q.defer();\n\n this.$modal.show({\n parent: angular.element(document.body),\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '<md-dialog flex=\"50\" flex-xs=\"90\">',\n ' <form name=\"' + id + 'Form\" ng-submit=\"ok()\">',\n ' <md-dialog-content class=\"md-dialog-content\" layout=\"column\">',\n ' <h2 class=\"md-title\" ng-bind=\"title\"></h2>',\n ' <md-input-container>',\n ' <label>' + label + '</label>',\n ' <input type=\"' + (o.inputType || 'text') + '\"',\n ' aria-label=\"' + title + '\"',\n ' ng-model=\"name\" md-autofocus=\"true\" required />',\n ' </md-input-container>',\n ' </md-dialog-content>',\n ' <md-dialog-actions>',\n ' <md-button ng-click=\"cancel()\">',\n ' ' + l('Cancel'),\n ' </md-button>',\n ' <md-button type=\"submit\" class=\"md-primary\" ng-disabled=\"' + id + 'Form.$invalid\">',\n ' ' + l('OK'),\n ' </md-button>',\n ' </md-dialog-actions>',\n ' </form>',\n '</md-dialog>'\n ].join(''),\n controller: PromptDialogController\n });\n\n /**\n * @ngInject\n */\n PromptDialogController.$inject = ['scope', '$mdDialog'];\n function PromptDialogController(scope, $mdDialog) {\n scope.title = title;\n scope.name = \"\";\n scope.cancel = function() {\n d.reject();\n $mdDialog.hide();\n };\n scope.ok = function() {\n d.resolve(scope.name);\n $mdDialog.hide();\n };\n }\n\n return d.promise;\n };\n\n /**\n * @memberof Dialog\n * @desc The factory we'll register as Dialog in the Angular module SOGo.Common\n * @ngInject\n */\n DialogService.$inject = ['$q', '$mdDialog'];\n function DialogService($q, $mdDialog) {\n angular.extend(Dialog, { $q: $q , $modal: $mdDialog });\n\n return Dialog; // return constructor\n }\n\n /* Factory registration in Angular module */\n angular\n .module('SOGo.Common')\n .factory('Dialog', DialogService);\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * Gravatar - A service to build the Gravatar URL for an email address\n * @memberof SOGo.Common\n * @param {string} email\n * @param {number} [size] - the size of the image\n * @param {string} alternate avatar to use (none, identicon, monsterid, wavatar, retro)\n * @ngInject\n */\n function Gravatar() {\n return function(email, size, alternate_avatar, options) {\n var x, y, hash, s = size, a = alternate_avatar;\n if (!email) {\n return '';\n }\n x = email.indexOf('<');\n if (x >= 0) {\n y = email.indexOf('>', x);\n if (y > x)\n email = email.substring(x+1,y);\n }\n if (!size) {\n s = 48; // default to 48 pixels\n }\n hash = email.md5();\n\n if (!a || a == \"none\") {\n if (options && options.no_404)\n alternate_avatar = \"mm\"; // mystery man alternative\n else\n alternate_avatar = \"404\";\n }\n\n return 'https://www.gravatar.com/avatar/' + hash + '?s=' + s + '&d=' + alternate_avatar;\n };\n }\n\n angular\n .module('SOGo.Common')\n .factory('Gravatar', Gravatar);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * @name Resource\n * @constructor\n * @param {Object} $http - the Angular HTTP service\n * @param {Object} $q - the Angular promise/deferred service\n * @param {String} path - the base path of the external resource\n * @param {Object} options - extra attributes to be associated to the object\n */\n function Resource($http, $q, path, activeUser, options) {\n angular.extend(this, {\n _http: $http,\n _q: $q,\n _path: path,\n _activeUser: activeUser\n });\n angular.extend(this, options);\n // Trim trailing slash\n this._path = this._path.replace(/\\/$/, '');\n }\n\n /**\n * @memberof Resource\n * @desc The factory we'll use to register with Angular.\n * @return a new Resource object\n */\n Resource.$factory = ['$http', '$q', function($http, $q) {\n return function(path, activeUser, options) {\n return new Resource($http, $q, path, activeUser, options);\n };\n }];\n\n /**\n * @module SOGo.Common\n * @desc Factory registration of Resource in Angular module.\n */\n angular.module('SOGo.Common').factory('Resource', Resource.$factory);\n\n /**\n * @function userResource\n * @memberof Resource.prototype\n * @desc Create a new Resource object associated to a username different than the active user.\n * @param {String} uid - the user UID\n * @return a new Resource object\n */\n Resource.prototype.userResource = function(uid) {\n var path = _.compact(this._activeUser.folderURL.split('/'));\n path.splice(path.length - 1, 1, escape(uid));\n\n return new Resource(this._http, this._q, '/' + path.join('/'), this._activeUser);\n };\n\n /**\n * @function fetch\n * @memberof Resource.prototype\n * @desc Fetch resource using a specific folder, action and/or parameters.\n * @param {string} folderId - the folder on which the action will be applied (ex: addressbook, calendar)\n * @param {string} action - the action to be used in the URL\n * @param {Object} params - Object parameters injected through the $http service\n * @return a promise\n */\n Resource.prototype.fetch = function(folderId, action, params) {\n var deferred = this._q.defer(),\n path = [this._path];\n if (folderId) path.push(folderId.split('/'));\n if (action) path.push(action);\n path = _.compact(_.flatten(path)).join('/');\n\n this._http({\n method: 'GET',\n url: path,\n params: params\n })\n .then(function(response) {\n return deferred.resolve(response.data);\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n /**\n * @function newguid\n * @memberof Resource.prototype\n * @desc Fetch a new GUID on the specified folder ID.\n * @return a promise of the new data structure\n */\n Resource.prototype.newguid = function(folderId) {\n var deferred = this._q.defer(),\n path = this._path + '/' + folderId + '/newguid';\n\n this._http\n .get(path)\n .then(function(response) {\n return deferred.resolve(response.data);\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n /**\n * @function create\n * @memberof Resource.prototype\n * @desc Create a new resource using a specific action (post).\n * @param {string} action - the action to be used in the URL\n * @param {string} name - the new resource's name\n * @return a promise\n */\n Resource.prototype.create = function(action, name) {\n var deferred = this._q.defer(),\n path = this._path + '/' + action;\n\n this._http\n .post(path, { name: name })\n .then(function(response) {\n return deferred.resolve(response.data);\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n /**\n * @function post\n * @memberof Resource.prototype\n * @desc Post a resource attributes on the server.\n * @return a promise\n */\n Resource.prototype.post = function(id, action, data) {\n var deferred = this._q.defer(),\n path = [this._path];\n if (id) path.push(id);\n if (action) path.push(action);\n path = _.compact(_.flatten(path)).join('/');\n\n this._http\n .post(path, data)\n .then(function(response) {\n return deferred.resolve(response.data);\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n /**\n * @function save\n * @memberof Resource.prototype\n * @desc Save a resource attributes on the server (post /save).\n * @return a promise\n */\n Resource.prototype.save = function(id, newValue, options) {\n var action = (options && options.action)? options.action : 'save';\n\n return this.post(id, action, newValue);\n };\n\n /**\n * @function download\n * @memberof Resource.prototype\n * @desc Download a file from the server. Requires FileSaver.js.\n * @see {@link http://blog.davidjs.com/2015/07/download-files-via-post-request-in-angularjs/|Download files via POST request in AngularJs}\n * @see {@link https://github.com/eligrey/FileSaver.js|FileSaver.js}\n * @return a promise\n */\n Resource.prototype.download = function(id, action, data, options) {\n var deferred = this._q.defer(),\n type = (options && options.type)? options.type : 'application/zip',\n path = [this._path];\n if (id) path.push(id);\n if (action) path.push(action);\n path = _.compact(_.flatten(path)).join('/');\n\n function getFileNameFromHeader(header) {\n var result;\n\n if (!header) return null;\n result = header.split(\";\")[1].trim().split(\"=\")[1];\n\n return result.replace(/\"/g, '');\n }\n\n return this._http({\n method: 'POST',\n url: path,\n data: data,\n headers: {\n accept: type\n },\n responseType: 'arraybuffer',\n cache: false,\n transformResponse: function (data, headers) {\n var fileName, result, blob = null;\n\n if (data) {\n blob = new Blob([data], { type: type });\n }\n fileName = getFileNameFromHeader(headers('content-disposition'));\n\n if (!saveAs) {\n throw new Error('To use Resource.download, FileSaver.js must be loaded.');\n }\n else {\n saveAs(blob, fileName);\n }\n }\n });\n };\n\n /**\n * @function remove\n * @memberof Resource.prototype\n * @desc Delete a resource (get /delete).\n * @return a promise\n */\n Resource.prototype.remove = function(uid) {\n var deferred = this._q.defer(),\n path = this._path + '/' + uid + '/delete';\n\n this._http\n .get(path)\n .then(function(response) {\n return deferred.resolve(response.data);\n }, deferred.reject);\n\n return deferred.promise;\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n \n /**\n * sgFocus - A service to set the focus on the element associated to a specific string\n * @memberof SOGo.Common\n * @param {string} name - the string identifier of the element\n * @see {@link SOGo.Common.sgFocusOn}\n * @ngInject\n */\n sgFocus.$inject = ['$rootScope', '$timeout'];\n function sgFocus($rootScope, $timeout) {\n return function(name) {\n $timeout(function() {\n $rootScope.$broadcast('sgFocusOn', name);\n });\n };\n }\n\n angular\n .module('SOGo.Common')\n .factory('sgFocus', sgFocus);\n})();\n","/* -*- Mode: js; indent-tabs-mode: nil; js-indent-level: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /**\n * $sgHotkeys - A service to associate keyboard shortcuts to actions.\n * @memberof SOGo.Common\n *\n * @description\n * This service is a modified version of angular-hotkeys-light by Eugene Brodsky:\n * https://github.com/fupslot/angular-hotkeys-light\n */\n function $sgHotkeys() {\n\n // Key-code values for various meta-keys.\n // Source : http://www.cambiaresearch.com/articles/15/javascript-char-codes-key-codes\n // http://unixpapa.com/js/key.html\n // Date: Oct 02, 2015.\n var KEY_CODES = {\n 8: 'backspace',\n 9: 'tab',\n 13: 'enter',\n 16: 'shift',\n 17: 'ctrl',\n 18: 'alt',\n 19: 'pause',\n 20: 'caps',\n 27: 'escape',\n 32: 'space',\n 33: 'pageup',\n 34: 'pagedown',\n 35: 'end',\n 36: 'home',\n 37: 'left',\n 38: 'up',\n 39: 'right',\n 40: 'down',\n 45: 'insert',\n 46: 'delete',\n // Numpad\n 96: '0',\n 97: '1',\n 98: '2',\n 99: '3',\n 100: '4',\n 101: '5',\n 102: '6',\n 103: '7',\n 104: '8',\n 105: '9',\n 106: '*',\n 107: '+',\n 109: '-',\n 110: '.',\n 111: '/',\n // Function keys\n 112: 'f1',\n 113: 'f2',\n 114: 'f3',\n 115: 'f4',\n 116: 'f5',\n 117: 'f6',\n 118: 'f7',\n 119: 'f8',\n 120: 'f9',\n 121: 'f10',\n 122: 'f11',\n 123: 'f12'\n };\n // Char-code values for characters that require a key combinations\n var CHAR_CODES = {\n 42: '*',\n 63: '?'\n };\n\n this.$get = getService;\n\n getService.$inject = ['$rootScope', '$window'];\n function getService($rootScope, $window) {\n\n var wrapWithApply = function (fn) {\n return function(event, args) {\n $rootScope.$apply(function() {\n fn.call(this, event, args);\n }.bind(this));\n };\n };\n\n var HotKey = function(params) {\n this.id = params.id || guid();\n this.key = params.key;\n this.description = params.description || null;\n this.context = params.context || null;\n this.callback = params.callback;\n this.preventInClass = params.preventInClass;\n this.args = params.args;\n this.onKeyUp = false;\n\n if (this.key.length > 1)\n // Automatically translate common hotkeys\n this.lkey = l('key_' + this.key);\n };\n\n HotKey.prototype.clone = function() {\n return new HotKey(this);\n };\n\n var Hotkeys = function() {\n /**\n * Sometimes a UI wants keybindings which are global, so called hotkeys.\n * Keys are keystrings (identify key combinations) and values are objects\n * with keys callback, context.\n */\n this._hotkeys = {};\n\n /**\n * Sometimes a UI wants keybindings for keyup behaviour.\n */\n this._hotkeysUp = {};\n\n /**\n * Keybindings are ignored by default when coming from a form input field.\n */\n this._preventIn = ['INPUT', 'SELECT', 'TEXTAREA', 'MD-OPTION'];\n\n /**\n * Keybindings are ignored by default when coming from special elements\n */\n this._preventInClass = ['md-chip-content'];\n\n this._onKeydown = this._onKeydown.bind(this);\n this._onKeyup = this._onKeyup.bind(this);\n this._onKeypress = this._onKeypress.bind(this);\n\n this.initialize();\n };\n\n /**\n * Binds Keydown, Keyup with the window object\n */\n Hotkeys.prototype.initialize = function() {\n this.registerHotkey(\n this.createHotkey({\n key: '?',\n description: l('Show or hide this help'),\n callback: this._toggleCheatSheet.bind(this)\n })\n );\n\n $window.addEventListener('keydown', this._onKeydown, true);\n $window.addEventListener('keyup', this._onKeyup, true);\n $window.addEventListener('keypress', this._onKeypress, true);\n };\n\n /**\n * Invokes callback functions assosiated with the given hotkey\n * @param {Event} event\n * @param {String} keyString hotkey\n * @param {Array.<HotKey>} hotkeys List of registered callbacks for\n * the given hotkey\n * @private\n */\n Hotkeys.prototype._invokeHotkeyHandlers = function(event, keyString, hotkeys) {\n for (var i = 0, l = hotkeys.length; i < l; i++) {\n var hotkey = hotkeys[i],\n target = event.target || event.srcElement,\n nodeName = target.nodeName.toUpperCase();\n if (!_.includes(this._preventIn, nodeName) &&\n _.intersection(target.classList, this._preventInClass).length === 0 &&\n _.intersection(target.classList, hotkey.preventInClass).length === 0) {\n try {\n hotkey.callback.call(hotkey.context, event, hotkey.args);\n } catch(e) {\n console.error('HotKeys: ', hotkey.key, e.message);\n }\n }\n }\n };\n\n /**\n * Keydown Event Handler\n * @private\n */\n Hotkeys.prototype._onKeydown = function(event) {\n var keyString = this.keyStringFromEvent(event);\n if (this._hotkeys[keyString]) {\n this._invokeHotkeyHandlers(event, keyString, this._hotkeys[keyString]);\n }\n };\n\n /**\n * Keyup Event Handler\n * @private\n */\n Hotkeys.prototype._onKeyup = function(event) {\n var keyString = this.keyStringFromEvent(event);\n if (this._hotkeysUp[keyString]) {\n this._invokeHotkeyHandlers(this._hotkeysUp[keyString], keyString);\n }\n };\n\n /**\n * Keypress Event Handler\n * @private\n */\n Hotkeys.prototype._onKeypress = function(event) {\n var charCode, keyString;\n\n charCode = event.keyCode || event.which;\n keyString = CHAR_CODES[charCode];\n if (keyString && this._hotkeys[keyString]) {\n this._invokeHotkeyHandlers(event, keyString, this._hotkeys[keyString]);\n }\n };\n\n /**\n * Cross-browser method which can extract a key string from an event.\n * Key strings are of the form\n *\n * ctrl+alt+shift+meta+character\n *\n * where each of the 4 modifiers may or may not appear, but always appear\n * in that order if they do appear.\n *\n * TODO : this is not yet implemented fully. The trouble is, the keyCode,\n * charCode, and which properties of the DOM standard KeyboardEvent are\n * discouraged in favour of the use of key and char, but key and char are\n * not yet implemented in Gecko nor in Blink/Webkit. We need to leverage\n * keyCode/charCode so that current browser versions are supported, but also\n * look to key and char because they're apparently more useful and are the\n * future.\n */\n Hotkeys.prototype.keyStringFromEvent = function(event) {\n var result = [];\n var key = event.which;\n\n if (KEY_CODES[key]) {\n key = KEY_CODES[key];\n } else {\n key = String.fromCharCode(key).toLowerCase();\n }\n\n if (event.ctrlKey) { result.push('ctrl'); }\n if (event.altKey) { result.push('alt'); }\n if (event.shiftKey) { result.push('shift'); }\n if (event.metaKey) { result.push('meta'); }\n result.push(key);\n return _.uniq(result).join('+');\n };\n\n /**\n * Unregister a hotkey (shortcut) helper for (keyUp/keyDown).\n *\n * @param {String} params.key - valid key string.\n */\n Hotkeys.prototype._deregisterHotkey = function(hotkey) {\n var ret;\n var table = this._hotkeys;\n\n if (hotkey.onKeyUp) {\n table = this._hotkeysUp;\n }\n\n if (table[hotkey.key]) {\n var callbackArray = table[hotkey.key];\n for (var i = 0; i < callbackArray.length; ++i) {\n var callbackData = callbackArray[i];\n if ((hotkey.callback === callbackData.callback &&\n callbackData.context === hotkey.context) ||\n (hotkey.id === callbackData.id)) {\n ret = callbackArray.splice(i, 1);\n }\n }\n if (callbackArray.length === 0)\n delete this._hotkeys[hotkey.key];\n }\n return ret;\n };\n\n /**\n * Unregister hotkeys\n * @param {Hotkey} hotkey A hotkey object\n * @return {Array}\n */\n Hotkeys.prototype.deregisterHotkey = function(hotkey) {\n var result = [];\n\n this._validateHotkey(hotkey);\n\n if (angular.isArray(hotkey.key)) {\n for (var i = hotkey.key.length - 1; i >= 0; i--) {\n var clone = hotkey.clone();\n clone.key = hotkey.key[i];\n var ret = this._deregisterHotkey(clone);\n if (ret !== void 0) {\n result.push(ret[0]);\n }\n }\n } else {\n result.push(this._deregisterHotkey(hotkey));\n }\n return result;\n };\n\n /**\n * Validate HotKey type\n */\n Hotkeys.prototype._validateHotkey = function(hotkey) {\n if (!(hotkey instanceof HotKey)) {\n throw new TypeError('Hotkeys: Expected a hotkey object be instance of HotKey');\n }\n };\n\n /**\n * Register a hotkey (shortcut) helper for (keyUp/keyDown).\n * @param {Object} params Parameters object\n * @param {String} params.key - valid key string.\n * @param {Function} params.callback - routine to run when key is pressed.\n * @param {Object} params.context - @this value in the callback.\n * @param [Boolean] params.onKeyUp - if this is intended for a keyup.\n * @param [String] params.id - the identifier for this registration.\n */\n Hotkeys.prototype._registerKey = function(hotkey) {\n var table = this._hotkeys;\n\n if (hotkey.onKeyUp) {\n table = this._hotkeysUp;\n }\n\n table[hotkey.key] = table[hotkey.key] || [];\n table[hotkey.key].push(hotkey);\n return hotkey;\n };\n\n Hotkeys.prototype._registerKeys = function(hotkey) {\n var result = [];\n\n if (angular.isArray(hotkey.key)) {\n for (var i = hotkey.key.length - 1; i >= 0; i--) {\n var clone = hotkey.clone();\n clone.id = guid();\n clone.key = hotkey.key[i];\n result.push(this._registerKey(clone));\n }\n } else {\n result.push(this._registerKey(hotkey));\n }\n return result;\n };\n\n /**\n * Register a hotkey (shortcut). see _registerHotKey\n */\n Hotkeys.prototype.registerHotkey = function(hotkey) {\n this._validateHotkey(hotkey);\n return this._registerKeys(hotkey);\n };\n\n /**\n * Register a hotkey (shortcut) keyup behavior.\n * see _registerHotKey\n */\n Hotkeys.prototype.registerHotkeyUp = function(hotkey) {\n this._validateHotkey(hotkey);\n hotkey.onKeyUp = true;\n this._registerKeys(hotkey);\n };\n\n /**\n * Creates new hotkey object.\n * @param {Object} args\n * @return {HotKey}\n */\n Hotkeys.prototype.createHotkey = function(args) {\n if (args.key === null || args.key === void 0) {\n throw new TypeError('HotKeys: Argument \"key\" is required');\n }\n\n if (args.callback === null || args.callback === void 0) {\n throw new TypeError('HotKeys: Argument \"callback\" is required');\n }\n\n args.callback = wrapWithApply(args.callback);\n return new HotKey(args);\n };\n\n /**\n * Checks if given shortcut match the event\n * @param {Event} event An event\n * @param {String|Array} key A shortcut\n * @return {Boolean}\n */\n Hotkeys.prototype.match = function(event, key) {\n if (!angular.isArray(key)) {\n key = [key];\n }\n\n var eventHotkey = this.keyStringFromEvent(event);\n return Boolean(~key.indexOf(eventHotkey));\n };\n\n /**\n * Build and display (or hide) the hotkeys cheat sheet\n *\n * If a hotkey is registered multiple times, only the description of the first registered\n * hotkey is displayed.\n */\n Hotkeys.prototype._toggleCheatSheet = function() {\n var _this = this;\n\n if (this._cheatSheet) {\n Hotkeys.$modal.hide();\n this._cheatSheet = null;\n }\n else {\n this._cheatSheet = Hotkeys.$modal\n .show({\n clickOutsideToClose: true,\n escapeToClose: true,\n template: [\n '<md-dialog>',\n ' <md-dialog-content>',\n ' <md-list>',\n ' <md-list-item ng-repeat=\"(hotkey, keys) in hotkeys\">',\n ' <div class=\"sg-hotkey-container\">',\n ' <sg-hotkey>{{keys[0].lkey || hotkey}}</sg-hotkey>',\n ' </div>',\n ' {{keys[0].description}}',\n ' </md-list-item>',\n ' </md-list>',\n ' </md-dialog-content>',\n '</md-dialog>'\n ].join(''),\n controller: CheatSheetController,\n locals: {\n hotkeys: _this._hotkeys\n }\n })\n .finally(function() {\n _this._cheatSheet = null;\n });\n }\n\n CheatSheetController.$inject = ['$scope', 'hotkeys'];\n function CheatSheetController($scope, hotkeys) {\n $scope.hotkeys = hotkeys;\n $scope.closeDialog = function() {\n Hotkeys.$modal.hide();\n };\n }\n };\n\n return Hotkeys;\n }\n }\n\n sgHotkeys.$inject = ['$mdDialog', '$sgHotkeys'];\n function sgHotkeys($mdDialog, $sgHotkeys) {\n angular.extend($sgHotkeys, { $modal: $mdDialog });\n\n return new $sgHotkeys();\n }\n\n angular\n .module('SOGo.Common')\n .service('sgHotkeys', sgHotkeys)\n .provider('$sgHotkeys', $sgHotkeys);\n})();\n","(function() {\n 'use strict';\n\n /**\n * @name User\n * @constructor\n * @param {object} [userData] - some default values for the user\n */\n function User(userData) {\n if (userData) {\n this.init(userData);\n }\n }\n\n /**\n * @memberof User\n * @desc The factory we'll use to register with Angular.\n * @return the User constructor\n */\n User.factory = ['$q', '$log', 'sgSettings', 'Resource', function($q, $log, Settings, Resource) {\n angular.extend(User, {\n $q: $q,\n $log: $log,\n $$resource: new Resource(Settings.activeUser('folderURL'), Settings.activeUser()),\n $query: '',\n $users: []\n });\n\n return User;\n }];\n\n /**\n * @module SOGo.Common\n * @desc Factory registration of User in Angular module.\n */\n angular.module('SOGo.Common').factory('User', User.factory);\n\n /**\n * @memberof User\n * @desc Search for users that match a string.\n * @param {string} search - a string used to performed the search\n * @param {object[]} excludedUsers - a list of User objects that must be excluded from the results\n * @return a promise of an array of matching User objects\n */\n User.$filter = function(search, excludedUsers, options) {\n var _this = this, param = {search: search};\n\n if (!options || !options.dry) {\n if (!search) {\n // No query specified\n User.$users.splice(0, User.$users.length);\n return User.$q.when(User.$users);\n }\n if (User.$query == search) {\n // Query hasn't changed\n return User.$q.when(User.$users);\n }\n User.$query = search;\n }\n\n return User.$$resource.fetch(null, 'usersSearch', param).then(function(response) {\n var results, index, user, users,\n compareUids = function(data) {\n return this.uid == data.uid;\n };\n\n if (options) {\n if (options.dry)\n users = [];\n else if (options.results)\n users = options.results;\n }\n else\n users = User.$users;\n\n if (excludedUsers) {\n // Remove excluded users from response\n results = _.filter(response.users, function(user) {\n return !_.find(excludedUsers, _.bind(compareUids, user));\n });\n }\n else {\n results = response.users;\n }\n\n // Remove users that no longer match the search query\n for (index = users.length - 1; index >= 0; index--) {\n user = users[index];\n if (!_.find(results, _.bind(compareUids, user))) {\n users.splice(index, 1);\n }\n }\n // Add new users matching the search query\n _.forEach(results, function(data, index) {\n if (_.isUndefined(_.find(users, _.bind(compareUids, data)))) {\n var user = new User(data);\n users.splice(index, 0, user);\n }\n });\n User.$log.debug(users);\n return users;\n });\n };\n\n /**\n * @function init\n * @memberof User.prototype\n * @desc Extend instance with required attributes and new data.\n * @param {object} data - attributes of user\n */\n User.prototype.init = function(data) {\n angular.extend(this, data);\n if (!this.$$shortFormat)\n this.$$shortFormat = this.$shortFormat();\n if (!this.$$image)\n this.$$image = this.image;\n // NOTE: We can't assign a Gravatar at this stage since we would need the Preferences module\n // which already depend on the User module.\n\n // An empty attribute to trick md-autocomplete when adding users from the ACLs editor\n this.empty = ' ';\n };\n\n /**\n * @function $shortFormat\n * @memberof User.prototype\n * @return the fullname along with the email address\n */\n User.prototype.$shortFormat = function(options) {\n var fullname = this.cn || this.c_email;\n var email = this.c_email;\n var no_email = options && options.email === false;\n if (!no_email && email && fullname != email) {\n fullname += ' <' + email + '>';\n }\n return fullname;\n };\n\n /**\n * @function $acl\n * @memberof User.prototype\n * @desc Fetch the user rights associated to a specific folder and populate the 'rights' attribute.\n * @param {string} the folder ID\n * @param {Object} owner - the owner to use when fetching the ACL as it might not be the Settings.activeUser\n * @return a promise\n */\n User.prototype.$acl = function(folderId, owner) {\n var _this = this,\n deferred = User.$q.defer(),\n param = {uid: this.uid};\n if (this.$shadowRights) {\n deferred.resolve(this.rights);\n }\n else {\n var rights;\n\n if (angular.isDefined(owner))\n rights = User.$$resource.userResource(owner).fetch(folderId, 'userRights', param);\n else\n rights = User.$$resource.fetch(folderId, 'userRights', param);\n\n rights.then(function(data) {\n _this.rights = data;\n // Convert numbers (0|1) to boolean values\n //angular.forEach(_.keys(_this.rights), function(key) {\n // _this.rights[key] = _this.rights[key] ? true : false;\n //});\n // console.debug('rights ' + _this.uid + ' => ' + JSON.stringify(data, undefined, 2));\n // Keep a copy of the server's version\n _this.$shadowRights = angular.copy(data);\n deferred.resolve(data);\n return data;\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $isAnonymous\n * @memberof User.prototype\n * @return true if it's the special anonymous user\n */\n User.prototype.$isAnonymous = function() {\n return this.uid == 'anonymous';\n };\n\n /**\n * @function $isSpecial\n * @memberof User.prototype\n * @desc Only accurate from the ACL editor.\n * @return true if the user is not a regular system user\n */\n User.prototype.$isSpecial = function() {\n return this.userClass && this.userClass == 'public-user';\n };\n\n /**\n * @function $confirmRights\n * @memberof User.prototype\n * @desc Check if a confirmation is required before giving some rights.\n * @return the confirmation message or false if no confirmation is required\n */\n User.prototype.$confirmRights = function(folder) {\n var confirmation = false;\n\n if (this.$confirmation) {\n // Don't bother the user more than once\n return false;\n }\n\n if (_.some(_.values(this.rights))) {\n if (this.uid == 'anonymous') {\n if (folder.constructor.name == 'AddressBook')\n confirmation = l('Potentially anyone on the Internet will be able to access your address book \"%{0}\", even if they do not have an account on this system. Is this information suitable for the public Internet?', folder.name);\n else if (folder.constructor.name == 'Calendar')\n confirmation = l('Potentially anyone on the Internet will be able to access your calendar \"%{0}\", even if they do not have an account on this system. Is this information suitable for the public Internet?', folder.name);\n }\n else if (this.uid == 'anyone' || this.uid == '<default>') {\n if (folder.constructor.name == 'AddressBook')\n confirmation = l('Any user with an account on this system will be able to access your address book \"%{0}\". Are you certain you trust them all?', folder.name);\n else if (folder.constructor.name == 'Calendar')\n confirmation = l('Any user with an account on this system will be able to access your calendar \"%{0}\". Are you certain you trust them all?', folder.name);\n else if (folder.constructor.name == 'Mailbox')\n confirmation = l('Any user with an account on this system will be able to access your mailbox \"%{0}\". Are you certain you trust them all?', folder.name);\n }\n }\n\n this.$confirmation = confirmation;\n\n return confirmation;\n };\n\n /**\n * @function $rightsAreDirty\n * @memberof User.prototype\n * @return whether or not the rights have changed from their initial values\n */\n User.prototype.$rightsAreDirty = function() {\n return this.rights && !_.isEqual(this.rights, this.$shadowRights);\n };\n\n /**\n * @function $resetRights\n * @memberof User.prototype\n * @desc Restore initial rights or disable all rights\n * @param {boolean} [zero] - reset all rights to zero when true\n */\n User.prototype.$resetRights = function(zero) {\n var _this = this;\n if (zero) {\n // Disable all rights\n _.map(_.keys(this.rights), function(key) {\n if (angular.isString(_this.rights[key]))\n _this.rights[key] = 'None';\n else\n _this.rights[key] = 0;\n });\n }\n else if (this.$shadowRights) {\n // Restore initial rights\n this.rights = angular.copy(this.$shadowRights);\n }\n };\n\n /**\n * @function $folders\n * @memberof User.prototype\n * @desc Retrieve the list of folders of a specific type\n * @param {string} type - either 'contact' or 'calendar'\n * @return a promise of the HTTP query result or the cached result\n */\n User.prototype.$folders = function(type) {\n var _this = this,\n deferred = User.$q.defer(),\n param = {type: type};\n if (this.$$folders) {\n deferred.resolve(this.$$folders);\n }\n else {\n User.$$resource.userResource(this.uid).fetch(null, 'foldersSearch', param).then(function(response) {\n _this.$$folders = response.folders;\n deferred.resolve(response.folders);\n });\n }\n return deferred.promise;\n };\n\n /**\n * @function $omit\n * @memberof User.prototype\n * @desc Return a sanitized object used to send to the server.\n * @return an object literal copy of the User instance\n */\n User.prototype.$omit = function() {\n var user = {};\n angular.forEach(this, function(value, key) {\n if (key != 'constructor' && key[0] != '$') {\n user[key] = value;\n }\n });\n return user;\n };\n\n User.prototype.toString = function() {\n return '[User ' + this.c_email + ']';\n };\n\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true, newcap: false */\n 'use strict';\n\n /**\n * sgAvatarImage - An avatar directive that returns un img element with either a local URL (if sg-src is specified)\n * or a Gravatar URL built from the Gravatar factory (using sg-email).\n * Based on http://blog.lingohub.com/2014/08/better-ux-with-angularjs-directives/.\n * @memberof SOGo.Common\n * @example:\n <sg-avatar-image sg-email=\"test@email.com\" size=\"50\"></sg-avatar-image>\n */\n function sgAvatarImage() {\n return {\n restrict: 'AE',\n scope: {},\n bindToController: {\n size: '@',\n email: '=sgEmail',\n src: '=sgSrc'\n },\n template: [\n '<md-icon>person</md-icon>', // the generic icon\n '<img class=\"ng-hide\" ng-src=\"{{vm.url}}\" />' // the gravatar or local image\n ].join(''),\n link: link,\n controller: 'sgAvatarImageController',\n controllerAs: 'vm'\n };\n }\n\n function link(scope, element, attrs, controller) {\n var imgElement = element.find('img'),\n mdIconElement = element.find('md-icon');\n\n if (attrs.size) {\n imgElement.attr('width', attrs.size);\n imgElement.attr('height', attrs.size);\n mdIconElement.css('font-size', attrs.size + 'px');\n }\n\n controller.img = imgElement;\n controller.genericImg = mdIconElement;\n }\n\n /**\n * @ngInject\n */\n sgAvatarImageController.$inject = ['$scope', '$element', '$http', '$q', 'Preferences', 'Gravatar'];\n function sgAvatarImageController($scope, $element, $http, $q, Preferences, Gravatar) {\n var vm, toggleZoomFcn;\n\n vm = this;\n\n $scope.$on('$destroy', function() {\n if (toggleZoomFcn)\n $element.off('click', toggleZoomFcn);\n });\n\n // Wait on user's defaults\n Preferences.ready().then(function() {\n $scope.$watch(function() { return vm.email; }, function(email, old) {\n if (email && vm.urlEmail != email) {\n // Email has changed or doesn't match the current URL (this happens when using md-virtual-repeat)\n showGenericAvatar();\n if (Preferences.defaults.SOGoGravatarEnabled)\n getGravatar(email);\n }\n else if (!email)\n showGenericAvatar();\n });\n });\n\n // If sg-src is defined, watch the expression for the URL of a local image\n if ('sg-src' in $element[0].attributes) {\n $scope.$watch(function() { return vm.src; }, function(src) {\n if (src) {\n // Set image URL and save the associated email address\n vm.url = src;\n vm.urlEmail = '' + vm.email;\n configureZoomableAvatar();\n hideGenericAvatar();\n }\n });\n }\n\n function getGravatar(email) {\n var url = Gravatar(email, vm.size, Preferences.defaults.SOGoAlternateAvatar);\n $http({\n method: 'GET',\n url: url,\n cache: true,\n headers: { Accept: 'image/*' }\n }).then(function successCallback() {\n if (!vm.url) {\n // Set image URL and save the associated email address\n vm.url = url;\n vm.urlEmail = email;\n hideGenericAvatar();\n }\n }, function errorCallback() {\n showGenericAvatar();\n });\n }\n\n function showGenericAvatar() {\n vm.url = null;\n vm.urlEmail = null;\n vm.img.addClass('ng-hide');\n vm.genericImg.removeClass('ng-hide');\n }\n\n function hideGenericAvatar() {\n vm.genericImg.addClass('ng-hide');\n vm.img.removeClass('ng-hide');\n }\n\n function configureZoomableAvatar() {\n $element.addClass('sg-avatar-image--zoomable');\n toggleZoomFcn = function() {\n $element.toggleClass('sg-avatar-image--zoom');\n };\n $element.on('click', toggleZoomFcn);\n }\n\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgAvatarImage', sgAvatarImage)\n .controller('sgAvatarImageController', sgAvatarImageController);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n angular\n .module('SOGo.Common')\n .directive('sgCheckmark', sgCheckmarkDirective);\n\n /*\n * sgCheckmark - A checkmark to be used in a mdMenuItem\n * @memberof SOGo.Common\n * @restrict element\n *\n * @example:\n\n <md-menu>\n <md-button class=\"md-icon-button\" aria-label=\"Sort\"\n ng-click=\"$mdOpenMenu()\">\n <md-icon>sort</md-icon>\n </md-button>\n <md-menu-content>\n <md-menu-item>\n <sg-checkmark\n aria-label=\"Descending Order\"\n ng-model=\"ctrl.asc\"\n ng-click=\"ctrl.filter()\"\n sg-true-value=\"0\"\n sg-false-value=\"1\">Descending Order</sg-checkmark>\n </md-menu-item> \n </md-menu-content>\n </md-menu>\n */\n sgCheckmarkDirective.$inject = ['$parse', '$mdAria', '$mdTheming', '$mdUtil'];\n function sgCheckmarkDirective($parse, $mdAria, $mdTheming, $mdUtil) {\n var CHECKED_CSS = 'sg-checked';\n\n return {\n restrict: 'E',\n replace: true,\n transclude: true,\n require: '?ngModel',\n //priority: 210, // Run before ngAria\n template: [\n '<button class=\"md-button sg-checkmark\" type=\"button\">',\n ' <md-icon>check</md-icon>',\n ' <span ng-transclude></span',\n '</button>'\n ].join(''),\n compile: compile\n };\n\n function compile(tElement, tAttrs) {\n\n // Attach a click handler in compile in order to immediately stop propagation\n // (especially for ng-click) when the checkmark is disabled.\n tElement.on('click', function(event) {\n if (this.hasAttribute('disabled')) {\n event.stopImmediatePropagation();\n }\n });\n\n return function postLink(scope, element, attr, ngModelCtrl) {\n // See https://github.com/angular/angular.js/commit/c90cefe16142d973a123e945fc9058e8a874c357\n var trueValue = parseConstantExpr($parse, scope, 'sgTrueValue', attr.sgTrueValue, true),\n falseValue = parseConstantExpr($parse, scope, 'sgFalseValue', attr.sgFalseValue, false);\n \n ngModelCtrl = ngModelCtrl || $mdUtil.fakeNgModel();\n $mdTheming(element);\n\n $mdAria.expectWithText(element, 'aria-label');\n\n element.on('click', listener);\n\n ngModelCtrl.$render = render;\n\n function parseConstantExpr($parse, context, name, expression, fallback) {\n var parseFn;\n if (angular.isDefined(expression)) {\n parseFn = $parse(expression);\n if (!parseFn.constant) {\n throw Error('Expected constant expression for `' + name + '`, but saw `' + expression + '`.');\n }\n return parseFn(context);\n }\n return fallback;\n }\n\n function listener(ev) {\n if (element[0].hasAttribute('disabled')) {\n return;\n }\n\n scope.$apply(function() {\n // Toggle the checkmark value\n var viewValue = ngModelCtrl.$viewValue == trueValue? falseValue : trueValue;\n\n ngModelCtrl.$setViewValue( viewValue, ev && ev.type);\n ngModelCtrl.$render();\n });\n }\n\n function render() {\n if (ngModelCtrl.$viewValue == trueValue)\n element.addClass(CHECKED_CSS);\n else\n element.removeClass(CHECKED_CSS);\n }\n };\n }\n }\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgColorPicker - Color picker widget\n * @restrict element\n * @param {function} sgOnSelect - the function to call when clicking on a color.\n * One variable is available: color.\n * @ngInject\n * @example:\n\n <sg-color-picker sg-on-select=\"properties.calendar.color = color\"></sg-color-picker>\n */\n function sgColorPicker() {\n return {\n restrict: 'E',\n require: 'ngModel',\n template: [\n '<md-menu>',\n ' <md-button class=\"md-icon-button\"',\n ' label:aria-label=\"Options\"',\n ' ng-style=\"{ \\'background-color\\': sgColor }\"',\n ' ng-click=\"$mdOpenMenu()\"',\n ' md-menu-origin=\"md-menu-origin\">',\n ' <md-icon ng-style=\"{ color: sgIconColor }\">color_lens</md-icon>',\n ' </md-button>',\n ' <md-menu-content width=\"3\">',\n ' <md-content class=\"md-padding\">',\n ' <md-grid-list class=\"sg-color-picker\" md-cols=\"7\" md-row-height=\"1:1\" md-gutter=\"0.5em\">',\n ' <md-grid-tile ng-repeat=\"color in ::sgColors track by $index\"',\n ' ng-style=\"::{ \\'background-color\\': color }\"',\n ' ng-class=\"::{ selected: color == sgColor }\"',\n ' ng-click=\"setColor($event, color)\"><md-icon ng-style=\"::{ color: color }\">check_box</md-icon></md-grid-tile>',\n ' </md-grid-list>',\n ' </md-content>',\n ' </md-menu-content>',\n '</md-menu>'\n ].join(''),\n replace: true,\n controller: sgColorPickerController,\n link: link\n };\n\n function link(scope, iElement, iAttr, ngModelController) {\n // Expose ng-model value to scope\n ngModelController.$render = function() {\n scope.sgColor = ngModelController.$viewValue;\n scope.sgIconColor = contrast(ngModelController.$viewValue);\n };\n }\n }\n \n /**\n * @ngInject\n */\n sgColorPickerController.$inject = ['$scope', '$element', 'sgColors'];\n function sgColorPickerController($scope, $element, sgColors) {\n var ngModelController = $element.controller('ngModel');\n\n $scope.sgColors = sgColors.selection;\n $scope.setColor = function(event, color) {\n if (event) {\n _.forEach(event.currentTarget.parentElement.children, function(tile) {\n tile.classList.remove('selected');\n });\n event.currentTarget.classList.add('selected');\n }\n // Update scope value and ng-model\n $scope.sgColor = color;\n $scope.sgIconColor = contrast(color);\n ngModelController.$setViewValue(color);\n };\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgColorPicker', sgColorPicker);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgCompile - Assign an expression to a DOM element and compile it.\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {object} sgCompile - the expression to compile\n * @ngInject\n * @example:\n\n <div sg-compile=\"part.content\"><!-- msg --></div>\n */\n sgCompile.$inject = ['$compile'];\n function sgCompile($compile) {\n return {\n restrict: 'A',\n link: sgCompileLink\n };\n\n function sgCompileLink(scope, element, attrs) {\n var ensureCompileRunsOnce = scope.$watch(\n function(scope) {\n // Watch the sg-compile expression for changes\n return scope.$eval(attrs.sgCompile);\n },\n function(value) {\n // When the sg-compile expression changes, assign it into the current DOM\n element.html(value);\n \n // Compile the new DOM and link it to the current scope.\n // NOTE: we only compile .childNodes so that we don't get into infinite loop compiling ourselves\n $compile(element.contents())(scope);\n \n // Use un-watch feature to ensure compilation happens only once.\n ensureCompileRunsOnce();\n }\n );\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgCompile', sgCompile);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgDatepickerReadonlyInput - A directive that disabled the input field of a datepicker.\n * @memberof SOGo.Common\n *\n * @example:\n\n <md-datepicker md-hide-icons=\"triangle\"\n md-open-on-focus=\"md-open-on-focus\"\n ng-model=\"selectedDate\"\n sg-datepicker-readonly-input>\n */\n function sgDatepickerReadonlyInput() {\n return {\n link: postLink,\n require: 'mdDatepicker',\n restrict: 'A'\n };\n\n function postLink(scope, element, attrs, datepickerCtrl) {\n function getInput() {\n return element.find('input').eq(0);\n }\n\n // We need to wait for the autocomplete directive to be compiled\n var listener = scope.$watch(getInput, function (input) {\n if (input.length) {\n listener(); // self release\n input.prop('disabled', true);\n input.parent().addClass('sg-datepicker-readonly-input-container');\n }\n });\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgDatepickerReadonlyInput', sgDatepickerReadonlyInput);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgDraggable - Make an element (usually a folder of elements) draggable.\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {Object=} sgDraggable - the object to be exposed to the droppable target.\n * @param {expression} sgDragStart - dragging will only start if this expression returns true.\n * @param {expression} sgDragCount - the number of items being dragged; this number appears inside\n * the sg-draggable-helper element that follows the mouse cursor.\n *\n * @example:\n\n <sg-draggable-helper>\n <md-icon>email</md-icon>\n <sg-draggable-helper-counter></sg-draggable-helper-counter>\n </sg-draggable-helper>\n\n <md-list sg-draggable=\"mailbox.service.selectedFolder\"\n sg-drag-start=\"mailbox.selectedFolder.$selectedCount()\"\n sg-drag-count=\"mailbox.selectedFolder.$selectedCount()\">\n */\n sgDraggable.$inject = ['$parse', '$rootScope', '$document', '$timeout', '$log'];\n function sgDraggable($parse, $rootScope, $document, $timeout, $log) {\n return {\n restrict: 'A',\n link: link\n };\n\n function link(scope, element, attrs) {\n var o;\n \n $timeout(function() {\n var folder, dragStart, count;\n\n folder = $parse(attrs.sgDraggable)(scope);\n dragStart = attrs.sgDragStart? $parse(attrs.sgDragStart) : null;\n count = attrs.sgDragCount? $parse(attrs.sgDragCount) : null;\n o = new sgDraggableObject(element, folder, dragStart, count);\n });\n\n scope.$on('$destroy', function() {\n o.$destroy();\n });\n \n function sgDraggableObject($element, folder, dragStart, count) {\n this.$element = $element;\n this.folder = folder;\n this.dragStart = dragStart;\n this.count = count;\n this.helper = $document.find('sg-draggable-helper');\n\n if (!this.helper) {\n throw Error('sg-draggable requires a sg-draggable-helper element.');\n }\n\n this.bindedOnDragDetect = angular.bind(this, this.onDragDetect);\n this.bindedOnDrag = angular.bind(this, this.onDrag);\n\n // Register the mousedown event that can trigger the dragging action\n this.$element.on('mousedown', this.bindedOnDragDetect);\n }\n\n /**\n * sgDraggableObject is an object that wraps the logic to emit the folder:dragstart and\n * folder:dragend custom events.\n */\n sgDraggableObject.prototype = {\n\n dragHasStarted: false,\n\n $destroy: function() {\n this.$element.off('mousedown', this.bindedOnDragDetect);\n },\n\n getDistanceFromStart: function(event) {\n var delta = {\n x: this.startPosition.clientX - event.clientX,\n y: this.startPosition.clientY - event.clientY\n };\n\n return Math.sqrt(delta.x * delta.x + delta.y * delta.y);\n },\n\n\n // Start dragging on mousedown\n onDragDetect: function(ev) {\n var dragMode, pointerHandler;\n\n ev.stopPropagation();\n\n if (!this.dragStart || this.dragStart(scope)) {\n // Listen to mousemove and start dragging when mouse has moved from at least 3 pixels\n $document.on('mousemove', this.bindedOnDrag);\n // Stop dragging on the next \"mouseup\"\n $document.one('mouseup', angular.bind(this, this.onDragEnd));\n }\n },\n\n // \n onDrag: function(ev) {\n var counter;\n\n if (!this.startPosition) {\n this.startPosition = { clientX: ev.clientX, clientY: ev.clientY };\n }\n else if (!this.dragHasStarted && this.getDistanceFromStart(ev) > 10) {\n counter = this.helper.find('sg-draggable-helper-counter');\n this.dragHasStarted = true;\n\n this.helper.removeClass('ng-hide');\n if (this.count && this.count(scope) > 1)\n counter.text(this.count(scope)).removeClass('ng-hide');\n else\n counter.addClass('ng-hide');\n \n $log.debug('emit folder:dragstart');\n $rootScope.$emit('folder:dragstart', this.folder);\n }\n if (this.dragHasStarted) {\n if (ev.shiftKey)\n this.helper.addClass('sg-draggable-helper--copy');\n else\n this.helper.removeClass('sg-draggable-helper--copy');\n this.helper.css({ top: (ev.pageY + 5) + 'px', left: (ev.pageX + 5) + 'px' });\n }\n },\n\n\n onDragEnd: function(ev) {\n this.startPosition = null;\n $document.off('mousemove', this.bindedOnDrag);\n\n if (this.dragHasStarted) {\n $log.debug('emit folder:dragend');\n $rootScope.$emit('folder:dragend', this.folder, ev.shiftKey?'copy':'move');\n this.dragHasStarted = false;\n this.helper.addClass('ng-hide');\n }\n }\n\n };\n\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgDraggable', sgDraggable);\n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgDroppable - Make an element a possible destination while dragging\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {expression} sgDroppable - dropping is accepted only if this expression returs true.\n * One variables is exposed: dragFolder.\n * @param {expression} sgDrop - called when dropping ends on the element.\n * Two variables are exposed: dragFolder and dragMode.\n *\n * @example:\n\n <md-list-item sg-droppable=\"folder.id != dragFolder.id\"\n sg-drop=\"app.dragSelectedMessages(dragFolder, folder, dragMode)\">\n */\n sgDroppable.$inject = ['$parse', '$rootScope', '$document', '$timeout', '$log'];\n function sgDroppable($parse, $rootScope, $document, $timeout, $log) {\n return {\n restrict: 'A',\n link: link\n };\n\n function link(scope, element, attrs) {\n var overElement = false, dropAction, droppable,\n deregisterFolderDragStart, deregisterFolderDragEnd;\n\n if (!attrs.sgDrop) {\n throw Error('sg-droppable requires a sg-drop action.');\n }\n\n overElement = false;\n droppable = $parse(attrs.sgDroppable);\n dropAction = $parse(attrs.sgDrop);\n\n // Register listeners of custom events on root scope\n deregisterFolderDragStart = $rootScope.$on('folder:dragstart', function(event, folder) {\n if (droppable(scope, { dragFolder: folder })) {\n element.on('mouseenter', onEnter);\n element.on('mouseleave', onLeave);\n }\n });\n deregisterFolderDragEnd = $rootScope.$on('folder:dragend', function(event, folder, mode) {\n element.off('mouseenter');\n element.off('mouseleave');\n if (overElement) {\n angular.bind(element[0], onLeave)(event);\n dropAction(scope, { dragFolder: folder, dragMode: mode });\n }\n });\n\n scope.$on('destroy', function() {\n deregisterFolderDragStart();\n deregisterFolderDragEnd();\n });\n\n function onEnter(event) {\n overElement = true;\n element.addClass('sg-droppable-over');\n }\n\n function onLeave(event) {\n overElement = false;\n this.classList.remove('sg-droppable-over');\n element.off('mousemove');\n }\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgDroppable', sgDroppable);\n})();\n\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgEnter - A directive evaluated when the enter key is pressed\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <input type=\"text\"\n sg-enter=\"save($index)\" />\n */\n function sgEnter() {\n var ENTER_KEY = 13;\n return function(scope, element, attrs) {\n element.bind(\"keydown keypress\", function(event) {\n if (event.which === ENTER_KEY) {\n scope.$apply(attrs.sgEnter);\n event.preventDefault();\n }\n });\n };\n }\n \n angular\n .module('SOGo.Common')\n .directive('sgEnter', sgEnter);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgEscape - A directive evaluated when the escape key is pressed\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <input type=\"text\"\n sg-escape=\"revertEditing($index)\" />\n */\n function sgEscape() {\n var ESCAPE_KEY = 27;\n return function(scope, elem, attrs) {\n elem.bind('keydown', function(event) {\n if (event.keyCode === ESCAPE_KEY) {\n scope.$apply(attrs.sgEscape);\n }\n });\n };\n }\n \n angular\n .module('SOGo.Common')\n .directive('sgEscape', sgEscape);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgFocusOn - A directive that sets the focus on its element when the specified string is broadcasted\n * @memberof SOGo.Common\n * @see {@link SOGo.Common.sgFocus}\n * @ngInject\n * @example:\n\n <input type=\"text\"\n sg-focus-on=\"username\" />\n */\n function sgFocusOn() {\n return function(scope, elem, attr) {\n scope.$on('sgFocusOn', function(e, name) {\n if (name === attr.sgFocusOn) {\n elem[0].focus();\n elem[0].select();\n }\n });\n };\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgFocusOn', sgFocusOn);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgFolderStylesheet - Add CSS stylesheet for a folder's color (addressbook or calendar)\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {object} ngModel - the object literal describing the folder (an Addressbook or Calendar instance)\n * @example:\n\n <sg-folder-stylesheet\n ng-repeat=\"calendar in calendars.list\"\n ng-model=\"calendar\" />\n */\n function sgFolderStylesheet() {\n return {\n restrict: 'E',\n require: 'ngModel',\n scope: {\n ngModel: '='\n },\n replace: true,\n bindToController: true,\n controller: sgFolderStylesheetController,\n controllerAs: 'cssCtrl',\n template: [\n '<style type=\"text/css\">',\n /* Background color */\n ' .bg-folder{{ cssCtrl.ngModel.id }} {',\n ' background-color: {{ cssCtrl.ngModel.color }} !important;',\n ' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' }',\n ' .sg-event.bg-folder{{ cssCtrl.ngModel.id }} md-icon {',\n ' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' }',\n // Set the contrast color of toolbar icons except the one of the background\n ' md-toolbar.bg-folder{{ cssCtrl.ngModel.id }} md-icon:not(.sg-icon-toolbar-bg) {',\n ' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' }',\n // Set the contrast color of input labels\n ' .bg-folder{{ cssCtrl.ngModel.id }} label,',\n ' .bg-folder{{ cssCtrl.ngModel.id }} .md-input {',\n ' color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' opacity: 0.8;',\n ' }',\n /* Foreground color */\n ' .fg-folder{{ cssCtrl.ngModel.id }},',\n ' .sg-event.fg-folder{{ cssCtrl.ngModel.id }} md-icon {',\n ' color: {{ cssCtrl.ngModel.color }} !important;',\n ' }',\n /* Border color */\n ' .bdr-folder{{ cssCtrl.ngModel.id }} {',\n ' border-color: {{ cssCtrl.ngModel.color }} !important;',\n ' }',\n ' .contrast-bdr-folder{{ cssCtrl.ngModel.id }} {',\n ' border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' }',\n /* Checkbox color */\n ' .checkbox-folder{{ cssCtrl.ngModel.id }} .md-icon {',\n ' background-color: {{ cssCtrl.ngModel.color }} !important;',\n ' }',\n ' .checkbox-folder{{ cssCtrl.ngModel.id }}.md-checked .md-icon:after {',\n ' border-color: {{ cssCtrl.contrast(cssCtrl.ngModel.color) }} !important;',\n ' }',\n '</style>'\n ].join('')\n };\n\n function sgFolderStylesheetController() {\n var vm = this;\n\n vm.contrast = contrast; // defined in Common/utils.js\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgFolderStylesheet', sgFolderStylesheet);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgPlaceholder - A directive for dynamic placeholder\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <input type=\"text\"\n sg-placeholder=\"this_is_a_variable\" />\n */\n function sgPlaceholder() {\n return {\n restrict: 'A',\n scope: {\n placeholder: '=sgPlaceholder'\n },\n link: function(scope, elem, attr) {\n scope.$watch('placeholder',function() {\n elem[0].placeholder = scope.placeholder;\n });\n }\n };\n }\n \n angular\n .module('SOGo.Common')\n .directive('sgPlaceholder', sgPlaceholder);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgResetOnDisabled - A directive to reset any error of a datepicker when marked\n * as disabled.\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <md-datepicker\n ng-model=\"myDate\"\n ng-disabled=\"!myDateEnabled\"\n sg-reset-on-disabled>\n */\n function sgResetOnDisabled() {\n return {\n link: postLink,\n require: 'mdDatepicker',\n restrict: 'A'\n };\n\n function postLink(scope, element, attrs, datepickerCtrl) {\n function getInput() {\n return element.find('input').eq(0);\n }\n\n // We need to wait for the datepicker directive to be compiled\n var listener = scope.$watch(getInput, function (input) {\n var ngModel;\n\n if (input.length) {\n listener(); // self release\n datepickerCtrl.$scope.$watch('ctrl.isDisabled', function(isDisabled) {\n if (isDisabled)\n if (datepickerCtrl.ngModelCtrl.$invalid)\n // Trigger the event that will reset the errors and the model value\n datepickerCtrl.$scope.$emit('md-calendar-change', datepickerCtrl.date);\n });\n }\n });\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgResetOnDisabled', sgResetOnDisabled);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n angular\n .module('SOGo.Common')\n .directive('sgRippleClick', sgRippleClick);\n\n /*\n * sgRippleClick - A ripple effect to cover the parent element.\n * @memberof SOGo.Common\n * @restrict attribute\n *\n * @example:\n\n <md-dialog id=\"mailEditor\">\n <md-button ng-click=\"editor.send()\"\n sg-ripple-click=\"mailEditor\">Send</md-button>\n </md-dialog>\n\n */\n sgRippleClick.$inject = ['$log', '$timeout'];\n function sgRippleClick($log, $timeout) {\n\n return {\n restrict: 'A',\n compile: compile\n };\n\n function compile(tElement, tAttrs) {\n\n return function postLink(scope, element, attr) {\n var ripple, content, container, containerId;\n\n // Lookup container element\n containerId = element.attr('sg-ripple-click');\n container = element[0].parentNode;\n while (container && container.id != containerId) {\n container = container.parentNode;\n }\n if (!container) {\n $log.error('No parent element found with id ' + containerId);\n return undefined;\n }\n\n // Lookup sg-ripple-content element\n content = container.querySelector('sg-ripple-content');\n if (!content) {\n $log.error('sg-ripple-content not found inside #' + containerId);\n return undefined;\n }\n\n // Lookup sg-ripple element\n ripple = container.querySelector('sg-ripple');\n if (ripple) {\n ripple = angular.element(ripple);\n }\n else {\n // If ripple layer doesn't exit, create it with the primary background color\n ripple = angular.element('<sg-ripple class=\"md-default-theme md-bg\"></sg-ripple>');\n container.appendChild(ripple[0]);\n\n // Hide ripple content on initialization\n if (!content.classList.contains('ng-hide'))\n content.classList.add('ng-hide');\n }\n\n // Register listener\n element.on('click', listener);\n\n scope.$on('$destroy', function() {\n element.off('click', listener);\n });\n\n function listener(event) {\n var coordinates;\n\n if (element[0].hasAttribute('disabled')) {\n return;\n }\n\n if (event.pageX && event.pageY) {\n // Event is a mouse click\n coordinates = { left: event.pageX, top: event.pageY };\n }\n else {\n // Event is a form submit; target is the submit button\n coordinates = event.target.getBoundingClientRect();\n }\n\n if (content.classList.contains('ng-hide')) {\n // Show ripple\n angular.element(container).css({ 'overflow': 'hidden', 'position': 'relative' });\n angular.element(content).css({ top: container.scrollTop + 'px' });\n $timeout(function() {\n // Wait until next digest for CSS animation to work\n ripple.css({\n\t 'top': (coordinates.top - container.offsetTop + container.scrollTop) + 'px',\n\t 'left': (coordinates.left - container.offsetLeft) + 'px',\n\t 'height': '400vmin',\n\t 'width': '400vmin'\n\t });\n // Show ripple content\n content.classList.remove('ng-hide');\n });\n }\n else {\n // Hide ripple layer\n ripple.css({\n 'top': (coordinates.top - container.offsetTop + container.scrollTop) + 'px',\n\t 'left': (coordinates.left - container.offsetLeft) + 'px',\n 'height': '0px',\n 'width': '0px'\n });\n // Hide ripple content\n content.classList.add('ng-hide');\n // Restore overflow of container once the animation is completed\n $timeout(function() {\n angular.element(container).css({ 'overflow': '', 'position': '' });\n }, 800);\n }\n }\n };\n }\n }\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgSearch - Search within a list of items\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {function} sgSearch - the function to call when performing a search.\n * Two variables are available: searchField and searchText.\n * @example:\n\n <div sg-search=\"mailbox.$filter({ sort: 'date', asc: false }, [{ searchBy: searchField, searchInput: searchText }])\">\n <md-button class=\"sg-icon-button\"\n sg-search-cancel=\"ctrl.cancelSearch()\">\n <md-icon>arrow_back</md-icon>\n </md-button>\n <md-input-container>\n <input name=\"search\" type=\"search\"/>\n </md-input-container>\n <md-select class=\"sg-toolbar-sort md-contrast-light\">\n <md-option value=\"subject\">Subject</md-option>\n <md-option value=\"sender\">sender</md-option>\n </md-select>\n </div>\n */\n sgSearchPreTransclude.$inject = ['$parse'];\n function sgSearchPreTransclude($parse) {\n return {\n restrict: 'A',\n controller: 'sgSearchController',\n controllerAs: '$sgSearchController',\n priority: 1001,\n compile: compile\n };\n\n function compile(tElement, tAttr) {\n var mdInputEl = tElement.find('md-input-container'),\n inputEl = tElement.find('input'),\n selectEl = tElement.find('md-select'),\n buttonEl = tElement.find('md-button');\n\n inputEl.attr('ng-model', '$sgSearchController.searchText');\n inputEl.attr('ng-model-options', '$sgSearchController.searchTextOptions');\n inputEl.attr('ng-change', '$sgSearchController.onChange()');\n if (selectEl) {\n selectEl.attr('ng-model', '$sgSearchController.searchField');\n selectEl.attr('ng-change', '$sgSearchController.onChange()');\n }\n if (buttonEl && buttonEl.attr('sg-search-cancel')) {\n buttonEl.attr('ng-click', buttonEl.attr('sg-search-cancel'));\n buttonEl.removeAttr('sg-search-cancel');\n }\n else {\n buttonEl = null;\n }\n\n return function postLink(scope, iElement, iAttr, controller) {\n var compiledButtonEl = iElement.find('button');\n\n // Retrive the form and input names to check the form's validity in the controller\n controller.formName = iElement.attr('name');\n controller.inputName = inputEl.attr('name');\n\n // Associate the sg-allow-dot parameter (boolean) to the controller\n controller.allowDot = $parse(iElement.attr('sg-allow-dot'))(scope);\n\n // Associate callback to controller\n controller.doSearch = $parse(iElement.attr('sg-search'));\n\n // Reset the input field when cancelling the search\n if (buttonEl && compiledButtonEl) {\n compiledButtonEl.on('click', controller.cancelSearch);\n }\n };\n }\n }\n\n function sgSearch() {\n return {\n restrict: 'A',\n priority: 1000,\n transclude: true,\n compile: compile\n };\n\n function compile(tElement, tAttr) {\n return function postLink(scope, iElement, iAttr, controller, transclude) {\n transclude(function(clone) {\n iElement.append(clone);\n });\n };\n }\n }\n\n /**\n * @ngInject\n */\n sgSearchController.$inject = ['$window', '$scope', '$element'];\n function sgSearchController($window, $scope, $element) {\n var vm = this;\n\n // Controller variables\n vm.searchText = null;\n\n // Model options\n vm.searchTextOptions = {\n updateOn: 'default blur',\n debounce: {\n default: 300,\n blur: 0\n }\n };\n\n // Method to call on data changes\n vm.onChange = function() {\n var form = $scope[vm.formName],\n input = form[vm.inputName],\n rawSearchText = input.$viewValue;\n\n if (vm.allowDot && rawSearchText == '.' || form.$valid && rawSearchText) {\n if (rawSearchText == '.')\n // Ignore the minlength constraint when using the dot operator\n input.$setValidity('minlength', true);\n\n // doSearch is the compiled expression of the sg-search attribute\n vm.doSearch($scope, { searchText: rawSearchText, searchField: vm.searchField });\n }\n };\n\n // Reset input field when cancelling the search\n vm.cancelSearch = function() {\n vm.searchText = null;\n };\n }\n\n angular\n .module('SOGo.Common')\n .controller('sgSearchController', sgSearchController)\n .directive('sgSearch', sgSearchPreTransclude)\n .directive('sgSearch', sgSearch);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /**\n * sgSelectOnly - A directive that restricts an autocomplete field to its selectable values.\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <md-autocomplete\n md-items=\"timezone in timeZones\"\n ng-required=\"true\"\n sg-select-only>\n */\n function sgSelectOnly() {\n return {\n link: postLink,\n require: 'mdAutocomplete',\n restrict: 'A'\n };\n\n function postLink(scope, element, attrs, autoComplete) {\n function getInput() {\n return element.find('input').eq(0);\n }\n\n // We need to wait for the autocomplete directive to be compiled\n var listener = scope.$watch(getInput, function (input) {\n var ngModel;\n\n if (input.length) {\n listener(); // self release\n ngModel = input.controller('ngModel');\n input.on('blur', function () {\n if (!autoComplete.scope.selectedItem) {\n scope.$applyAsync(ngModel.$setValidity('required', false));\n }\n });\n }\n });\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgSelectOnly', sgSelectOnly);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint validthis: true */\n 'use strict';\n\n /*\n * sgSubscribe - Common subscription widget\n * @restrict attribute\n * @param {string} sgSubscribe - the folder type\n * @param {function} sgSubscribeOnSelect - the function to call when subscribing to a folder.\n * One variable is available: folderData.\n * @ngInject\n * @example:\n\n <md-button sg-subscribe=\"contact\" sg-subscribe-on-select=\"subscribeToFolder\">Subscribe ..</md-button>\n */\n sgSubscribe.$inject = ['User'];\n function sgSubscribe(User) {\n return {\n restrict: 'A',\n scope: {\n folderType: '@sgSubscribe',\n onFolderSelect: '&sgSubscribeOnSelect'\n },\n replace: false,\n bindToController: true,\n controller: sgSubscribeDialogController,\n controllerAs: '$sgSubscribeDialogController',\n link: link\n };\n }\n\n function link(scope, element, attrs, controller) {\n var inputEl = element.find('input');\n element.on('click', controller.showDialog);\n }\n\n /**\n * @ngInject\n */\n sgSubscribeDialogController.$inject = ['$mdDialog'];\n function sgSubscribeDialogController($mdDialog) {\n var vm = this;\n vm.showDialog = function() {\n $mdDialog.show({\n templateUrl: '../Contacts/UIxContactsUserFolders',\n clickOutsideToClose: true,\n locals: {\n folderType: vm.folderType,\n onFolderSelect: vm.onFolderSelect\n },\n controller: sgSubscribeController,\n controllerAs: 'subscribe'\n });\n };\n }\n\n /**\n * @ngInject\n */\n sgSubscribeController.$inject = ['$mdDialog', 'folderType', 'onFolderSelect', 'User'];\n function sgSubscribeController($mdDialog, folderType, onFolderSelect, User) {\n var vm = this;\n\n vm.selectedUser = null;\n vm.users = [];\n\n vm.searchTextOptions = {\n updateOn: 'default blur',\n debounce: {\n default: 300,\n blur: 0\n }\n };\n\n vm.onChange = function(input) {\n User.$filter(vm.searchText, null, { results: vm.users }).then(function(users) {\n input.$setValidity('matches', users.length > 0);\n input.$setTouched();\n if (vm.selectedUser) {\n // If selected user is no longer part of the matching users, unselect it\n if (_.isUndefined(_.find(users, function(user) {\n return user.uid == vm.selectedUser.uid;\n }))) {\n vm.selectedUser = null;\n }\n }\n });\n };\n\n vm.selectUser = function(i) {\n if (vm.selectedUser == vm.users[i]) {\n vm.selectedUser = null;\n }\n else {\n // Fetch folders of specific type for selected user\n vm.users[i].$folders(folderType).then(function() {\n vm.selectedUser = vm.users[i];\n });\n }\n };\n\n // Callback upon subscription to a folder\n vm.selectFolder = function(folder) {\n onFolderSelect({folderData: folder});\n };\n\n vm.close = function() {\n $mdDialog.hide();\n };\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgSubscribe', sgSubscribe);\n})();\n","(function() {\n 'use strict';\n\n /**\n * This section is inspired from angular-material/src/components/datepicker/js/calendar.js\n */\n\n angular\n .module('SOGo.Common')\n .directive('sgTimePane', timePaneDirective);\n\n function timePaneDirective() {\n return {\n template: [\n '<div class=\"sg-time-pane\">',\n ' <div class=\"hours-pane\">',\n ' <div ng-repeat=\"hoursBigLine in hours\" layout=\"row\" layout-xs=\"column\">',\n ' <div ng-repeat=\"hoursLine in hoursBigLine\" layout=\"row\" class=\"hours\">',\n ' <md-button class=\"hourBtn sg-time-selection-indicator\" id=\"{{hour.id}}\"',\n ' md-no-ink',\n ' ng-repeat=\"hour in hoursLine\"',\n ' ng-click=\"hourClickHandler(hour.displayName)\">{{hour.displayName}}</md-button>',\n ' </div>',\n ' </div>',\n ' </div>',\n ' <div class=\"min5\" ng-show=\"is5min()\">',\n ' <div layout=\"row\" layout-xs=\"column\">',\n ' <div ng-repeat=\"minutesLine in min5\" layout=\"row\">',\n ' <md-button class=\"minuteBtn sg-time-selection-indicator\" id=\"{{minute.id}}\"',\n ' md-no-ink',\n ' ng-repeat=\"minute in minutesLine\"',\n ' ng-click=\"minuteClickHandler(minute.displayName)\">{{minute.displayName}}</md-button>',\n ' </div>',\n ' </div>',\n ' </div>',\n ' <div class=\"sg-time-scroll-mask\" ng-hide=\"is5min()\">',\n ' <div class=\"min1\" layout=\"row\" layout-xs=\"column\" layout-wrap>',\n ' <div ng-repeat=\"minutesLine in min1\" layout=\"row\" layout-align=\"space-around center\">',\n ' <md-button class=\"minuteBtn sg-time-selection-indicator\" id=\"{{minute.id}}\"',\n ' md-no-ink',\n ' ng-repeat=\"minute in minutesLine\"',\n ' ng-click=\"minuteClickHandler(minute.displayName)\">{{minute.displayName}}</md-button>',\n ' </div>',\n ' </div>',\n ' </div>',\n ' <div flex layout=\"row\" layout-align=\"center center\" md-colors=\"::{background: \\'default-background-200\\'}\">',\n ' <md-button class=\"toggleBtn md-fab md-mini\" ng-bind=\"getToggleBtnLbl()\" ng-click=\"toggleManual5min()\"></md-button>',\n ' </div>',\n '</div>'\n ].join(''),\n scope: {},\n require: ['ngModel', 'sgTimePane', '?^mdInputContainer'],\n controller: TimePaneCtrl,\n controllerAs: 'ctrl',\n bindToController: true,\n link: function(scope, element, attrs, controllers) {\n var ngModelCtrl = controllers[0];\n var sgTimePaneCtrl = controllers[1];\n\n var mdInputContainer = controllers[2];\n if (mdInputContainer) {\n throw Error('sg-timepicker should not be placed inside md-input-container.');\n }\n\n sgTimePaneCtrl.configureNgModel(ngModelCtrl, sgTimePaneCtrl);\n }\n };\n }\n\n /** Next identifier for calendar instance. */\n var nextUniqueId = 0;\n\n /**\n * Controller for the sgTimePane component.\n * @ngInject @constructor\n */\n TimePaneCtrl.$inject = ['$element', '$scope', '$$mdDateUtil', '$mdUtil',\n '$mdConstant', '$mdTheming', '$$rAF', '$attrs', '$mdDateLocale'];\n function TimePaneCtrl($element, $scope, $$mdDateUtil, $mdUtil,\n $mdConstant, $mdTheming, $$rAF, $attrs, $mdDateLocale) {\n\n var m;\n\n $mdTheming($element);\n\n /** @final {!angular.JQLite} */\n this.$element = $element;\n\n /** @final {!angular.Scope} */\n this.$scope = $scope;\n\n /** @final */\n this.dateUtil = $$mdDateUtil;\n\n /** @final */\n this.$mdUtil = $mdUtil;\n\n /** @final */\n this.keyCode = $mdConstant.KEY_CODE;\n\n /** @final */\n this.$$rAF = $$rAF;\n\n this.timePaneElement = $element[0].querySelector('.sg-time-pane');\n\n // this.$q = $q;\n\n /** @type {!angular.NgModelController} */\n this.ngModelCtrl = null;\n\n /** @type {String} Class applied to the selected hour or minute cell. */\n this.SELECTED_TIME_CLASS = 'sg-time-selected';\n\n /** @type {String} Class applied to the focused hour or minute cell. */\n this.FOCUSED_TIME_CLASS = 'md-focus';\n\n /** @final {number} Unique ID for this time pane instance. */\n this.id = nextUniqueId++;\n\n /**\n * The date that is currently focused or showing in the calendar. This will initially be set\n * to the ng-model value if set, otherwise to today. It will be updated as the user navigates\n * to other months. The cell corresponding to the displayDate does not necesarily always have\n * focus in the document (such as for cases when the user is scrolling the calendar).\n * @type {Date}\n */\n this.displayTime = null;\n\n /**\n * The selected date. Keep track of this separately from the ng-model value so that we\n * can know, when the ng-model value changes, what the previous value was before it's updated\n * in the component's UI.\n *\n * @type {Date}\n */\n this.selectedTime = null;\n\n /**\n * Used to toggle initialize the root element in the next digest.\n * @type {Boolean}\n */\n this.isInitialized = false;\n\n $scope.hours=[];\n $scope.hours[0]=[];\n $scope.hours[0][0]=[];\n $scope.hours[0][1]=[];\n $scope.hours[1]=[];\n $scope.hours[1][0]=[];\n $scope.hours[1][1]=[];\n for(var i=0; i<6; i++){\n $scope.hours[0][0][i] = {id:'tp-'+this.id+'-hour-'+i, displayName:i<10?\"0\"+i:\"\"+i, selected:false};\n $scope.hours[0][1][i] = {id:'tp-'+this.id+'-hour-'+(i+6),displayName:(i+6)<10?\"0\"+(i+6):\"\"+(i+6), selected:false};\n $scope.hours[1][0][i] = {id:'tp-'+this.id+'-hour-'+(i+12), displayName:\"\"+(i+12), selected:false};\n $scope.hours[1][1][i] = {id:'tp-'+this.id+'-hour-'+(i+18), displayName:\"\"+(i+18), selected:false};\n }\n\n $scope.min5=[];\n $scope.min5[0]=[];\n $scope.min5[1]=[];\n for(i=0; i<6; i++){\n m=i*5;\n $scope.min5[0][i] = {id:'tp-'+this.id+'-minute5-'+m, displayName:m<10?\":0\"+m:\":\"+m, selected:true};\n $scope.min5[1][i] = {id:'tp-'+this.id+'-minute5-'+(m+30), displayName:\":\"+(m+30), selected:false};\n }\n\n $scope.min1=[];\n for(i=0; i<12; i++){\n $scope.min1[i]=[];\n for(var ii=0; ii<5; ii++){\n m=i*5 + ii;\n $scope.min1[i][ii] = {id:'tp-'+this.id+'-minute-'+m, displayName:m<10?\":0\"+m:\":\"+m, selected:true};\n }\n }\n\n $scope.show5min = true;\n $scope.getToggleBtnLbl = function() {\n return ($scope.is5min()) ? '>>' : '<<';\n };\n $scope.toggleManual5min = function() {\n $scope.manual5min = !$scope.is5min();\n };\n $scope.is5min = function() {\n if ($scope.manual5min === true || $scope.manual5min === false) {\n return $scope.manual5min;\n }\n else {\n return $scope.show5min;\n }\n };\n\n // Unless the user specifies so, the calendar should not be a tab stop.\n // This is necessary because ngAria might add a tabindex to anything with an ng-model\n // (based on whether or not the user has turned that particular feature on/off).\n if (!$attrs.tabindex) {\n $element.attr('tabindex', '-1');\n }\n\n var self = this;\n\n this.hourClickHandler = function(displayVal) {\n var updated = new Date(self.displayTime);\n updated.setHours(Number(displayVal));\n self.setNgModelValue(updated, 'hours');\n };\n $scope.hourClickHandler = this.hourClickHandler;\n\n this.minuteClickHandler = function(displayVal) {\n // Remove leading ':'\n var val = displayVal.substr(1);\n var updated = new Date(self.displayTime);\n updated.setMinutes(Number(val));\n self.setNgModelValue(updated, 'minutes');\n };\n $scope.minuteClickHandler = this.minuteClickHandler;\n\n var boundKeyHandler = angular.bind(this, this.handleKeyEvent);\n\n // Bind the keydown handler to the body, in order to handle cases where the focused\n // element gets removed from the DOM and stops propagating click events.\n angular.element(document.body).on('keydown', boundKeyHandler);\n\n $scope.$on('$destroy', function() {\n angular.element(document.body).off('keydown', boundKeyHandler);\n });\n }\n\n /**\n * Sets up the controller's reference to ngModelController.\n * @param {!angular.NgModelController} ngModelCtrl\n */\n TimePaneCtrl.prototype.configureNgModel = function(ngModelCtrl, sgTimePaneCtrl) {\n var self = this;\n\n // self.displayTime = new Date(self.$viewValue);\n\n self.ngModelCtrl = ngModelCtrl;\n\n self.$mdUtil.nextTick(function() {\n self.isInitialized = true;\n });\n\n ngModelCtrl.$render = function() {\n var date = this.$viewValue;\n self.$mdUtil.nextTick(function() {\n self.changeSelectedTime(date, sgTimePaneCtrl);\n });\n };\n };\n\n /**\n * Change the selected date in the time (ngModel value has already been changed).\n */\n TimePaneCtrl.prototype.changeSelectedTime = function(date, sgTimePaneCtrl) {\n var self = this;\n var previousSelectedTime = this.selectedTime;\n\n this.selectedTime = date;\n this.displayTime = new Date(date);\n\n // Remove the selected class from the previously selected date, if any.\n if (previousSelectedTime) {\n var prevH = previousSelectedTime.getHours();\n var prevHCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-hour-'+prevH);\n if (prevHCell) {\n prevHCell.classList.remove(this.SELECTED_TIME_CLASS);\n prevHCell.setAttribute('aria-selected', 'false');\n }\n var prevM = previousSelectedTime.getMinutes();\n var prevMCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-minute-'+prevM);\n if (prevMCell) {\n prevMCell.classList.remove(this.SELECTED_TIME_CLASS);\n prevMCell.setAttribute('aria-selected', 'false');\n }\n var prevM5Cell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-minute5-'+prevM);\n if (prevM5Cell) {\n prevM5Cell.classList.remove(this.SELECTED_TIME_CLASS);\n prevM5Cell.setAttribute('aria-selected', 'false');\n }\n }\n\n // Apply the select class to the new selected date if it is set.\n if (date) {\n var newH = date.getHours();\n var mCell, hCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-hour-'+newH);\n if (hCell) {\n hCell.classList.add(this.SELECTED_TIME_CLASS);\n hCell.setAttribute('aria-selected', 'true');\n }\n var newM = date.getMinutes();\n if (newM % 5 === 0) {\n sgTimePaneCtrl.$scope.show5min = true;\n mCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-minute5-'+newM);\n if (mCell) {\n mCell.classList.add(this.SELECTED_TIME_CLASS);\n mCell.setAttribute('aria-selected', 'true');\n }\n }\n else {\n sgTimePaneCtrl.$scope.show5min = false;\n }\n mCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-minute-'+newM);\n if (mCell) {\n mCell.classList.add(this.SELECTED_TIME_CLASS);\n mCell.setAttribute('aria-selected', 'true');\n }\n }\n };\n\n /**\n * Sets the ng-model value for the time pane and emits a change event.\n * @param {Date} date\n */\n TimePaneCtrl.prototype.setNgModelValue = function(date, mode) {\n this.$scope.$emit('sg-time-pane-change', { date: date, changed: mode });\n this.ngModelCtrl.$setViewValue(date);\n this.ngModelCtrl.$render();\n return date;\n };\n\n\n /*** User input handling ***/\n\n /**\n * Handles a key event in the calendar with the appropriate action. The action will either\n * be to select the focused date or to navigate to focus a new date.\n * @param {KeyboardEvent} event\n */\n TimePaneCtrl.prototype.handleKeyEvent = function(event) {\n var self = this;\n this.$scope.$apply(function() {\n // Capture escape and emit back up so that a wrapping component\n // (such as a time-picker) can decide to close.\n if (event.which == self.keyCode.ESCAPE || event.which == self.keyCode.TAB) {\n self.$scope.$emit('md-time-pane-close');\n\n if (event.which == self.keyCode.TAB) {\n event.preventDefault();\n }\n\n return;\n }\n\n // Remaining key events fall into two categories: selection and navigation.\n // Start by checking if this is a selection event.\n if (event.which === self.keyCode.ENTER) {\n self.setNgModelValue(self.displayTime, 'enter');\n event.preventDefault();\n return;\n }\n\n // Selection isn't occuring, so the key event is either navigation or nothing.\n /*var date = self.getFocusDateFromKeyEvent(event);\n if (date) {\n event.preventDefault();\n event.stopPropagation();\n\n // Since this is a keyboard interaction, actually give the newly focused date keyboard\n // focus after the been brought into view.\n self.changeDisplayTime(date).then(function () {\n self.focus(date);\n });\n }*/\n });\n };\n\n /**\n * Focus the cell corresponding to the given date.\n * @param {Date=} opt_date The date to be focused.\n */\n TimePaneCtrl.prototype.focus = function(opt_date, sgTimePaneCtrl) {\n var date = opt_date || this.selectedTime || this.today;\n\n var previousFocus = this.timePaneElement.querySelector('.md-focus');\n if (previousFocus) {\n previousFocus.classList.remove(this.FOCUSED_TIME_CLASS);\n }\n\n if (date) {\n var newH = date.getHours();\n var hCell = document.getElementById('tp-'+sgTimePaneCtrl.id+'-hour-'+newH);\n if (hCell) {\n hCell.classList.add(this.FOCUSED_TIME_CLASS);\n hCell.focus();\n }\n }\n };\n})();\n\n(function() {\n 'use strict';\n\n /**\n * This section is inspired from angular-material/src/components/datepicker/js/datepickerDirective.js\n */\n\n angular.module('SOGo.Common')\n .directive('sgTimepicker', timePickerDirective);\n\n /**\n * @ngdoc directive\n * @name mdTimepicker\n * @module material.components.timepicker\n *\n * @param {Date} ng-model The component's model. Expects a JavaScript Date object.\n * @param {expression=} ng-change Expression evaluated when the model value changes.\n * @param {String=} md-placeholder The time input placeholder value.\n * @param {boolean=} ng-disabled Whether the timepicker is disabled.\n * @param {boolean=} ng-required Whether a value is required for the timepicker.\n *\n * @description\n * `<sg-timepicker>` is a component used to select a single time.\n * For information on how to configure internationalization for the time picker,\n * see `$mdTimeLocaleProvider`.\n *\n * @usage\n * <hljs lang=\"html\">\n * <sg-timepicker ng-model=\"birthday\"></sg-timepicker>\n * </hljs>\n *\n */\n\n timePickerDirective.$inject = ['$mdUtil', '$mdAria'];\n function timePickerDirective($mdUtil, $mdAria) {\n return {\n template: function(tElement, tAttrs) {\n // Buttons are not in the tab order because users can open the hours pane via keyboard\n // interaction on the text input, and multiple tab stops for one component (picker)\n // may be confusing.\n var ariaLabelValue = tAttrs.ariaLabel || tAttrs.mdPlaceholder;\n\n return [\n '<md-button class=\"sg-timepicker-button md-icon-button\" type=\"button\" ',\n ' tabindex=\"-1\" aria-hidden=\"true\" ',\n ' ng-click=\"ctrl.openTimePane($event)\">',\n ' <md-icon class=\"sg-timepicker-icon\">access_time</md-icon>',\n '</md-button>',\n '<div class=\"md-default-theme sg-timepicker-input-container\" ',\n ' ng-class=\"{\\'sg-timepicker-focused\\': ctrl.isFocused}\">',\n ' <input class=\"sg-timepicker-input\" ',\n (ariaLabelValue ? 'aria-label=\"' + ariaLabelValue + '\" ' : ''),\n ' aria-haspopup=\"true\"',\n ' aria-expanded=\"{{ctrl.isTimeOpen}}\" ',\n ' aria-owns=\"{{::ctrl.timePaneId}}\"',\n ' ng-focus=\"ctrl.setFocused(true)\" ng-blur=\"ctrl.setFocused(false)\">',\n ' <md-button type=\"button\" md-no-ink ',\n ' class=\"sg-timepicker-triangle-button md-icon-button\" ',\n ' ng-click=\"ctrl.openTimePane($event)\" ',\n ' aria-label=\"{{::ctrl.dateLocale.msgOpenCalendar}}\">',\n ' <div class=\"sg-timepicker-expand-triangle\"></div>',\n ' </md-button>',\n '</div>',\n // This pane will be detached from here and re-attached to the document body.\n '<div class=\"sg-timepicker-time-pane md-whiteframe-z1\" id=\"{{::ctrl.timePaneId}}\">',\n ' <div class=\"sg-timepicker-input-mask\">',\n ' <div class=\"sg-timepicker-input-mask-opaque\"></div>',\n // ' md-colors=\"::{\\'box-shadow\\': \\'default-background-hue-1\\'}\"></div>', // using mdColors\n ' </div>',\n ' <div class=\"sg-timepicker-time\" md-colors=\"::{background: \\'default-background-A100\\'}\">',\n ' <sg-time-pane role=\"dialog\" aria-label=\"{{::ctrl.dateLocale.msgCalendar}}\" ',\n ' ng-model=\"ctrl.time\" ng-if=\"ctrl.isTimeOpen\"></sg-time-pane>',\n ' </div>',\n '</div>'\n ].join('');\n },\n require: ['ngModel', 'sgTimepicker', '?^form'],\n scope: {\n placeholder: '@mdPlaceholder'\n },\n controller: TimePickerCtrl,\n controllerAs: 'ctrl',\n bindToController: true,\n link: function(scope, element, attr, controllers) {\n var ngModelCtrl = controllers[0];\n var mdTimePickerCtrl = controllers[1];\n var parentForm = controllers[2];\n var mdNoAsterisk = $mdUtil.parseAttributeBoolean(attr.mdNoAsterisk);\n\n mdTimePickerCtrl.configureNgModel(ngModelCtrl);\n\n // TODO: shall we check ^mdInputContainer?\n if (parentForm) {\n // If invalid, highlights the input when the parent form is submitted.\n var parentSubmittedWatcher = scope.$watch(function() {\n return parentForm.$submitted;\n }, function(isSubmitted) {\n if (isSubmitted) {\n mdTimePickerCtrl.updateErrorState();\n parentSubmittedWatcher();\n }\n });\n }\n }\n };\n }\n\n /** Additional offset for the input's `size` attribute, which is updated based on its content. */\n var EXTRA_INPUT_SIZE = 3;\n\n /** Class applied to the container if the date is invalid. */\n var INVALID_CLASS = 'sg-timepicker-invalid';\n\n /** Class applied to the timepicker when it's open. */\n var OPEN_CLASS = 'sg-timepicker-open';\n\n /** Default time in ms to debounce input event by. */\n var DEFAULT_DEBOUNCE_INTERVAL = 500;\n\n /**\n * Height of the calendar pane used to check if the pane is going outside the boundary of\n * the viewport. See calendar.scss for how $md-calendar-height is computed; an extra 20px is\n * also added to space the pane away from the exact edge of the screen.\n *\n * This is computed statically now, but can be changed to be measured if the circumstances\n * of calendar sizing are changed.\n */\n var TIME_PANE_HEIGHT = { MIN5: { GTXS: 172 + 20, XS: 291 + 20 },\n MIN1: { GTXS: 364 + 20, XS: 454 + 20 } };\n\n /**\n * Width of the calendar pane used to check if the pane is going outside the boundary of\n * the viewport. See calendar.scss for how $md-calendar-width is computed; an extra 20px is\n * also added to space the pane away from the exact edge of the screen.\n *\n * This is computed statically now, but can be changed to be measured if the circumstances\n * of calendar sizing are changed.\n */\n var TIME_PANE_WIDTH = { GTXS: 510 + 20, XS: 274 + 20 };\n\n /** Used for checking whether the current user agent is on iOS or Android. */\n var IS_MOBILE_REGEX = /ipad|iphone|ipod|android/i;\n\n /**\n * Controller for sg-timepicker.\n *\n * ngInject @constructor\n */\n TimePickerCtrl.$inject = ['$scope', '$element', '$attrs', '$window', '$mdConstant',\n '$mdTheming', '$mdUtil', '$mdDateLocale', '$$mdDateUtil', '$$rAF',\n '$mdMedia'];\n function TimePickerCtrl($scope, $element, $attrs, $window, $mdConstant,\n $mdTheming, $mdUtil, $mdDateLocale, $$mdDateUtil, $$rAF,\n $mdMedia) {\n /** @final */\n this.$window = $window;\n\n /** @final */\n this.dateLocale = $mdDateLocale;\n\n /** @final */\n this.dateUtil = $$mdDateUtil;\n\n /** @final */\n this.$mdConstant = $mdConstant;\n\n /* @final */\n this.$mdUtil = $mdUtil;\n\n /** @final */\n this.$$rAF = $$rAF;\n\n /** @final */\n this.$mdMedia = $mdMedia;\n\n /**\n * The root document element. This is used for attaching a top-level click handler to\n * close the calendar panel when a click outside said panel occurs. We use `documentElement`\n * instead of body because, when scrolling is disabled, some browsers consider the body element\n * to be completely off the screen and propagate events directly to the html element.\n * @type {!angular.JQLite}\n */\n this.documentElement = angular.element(document.documentElement);\n\n /** @type {!angular.NgModelController} */\n this.ngModelCtrl = null;\n\n /** @type {HTMLInputElement} */\n this.inputElement = $element[0].querySelector('input');\n\n /** @final {!angular.JQLite} */\n this.ngInputElement = angular.element(this.inputElement);\n\n /** @type {HTMLElement} */\n this.inputContainer = $element[0].querySelector('.sg-timepicker-input-container');\n\n /** @type {HTMLElement} Floating time pane. */\n this.timePane = $element[0].querySelector('.sg-timepicker-time-pane');\n\n /** @type {HTMLElement} Time icon button. */\n this.timeButton = $element[0].querySelector('.sg-timepicker-button');\n\n /**\n * Element covering everything but the input in the top of the floating calendar pane.\n * @type {HTMLElement}\n */\n this.inputMask = angular.element($element[0].querySelector('.sg-timepicker-input-mask-opaque'));\n\n /** @final {!angular.JQLite} */\n this.$element = $element;\n\n /** @final {!angular.Attributes} */\n this.$attrs = $attrs;\n\n /** @final {!angular.Scope} */\n this.$scope = $scope;\n\n /** @type {Date} */\n this.date = null;\n\n /** @type {boolean} */\n this.isFocused = false;\n\n /** @type {boolean} */\n this.isDisabled = false;\n this.setDisabled($element[0].disabled || angular.isString($attrs.disabled));\n\n /** @type {boolean} Whether the date-picker's calendar pane is open. */\n this.isTimeOpen = false;\n\n /** @type {boolean} Whether the calendar should open when the input is focused. */\n // this.openOnFocus = $attrs.hasOwnProperty('mdOpenOnFocus');\n\n /** @final */\n // this.mdInputContainer = null;\n\n /**\n * Element from which the calendar pane was opened. Keep track of this so that we can return\n * focus to it when the pane is closed.\n * @type {HTMLElement}\n */\n this.timePaneOpenedFrom = null;\n\n /** @type {String} Unique id for the time pane. */\n this.timePaneId = 'sg-time-pane' + $mdUtil.nextUid();\n\n /** Pre-bound click handler is saved so that the event listener can be removed. */\n this.bodyClickHandler = angular.bind(this, this.handleBodyClick);\n\n /**\n * Name of the event that will trigger a close. Necessary to sniff the browser, because\n * the resize event doesn't make sense on mobile and can have a negative impact since it\n * triggers whenever the browser zooms in on a focused input.\n */\n this.windowEventName = IS_MOBILE_REGEX.test(\n navigator.userAgent || navigator.vendor || window.opera\n ) ? 'orientationchange' : 'resize';\n\n /** Pre-bound close handler so that the event listener can be removed. */\n this.windowEventHandler = $mdUtil.debounce(angular.bind(this, this.closeTimePane), 100);\n\n /** Pre-bound handler for the window blur event. Allows for it to be removed later. */\n this.windowBlurHandler = angular.bind(this, this.handleWindowBlur);\n\n /** @type {Number} Extra margin for the left side of the floating calendar pane. */\n this.leftMargin = 20;\n\n /** @type {Number} Extra margin for the top of the floating calendar. Gets determined on the first open. */\n this.topMargin = null;\n\n // Unless the user specifies so, the timepicker should not be a tab stop.\n // This is necessary because ngAria might add a tabindex to anything with an ng-model\n // (based on whether or not the user has turned that particular feature on/off).\n if ($attrs.tabindex) {\n this.ngInputElement.attr('tabindex', $attrs.tabindex);\n $attrs.$set('tabindex', null);\n } else {\n $attrs.$set('tabindex', '-1');\n }\n\n $mdTheming($element);\n $mdTheming(angular.element(this.timePane));\n\n this.installPropertyInterceptors();\n this.attachChangeListeners();\n this.attachInteractionListeners();\n\n var self = this;\n\n $scope.$on('$destroy', function() {\n self.detachTimePane();\n });\n }\n\n /**\n * Sets up the controller's reference to ngModelController.\n * @param {!angular.NgModelController} ngModelCtrl Instance of the ngModel controller.\n */\n TimePickerCtrl.prototype.configureNgModel = function(ngModelCtrl) {\n this.ngModelCtrl = ngModelCtrl;\n\n var self = this;\n\n // Responds to external changes to the model value.\n self.ngModelCtrl.$formatters.push(function(value) {\n if (value && !(value instanceof Date)) {\n throw Error('The ng-model for sg-timepicker must be a Date instance. ' +\n 'Currently the model is a: ' + (typeof value));\n }\n\n self.time = value;\n self.inputElement.value = self.dateLocale.formatTime(value);\n self.resizeInputElement();\n self.updateErrorState();\n\n return value;\n });\n\n // Responds to external error state changes (e.g. ng-required based on another input).\n ngModelCtrl.$viewChangeListeners.unshift(angular.bind(this, this.updateErrorState));\n };\n\n /**\n * Attach event listeners for both the text input and the md-time.\n * Events are used instead of ng-model so that updates don't infinitely update the other\n * on a change. This should also be more performant than using a $watch.\n */\n TimePickerCtrl.prototype.attachChangeListeners = function() {\n var self = this;\n\n self.$scope.$on('sg-time-pane-change', function(event, data) {\n var time = new Date(data.date);\n self.ngModelCtrl.$setViewValue(time);\n self.time = time;\n self.inputElement.value = self.dateLocale.formatTime(time);\n if (data.changed == 'minutes') {\n self.closeTimePane();\n }\n self.resizeInputElement();\n self.inputContainer.classList.remove(INVALID_CLASS);\n });\n\n self.ngInputElement.on('input', angular.bind(self, self.resizeInputElement));\n\n var debounceInterval = angular.isDefined(this.debounceInterval) ?\n this.debounceInterval : DEFAULT_DEBOUNCE_INTERVAL;\n self.ngInputElement.on('input', self.$mdUtil.debounce(self.handleInputEvent,\n debounceInterval, self));\n };\n\n /** Attach event listeners for user interaction. */\n TimePickerCtrl.prototype.attachInteractionListeners = function() {\n var self = this;\n var $scope = this.$scope;\n var keyCodes = this.$mdConstant.KEY_CODE;\n\n // Add event listener through angular so that we can triggerHandler in unit tests.\n self.ngInputElement.on('keydown', function(event) {\n if (event.altKey && event.keyCode == keyCodes.DOWN_ARROW) {\n self.openTimePane(event);\n $scope.$digest();\n }\n });\n\n $scope.$on('md-time-close', function() {\n self.closeTimePane();\n });\n };\n\n /**\n * Capture properties set to the time-picker and imperitively handle internal changes.\n * This is done to avoid setting up additional $watches.\n */\n TimePickerCtrl.prototype.installPropertyInterceptors = function() {\n var self = this;\n\n if (this.$attrs.ngDisabled) {\n // The expression is to be evaluated against the directive element's scope and not\n // the directive's isolate scope.\n var scope = this.$scope.$parent;\n\n if (scope) {\n scope.$watch(this.$attrs.ngDisabled, function(isDisabled) {\n self.setDisabled(isDisabled);\n });\n }\n }\n\n Object.defineProperty(this, 'placeholder', {\n get: function() { return self.inputElement.placeholder; },\n set: function(value) { self.inputElement.placeholder = value || ''; }\n });\n };\n\n /**\n * Sets whether the date-picker is disabled.\n * @param {boolean} isDisabled\n */\n TimePickerCtrl.prototype.setDisabled = function(isDisabled) {\n this.isDisabled = isDisabled;\n this.inputElement.disabled = isDisabled;\n\n if (this.timeButton) {\n this.timeButton.disabled = isDisabled;\n }\n };\n\n /**\n * Sets the custom ngModel.$error flags to be consumed by ngMessages. Flags are:\n * - mindate: whether the selected date is before the minimum date.\n * - maxdate: whether the selected flag is after the maximum date.\n * - filtered: whether the selected date is allowed by the custom filtering function.\n * - valid: whether the entered text input is a valid date\n *\n * The 'required' flag is handled automatically by ngModel.\n *\n * @param {Date=} opt_date Date to check. If not given, defaults to the datepicker's model value.\n */\n TimePickerCtrl.prototype.updateErrorState = function(opt_date) {\n var date = opt_date || this.date;\n\n // Clear any existing errors to get rid of anything that's no longer relevant.\n this.clearErrorState();\n\n if (!this.dateUtil.isValidDate(date)) {\n // The date is seen as \"not a valid date\" if there is *something* set\n // (i.e.., not null or undefined), but that something isn't a valid date.\n this.ngModelCtrl.$setValidity('valid', date === null);\n }\n\n // TODO(jelbourn): Change this to classList.toggle when we stop using PhantomJS in unit tests\n // because it doesn't conform to the DOMTokenList spec.\n // See https://github.com/ariya/phantomjs/issues/12782.\n if (!this.ngModelCtrl.$valid) {\n this.inputContainer.classList.add(INVALID_CLASS);\n }\n };\n\n /** Clears any error flags set by `updateErrorState`. */\n TimePickerCtrl.prototype.clearErrorState = function() {\n this.inputContainer.classList.remove(INVALID_CLASS);\n ['valid'].forEach(function(field) {\n this.ngModelCtrl.$setValidity(field, true);\n }, this);\n };\n\n /**\n * Resizes the input element based on the size of its content.\n */\n TimePickerCtrl.prototype.resizeInputElement = function() {\n this.inputElement.size = this.inputElement.value.length + EXTRA_INPUT_SIZE;\n };\n\n /**\n * Sets the model value if the user input is a valid time.\n * Adds an invalid class to the input element if not.\n */\n TimePickerCtrl.prototype.handleInputEvent = function(self) {\n var inputString = this.inputElement.value;\n var parsedTime = inputString ? this.dateLocale.parseTime(inputString) : null;\n\n // An input string is valid if it is either empty (representing no date)\n // or if it parses to a valid time that the user is allowed to select.\n var isValidInput = inputString === '' || this.dateUtil.isValidDate(parsedTime);\n\n // The datepicker's model is only updated when there is a valid input.\n if (isValidInput) {\n var updated = new Date(this.time);\n updated.setHours(parsedTime.getHours());\n updated.setMinutes(parsedTime.getMinutes());\n this.ngModelCtrl.$setViewValue(updated);\n this.time = updated;\n }\n\n this.updateErrorState(parsedTime);\n };\n\n /** Position and attach the floating calendar to the document. */\n TimePickerCtrl.prototype.attachTimePane = function() {\n var timePane = this.timePane;\n var body = document.body;\n\n timePane.style.transform = '';\n this.$element.addClass(OPEN_CLASS);\n // this.mdInputContainer && this.mdInputContainer.element.addClass(OPEN_CLASS);\n angular.element(body).addClass('md-datepicker-is-showing');\n\n var elementRect = this.inputContainer.getBoundingClientRect();\n var bodyRect = body.getBoundingClientRect();\n\n if (!this.topMargin || this.topMargin < 0) {\n this.topMargin = (this.inputMask.parent().prop('clientHeight') - this.ngInputElement.prop('clientHeight')) / 2;\n }\n\n // Check to see if the calendar pane would go off the screen. If so, adjust position\n // accordingly to keep it within the viewport.\n var paneTop = elementRect.top - bodyRect.top - this.topMargin;\n var paneLeft = elementRect.left - bodyRect.left - this.leftMargin;\n\n // If ng-material has disabled body scrolling (for example, if a dialog is open),\n // then it's possible that the already-scrolled body has a negative top/left. In this case,\n // we want to treat the \"real\" top as (0 - bodyRect.top). In a normal scrolling situation,\n // though, the top of the viewport should just be the body's scroll position.\n var viewportTop = (bodyRect.top < 0 && body.scrollTop === 0) ?\n -bodyRect.top :\n document.body.scrollTop;\n\n var viewportLeft = (bodyRect.left < 0 && body.scrollLeft === 0) ?\n -bodyRect.left :\n document.body.scrollLeft;\n\n var viewportBottom = viewportTop + this.$window.innerHeight;\n var viewportRight = viewportLeft + this.$window.innerWidth;\n\n // Creates an overlay with a hole the same size as element. We remove a pixel or two\n // on each end to make it overlap slightly. The overlay's background is added in\n // the theme in the form of a box-shadow with a huge spread.\n this.inputMask.css({\n position: 'absolute',\n left: this.leftMargin + 'px',\n top: this.topMargin + 'px',\n width: (elementRect.width - 1) + 'px',\n height: (elementRect.height - 2) + 'px'\n });\n\n // If the right edge of the pane would be off the screen and shifting it left by the\n // difference would not go past the left edge of the screen. If the time pane is too\n // big to fit on the screen at all, move it to the left of the screen and scale the entire\n // element down to fit.\n var paneWidth = this.$mdMedia('xs')? TIME_PANE_WIDTH.XS : TIME_PANE_WIDTH.GTXS;\n if (paneLeft + paneWidth > viewportRight) {\n if (viewportRight - paneWidth > 0) {\n paneLeft = viewportRight - paneWidth;\n } else {\n paneLeft = viewportLeft;\n var scale = this.$window.innerWidth / paneWidth;\n timePane.style.transform = 'scale(' + scale + ')';\n }\n\n timePane.classList.add('sg-timepicker-pos-adjusted');\n }\n\n // If the bottom edge of the pane would be off the screen and shifting it up by the\n // difference would not go past the top edge of the screen.\n var min = (typeof this.time == 'object' && this.time.getMinutes() % 5 === 0)? 'MIN5' : 'MIN1';\n var paneHeight = this.$mdMedia('xs')? TIME_PANE_HEIGHT[min].XS : TIME_PANE_HEIGHT[min].GTXS;\n if (paneTop + paneHeight > viewportBottom &&\n viewportBottom - paneHeight > viewportTop) {\n paneTop = viewportBottom - paneHeight;\n timePane.classList.add('sg-timepicker-pos-adjusted');\n }\n\n timePane.style.left = paneLeft + 'px';\n timePane.style.top = paneTop + 'px';\n document.body.appendChild(timePane);\n\n // Add CSS class after one frame to trigger open animation.\n this.$$rAF(function() {\n timePane.classList.add('md-pane-open');\n });\n };\n\n /** Detach the floating time pane from the document. */\n TimePickerCtrl.prototype.detachTimePane = function() {\n this.$element.removeClass(OPEN_CLASS);\n //this.mdInputContainer && this.mdInputContainer.element.removeClass(OPEN_CLASS);\n angular.element(document.body).removeClass('md-datepicker-is-showing');\n this.timePane.classList.remove('md-pane-open');\n this.timePane.classList.remove('md-timepicker-pos-adjusted');\n\n if (this.isTimeOpen) {\n this.$mdUtil.enableScrolling();\n }\n\n if (this.timePane.parentNode) {\n // Use native DOM removal because we do not want any of the angular state of this element\n // to be disposed.\n this.timePane.parentNode.removeChild(this.timePane);\n }\n };\n\n /**\n * Open the floating time pane.\n * @param {Event} event\n */\n TimePickerCtrl.prototype.openTimePane = function(event) {\n if (!this.isTimeOpen && !this.isDisabled) {\n this.isTimeOpen = true;\n this.timePaneOpenedFrom = event.target;\n\n // Because the time pane is attached directly to the body, it is possible that the\n // rest of the component (input, etc) is in a different scrolling container, such as\n // an md-content. This means that, if the container is scrolled, the pane would remain\n // stationary. To remedy this, we disable scrolling while the time pane is open, which\n // also matches the native behavior for things like `<select>` on Mac and Windows.\n this.$mdUtil.disableScrollAround(this.timePane);\n\n this.attachTimePane();\n //this.focusTime();\n this.evalAttr('ngFocus');\n\n // Attach click listener inside of a timeout because, if this open call was triggered by a\n // click, we don't want it to be immediately propogated up to the body and handled.\n var self = this;\n this.$mdUtil.nextTick(function() {\n // Use 'touchstart` in addition to click in order to work on iOS Safari, where click\n // events aren't propogated under most circumstances.\n // See http://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html\n self.documentElement.on('click touchstart', self.bodyClickHandler);\n }, false);\n\n window.addEventListener(this.windowEventName, this.windowEventHandler);\n }\n };\n\n /** Close the floating time pane. */\n TimePickerCtrl.prototype.closeTimePane = function() {\n if (this.isTimeOpen) {\n var self = this;\n\n self.detachTimePane();\n self.ngModelCtrl.$setTouched();\n self.evalAttr('ngBlur');\n\n self.documentElement.off('click touchstart', self.bodyClickHandler);\n window.removeEventListener(self.windowEventName, self.windowEventHandler);\n\n self.timePaneOpenedFrom.focus();\n self.timePaneOpenedFrom = null;\n\n self.isTimeOpen = false;\n }\n };\n\n /** Gets the controller instance for the time in the floating pane. */\n TimePickerCtrl.prototype.getTimePaneCtrl = function() {\n return angular.element(this.timePane.querySelector('sg-time-pane')).controller('sgTimePane');\n };\n\n /** Focus the time in the floating pane. */\n TimePickerCtrl.prototype.focusTime = function() {\n // Use a timeout in order to allow the time to be rendered, as it is gated behind an ng-if.\n var self = this;\n this.$mdUtil.nextTick(function() {\n var ctrl = self.getTimePaneCtrl();\n self.getTimePaneCtrl().focus(null, ctrl);\n }, false);\n };\n\n /**\n * Sets whether the input is currently focused.\n * @param {boolean} isFocused\n */\n TimePickerCtrl.prototype.setFocused = function(isFocused) {\n if (!isFocused) {\n this.ngModelCtrl.$setTouched();\n }\n\n this.evalAttr(isFocused ? 'ngFocus' : 'ngBlur');\n\n this.isFocused = isFocused;\n };\n\n /**\n * Handles a click on the document body when the floating time pane is open.\n * Closes the floating time pane if the click is not inside of it.\n * @param {MouseEvent} event\n */\n TimePickerCtrl.prototype.handleBodyClick = function(event) {\n if (this.isTimeOpen) {\n var isInTime = this.$mdUtil.getClosest(event.target, 'sg-time-pane');\n\n if (!isInTime) {\n this.closeTimePane();\n }\n\n this.$scope.$digest();\n }\n };\n\n /**\n * Handles the event when the user navigates away from the current tab. Keeps track of\n * whether the input was focused when the event happened, in order to prevent the time pane\n * from re-opening.\n */\n TimePickerCtrl.prototype.handleWindowBlur = function() {\n this.inputFocusedOnWindowBlur = document.activeElement === this.inputElement;\n };\n\n /**\n * Evaluates an attribute expression against the parent scope.\n * @param {String} attr Name of the attribute to be evaluated.\n */\n TimePickerCtrl.prototype.evalAttr = function(attr) {\n if (this.$attrs[attr]) {\n this.$scope.$parent.$eval(this.$attrs[attr]);\n }\n };\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n 'use strict';\n\n /*\n * sgToggleGrid - Convert the tiles of a grid to toggle buttons\n * @memberof SOGo.Common\n * @restrict attribute\n * @param {string} [sgToggleGridAttr] - the attribute that specifies if an object is enabled (toggled)\n * @ngInject\n * @example:\n\n <md-grid-list md-cols=\"7\" md-row-height=\"1:1\"\n ng-model=\"editor.event.repeat.days\"\n sg-toggle-grid sg-toggle-grid-attr=\"day\">..</md-grid-list>\n */\n sgToggleGrid.$inject = ['$parse', '$mdUtil'];\n function sgToggleGrid($parse, $mdUtil) {\n return {\n restrict: 'A',\n require: '?ngModel',\n compile: compile\n };\n\n function compile(tElement, tAttrs) {\n return function postLink(scope, element, attr, ngModelCtrl) {\n var tiles = tElement.find('md-grid-tile'),\n tile,\n i,\n modelDays,\n modelAttr,\n toggleClass;\n\n ngModelCtrl = ngModelCtrl || $mdUtil.fakeNgModel();\n ngModelCtrl.$render = render;\n\n toggleClass = function() {\n // Toggle class on click event and call toggle function\n var tile = angular.element(this),\n day = tile.attr('value');\n tile.toggleClass('sg-active');\n toggle(day);\n };\n\n for (i = 0; i < tiles.length; i++) {\n tile = angular.element(tiles[i]);\n tile.addClass('sg-icon-button');\n tile.find('figure').addClass('md-icon');\n tile.on('click', toggleClass);\n }\n\n function render() {\n var flattenedDays = ngModelCtrl.$viewValue;\n modelDays = ngModelCtrl.$viewValue;\n if (tAttrs.sgToggleGridAttr) {\n modelAttr = tAttrs.sgToggleGridAttr;\n flattenedDays = _.map(ngModelCtrl.$viewValue, tAttrs.sgToggleGridAttr);\n }\n _.forEach(tiles, function(o) {\n var tile = angular.element(o);\n if (_.includes(flattenedDays, tile.attr('value'))) {\n tile.addClass('sg-active');\n }\n });\n }\n\n function toggle(day) {\n var i = _.findIndex(modelDays, function(o) {\n if (modelAttr)\n return o[modelAttr] == day;\n else\n return o == day;\n });\n if (i < 0) {\n if (modelAttr) {\n var o = {};\n o[modelAttr] = day;\n modelDays.push(o);\n }\n else\n modelDays.push(day);\n }\n else\n modelDays.splice(i, 1);\n\n scope.$apply(function() {\n ngModelCtrl.$setViewValue(modelDays);\n ngModelCtrl.$setDirty();\n });\n }\n };\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgToggleGrid', sgToggleGrid);\n})();\n","/* -*- Mode: javascript; indent-tabs-mode: nil; c-basic-offset: 2 -*- */\n\n(function() {\n /* jshint loopfunc: true */\n 'use strict';\n\n /**\n * sgTransformOnBlur - A directive to extend md-chips so the text of the input\n * field is converted to a chip when the field is loosing focus.\n *\n * See issues on github:\n *\n * https://github.com/angular/material/issues/3364 (md-add-on-blur)\n * https://github.com/angular/material/issues/9582\n *\n * Code is extracted from \"MdChipsCtrl.prototype.onInputBlur\" in controller:\n *\n * angular-material/src/components/chips/js/chipsController.js\n *\n * @memberof SOGo.Common\n * @ngInject\n * @example:\n\n <md-chips ng-model=\"editor.message.editable.to\"\n md-separator-keys=\"editor.recipientSeparatorKeys\"\n md-transform-chip=\"editor.addRecipient($chip, 'to')\"\n sg-transform-on-blur>\n */\n sgTransformOnBlur.$inject = ['$window', '$timeout'];\n function sgTransformOnBlur($window, $timeout) {\n return {\n link: link,\n require: 'mdChips', // Extends the original mdChips directive\n restrict: 'A'\n };\n\n function link(scope, element, attributes, mdChipsCtrl) {\n var mouseUpActions = [];\n\n mdChipsCtrl.onInputBlur = function() {\n var appendFcn;\n\n this.inputHasFocus = false;\n appendFcn = (function() {\n var chipBuffer = this.getChipBuffer().trim();\n\n // Update the custom chip validators.\n this.validateModel();\n\n var isModelValid = this.ngModelCtrl.$valid;\n\n if (this.userInputNgModelCtrl) {\n isModelValid &= this.userInputNgModelCtrl.$valid;\n }\n\n // Only append the chip and reset the chip buffer if the chips and input ngModel is valid.\n if (chipBuffer && isModelValid) {\n this.appendChip(chipBuffer);\n this.resetChipBuffer();\n }\n }).bind(this);\n\n if (this.autocompleteCtrl) {\n mouseUpActions.push(appendFcn);\n $window.addEventListener('click', function(event){\n while (mouseUpActions.length > 0) {\n // Trigger actions after some delay to give time to md-autocomple to clear the input field\n var action = mouseUpActions.splice(0,1)[0];\n $timeout(function(){\n $timeout(action);\n });\n }\n }, false);\n }\n else\n appendFcn();\n };\n }\n }\n\n angular\n .module('SOGo.Common')\n .directive('sgTransformOnBlur', sgTransformOnBlur);\n})();\n"]} |