cms.registerWidgetHandler("gallery",new function(){InlineWidget.apply(this,arguments);this.getName=function(){return"gallery"};this.getIcon=function(){return"fa-th-large"};this.getToolbarButtons=function(){var a=this;return{options:{icon:"fa-th-large",click:function(c,b){a.openOptionsForm(c,b)}}}};this.getOptionsFormSettings=function(){var a=this;return{onCreate:function(c){var d=$(".f-upload",c);var b=$(".file-button",c);c.on("click",".actions .b-rename",function(g){g.preventDefault();var f=$(this).parents(".item").find("img");cms.showPromptDialog(a.lang("galleryImageEnterTitle"),a.lang("galleryImageTitle"),function(e){f.attr("alt",e)},f.attr("alt"))});c.on("click",".actions .b-delete",function(f){f.preventDefault();$(this).parents(".item").remove()});$("input",d).fileupload({sequentialUploads:true,dataType:"json",add:function(j,g){var f=$(".t-width",c);var i=$(".t-height",c);var h=$(".t-square",c);var k={w:f.val()?f.val():150,h:i.val()?i.val():150,s:h.prop("checked")?1:0};g.url=cms.getModuleUrl("uploader","uploadAndResize",k);g.submit()},submit:function(){$("input",d).hide();$("i",b).removeClass("fa-plus").addClass("fa-spinner fa-spin");$("span",b).text(cms.lang("uploading"));$(b).addClass("disabled").prop("disabled",true)},done:function(g,f){a.addImagesToList($(".images-list",c),f.result.images)},always:function(g,f){$("input",d).show();$("i",b).removeClass("fa-spinner").removeClass("fa-spin").addClass("fa-plus");$("span",b).text($("span",b).data("title"));$(b).removeClass("disabled").prop("disabled",false)}})},onShow:function(c,b){var d=$(".images-list",c);$(".item",d).remove();if(b&&b.images){a.addImagesToList(d,b.images)}}}};this.onCreateWidget=function(a,b){this.openOptionsForm(b,a.id);return a};this.addImagesToList=function(b,a){$.each(a,function(c,e){var d=$(".item-template",b).clone().show().removeClass("item-template").addClass("item");$("img",d).attr("src",e.thumb_url).data("url",e.url).attr("alt",e.title);b.append(d)});b.sortable()};this.applyOptions=function(d,b,c){var e=this.dom(d);e.empty();b.images=[];var a=$("<div/>").addClass("inlinecms-gallery");if(b.open_in=="lightbox"){a.addClass("lightbox")}if(b.style){a.addClass(b.style)}if(b.is_center){a.addClass("centered")}$(".images-list .item",c).each(function(){var g=$(this).find("img");var h=g.data("url");var i=g.attr("src");var l=g.attr("alt");b.images.push({url:h,thumb_url:i,title:l});var j=$("<div/>").addClass("image");var f=$("<a/>").attr("href",h).attr("target","_blank");var k=$("<img/>").attr("src",i);if(b.is_titles){f.attr("title",l);k.attr("alt",l)}f.append(k);j.append(f);a.append(j)});e.append(a);return b}});