/**
 * These are Bolt’s COMPILED JS files!
 * You can edit *.js files in /app/src/js/ and then run "grunt updateBolt" to generate this file.
 */function getSelectedItems(){var a=[];return $(".dashboardlisting input:checked").each(function(){$(this).parents("tr").attr("id")&&a.push($(this).parents("tr").attr("id").substr(5))}),a}function bindFileUpload(a){$("#fileupload-"+a).fileupload({dataType:"json",dropZone:$("#dropzone-"+a),pasteZone:null,done:function(b,c){$.each(c.result,function(b,c){var d,e;void 0===c.error?(d=decodeURI(c.url).replace("files/",""),$("#field-"+a).val(d),$("#thumbnail-"+a).html('<img src="'+Bolt.conf("paths.root")+"thumbs/200x150c/"+encodeURI(d)+'" width="200" height="150">'),window.setTimeout(function(){$("#progress-"+a).fadeOut("slow")},1500),Bolt.stack.addToStack(d)):(e="Oops! There was an error uploading the file. Make sure the file is not corrupt, and that the 'files/'-folder is writable.\n\n(error was: "+c.error+")",alert(e),window.setTimeout(function(){$("#progress-"+a).fadeOut("slow")},50)),$("#progress-"+a+" div.bar").css("width","100%"),$("#progress-"+a).removeClass("progress-striped active")})},add:bindFileUpload.checkFileSize}).bind("fileuploadprogress",function(b,c){var d=Math.round(100*c.loaded/c.total);$("#progress-"+a).show().addClass("progress-striped active"),$("#progress-"+a+" div.progress-bar").css("width",d+"%")})}try{console.assert(1)}catch(e){console={log:function(){},assert:function(){}}}String.prototype.subst=function(a){return this.replace(/%[A-Z][A-Z0-9_]+%/g,function(b){return b in a?a[b]:b})};var Bolt={};!function(bolt,$){var actions={};actions.init=function(){$("button, input[type=button], a").off("click.action"),$("[data-action]").on("click.action",function(e){var action=$(this).attr("data-action");"undefined"!=typeof action&&""!==action&&(e.preventDefault(),eval(action),e.stopPropagation())}).on("click.popover",".popover",function(a){a.stopPropagation()}),$(".clickspinner").on("click.spinner",function(){$(this).addClass("disabled").blur(),$(this).find("i").addClass("fa-spin fa-spinner"),window.setTimeout(function(a){$(a).removeClass("disabled"),$(a).find("i").removeClass("fa-spin fa-spinner")},1e4,this)}),$(".submitspinner").on("submit.spinner",function(){$(this).find("button[type=submit]").addClass("disabled").blur(),$(this).find("button[type=submit] i").addClass("fa-spin fa-spinner"),window.setTimeout(function(a){$(a).removeClass("disabled"),$(a).find("i").removeClass("fa-spin fa-spinner")},1e4,$(this).find("button[type=submit]"))})},bolt.actions=actions}(Bolt||{},jQuery),function(a,b){var c={};c.init=function(){b("#latestactivity").is("*")&&setTimeout(function(){a.activity.update()},d)},c.update=function(){b.get(a.conf("paths.async")+"latestactivity",function(c){b("#latesttemp").html(c),a.moments.update(),b("#latestactivity").html(b("#latesttemp").html())}),setTimeout(function(){a.activity.update()},d)};var d=3e4;a.activity=c}(Bolt||{},jQuery),function(a,b){function c(){a.moments=new Moments,a.imagelist=[],a.filelist=[],init.confirmationDialogs(),init.magnificPopup(),init.dropZone(),init.popOvers(),init.dropDowns(),init.deferredWidgets(),init.passwordInput(),init.dashboardCheckboxes(),init.sortables(),init.omnisearch(),init.uploads(),init.focusStatusSelect(),init.depublishTracking(),b("[data-bind]").each(function(){var c=b(this).data("bind");switch(c.bind){case"editcontent":a.editcontent.init(c);break;case"editfile":init.bindEditFile(c);break;case"editlocale":init.bindEditLocale(c);break;case"filebrowser":init.bindFileBrowser();break;case"ckfileselect":init.bindCkFileSelect();break;case"prefill":init.bindPrefill();break;case"video":a.video.bind(c.key);break;default:console.log("Binding "+c.bind+" failed!")}})}var d={};d.initFields=function(){b("[data-bolt-field]").each(function(){var c=b(this).data("bolt-field"),d=b(this).data("bolt-fconf");switch(c){case"geolocation":a.fields.geolocation.init(this,d);break;case"slug":a.fields.slug.init(this,d);break;default:console.log("Unknown field type: "+c)}})},d.run=function(){a.conf.init(),a.data.init(),a.actions.init(),a.secmenu.init(),a.stack.init(),a.activity.init(),a.ckeditor.init(),a.datetime.init(),c(),a.app.initFields()},b(document).ready(d.run),a.app=d}(Bolt||{},jQuery),function(a,b,c){function d(){var a=[];for(var b in arguments)if(1===arguments[b].length||arguments[b][0]){var c=arguments[b][arguments[b].length-1];"string"==typeof c&&"|"===c.substr(0,1)&&(c=c.substr(1),a=a.concat("-")),a=a.concat(c)}return a}var e={};e.init=function(){c&&(c=e.initcke(c))},e.update=function(){if(c)for(var a in c.instances)c.instances[a].updateElement()},e.initcke=function(c){c.editorConfig=function(c){var e,f=b(this.element.$).data("param")||{},g=a.conf("ckeditor");c.language=a.conf("locale.short"),c.skin="boltcke",c.resize_enabled=!0,c.entities=!1,c.fillEmptyBlocks=!1,c.extraPlugins="codemirror",c.toolbar=d([{name:"styles",items:d(["Format"],[g.styles,"Styles"])}],[{name:"basicstyles",items:d(["Bold"],["Italic"],[g.underline,"Underline"],[g.strike,"Strike"])}],[{name:"paragraph",items:d(["NumberedList"],["BulletedList"],["Indent"],["Outdent"],[g.blockquote,"|Blockquote"])}],[{name:"links",items:d(["Link"],["Unlink"],[g.anchor,"|Anchor"])}],[g.subsuper,{name:"subsuper",items:d(["Subscript"],["Superscript"])}],[g.images,{name:"image",items:d(["Image"])}],[g.embed,{name:"embed",items:d(["oembed"])}],[g.tables,{name:"table",items:d(["Table"])}],[g.ruler,{name:"ruler",items:d(["HorizontalRule"])}],[g.align,{name:"align",items:d(["JustifyLeft"],["JustifyCenter"],["JustifyRight"],["JustifyBlock"])}],[g.fontcolor,{name:"colors",items:d(["TextColor"],["BGColor"])}],[g.codesnippet,{name:"code",items:d(["|CodeSnippet"])}],[{name:"tools",items:d(["RemoveFormat"],["Maximize"],["|Source"],[g.specialchar,"|SpecialChar"])}]),g.embed&&(c.extraPlugins+=",oembed,widget",c.oembed_maxWidth="853",c.oembed_maxHeight="480"),c.height=250,c.autoGrow_onStartup=!0,c.autoGrow_minHeight=150,c.autoGrow_maxHeight=400,c.autoGrow_bottomSpace=24,c.removePlugins="elementspath",c.resize_dir="vertical",g.filebrowser?(g.filebrowser.browseUrl&&(c.filebrowserBrowseUrl=g.filebrowser.browseUrl),g.filebrowser.imageBrowseUrl&&(c.filebrowserImageBrowseUrl=g.filebrowser.imageBrowseUrl),g.filebrowser.uploadUrl&&(c.filebrowserUploadUrl=g.filebrowser.uploadUrl),g.filebrowser.imageUploadUrl&&(c.filebrowserImageUploadUrl=g.filebrowser.imageUploadUrl)):(c.filebrowserBrowseUrl="",c.filebrowserImageBrowseUrl="",c.filebrowserUploadUrl="",c.filebrowserImageUploadUrl=""),c.codemirror={theme:"default",lineNumbers:!0,lineWrapping:!0,matchBrackets:!0,autoCloseTags:!0,autoCloseBrackets:!0,enableSearchTools:!0,enableCodeFolding:!0,enableCodeFormatting:!1,autoFormatOnStart:!1,autoFormatOnUncomment:!1,autoFormatOnModeChange:!1,highlightActiveLine:!0,highlightMatches:!0,showFormatButton:!1,showCommentButton:!1,showUncommentButton:!1};for(e in g.ck)g.ck.hasOwnProperty(e)&&(c[e]=g.ck[e]);f.height&&(c.height=parseInt(f.height),c.autoGrow_minHeight=Math.max(c.autoGrow_minHeight,c.height),c.autoGrow_maxHeight=Math.max(c.autoGrow_maxHeight,c.height));for(e in f.ckeditor)f.ckeditor.hasOwnProperty(e)&&(c[e]=f.ckeditor[e])};var e=a.conf("ckeditor");return e.ck.allowNbsp&&c.on("instanceReady",function(a){a.editor.on("paste",function(a){a.data.dataValue=a.data.dataValue.replace(/&nbsp;/g," "),a.data.dataValue=a.data.dataValue.replace(/<p> <\/p>/g,"")},null,null,9)}),c},a.ckeditor=e}(Bolt||{},jQuery,"undefined"!=typeof CKEDITOR?CKEDITOR:void 0),function(a,b,c){var d={},e=function(a){var b,e=a.split("."),f=d;for(b=0;b<e.length;b++){if("undefined"==typeof f[e[b]])return c;f=f[e[b]]}return f};e.get=e,e.init=function(){d=b("script[data-config]").first().data("config")},a.conf=e}(Bolt||{},jQuery),function(a,b,c){var d={},e=function(a,b){var e,f=a.split("."),g=d;for(e=0;e<f.length;e++){if("undefined"==typeof g[f[e]])return c;g=g[f[e]]}return b&&"string"==typeof g?g.subst(b):g};e.get=e,e.init=function(){d=b("script[data-jsdata]").first().data("jsdata")||{}},a.data=e}(Bolt||{},jQuery),function(a,b,c){function d(a){var b,d,e,f=c(a.date.datepicker("getDate")),g=c([2001,11,24]),h=!1;if(a.time.exists&&(e=a.time.val().match(/^\s*(?:(?:([01]?[0-9]|2[0-3])[:,.]([0-5]?[0-9]))|(1[012]|0?[1-9])[:,.]([0-5]?[0-9])(?:\s*([AP])[. ]?M\.?))\s*$/i),e&&(b=parseInt(e[1]?e[1]:e[3]),d=parseInt(e[2]?e[2]:e[4]),"p"!==e[5]&&"P"!==e[5]||12===b?"a"!==e[5]&&"A"!==e[5]||12!==b||(b-=12):b+=12,g=c([2001,11,24,b,d]),h=!0)),f.isValid()){var i=a.time.exists?" "+g.format("HH:mm:00"):"";a.data.val(f.format("YYYY-MM-DD")+i)}else h?a.data.val(c().format("YYYY-MM-DD")+" "+g.format("HH:mm:00")):a.data.val("")}function e(a){var c,d,e,f,g="",h="";"datedepublish"===a.data.attr("id")&&"1900-01-01 00:00:00"===a.data.val()&&a.data.val(""),d=a.data.val().match(/^(\d{4}-\d{2}-\d{2})(?: (\d{2}:\d{2}:\d{2}))?$/),d&&(g=d[1],h=d[2]||""),e=""===g||"0000-00-00"===g?"":b.datepicker.parseDate("yy-mm-dd",g),a.date.datepicker("setDate",e),a.time.exists&&"0000-00-00"!==g&&(""===h?h=""!==g?"00:00":"":i?h=a.data.val().slice(11,16):(c=parseInt(h.slice(0,2)),f=12>c?" AM":" PM",h=(c%12||12)+h.slice(2,5)+f),a.time.val(h)),a.data.trigger("change")}function f(a){var b=a.date.data("field-options"),c={showOn:"none"};for(var d in b)b.hasOwnProperty(d)&&(c[d]=b[d]);a.date.datepicker(c),a.show.click(function(){a.date.datepicker("show")}),a.clear.click(function(){a.data.val(""),e(a)})}function g(a){var b={},c=a.next();return b.data=a,b.date=c.find("input.datepicker"),b.time=c.find("input.timepicker"),b.show=c.find("button.btn-tertiary"),b.clear=c.find("button.btn-default"),b.time.exists=b.time.length>0,b}var h={};h.init=function(){b.datepicker.setDefaults(b.datepicker.regional[a.conf("locale.long")]),i=c.localeData()._longDateFormat.LT.replace(/\[.+?\]/gi,"").match(/A/)?!1:!0,b("input.datetime").each(function(){var a=g(b(this));j.push(a),f(a),e(a),a.date.change(function(){d(a),e(a)}),a.time.change(function(){d(a),e(a)})})},h.update=function(){for(var a in j)e(j[a])};var i,j=[];a.datetime=h}(Bolt||{},jQuery,moment),function(a,b,c,d,e,f){function g(){b("#editcontent").attr("novalidate","novalidate").on("submit",function(c){var d=a.validation.run(this);return b(this).data("valid",d),d?void 0:(c.preventDefault(),!1)}),b("#editcontent").on("boltvalidate",function(){var c=a.validation.run(this);return b(this).data("valid",c),c})}function h(){var a=c.location.hash;a&&b('#filtertabs a[href="#tab-'+a.replace(/^#/,"")+'"]').tab("show"),b("#filtertabs a").click(function(){var a;b(this).tab("show"),a=b("body").scrollTop(),c.location.hash=this.hash.replace(/^#tab-/,""),b("html,body").scrollTop(a)})}function i(){b("#previewbutton, #sidebarpreviewbutton").bind("click",function(a){var c=b(a.target).data("url");a.preventDefault(),b("#editcontent").attr("action",c).attr("target","_blank").submit(),b("#editcontent").attr("action","").attr("target","_self")})}function j(a){}function k(){b("#deletebutton, #sidebardeletebutton").bind("click",function(d){d.preventDefault(),e.confirm(a.data("editcontent.delete"),function(d){if(b(".alert").alert(),d===!0){var e=a.conf("paths.bolt"),f=b("#id").closest("form"),g=b("#contenttype").val(),h=b("#id").val(),i=f.find('input[name="bolt_csrf_token"]').val(),j=e+"content/deletecontent/"+g+"/"+h+"?bolt_csrf_token="+i;b.ajax({url:j,type:"GET",success:function(a){c.location.href=e+"overview/"+b("#contenttype").val()}})}})})}function l(){b("#sidebarsavebutton").bind("click",function(){b("#savebutton").trigger("click")}),b("#savebutton").bind("click",function(){q()})}function m(){b("#sidebarsavenewbutton, #savenewbutton").bind("click",function(){q();var a="?returnto=saveandnew";b("#editcontent").attr("action",a).submit()})}function n(e){b("#sidebarsavecontinuebutton, #savecontinuebutton").bind("click",function(g){if(g.preventDefault(),b("#editcontent").trigger("boltvalidate"),!b("#editcontent").data("valid"))return!1;var h=e.newRecord,i=e.savedon,j=e.msgNotSaved;b("#sidebarsavecontinuebutton, #savecontinuebutton").addClass("disabled").blur(),b("#sidebarsavecontinuebutton i, #savecontinuebutton i").addClass("fa-spin fa-spinner"),b("p.lastsaved").text(a.data("editcontent.msg.saving")),h?(q(),b("#editcontent").attr("action","?returnto=new").submit()):(q(),b(Bolt).trigger("start.bolt.content.save"),b.post("?returnto=ajax",b("#editcontent").serialize()).done(function(e){b(Bolt).trigger("done.bolt.content.save",e),c.onbeforeunload=null,b("p.lastsaved").html(i),b("p.lastsaved").find("strong").text(d(e.datechanged).format("MMM D, HH:mm")),b("p.lastsaved").find("time").attr("datetime",d(e.datechanged).format()),b("p.lastsaved").find("time").attr("title",d(e.datechanged).format()),a.moments.update(),b("a#lastsavedstatus strong").html('<i class="fa fa-circle status-'+b("#statusselect option:selected").val()+'"></i> '+b("#statusselect option:selected").text()),"object"===b.type(e)&&b.each(e,function(a,c){if("object"===b.type(c))b.each(c,function(c,d){b(':input[name="'+a+"["+c+']"]').val(d)});else{var d=b("#"+a);"checkbox"===d.attr("type")?d.prop("checked","on"==c):d.val(c),f&&f.instances[a]&&f.instances[a].setData(c,{callback:function(){this.resetDirty()}})}}),a.datetime.update(),q()}).fail(function(){b(Bolt).trigger("fail.bolt.content.save"),b("p.lastsaved").text(j)}).always(function(){b(Bolt).trigger("always.bolt.content.save"),c.setTimeout(function(){b("#sidebarsavecontinuebutton, #savecontinuebutton").removeClass("disabled"),b("#sidebarsavecontinuebutton i, #savecontinuebutton i").removeClass("fa-spin fa-spinner")},300)}))})}function o(){(b("#sidebarsavecontinuebutton").is("*")||b("#saveeditfile").is("*"))&&(b("body, input").bind("keydown.ctrl_s keydown.meta_s",function(a){a.preventDefault(),q(),b("#sidebarsavecontinuebutton, #saveeditfile").trigger("click")}),c.setTimeout(function(){q()},1e3))}function p(){b(".templateselect").each(function(){var a=b(this).find("select"),c=a.data("stats"),d=b(this).find(".templatewarning");a.change(function(){d.html("").addClass("hidden").removeClass("text-danger"),a.val()!==c.current&&(c.currentHas?d.html("<strong>"+c.message.warning+":</strong> "+c.message.warningChange).removeClass("hidden").addClass("text-danger"):_.contains(c.fieldTemplates,a.val())&&d.html(c.message.change).removeClass("hidden"))})})}function q(){b("form#editcontent").find("input, textarea, select").each(function(){if("textarea"===this.type&&b(this).hasClass("ckeditor"))f.instances[this.id].checkDirty()&&(f.instances[this.id].updateElement(),f.instances[this.id].resetDirty());else{var a=s(this);void 0!==a&&b(this).data("watch",a)}}),c.onbeforeunload=function(){return r()||a.liveEditor.active?a.data("editcontent.msg.change_quit"):void 0}}function r(){var a=0;return b("form#editcontent").find("input, textarea, select").each(function(){if("textarea"===this.type&&b(this).hasClass("ckeditor"))f.instances[this.id].checkDirty()&&a++;else{var c=s(this);void 0!==c&&b(this).data("watch")!==c&&a++}}),a>0}function s(a){var c;return a.name&&(c=b(a).val(),"select-multiple"===a.type&&(c=JSON.stringify(c))),c}var t={};t.init=function(b){g(),l(),m(),n(b),i(),j(b.singularSlug),k(),h(),p(),a.liveEditor.init(b),c.setTimeout(function(){o()},1e3)},a.editcontent=t}(Bolt||{},jQuery,window,moment,bootbox,"undefined"!=typeof CKEDITOR?CKEDITOR:void 0),function(a,b){function c(c,d,e,f){var g={url:a.conf("paths.async")+c,type:"POST",data:d,success:function(a){document.location.reload()},error:function(a){alert(a.responseText),console.log(e)}};f&&(g.success=f),b.ajax(g)}var d={};d.renameFile=function(b,d,e,f){var g=window.prompt(a.data("files.msg.rename_file"),e);g.length&&g!==e&&c("renamefile",{namespace:b,parent:d,oldname:e,newname:g},"Something went wrong renaming this file!")},d.deleteFile=function(d,e,f){confirm(a.data("files.msg.delete_file",{"%FILENAME%":e}))&&c("deletefile",{namespace:d,filename:e},"Failed to delete the file from the server",function(a){null!==f&&b(f).closest("tr").slideUp()})},d.duplicateFile=function(a,b){c("duplicatefile",{namespace:a,filename:b},"Something went wrong duplicating this file!")},d.createFolder=function(b,d,e){var f=window.prompt(a.data("files.msg.create_folder"));f.length&&c("folder/create",{parent:d,foldername:f,namespace:b},"Something went wrong renaming this folder!")},d.renameFolder=function(b,d,e,f){var g=window.prompt(a.data("files.msg.rename_folder"),e);g.length&&g!==e&&c("folder/rename",{namespace:b,parent:d,oldname:e,newname:g},"Something went wrong renaming this folder!")},d.deleteFolder=function(d,e,f,g){window.confirm(a.data("files.msg.delete_folder",{"%FOLDERNAME%":f}))&&(c("folder/remove",{namespace:d,parent:e,foldername:f},"Something went wrong renaming this folder!"),b.ajax({success:function(a){}}))},a.files=d}(Bolt||{},jQuery),function(a,b,c,d){var e={},f=(a.editcontent,["text","html","textarea"]);e.init=function(a){b("#live-editor-iframe");e.slug=a.singularSlug,Modernizr.contenteditable?(b("#sidebar-live-editor-button, #live-editor-button").bind("click",e.start),b(".close-live-editor").bind("click",e.stop)):b(".live-editor, #sidebar-live-editor-button, #live-editor-button").remove()},e.start=function(c){var d=a.validation.run(b("#editcontent")[0]);if(d){var g=function(a){a.preventDefault()},h=function(){var c=b("#live-editor-iframe")[0],d=c.contentWindow||c,h=d.document,i=b(h);i.on("click","a",g);var j=a.ckeditor.initcke(d.CKEDITOR),k=j.editorConfig;j.editorConfig=function(a){k.bind(this)(a);var b;_.each(a.toolbar,function(a,c){"tools"===a.name&&(b=c)}),a.toolbar[b]=_.without(a.toolbar[b],"Source")},j.disableAutoInline=!1,i.find("[data-bolt-field]").each(function(){var a=b("#editcontent *[name="+e.escapejQuery(b(this).data("bolt-field"))+"]"),c=a.closest("[data-fieldtype]").data("fieldtype");if(b(this).addClass("bolt-editable"),!b(this).data("no-edit")&&-1!=f.indexOf(c))if(b(this).attr("contenteditable",!0),"html"==c){j.inline(this,{allowedContent:""})}else b(this).on("paste",function(a){var b;a.preventDefault(),a.originalEvent.clipboardData?(b=a.originalEvent.clipboardData.getData("text/plain"),h.execCommand("insertText",!1,b)):d.clipboardData&&(b=d.clipboardData.getData("Text"),d.getSelection&&d.getSelection().getRangeAt(0).insertNode(h.createTextNode(b)))}),"textarea"==c?b(this).on("keypress",function(a){13==a.which&&(a.preventDefault(),h.execCommand("insertHTML",!1,"<br><br>"))}):b(this).on("keypress",function(a){return 13!=a.which}).on("focus blur",function(a){b(this).html(b(this).text())})})};b("#live-editor-iframe").on("load",h),a.liveEditor.active=!0,b("body").addClass("live-editor-active"),b("#navpage-primary .navbar-header a").on("click",g);var i=a.conf("paths.root")+"preview/"+e.slug;b("#editcontent *[name=_live-editor-preview]").val("yes"),b("#editcontent").attr("action",i).attr("target","live-editor-iframe").submit(),b("#editcontent").attr("action","").attr("target","_self"),b("#editcontent *[name=_live-editor-preview]").val(""),e.removeEvents=function(){b("#live-editor-iframe").off("load",h),b("#navpage-primary .navbar-header a").off("click",g)}}},e.stop=function(c){var f=b("#live-editor-iframe")[0],g=f.contentWindow||f,h=g.document,i=b(h);i.find("[data-bolt-field]").each(function(){var a=b(this).data("bolt-field"),c=b("#editcontent [name="+e.escapejQuery(a)+"]"),f=c.closest("[data-fieldtype]").data("fieldtype"),g="";if("html"===f){g=b(this).html();var h=c.attr("id");_.has(d.instances,h)&&d.instances[h].setData(g)}else g=e.cleanText(b(this),f);c.val(g)}),b(f).attr("src",""),a.liveEditor.active=!1,b("body").removeClass("live-editor-active"),e.removeEvents()},e.cleanText=function(a,b){return"textarea"==b&&a.html(a.html().replace(/&nbsp;/g," ").replace(/\s?<br.*?>\s?/g,"\n")),a.text()},e.escapejQuery=function(a){return a.replace(/(:|\.|\[|\]|,)/g,"\\$1")},e.active=!1,e.slug=null,e.removeEvents=null,a.liveEditor=e}(Bolt||{},jQuery,window,"undefined"!=typeof CKEDITOR?CKEDITOR:void 0),function(a,b){var c={};c.init=function(){bindFileUpload("stack"),b("#selectImageModal-stack").on("click",".folder",function(a){a.preventDefault(),b("#selectImageModal-stack .modal-content").load(b(this).attr("href"))});var c=b([]);b('[data-toggle="modal"]').each(function(){c=c.add(b(b(this).data("target")))}),b(c).on("loaded.bs.modal",function(b){a.actions.init()})},c.addToStack=function(c,d){var e,f=c.substr(c.lastIndexOf(".")+1).toLowerCase();e="jpg"===f||"jpeg"===f||"png"===f||"gif"===f?"image":"other",c=c.replace(/files\//gi,""),b.ajax({url:a.conf("paths.async")+"addstack/"+c,type:"GET",success:function(g){var h,i,j,k,l=b("#stackholder div.stackitem");for(h=l.length;h>=1;h--)i=h+1,j=b("#stackholder div.stackitem.item-"+h),j.addClass("item-"+i).removeClass("item-"+h);b("#stackholder div.stackitem.item-8").is("*")&&b("#stackholder div.stackitem.item-8").remove(),null!==d&&b(d).addClass("disabled"),"image"===e?(k=b("#protostack div.image").clone(),b(k).find("img").attr("src",a.conf("paths.bolt")+"../thumbs/100x100c/"+encodeURI(c))):(k=b("#protostack div.other").clone(),b(k).find("strong").html(f.toUpperCase()),b(k).find("small").html(c)),b("#stackholder").prepend(k),b(".nostackitems").remove()},error:function(){console.log("Failed to add file to stack")}})},c.selectFromPulldown=function(c,d){if(b("#field-"+c).is("*")&&b("#field-"+c).val(d),"object"==typeof a.imagelist&&"object"==typeof a.imagelist[c]&&a.imagelist[c].add(d,d),"object"==typeof a.filelist&&"object"==typeof a.filelist[c]&&a.filelist[c].add(d,d),b("#thumbnail-"+c).is("*")){var e=a.conf("paths.bolt")+"../thumbs/200x150c/"+encodeURI(d);b("#thumbnail-"+c).html('<img src="'+e+'" width="200" height="150">')}b("#selectModal-"+c).is("*")&&b("#selectModal-"+c).modal("hide"),"stack"===c&&a.stack.addToStack(d),b(".in, .open").removeClass("in open")},c.changeFolder=function(c,d){b("#selectModal-"+c+" .modal-content").load(d,function(){a.actions.init()})},a.stack=c}(Bolt||{},jQuery),function(a,b,c){function d(){b("#navpage-secondary").outerHeight(0);var a=b(document).height()-b("#navpage-secondary").position().top,e=3e3;a!==b("#navpage-secondary").outerHeight()&&(b("#navpage-secondary").outerHeight(a),e=300),c.setTimeout(d,e)}function e(){b(".navbar-toggle").on("click",function(){var a=b("#navpage-wrapper");a.hasClass("nav-secondary-opened")?a.removeClass("nav-secondary-opened nav-secondary-collapsed"):a.removeClass("nav-secondary-collapsed").addClass("nav-secondary-opened")})}function f(){b(".nav-secondary-collapse a").on("click",function(){return b("#navpage-wrapper").removeClass("nav-secondary-opened").addClass("nav-secondary-collapsed"),setTimeout(function(){b("#navpage-wrapper").addClass("nav-secondary-collapsed-hoverable")},300),b.cookie("sidebar","collapsed",{expires:21,path:"/"}),!1})}function g(){b(".nav-secondary-expand a").on("click",function(){return b("#navpage-wrapper").removeClass("nav-secondary-collapsed nav-secondary-opened nav-secondary-collapsed-hoverable"),b.removeCookie("sidebar",{path:"/"}),!1})}function h(){b("#navpage-secondary").find("a.menu-pop").each(function(){var a=b(this),d="";a.nextAll(".submenu").children().each(function(){b(this).hasClass("subdivider")&&(d+="<hr>"),d+=b(this).html().trim().replace(/[ \n]+/g," ").replace(/(>) | (<)/g,"$1$2")}),a.popover({trigger:"manual",content:d,html:!0}),a.on("mouseover focus click dblclick",function(a){var d=this,e=150;"click"!==a.type||b(d).next().hasClass("popover")||(a.preventDefault(),e=0),c.clearTimeout(k),k=c.setTimeout(function(){b("#navpage-secondary a.menu-pop").not(d).popover("hide"),b(d).popover("show")},e)})}).end().on("mouseenter focus",".popover",function(){c.clearTimeout(k)}).on("mouseleave blur","a.menu-pop, .popover",function(){c.clearTimeout(k),k=c.setTimeout(function(){b("#navpage-secondary a.menu-pop").popover("hide")},300)})}function i(){b("#navpage-secondary a.menu-pop").on("click",function(a){var c=b(this).nextAll(".submenu");a.preventDefault(),c.hasClass("show")?c.removeClass("show"):(b("#navpage-secondary .submenu").removeClass("show"),c.addClass("show"))})}var j={};j.init=function(){var a=!b(".navbar-toggle").is(":visible");e(),f(),g(),b("#navpage-secondary").length&&d(),a?h():i()};var k=0;a.secmenu=j}(Bolt||{},jQuery,window),function(a,b){var c={};c.bind=function(a){b("#video-"+a).bind("propertychange input",function(){clearTimeout(d),d=setTimeout(function(){e(a)},400)}),b("#video-"+a+"-width").bind("propertychange input",function(){b("#video-"+a+"-ratio").val()>0&&b("#video-"+a+"-height").val(Math.round(b("#video-"+a+"-width").val()/b("#video-"+a+"-ratio").val()))}),b("#video-"+a+"-height").bind("propertychange input",function(){b("#video-"+a+"-ratio").val()>0&&b("#video-"+a+"-width").val(Math.round(b("#video-"+a+"-height").val()*b("#video-"+a+"-ratio").val()))})};var d,e=function(a){var c="https://api.embed.ly/1/oembed?format=json&key=51fa004148ad4d05b115940be9dd3c7e&url=",d=b("#video-"+a).val(),e=c+encodeURI(d);return d.length<2?(b("#video-"+a+"-html").val(""),b("#video-"+a+"-width").val(""),b("#video-"+a+"-height").val(""),b("#video-"+a+"-ratio").val(""),b("#video-"+a+"-text").html(""),b("#myModal").find(".modal-body").html(""),b("#video-"+a+"-author_name").val(""),b("#video-"+a+"-author_url").val(""),b("#video-"+a+"-title").val(""),b("#thumbnail-"+a).html(""),void b("#video-"+a+"-thumbnail").val("")):void b.getJSON(e,function(c){c.html&&(b("#video-"+a+"-html").val(c.html),b("#video-"+a+"-width").val(c.width),b("#video-"+a+"-height").val(c.height),b("#video-"+a+"-ratio").val(c.width/c.height),b("#video-"+a+"-text").html('"<b>'+c.title+'</b>" by '+c.author_name),b("#myModal").find(".modal-body").html(c.html),b("#video-"+a+"-author_name").val(c.author_name),b("#video-"+a+"-author_url").val(c.author_url),b("#video-"+a+"-title").val(c.title)),c.thumbnail_url&&(b("#thumbnail-"+a).html('<img src="'+c.thumbnail_url+'" width="200" height="150">'),b("#video-"+a+"-thumbnail").val(c.thumbnail_url))})};a.video=c}(Bolt||{},jQuery),function(a){a.fields={}}(Bolt||{}),function(a,b){function c(a,c){c&&(new google.maps.Geocoder).geocode(c,function(e,f){if(f===google.maps.GeocoderStatus.OK){var g;g=c.latLng&&!b(a.snap).is(":checked")?c.latLng:e[0].geometry.location,d(a,e[0].formatted_address,g.lat(),g.lng()),a.marker.setPosition(g),a.map.setCenter(g)}}),d(a)}function d(a,b,c,d){a.matched.val(b||""),a.latitude.val(c||""),a.longitude.val(d||"")}function e(d,e,f){var g={zoom:15,mapTypeId:google.maps.MapTypeId.ROADMAP,center:new google.maps.LatLng(e,f),streetViewControl:!1};d.map=new google.maps.Map(d.mapholder[0],g),d.marker=new google.maps.Marker({map:d.map,position:g.center,title:a.data("field.geolocation.marker"),draggable:!0,animation:google.maps.Animation.DROP,icon:a.conf("paths.app")+"view/img/pin_red.png"}),google.maps.event.addListener(d.marker,"mouseup",function(){c(d,{latLng:d.marker.getPosition()})}),d.address.on("propertychange input",function(){clearTimeout(d.timeout),d.timeout=setTimeout(function(){var a=d.address.val();c(d,a.length>2?{address:a}:void 0)},800)}),b('a[data-toggle="tab"]').on("shown.bs.tab",function(){d.mapholder.closest("div.tab-pane").hasClass("active")&&google.maps.event.trigger(d.map,"resize")})}var f={};f.init=function(a,c){var d={address:b(a).find(".address"),matched:b(a).find(".matched"),mapholder:b(a).find(".mapholder"),latitude:b(a).find(".latitude"),longitude:b(a).find(".longitude"),snap:b(a).find(".snap"),map:null,marker:null,timeout:void 0};"undefined"!=typeof google&&google.maps?e(d,c.latitude,c.longitude):console.log("ERROR: Google Maps not loaded!")},a.fields.geolocation=f}(Bolt||{},jQuery),function(a,b){function c(c,d){b.ajax({url:a.conf("paths.async")+"makeuri",type:"GET",data:{title:d,contenttypeslug:c.slug,id:c.id,slugfield:c.key,fulluri:!1},success:function(a){c.data.val(a),c.show.html(a)},error:function(){console.log("failed to get an URI")}})}function d(a){b.each(a.uses,function(d,e){b("#"+e).on("propertychange.bolt input.bolt change.bolt",function(){var d=[];b.each(a.uses,function(a,c){var e=b("#"+c);e.is("select")?e.find("option:selected").each(function(a,b){""!==b.text&&d.push(b.text)}):e.val()&&d.push(e.val())}),clearTimeout(g[a.key]),g[a.key]=setTimeout(function(){c(a,d.join(" "))},200)}).trigger("change.bolt")})}function e(a){b.each(a.uses,function(a,c){b("#"+c).off("propertychange.bolt input.bolt change.bolt")}),clearTimeout(g[a.key])}var f={};f.init=function(f,g){var h={group:b(f).find(".input-group"),show:b(f).find("em"),data:b(f).find("input"),lock:b(f).find("button.lock"),key:g.key,uses:g.uses,slug:g.slug,id:g.contentId};h.lock.on("click",function(){h.group.hasClass("locked")?(g.isEmpty||confirm(a.data("field.slug.message.unlock")))&&(h.group.removeClass("locked").addClass("unlocked"),d(h)):(h.group.removeClass("unlocked").addClass("locked"),e(h)),this.blur()}),b(f).find("button.edit").on("click",function(){var b=prompt(a.data("field.slug.message.set"),h.data.val());b&&(h.group.removeClass("unlocked").addClass("locked"),e(h),c(h,b)),this.blur()}),g.isEmpty&&h.lock.trigger("click")};var g=[];a.fields.slug=f}(Bolt||{},jQuery),bindFileUpload.checkFileSize=function(a,b){var c=[];if("undefined"==typeof b.originalFiles.bad&&(b.originalFiles.bad=[]),_.each(b.files,function(a,d){(a.size||0)>Bolt.conf("uploadConfig.maxSize")&&Bolt.conf("uploadConfig.maxSize")>0&&(c.push(a.name),b.originalFiles.bad.push(a.name))}),b.originalFiles.bad.length>0){var d=b.files[b.files.length-1].name,e=b.originalFiles[b.originalFiles.length-1].name;if(d===e){var f="One or more of the files that you selected was larger than the max size of "+Bolt.conf("uploadConfig.maxSizeNice")+":\n\n"+b.originalFiles.bad.join("\n");alert(f)}}0===c.length&&b.submit()};var FileModel=Backbone.Model.extend({defaults:{id:null,filename:null,title:"Untitled",order:1,progress:0,element:null},initialize:function(){}}),Filelist=Backbone.Collection.extend({model:FileModel,comparator:function(a){return a.get("order")},setOrder:function(a,b,c){_.each(this.models,function(d){d.get("id")===a&&(d.set("order",b),d.set("title",c))})}}),FilelistHolder=Backbone.View.extend({initialize:function(a){this.list=new Filelist,this.uploading=new Filelist,this.type=a.type,this.idPrefix="ImageList"==a.type?"#imagelist-":"#filelist-";var b=$("#"+this.id).val();""!==b&&(b=$.parseJSON($("#"+this.id).val()),_.each(b,function(a){this.list.add(new FileModel({filename:a.filename,title:a.title,id:this.list.length}))},this)),this.render(),this.bindEvents()},render:function(){this.list.sort();var a=$(this.idPrefix+this.id+" .list"),b=a.data("list"),c=this.type,d=$(this.idPrefix+this.id+" .uploading-list");a.html(""),_.each(this.list.models,function(d){var e=$(b.item.replace(/<ID>/g,d.get("id")).replace(/<VAL>/g,_.escape(d.get("title"))).replace(/<PATH>/g,Bolt.conf("paths.bolt")).replace(/<FNAME>/g,d.get("filename")));"ImageList"===c&&e.find(".thumbnail-link").magnificPopup({type:"image"}),a.append(e)}),d.html(""),_.each(this.uploading.models,function(a){var c=$(b.itemUploading.replace(/<FNAME>/g,a.get("filename")).replace(/<PROGRESS>/g,Math.round(100*a.progress)+"%"));a.element=c,d.append(c)}),0===this.list.models.length&&a.append(b.empty),this.serialize()},add:function(a,b){this.list.add(new FileModel({filename:a,title:b,id:this.list.length})),this.render()},remove:function(a,b){var c=!1;_.each(this.list.models,function(b){c||b.get("id")!==a||(this.list.remove(b),c=!0)},this),b||this.render()},serialize:function(){var a=JSON.stringify(this.list);$("#"+this.id).val(a)},doneSort:function(){var a=this.list;$(this.idPrefix+this.id+" .list div").each(function(b){var c=$(this).data("id"),d=$(this).find("input").val();a.setOrder(c,b,d)}),this.render()},bindEvents:function(){var a=this,b=this.id,c=$(this.idPrefix+this.id);c.find("div.list").sortable({helper:function(a,b){return b.hasClass("selected")||b.toggleClass("selected"),$("<div></div>")},start:function(a,b){var d=c.find(".selected").not(".ui-sortable-placeholder"),e=d.length,f=b.placeholder.outerHeight(!0),g=b.placeholder.height(),h=parseInt(b.placeholder.css("margin-top"))+parseInt(b.placeholder.css("margin-bottom"));d.css("display","none"),b.placeholder.height(g+e*f-f-h),b.item.data("items",d)},beforeStop:function(a,b){b.item.before(b.item.data("items"))},stop:function(){c.find(".ui-state-active").css("display",""),
a.doneSort()},delay:100,distance:5}),$("#fileupload-"+b).fileupload({dataType:"json",dropZone:c,pasteZone:null,done:function(b,c){$.each(c.result,function(b,c){var d=decodeURI(c.url).replace("files/","");a.add(d,d)})},add:bindFileUpload.checkFileSize}).bind("fileuploadsubmit",function(c,d){var e,f=$("#fileupload-"+b).attr("accept"),g=$(this.idPrefix+b+" div.list").data("list");"undefined"!=typeof f&&(e=new RegExp("\\.("+f.replace(/,/g,"|").replace(/\./g,"")+")$","i"),$.each(d.files,function(b,d){if(!e.test(d.name))return alert(g.message.wrongtype),c.preventDefault(),!1;var f=new FileModel({filename:d.name});d.uploading=f,a.uploading.add(f)})),a.render()}).bind("fileuploadprogress",function(a,b){var c=b.loaded/b.total;_.each(b.files,function(a,b){a.uploading.progress=c;var d=a.uploading.element.find(".progress-bar");d.css("width",Math.round(100*a.uploading.progress)+"%")})}).bind("fileuploadalways",function(b,c){_.each(c.files,function(b,c){a.uploading.remove(b.uploading)}),a.render()});var d=null;c.find("div.list").on("click",".list-item",function(a){if($(a.target).hasClass("list-item")){if(a.shiftKey){if(d){var b=$(this).index(),e=d.index();e>b?$(this).nextUntil(d).add(this).add(d).addClass("selected"):b>e?$(this).prevUntil(d).add(this).add(d).addClass("selected"):$(this).toggleClass("selected")}}else a.ctrlKey||a.metaKey?$(this).toggleClass("selected"):(c.find(".list-item").not($(this)).removeClass("selected"),$(this).toggleClass("selected"));d=a.shiftKey||a.ctrlKey||a.metaKey||$(this).hasClass("selected")?$(this):null}}),c.find(".remove-selected-button").on("click",function(b){var d=c.find("div.list").data("list");confirm(d.message.removeMulti)&&(c.find(".selected").each(function(){a.remove($(this).data("id"),!0)}),a.render())}),c.find("div.list").on("click",".remove-button",function(b){var c=$(this).closest("div.list").data("list");b.preventDefault(),confirm(c.message.remove)&&a.remove($(this).parent().data("id"))}),c.find("div.list").on("blur","input",function(){a.doneSort()}),"ImageList"===this.type&&($("#selectImageModal-"+b).on("click",".folder",function(a){a.preventDefault(),$("#selectImageModal-"+b+" .modal-content").load($(this).data("action"))}),$("#selectImageModal-"+b).on("click",".file",function(b){b.preventDefault();var c=$(this).data("action");a.add(c,c)}))}}),Moments=Backbone.Model.extend({defaults:{timeout:void 0,wait:16e3},initialize:function(){moment.locale(Bolt.conf("locale.long")),$("time.moment").length&&this.update()},update:function(){var a,b=this;$("time.moment").each(function(){$(this).html(moment($(this).attr("datetime")).fromNow())}),clearTimeout(this.get("timeout")),a=setTimeout(function(){b.update()},this.get("wait")),this.set("timeout",a)}});Bolt.validation=function(){function a(a){var b=!0,c=a.value,d=a.getAttribute("type"),e="checkbox"===d||"radio"===d,f=a.getAttribute("required"),g=a.getAttribute("minlength"),h=a.getAttribute("maxlength"),i=a.getAttribute("pattern");return a.disabled?b:(b=b&&(!f||e&&a.checked||!e&&""!==c),b=b&&(e||(!g||c.length>=g)&&(!h||c.length<=h)),b&&i&&(i=new RegExp("^(?:"+i+")$"),b=i.test(c)),b)}function b(a,b){$(a).addClass("error"),b&&$("#cke_"+a.id).addClass("cke_error")}function c(a,b){$(a).removeClass("error"),b&&$("#cke_"+a.id).removeClass("cke_error")}function d(a,b,c){var d;d=Bolt.data("validation.alertbox",{"%NOTICE_ID%":a,"%FIELD_ID%":b.id,"%FIELD_NAME%":$('label[for="'+b.id+'"]').contents().first().text().trim()||b.name,"%MESSAGE%":c||$(b).data("errortext")||Bolt.data("validation.generic_msg")}),$(d).hide().insertAfter(".page-header").slideDown("fast")}function e(a){return""===a||a.match(/^[-+]?[0-9]*[,.]?[0-9]+([eE][-+]?[0-9]+)?$/)?"":Bolt.data("validation.float")}function f(a,b){return b===!0&&""===a?Bolt.data("validation.required"):""}function g(a,b){return""!==a&&Number(a.replace(",","."))<b?Bolt.data("validation.min",{"%MINVAL%":b}):""}function h(a,b){return""!==a&&Number(a.replace(",","."))>b?Bolt.data("validation.max",{"%MAXVAL%":b}):""}function i(a,b){"undefined"!=typeof a.willValidate?a.setCustomValidity(b):a.validity.valid=""===b}function j(j){var k,l,m,n="undefined"!=typeof j.willValidate,o=j.value,p="",q=$(j).data("validate");if(q){for(l in q){switch(m=q[l],l){case"float":p=e(o);break;case"required":p=f(o,m);break;case"min":p=g(o,m);break;case"max":p=h(o,m);break;default:console.log("UNKNOWN VALIDATION"+l+" -> "+m)}if(p)break}i(j,p)}else if(n?("INPUT"===j.nodeName&&j.type!==j.getAttribute("type")&&j.setCustomValidity(a(j)?"":"error"),j.checkValidity()):(j.validity=j.validity||{},j.validity.valid=a(j)),k="TEXTAREA"===j.nodeName&&$(j).hasClass("ckeditor")){var r,s=CKEDITOR.instances[j.id];s&&(r=s._.required===!0&&""===s.getData().trim(),i(j,r?"Required":""))}var t="notice--"+j.id;return $("#"+t).remove(),j.validity.valid?(c(j,k),!0):(b(j,k),d(t,j,p),!1)}return{run:function(a){var b,c,d=a.elements.length,e=!0;for(b=0;d>b;b++)c=a.elements[b],("INPUT"===c.nodeName||"TEXTAREA"===c.nodeName||"SELECT"===c.nodeName)&&("INPUT"===c.nodeName&&(c.value=c.value.trim()),j(c)===!1&&(e=!1));return e}}}(),Object.extend=function(a,b){var c=function(){};b.constructor!==Object&&(c=b.constructor),c.prototype=new a;for(var d in b)"constructor"!==d&&(c.prototype[d]=b[d]);return c};var delay=function(){var a=0;return function(b,c){clearTimeout(a),a=setTimeout(b,c)}}(),active_console,active_interval,BoltExtender=Object.extend(Object,{selector:".extend-bolt-container",messages:{},paths:{},constructor:function(){jQuery(this.selector).on("change",this,this.events.change),jQuery(this.selector).on("click",this,this.events.click),jQuery(document).ajaxStart(function(){active_interval=setInterval(function(){active_console&&active_console.append(".")},1e3)}).ajaxSuccess(function(){clearInterval(active_interval)}).ajaxError(function(){clearInterval(active_interval)}),this.checkInstalled(),this.liveSearch(),this.installReset()},find:function(a){return jQuery(this.selector).find(a)},setMessage:function(a,b){this.messages[a]=b},setPath:function(a,b){this.paths[a]=b},installReset:function(){var a=this;jQuery("#installModal").on("hide.bs.modal",function(b){a.find(".stable-version-container .installed-version-item").html('<tr><td colspan="3"><strong>'+a.messages.noStable+"</strong></td></tr>"),a.find(".dev-version-container .installed-version-item").html('<tr><td colspan="3"><strong>'+a.messages.noTest+"</strong></td></tr>"),a.find(".install-response-container .console").html(a.messages.installing),a.find(".theme-postinstall").hide(),a.find(".theme-generate-response").hide(),a.find(".extension-postinstall").hide(),a.find(".install-response-container").hide(),a.find(".install-version-container").hide(),a.find("#installModal .loader").show()})},updateCheck:function(){var a,b=this;b.find(".update-container").show(),a=b.find(".update-list-items"),active_console=b.find(".update-output"),active_console.html(b.messages.updating),jQuery.get(baseurl+"check",function(c){if(c.updates.length>0||c.installs.length>0){var d,e;for(d in c.installs)e=c.installs[d],a.append(Bolt.data("extend.packages.install_new",{"%PACKAGE%":e.name,"%VERSION%":e.version,"%PRETTYVERSION%":e.prettyversion}));for(d in c.updates)e=c.updates[d],a.append(Bolt.data("extend.packages.install_update",{"%PACKAGE%":e.name,"%VERSION%":e.version,"%PRETTYVERSION%":e.prettyversion}));active_console.hide(),b.find(".update-list").show()}else active_console.html(b.messages.updated)}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)})},updateRun:function(){var a=this;a.find(".update-container").show();var b=a.find(".update-output");active_console=b,active_console.html(a.messages.runningUpdate),jQuery.get(baseurl+"update",function(c){b.html(c),setTimeout(function(){a.find(".update-container").hide()},7e3),a.checkInstalled()}).fail(function(b){active_console.html(a.formatErrorLog(b)),a.extensionFailedInstall(b)})},updatePackage:function(a){var b=this,c=this.find(".update-output").html(b.messages.updating),d=jQuery(a.target).data("package");c.show(),active_console=c,jQuery.get(baseurl+"update?package="+d).success(function(a){b.find(".update-output").html(a),b.find('.update-list-items tr[data-package="'+d+'"]').remove(),delay(function(){active_console.hide()},4e3),b.find(".update-list-items tbody tr").length<1&&b.find(".update-container").hide(),b.checkInstalled()}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.preventDefault()},installRun:function(a){var b=this;b.find(".update-container").show();var c=b.find(".update-output");active_console=c,active_console.html(b.messages.installAll),jQuery.get(baseurl+"installAll",function(a){c.html(a),delay(function(){b.find(".update-container").hide()},7e3),b.checkInstalled()}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.stopPropagation(),a.preventDefault()},checkInstalled:function(){var a=this;a.find(".installed-container").each(function(){active_console=a.find(".installed-container .console");var b=jQuery(this).find(".installed-list");jQuery.get(baseurl+"installed",function(c){if("object"!=typeof c)return void active_console.html(a.messages.badJson);b.show();var d="";b.find(".installed-list-items").html(""),a.find(".installed-container .console").hide();var e=!0;c.installed.length>0&&(d+=a.renderPackage(c.installed,!0),e=!1),c.pending.length>0&&(d+=a.renderPackage(c.pending,!0),e=!1),c.local.length>0&&(d+=a.renderPackage(c.local,!1),e=!1),e&&(d=Bolt.data("extend.packages.empty"),active_console.hide()),b.find(".installed-list-items").append(d)}).fail(function(b){active_console.html(a.formatErrorLog(b)),a.extensionFailedInstall(b)})})},renderPackage:function(a,b){var c="";for(var d in a){var e=a[d],f=Bolt.data("extend.packages"),g="",h="",i=0;if(e.authors&&e.authors.length>0){var j=e.authors;for(i=0;i<j.length;i++)g+=f.author.subst({"%AUTHOR%":j[i].name})}if(e.keywords&&e.keywords.length>0){var k=e.keywords;for(i=0;i<k.length;i++)h+=f.keyword.subst({"%KEYWORD%":k[i]})}var l="",m="";b&&(l=f.avail_button.subst({"%NAME%":e.name}),m=f.uninstall_button.subst({"%BASEURL%":baseurl,"%NAME%":e.name})),c+=f.item.subst({"%TITLE%":e.title?e.title:e.name,"%NAME%":e.name,"%VERSION%":e.version,"%AUTHORS%":g,"%TYPE%":e.type,"%AVAILABLE%":l,"%README%":e.readme?f.readme_button.subst({"%README%":e.readme}):"","%CONFIG%":e.config?f.config_button.subst({"%CONFIG%":e.config}):"","%THEME%":"bolt-theme"==e.type?f.theme_button.subst({"%NAME%":e.name}):"","%BASEURL%":baseurl,"%UNINSTALL%":m,"%DESCRIPTION%":e.descrip?e.descrip:"&lt;No description provided&gt;","%KEYWORDS%":h})}return c},checkPackage:function(a){var b=this,c=this.find('input[name="check-package"]').val(),d=this.find('input[name="check-package"]').data("packagename");d&&(c=d),b.installInfo(c),a.preventDefault()},installInfo:function(a){var b=this,c=b.find(".update-output");active_console=c,jQuery.get(baseurl+"installInfo?package="+a,function(a){var c=a.dev,d=a.stable;c.length>0&&(b.find(".dev-version-container .installed-version-item").html(""),b.find(".dev-version-container .installed-version-item").append(b.buildVersionTable(c))),d.length>0&&(b.find(".stable-version-container .installed-version-item").html(""),b.find(".stable-version-container .installed-version-item").append(b.buildVersionTable(d))),b.find(".install-version-container").show(),b.find("#installModal .loader").hide()}).fail(function(a){var c=b.find(".modal-failed");c.html(b.formatErrorLog(a)),b.find("#installModal .loader").hide(),b.extensionFailedInstall(a)})},buildVersionTable:function(a){var b,c,d="";for(var e in a)b=a[e],c="approved"===b.buildStatus?" label-success":"",d+=Bolt.data("extend.packages.versions",{"%NAME%":b.name,"%VERSION%":b.version,"%CLASS%%":c,"%BUILDSTATUS%":b.buildStatus});return d},install:function(a){var b=this,c=jQuery(a.target).data("package"),d=jQuery(a.target).data("version");b.find(".install-response-container").show(),b.find(".install-version-container").hide(),active_console=b.find(".install-response-container .console"),active_console.html(b.messages.installing),b.find("#installModal .loader .message").html(b.messages.installing),jQuery.get(baseurl+"install",{"package":c,version:d}).done(function(a){active_console.html(a),b.postInstall(c,d),b.find(".check-package").show(),b.find('input[name="check-package"]').val(""),b.checkInstalled()}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.preventDefault()},postInstall:function(a,b){var c=this;jQuery.get(baseurl+"packageInfo",{"package":a,version:b}).done(function(a){"bolt-extension"===a[0].type&&c.extensionPostInstall(a[0]),"bolt-theme"===a[0].type&&c.themePostInstall(a[0])}).fail(function(a){active_console.html(c.formatErrorLog(a)),c.extensionFailedInstall(a)})},extensionPostInstall:function(a){var b=this;b.find(".extension-postinstall .ext-link").attr("href",a.source),b.find(".extension-postinstall").show(),b.find(".extension-postinstall .modal-success").show(),b.find(".extension-postinstall [data-readme]").attr("data-readme",a.readme)},extensionFailedInstall:function(a){var b=this;b.find(".extension-postinstall .ext-link").attr("href",a.source),b.find(".extension-postinstall").show(),b.find(".extension-postinstall .modal-failed").show()},themePostInstall:function(a){var b=this;b.find(".install-response-container").hide(),b.find(".theme-postinstall").show(),b.find(".theme-generation-container").show();var c=a.name.split(/\/+/).pop();b.find(".theme-postinstall .theme-generator").data("theme",a.name),b.find(".theme-postinstall #theme-name").val(c),b.find(".theme-postinstall [data-readme]").attr("data-readme",a.readme)},generateTheme:function(a){var b=this,c=jQuery(a.target),d=c.data("theme"),e=b.find("#theme-name").val();jQuery.get(baseurl+"generateTheme",{theme:d,name:e}).done(function(a){b.find(".theme-generate-response").html("<p>"+a+"</p>").show(),b.find(".theme-generation-container").hide()}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.preventDefault()},copyTheme:function(a){var b=this,c=jQuery(a.target),d=c.data("theme"),e=b.find("#theme-name").val();if(confirm(b.messages.overwrite)){var f=b.find(".installed-container .console").html(b.messages.copying);f.show(),active_console=f,jQuery.get(baseurl+"generateTheme",{theme:d,name:e}).done(function(a){active_console.html(a),delay(function(){f.hide()},5e3)}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)})}a.preventDefault()},packageReadme:function(a){var b=this;jQuery.get(jQuery(a.target).data("readme")).done(function(a){bootbox.dialog({message:a?a:"Readme is empty."})}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.preventDefault()},packageAvailable:function(a){var b=this;jQuery.get(baseurl+"installInfo?package="+jQuery(a.target).data("available")).done(function(c){b.installInfo(jQuery(a.target).data("available")),a.preventDefault()}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),a.preventDefault()},uninstall:function(a){var b=this,c=this.find(".installed-container .console").html(b.messages.removing);return confirm(b.messages.confirmRemove)===!1?(a.stopPropagation(),a.preventDefault(),!1):(c.show(),active_console=c,jQuery.get(jQuery(a.target).attr("href")).done(function(a){b.find(".installed-container .console").html(a),b.checkInstalled(),delay(function(){active_console.hide()},2e3)}).fail(function(a){active_console.html(b.formatErrorLog(a)),b.extensionFailedInstall(a)}),void a.preventDefault())},liveSearch:function(){var a=this.find('input[name="check-package"]');a.on("keyup",function(b){var c=jQuery(this).val();c.length<3||delay(function(){jQuery.ajax({url:site+"list.json",dataType:"jsonp",data:{name:c}}).success(function(b){if(!(b.packages.length<1)){var c=a.parent().find(".auto-search");c.html("").show();for(var d in b.packages){var e=b.packages[d],f='data-request="prefill-package" data-packagename="'+e.name+'"';c.append('<a class="btn btn-block btn-default prefill-package" '+f+'style="text-align: left;">'+e.title+" <small "+f+">("+e.authors+" - "+e.name+")</small></a>")}a.on("blur",function(){c.fadeOut()})}})},500)})},prefill:function(a){var b=jQuery(a.target);this.find('input[name="check-package"]').val(b.closest("a").text()),this.find('input[name="check-package"]').data("packagename",b.data("packagename")),this.find(".auto-search").hide()},formatErrorLog:function(a){var b=$.parseJSON(a.responseText),c="",d="";if("Bolt\\Exception\\PackageManagerException"===b.error.type)d=b.error.message.replace(/(<http)/g,'<a href="http').replace(/(\w+>)/g,'">this link</a>'),c=Bolt.data("extend.packages.error",{"%ERROR_TYPE%":"Composer Error","%ERROR_MESSAGE%":d,"%ERROR_LOCATION%":""});else if("Bolt\\Exception\\ExtensionsInfoServiceException"===b.error.type)d=b.error.message,c=Bolt.data("extend.packages.error",{"%ERROR_TYPE%":"Extension Site Error","%ERROR_MESSAGE%":d,"%ERROR_LOCATION%":""});else{var e=b.error.file.replace(new RegExp(rootpath,"g"),"");c=Bolt.data("extend.packages.error",{"%ERROR_TYPE%":"PHP Error","%ERROR_MESSAGE%":b.error.message,"%ERROR_LOCATION%":"File: "+e+"::"+b.error.line})}return c},events:{change:function(a,b){a.data},click:function(a,b){var c=a.data,d=jQuery(a.target).data("request");switch(d){case"update-check":c.updateCheck();break;case"update-run":c.updateRun();break;case"update-package":c.updatePackage(a.originalEvent);break;case"check-package":c.checkPackage(a.originalEvent);break;case"uninstall-package":c.uninstall(a.originalEvent);break;case"install-package":c.install(a.originalEvent);break;case"prefill-package":c.prefill(a.originalEvent);break;case"install-run":c.installRun(a.originalEvent);break;case"generate-theme":c.generateTheme(a.originalEvent);break;case"package-available":c.packageAvailable(a.originalEvent);break;case"package-config":c.packageConfig(a.originalEvent);break;case"package-copy":c.copyTheme(a.originalEvent);break;case"package-readme":c.packageReadme(a.originalEvent)}}}}),init={depublishTracking:function(){var a="dateDepublishNotice",b=$("#datedepublish").data("notice");$("#datedepublish, #statusselect").on("change",function(c){var d=$("#statusselect").val(),e=$("#datedepublish").val();$("."+a).remove(),""!==e&&"published"===d&&moment(e+Bolt.conf("timezone.offset"))<moment()&&$('<div class="'+a+' alert alert-warning"><button class="close" data-dismiss="alert">×</button>'+b+"</div>").hide().insertAfter(".depublish-group").slideDown("fast")}),$("#datedepublish").trigger("change")},bindEditFile:function(a){if($("#saveeditfile").bind("click",function(a){$(Bolt).trigger("start.bolt.file.save"),"undefined"!=typeof CodeMirror&&$("#form_contents").val(b.getValue());var c="Not saved";$("#saveeditfile").addClass("disabled"),$("#saveeditfile i").addClass("fa-spin fa-spinner"),$("p.lastsaved").text(Bolt.data("editcontent.msg.saving")),$.post("?returnto=ajax",$("#editfile").serialize()).done(function(a){a.ok?$(Bolt).trigger("done.bolt.file.save",a):(alert(a.msg),$(Bolt).trigger("fail.bolt.file.save",a)),$("p.lastsaved").html(a.msg)}).fail(function(){$(Bolt).trigger("fail.bolt.file.save"),alert(c)}).always(function(){$(Bolt).trigger("always.bolt.file.save"),window.setTimeout(function(){$("#saveeditfile").removeClass("disabled").blur(),$("#saveeditfile i").removeClass("fa-spin fa-spinner")},300)})}),"undefined"!=typeof CodeMirror){var b=CodeMirror.fromTextArea(document.getElementById("form_contents"),{lineNumbers:!0,autofocus:!0,tabSize:4,indentUnit:4,indentWithTabs:!1,readOnly:a.readonly}),c=$(window).height()-312;200>c&&(c=200),b.setSize(null,c)}},bindEditLocale:function(a){var b=CodeMirror.fromTextArea(document.getElementById("form_contents"),{lineNumbers:!0,autofocus:!0,tabSize:4,indentUnit:4,indentWithTabs:!1,readOnly:a.readonly});b.setSize(null,$(window).height()-276)},bindFileBrowser:function(){$("#myTab a").click(function(a){a.preventDefault(),$(this).tab("show")});var a=function(a){var b=new RegExp("(?:[?&]|&)"+a+"=([^&]+)","i"),c=window.location.search.match(b);return c&&c.length>1?c[1]:null},b=a("CKEditorFuncNum");$("a.filebrowserCallbackLink").bind("click",function(a){a.preventDefault();var c=$(this).attr("href");window.opener.CKEDITOR.tools.callFunction(b,c),window.close()}),$("a.filebrowserCloseLink").bind("click",function(){window.close()})},bindCkFileSelect:function(a){var b=function(a){var b=new RegExp("(?:[?&]|&)"+a+"=([^&]+)","i"),c=window.location.search.match(b);return c&&c.length>1?c[1]:null},c=b("CKEditorFuncNum");$("a.filebrowserCallbackLink").bind("click",function(a){a.preventDefault();var b=$(this).attr("href");window.opener.CKEDITOR.tools.callFunction(c,b),window.close()})},bindPrefill:function(){$("#check-all").on("click",function(){$("#form_contenttypes :checkbox").removeAttr("checked").trigger("click")}),$("#uncheck-all").on("click",function(){$("#form_contenttypes :checkbox").removeAttr("checked")})},confirmationDialogs:function(){$(".confirm").on("click",function(){return confirm($(this).data("confirm"))})},dashboardCheckboxes:function(){$(".dashboardlisting tr th:first-child input:checkbox").click(function(){var a=this.checked;$(this).closest("tbody").find("td input:checkbox").each(function(){this.checked=a,a===this.checked&&$(this).closest("table tbody tr").removeClass("row-checked"),this.checked&&$(this).closest("table tbody tr").addClass("row-checked")})}),$(".dashboardlisting input:checkbox").click(function(){var a=getSelectedItems();a.length>=1?($("a.checkchosen").removeClass("disabled"),$("a.showifchosen").show()):($("a.checkchosen").addClass("disabled"),$("a.showifchosen").hide())}),$("a.deletechosen").click(function(a){a.preventDefault();var b,c=getSelectedItems();c.length>0&&(b=1===c.length?Bolt.data("recordlisting.delete_one"):Bolt.data("recordlisting.delete_mult"),bootbox.confirm(b,function(a){$(".alert").alert(),a===!0&&$.ajax({url:Bolt.conf("paths.bolt")+"content/deletecontent/"+$("#item_"+c[0]).closest("table").data("contenttype")+"/"+c.join(",")+"?bolt_csrf_token="+$("#item_"+c[0]).closest("table").data("bolt_csrf_token"),type:"get",success:function(a){var b=[];$.each(c,function(a,c){b.push(document.getElementById("item_"+c))}),$(b).hide(),$("a.deletechosen").hide()}})}))})},deferredWidgets:function(){$("div.widget").each(function(){if("undefined"!=typeof $(this).data("defer")){var a=$(this).data("key");$.ajax({url:Bolt.conf("paths.async")+"widget/"+a,type:"GET",success:function(b){$("#widget-"+a).html(b)},error:function(){console.log("failed to get widget")}})}})},dropDowns:function(){$('[data-toggle="dropdown"]').each(function(a,b){var c;"undefined"==typeof event?$(b).parent().click(function(a){c=a}):c=event,$(b).parent().on("show.bs.dropdown",function(a){if("undefined"!=typeof c&&null!==c){var b=$(this).find('[data-toggle="dropdown"]'),d=b.next(".dropdown-menu"),e=c.pageY+20,f=d.height(),g=$(window).height()-e+f,h=37;e-f>20&&h>g&&d.css({top:"auto",bottom:"100%"})}})})},dropZone:function(){$(document).bind("dragover",function(a){var b=$(".dropzone"),c=window.dropZoneTimeout;c?clearTimeout(c):b.addClass("in"),a.target===b[0]?b.addClass("hover"):b.removeClass("hover"),window.dropZoneTimeout=setTimeout(function(){window.dropZoneTimeout=null,b.removeClass("in hover")},100)})},magnificPopup:function(){$(".magnific, .fancybox").magnificPopup({type:"image",gallery:{enabled:!0},disableOn:400,closeBtnInside:!0,enableEscapeKey:!0,mainClass:"mfp-with-zoom",zoom:{enabled:!0,duration:300,easing:"ease-in-out",opener:function(a){return a.parent().parent().find("img")}}})},focusStatusSelect:function(){$("#lastsavedstatus").click(function(a){a.preventDefault(),$('a[href="#tab-meta"]').click(),$("#statusselect").focus()})},omnisearch:function(){$(".omnisearch").select2({placeholder:"",minimumInputLength:3,multiple:!0,ajax:{url:Bolt.conf("paths.async")+"omnisearch",dataType:"json",data:function(a,b){return{q:a}},results:function(a,b){var c=[];return $.each(a,function(a,b){c.push({id:b.path,path:b.path,label:b.label,priority:b.priority})}),{results:c}}},formatResult:function(a){var b='<table class="omnisearch-result"><tr><td class="omnisearch-result-info"><div class="omnisearch-result-label">'+a.label+'</div><div class="omnisearch-result-description">'+a.path+"</div></td></tr></table>";return b},formatSelection:function(a){return window.location.href=a.path,a.label},dropdownCssClass:"bigdrop",escapeMarkup:function(a){return a}})},passwordInput:function(){$(".togglepass").on("click",function(){$(this).hasClass("show-password")?($('input[name="password"]').attr("type","text"),$(".togglepass.show-password").hide(),$(".togglepass.hide-password").show()):($('input[name="password"]').attr("type","password"),$(".togglepass.show-password").show(),$(".togglepass.hide-password").hide())}),$(".login-forgot").bind("click",function(a){$(".login-group, .password-group").hide(),$(".reset-group").show()}),$(".login-remembered").bind("click",function(a){$(".login-group, .password-group").show(),$(".reset-group").hide()})},popOvers:function(){$(".info-pop").popover({trigger:"hover",delay:{show:500,hide:200}})},uploads:function(){$("input[data-upload]").each(function(a){var b,c=$(this).data("upload"),d=$(this).attr("accept").replace(/\./g,"");switch(c.type){case"Image":case"File":bindFileUpload(c.key),b={source:Bolt.conf("paths.async")+"filesautocomplete?ext="+encodeURIComponent(d),minLength:2},"Image"===c.type&&(b.close=function(){var a,b=$("#field-"+c.key).val();a=b?Bolt.conf("paths.root")+"thumbs/"+c.width+"x"+c.height+"c/"+encodeURI(b):Bolt.conf("paths.app")+"view/img/default_empty_4x3.png",$("#thumbnail-"+c.key).html('<img src="'+a+'" width="'+c.width+'" height="'+c.height+'">')}),$("#field-"+c.key).autocomplete(b);break;case"ImageList":Bolt.imagelist[c.key]=new FilelistHolder({id:c.key,type:c.type});break;case"FileList":Bolt.filelist[c.key]=new FilelistHolder({id:c.key,type:c.type})}})},sortables:function(){$("tbody.sortable").sortable({items:"tr",opacity:"0.5",axis:"y",handle:".sorthandle",update:function(a,b){var c=$(this).sortable("serialize");$.ajax({url:$("#baseurl").attr("value")+"content/sortcontent/"+$(this).parent("table").data("contenttype"),type:"POST",data:c,success:function(a){}})}})}};