/*------------------------------------------------------------------------
# Copyright (C) 2005-2012 WebxSolution Ltd. All Rights Reserved.
# @license - GPLv2.0
# Author: WebxSolution Ltd
# Websites:  http://www.webxsolution.com
# Terms of Use: An extension that is derived from the JoomlaCK editor will only be allowed under the following conditions: http://joomlackeditor.com/terms-of-use
# ------------------------------------------------------------------------*/ 
(function(){var a="jtreelink";CKEDITOR.plugins.add(a,{requires:["link"],lang:["en","fi","de","fr","es","it","ru","nl"],beforeInit:function(a){var b=CKEDITOR.document.getHead();b.append(CKEDITOR.document.createElement("link",{attributes:{type:"text/css",rel:"stylesheet",href:a.config.baseHref+"media/system/css/mootree.css"}}));b.append(CKEDITOR.document.createElement("script",{attributes:{type:"text/javascript",src:a.config.baseHref+"media/system/js/mootree.js"}}))},init:function(b){b.addCommand(a,new CKEDITOR.dialogCommand(a));b.ui.addButton("JTreeLink",{label:b.lang.jtreelink.toolbar,command:a,icon:this.path+"images/"+a+".png"});CKEDITOR.dialog.add(a,this.path+"dialogs/"+a+".js");if(b.addMenuItems){b.addMenuItems({jtreelink:{label:b.lang.jtreelink.menu,command:a,icon:this.path+"images/"+a+".png",group:"link"}})}b.on("doubleclick",function(a){var c=CKEDITOR.plugins.link.getSelectedLink(b)||a.data.element;if(!c.isReadOnly()){if(c.is("a")&&c.getAttribute("href")&&c.getAttribute("href").substring(0,5)=="index")a.data.dialog="jtreelink"}});if(b.contextMenu){b.contextMenu.addListener(function(a,c){if(!a||a.isReadOnly())return null;var d=a.is("img")&&a.getAttribute("_cke_real_element_type")=="anchor";if(d)return null;if(!(a=CKEDITOR.plugins.link.getSelectedLink(b)))return null;isJoomlaLink=a.getAttribute("href")&&a.getAttribute("href").substring(0,5)=="index";return!isJoomlaLink?null:{jtreelink:CKEDITOR.TRISTATE_OFF}})}}});CKEDITOR.tools.extend(CKEDITOR.config,{jtreelinkShowAdvancedTab:true,jtreelinkShowTargetTab:true})})()