text: !function(l){var e=Garnish.Base.extend({totalAvailableUpdates:0,criticalUpdateAvailable:!1,allowAutoUpdates:null,init:function(){var n=l("#graphic"),o=l("#status");Craft.postActionRequest("update/getAvailableUpdates",l.proxy(function(e,t){if("success"!=t||e.error||e.errors){var a=Craft.t("An unknown error occurred.");e.errors&&e.errors.length?a=e.errors[0]:e.error&&(a=e.error),n.addClass("error"),o.text(a)}else{if(this.allowAutoUpdates=e.allowAutoUpdates,e.app&&this.processUpdate(e.app,!1),e.plugins&&e.plugins.length)for(var s=0;s<e.plugins.length;s++)this.processUpdate(e.plugins[s],!0);var i;if(this.totalAvailableUpdates||e.v3Plugins&&e.v3Plugins.length)n.remove(),o.remove(),i=1==this.totalAvailableUpdates?Craft.t("1 update available"):Craft.t("{num} updates available",{num:this.totalAvailableUpdates}),l('<div id="page-title"/>').appendTo(Craft.cp.$pageHeader).append(l("<h1/>").text(i)),e.v3Plugins&&e.v3Plugins.length&&this.processV3Plugins(e.v3Plugins);else n.addClass("success"),o.text(Craft.t("You’re all up-to-date!"))}},this))},processUpdate:function(e,t){if(e.releases&&e.releases.length){this.totalAvailableUpdates++;new a(e,t)}},processV3Plugins:function(e){this.totalAvailableUpdates&&l("<hr/>").appendTo(Craft.cp.$main);var t=l('<div class="pane"/>').appendTo(Craft.cp.$main),a=l('<div class="header"/>').appendTo(t);l("<h1/>",{class:"left",text:"Craft 3 Plugin Availability"}).appendTo(a);var s=l('<table class="data fullwidth"><thead><tr><th scope="col" colspan="2">'+Craft.t("Plugin")+'</th><th scope="col">'+Craft.t("Developer")+'</th><th scope="col">'+Craft.t("Status")+'</th><th scope="col">'+Craft.t("Price")+"</th></tr></thead><tbody></tbody></table>").appendTo(t);l("<p/>",{class:"centeralign",css:{"margin-top":"24px"},html:'Check out the <a href="http://craftcms.com/craft3upgradeguide">Craft 3 upgrade guide</a> for information about upgrading your site to Craft 3.'}).appendTo(t);for(var i,n=s.find("tbody"),o=0;o<e.length;o++)i=e[o],l('<tr><td class="thin"><img src="'+i.iconUrl+'" width="36" height="36"></td><td><strong>'+i.name+"</strong></td><td>"+(i.developerUrl?'<a href="'+i.developerUrl+'" target="_blank">'+i.developerName+"</a>":i.developerName)+'</td><td><span class="status '+i.statusColor+'"></span>'+i.status+"</td><td>"+(i.formattedPrice||"")+"</td></tr>").appendTo(n)}}),a=Garnish.Base.extend({updateInfo:null,isPlugin:null,displayName:null,manualUpdateRequired:null,$pane:null,$paneHeader:null,$downloadBtn:null,licenseHud:null,$licenseSubmitBtn:null,licenseSubmitAction:null,init:function(e,t){this.updateInfo=e,this.isPlugin=t,this.displayName=this.isPlugin?this.updateInfo.displayName:"Craft CMS",this.manualUpdateRequired=!s.allowAutoUpdates||this.updateInfo.manualUpdateRequired,this.createPane(),this.createHeading(),this.createDownloadButton(),this.createReleaseList()},createPane:function(){this.$pane=l('<div class="pane update"/>').appendTo(Craft.cp.$main),this.$paneHeader=l('<div class="header"/>').appendTo(this.$pane)},createHeading:function(){l("<h1/>",{class:"left",text:this.displayName}).appendTo(this.$paneHeader)},createDownloadButton:function(){var e,t=l('<div class="buttons right"/>').appendTo(this.$paneHeader);if(this.manualUpdateRequired)this.$downloadBtn=l('<div class="btn submit">'+Craft.t("Download")+"</div>").appendTo(t);else{var a=l('<div class="btngroup submit"/>').appendTo(t),s=l('<div class="btn submit menubtn"/>').appendTo(a),i=l('<div class="menu" data-align="right"/>').appendTo(a),n=l("<ul/>").appendTo(i),o=l("<li/>").appendTo(n);e=l('<div class="btn submit">'+Craft.t("Update")+"</div>").insertBefore(s),this.$downloadBtn=l("<a>"+Craft.t("Download")+"</a>").appendTo(o),new Garnish.MenuBtn(s)}this.updateInfo.licenseUpdated?(this.addListener(this.$downloadBtn,"click","showLicenseForm"),this.manualUpdateRequired||this.addListener(e,"click","showLicenseForm")):(this.addListener(this.$downloadBtn,"click","downloadThat"),this.manualUpdateRequired||this.addListener(e,"click","autoUpdateThat"))},createReleaseList:function(){for(var e=0;e<this.updateInfo.releases.length;e++)new Release(this,this.updateInfo.releases[e])},showLicenseForm:function(e){if(e.stopPropagation(),this.licenseHud)this.licenseHud.$trigger=l(e.currentTarget),this.licenseHud.show();else{var t=l("<div><p>"+Craft.t('Craft’s <a href="http://craftcms.com/license" target="_blank">Terms and Conditions</a> have changed.')+"</p></div>"),a=l("<label> "+Craft.t("I agree.")+" &nbsp;</label>").appendTo(t),s=l('<input type="checkbox"/>').prependTo(a);this.$licenseSubmitBtn=l('<input class="btn submit" type="submit"/>').appendTo(t),this.licenseHud=new Garnish.HUD(e.currentTarget,t,{onSubmit:l.proxy(function(){s.prop("checked")?(this.licenseSubmitAction(),this.licenseHud.hide(),s.prop("checked",!1)):Garnish.shake(this.licenseHud.$hud)},this)})}e.currentTarget==this.$downloadBtn[0]?(this.$licenseSubmitBtn.attr("value",Craft.t("Seriously, download.")),this.licenseSubmitAction=this.downloadThat):(this.$licenseSubmitBtn.attr("value",Craft.t("Seriously, update.")),this.licenseSubmitAction=this.autoUpdateThat)},downloadThat:function(){window.location.href=this.updateInfo.manualDownloadEndpoint},autoUpdateThat:function(){window.location.href=Craft.getUrl("updates/go/"+(this.isPlugin?this.updateInfo.class.toLowerCase():"craft"))}});Release=Garnish.Base.extend({update:null,releaseInfo:null,$container:null,$releaseNotes:null,$showMoreLink:null,init:function(e,t){this.update=e,this.releaseInfo=t,this.createContainer(),this.createHeading(),this.createReleaseNotes()},createContainer:function(){this.$container=l('<div class="release"/>').appendTo(this.update.$pane)},createHeading:function(){var e=this.releaseInfo.version;this.releaseInfo.build&&(e+="."+this.releaseInfo.build),this.releaseInfo.critical&&(e+=' <span class="critical">'+Craft.t("Critical")+"</span>"),l("<h2/>",{html:e}).appendTo(this.$container),l("<p/>",{class:"release-date light",text:Craft.t("Released on {date}",{date:this.releaseInfo.localizedDate})}).appendTo(this.$container)},createReleaseNotes:function(){this.$releaseNotes=l('<div class="release-notes"/>').appendTo(this.$container).html(this.releaseInfo.notes),this.$releaseNotes.children("ul").children().length>Release.maxInitialReleaseNotes&&(this.$releaseNotes.addClass("fade-out"),this.$showMoreLink=l("<a/>",{class:"show-full-notes",text:Craft.t("Show more")}).appendTo(this.$container),this.addListener(this.$showMoreLink,"click","showMoreReleaseNotes"))},showMoreReleaseNotes:function(){var e=this.$releaseNotes.height();this.$releaseNotes.css("max-height","none");var t=this.$releaseNotes.height();this.$releaseNotes.height(e).velocity({height:t},{duration:"fast",complete:l.proxy(function(){this.$releaseNotes.removeClass("fade-out").css("max-height",""),this.$showMoreLink.remove()},this)}),this.$showMoreLink.velocity({opacity:0,"margin-top":-18},{duration:"fast",complete:l.proxy(function(){this.$showMoreLink.remove()})})}},{maxInitialReleaseNotes:5});var s=new e}(jQuery);
  //# sourceMappingURL=updates.js.map