WRMCB=function(e){var c=console;if(c&&c.log&&c.error){c.log('Error running batched script.');c.error(e);}} ; try { /* module-key = 'com.atlassian.confluence.extra.team-calendars:non-space-calendars-dialog', location = 'com/atlassian/confluence/extra/calendar3/components/non-space-calendars-dialog/non-space-calendar-entry-view.js' */ define("tc/non-space-calendar-entry-view",["jquery","underscore","tc-backbone","ajs","tc/calendar-util"],function(d,b,f,a,c){var e=f.View.extend({initialize:function(g){this.template=Confluence.TeamCalendars.Templates.nonSpaceCalendarEntry;this.subCalendar=g.subCalendar;this.CalendarPlugin=g.CalendarPlugin;this.calendarDiv=g.calendarDiv;this.cache=g.cache},render:function(){this.$el.html(this.template({subCalendar:this.subCalendar}));this.spaceKeyAutocompleteField=this.$("input.autocomplete-space");this.spaceKeyField=this.$("input.space-key");this.spaceKeyAutocompleteField.keypress(b.bind(function(g){if(g.which!==13){this.spaceKeyField.val(g.which)}},this));this.spaceKeyAutocompleteField.bind("selected.autocomplete-content",b.bind(function(h,g){this.spaceKeyField.val(g.content.key);this.spaceKeyAutocompleteField.val(g.content.name)},this));this.successIcon=this.$(".success-icon");this.errorIcon=this.$(".error-icon");this.spinnerIcon=this.$(".spinner");this.errorMessageDiv=this.$(".error-message");return this.$el},getData:function(){return{calendarId:this.subCalendar.id,spaceKey:this.spaceKeyField.val()}},isUpdateSuccessfully:function(){return this.spaceKeyAutocompleteField.attr("updated")==="true"},updateSubCalendar:function(){if(this.isUpdateSuccessfully()){return}var g=this.getData();if(!g.spaceKey){return}this.spinnerIcon.show();return d.ajax({cache:false,data:JSON.stringify(g),contentType:"application/json",dataFilter:function(h){var i=d.parseJSON(h);if(i.success){c.mergeSubCalendarObjectsToArray(i.payload)}return i},dataType:"json",converters:{"text json":function(h){return h}},error:b.bind(function(i,k,j){var h=JSON.parse(i.responseText)[0]||"Uh oh. Looks like something unexpectedly went wrong. Please check the Confluence log file.";this._showResult(false,h);c.fireEventForAnalytics("non.space.calendars.upgrade.one.calendar.failed")},this),success:b.bind(function(h){if(h.success){this._showResult(true,"");this._hide();this.CalendarPlugin.setSubCalendar(g.calendarId,this.calendarDiv,h.payload);c.fireEventForAnalytics("non.space.calendars.upgrade.one.calendar.successful")}else{var i=(h.fieldErrors&&h.fieldErrors.length)?h.fieldErrors[0].errorMessages[0]:"Uh oh. Looks like something unexpectedly went wrong. Please check the Confluence log file.";this._showResult(false,i);c.fireEventForAnalytics("non.space.calendars.upgrade.one.calendar.failed")}},this),type:"POST",timeout:c.ajaxTimeout,url:Confluence.TeamCalendars.getCalendarServiceBaseUrl("/subcalendar/space")})},_hide:function(){this.$el.animate({height:0,opacity:0},500,function(){d(this).remove()})},_showResult:function(h,g){this.spinnerIcon.hide();this.successIcon.toggleClass("hidden",!h);this.errorIcon.toggleClass("hidden",h);this.errorMessageDiv.toggleClass("hidden",h);if(h){this.spaceKeyAutocompleteField.prop("disabled",true);this.spaceKeyAutocompleteField.attr("updated","true")}if(g){this.errorMessageDiv.text(g)}}});return e}); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.extra.team-calendars:non-space-calendars-dialog', location = 'com/atlassian/confluence/extra/calendar3/components/non-space-calendars-dialog/non-space-calendars-dialog-view.js' */ define("tc/non-space-calendars-dialog-view",["jquery","underscore","tc-backbone","ajs","tc/calendar-util","tc/non-space-calendar-entry-view"],function(e,b,h,a,d,f){var c;var g=h.View.extend({events:{},initialize:function(i){this.subCalendars=i.subCalendars;this.nonSpaceCalendarEntryViews=[];this.CalendarPlugin=i.CalendarPlugin;this.calendarDiv=i.calendarDiv;this.cache=i.cache},setSubCalendars:function(i){this.subCalendars=i},render:function(){if(!c){c=this.dialog=new a.Dialog(600,600,"non-space-calendars-dialog");var i="Your calendars need a related space";c.addHeader(i);c.addPanel(i,Confluence.TeamCalendars.Templates.nonSpaceCalendarsDialog(),"non-space-calendars-panel");c.addSubmit("Save",b.bind(this._onSubmit,this));c.addCancel("Not right now",b.bind(this._onCancel,this));this.setElement(c.getCurPanel().body)}this._renderNonSpaceCalendarEntries();c.show()},_renderNonSpaceCalendarEntries:function(){this.nonSpaceCalendarEntryViews=[];this.$(".non-space-calendars-list").empty();b.each(this.subCalendars,b.bind(function(j){var i=new f({subCalendar:j,CalendarPlugin:this.CalendarPlugin,calendarDiv:this.calendarDiv,cache:this.cache});this.nonSpaceCalendarEntryViews.push(i);this.$(".non-space-calendars-list").append(i.render())},this))},_onSubmit:function(){var i=[];b.each(this.nonSpaceCalendarEntryViews,function(j){var k=j.updateSubCalendar("onSubmit");if(k!==undefined){i.push(k)}});e.when.apply(e,i).done(b.bind(function(){var j=true;b.each(this.nonSpaceCalendarEntryViews,function(k){if(!k.isUpdateSuccessfully()){j=false}});if(j){this.CalendarPlugin.updateAvailableSubCalendarsInSubCalendarPanel(this.calendarDiv);c.hide();d.fireEventForAnalytics("non.space.calendars.upgrade.all.calendars.successful")}},this));d.fireEventForAnalytics("non.space.calendars.upgrade.dialog.submit.click");return false},_onCancel:function(){var i=false;b.each(this.nonSpaceCalendarEntryViews,function(j){if(j.isUpdateSuccessfully()){i=true}});if(i){this.CalendarPlugin.updateAvailableSubCalendarsInSubCalendarPanel(this.calendarDiv)}c.hide();d.fireEventForAnalytics("non.space.calendars.upgrade.dialog.cancel.click");return false}});return g}); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.extra.team-calendars:non-space-calendars-dialog', location = 'com/atlassian/confluence/extra/calendar3/components/non-space-calendars-dialog/non-space-calendars-handler.js' */ define("tc/non-space-calendars-handler",["jquery","underscore","tc/calendar-util","tc/non-space-calendars-warning-view"],function(d,a,b,e){var c;return{handle:function(j,i,f,h){if(b.isMyCalendarView(i)){var g=a.filter(h,function(k){return k.eventsEditable&&(k.spaceKey===undefined||k.spaceKey==="")});if(!c){c=new e({el:".non-space-calendars-warning",CalendarPlugin:j,calendarDiv:i,cache:f})}c.render(g)}}}}); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.extra.team-calendars:non-space-calendars-dialog', location = 'com/atlassian/confluence/extra/calendar3/components/non-space-calendars-dialog/non-space-calendars-warning-view.js' */ define("tc/non-space-calendars-warning-view",["jquery","underscore","tc-backbone","ajs","tc/calendar-util","tc/non-space-calendars-dialog-view"],function(d,b,g,a,c,f){var e=g.View.extend({events:{"click .fix-calendars-link":"_onFixCalendarLinkClick"},initialize:function(h){this.CalendarPlugin=h.CalendarPlugin;this.calendarDiv=h.calendarDiv;this.cache=h.cache},render:function(h){this.nonSpaceCalendars=h;this.$(".title strong").text(a.format("{0} of these calendars need a related space.",this.nonSpaceCalendars.length));if(this.nonSpaceCalendars&&this.nonSpaceCalendars.length>0){this.show()}else{this.hide()}},show:function(){this.$el.removeClass("hidden")},hide:function(){this.$el.addClass("hidden")},_onFixCalendarLinkClick:function(){if(!this.nonSpaceCalendarsDialogView){this.nonSpaceCalendarsDialogView=new f({subCalendars:this.nonSpaceCalendars,CalendarPlugin:this.CalendarPlugin,calendarDiv:this.calendarDiv,cache:this.cache})}this.nonSpaceCalendarsDialogView.setSubCalendars(this.nonSpaceCalendars);this.nonSpaceCalendarsDialogView.render();c.fireEventForAnalytics("non.space.calendars.upgrade.link.click");return false}});return e}); }catch(e){WRMCB(e)}; ; try { /* module-key = 'com.atlassian.confluence.extra.team-calendars:non-space-calendars-dialog', location = 'com/atlassian/confluence/extra/calendar3/components/non-space-calendars-dialog/non-space-calendars-dialog.soy' */ // This file was automatically generated from non-space-calendars-dialog.soy. // Please don't edit this file by hand. /** * @fileoverview Templates in namespace Confluence.TeamCalendars.Templates. */ if (typeof Confluence == 'undefined') { var Confluence = {}; } if (typeof Confluence.TeamCalendars == 'undefined') { Confluence.TeamCalendars = {}; } if (typeof Confluence.TeamCalendars.Templates == 'undefined') { Confluence.TeamCalendars.Templates = {}; } Confluence.TeamCalendars.Templates.nonSpaceCalendarsDialog = function(opt_data, opt_ignored) { return '
' + soy.$$escapeHtml('Set a related space for these calendars, to make them easier to:') + '
' + soy.$$escapeHtml('Calendar') + '
' + soy.$$escapeHtml('Related Space') + '
'; }; if (goog.DEBUG) { Confluence.TeamCalendars.Templates.nonSpaceCalendarsDialog.soyTemplateName = 'Confluence.TeamCalendars.Templates.nonSpaceCalendarsDialog'; } Confluence.TeamCalendars.Templates.nonSpaceCalendarEntry = function(opt_data, opt_ignored) { return '
'; }; if (goog.DEBUG) { Confluence.TeamCalendars.Templates.nonSpaceCalendarEntry.soyTemplateName = 'Confluence.TeamCalendars.Templates.nonSpaceCalendarEntry'; } }catch(e){WRMCB(e)};