1
|
var image_added;!function(d){var i,o,n,r,s,p;d(document).ready(function(){var a=d("#page_image_picker");p=a.data("input-type"),s="wym"==p,d("#custom_images_tab a").click(function(){if(!a.data("size-applied")&&s){var t=d(".page_part:first .wym_box"),e=d(".page_part:first iframe");a.css({height:t.height(),width:t.width()}).data("size-applied",!0).corner("tr 5px").corner("bottom 5px").find(".wym_box").css({backgroundColor:"white",height:e.height()+d(".page_part:first .wym_area_top").height()-parseInt(d(".wym_area_top .label_inline_with_link a").css("lineHeight")),width:e.width()-20,"border-color":e.css("border-top-color"),"border-style":e.css("border-top-style"),"border-width":e.css("border-top-width"),padding:"0px 10px 0px 10px"})}}),d("#page_images li textarea:hidden").each(function(t){var e=d(this).attr("name"),a=d(this);a.attr("data-old-id",a.attr("id")),a.attr("name","ignore_me_"+t),a.attr("id","ignore_me_"+t);var i=d("<input>").addClass("caption").attr("type","hidden").attr("name",e).attr("id",a.attr("data-old-id")).val(a.val());a.parents("li").first().append(i)}),i(),d(".page-images-caption-modal").hide(),r=d("#page_images .js-page-images-template").detach()}),i=function(){s&&WYMeditor.onload_functions.push(function(){d(".wym_box").css({width:null})}),d("#page_images").sortable({tolerance:"pointer",placeholder:"placeholder",cursor:"drag",items:"li",stop:n}),d("#page_images").on("mouseenter mouseleave","li",function(t){var e=d(this),a=e.find(".image_actions");if("mouseenter"==t.type){if(0==a.length){a=d("<div class='image_actions'></div>");var i=d("<img src='/assets/refinery/icons/delete.png' width='16' height='16' />");if(i.appendTo(a),i.click(function(){d(this).parents("li").first().remove(),n()}),0<e.find("textarea.page_caption").length){var r=d("<img src='/assets/refinery/icons/user_comment.png' width='16' height='16' class='caption' />");r.appendTo(a),r.click(o)}else a.addClass("no_captions");a.appendTo(e)}a.show()}else"mouseleave"==t.type&&a.hide()}),n()},image_added=function(t){var e=r.clone(),a=d(t).attr("id").replace("image_","");e.find("input:hidden:first").val(a),d("<img />").attr({title:d(t).attr("title"),alt:d(t).attr("alt"),src:d(t).attr("data-grid")}).appendTo(e),e.attr("id","image_"+a).removeClass("empty"),e.appendTo(d("#page_images")),i()},o=function(){var t=d(this).closest("li"),e=t.find(".page-images-caption-modal > textarea"),a=e.parent(),i={textarea:{width:400,height:"auto"},wym:{width:928,height:530}};a.find(".js-page-images-done").on("click",function(){a.dialog("close")});var r=function(){s&&e.data("wymeditor").update(),d("li.current_caption_list_item").removeClass("current_caption_list_item"),d("#"+e.attr("data-old-id")).val(e.val()),a.dialog("destroy")};t.addClass("current_caption_list_item"),a.dialog({title:"Add Caption",modal:!0,resizable:!1,autoOpen:!0,width:i[p].width,height:i[p].height,close:r}),s?e.addClass("wymeditor active_rotator_wymeditor widest").wymeditor(wymeditor_boot_options):e.show()},n=function(){d("#page_images li textarea:hidden").each(function(t,e){var a=d(e).attr("name").split("_");a[2]=""+t,d(e).attr("name",a.join("_")),d(e).attr("id",d(e).attr("id").replace(/_\d/,"_"+t)),d(e).attr("data-old-id",d(e).attr("data-old-id").replace(/_\d_/,"_"+t+"_").replace(/_\d/,"_"+t))}),d("#page_images li").each(function(a,t){d("input:hidden",t).each(function(){var t=d(this),e=t.attr("name").split("]");e[1]="["+a,t.attr("name",e.join("]")),t.attr("id",t.attr("id").replace(/_\d_/,"_"+a+"_").replace(/_\d/,"_"+a))})})}}(jQuery);
|