| Current Path : /home/gonzalx/www/media/com_widgetkit/js/ |
| Current File : /home/gonzalx/www/media/com_widgetkit/js/joomla.picker.js |
(function(p){"use strict";function m(o){return o&&typeof o=="object"&&"default"in o?o:{default:o}}var a=m(p);function h(o){var t;return(window.WFEditor||window.JContentEditor||window.tinyMCE)&&!o.is(":visible")?t=new v(o):window.CodeMirror&&o.next()[0]&&o.next()[0].CodeMirror?t=new P(o):window.ace?t=new k(o):window.CKEDITOR?t=new S(o):t=new b(o),t}function v(o){var t=window.tinymce.editors[o.attr("id")];return{getContent:function(){return t.getContent()},insertContent:function(e){t.execCommand("mceInsertContent",!1,e)},updateContent:function(e,n,r){var s=this.getContent();s=s.substring(0,n)+e+'<span id="tmp-wkid"></span>'+s.substring(r),t.setContent(s),t.selection.select(t.dom.select("#tmp-wkid")[0],!0),t.selection.collapse(!1),t.dom.remove("tmp-wkid",!1),t.focus()},getCursorPosition:function(){var e=t.selection.getBookmark(0),n="[data-mce-type=bookmark]",r=t.dom.select(n);t.selection.select(r[0]),t.selection.collapse();var s="######cursor######",u='<span id="'+s+'"></span>';t.selection.setContent(u);var l=t.getContent({format:"html"}),D=l.indexOf(u);return t.dom.remove(s,!1),t.selection.moveToBookmark(e),D}}}function b(o){return{getContent:function(){return o.val()},insertContent:function(i){this.updateContent(i,o.prop("selectionStart"),o.prop("selectionEnd"))},updateContent:function(i,e,n){var r=o.val(),s=e+i.length;r=r.substring(0,e)+i+r.substring(n),o.val(r),o[0].setSelectionRange(s,s),o.focus().trigger("change")},getCursorPosition:function(){return o.prop("selectionStart")}}}function P(o){var t=o.next()[0].CodeMirror;return{getContent:function(){return t.getValue()},insertContent:function(e){t.replaceRange(e,t.getCursor()),t.focus()},updateContent:function(e,n,r){t.replaceRange(e,this.translateOffset(n),this.translateOffset(r)),t.focus()},getCursorPosition:function(){return this.translatePosition(t.getCursor())},translatePosition:function(e){return t.getValue().split(`
`,e.line).join("").length+e.line+e.ch},translateOffset:function(e){var n=t.getValue().substring(0,e).split(`
`);return{line:n.length-1,ch:n[n.length-1].length}}}}function k(o){var t=window.ace.edit(o.parent().attr("id"));return{getContent:function(){return t.getValue()},insertContent:function(e){t.insert(e),t.focus()},updateContent:function(e,n,r){n=this.translateOffset(n),r=this.translateOffset(r);var s=t.getSelectionRange();s.setStart(n.row,n.column),s.setEnd(r.row,r.column),t.getSession().getDocument().replace(s,e),t.focus()},getCursorPosition:function(){return this.translatePosition(t.getSelection().getCursor())},translatePosition:function(e){return this.getContent().split(`
`,e.row).join("").length+e.row+e.column},translateOffset:function(e){var n=this.getContent().substring(0,e).split(`
`);return{row:n.length-1,column:n[n.length-1].length}}}}function S(o){var t=window.CKEDITOR.instances[o.attr("id")];return{getContent:function(){return t.getData()},insertContent:function(e){this.updateContent(e,this.getCursorPosition(),this.getCursorPosition())},updateContent:function(e,n,r){var s=t.getData();s=s.substring(0,n)+e+s.substring(r),t.setData(s)},getCursorPosition:function(){return t.mode==="source"?a.default(t.textarea.$).prop("selectionStart"):this.getCursorPositionInWYSIWYG()},getCursorPositionInWYSIWYG:function(){var e=t.getSelection().createBookmarks(),n="######cursor######",r='<span id="'+n+'"> </span>',s=window.CKEDITOR.dom.element.createFromHtml(r);s.insertBefore(e[0].startNode);var u=this.getContent(),l=u.indexOf(r);return s.remove(),t.getSelection().selectBookmarks(e),l}}}var c=function(t){a.default.extend(this,{tag:"",attrs:{},type:"single",content:""},t)};a.default.extend(c,{parse:function(t,i){var e=this.regexp(t).exec(i),n={tag:t},r;return e&&(e[4]?r="self-closing":e[6]?r="closed":r="single",n={tag:e[2],attrs:this.attrs(e[3]),type:r,content:e[5]}),new c(n)},attrs:function(t){var i=/(\w+)\s*=\s*"([^"]*)"(?:\s|$)|(\w+)\s*=\s*'([^']*)'(?:\s|$)|(\w+)\s*=\s*([^\s'"]+)(?:\s|$)|"([^"]*)"(?:\s|$)|(\S+)(?:\s|$)/g,e={},n;for(t=t.replace(/[\u00a0\u200b]/g," ");n=i.exec(t);)n[1]?e[n[1].toLowerCase()]=n[2]:n[3]?e[n[3].toLowerCase()]=n[4]:n[5]&&(n[6]==="true"||n[6]==="1")?e[n[5].toLowerCase()]=!0:n[5]&&(n[6]==="false"||n[6]==="0")?e[n[5].toLowerCase()]=!1:n[5]?e[n[5].toLowerCase()]=n[6]:n[7]?e[n[7]]=!0:n[8]&&(e[n[8]]=!0);return e},regexp:function(t){return new RegExp("\\[(\\[?)("+t+")(?![\\w-])([^\\]\\/]*(?:\\/(?!\\])[^\\]\\/]*)*?)(?:(\\/)\\]|\\](?:([^\\[]*(?:\\[(?!\\/\\2\\])[^\\[]*)*)(\\[\\/\\2\\]))?)(\\]?)","g")}}),a.default.extend(c.prototype,{string:function(){var t="["+this.tag;return a.default.each(this.attrs,function(i,e){typeof e=="boolean"?t+=" "+i+"="+(e?1:0):e!==""&&(t+=" "+i+'="'+e+'"')}),this.type==="single"?t+"]":this.type==="self-closing"?t+" /]":(t+="]",this.content&&(t+=this.content),t+"[/"+this.tag+"]")}});var y=window,g=y.Joomla,d,f;window.insertWidgetkitWidget=function(o){for(var t=h(a.default("#"+o)),i=t.getContent(),e=t.getCursorPosition(),n=/\[widgetkit([^\]]*)\]/gi,r,s;s=n.exec(i);)if(s.index<=e&&n.lastIndex>e){r=s[0];break}C(function(u){var l=new c({tag:"widgetkit",attrs:u}).string();r?t.updateContent(l,s.index,n.lastIndex):t.insertContent(l)})},a.default(".widgetkit-widget",".view-module, #module-form, #modules-form").on("click",function(o){var t=this;o.preventDefault(),C(function(i){return w(t,i)})}).each(function(){w(this)});function C(o){var t=g.getOptions("widgetkit"),i=t.iframe;d=d||a.default(O(i)).appendTo("body"),d.find(".modal-body").css("height",window.innerHeight*.9),f=E(d),f.show(),window.selectWidget=function(e){o(e),f.hide()}}function O(o){return`<div class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg jviewport-width90" role="document">
<div class="modal-content">
<div class="modal-body">
<iframe src="`+o+`" style="height: 100%"></iframe>
</div>
</div>
</div>
</div>`}function E(o){var t=window,i=t.bootstrap;return i?new i.Modal(o):(a.default(o).modal().css({width:"90%",marginLeft:"-45%"}),{show:function(){a.default(o).modal("show")},hide:function(){a.default(o).modal("hide")}})}function w(o,t){var i=o.nextElementSibling,e=t?JSON.stringify(t):i.value,n=I(i.value=e),r=g.getOptions("widgetkit");o.textContent=n.name?r.current.replace("%widget%",n.name):r.select}function I(o){try{return JSON.parse(o)}catch(t){return{}}}})(jQuery);