profile.min.js 16 KB
/* jce - 2.8.5 | 2020-01-29 | https://www.joomlacontenteditor.net | Copyright (C) 2006 - 2020 Ryan Demmer. All rights reserved | GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html */
!function($,window){function ucfirst(str){return str.charAt(0).toUpperCase()+str.substring(1)}function init(){var skip=!0,base_url="";$('script[src*="components/com_jce/media/js/profile.min.js"]').each(function(){var url=this.src;base_url=url.substring(0,url.indexOf("administrator"))}),$("#jform_components_select input").change(function(){this.checked&&$("#jform_components").prop("disabled",0==$(this).val()).trigger("liszt:updated").trigger("chosen:updated")}).change(),$("#profile-features :input[name], #profile-editor :input[name], #profile-plugins :input[name]").change(function(){if(!skip&&this.name.indexOf("jform")!==-1){var name=this.name.replace('!"#$%&()*+,./:;<=>?@[]^`{|}~',"\\$1","g");$(this).add('[name="'+name+'"]').addClass("isdirty")}}).on("liszt:updated",function(){$(this).addClass("isdirty")}),createLayout();var startSize;$(".mce-resizehandle").dragHelper().on("drag:start",function(e){startSize={width:$(".editor-layout .mce-tinymce").width(),height:$(".mce-edit-area").height()}}).on("drag:drag",function(o,e){var width=startSize.width+e.deltaX,height=startSize.height+e.deltaY;null!==width&&(width=Math.max(100,width),width=Math.min(65535,width),$(".editor-layout .mce-tinymce, .widthMarker").width(width),$("#jform_config_editor_width").val(width),$(".widthMarker span").html(width+"px")),null!==height&&(height=Math.max(100,height),height=Math.min(65535,height),$(".editor-layout .mce-edit-area").height(height),$("#jform_config_editor_height").val(height))}),$("#jform_config_editor_width").change(function(){var v=$(this).val()||"100%",s=v+"px";/%/.test(v)?(s=v,v=100):(v=parseInt(v),s=v+"px"),$(".widthMarker span").html(s),$(".widthMarker, .mce-tinymce").width(s)}),$("#jform_config_editor_width").change(function(){var v=$(this).val()||"auto";/%/.test(v)?v="auto":"number"===$.type(v)&&(v=parseInt(v))}),$("#jform_config_editor_toolbar_theme").change(function(){var value=this.value;if(value=value.indexOf(".")!==-1?value.replace(/([^\.]+)\.([\w]+)/,function(match,skin,variant){return skin="mce"+ucfirst(skin),skin+"Skin "+skin+"Skin"+ucfirst(variant)}):"mce"+ucfirst(value)+"Skin",$(".editor-layout .mceEditor, .editor-button-pool .mceEditor").attr("class",function(i,value){return $.trim(value.replace(/mce([a-z0-9]+)Skin([a-z0-9]*)/gi,""))}).addClass("mceDefaultSkin "+value),$("#mce-theme").remove(),"default"!==this.value){var stylesheet=this.value.replace(/\.\w+/,"");$('<link href="'+base_url+"components/com_jce/editor/tiny_mce/themes/advanced/skins/"+stylesheet+'/ui.admin.css" rel="stylesheet" id="mce-theme" />').appendTo("head")}}).change(),$("#jform_config_editor_path :input[name]:checked").change(function(){$(".editor-layout .mce-tinymce .mce-statusbar .mce-path").toggle(1==$(this).val())}).change(),$(".editor-features input:checkbox").click(function(){setPlugins()}),$("#paramseditorresizing").change(function(){var v=$(this).val();$(".editor-layout .mce-tinymce .mce-statusbar .mce-resizehandle").toggle(1==v)}).change(),$("#jform_config_editor_toggle").change(function(){var v=$(this).val();$("#editor_toggle").toggle(1===v)}).change(),$("#jform_config_editor_toggle_label").on("change keyup",function(){this.value&&$("#editor_toggle").text(this.value)}),$('input[type="number"]').change(function(){this.value<1&&(this.value="")}),skip=!1,$(".nav-tabs li",".tab-content").on("click",function(e){e.preventDefault();var idx=$(this).index(),$container=$(this).parent().parent(".tabbable");$(this).parent().children(".active").removeClass("active show"),$(this).addClass("active show"),$(".tab-content .tab-pane",$container).removeClass("active show").eq(idx).addClass("active show")}),$(".ui-jce").removeClass("loading")}function onSubmit(){$("#profile-features :input[name], #profile-editor :input[name], #profile-plugins :input[name]").not(".isdirty").prop("disabled",!0)}function fixLayout(){$(".editor-layout .mce-btn-group").filter(function(){return 0===$(this).children("div").length}).remove().addBack(":last-child").after('<div class="mce-container mce-flow-layout-item mce-btn-group" />');var options=$(".mce-btn-group").sortable("option");$(".editor-layout .mce-btn-group.ui-sortable").sortable("destroy"),$(".editor-layout .mce-btn-group").sortable(options)}function createLayout(){$(".sortableList").sortable({connectWith:".sortableList",axis:"y",update:function(event,ui){setRows(),setPlugins()},start:function(event,ui){$(ui.placeholder).width($(ui.item).width()).height($(ui.item).height())},placeholder:"sortable-row-highlight",opacity:.8}),$(".mce-btn-group:last-child").after('<div class="mce-container mce-flow-layout-item mce-btn-group" />'),$(".sortableListItem").sortable({items:".mce-btn",connectWith:".sortableListItem",placeholder:"sortable-btn-highlight mce-widget mce-btn",cancel:"",update:function(event,ui){setRows(),setPlugins(),fixLayout()},start:function(event,ui){$(ui.item).parents(".mce-toolbar-grp").addClass("ui-sortable-sorting"),$(ui.placeholder).width($(ui.item).width()).height($(ui.item).height()),$(".mce-btn-group:empty").addClass("visible")},stop:function(event,ui){$(ui.item).parents(".mce-toolbar-grp").removeClass("ui-sortable-sorting")},opacity:.8})}function setRows(){var rows=$.map($(".editor-layout .mce-toolbar").has(".mce-btn"),function(toolbar){return $.map($(".mce-btn",toolbar),function(button){return $(button).data("name")}).join(",")}),v=rows.join(";");$('input[name="jform\\[rows\\]"]').val(v).change()}function setPlugins(){var plugins=[];$(".ui-sortable > .mce-btn",".editor-layout").each(function(){plugins.push($(this).data("name"))}),$(".editor-features input:checkbox:checked").each(function(){plugins.push($(this).val())}),$('input[name="jform\\[plugins\\]"]').val(plugins.join(",")).change(),setParams(plugins)}function setParams(plugins){var $tabs=$("#profile-plugins-tabs > .nav-item");$tabs.removeClass("hide active").each(function(i){var name=$(this).children("[href]").attr("href").replace("#profile-plugins-",""),s=$.inArray(name,plugins)!=-1;$("input[name], select[name]","#profile-plugins-"+name).prop("disabled",!s),s||$(this).addClass("hide")}),$tabs.not(".hide").first().addClass("active")}Joomla.submitbutton=function(task){var form=document.getElementById("adminForm");if("profile.cancel"!=task){if(document.formvalidator.isValid(form)){onSubmit();try{Joomla.submitform(task,form)}catch(e){}}}else try{Joomla.submitform(task,form)}catch(e){}},$.fn.dragHelper=function(options){var downButton,overlay,start,stop,drag,startX,startY;options=options||{};var element=this;return start=function(e){var dw=$(document).width(),dh=$(document).height();e.preventDefault(),downButton=e.button,startX=e.screenX,startY=e.screenY,overlay=$("<div />").css({position:"absolute",top:0,left:0,width:dw,height:dh,zIndex:2147483647,opacity:1e-4}).appendTo("body"),$(document).on("mousemove.drag",function(e){drag(e)}),$(document).on("mouseup.drag",function(e){stop(e)}),$(element).trigger("drag:start",e)},drag=function(e){return e.button!==downButton?stop(e):(e.deltaX=e.screenX-startX,e.deltaY=e.screenY-startY,e.preventDefault(),void $(element).trigger("drag:drag",e))},stop=function(e){$(document).off("mousemove.drag mouseup.drag"),$(overlay).remove(),$(element).trigger("drag:stop",e)},this.destroy=function(){$(element).off()},$(element).on("mousedown.drag",function(e){start(e)}),this},$(document).ready(function(){$("select[data-toggle]").on("change",function(){var key=$(this).attr("data-toggle"),value=$(this).val();$parent=$(this).parents(".control-group").siblings(".filesystem-options"),$('[data-toggle-target^="'+key+'"]',$parent).hide().find(":input").prop("disabled",!0),$item=$('[data-toggle-target="'+key+"-"+value+'"]',$parent),$item.show().find(":input").prop("disabled",!1),$.fn.chosen&&$item.find("select").chosen("destroy").chosen()}),$("select[data-toggle]").trigger("change")}),$(window).on("load",function(){$(".com_jce_select_custom").each(function(){function tagHandler(event,element){var highlighted=$(selector).find("li.active-result.highlighted").first();if(13===event.which&&""!==highlighted.text()){var customOptionValue=highlighted.text();$(selector).find("option").filter(function(){return $(element).val()==customOptionValue}).remove();var customOption=$(selector).find("option").filter(function(){return $(element).html()==highlighted.text()}).attr("selected","selected")}else{var customOption=$(elm).find("option").filter(function(){return $(element).html()==customOption});if(""!==customOption.text())customOption.attr("selected","selected");else{var option=$("<option>");option.text(element.value).val(element.value),option.attr("selected","selected"),$(elm).append(option)}}element.value="",$(elm).trigger("liszt:updated")}var elm=this,id=$(this).attr("id"),selector="#"+id+"_chzn";$(selector).find("input").on("keypress",function(event){44===event.charCode&&(this.value&&this.value.length>=3&&tagHandler(event,this),event.preventDefault())}),$(selector).find("input").on("keyup",function(event){13===event.which&&(this.value&&this.value.length>=3&&tagHandler(event,this),event.preventDefault())})})}),$(document).ready(function(){window.setTimeout(function(){init()},100)})}(jQuery,window),function($){window.WfSelectUsers=function(){var name=$("#jform_users").val(),id=$("#jform_users_id").val();$("#jform_users").val(""),$("#jform_users_id").val("");var opt=new Option(name,id),value=$("#jform_users_select").val();"array"!==$.type(value)&&(value=[value]),value.push(id),0===$("#jform_users_select").find('option[value="'+id+'"]').length&&$("#jform_users_select").append(opt),$("#jform_users_select").val(value).trigger("chosen:updated").trigger("liszt:updated.chosen")}}(jQuery),function($){$(document).ready(function(){$(".filetype").each(function(){function serialize(){var list=[];$(self).parent().find(".filetype-list").each(function(){var v1=$(this).find('.filetype-item input[type="checkbox"]').map(function(){return this.checked?this.value:"-"+this.value}).get(),v2=$(this).find(".filetype-custom input").map(function(){if(""!==this.value)return this.value}).get(),group="";$(this).find('.filetype-group input[type="checkbox"]').map(function(){group=$(this).parents(".filetype-group").data("filetype-group"),this.checked||(group="-"+group)});var items=$.merge(v1,v2).join(",");group?list.push(group+"="+items):list.push(items)});var v=list.join(";");$input.val(v).addClass("isdirty"),$(self).val(v)}var self=this,$input=($(self).parent(),$('input[type="hidden"]',this));$('input[type="checkbox"]',this).on("click",function(){serialize()}),$(".filetype-edit",this).on("click",function(e){e.preventDefault(),$(".filetype-list",self).slideToggle()}),$(this).on("change",".filetype-custom input",function(e){e.preventDefault(),$(this).siblings(".file").attr("class","").addClass("file").addClass(this.value),serialize()}),$(this).on("click",".filetype-custom .filetype-clear",function(e){e.preventDefault(),$(this).siblings("input").val("")}),$(".filetype-add",this).on("click",function(e){e.preventDefault();var $p=$(this).parents(".filetype-item"),clone=$p.clone();$(clone).find("input").val(""),$(clone).insertAfter($p)}),$(this).on("click",".filetype-remove",function(e){e.preventDefault(),$(this).parents(".filetype-item").remove(),serialize()}),$(".filetype-group",this).length&&$(".filetype-list",this).sortable({axis:"y",items:"> .filetype-item",connectWith:".filetype .filetype-list",update:function(event,ui){serialize()}})})})}(jQuery),function($){function camelCase(str){return str.replace(/^-ms-/,"ms-").replace(/-([\da-z])/gi,function(all,letter){return letter.toUpperCase()})}function updateStyles(n,string){$.each(string.split(";"),function(i,s){var kv=$.trim(s).split(":");if(kv.length>1){var k=$.trim(kv[0]),v=$.trim(kv[1]);$.inArray(camelCase(k),previewStyles)!==-1&&$(n).css(k,v)}})}var previewStyles=["fontFamily","fontSize","fontWeight","textDecoration","textTransform","color","backgroundColor"];$(document).ready(function(){var init=!0;$(".styleformat-item-trash",".styleformat-list").on("click",function(e){e.preventDefault(),1===$("div.styleformat-list div.styleformat").length?($("input, select",this.parentNode).val("").removeAttr("style").removeAttr("class"),$(this).parents(".styleformat").hide()):$(this).parents(".styleformat").remove(),$(".styleformat-list").trigger("update"),e.preventDefault()}),$(".styleformat-item-plus",".styleformat-list").on("click",function(e){e.preventDefault();var $item=$(this).prev();$.fn.chosen&&$("select",$item).chosen("destroy"),$item.clone(!0).insertBefore(this).show(),$("div",$item).removeClass("hide"),$("a.close.collapse",$item).removeClass("icon-chevron-down").addClass("icon-chevron-up"),$("input, select",$item).val("").removeAttr("style").removeAttr("class").first().focus(),e.preventDefault()}),$(".styleformat-list").sortable({axis:"y",update:function(event,ui){$("div.styleformat-list").trigger("update")},handle:".styleformat-item-handle",items:".styleformat",placeholder:"styleformat-highlight",start:function(event,ui){$(ui.placeholder).height($(ui.item).height())}}).on("update",function(){var list=[],v="";$(".styleformat",this).each(function(){var data={},p=this,x=0;$(".styleformat-item-title input",p).val()&&$('input[type="text"], select',p).each(function(){var k=$(this).data("key"),v=$(this).val();""!==v&&("element"!==k&&"classes"!==k&&"styles"!==k&&"attributes"!==k||x++,data[k]=v)}),x>0&&!$.isEmptyObject(data)&&list.push(data)}),list.length&&(v=JSON.stringify(list)),init||$('input[type="hidden"]',this).first().val(v).trigger("change")}),$(".styleformat").each(function(){$('input[type="text"], select',this).on("change",function(){$("div.styleformat-list").trigger("update");var title=$("div.styleformat-item-title input",$(this).parents("div.styleformat")),v=$(this).val();"element"===$(this).data("key")&&($(title).attr("class",""),/^(h[1-6]|em|strong|code|sub|sup)$/.test(v)&&$(title).addClass(v)),"styles"===$(this).data("key")&&($(title).attr("style",""),updateStyles(title,v))}).trigger("change"),$(".collapse",this).on("click.collapse",function(e){e.preventDefault(),$(this).parents(".styleformat").toggleClass("styleformat-collapse")})}),$(".styleformat",".styleformat-list").length>1&&$(".styleformat",".styleformat-list").addClass("styleformat-collapse"),init&&$(document).ready(function(){$.fn.chosen&&$(".styleformat select").chosen("destroy")}),init=!1,$('input[type="hidden"]',".styleformat-list").length>1&&$(".styleformat-list").trigger("update")})}(jQuery),function($){$(document).ready(function(){$(".fontlist").each(function(){var el=this;$('input[type="checkbox"]',this).on("click",function(){$(".fontlist").trigger("update")}),$('input[type="text"]',this).on("change",function(){$(".fontlist").trigger("update")}),$(".font-item-trash",this).on("click",function(e){e.preventDefault(),$(this).parents(".font-item").remove(),$(".fontlist").trigger("update")}),$(".font-item-plus",this).on("click",function(e){e.preventDefault(),$(".font-item[hidden]",el).clone(!0).insertBefore(this).removeAttr("hidden").find("input").val("").first().focus()})}).on("update",function(){var data=[],v="";$(".font-item",this).not(".hide").each(function(){var obj={},key=$("input:text",this).first().val(),val=$("input:text",this).last().val();key&&val&&(obj[key]=val);var values=$("input:checkbox:checked",this).val();if(values){var pair=values.split("=");2===pair.length&&(obj[pair[0]]=pair[1])}$.isEmptyObject(obj)||data.push(obj)}),data.length&&(v=JSON.stringify(data)),$('input[type="hidden"]',this).val(v).trigger("change")}).sortable({axis:"y",items:".font-item",update:function(event,ui){$(".fontlist").trigger("update")},placeholder:"font-item-highlight",start:function(event,ui){$(ui.placeholder).height($(ui.item).height()).width($(ui.item).width())}})})}(jQuery),function($){$(document).ready(function(){$(".blockformats").each(function(){var el=this;$('input[type="checkbox"]',this).on("click",function(){$(el).trigger("update")})}).on("update",function(){$(":input[name]",this).trigger("change")}).sortable({axis:"y",update:function(event,ui){$(".blockformats").trigger("update")},placeholder:"blockformat-highlight",start:function(event,ui){$(ui.placeholder).height($(ui.item).height()).width($(ui.item).width())}})})}(jQuery);