mirror of
https://github.com/YunoHost-Apps/webtrees_ynh.git
synced 2024-09-03 18:26:37 +02:00
1 line
No EOL
11 KiB
JavaScript
1 line
No EOL
11 KiB
JavaScript
(function(){CKEDITOR.dialog.add("link",function(o){var e=CKEDITOR.plugins.link,a=function(){var f=this.getDialog(),d=f.getContentElement("target","popupFeatures"),f=f.getContentElement("target","linkTargetName"),c=this.getValue();if(d&&f){switch(d=d.getElement(),d.hide(),f.setValue(""),c){case"frame":f.setLabel(o.lang.link.targetFrameName);f.getElement().show();break;case"popup":d.show();f.setLabel(o.lang.link.targetPopupName);f.getElement().show();break;default:f.setValue(c),f.getElement().hide()}}},q=function(b){b.target&&this.setValue(b.target[this.id]||"")},m=function(b){b.advanced&&this.setValue(b.advanced[this.id]||"")},j=function(b){b.target||(b.target={});b.target[this.id]=this.getValue()||""},i=function(b){b.advanced||(b.advanced={});b.advanced[this.id]=this.getValue()||""},s=o.lang.common,t=o.lang.link,r;return{title:t.title,minWidth:350,minHeight:230,contents:[{id:"info",label:t.info,title:t.info,elements:[{id:"linkType",type:"select",label:t.type,"default":"url",items:[[t.toUrl,"url"],[t.toAnchor,"anchor"],[t.toEmail,"email"]],onChange:function(){var g=this.getDialog(),f=["urlOptions","anchorOptions","emailOptions"],d=this.getValue(),h=g.definition.getContents("upload"),h=h&&h.hidden;"url"==d?(o.config.linkShowTargetTab&&g.showPage("target"),h||g.showPage("upload")):(g.hidePage("target"),h||g.hidePage("upload"));for(h=0;h<f.length;h++){var k=g.getContentElement("info",f[h]);k&&(k=k.getElement().getParent().getParent(),f[h]==d+"Options"?k.show():k.hide())}g.layout()},setup:function(b){this.setValue(b.type||"url")},commit:function(b){b.type=this.getValue()}},{type:"vbox",id:"urlOptions",children:[{type:"hbox",widths:["25%","75%"],children:[{id:"protocol",type:"select",label:s.protocol,"default":"http://",items:[["http://\u200e","http://"],["https://\u200e","https://"],["ftp://\u200e","ftp://"],["news://\u200e","news://"],[t.other,""]],setup:function(b){b.url&&this.setValue(b.url.protocol||"")},commit:function(b){b.url||(b.url={});b.url.protocol=this.getValue()}},{type:"text",id:"url",label:s.url,required:!0,onLoad:function(){this.allowOnChange=!0},onKeyUp:function(){this.allowOnChange=!1;var g=this.getDialog().getContentElement("info","protocol"),f=this.getValue(),d=/^((javascript:)|[#\/\.\?])/i,h=/^(http|https|ftp|news):\/\/(?=.)/i.exec(f);h?(this.setValue(f.substr(h[0].length)),g.setValue(h[0].toLowerCase())):d.test(f)&&g.setValue("");this.allowOnChange=!0},onChange:function(){if(this.allowOnChange){this.onKeyUp()}},validate:function(){var b=this.getDialog();return b.getContentElement("info","linkType")&&"url"!=b.getValueOf("info","linkType")?!0:!o.config.linkJavaScriptLinksAllowed&&/javascript\:/.test(this.getValue())?(alert(s.invalidValue),!1):this.getDialog().fakeObj?!0:CKEDITOR.dialog.validate.notEmpty(t.noUrl).apply(this)},setup:function(b){this.allowOnChange=!1;b.url&&this.setValue(b.url.url);this.allowOnChange=!0},commit:function(b){this.onChange();b.url||(b.url={});b.url.url=this.getValue();this.allowOnChange=!1}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().show()}},{type:"button",id:"browse",hidden:"true",filebrowser:"info:url",label:s.browseServer}]},{type:"vbox",id:"anchorOptions",width:260,align:"center",padding:0,children:[{type:"fieldset",id:"selectAnchorText",label:t.selectAnchor,setup:function(){r=e.getEditorAnchors(o);this.getElement()[r&&r.length?"show":"hide"]()},children:[{type:"hbox",id:"selectAnchor",children:[{type:"select",id:"anchorName","default":"",label:t.anchorName,style:"width: 100%;",items:[[""]],setup:function(d){this.clear();this.add("");if(r){for(var c=0;c<r.length;c++){r[c].name&&this.add(r[c].name)}}d.anchor&&this.setValue(d.anchor.name);(d=this.getDialog().getContentElement("info","linkType"))&&"email"==d.getValue()&&this.focus()},commit:function(b){b.anchor||(b.anchor={});b.anchor.name=this.getValue()}},{type:"select",id:"anchorId","default":"",label:t.anchorId,style:"width: 100%;",items:[[""]],setup:function(d){this.clear();this.add("");if(r){for(var c=0;c<r.length;c++){r[c].id&&this.add(r[c].id)}}d.anchor&&this.setValue(d.anchor.id)},commit:function(b){b.anchor||(b.anchor={});b.anchor.id=this.getValue()}}],setup:function(){this.getElement()[r&&r.length?"show":"hide"]()}}]},{type:"html",id:"noAnchors",style:"text-align: center;",html:'<div role="note" tabIndex="-1">'+CKEDITOR.tools.htmlEncode(t.noAnchors)+"</div>",focus:!0,setup:function(){this.getElement()[r&&r.length?"hide":"show"]()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}},{type:"vbox",id:"emailOptions",padding:1,children:[{type:"text",id:"emailAddress",label:t.emailAddress,required:!0,validate:function(){var b=this.getDialog();return b.getContentElement("info","linkType")&&"email"==b.getValueOf("info","linkType")?CKEDITOR.dialog.validate.notEmpty(t.noEmail).apply(this):!0},setup:function(b){b.email&&this.setValue(b.email.address);(b=this.getDialog().getContentElement("info","linkType"))&&"email"==b.getValue()&&this.select()},commit:function(b){b.email||(b.email={});b.email.address=this.getValue()}},{type:"text",id:"emailSubject",label:t.emailSubject,setup:function(b){b.email&&this.setValue(b.email.subject)},commit:function(b){b.email||(b.email={});b.email.subject=this.getValue()}},{type:"textarea",id:"emailBody",label:t.emailBody,rows:3,"default":"",setup:function(b){b.email&&this.setValue(b.email.body)},commit:function(b){b.email||(b.email={});b.email.body=this.getValue()}}],setup:function(){this.getDialog().getContentElement("info","linkType")||this.getElement().hide()}}]},{id:"target",requiredContent:"a[target]",label:t.target,title:t.target,elements:[{type:"hbox",widths:["50%","50%"],children:[{type:"select",id:"linkTargetType",label:s.target,"default":"notSet",style:"width : 100%;",items:[[s.notSet,"notSet"],[t.targetFrame,"frame"],[t.targetPopup,"popup"],[s.targetNew,"_blank"],[s.targetTop,"_top"],[s.targetSelf,"_self"],[s.targetParent,"_parent"]],onChange:a,setup:function(b){b.target&&this.setValue(b.target.type||"notSet");a.call(this)},commit:function(b){b.target||(b.target={});b.target.type=this.getValue()}},{type:"text",id:"linkTargetName",label:t.targetFrameName,"default":"",setup:function(b){b.target&&this.setValue(b.target.name)},commit:function(b){b.target||(b.target={});b.target.name=this.getValue().replace(/\W/gi,"")}}]},{type:"vbox",width:"100%",align:"center",padding:2,id:"popupFeatures",children:[{type:"fieldset",label:t.popupFeatures,children:[{type:"hbox",children:[{type:"checkbox",id:"resizable",label:t.popupResizable,setup:q,commit:j},{type:"checkbox",id:"status",label:t.popupStatusBar,setup:q,commit:j}]},{type:"hbox",children:[{type:"checkbox",id:"location",label:t.popupLocationBar,setup:q,commit:j},{type:"checkbox",id:"toolbar",label:t.popupToolbar,setup:q,commit:j}]},{type:"hbox",children:[{type:"checkbox",id:"menubar",label:t.popupMenuBar,setup:q,commit:j},{type:"checkbox",id:"fullscreen",label:t.popupFullScreen,setup:q,commit:j}]},{type:"hbox",children:[{type:"checkbox",id:"scrollbars",label:t.popupScrollBars,setup:q,commit:j},{type:"checkbox",id:"dependent",label:t.popupDependent,setup:q,commit:j}]},{type:"hbox",children:[{type:"text",widths:["50%","50%"],labelLayout:"horizontal",label:s.width,id:"width",setup:q,commit:j},{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:t.popupLeft,id:"left",setup:q,commit:j}]},{type:"hbox",children:[{type:"text",labelLayout:"horizontal",widths:["50%","50%"],label:s.height,id:"height",setup:q,commit:j},{type:"text",labelLayout:"horizontal",label:t.popupTop,widths:["50%","50%"],id:"top",setup:q,commit:j}]}]}]}]},{id:"upload",label:t.upload,title:t.upload,hidden:!0,filebrowser:"uploadButton",elements:[{type:"file",id:"upload",label:s.upload,style:"height:40px",size:29},{type:"fileButton",id:"uploadButton",label:s.uploadSubmit,filebrowser:"info:url","for":["upload","upload"]}]},{id:"advanced",label:t.advanced,title:t.advanced,elements:[{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",id:"advId",requiredContent:"a[id]",label:t.id,setup:m,commit:i},{type:"select",id:"advLangDir",requiredContent:"a[dir]",label:t.langDir,"default":"",style:"width:110px",items:[[s.notSet,""],[t.langDirLTR,"ltr"],[t.langDirRTL,"rtl"]],setup:m,commit:i},{type:"text",id:"advAccessKey",requiredContent:"a[accesskey]",width:"80px",label:t.acccessKey,maxLength:1,setup:m,commit:i}]},{type:"hbox",widths:["45%","35%","20%"],children:[{type:"text",label:t.name,id:"advName",requiredContent:"a[name]",setup:m,commit:i},{type:"text",label:t.langCode,id:"advLangCode",requiredContent:"a[lang]",width:"110px","default":"",setup:m,commit:i},{type:"text",label:t.tabIndex,id:"advTabIndex",requiredContent:"a[tabindex]",width:"80px",maxLength:5,setup:m,commit:i}]}]},{type:"vbox",padding:1,children:[{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:t.advisoryTitle,requiredContent:"a[title]","default":"",id:"advTitle",setup:m,commit:i},{type:"text",label:t.advisoryContentType,requiredContent:"a[type]","default":"",id:"advContentType",setup:m,commit:i}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:t.cssClasses,requiredContent:"a(cke-xyz)","default":"",id:"advCSSClasses",setup:m,commit:i},{type:"text",label:t.charset,requiredContent:"a[charset]","default":"",id:"advCharset",setup:m,commit:i}]},{type:"hbox",widths:["45%","55%"],children:[{type:"text",label:t.rel,requiredContent:"a[rel]","default":"",id:"advRel",setup:m,commit:i},{type:"text",label:t.styles,requiredContent:"a{cke-xyz}","default":"",id:"advStyles",validate:CKEDITOR.dialog.validate.inlineStyle(o.lang.common.invalidInlineStyle),setup:m,commit:i}]}]}]}],onShow:function(){var f=this.getParentEditor(),d=f.getSelection(),g=null;(g=e.getSelectedLink(f))&&g.hasAttribute("href")?d.getSelectedElement()||d.selectElement(g):g=null;f=e.parseLinkAttributes(f,g);this._.selectedElement=g;this.setupContent(f)},onOk:function(){var h={};this.commitContent(h);var g=o.getSelection(),p=e.getLinkAttributes(o,h);if(this._.selectedElement){var l=this._.selectedElement,n=l.data("cke-saved-href"),k=l.getHtml();l.setAttributes(p.set);l.removeAttributes(p.removed);if(n==k||"email"==h.type&&-1!=k.indexOf("@")){l.setHtml("email"==h.type?h.email.address:p.set["data-cke-saved-href"]),g.selectElement(l)}delete this._.selectedElement}else{g=g.getRanges()[0],g.collapsed&&(h=new CKEDITOR.dom.text("email"==h.type?h.email.address:p.set["data-cke-saved-href"],o.document),g.insertNode(h),g.selectNodeContents(h)),p=new CKEDITOR.style({element:"a",attributes:p.set}),p.type=CKEDITOR.STYLE_INLINE,p.applyToRange(g,o),g.select()}},onLoad:function(){o.config.linkShowAdvancedTab||this.hidePage("advanced");o.config.linkShowTargetTab||this.hidePage("target")},onFocus:function(){var b=this.getContentElement("info","linkType");b&&"url"==b.getValue()&&(b=this.getContentElement("info","url"),b.select())}}})})(); |