1"use strict"; 2 3function recipeDetailsPageInit(ctx){ 4 5 $(".customise-btn").click(function(e){ 6 e.preventDefault(); 7 var imgCustomModal = $("#new-custom-image-modal"); 8 9 if (imgCustomModal.length === 0) 10 throw("Modal new-custom-image not found"); 11 12 var recipe = {id: $(this).data('recipe'), name: null} 13 newCustomImageModalSetRecipes([recipe]); 14 imgCustomModal.modal('show'); 15 }); 16 17 $("#add-layer-btn").click(function(){ 18 var btn = $(this); 19 20 libtoaster.addRmLayer(ctx.recipe.layer_version, 21 true, 22 function (layersList){ 23 var msg = libtoaster.makeLayerAddRmAlertMsg(ctx.recipe.layer_version, 24 layersList, 25 true); 26 27 libtoaster.showChangeNotification(msg); 28 29 var toShow = $("#customise-build-btns"); 30 31 /* If we have no packages built yet also fade in the build packages 32 * hint message 33 */ 34 if (ctx.recipe.totalPackages === 0){ 35 toShow = toShow.add("#build-to-get-packages-msg"); 36 } 37 38 $("#packages-alert").add(btn).fadeOut(function(){ 39 toShow.fadeIn(); 40 }); 41 }); 42 }); 43 44 /* Trigger a build of your custom image */ 45 $(".build-recipe-btn").click(function(){ 46 libtoaster.startABuild(null, ctx.recipe.name, 47 function(){ 48 window.location.replace(libtoaster.ctx.projectBuildsUrl); 49 }); 50 }); 51} 52