code
stringlengths
1
2.08M
language
stringclasses
1 value
/* +-------------------------------------------------------------------+ | J S - T O O L T I P (v2.2) | | | | Copyright Gerd Tentler www.gerd-tentler.de/tools | | Created: Feb. 15, 2005 Last modified: Feb. 22, 2009 | +-------------------------------------------------------------------+ | This program may be used and hosted free of charge by anyone for | | personal purpose as long as this copyright notice remains intact. | | | | Obtain permission before selling the code for this program or | | hosting this software on a commercial website or redistributing | | this software over the Internet or in any other medium. In all | | cases copyright must remain intact. | +-------------------------------------------------------------------+ ====================================================================================================== This script was tested with the following systems and browsers: - Windows XP: IE 6, NN 7, Opera 7 + 9, Firefox 2 - Mac OS X: IE 5, Safari 1 If you use another browser or system, this script may not work for you - sorry. ------------------------------------------------------------------------------------------------------ USAGE: Use the toolTip-function with mouse-over and mouse-out events (see example below). - To show a tooltip, use this syntax: toolTip(text, width in pixels, opacity in percent) Note: width and opacity are optional. Opacity is not supported by all browsers. - To hide a tooltip, use this syntax: toolTip() ------------------------------------------------------------------------------------------------------ EXAMPLE: <a href="#" onMouseOver="toolTip('Just a test', 150)" onMouseOut="toolTip()">some text here</a> ====================================================================================================== */ var OP = (navigator.userAgent.indexOf('Opera') != -1); var IE = (navigator.userAgent.indexOf('MSIE') != -1 && !OP); var GK = (navigator.userAgent.indexOf('Gecko') != -1); var SA = (navigator.userAgent.indexOf('Safari') != -1); var DOM = document.getElementById; var tooltip = null; function TOOLTIP() { //---------------------------------------------------------------------------------------------------- // Configuration //---------------------------------------------------------------------------------------------------- this.width = 150; // width (pixels) this.bgColor = "#000"; // background color this.textFont = "Calibri"; // text font family this.textSize = 11; // text font size (pixels) this.textColor = "#FFF"; // text color this.border = "1px solid #FFF"; // border (CSS spec: size style color, e.g. "1px solid #D00000") this.opacity = 80; // opacity (0 - 100); not supported by all browsers this.cursorDistance = 5; // distance from mouse cursor (pixels) this.xPos = 'right'; // horizontal position: "left" or "right" this.yPos = 'bottom'; // vertical position: "top" or "bottom" // don't change this.text = ''; this.height = 0; this.obj = null; this.active = false; //---------------------------------------------------------------------------------------------------- // Methods //---------------------------------------------------------------------------------------------------- this.create = function() { if(!this.obj) this.init(); var s = (this.textFont ? 'font-family:' + this.textFont + '; ' : '') + (this.textSize ? 'font-size:' + this.textSize + 'px; ' : '') + (this.border ? 'border:' + this.border + '; ' : '') + (this.textColor ? 'color:' + this.textColor + '; ' : ''); var t = '<table border=0 cellspacing=0 cellpadding=4 width=' + this.width + '><tr>' + '<td align=center' + (s ? ' style="' + s + '"' : '') + '>' + this.text + '</td></tr></table>'; if(DOM || IE) this.obj.innerHTML = t; if(DOM) this.height = this.obj.offsetHeight; else if(IE) this.height = this.obj.style.pixelHeight; if(this.bgColor) this.obj.style.backgroundColor = this.bgColor; this.setOpacity(); this.move(); this.show(); } this.init = function() { if(DOM) this.obj = document.getElementById('ToolTip'); else if(IE) this.obj = document.all.ToolTip; } this.move = function() { var winX = getWinX() - (((GK && !SA) || OP) ? 17 : 0); var winY = getWinY() - (((GK && !SA) || OP) ? 17 : 0); var x = mouseX; var y = mouseY; if(this.xPos == 'left') { if(x - this.width - this.cursorDistance >= getScrX()) x -= this.width + this.cursorDistance; else x += this.cursorDistance; } else { if(x + this.width + this.cursorDistance > winX + getScrX()) x -= this.width + this.cursorDistance; else x += this.cursorDistance; } if(this.yPos == 'top') { if(y - this.height - this.cursorDistance >= getScrY()) y -= this.height + this.cursorDistance; else y += this.cursorDistance; } else { if(y + this.height + this.cursorDistance > winY + getScrY()) y -= this.height; else y += this.cursorDistance; } this.obj.style.left = x + 'px'; this.obj.style.top = y + 'px'; } this.show = function() { this.obj.style.zIndex = 69; this.active = true; this.obj.style.visibility = 'visible'; } this.hide = function() { this.obj.style.zIndex = -1; this.active = false; this.obj.style.visibility = 'hidden'; } this.setOpacity = function() { this.obj.style.opacity = this.opacity / 100; this.obj.style.MozOpacity = this.opacity / 100; this.obj.style.KhtmlOpacity = this.opacity / 100; this.obj.style.filter = 'alpha(opacity=' + this.opacity + ')'; } } //---------------------------------------------------------------------------------------------------- // Global functions //---------------------------------------------------------------------------------------------------- function getScrX() { var offset = 0; if(window.pageXOffset) offset = window.pageXOffset; else if(document.documentElement && document.documentElement.scrollLeft) offset = document.documentElement.scrollLeft; else if(document.body && document.body.scrollLeft) offset = document.body.scrollLeft; return offset; } function getScrY() { var offset = 0; if(window.pageYOffset) offset = window.pageYOffset; else if(document.documentElement && document.documentElement.scrollTop) offset = document.documentElement.scrollTop; else if(document.body && document.body.scrollTop) offset = document.body.scrollTop; return offset; } function getWinX() { var size = 0; if(window.innerWidth) size = window.innerWidth; else if(document.documentElement && document.documentElement.clientWidth) size = document.documentElement.clientWidth; else if(document.body && document.body.clientWidth) size = document.body.clientWidth; else size = screen.width; return size; } function getWinY() { var size = 0; if(window.innerHeight) size = window.innerHeight; else if(document.documentElement && document.documentElement.clientHeight) size = document.documentElement.clientHeight; else if(document.body && document.body.clientHeight) size = document.body.clientHeight; else size = screen.height; return size; } function getMouseXY(e) { if(e && e.pageX != null) { mouseX = e.pageX; mouseY = e.pageY; } else if(event && event.clientX != null) { mouseX = event.clientX + getScrX(); mouseY = event.clientY + getScrY(); } if(mouseX < 0) mouseX = 0; if(mouseY < 0) mouseY = 0; if(tooltip && tooltip.active) tooltip.move(); } function toolTip(text, width, opacity) { if(text) { tooltip = new TOOLTIP(); tooltip.text = text; if(width) tooltip.width = width; if(opacity) tooltip.opacity = opacity; tooltip.create(); } else if(tooltip) tooltip.hide(); } //---------------------------------------------------------------------------------------------------- // Build tooltip box //---------------------------------------------------------------------------------------------------- document.write('<div id="ToolTip" style="position:absolute; visibility:hidden"></div>'); //---------------------------------------------------------------------------------------------------- // Event handlers //---------------------------------------------------------------------------------------------------- var mouseX = mouseY = 0; document.onmousemove = getMouseXY; //----------------------------------------------------------------------------------------------------
JavaScript
/* * jQuery Reveal Plugin 1.0 * www.ZURB.com * Copyright 2010, ZURB * Free to use under the MIT license. * http://www.opensource.org/licenses/mit-license.php */ (function($) { /*--------------------------- Defaults for Reveal ----------------------------*/ /*--------------------------- Listener for data-reveal-id attributes ----------------------------*/ $('a[data-reveal-id]').live('click', function(e) { e.preventDefault(); var modalLocation = $(this).attr('data-reveal-id'); $('#'+modalLocation).reveal($(this).data()); }); /*--------------------------- Extend and Execute ----------------------------*/ $.fn.reveal = function(options) { var defaults = { animation: 'fadeAndPop', //fade, fadeAndPop, none animationspeed: 300, //how fast animtions are closeonbackgroundclick: true, //if you click background will modal close? dismissmodalclass: 'close-reveal-modal' //the class of a button or element that will close an open modal }; //Extend dem' options var options = $.extend({}, defaults, options); return this.each(function() { /*--------------------------- Global Variables ----------------------------*/ var modal = $(this), topMeasure = parseInt(modal.css('top')), topOffset = modal.height() + topMeasure, locked = false, modalBG = $('.reveal-modal-bg'); /*--------------------------- Create Modal BG ----------------------------*/ if(modalBG.length == 0) { modalBG = $('<div class="reveal-modal-bg" />').insertAfter(modal); } /*--------------------------- Open and add Closing Listeners ----------------------------*/ //Open Modal Immediately openModal(); //Close Modal Listeners var closeButton = $('.' + options.dismissmodalclass).bind('click.modalEvent',closeModal) if(options.closeonbackgroundclick) { modalBG.css({"cursor":"pointer"}) modalBG.bind('click.modalEvent',closeModal) } /*--------------------------- Open & Close Animations ----------------------------*/ //Entrance Animations function openModal() { modalBG.unbind('click.modalEvent'); $('.' + options.dismissmodalclass).unbind('click.modalEvent'); if(!locked) { lockModal(); if(options.animation == "fadeAndPop") { modal.css({'top': $(document).scrollTop()-topOffset, 'opacity' : 0, 'visibility' : 'visible'}); modalBG.fadeIn(options.animationspeed/2); modal.delay(options.animationspeed/2).animate({ "top": $(document).scrollTop()+topMeasure, "opacity" : 1 }, options.animationspeed,unlockModal()); } if(options.animation == "fade") { modal.css({'opacity' : 0, 'visibility' : 'visible', 'top': $(document).scrollTop()+topMeasure}); modalBG.fadeIn(options.animationspeed/2); modal.delay(options.animationspeed/2).animate({ "opacity" : 1 }, options.animationspeed,unlockModal()); } if(options.animation == "none") { modal.css({'visibility' : 'visible', 'top':$(document).scrollTop()+topMeasure}); modalBG.css({"display":"block"}); unlockModal() } } } //Closing Animation function closeModal() { if(!locked) { lockModal(); if(options.animation == "fadeAndPop") { modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); modal.animate({ "top": $(document).scrollTop()-topOffset, "opacity" : 0 }, options.animationspeed/2, function() { modal.css({'top':topMeasure, 'opacity' : 1, 'visibility' : 'hidden'}); unlockModal(); }); } if(options.animation == "fade") { modalBG.delay(options.animationspeed).fadeOut(options.animationspeed); modal.animate({ "opacity" : 0 }, options.animationspeed, function() { modal.css({'opacity' : 1, 'visibility' : 'hidden', 'top' : topMeasure}); unlockModal(); }); } if(options.animation == "none") { modal.css({'visibility' : 'hidden', 'top' : topMeasure}); modalBG.css({'display' : 'none'}); } } } /*--------------------------- Animations Locks ----------------------------*/ function unlockModal() { locked = false; } function lockModal() { locked = true; } });//each call }//orbit plugin call })(jQuery);
JavaScript
/** * @version $Id: $Revision * @package mootool * @subpackage lofslidernews * @copyright Copyright (C) JAN 2010 LandOfCoder.com <@emai:landofcoder@gmail.com>. All rights reserved. * @website http://landofcoder.com * @license This plugin is dual-licensed under the GNU General Public License and the MIT License */ if( typeof(LofSlideshow) == 'undefined' ){ var LofFlashContent = new Class( { initialize:function( eMain, eNavigator,eNavOuter, options ){ this.setting = $extend({ autoStart : true, descStyle : 'sliding', mainItemSelector : 'div.lof-main-item', navSelector : 'li' , navigatorEvent : 'click', interval : 2000, auto : false, navItemsDisplay:3, startItem:0, navItemHeight:100 }, options || {} ); this.currentNo = 0; this.nextNo = null; this.previousNo = null; this.fxItems = []; this.minSize = 0; if( $defined(eMain) ){ this.slides = eMain.getElements( this.setting.mainItemSelector ); this.maxWidth = eMain.getStyle('width').toInt(); this.maxHeight = eMain.getStyle('height').toInt(); this.styleMode = this.__getStyleMode(); var fx = $extend( {waiting:false}, this.setting.fxObject ); this.slides.each( function(item, index) { item.setStyles( eval('({"'+this.styleMode[0]+'": index * this.maxSize,"'+this.styleMode[1]+'":Math.abs(this.maxSize),"display" : "block"})') ); this.fxItems[index] = new Fx.Morph( item, fx ); }.bind(this) ); if( this.styleMode[0] == 'opacity' || this.styleMode[0] =='z-index' ){ this.slides[0].setStyle(this.styleMode[0],'1'); } eMain.addEvents( { 'mouseenter' : this.stop.bind(this), 'mouseleave' :function(e){ this.play( this.setting.interval,'next', true );}.bind(this) } ); } // if has the navigator if( $defined(eNavigator) ){ this.navigatorItems = eNavigator.getElements( this.setting.navSelector ); if( this.setting.navItemsDisplay > this.navigatorItems.length ){ this.setting.navItemsDisplay = this.navigatorItems.length; } eNavOuter.setStyle( 'height',this.setting.navItemsDisplay*this.setting.navItemHeight); this.navigatorFx = new Fx.Morph( eNavigator, {transition:Fx.Transitions.Quad.easeInOut,duration:800} ); this.registerMousewheelHandler( eNavigator ); // allow to use the srcoll this.navigatorItems.each( function(item,index) { item.addEvent( this.setting.navigatorEvent, function(){ this.jumping( index, true ); this.setNavActive( index, item ); }.bind(this) ); item.setStyle( 'height', this.setting.navItemHeight ); }.bind(this) ); this.setNavActive( 0 ); } }, navivationAnimate:function( currentIndex ) { if (currentIndex <= this.setting.startItem || currentIndex - this.setting.startItem >= this.setting.navItemsDisplay-1) { this.setting.startItem = currentIndex - this.setting.navItemsDisplay+2; if (this.setting.startItem < 0) this.setting.startItem = 0; if (this.setting.startItem >this.slides.length-this.setting.navItemsDisplay) { this.setting.startItem = this.slides.length-this.setting.navItemsDisplay; } } this.navigatorFx.cancel().start( { 'top':-this.setting.startItem*this.setting.navItemHeight} ); }, setNavActive:function( index, item ){ if( $defined(this.navigatorItems) ){ this.navigatorItems.removeClass('active'); this.navigatorItems[index].addClass('active'); this.navivationAnimate( this.currentNo ); } }, __getStyleMode:function(){ switch( this.setting.direction ){ case 'opacity': this.maxSize=0; this.minSize=1; return ['opacity','opacity']; case 'vrup': this.maxSize=this.maxHeight; return ['top','height']; case 'vrdown': this.maxSize=-this.maxHeight; return ['top','height']; case 'hrright': this.maxSize=-this.maxWidth; return ['left','width']; case 'hrleft': default: this.maxSize=this.maxWidth; return ['left','width']; } }, registerMousewheelHandler:function( element ){ element.addEvent( 'mousewheel', function(e){ e.stop(); if( e.wheel > 0 ){ this.previous(true); } else { this.next(true); } }.bind(this) ); }, registerButtonsControl:function( eventHandler, objects, isHover ){ if( $defined(objects) && this.slides.length > 1 ){ for( var action in objects ){ if( $defined(this[action.toString()]) && $defined(objects[action]) ){ objects[action].addEvent( eventHandler, this[action.toString()].bind(this, [true]) ); } } } return this; }, start:function( isStart, obj ){ this.setting.auto = isStart; // if use the preload image. if( obj ) { var images = [] this.slides.getElements('img').each( function(item, index){ images[index] = item.getProperty('src'); } ); var loader = new Asset.images(images, { onComplete:function(){ (function(){ obj.fade('out') ;}).delay(400); if( isStart && this.slides.length > 0 ){this.play( this.setting.interval,'next', true );} }.bind(this) } ); } else { if( isStart && this.slides.length > 0 ){this.play( this.setting.interval,'next', true );} } }, onProcessing:function( manual, start, end ){ this.previousNo = this.currentNo + (this.currentNo>0 ? -1 : this.slides.length-1); this.nextNo = this.currentNo + (this.currentNo < this.slides.length-1 ? 1 : 1- this.slides.length); return this; }, finishFx:function( manual ){ if( manual ) this.stop(); if( manual && this.setting.auto ){ this.setNavActive( this.currentNo ); this.play( this.setting.interval,'next', true ); } }, getObjectDirection:function( start, end ){ return eval("({'"+this.styleMode[0]+"':["+start+", "+end+"]})"); }, fxStart:function( index, obj ){ this.fxItems[index].cancel().start( obj ); return this; }, jumping:function( no, manual ){ this.stop(); if( this.currentNo == no ) return; this.onProcessing( null, manual, 0, this.maxSize ) .fxStart( no, this.getObjectDirection(this.maxSize , this.minSize) ) .fxStart( this.currentNo, this.getObjectDirection(this.minSize, -this.maxSize) ) .finishFx( manual ); this.currentNo = no; }, next:function( manual , item){ this.currentNo += (this.currentNo < this.slides.length-1) ? 1 : (1 - this.slides.length); this.onProcessing( item, manual, 0, this.maxSize ) .fxStart( this.currentNo, this.getObjectDirection(this.maxSize ,this.minSize) ) .fxStart( this.previousNo, this.getObjectDirection(this.minSize, -this.maxSize) ) .finishFx( manual ); }, previous:function( manual, item ){ this.currentNo += this.currentNo > 0 ? -1 : this.slides.length - 1; this.onProcessing( item, manual, -this.maxWidth, this.minSize ) .fxStart( this.nextNo, this.getObjectDirection(this.minSize, this.maxSize) ) .fxStart( this.currentNo, this.getObjectDirection(-this.maxSize, this.minSize) ) .finishFx( manual ); }, play:function( delay, direction, wait ){ this.stop(); if(!wait){ this[direction](false); } this.isRun = this[direction].periodical(delay,this,true); },stop:function(){; $clear(this.isRun ); } } ); }
JavaScript
Calendar.LANG("ro", "Română", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Astăzi", today: "Astăzi", // appears in bottom bar wk: "săp.", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Ianuarie", "Februarie", "Martie", "Aprilie", "Mai", "Iunie", "Iulie", "August", "Septembrie", "Octombrie", "Noiembrie", "Decembrie" ], smn : [ "Ian", "Feb", "Mar", "Apr", "Mai", "Iun", "Iul", "Aug", "Sep", "Oct", "Noi", "Dec" ], dn : [ "Duminică", "Luni", "Marţi", "Miercuri", "Joi", "Vineri", "Sâmbătă", "Duminică" ], sdn : [ "Du", "Lu", "Ma", "Mi", "Jo", "Vi", "Sâ", "Du" ] });
JavaScript
Calendar.LANG("cn", "中文", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "今天", today: "今天", // appears in bottom bar wk: "周", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "AM", PM: "PM", mn : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], smn : [ "一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], dn : [ "日", "一", "二", "三", "四", "五", "六", "日" ], sdn : [ "日", "一", "二", "三", "四", "五", "六", "日" ] });
JavaScript
Calendar.LANG("ru", "русский", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Сегодня", today: "Сегодня", // appears in bottom bar wk: "нед", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "январь", "февраль", "март", "апрель", "май", "июнь", "июль", "август", "сентябрь", "октябрь", "ноябрь", "декабрь" ], smn : [ "янв", "фев", "мар", "апр", "май", "июн", "июл", "авг", "сен", "окт", "ноя", "дек" ], dn : [ "воскресенье", "понедельник", "вторник", "среда", "четверг", "пятница", "суббота", "воскресенье" ], sdn : [ "вск", "пон", "втр", "срд", "чет", "пят", "суб", "вск" ] });
JavaScript
Calendar.LANG("fr", "Français", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday : "Aujourd'hui", today: "Aujourd'hui", // appears in bottom bar wk: "sm.", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre" ], smn : [ "Jan", "Fév", "Mar", "Avr", "Mai", "Juin", "Juil", "Aou", "Sep", "Oct", "Nov", "Déc" ], dn : [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche" ], sdn : [ "Di", "Lu", "Ma", "Me", "Je", "Ve", "Sa", "Di" ] });
JavaScript
Calendar.LANG("pt", "Portuguese", { fdow: 1, // primeiro dia da semana para esse local; 0 = Domingo, 1 = Segunda, etc. goToday: "Dia de Hoje", today: "Hoje", wk: "sm", weekend: "0,6", // 0 = Domingo, 1 = Segunda, etc. AM: "am", PM: "pm", mn : [ "Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro" ], smn : [ "Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez" ], dn : [ "Domingo", "Segunda", "Terça", "Quarta", "Quinta", "Sexta", "Sábado", "Domingo" ], sdn : [ "Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sab", "Dom" ] });
JavaScript
Calendar.LANG("ca", "Catalan", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Anar a Avui", today: "Avui", // appears in bottom bar wk: "sem", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "gener", "febrer", "març", "abril", "maig", "juny", "juliol", "agost", "setembre", "octubre", "novembre", "desembre" ], smn : [ "gen", "feb", "mar", "abr", "mai", "jun", "jul", "ago", "set", "oct", "nov", "des" ], dn : [ "diumenge", "dilluns", "dimarts", "dimecres", "dijous", "divendres", "dissabte", "diumenge" ], sdn : [ "dg", "dl", "dt", "dc", "dj", "dv", "ds", "dg" ] });
JavaScript
Calendar.LANG("cz", "Czech", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Ukaž dnešek", today: "Dnes", // appears in bottom bar wk: "týd", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Leden", "Únor", "Březen", "Duben", "Květen", "Červen", "Červenec", "Srpen", "Září", "Říjen", "Listopad", "Prosinec" ], smn : [ "Led", "Úno", "Bře", "Dub", "Kvě", "Črn", "Črc", "Srp", "Zář", "Říj", "Lis", "Pro" ], dn : [ "Neděle", "Pondělí", "Úterý", "Středa", "Čtvrtek", "Pátek", "Sobota", "Neděle" ], sdn : [ "Ne", "Po", "Út", "St", "Čt", "Pá", "So", "Ne" ] });
JavaScript
Calendar.LANG("sv", "svenska", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Gå till idag", today: "Idag", // appears in bottom bar wk: "v", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "januari", "februari", "mars", "april", "maj", "juni", "juli", "augusti", "september", "oktober", "november", "december" ], smn : [ "jan", "feb", "mar", "apr", "maj", "jun", "jul", "aug", "sep", "okt", "nov", "dec" ], dn : [ "söndag", "måndag", "tisdag", "onsdag", "torsdag", "fredag", "lördag", "söndag" ], sdn : [ "sö", "må", "ti", "on", "to", "fr", "lö", "sö" ] });
JavaScript
Calendar.LANG("de", "Deutsch", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday : "Heute ausw\u00e4hlen", today: "Heute", // appears in bottom bar wk: "KW", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Januar", "Februar", "M\u00e4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember" ], smn : [ "Jan", "Feb", "M\u00e4r", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez" ], dn : [ "Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag" ], sdn : [ "So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So" ] });
JavaScript
Calendar.LANG("jp", "Japanese", { fdow: 1, // 地元の週の初めの日; 0 = 日曜日, 1 = 月曜日, 等. goToday: "本日へ", today: "本日", // ボットンバーに表示 wk: "週", weekend: "0,6", // 0 = 日曜日, 1 = 月曜日, 等. AM: "am", PM: "pm", mn : [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ], smn : [ "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" ], dn : [ "日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜日" ], sdn : [ "日", "月", "火", "水", "木", "金", "土", "日" ] });
JavaScript
Calendar.LANG("it", "Italiano", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Vai a oggi", today: "Oggi", // appears in bottom bar wk: "set", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Gennaio", "Febbraio", "Marzo", "Aprile", "Maggio", "Giugno", "Luglio", "Agosto", "Settembre", "Ottobre", "Novembre", "Dicembre" ], smn : [ "Gen", "Feb", "Mar", "Apr", "Mag", "Giu", "Lug", "Ago", "Set", "Ott", "Nov", "Dic" ], dn : [ "Domenica", "Lunedì", "Martedì", "Mercoledì", "Giovedi", "Venerdì", "Sabato", "Domenica" ], sdn : [ "Do", "Lu", "Ma", "Me", "Gi", "Ve", "Sa", "Do" ] });
JavaScript
Calendar.LANG("sk", "Slovak", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Nastaviť dnešok", today: "Dnes", // appears in bottom bar wk: "týž", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "január", "február", "marec", "apríl", "máj", "jún", "júl", "august", "september", "október", "november", "december" ], smn : [ "jan", "feb", "mar", "apr", "máj", "jún", "júl", "aug", "sep", "okt", "nov", "dec" ], dn : [ "Nedeľa", "Pondelok", "Utorok", "Streda", "Štvrtok", "Piatok", "Sobota", "Nedeľa" ], sdn : [ "Ne", "Po", "Ut", "St", "Št", "Pi", "So", "Ne" ] });
JavaScript
Calendar.LANG("nl", "Nederlands", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "naar vandaag", today: "Vandaag", // appears in bottom bar wk: "wk", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "vm", PM: "nm", mn : [ "Januari", "Februari", "Maart", "April", "Mei", "Juni", "Juli", "Augustus", "September", "Oktober", "November", "December" ], smn : [ "Jan", "Feb", "Maa", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dec" ], dn : [ "Zondag", "Maandag", "Dinsdag", "Woensdag", "Donderdag", "Vrijdag", "Zaterdag", "Zondag" ], sdn : [ "Zo", "Ma", "Di", "Wo", "Do", "Vr", "Za", "Zo" ] });
JavaScript
Calendar.LANG("es", "Español", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Ir a Hoy", today: "Hoy", // appears in bottom bar wk: "sem", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre" ], smn : [ "Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic" ], dn : [ "Domingo", "Lunes", "Martes", "Miercoles", "Jueves", "Viernes", "Sabado", "Domingo" ], sdn : [ "Do", "Lu", "Ma", "Mi", "Ju", "Vi", "Sa", "Do" ] });
JavaScript
// autor: Piotr kwiatkowski // www: http://pasjonata.net Calendar.LANG("pl", "Polish", { fdow: 1, // pierwszy dzień tygodnia; 0 = Niedziela, 1 = Poniedziałek, itd. goToday: "Idzie Dzisiaj", today: "Dziś", wk: "wk", weekend: "0,6", // 0 = Niedziela, 1 = Poniedziałek, itd. AM: "am", PM: "pm", mn : [ "Styczeń", "Luty", "Marzec", "Kwiecień", "Maj", "Czerwiec", "Lipiec", "Sierpień", "Wrzesień", "Październik", "Listopad", "Grudzień" ], smn : [ "Sty", "Lut", "Mar", "Kwi", "Maj", "Cze", "Lip", "Sie", "Wrz", "Paź", "Lis", "Gru" ], dn : [ "Niedziela", "Poniedziałek", "Wtorek", "Środa", "Czwartek", "Piątek", "Sobota", "Niedziela" ], sdn : [ "Ni", "Po", "Wt", "Śr", "Cz", "Pi", "So", "Ni" ] });
JavaScript
Calendar.LANG("hr", "Hrvatski", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Odaberi Danas", today: "Danas", // appears in bottom bar wk: "tj", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "Siječanj", "Veljača", "Ožujak", "Travanj", "Svibanj", "Lipanj", "Srpanj", "Kolovoz", "Rujan", "Listopad", "Studeni", "Prosinac" ], smn : [ "Sij", "Velj", "Ožu", "Tra", "Svi", "Lip", "Srp", "Kol", "Ruj", "Lis", "Stu", "Pro" ], dn : [ "Nedjelja", "Ponedjeljak", "Utorak", "Srijeda", "Četvrtak", "Petak", "Subota", "Nedjelja" ], sdn : [ "Ned", "Pon", "Uto", "Sri", "Čet", "Pet", "Sub", "Ned" ] });
JavaScript
Calendar.LANG("en", "English", { fdow: 1, // first day of week for this locale; 0 = Sunday, 1 = Monday, etc. goToday: "Go Today", today: "Today", // appears in bottom bar wk: "wk", weekend: "0,6", // 0 = Sunday, 1 = Monday, etc. AM: "am", PM: "pm", mn : [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], smn : [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], dn : [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ], sdn : [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "Su" ] });
JavaScript
function loadXmlHttp(url, id) { var f = this; f.xmlHttp = null; /*@cc_on @*/ // used here and below, limits try/catch to those IE browsers that both benefit from and support it /*@if(@_jscript_version >= 5) // prevents errors in old browsers that barf on try/catch & problems in IE if Active X disabled try {f.ie = window.ActiveXObject}catch(e){f.ie = false;} @end @*/ if (window.XMLHttpRequest&&!f.ie||/^http/.test(window.location.href)) f.xmlHttp = new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari, others, IE 7+ when live - this is the standard method else if (/(object)|(function)/.test(typeof createRequest)) f.xmlHttp = createRequest(); // ICEBrowser, perhaps others else { f.xmlHttp = null; // Internet Explorer 5 to 6, includes IE 7+ when local // /*@cc_on @*/ /*@if(@_jscript_version >= 5) try{f.xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");} catch (e){try{f.xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){f.xmlHttp=null;}} @end @*/ } if(f.xmlHttp != null){ f.el = document.getElementById(id); f.xmlHttp.open("GET",url,true); f.xmlHttp.onreadystatechange = function(){f.stateChanged();}; f.xmlHttp.send(null); } } loadXmlHttp.prototype.stateChanged=function () { if (this.xmlHttp.readyState == 4 && (this.xmlHttp.status == 200 || !/^http/.test(window.location.href))) this.el.innerHTML = this.xmlHttp.responseText; } var requestTime = function(){ new loadXmlHttp('connected.jsp', 'connectedDiv'); setInterval(function(){new loadXmlHttp('connected.jsp?t=' + new Date().getTime(), 'connectedDiv');}, 10000); } if (window.addEventListener) window.addEventListener('load', requestTime, false); else if (window.attachEvent) window.attachEvent('onload', requestTime);
JavaScript
var JCaption = new Class({ initialize : function(b) { this.selector = b; var a = $$(b); a.each(function(c) { this.createCaption(c) }, this) }, createCaption : function(c) { var b = document.createTextNode(c.title); var a = document.createElement("div"); var e = document.createElement("p"); var d = c.getAttribute("width"); var f = c.getAttribute("align"); if (!d) { d = c.width } if (!f) { f = c.getStyle("float") } if (!f) { f = c.style.styleFloat } if (f == "" || !f) { f = "none" } e.appendChild(b); e.className = this.selector.replace(".", "_"); c.parentNode.insertBefore(a, c); a.appendChild(c); if (c.title != "") { a.appendChild(e) } a.className = this.selector.replace(".", "_"); a.className = a.className + " " + f; a.setAttribute("style", "float:" + f); a.style.width = d + "px" } }); document.caption = null; window.addEvent("load", function() { var a = new JCaption("img.caption"); document.caption = a });
JavaScript
jQuery.noConflict(); (function($) { /*namespacing the $ to avoid conflict with mootools*/ $(document).ready(function() { // Caption Sliding (Partially Hidden to Visible) $('.boxgrid.caption').hover(function() { $(".cover", this).stop().animate({ top : '0px' }, { queue : false, duration : 200 }); }, function() { $(".cover", this).stop().animate({ top : '71px' }, { queue : false, duration : 160 }); }); }); })(jQuery);
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * An info panel, which complements the map view of the Store Locator. * Provides a list of stores, location search, feature filter, and directions. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * An info panel, to complement the map view. * Provides a list of stores, location search, feature filter, and directions. * @example <pre> * var container = document.getElementById('panel'); * var panel = new storeLocator.Panel(container, { * view: view, * locationSearchLabel: 'Location:' * }); * google.maps.event.addListener(panel, 'geocode', function(result) { * geocodeMarker.setPosition(result.geometry.location); * }); * </pre> * @extends {google.maps.MVCObject} * @param {!Node} el the element to contain this panel. * @param {storeLocator.PanelOptions} opt_options * @constructor * @implements storeLocator_Panel */ storeLocator.Panel = function(el, opt_options) { this.el_ = $(el); this.el_.addClass('storelocator-panel'); this.settings_ = $.extend({ 'locationSearch': true, 'locationSearchLabel': 'Where are you?', 'featureFilter': true, 'directions': true, 'view': null }, opt_options); this.directionsRenderer_ = new google.maps.DirectionsRenderer({ draggable: true }); this.directionsService_ = new google.maps.DirectionsService; this.init_(); }; storeLocator['Panel'] = storeLocator.Panel; storeLocator.Panel.prototype = new google.maps.MVCObject; /** * Initialise the info panel * @private */ storeLocator.Panel.prototype.init_ = function() { var that = this; this.itemCache_ = {}; if (this.settings_['view']) { this.set('view', this.settings_['view']); } this.filter_ = $('<form class="storelocator-filter"/>'); this.el_.append(this.filter_); if (this.settings_['locationSearch']) { this.locationSearch_ = $('<div class="location-search"><h4>' + this.settings_['locationSearchLabel'] + '</h4><input></div>'); this.filter_.append(this.locationSearch_); if (typeof google.maps.places != 'undefined') { this.initAutocomplete_(); } else { this.filter_.submit(function() { var search = $('input', that.locationSearch_).val(); that.searchPosition(/** @type {string} */(search)); }); } this.filter_.submit(function() { return false; }); google.maps.event.addListener(this, 'geocode', function(place) { if (!place.geometry) { that.searchPosition(place.name); return; } this.directionsFrom_ = place.geometry.location; if (that.directionsVisible_) { that.renderDirections_(); } var sl = that.get('view'); sl.highlight(null); var map = sl.getMap(); if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(13); } sl.refreshView(); that.listenForStoresUpdate_(); }); } if (this.settings_['featureFilter']) { // TODO(cbro): update this on view_changed this.featureFilter_ = $('<div class="feature-filter"/>'); var allFeatures = this.get('view').getFeatures().asList(); for (var i = 0, ii = allFeatures.length; i < ii; i++) { var feature = allFeatures[i]; var checkbox = $('<input type="checkbox"/>'); checkbox.data('feature', feature); $('<label/>').append(checkbox).append(feature.getDisplayName()) .appendTo(this.featureFilter_); } this.filter_.append(this.featureFilter_); this.featureFilter_.find('input').change(function() { var feature = $(this).data('feature'); that.toggleFeatureFilter_(/** @type {storeLocator.Feature} */(feature)); that.get('view').refreshView(); }); } this.storeList_ = $('<ul class="store-list"/>'); this.el_.append(this.storeList_); if (this.settings_['directions']) { this.directionsPanel_ = $('<div class="directions-panel"><form>' + '<input class="directions-to"/>' + '<input type="submit" value="Find directions"/>' + '<a href="#" class="close-directions">Close</a>' + '</form><div class="rendered-directions"></div></div>'); this.directionsPanel_.find('.directions-to').attr('readonly', 'readonly'); this.directionsPanel_.hide(); this.directionsVisible_ = false; this.directionsPanel_.find('form').submit(function() { that.renderDirections_(); return false; }); this.directionsPanel_.find('.close-directions').click(function() { that.hideDirections(); }); this.el_.append(this.directionsPanel_); } }; /** * Toggles a particular feature on/off in the feature filter. * @param {storeLocator.Feature} feature The feature to toggle. * @private */ storeLocator.Panel.prototype.toggleFeatureFilter_ = function(feature) { var featureFilter = this.get('featureFilter'); featureFilter.toggle(feature); this.set('featureFilter', featureFilter); }; /** * Global Geocoder instance, for convenience. * @type {google.maps.Geocoder} * @private */ storeLocator.geocoder_ = new google.maps.Geocoder; /** * Triggers an update for the store list in the Panel. Will wait for stores * to load asynchronously from the data source. * @private */ storeLocator.Panel.prototype.listenForStoresUpdate_ = function() { var that = this; var view = /** @type storeLocator.View */(this.get('view')); if (this.storesChangedListener_) { google.maps.event.removeListener(this.storesChangedListener_); } this.storesChangedListener_ = google.maps.event.addListenerOnce(view, 'stores_changed', function() { that.set('stores', view.get('stores')); }); }; /** * Search and pan to the specified address. * @param {string} searchText the address to pan to. */ storeLocator.Panel.prototype.searchPosition = function(searchText) { var that = this; var request = { address: searchText, bounds: this.get('view').getMap().getBounds() }; storeLocator.geocoder_.geocode(request, function(result, status) { if (status != google.maps.GeocoderStatus.OK) { //TODO(cbro): proper error handling return; } google.maps.event.trigger(that, 'geocode', result[0]); }); }; /** * Sets the associated View. * @param {storeLocator.View} view the view to set. */ storeLocator.Panel.prototype.setView = function(view) { this.set('view', view); }; /** * view_changed handler. * Sets up additional bindings between the info panel and the map view. */ storeLocator.Panel.prototype.view_changed = function() { var sl = /** @type {google.maps.MVCObject} */ (this.get('view')); this.bindTo('selectedStore', sl); var that = this; if (this.geolocationListener_) { google.maps.event.removeListener(this.geolocationListener_); } if (this.zoomListener_) { google.maps.event.removeListener(this.zoomListener_); } if (this.idleListener_) { google.maps.event.removeListener(this.idleListener_); } var center = sl.getMap().getCenter(); var updateList = function() { sl.clearMarkers(); that.listenForStoresUpdate_(); }; //TODO(cbro): somehow get the geolocated position and populate the 'from' box. this.geolocationListener_ = google.maps.event.addListener(sl, 'load', updateList); this.zoomListener_ = google.maps.event.addListener(sl.getMap(), 'zoom_changed', updateList); this.idleListener_ = google.maps.event.addListener(sl.getMap(), 'idle', function() { return that.idle_(sl.getMap()); }); updateList(); this.bindTo('featureFilter', sl); if (this.autoComplete_) { this.autoComplete_.bindTo('bounds', sl.getMap()); } }; /** * Adds autocomplete to the input box. * @private */ storeLocator.Panel.prototype.initAutocomplete_ = function() { var that = this; var input = $('input', this.locationSearch_)[0]; this.autoComplete_ = new google.maps.places.Autocomplete(input); if (this.get('view')) { this.autoComplete_.bindTo('bounds', this.get('view').getMap()); } google.maps.event.addListener(this.autoComplete_, 'place_changed', function() { google.maps.event.trigger(that, 'geocode', this.getPlace()); }); }; /** * Called on the view's map idle event. Refreshes the store list if the * user has navigated far away enough. * @param {google.maps.Map} map the current view's map. * @private */ storeLocator.Panel.prototype.idle_ = function(map) { if (!this.center_) { this.center_ = map.getCenter(); } else if (!map.getBounds().contains(this.center_)) { this.center_ = map.getCenter(); this.listenForStoresUpdate_(); } }; /** * @const * @type {string} * @private */ storeLocator.Panel.NO_STORES_HTML_ = '<li class="no-stores">There are no' + ' stores in this area.</li>'; /** * @const * @type {string} * @private */ storeLocator.Panel.NO_STORES_IN_VIEW_HTML_ = '<li class="no-stores">There are' + ' no stores in this area. However, stores closest to you are' + ' listed below.</li>'; /** * Handler for stores_changed. Updates the list of stores. * @this storeLocator.Panel */ storeLocator.Panel.prototype.stores_changed = function() { if (!this.get('stores')) { return; } var view = this.get('view'); var bounds = view && view.getMap().getBounds(); var that = this; var stores = this.get('stores'); var selectedStore = this.get('selectedStore'); this.storeList_.empty(); if (!stores.length) { this.storeList_.append(storeLocator.Panel.NO_STORES_HTML_); } else if (bounds && !bounds.contains(stores[0].getLocation())) { this.storeList_.append(storeLocator.Panel.NO_STORES_IN_VIEW_HTML_); } var clickHandler = function() { view.highlight(this['store'], true); }; // TODO(cbro): change 10 to a setting/option for (var i = 0, ii = Math.min(10, stores.length); i < ii; i++) { var storeLi = stores[i].getInfoPanelItem(); storeLi['store'] = stores[i]; if (selectedStore && stores[i].getId() == selectedStore.getId()) { $(storeLi).addClass('highlighted'); } if (!storeLi.clickHandler_) { storeLi.clickHandler_ = google.maps.event.addDomListener( storeLi, 'click', clickHandler); } that.storeList_.append(storeLi); } }; /** * Handler for selectedStore_changed. Highlights the selected store in the * store list. * @this storeLocator.Panel */ storeLocator.Panel.prototype.selectedStore_changed = function() { $('.highlighted', this.storeList_).removeClass('highlighted'); var that = this; var store = this.get('selectedStore'); if (!store) { return; } this.directionsTo_ = store; this.storeList_.find('#store-' + store.getId()).addClass('highlighted'); if (this.settings_['directions']) { this.directionsPanel_.find('.directions-to') .val(store.getDetails().title); } var node = that.get('view').getInfoWindow().getContent(); var directionsLink = $('<a/>') .text('Directions') .attr('href', '#') .addClass('action') .addClass('directions'); // TODO(cbro): Make these two permanent fixtures in InfoWindow. // Move out of Panel. var zoomLink = $('<a/>') .text('Zoom here') .attr('href', '#') .addClass('action') .addClass('zoomhere'); var streetViewLink = $('<a/>') .text('Street view') .attr('href', '#') .addClass('action') .addClass('streetview'); directionsLink.click(function() { that.showDirections(); return false; }); zoomLink.click(function() { that.get('view').getMap().setOptions({ center: store.getLocation(), zoom: 16 }); }); streetViewLink.click(function() { var streetView = that.get('view').getMap().getStreetView(); streetView.setPosition(store.getLocation()); streetView.setVisible(true); }); $(node).append(directionsLink).append(zoomLink).append(streetViewLink); }; /** * Hides the directions panel. */ storeLocator.Panel.prototype.hideDirections = function() { this.directionsVisible_ = false; this.directionsPanel_.fadeOut(); this.featureFilter_.fadeIn(); this.storeList_.fadeIn(); this.directionsRenderer_.setMap(null); }; /** * Shows directions to the selected store. */ storeLocator.Panel.prototype.showDirections = function() { var store = this.get('selectedStore'); this.featureFilter_.fadeOut(); this.storeList_.fadeOut(); this.directionsPanel_.find('.directions-to').val(store.getDetails().title); this.directionsPanel_.fadeIn(); this.renderDirections_(); this.directionsVisible_ = true; }; /** * Renders directions from the location in the input box, to the store that is * pre-filled in the 'to' box. * @private */ storeLocator.Panel.prototype.renderDirections_ = function() { var that = this; if (!this.directionsFrom_ || !this.directionsTo_) { return; } var rendered = this.directionsPanel_.find('.rendered-directions').empty(); this.directionsService_.route({ origin: this.directionsFrom_, destination: this.directionsTo_.getLocation(), travelMode: google.maps['DirectionsTravelMode'].DRIVING //TODO(cbro): region biasing, waypoints, travelmode }, function(result, status) { if (status != google.maps.DirectionsStatus.OK) { // TODO(cbro): better error handling return; } var renderer = that.directionsRenderer_; renderer.setPanel(rendered[0]); renderer.setMap(that.get('view').getMap()); renderer.setDirections(result); }); }; /** * featureFilter_changed event handler. */ storeLocator.Panel.prototype.featureFilter_changed = function() { this.listenForStoresUpdate_(); }; /** * Fired when searchPosition has been called. This happens when the user has * searched for a location from the location search box and/or autocomplete. * @name storeLocator.Panel#event:geocode * @param {google.maps.PlaceResult|google.maps.GeocoderResult} result * @event */ /** * Fired when the <code>Panel</code>'s <code>view</code> property changes. * @name storeLocator.Panel#event:view_changed * @event */ /** * Fired when the <code>Panel</code>'s <code>featureFilter</code> property * changes. * @name storeLocator.Panel#event:featureFilter_changed * @event */ /** * Fired when the <code>Panel</code>'s <code>stores</code> property changes. * @name storeLocator.Panel#event:stores_changed * @event */ /** * Fired when the <code>Panel</code>'s <code>selectedStore</code> property * changes. * @name storeLocator.Panel#event:selectedStore_changed * @event */ /** * @example see storeLocator.Panel * @interface */ storeLocator.PanelOptions = function() {}; /** * Whether to show the location search box. Default is true. * @type boolean */ storeLocator.prototype.locationSearch; /** * The label to show above the location search box. Default is "Where are you * now?". * @type string */ storeLocator.PanelOptions.prototype.locationSearchLabel; /** * Whether to show the feature filter picker. Default is true. * @type boolean */ storeLocator.PanelOptions.prototype.featureFilter; /** * Whether to provide directions. Deafult is true. * @type boolean */ storeLocator.PanelOptions.prototype.directions; /** * The store locator model to bind to. * @type storeLocator.View */ storeLocator.PanelOptions.prototype.view;
JavaScript
// Copyright 2012 Google Inc. /** * @name Store Locator for Google Maps API V3 * @version 0.1 * @author Chris Broadfoot (Google) * @fileoverview * This library makes it easy to create a fully-featured Store Locator for * your business's website. */ /** * @license * * Copyright 2012 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Namespace for Store Locator. * @constructor */ var storeLocator = function() {}; window['storeLocator'] = storeLocator; /** * Convert from degrees to radians. * @private * @param {number} degrees the number in degrees. * @return {number} the number in radians. */ storeLocator.toRad_ = function(degrees) { return degrees * Math.PI / 180; };
JavaScript
// Copyright 2013 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * Provides access to store data through Google Maps Engine. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * A DataFeed where stores are provided by Google Maps Engine. * <p> * Note: the table that contains the stores needs to be publicly accessible. * @example <pre> * var dataFeed = new storeLocator.GMEDataFeed({ * tableId: '12421761926155747447-06672618218968397709', * apiKey: 'AIzaSyAtunhRg0VTElV-P7n4Agpm9tYlABQDCAM', * propertiesModifier: function(props) { * return { * id: transformId(props.store_id), * title: props.store_title * }; * } * }); * new storeLocator.View(map, dataFeed); * </pre> * @implements storeLocator.DataFeed * @param {!storeLocator.GMEDataFeedOptions} opts the table ID, API key and * a transformation function for feature/store properties. * @constructor * @implements storeLocator_GMEDataFeed */ storeLocator.GMEDataFeed = function(opts) { this.tableId_ = opts['tableId']; this.apiKey_ = opts['apiKey']; if (opts['propertiesModifier']) { this.propertiesModifier_ = opts['propertiesModifier']; } }; storeLocator['GMEDataFeed'] = storeLocator.GMEDataFeed; storeLocator.GMEDataFeed.prototype.getStores = function(bounds, features, callback) { // TODO: use features. var that = this; var center = bounds.getCenter(); var where = '(ST_INTERSECTS(geometry, ' + this.boundsToWkt_(bounds) + ')' + ' OR ST_DISTANCE(geometry, ' + this.latLngToWkt_(center) + ') < 20000)'; var url = 'https://www.googleapis.com/mapsengine/v1/tables/' + this.tableId_ + '/features?callback=?'; $.getJSON(url, { 'key': this.apiKey_, 'where': where, 'version': 'published', 'maxResults': 300 }, function(resp) { var stores = that.parse_(resp); that.sortByDistance_(center, stores); callback(stores); }); }; /** * @private * @param {!google.maps.LatLng} point * @return {string} */ storeLocator.GMEDataFeed.prototype.latLngToWkt_ = function(point) { return 'ST_POINT(' + point.lng() + ', ' + point.lat() + ')'; }; /** * @private * @param {!google.maps.LatLngBounds} bounds * @return {string} */ storeLocator.GMEDataFeed.prototype.boundsToWkt_ = function(bounds) { var ne = bounds.getNorthEast(); var sw = bounds.getSouthWest(); return [ "ST_GEOMFROMTEXT('POLYGON ((", sw.lng(), ' ', sw.lat(), ', ', ne.lng(), ' ', sw.lat(), ', ', ne.lng(), ' ', ne.lat(), ', ', sw.lng(), ' ', ne.lat(), ', ', sw.lng(), ' ', sw.lat(), "))')" ].join(''); }; /** * @private * @param {*} data GeoJSON feature set. * @return {!Array.<!storeLocator.Store>} */ storeLocator.GMEDataFeed.prototype.parse_ = function(data) { if (data['error']) { window.alert(data['error']['message']); return []; } var features = data['features']; if (!features) { return []; } var stores = []; for (var i = 0, row; row = features[i]; i++) { var coordinates = row['geometry']['coordinates']; var position = new google.maps.LatLng(coordinates[1], coordinates[0]); var props = this.propertiesModifier_(row['properties']); var store = new storeLocator.Store(props['id'], position, null, props); stores.push(store); } return stores; }; /** * Default properties modifier. Just returns the same properties passed into * it. Useful if the columns in the GME table are already appropriate. * @private * @param {Object} props * @return {Object} an Object to be passed into the "props" argument in the * Store constructor. */ storeLocator.GMEDataFeed.prototype.propertiesModifier_ = function(props) { return props; }; /** * Sorts a list of given stores by distance from a point in ascending order. * Directly manipulates the given array (has side effects). * @private * @param {google.maps.LatLng} latLng the point to sort from. * @param {!Array.<!storeLocator.Store>} stores the stores to sort. */ storeLocator.GMEDataFeed.prototype.sortByDistance_ = function(latLng, stores) { stores.sort(function(a, b) { return a.distanceTo(latLng) - b.distanceTo(latLng); }); }; /** * @example see storeLocator.GMEDataFeed * @interface */ storeLocator.GMEDataFeedOptions = function() {}; /** * The table's asset ID. * @type string */ storeLocator.GMEDataFeedOptions.prototype.tableId; /** * The API key to use for all requests. * @type string */ storeLocator.GMEDataFeedOptions.prototype.apiKey; /** * A transformation function. The first argument is the feature's properties. * Return an object useful for the <code>"props"</code> argument in the * storeLocator.Store constructor. The default properties modifier * function passes the feature straight through. * <p> * Note: storeLocator.GMEDataFeed expects an <code>"id"</code> property. * @type ?(function(Object): Object) */ storeLocator.GMEDataFeedOptions.prototype.propertiesModifier;
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * Allows developers to specify a static set of stores to be used in the * storelocator. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * A DataFeed with a static set of stores. Provides sorting of stores by * proximity and feature filtering (store must have <em>all</em> features from * the filter). * @example <pre> * var dataFeed = new storeLocator.StaticDataFeed(); * jQuery.getJSON('stores.json', function(json) { * var stores = parseStores(json); * dataFeed.setStores(stores); * }); * new storeLocator.View(map, dataFeed); * </pre> * @implements {storeLocator.DataFeed} * @constructor * @implements storeLocator_StaticDataFeed */ storeLocator.StaticDataFeed = function() { /** * The static list of stores. * @private * @type {Array.<storeLocator.Store>} */ this.stores_ = []; }; storeLocator['StaticDataFeed'] = storeLocator.StaticDataFeed; /** * This will contain a callback to be called if getStores was called before * setStores (i.e. if the map is waiting for data from the data source). * @private * @type {Function} */ storeLocator.StaticDataFeed.prototype.firstCallback_; /** * Set the stores for this data feed. * @param {!Array.<!storeLocator.Store>} stores the stores for this data feed. */ storeLocator.StaticDataFeed.prototype.setStores = function(stores) { this.stores_ = stores; if (this.firstCallback_) { this.firstCallback_(); } else { delete this.firstCallback_; } }; /** * @inheritDoc */ storeLocator.StaticDataFeed.prototype.getStores = function(bounds, features, callback) { // Prevent race condition - if getStores is called before stores are loaded. if (!this.stores_.length) { var that = this; this.firstCallback_ = function() { that.getStores(bounds, features, callback); }; return; } // Filter stores for features. var stores = []; for (var i = 0, store; store = this.stores_[i]; i++) { if (store.hasAllFeatures(features)) { stores.push(store); } } this.sortByDistance_(bounds.getCenter(), stores); callback(stores); }; /** * Sorts a list of given stores by distance from a point in ascending order. * Directly manipulates the given array (has side effects). * @private * @param {google.maps.LatLng} latLng the point to sort from. * @param {!Array.<!storeLocator.Store>} stores the stores to sort. */ storeLocator.StaticDataFeed.prototype.sortByDistance_ = function(latLng, stores) { stores.sort(function(a, b) { return a.distanceTo(latLng) - b.distanceTo(latLng); }); };
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * Store model class for Store Locator library. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Represents a store. * @example <pre> * var latLng = new google.maps.LatLng(40.7585, -73.9861); * var store = new storeLocator.Store('times_square', latLng, null); * </pre> * <pre> * var features = new storeLocator.FeatureSet( * view.getFeatureById('24hour'), * view.getFeatureById('express'), * view.getFeatureById('wheelchair_access')); * * var store = new storeLocator.Store('times_square', latLng, features, { * title: 'Times Square', * address: '1 Times Square&lt;br>Manhattan, NY 10036' * }); * </pre> * <pre> * store.distanceTo(map.getCenter()); * * // override default info window * store.getInfoWindowContent = function() { * var details = this.getDetails(); * return '&lt;h1>' + details.title + '&lt;h1>' + details.address; * }; * </pre> * @param {string} id globally unique id of the store - should be suitable to * use as a HTML id. * @param {!google.maps.LatLng} location location of the store. * @param {storeLocator.FeatureSet} features the features of this store. * @param {Object.<string, *>=} props any additional properties. * <p> Recommended fields are: * 'title', 'address', 'phone', 'misc', 'web'. </p> * @constructor * @implements storeLocator_Store */ storeLocator.Store = function(id, location, features, props) { this.id_ = id; this.location_ = location; this.features_ = features || storeLocator.FeatureSet.NONE; this.props_ = props || {}; }; storeLocator['Store'] = storeLocator.Store; /** * Sets this store's Marker. * @param {google.maps.Marker} marker the marker to set on this store. */ storeLocator.Store.prototype.setMarker = function(marker) { this.marker_ = marker; google.maps.event.trigger(this, 'marker_changed', marker); }; /** * Gets this store's Marker * @return {google.maps.Marker} the store's marker. */ storeLocator.Store.prototype.getMarker = function() { return this.marker_; }; /** * Gets this store's ID. * @return {string} this store's ID. */ storeLocator.Store.prototype.getId = function() { return this.id_; }; /** * Gets this store's location. * @return {google.maps.LatLng} this store's location. */ storeLocator.Store.prototype.getLocation = function() { return this.location_; }; /** * Gets this store's features. * @return {storeLocator.FeatureSet} this store's features. */ storeLocator.Store.prototype.getFeatures = function() { return this.features_; }; /** * Checks whether this store has a particular feature. * @param {!storeLocator.Feature} feature the feature to check for. * @return {boolean} true if the store has the feature, false otherwise. */ storeLocator.Store.prototype.hasFeature = function(feature) { return this.features_.contains(feature); }; /** * Checks whether this store has all the given features. * @param {storeLocator.FeatureSet} features the features to check for. * @return {boolean} true if the store has all features, false otherwise. */ storeLocator.Store.prototype.hasAllFeatures = function(features) { if (!features) { return true; } var featureList = features.asList(); for (var i = 0, ii = featureList.length; i < ii; i++) { if (!this.hasFeature(featureList[i])) { return false; } } return true; }; /** * Gets additional details about this store. * @return {Object} additional properties of this store. */ storeLocator.Store.prototype.getDetails = function() { return this.props_; }; /** * Generates HTML for additional details about this store. * @private * @param {Array.<string>} fields the optional fields of this store to output. * @return {string} html version of additional fields of this store. */ storeLocator.Store.prototype.generateFieldsHTML_ = function(fields) { var html = []; for (var i = 0, ii = fields.length; i < ii; i++) { var prop = fields[i]; if (this.props_[prop]) { html.push('<div class="'); html.push(prop); html.push('">'); html.push(this.props_[prop]); html.push('</div>'); } } return html.join(''); }; /** * Generates a HTML list of this store's features. * @private * @return {string} html list of this store's features. */ storeLocator.Store.prototype.generateFeaturesHTML_ = function() { var html = []; html.push('<ul class="features">'); var featureList = this.features_.asList(); for (var i = 0, feature; feature = featureList[i]; i++) { html.push('<li>'); html.push(feature.getDisplayName()); html.push('</li>'); } html.push('</ul>'); return html.join(''); }; /** * Gets the HTML content for this Store, suitable for use in an InfoWindow. * @return {string} a HTML version of this store. */ storeLocator.Store.prototype.getInfoWindowContent = function() { if (!this.content_) { // TODO(cbro): make this a setting? var fields = ['title', 'address', 'phone', 'misc', 'web']; var html = ['<div class="store">']; html.push(this.generateFieldsHTML_(fields)); html.push(this.generateFeaturesHTML_()); html.push('</div>'); this.content_ = html.join(''); } return this.content_; }; /** * Gets the HTML content for this Store, suitable for use in suitable for use * in the sidebar info panel. * @this storeLocator.Store * @return {string} a HTML version of this store. */ storeLocator.Store.prototype.getInfoPanelContent = function() { return this.getInfoWindowContent(); }; /** * Keep a cache of InfoPanel items (DOM Node), keyed by the store ID. * @private * @type {Object} */ storeLocator.Store.infoPanelCache_ = {}; /** * Gets a HTML element suitable for use in the InfoPanel. * @return {Node} a HTML element. */ storeLocator.Store.prototype.getInfoPanelItem = function() { var cache = storeLocator.Store.infoPanelCache_; var store = this; var key = store.getId(); if (!cache[key]) { var content = store.getInfoPanelContent(); cache[key] = $('<li class="store" id="store-' + store.getId() + '">' + content + '</li>')[0]; } return cache[key]; }; /** * Gets the distance between this Store and a certain location. * @param {google.maps.LatLng} point the point to calculate distance to/from. * @return {number} the distance from this store to a given point. * @license * Latitude/longitude spherical geodesy formulae & scripts * (c) Chris Veness 2002-2010 * www.movable-type.co.uk/scripts/latlong.html */ storeLocator.Store.prototype.distanceTo = function(point) { var R = 6371; // mean radius of earth var location = this.getLocation(); var lat1 = storeLocator.toRad_(location.lat()); var lon1 = storeLocator.toRad_(location.lng()); var lat2 = storeLocator.toRad_(point.lat()); var lon2 = storeLocator.toRad_(point.lng()); var dLat = lat2 - lat1; var dLon = lon2 - lon1; var a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.cos(lat1) * Math.cos(lat2) * Math.sin(dLon / 2) * Math.sin(dLon / 2); var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); return R * c; }; /** * Fired when the <code>Store</code>'s <code>marker</code> property changes. * @name storeLocator.Store#event:marker_changed * @param {google.maps.Marker} marker * @event */
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * FeatureSet class for Store Locator library. A mutable, ordered set of * storeLocator.Features. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * A mutable, ordered set of <code>storeLocator.Feature</code>s. * @example <pre> * var feature1 = new storeLocator.Feature('1', 'Feature One'); * var feature2 = new storeLocator.Feature('2', 'Feature Two'); * var feature3 = new storeLocator.Feature('3', 'Feature Three'); * * var featureSet = new storeLocator.FeatureSet(feature1, feature2, feature3); * </pre> * @param {...storeLocator.Feature} var_args the initial features to add to * the set. * @constructor * @implements storeLocator_FeatureSet */ storeLocator.FeatureSet = function(var_args) { /** * Stores references to the actual Feature. * @private * @type {!Array.<storeLocator.Feature>} */ this.array_ = []; /** * Maps from a Feature's id to its array index. * @private * @type {Object.<string, number>} */ this.hash_ = {}; for (var i = 0, feature; feature = arguments[i]; i++) { this.add(feature); } }; storeLocator['FeatureSet'] = storeLocator.FeatureSet; /** * Adds the given feature to the set, if it doesn't exist in the set already. * Else, removes the feature from the set. * @param {!storeLocator.Feature} feature the feature to toggle. */ storeLocator.FeatureSet.prototype.toggle = function(feature) { if (this.contains(feature)) { this.remove(feature); } else { this.add(feature); } }; /** * Check if a feature exists within this set. * @param {!storeLocator.Feature} feature the feature. * @return {boolean} true if the set contains the given feature. */ storeLocator.FeatureSet.prototype.contains = function(feature) { return feature.getId() in this.hash_; }; /** * Gets a Feature object from the set, by the feature id. * @param {string} featureId the feature's id. * @return {storeLocator.Feature} the feature, if the set contains it. */ storeLocator.FeatureSet.prototype.getById = function(featureId) { if (featureId in this.hash_) { return this.array_[this.hash_[featureId]]; } return null; }; /** * Adds a feature to the set. * @param {storeLocator.Feature} feature the feature to add. */ storeLocator.FeatureSet.prototype.add = function(feature) { if (!feature) { return; } this.array_.push(feature); this.hash_[feature.getId()] = this.array_.length - 1; }; /** * Removes a feature from the set, if it already exists in the set. If it does * not already exist in the set, this function is a no op. * @param {!storeLocator.Feature} feature the feature to remove. */ storeLocator.FeatureSet.prototype.remove = function(feature) { if (!this.contains(feature)) { return; } this.array_[this.hash_[feature.getId()]] = null; delete this.hash_[feature.getId()]; }; /** * Get the contents of this set as an Array. * @return {Array.<!storeLocator.Feature>} the features in the set, in the order * they were inserted. */ storeLocator.FeatureSet.prototype.asList = function() { var filtered = []; for (var i = 0, ii = this.array_.length; i < ii; i++) { var elem = this.array_[i]; if (elem !== null) { filtered.push(elem); } } return filtered; }; /** * Empty feature set. * @type storeLocator.FeatureSet * @const */ storeLocator.FeatureSet.NONE = new storeLocator.FeatureSet;
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * This library makes it easy to create a fully-featured Store Locator for * your business's website. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Data feed that returns stores based on a given bounds and a set of features. * @example <pre> * // always returns the same stores * function SimpleStaticFeed(stores) { * this.stores = stores; * } * SimpleStaticFeed.prototype.getStores = function(bounds, features, callback) { * callback(this.stores); * }; * new storeLocator.View(map, new SimpleStaticFeed()); * </pre> * @interface */ storeLocator.DataFeed = function() {}; storeLocator['DataFeed'] = storeLocator.DataFeed; /** * Fetch stores, based on bounds to search within, and features to filter on. * @param {google.maps.LatLngBounds} bounds the bounds to search within. * @param {storeLocator.FeatureSet} features the features to filter on. * @param {function(Array.<!storeLocator.Store>)} callback the callback * function. */ storeLocator.DataFeed.prototype.getStores = function(bounds, features, callback) {}; /** * The main store locator object. * @example <pre> * new storeLocator.View(map, dataFeed); * </pre> * <pre> * var features = new storeLocator.FeatureSet(feature1, feature2, feature3); * new storeLocator.View(map, dataFeed, { * markerIcon: 'icon.png', * features: features, * geolocation: false * }); * </pre> * <pre> * // refresh stores every 10 seconds, regardless of interaction on the map. * var view = new storeLocator.View(map, dataFeed, { * updateOnPan: false * }); * setTimeout(function() { * view.refreshView(); * }, 10000); * </pre> * <pre> * // custom MarkerOptions, by overriding the createMarker method. * view.createMarker = function(store) { * return new google.maps.Marker({ * position: store.getLocation(), * icon: store.getDetails().icon, * title: store.getDetails().title * }); * }; * </pre> * @extends {google.maps.MVCObject} * @param {google.maps.Map} map the map to operate upon. * @param {storeLocator.DataFeed} data the data feed to fetch stores from. * @param {storeLocator.ViewOptions} opt_options * @constructor * @implements storeLocator_View */ storeLocator.View = function(map, data, opt_options) { this.map_ = map; this.data_ = data; this.settings_ = $.extend({ 'updateOnPan': true, 'geolocation': true, 'features': new storeLocator.FeatureSet }, opt_options); this.init_(); google.maps.event.trigger(this, 'load'); this.set('featureFilter', new storeLocator.FeatureSet); }; storeLocator['View'] = storeLocator.View; storeLocator.View.prototype = new google.maps.MVCObject; /** * Attempt to perform geolocation and pan to the given location * @private */ storeLocator.View.prototype.geolocate_ = function() { var that = this; if (window.navigator && navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(pos) { var loc = new google.maps.LatLng( pos.coords.latitude, pos.coords.longitude); that.getMap().setCenter(loc); that.getMap().setZoom(11); google.maps.event.trigger(that, 'load'); }, undefined, /** @type GeolocationPositionOptions */({ maximumAge: 60 * 1000, timeout: 10 * 1000 })); } }; /** * Initialise the View object * @private */ storeLocator.View.prototype.init_ = function() { if (this.settings_['geolocation']) { this.geolocate_(); } this.markerCache_ = {}; this.infoWindow_ = new google.maps.InfoWindow; var that = this; var map = this.getMap(); this.set('updateOnPan', this.settings_['updateOnPan']); google.maps.event.addListener(this.infoWindow_, 'closeclick', function() { that.highlight(null); }); google.maps.event.addListener(map, 'click', function() { that.highlight(null); that.infoWindow_.close(); }); }; /** * Adds/remove hooks as appropriate. */ storeLocator.View.prototype.updateOnPan_changed = function() { if (this.updateOnPanListener_) { google.maps.event.removeListener(this.updateOnPanListener_); } if (this.get('updateOnPan') && this.getMap()) { var that = this; var map = this.getMap(); this.updateOnPanListener_ = google.maps.event.addListener(map, 'idle', function() { that.refreshView(); }); } }; /** * Add a store to the map. * @param {storeLocator.Store} store the store to add. */ storeLocator.View.prototype.addStoreToMap = function(store) { var marker = this.getMarker(store); store.setMarker(marker); var that = this; marker.clickListener_ = google.maps.event.addListener(marker, 'click', function() { that.highlight(store, false); }); if (marker.getMap() != this.getMap()) { marker.setMap(this.getMap()); } }; /** * Create a marker for a store. * @param {storeLocator.Store} store the store to produce a marker for. * @this storeLocator.View * @return {google.maps.Marker} a new marker. * @export */ storeLocator.View.prototype.createMarker = function(store) { var markerOptions = { position: store.getLocation() }; var opt_icon = this.settings_['markerIcon']; if (opt_icon) { markerOptions.icon = opt_icon; } return new google.maps.Marker(markerOptions); }; /** * Get a marker for a store. By default, this caches the value from * createMarker(store) * @param {storeLocator.Store} store the store to get the marker from. * @return {google.maps.Marker} the marker. */ storeLocator.View.prototype.getMarker = function(store) { var cache = this.markerCache_; var key = store.getId(); if (!cache[key]) { cache[key] = this['createMarker'](store); } return cache[key]; }; /** * Get a InfoWindow for a particular store. * @param {storeLocator.Store} store the store. * @return {google.maps.InfoWindow} the store's InfoWindow. */ storeLocator.View.prototype.getInfoWindow = function(store) { if (!store) { return this.infoWindow_; } var div = $(store.getInfoWindowContent()); this.infoWindow_.setContent(div[0]); return this.infoWindow_; }; /** * Gets all possible features for this View. * @return {storeLocator.FeatureSet} All possible features. */ storeLocator.View.prototype.getFeatures = function() { return this.settings_['features']; }; /** * Gets a feature by its id. Convenience method. * @param {string} id the feature's id. * @return {storeLocator.Feature|undefined} The feature, if the id is valid. * undefined if not. */ storeLocator.View.prototype.getFeatureById = function(id) { if (!this.featureById_) { this.featureById_ = {}; for (var i = 0, feature; feature = this.settings_['features'][i]; i++) { this.featureById_[feature.getId()] = feature; } } return this.featureById_[id]; }; /** * featureFilter_changed event handler. */ storeLocator.View.prototype.featureFilter_changed = function() { google.maps.event.trigger(this, 'featureFilter_changed', this.get('featureFilter')); if (this.get('stores')) { this.clearMarkers(); } }; /** * Clears the visible markers on the map. */ storeLocator.View.prototype.clearMarkers = function() { for (var marker in this.markerCache_) { this.markerCache_[marker].setMap(null); var listener = this.markerCache_[marker].clickListener_; if (listener) { google.maps.event.removeListener(listener); } } }; /** * Refresh the map's view. This will fetch new data based on the map's bounds. */ storeLocator.View.prototype.refreshView = function() { var that = this; this.data_.getStores(this.getMap().getBounds(), /** @type {storeLocator.FeatureSet} */ (this.get('featureFilter')), function(stores) { var oldStores = that.get('stores'); if (oldStores) { for (var i = 0, ii = oldStores.length; i < ii; i++) { google.maps.event.removeListener( oldStores[i].getMarker().clickListener_); } } that.set('stores', stores); }); }; /** * stores_changed event handler. * This will display all new stores on the map. * @this storeLocator.View */ storeLocator.View.prototype.stores_changed = function() { var stores = this.get('stores'); for (var i = 0, store; store = stores[i]; i++) { this.addStoreToMap(store); } }; /** * Gets the view's Map. * @return {google.maps.Map} the view's Map. */ storeLocator.View.prototype.getMap = function() { return this.map_; }; /** * Select a particular store. * @param {storeLocator.Store} store the store to highlight. * @param {boolean=} opt_pan if panning to the store on the map is desired. */ storeLocator.View.prototype.highlight = function(store, opt_pan) { var infoWindow = this.getInfoWindow(store); if (store) { var infoWindow = this.getInfoWindow(store); if (store.getMarker()) { infoWindow.open(this.getMap(), store.getMarker()); } else { infoWindow.setPosition(store.getLocation()); infoWindow.open(this.getMap()); } if (opt_pan) { this.getMap().panTo(store.getLocation()); } if (this.getMap().getStreetView().getVisible()) { this.getMap().getStreetView().setPosition(store.getLocation()); } } else { infoWindow.close(); } this.set('selectedStore', store); }; /** * Re-triggers the selectedStore_changed event with the store as a parameter. * @this storeLocator.View */ storeLocator.View.prototype.selectedStore_changed = function() { google.maps.event.trigger(this, 'selectedStore_changed', this.get('selectedStore')); }; /** * Fired when the <code>View</code> is loaded. This happens once immediately, * then once more if geolocation is successful. * @name storeLocator.View#event:load * @event */ /** * Fired when the <code>View</code>'s <code>featureFilter</code> property * changes. * @name storeLocator.View#event:featureFilter_changed * @event */ /** * Fired when the <code>View</code>'s <code>updateOnPan</code> property changes. * @name storeLocator.View#event:updateOnPan_changed * @event */ /** * Fired when the <code>View</code>'s <code>stores</code> property changes. * @name storeLocator.View#event:stores_changed * @event */ /** * Fired when the <code>View</code>'s <code>selectedStore</code> property * changes. This happens after <code>highlight()</code> is called. * @name storeLocator.View#event:selectedStore_changed * @param {storeLocator.Store} store * @event */ /** * @example see storeLocator.View * @interface */ storeLocator.ViewOptions = function() {}; /** * Whether the map should update stores in the visible area when the visible * area changes. <code>refreshView()</code> will need to be called * programatically. Defaults to true. * @type boolean */ storeLocator.ViewOptions.prototype.updateOnPan; /** * Whether the store locator should attempt to determine the user's location * for the initial view. Defaults to true. * @type boolean */ storeLocator.ViewOptions.prototype.geolocation; /** * All available store features. Defaults to empty FeatureSet. * @type storeLocator.FeatureSet */ storeLocator.ViewOptions.prototype.features; /** * The icon to use for markers representing stores. * @type string|google.maps.MarkerImage */ storeLocator.ViewOptions.prototype.markerIcon;
JavaScript
// Copyright 2012 Google Inc. /** * @author Chris Broadfoot (Google) * @fileoverview * Feature model class for Store Locator library. */ /** * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /** * Representation of a feature of a store. (e.g. 24 hours, BYO, etc). * @example <pre> * var feature = new storeLocator.Feature('24hour', 'Open 24 Hours'); * </pre> * @param {string} id unique identifier for this feature. * @param {string} name display name of this feature. * @constructor * @implements storeLocator_Feature */ storeLocator.Feature = function(id, name) { this.id_ = id; this.name_ = name; }; storeLocator['Feature'] = storeLocator.Feature; /** * Gets this Feature's ID. * @return {string} this feature's ID. */ storeLocator.Feature.prototype.getId = function() { return this.id_; }; /** * Gets this Feature's display name. * @return {string} this feature's display name. */ storeLocator.Feature.prototype.getDisplayName = function() { return this.name_; }; storeLocator.Feature.prototype.toString = function() { return this.getDisplayName(); };
JavaScript
// A simple demo showing how to grab places using the Maps API Places Library. // Useful extensions may include using "name" filtering or "keyword" search. google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('map-canvas'), { center: new google.maps.LatLng(-28, 135), zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }); var panelDiv = document.getElementById('panel'); var data = new PlacesDataSource(map); var view = new storeLocator.View(map, data); var markerSize = new google.maps.Size(24, 24); view.createMarker = function(store) { return new google.maps.Marker({ position: store.getLocation(), icon: new google.maps.MarkerImage(store.getDetails().icon, null, null, null, markerSize) }); }; new storeLocator.Panel(panelDiv, { view: view }); }); /** * Creates a new PlacesDataSource. * @param {google.maps.Map} map * @constructor */ function PlacesDataSource(map) { this.service_ = new google.maps.places.PlacesService(map); } /** * @inheritDoc */ PlacesDataSource.prototype.getStores = function(bounds, features, callback) { this.service_.search({ bounds: bounds }, function(results, status) { var stores = []; for (var i = 0, result; result = results[i]; i++) { var latLng = result.geometry.location; var store = new storeLocator.Store(result.id, latLng, null, { title: result.name, address: result.types.join(', '), icon: result.icon }); stores.push(store); } callback(stores); }); };
JavaScript
google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('map-canvas'), { center: new google.maps.LatLng(-28, 135), zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }); var panelDiv = document.getElementById('panel'); var data = new MedicareDataSource; var view = new storeLocator.View(map, data, { geolocation: false, features: data.getFeatures() }); new storeLocator.Panel(panelDiv, { view: view }); });
JavaScript
google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('map-canvas'), { center: new google.maps.LatLng(-28, 135), zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }); var panelDiv = document.getElementById('panel'); var data = new storeLocator.GMEDataFeed({ tableId: '12421761926155747447-06672618218968397709', apiKey: 'AIzaSyAtunhRg0VTElV-P7n4Agpm9tYlABQDCAM', propertiesModifier: function(props) { var shop = join([props.Shp_num_an, props.Shp_centre], ', '); var locality = join([props.Locality, props.Postcode], ', '); return { id: props.uuid, title: props.Fcilty_nam, address: join([shop, props.Street_add, locality], '<br>'), hours: props.Hrs_of_bus }; } }); var view = new storeLocator.View(map, data, { geolocation: false }); new storeLocator.Panel(panelDiv, { view: view }); }); /** * Joins elements of an array that are non-empty and non-null. * @private * @param {!Array} arr array of elements to join. * @param {string} sep the separator. * @return {string} */ function join(arr, sep) { var parts = []; for (var i = 0, ii = arr.length; i < ii; i++) { arr[i] && parts.push(arr[i]); } return parts.join(sep); }
JavaScript
// Store locator with customisations // - custom marker // - custom info window (using Info Bubble) // - custom info window content (+ store hours) var ICON = new google.maps.MarkerImage('medicare.png', null, null, new google.maps.Point(14, 13)); var SHADOW = new google.maps.MarkerImage('medicare-shadow.png', null, null, new google.maps.Point(14, 13)); google.maps.event.addDomListener(window, 'load', function() { var map = new google.maps.Map(document.getElementById('map-canvas'), { center: new google.maps.LatLng(-28, 135), zoom: 4, mapTypeId: google.maps.MapTypeId.ROADMAP }); var panelDiv = document.getElementById('panel'); var data = new MedicareDataSource; var view = new storeLocator.View(map, data, { geolocation: false, features: data.getFeatures() }); view.createMarker = function(store) { var markerOptions = { position: store.getLocation(), icon: ICON, shadow: SHADOW, title: store.getDetails().title }; return new google.maps.Marker(markerOptions); } var infoBubble = new InfoBubble; view.getInfoWindow = function(store) { if (!store) { return infoBubble; } var details = store.getDetails(); var html = ['<div class="store"><div class="title">', details.title, '</div><div class="address">', details.address, '</div>', '<div class="hours misc">', details.hours, '</div></div>'].join(''); infoBubble.setContent($(html)[0]); return infoBubble; }; new storeLocator.Panel(panelDiv, { view: view }); });
JavaScript
/** * @extends storeLocator.StaticDataFeed * @constructor */ function MedicareDataSource() { $.extend(this, new storeLocator.StaticDataFeed); var that = this; $.get('medicare.csv', function(data) { that.setStores(that.parse_(data)); }); } /** * @const * @type {!storeLocator.FeatureSet} * @private */ MedicareDataSource.prototype.FEATURES_ = new storeLocator.FeatureSet( new storeLocator.Feature('Wheelchair-YES', 'Wheelchair access'), new storeLocator.Feature('Audio-YES', 'Audio') ); /** * @return {!storeLocator.FeatureSet} */ MedicareDataSource.prototype.getFeatures = function() { return this.FEATURES_; }; /** * @private * @param {string} csv * @return {!Array.<!storeLocator.Store>} */ MedicareDataSource.prototype.parse_ = function(csv) { var stores = []; var rows = csv.split('\n'); var headings = this.parseRow_(rows[0]); for (var i = 1, row; row = rows[i]; i++) { row = this.toObject_(headings, this.parseRow_(row)); var features = new storeLocator.FeatureSet; features.add(this.FEATURES_.getById('Wheelchair-' + row.Wheelchair)); features.add(this.FEATURES_.getById('Audio-' + row.Audio)); var position = new google.maps.LatLng(row.Ycoord, row.Xcoord); var shop = this.join_([row.Shp_num_an, row.Shp_centre], ', '); var locality = this.join_([row.Locality, row.Postcode], ', '); var store = new storeLocator.Store(row.uuid, position, features, { title: row.Fcilty_nam, address: this.join_([shop, row.Street_add, locality], '<br>'), hours: row.Hrs_of_bus }); stores.push(store); } return stores; }; /** * Joins elements of an array that are non-empty and non-null. * @private * @param {!Array} arr array of elements to join. * @param {string} sep the separator. * @return {string} */ MedicareDataSource.prototype.join_ = function(arr, sep) { var parts = []; for (var i = 0, ii = arr.length; i < ii; i++) { arr[i] && parts.push(arr[i]); } return parts.join(sep); }; /** * Very rudimentary CSV parsing - we know how this particular CSV is formatted. * IMPORTANT: Don't use this for general CSV parsing! * @private * @param {string} row * @return {Array.<string>} */ MedicareDataSource.prototype.parseRow_ = function(row) { // Strip leading quote. if (row.charAt(0) == '"') { row = row.substring(1); } // Strip trailing quote. There seems to be a character between the last quote // and the line ending, hence 2 instead of 1. if (row.charAt(row.length - 2) == '"') { row = row.substring(0, row.length - 2); } row = row.split('","'); return row; }; /** * Creates an object mapping headings to row elements. * @private * @param {Array.<string>} headings * @param {Array.<string>} row * @return {Object} */ MedicareDataSource.prototype.toObject_ = function(headings, row) { var result = {}; for (var i = 0, ii = row.length; i < ii; i++) { result[headings[i]] = row[i]; } return result; };
JavaScript
/** * @implements storeLocator.DataFeed * @constructor */ function MedicareDataSource() { } MedicareDataSource.prototype.getStores = function(bounds, features, callback) { var that = this; var center = bounds.getCenter(); var audioFeature = this.FEATURES_.getById('Audio-YES'); var wheelchairFeature = this.FEATURES_.getById('Wheelchair-YES'); var where = '(ST_INTERSECTS(geometry, ' + this.boundsToWkt_(bounds) + ')' + ' OR ST_DISTANCE(geometry, ' + this.latLngToWkt_(center) + ') < 20000)'; if (features.contains(audioFeature)) { where += " AND Audio='YES'"; } if (features.contains(wheelchairFeature)) { where += " AND Wheelchair='YES'"; } var tableId = '12421761926155747447-06672618218968397709'; var url = 'https://www.googleapis.com/mapsengine/v1/tables/' + tableId + '/features?callback=?'; $.getJSON(url, { key: 'AIzaSyAtunhRg0VTElV-P7n4Agpm9tYlABQDCAM', where: where, version: 'published', maxResults: 300 }, function(resp) { var stores = that.parse_(resp); that.sortByDistance_(center, stores); callback(stores); }); }; MedicareDataSource.prototype.latLngToWkt_ = function(point) { return 'ST_POINT(' + point.lng() + ', ' + point.lat() + ')'; }; MedicareDataSource.prototype.boundsToWkt_ = function(bounds) { var ne = bounds.getNorthEast(); var sw = bounds.getSouthWest(); return [ "ST_GEOMFROMTEXT('POLYGON ((", sw.lng(), ' ', sw.lat(), ', ', ne.lng(), ' ', sw.lat(), ', ', ne.lng(), ' ', ne.lat(), ', ', sw.lng(), ' ', ne.lat(), ', ', sw.lng(), ' ', sw.lat(), "))')" ].join(''); }; MedicareDataSource.prototype.parse_ = function(data) { var stores = []; for (var i = 0, row; row = data.features[i]; i++) { var props = row.properties; var features = new storeLocator.FeatureSet; features.add(this.FEATURES_.getById('Wheelchair-' + props.Wheelchair)); features.add(this.FEATURES_.getById('Audio-' + props.Audio)); var position = new google.maps.LatLng(row.geometry.coordinates[1], row.geometry.coordinates[0]); var shop = this.join_([props.Shp_num_an, props.Shp_centre], ', '); var locality = this.join_([props.Locality, props.Postcode], ', '); var store = new storeLocator.Store(props.uuid, position, features, { title: props.Fcilty_nam, address: this.join_([shop, props.Street_add, locality], '<br>'), hours: props.Hrs_of_bus }); stores.push(store); } return stores; }; /** * @const * @type {!storeLocator.FeatureSet} * @private */ MedicareDataSource.prototype.FEATURES_ = new storeLocator.FeatureSet( new storeLocator.Feature('Wheelchair-YES', 'Wheelchair access'), new storeLocator.Feature('Audio-YES', 'Audio') ); /** * @return {!storeLocator.FeatureSet} */ MedicareDataSource.prototype.getFeatures = function() { return this.FEATURES_; }; /** * Joins elements of an array that are non-empty and non-null. * @private * @param {!Array} arr array of elements to join. * @param {string} sep the separator. * @return {string} */ MedicareDataSource.prototype.join_ = function(arr, sep) { var parts = []; for (var i = 0, ii = arr.length; i < ii; i++) { arr[i] && parts.push(arr[i]); } return parts.join(sep); }; /** * Sorts a list of given stores by distance from a point in ascending order. * Directly manipulates the given array (has side effects). * @private * @param {google.maps.LatLng} latLng the point to sort from. * @param {!Array.<!storeLocator.Store>} stores the stores to sort. */ MedicareDataSource.prototype.sortByDistance_ = function(latLng, stores) { stores.sort(function(a, b) { return a.distanceTo(latLng) - b.distanceTo(latLng); }); };
JavaScript
/** @interface */ function storeLocator_Feature() {}; storeLocator_Feature.prototype.getId = function(var_args) {}; storeLocator_Feature.prototype.getDisplayName = function(var_args) {}; /** @interface */ function storeLocator_FeatureSet() {}; storeLocator_FeatureSet.prototype.toggle = function(var_args) {}; storeLocator_FeatureSet.prototype.contains = function(var_args) {}; storeLocator_FeatureSet.prototype.getById = function(var_args) {}; storeLocator_FeatureSet.prototype.add = function(var_args) {}; storeLocator_FeatureSet.prototype.remove = function(var_args) {}; storeLocator_FeatureSet.prototype.asList = function(var_args) {}; /** @interface */ function storeLocator_GMEDataFeed() {}; /** @interface */ function storeLocator_Panel() {}; storeLocator_Panel.prototype.searchPosition = function(var_args) {}; storeLocator_Panel.prototype.setView = function(var_args) {}; storeLocator_Panel.prototype.view_changed = function(var_args) {}; storeLocator_Panel.prototype.stores_changed = function(var_args) {}; storeLocator_Panel.prototype.selectedStore_changed = function(var_args) {}; storeLocator_Panel.prototype.hideDirections = function(var_args) {}; storeLocator_Panel.prototype.showDirections = function(var_args) {}; storeLocator_Panel.prototype.featureFilter_changed = function(var_args) {}; /** @interface */ function storeLocator_StaticDataFeed() {}; storeLocator_StaticDataFeed.prototype.setStores = function(var_args) {}; storeLocator_StaticDataFeed.prototype.getStores = function(var_args) {}; /** @interface */ function storeLocator_Store() {}; storeLocator_Store.prototype.setMarker = function(var_args) {}; storeLocator_Store.prototype.getMarker = function(var_args) {}; storeLocator_Store.prototype.getId = function(var_args) {}; storeLocator_Store.prototype.getLocation = function(var_args) {}; storeLocator_Store.prototype.getFeatures = function(var_args) {}; storeLocator_Store.prototype.hasFeature = function(var_args) {}; storeLocator_Store.prototype.hasAllFeatures = function(var_args) {}; storeLocator_Store.prototype.getDetails = function(var_args) {}; storeLocator_Store.prototype.getInfoWindowContent = function(var_args) {}; storeLocator_Store.prototype.getInfoPanelContent = function(var_args) {}; storeLocator_Store.prototype.getInfoPanelItem = function(var_args) {}; storeLocator_Store.prototype.distanceTo = function(var_args) {}; /** @interface */ function storeLocator_View() {}; storeLocator_View.prototype.updateOnPan_changed = function(var_args) {}; storeLocator_View.prototype.addStoreToMap = function(var_args) {}; storeLocator_View.prototype.createMarker = function(var_args) {}; storeLocator_View.prototype.getMarker = function(var_args) {}; storeLocator_View.prototype.getInfoWindow = function(var_args) {}; storeLocator_View.prototype.getFeatures = function(var_args) {}; storeLocator_View.prototype.getFeatureById = function(var_args) {}; storeLocator_View.prototype.featureFilter_changed = function(var_args) {}; storeLocator_View.prototype.clearMarkers = function(var_args) {}; storeLocator_View.prototype.refreshView = function(var_args) {}; storeLocator_View.prototype.stores_changed = function(var_args) {}; storeLocator_View.prototype.getMap = function(var_args) {}; storeLocator_View.prototype.highlight = function(var_args) {}; storeLocator_View.prototype.selectedStore_changed = function(var_args) {};
JavaScript
$(window).load(function(){ $("#featured").orbit(); }); $(function(){ $(".panel").hover(function(){ $(this).find(".repo__top").show(); },function(){ $(this).find(".repo__top").hide(); }); }); $(function() { var $sidebar = $("#gkInset"), $window = $(window), offset = $sidebar.offset(), topPadding = 15; $window.scroll(function() { if ($window.scrollTop() > offset.top) { $sidebar.stop().animate({ marginTop: $window.scrollTop() - offset.top + topPadding }); } else { $sidebar.stop().animate({ marginTop: 0 }); } }); }); $(document).ready(function(){ $("#go_www").hover(function(){ $(this).addClass("hover_bg"); $(this).children("div").show(); },function(){ $(this).removeClass("hover_bg"); $(this).children("div").hide(); }) }) $(document).ready(function(){ $("#go_m").hover(function(){ $(this).addClass("hover_bg"); $(this).children("div").show(); },function(){ $(this).removeClass("hover_bg"); $(this).children("div").hide(); }) }) $(function(){ $(".panel").hover(function(){ $(this).find(".repo__top").show(); },function(){ $(this).find(".repo__top").hide(); }); });
JavaScript
window.addEvent('domready', function(){ // add loader if(document.id('gkPage').getChildren('.box').length > 2) { var content = document.id('gkPage').getChildren('.box')[0]; var base = document.id('gkPage').getChildren('.box')[1]; var width = document.id('gkPage').getSize().x - content.getSize().x; if(width < base.getSize().x) { // full width var loader = new Element('div', { 'html': '<div>'+document.body.getProperty('data-loading-translation')+'</div>', 'class': 'box gkSidebarPreloader gkPreloaderFullWidth' }); loader.inject(content, 'after'); } else { // other width var loader = new Element('div', { 'html': '<div>'+$(document.body).getProperty('data-loading-translation')+'</div>', 'class': 'box gkSidebarPreloader' }); loader.inject(content, 'after'); } } // smooth anchor scrolling new SmoothScroll(); // style area if(document.id('gkStyleArea')){ $$('#gkStyleArea a').each(function(element,index){ element.addEvent('click',function(e){ e.stop(); changeStyle(index+1); }); }); } // font-size switcher if(document.id('gkTools') && document.id('gkMainbody')) { var current_fs = 100; var content_fx = new Fx.Tween(document.id('gkMainbody'), { property: 'font-size', unit: '%', duration: 200 }).set(100); document.id('gkToolsInc').addEvent('click', function(e){ e.stop(); if(current_fs < 150) { content_fx.start(current_fs + 10); current_fs += 10; } }); document.id('gkToolsReset').addEvent('click', function(e){ e.stop(); content_fx.start(100); current_fs = 100; }); document.id('gkToolsDec').addEvent('click', function(e){ e.stop(); if(current_fs > 70) { content_fx.start(current_fs - 10); current_fs -= 10; } }); } // K2 font-size switcher fix if(document.id('fontIncrease') && document.getElement('.itemIntroText')) { document.id('fontIncrease').addEvent('click', function() { document.getElement('.itemIntroText').set('class', 'itemIntroText largerFontSize'); }); document.id('fontDecrease').addEvent('click', function() { document.getElement('.itemIntroText').set('class', 'itemIntroText smallerFontSize'); }); } // Tablet menu button if(document.id('gkTabletMenu') && document.id('gkInset')) { document.id('gkTabletMenu').addEvent('click', function() { document.id('gkInset').toggleClass('visible'); }); } // login popup if(document.id('gkPopupLogin')) { var popup_overlay = document.id('gkPopupOverlay'); popup_overlay.setStyles({'display': 'block', 'opacity': '0'}); popup_overlay.fade('out'); var opened_popup = null; var popup_login = null; var popup_login_h = null; var popup_login_fx = null; if(document.id('gkPopupLogin') && document.getElement('.gkmenu .login')) { popup_login = document.id('gkPopupLogin'); popup_login.setStyle('display', 'block'); popup_login_h = popup_login.getElement('.gkPopupWrap').getSize().y; popup_login_fx = new Fx.Morph(popup_login, {duration:200, transition: Fx.Transitions.Circ.easeInOut}).set({'opacity': 0, 'height': 0 }); document.getElement('.gkmenu .login').addEvent('click', function(e) { new Event(e).stop(); popup_overlay.fade(0.45); popup_login_fx.start({'opacity':1, 'height': popup_login_h}); opened_popup = 'login'; (function() { if(document.id('modlgn-username')) { document.id('modlgn-username').focus(); } }).delay(600); }); } popup_overlay.addEvent('click', function() { if(opened_popup == 'login') { popup_overlay.fade('out'); popup_login_fx.start({ 'opacity' : 0, 'height' : 0 }); } }); } }); // initial animation window.addEvent('load', function() { var boxes = []; document.id('gkPage').getElements('.box').each(function(box, i){ if(i > 0 && box.getParent().getAttribute('id') == 'gkPage') { boxes.push(box); } }); if(boxes.length > 0) { boxes[0].addClass('loaded'); if(boxes[0].hasClass('gkSidebarPreloader')) { (function() { boxes[0].destroy(); boxes[0] = false; }).delay(500); (function() { boxes.each(function(box, i) { if(box) { (function() { box.addClass('loaded'); }).delay(i * 100); } }); }).delay(600); } } }); // function to set cookie function setCookie(c_name, value, expire) { var exdate=new Date(); exdate.setDate(exdate.getDate()+expire); document.cookie=c_name+ "=" +escape(value) + ((expire==null) ? "" : ";expires=" + exdate.toUTCString()); } // Function to change styles function changeStyle(style){ var file1 = $GK_TMPL_URL+'/css/style'+style+'.css'; var file2 = $GK_TMPL_URL+'/css/typography/typography.style'+style+'.css'; var file3 = $GK_TMPL_URL+'/css/typography/typography.iconset.style'+style+'.css'; var file4 = $GK_TMPL_URL+'/css/style'+style+'.fonts.css'; new Asset.css(file1); new Asset.css(file2); new Asset.css(file3); new Asset.css(file4); Cookie.write('gk_fashion_j25_style', style, { duration:365, path: '/' }); }
JavaScript
function playVideo(sourceId, targetId) { if (typeof(sourceId)=='string') {sourceId=document.getElementById(sourceId);} if (typeof(targetId)=='string') {targetId=document.getElementById(targetId);} targetId.innerHTML=sourceId.innerHTML; return false; }
JavaScript
/**** the images grow/shrink ****/ // how many milliseconds we should wait between resizing events var resizeDelay = 10; // how many pixels we should grow or shrink by each time we resize var resizeIncrement = 5; // this will hold information about the images we're dealing with var imgCache = new Object(); /** The getCacheTag function just creates a (hopefully) unique identifier for each <img> that we resize. */ function getCacheTag (imgElement) { return imgElement.src + "~" + imgElement.offsetLeft + "~" + imgElement.offsetTop; } /** We're using this as a class to hold information about the <img> elements that we're manipulating. */ function cachedImg (imgElement, increment) { this.img = imgElement; this.cacheTag = getCacheTag(imgElement); this.originalSrc = imgElement.src; var h = imgElement.height; var w = imgElement.width; this.originalHeight = h; this.originalWidth = w; increment = (!increment) ? resizeIncrement : increment; this.heightIncrement = Math.ceil(Math.min(1, (h / w)) * increment); this.widthIncrement = Math.ceil(Math.min(1, (w / h)) * increment); } /** This is the function that should be called in the onMouseOver and onMouseOut events of an <img> element. For example: <img src='onesmaller.gif' onMouseOver='resizeImg(this, 150, "onebigger.gif")' onMouseOut='resizeImg(this)'> The only required parameter is the first one (imgElement), which is a reference to the <img> element itself. If you're calling from onMousexxx, you can just use "this" as the value. The second parameter specifies how much larger or smaller we should resize the image to, as a percentage of the original size. In the example above, we want to resize it to be 150% larger. If this parameter is omitted, we'll assume you want to resize the image to its original size (100%). The third parameter can specify another image that should be used as the image is being resized (it's common for "rollover images" to be similar but slightly different or more colorful than the base images). If this parameter is omitted, we'll just resize the existing image. */ function resizeImg (imgElement, percentChange, newImageURL) { // convert the percentage (like 150) to an percentage value we can use // for calculations (like 1.5) var pct = (percentChange) ? percentChange / 100 : 1; // if we've already resized this image, it will have a "cacheTag" attribute // that should uniquely identify it. If the attribute is missing, create a // cacheTag and add the attribute var cacheTag = imgElement.getAttribute("cacheTag"); if (!cacheTag) { cacheTag = getCacheTag(imgElement); imgElement.setAttribute("cacheTag", cacheTag); } // look for this image in our image cache. If it's not there, create it. // If it is there, update the percentage value. var cacheVal = imgCache[cacheTag]; if (!cacheVal) { imgCache[cacheTag] = new Array(new cachedImg(imgElement), pct); } else { cacheVal[1] = pct; } // if we're supposed to be using a rollover image, use it if (newImageURL) imgElement.src = newImageURL; // start the resizing loop. It will continue to call itself over and over // until the image has been resized to the proper value. resizeImgLoop(cacheTag); return true; } /** This is the function that actually does all the resizing. It calls itself repeatedly with setTimeout until the image is the right size. */ function resizeImgLoop (cacheTag) { // get information about the image element from the image cache var cacheVal = imgCache[cacheTag]; if (!cacheVal) return false; var cachedImageObj = cacheVal[0]; var imgElement = cachedImageObj.img; var pct = cacheVal[1]; var plusMinus = (pct > 1) ? 1 : -1; var hinc = plusMinus * cachedImageObj.heightIncrement; var vinc = plusMinus * cachedImageObj.widthIncrement; var startHeight = cachedImageObj.originalHeight; var startWidth = cachedImageObj.originalWidth; var currentHeight = imgElement.height; var currentWidth = imgElement.width; var endHeight = Math.round(startHeight * pct); var endWidth = Math.round(startWidth * pct); // if the image is already the right size, we can exit if ( (currentHeight == endHeight) || (currentWidth == endWidth) ) return true; // increase or decrease the height and width, making sure we don't get // larger or smaller than the final size we're supposed to be var newHeight = currentHeight + hinc; var newWidth = currentWidth + vinc; if (pct > 1) { if ((newHeight >= endHeight) || (newWidth >= endWidth)) { newHeight = endHeight; newWidth = endWidth; } } else { if ((newHeight <= endHeight) || (newWidth <= endWidth)) { newHeight = endHeight; newWidth = endWidth; } } // set the image element to the new height and width imgElement.height = newHeight; imgElement.width = newWidth; // if we've returned to the original image size, we can restore the // original image as well (because we may have been using a rollover // image in the original call to resizeImg) if ((newHeight == cachedImageObj.originalHeight) || (newWidth == cachedImageObj.originalwidth)) { imgElement.src = cachedImageObj.originalSrc; } // shrink or grow again in a few milliseconds setTimeout("resizeImgLoop('" + cacheTag + "')", resizeDelay); }
JavaScript
new TWTR.Widget({ version: 2, type: 'profile', rpp: 5, interval: 30000, width: 275, height: 110, theme: { shell: { background: '#333333', color: '#ffffff' }, tweets: { background: '#000000', color: '#ffffff', links: '#07eb44' } }, features: { scrollbar: true, loop: false, live: false, hashtags: true, timestamp: true, avatars: true, behavior: 'all' } }).render().setUser('thereggez').start();
JavaScript
/** * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/ * * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License: * http://www.opensource.org/licenses/mit-license.php * */ if(typeof deconcept == "undefined") var deconcept = new Object(); if(typeof deconcept.util == "undefined") deconcept.util = new Object(); if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object(); deconcept.SWFObject = function(swf, id, w, h, ver, c, quality, xiRedirectUrl, redirectUrl, detectKey) { if (!document.getElementById) { return; } this.DETECT_KEY = detectKey ? detectKey : 'detectflash'; this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); this.params = new Object(); this.variables = new Object(); this.attributes = new Array(); if(swf) { this.setAttribute('swf', swf); } if(id) { this.setAttribute('id', id); } if(w) { this.setAttribute('width', w); } if(h) { this.setAttribute('height', h); } if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); } this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(); if (!window.opera && document.all && this.installedVer.major > 7) { // only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE deconcept.SWFObject.doPrepUnload = true; } if(c) { this.addParam('bgcolor', c); } var q = quality ? quality : 'high'; this.addParam('quality', q); this.setAttribute('useExpressInstall', false); this.setAttribute('doExpressInstall', false); var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location; this.setAttribute('xiRedirectUrl', xir); this.setAttribute('redirectUrl', ''); if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); } } deconcept.SWFObject.prototype = { useExpressInstall: function(path) { this.xiSWFPath = !path ? "expressinstall.swf" : path; this.setAttribute('useExpressInstall', true); }, setAttribute: function(name, value){ this.attributes[name] = value; }, getAttribute: function(name){ return this.attributes[name]; }, addParam: function(name, value){ this.params[name] = value; }, getParams: function(){ return this.params; }, addVariable: function(name, value){ this.variables[name] = value; }, getVariable: function(name){ return this.variables[name]; }, getVariables: function(){ return this.variables; }, getVariablePairs: function(){ var variablePairs = new Array(); var key; var variables = this.getVariables(); for(key in variables){ variablePairs[variablePairs.length] = key +"="+ variables[key]; } return variablePairs; }, getSWFHTML: function() { var swfNode = ""; if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); this.setAttribute('swf', this.xiSWFPath); } swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'"'; swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" '; var params = this.getParams(); for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; } var pairs = this.getVariablePairs().join("&"); if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; } swfNode += '/>'; } else { // PC IE if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); this.setAttribute('swf', this.xiSWFPath); } swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" style="'+ this.getAttribute('style') +'">'; swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />'; var params = this.getParams(); for(var key in params) { swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />'; } var pairs = this.getVariablePairs().join("&"); if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';} swfNode += "</object>"; } return swfNode; }, write: function(elementId){ if(this.getAttribute('useExpressInstall')) { // check to see if we need to do an express install var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]); if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) { this.setAttribute('doExpressInstall', true); this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl'))); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; this.addVariable("MMdoctitle", document.title); } } if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){ var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId; n.innerHTML = this.getSWFHTML(); return true; }else{ if(this.getAttribute('redirectUrl') != "") { document.location.replace(this.getAttribute('redirectUrl')); } } return false; } } /* ---- detection functions ---- */ deconcept.SWFObjectUtil.getPlayerVersion = function(){ var PlayerVersion = new deconcept.PlayerVersion([0,0,0]); if(navigator.plugins && navigator.mimeTypes.length){ var x = navigator.plugins["Shockwave Flash"]; if(x && x.description) { PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); } }else if (navigator.userAgent && navigator.userAgent.indexOf("Windows CE") >= 0){ // if Windows CE var axo = 1; var counter = 3; while(axo) { try { counter++; axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+ counter); // document.write("player v: "+ counter); PlayerVersion = new deconcept.PlayerVersion([counter,0,0]); } catch (e) { axo = null; } } } else { // Win IE (non mobile) // do minor version lookup in IE, but avoid fp6 crashing issues // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ try{ var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); }catch(e){ try { var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); PlayerVersion = new deconcept.PlayerVersion([6,0,21]); axo.AllowScriptAccess = "always"; // error if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code) } catch(e) { if (PlayerVersion.major == 6) { return PlayerVersion; } } try { axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); } catch(e) {} } if (axo != null) { PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); } } return PlayerVersion; } deconcept.PlayerVersion = function(arrVersion){ this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0; this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0; this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0; } deconcept.PlayerVersion.prototype.versionIsValid = function(fv){ if(this.major < fv.major) return false; if(this.major > fv.major) return true; if(this.minor < fv.minor) return false; if(this.minor > fv.minor) return true; if(this.rev < fv.rev) return false; return true; } /* ---- get value of query string param ---- */ deconcept.util = { getRequestParameter: function(param) { var q = document.location.search || document.location.hash; if (param == null) { return q; } if(q) { var pairs = q.substring(1).split("&"); for (var i=0; i < pairs.length; i++) { if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) { return pairs[i].substring((pairs[i].indexOf("=")+1)); } } } return ""; } } /* fix for video streaming bug */ deconcept.SWFObjectUtil.cleanupSWFs = function() { var objects = document.getElementsByTagName("OBJECT"); for (var i = objects.length - 1; i >= 0; i--) { objects[i].style.display = 'none'; for (var x in objects[i]) { if (typeof objects[i][x] == 'function') { objects[i][x] = function(){}; } } } } // fixes bug in some fp9 versions see http://blog.deconcept.com/2006/07/28/swfobject-143-released/ if (deconcept.SWFObject.doPrepUnload) { if (!deconcept.unloadSet) { deconcept.SWFObjectUtil.prepUnload = function() { __flash_unloadHandler = function(){}; __flash_savedUnloadHandler = function(){}; window.attachEvent("onunload", deconcept.SWFObjectUtil.cleanupSWFs); } window.attachEvent("onbeforeunload", deconcept.SWFObjectUtil.prepUnload); deconcept.unloadSet = true; } } /* add document.getElementById if needed (mobile IE < 5) */ if (!document.getElementById && document.all) { document.getElementById = function(id) { return document.all[id]; }} /* add some aliases for ease of use/backwards compatibility */ var getQueryParamValue = deconcept.util.getRequestParameter; var FlashObject = deconcept.SWFObject; // for legacy support var SWFObject = deconcept.SWFObject;
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.skins.add( 'kama', (function() { var uiColorStylesheetId = 'cke_ui_color'; return { editor : { css : [ 'editor.css' ] }, dialog : { css : [ 'dialog.css' ] }, templates : { css : [ 'templates.css' ] }, margins : [ 0, 0, 0, 0 ], init : function( editor ) { if ( editor.config.width && !isNaN( editor.config.width ) ) editor.config.width -= 12; var uiColorMenus = []; var uiColorRegex = /\$color/g; var uiColorMenuCss = "/* UI Color Support */\ .cke_skin_kama .cke_menuitem .cke_icon_wrapper\ {\ background-color: $color !important;\ border-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuitem a:hover .cke_icon_wrapper,\ .cke_skin_kama .cke_menuitem a:focus .cke_icon_wrapper,\ .cke_skin_kama .cke_menuitem a:active .cke_icon_wrapper\ {\ background-color: $color !important;\ border-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuitem a:hover .cke_label,\ .cke_skin_kama .cke_menuitem a:focus .cke_label,\ .cke_skin_kama .cke_menuitem a:active .cke_label\ {\ background-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_label,\ .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_label,\ .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_label\ {\ background-color: transparent !important;\ }\ \ .cke_skin_kama .cke_menuitem a.cke_disabled:hover .cke_icon_wrapper,\ .cke_skin_kama .cke_menuitem a.cke_disabled:focus .cke_icon_wrapper,\ .cke_skin_kama .cke_menuitem a.cke_disabled:active .cke_icon_wrapper\ {\ background-color: $color !important;\ border-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuitem a.cke_disabled .cke_icon_wrapper\ {\ background-color: $color !important;\ border-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuseparator\ {\ background-color: $color !important;\ }\ \ .cke_skin_kama .cke_menuitem a:hover,\ .cke_skin_kama .cke_menuitem a:focus,\ .cke_skin_kama .cke_menuitem a:active\ {\ background-color: $color !important;\ }"; // We have to split CSS declarations for webkit. if ( CKEDITOR.env.webkit ) { uiColorMenuCss = uiColorMenuCss.split( '}' ).slice( 0, -1 ); for ( var i = 0 ; i < uiColorMenuCss.length ; i++ ) uiColorMenuCss[ i ] = uiColorMenuCss[ i ].split( '{' ); } function getStylesheet( document ) { var node = document.getById( uiColorStylesheetId ); if ( !node ) { node = document.getHead().append( 'style' ); node.setAttribute( "id", uiColorStylesheetId ); node.setAttribute( "type", "text/css" ); } return node; } function updateStylesheets( styleNodes, styleContent, replace ) { var r, i, content; for ( var id = 0 ; id < styleNodes.length ; id++ ) { if ( CKEDITOR.env.webkit ) { for ( i = 0 ; i < styleContent.length ; i++ ) { content = styleContent[ i ][ 1 ]; for ( r = 0 ; r < replace.length ; r++ ) content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] ); styleNodes[ id ].$.sheet.addRule( styleContent[ i ][ 0 ], content ); } } else { content = styleContent; for ( r = 0 ; r < replace.length ; r++ ) content = content.replace( replace[ r ][ 0 ], replace[ r ][ 1 ] ); if ( CKEDITOR.env.ie ) styleNodes[ id ].$.styleSheet.cssText += content; else styleNodes[ id ].$.innerHTML += content; } } } var uiColorRegexp = /\$color/g; CKEDITOR.tools.extend( editor, { uiColor: null, getUiColor : function() { return this.uiColor; }, setUiColor : function( color ) { var cssContent, uiStyle = getStylesheet( CKEDITOR.document ), cssId = '.' + editor.id; var cssSelectors = [ cssId + " .cke_wrapper", cssId + "_dialog .cke_dialog_contents", cssId + "_dialog a.cke_dialog_tab", cssId + "_dialog .cke_dialog_footer" ].join( ',' ); var cssProperties = "background-color: $color !important;"; if ( CKEDITOR.env.webkit ) cssContent = [ [ cssSelectors, cssProperties ] ]; else cssContent = cssSelectors + '{' + cssProperties + '}'; return ( this.setUiColor = function( color ) { var replace = [ [ uiColorRegexp, color ] ]; editor.uiColor = color; // Update general style. updateStylesheets( [ uiStyle ], cssContent, replace ); // Update menu styles. updateStylesheets( uiColorMenus, uiColorMenuCss, replace ); })( color ); } }); editor.on( 'menuShow', function( event ) { var panel = event.data[ 0 ]; var iframe = panel.element.getElementsByTag( 'iframe' ).getItem( 0 ).getFrameDocument(); // Add stylesheet if missing. if ( !iframe.getById( 'cke_ui_color' ) ) { var node = getStylesheet( iframe ); uiColorMenus.push( node ); var color = editor.getUiColor(); // Set uiColor for new menu. if ( color ) updateStylesheets( [ node ], uiColorMenuCss, [ [ uiColorRegexp, color ] ] ); } }); // Apply UI color if specified in config. if ( editor.config.uiColor ) editor.setUiColor( editor.config.uiColor ); } }; })() ); (function() { CKEDITOR.dialog ? dialogSetup() : CKEDITOR.on( 'dialogPluginReady', dialogSetup ); function dialogSetup() { CKEDITOR.dialog.on( 'resize', function( evt ) { var data = evt.data, width = data.width, height = data.height, dialog = data.dialog, contents = dialog.parts.contents; if ( data.skin != 'kama' ) return; contents.setStyles( { width : width + 'px', height : height + 'px' }); // Fix the size of the elements which have flexible lengths. setTimeout( function() { var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ), body = innerDialog.getChild( 0 ); // tc var el = innerDialog.getChild( 2 ); el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' ); // bc el = innerDialog.getChild( 7 ); el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' ); // ml el = innerDialog.getChild( 4 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); // mr el = innerDialog.getChild( 5 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); }, 100 ); }); } })(); /** * The base user interface color to be used by the editor. Not all skins are * compatible with this setting. * @name CKEDITOR.config.uiColor * @type String * @default '' (empty) * @example * // Using a color code. * config.uiColor = '#AADC6E'; * @example * // Using an HTML color name. * config.uiColor = 'Gold'; */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.skins.add( 'v2', (function() { return { editor : { css : [ 'editor.css' ] }, dialog : { css : [ 'dialog.css' ] }, templates : { css : [ 'templates.css' ] }, margins : [ 0, 14, 18, 14 ] }; })() ); (function() { CKEDITOR.dialog ? dialogSetup() : CKEDITOR.on( 'dialogPluginReady', dialogSetup ); function dialogSetup() { CKEDITOR.dialog.on( 'resize', function( evt ) { var data = evt.data, width = data.width, height = data.height, dialog = data.dialog, contents = dialog.parts.contents; if ( data.skin != 'v2' ) return; contents.setStyles( { width : width + 'px', height : height + 'px' }); if ( !CKEDITOR.env.ie ) return; // Fix the size of the elements which have flexible lengths. setTimeout( function() { var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ), body = innerDialog.getChild( 0 ); // tc var el = innerDialog.getChild( 2 ); el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' ); // bc el = innerDialog.getChild( 7 ); el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' ); // ml el = innerDialog.getChild( 4 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); // mr el = innerDialog.getChild( 5 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); }, 100 ); }); } })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.skins.add( 'office2003', (function() { return { editor : { css : [ 'editor.css' ] }, dialog : { css : [ 'dialog.css' ] }, templates : { css : [ 'templates.css' ] }, margins : [ 0, 14, 18, 14 ] }; })() ); (function() { CKEDITOR.dialog ? dialogSetup() : CKEDITOR.on( 'dialogPluginReady', dialogSetup ); function dialogSetup() { CKEDITOR.dialog.on( 'resize', function( evt ) { var data = evt.data, width = data.width, height = data.height, dialog = data.dialog, contents = dialog.parts.contents; if ( data.skin != 'office2003' ) return; contents.setStyles( { width : width + 'px', height : height + 'px' }); if ( !CKEDITOR.env.ie ) return; // Fix the size of the elements which have flexible lengths. var fixSize = function() { var innerDialog = dialog.parts.dialog.getChild( [ 0, 0, 0 ] ), body = innerDialog.getChild( 0 ); // tc var el = innerDialog.getChild( 2 ); el.setStyle( 'width', ( body.$.offsetWidth ) + 'px' ); // bc el = innerDialog.getChild( 7 ); el.setStyle( 'width', ( body.$.offsetWidth - 28 ) + 'px' ); // ml el = innerDialog.getChild( 4 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); // mr el = innerDialog.getChild( 5 ); el.setStyle( 'height', ( height + body.getChild(0).$.offsetHeight ) + 'px' ); }; setTimeout( fixSize, 100 ); // Ensure size is correct for RTL mode. (#4003) if ( evt.editor.lang.dir == 'rtl' ) setTimeout( fixSize, 1000 ); }); } })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Contains the second part of the {@link CKEDITOR} object * definition, which defines the basic editor features to be available in * the root ckeditor_basic.js file. */ if ( CKEDITOR.status == 'unloaded' ) { (function() { CKEDITOR.event.implementOn( CKEDITOR ); /** * Forces the full CKEditor core code, in the case only the basic code has been * loaded (ckeditor_basic.js). This method self-destroys (becomes undefined) in * the first call or as soon as the full code is available. * @example * // Check if the full core code has been loaded and load it. * if ( CKEDITOR.loadFullCore ) * <b>CKEDITOR.loadFullCore()</b>; */ CKEDITOR.loadFullCore = function() { // If not the basic code is not ready it, just mark it to be loaded. if ( CKEDITOR.status != 'basic_ready' ) { CKEDITOR.loadFullCore._load = 1; return; } // Destroy this function. delete CKEDITOR.loadFullCore; // Append the script to the head. var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = CKEDITOR.basePath + 'ckeditor.js'; document.getElementsByTagName( 'head' )[0].appendChild( script ); }; /** * The time to wait (in seconds) to load the full editor code after the * page load, if the "ckeditor_basic" file is used. If set to zero, the * editor is loaded on demand, as soon as an instance is created. * * This value must be set on the page before the page load completion. * @type Number * @default 0 (zero) * @example * // Loads the full source after five seconds. * CKEDITOR.loadFullCoreTimeout = 5; */ CKEDITOR.loadFullCoreTimeout = 0; /** * The class name used to identify &lt;textarea&gt; elements to be replace * by CKEditor instances. * @type String * @default 'ckeditor' * @example * <b>CKEDITOR.replaceClass</b> = 'rich_editor'; */ CKEDITOR.replaceClass = 'ckeditor'; /** * Enables the replacement of all textareas with class name matching * {@link CKEDITOR.replaceClass}. * @type Boolean * @default true * @example * // Disable the auto-replace feature. * <b>CKEDITOR.replaceByClassEnabled</b> = false; */ CKEDITOR.replaceByClassEnabled = 1; var createInstance = function( elementOrIdOrName, config, creationFunction, data ) { if ( CKEDITOR.env.isCompatible ) { // Load the full core. if ( CKEDITOR.loadFullCore ) CKEDITOR.loadFullCore(); var editor = creationFunction( elementOrIdOrName, config, data ); CKEDITOR.add( editor ); return editor; } return null; }; /** * Replaces a &lt;textarea&gt; or a DOM element (DIV) with a CKEditor * instance. For textareas, the initial value in the editor will be the * textarea value. For DOM elements, their innerHTML will be used * instead. We recommend using TEXTAREA and DIV elements only. * @param {Object|String} elementOrIdOrName The DOM element (textarea), its * ID or name. * @param {Object} [config] The specific configurations to apply to this * editor instance. Configurations set here will override global CKEditor * settings. * @returns {CKEDITOR.editor} The editor instance created. * @example * &lt;textarea id="myfield" name="myfield"&gt;&lt:/textarea&gt; * ... * <b>CKEDITOR.replace( 'myfield' )</b>; * @example * var textarea = document.body.appendChild( document.createElement( 'textarea' ) ); * <b>CKEDITOR.replace( textarea )</b>; */ CKEDITOR.replace = function( elementOrIdOrName, config ) { return createInstance( elementOrIdOrName, config, CKEDITOR.editor.replace ); }; /** * Creates a new editor instance inside a specific DOM element. * @param {Object|String} elementOrId The DOM element or its ID. * @param {Object} [config] The specific configurations to apply to this * editor instance. Configurations set here will override global CKEditor * settings. * @param {String} [data] Since 3.3. Initial value for the instance. * @returns {CKEDITOR.editor} The editor instance created. * @example * &lt;div id="editorSpace"&gt;&lt:/div&gt; * ... * <b>CKEDITOR.appendTo( 'editorSpace' )</b>; */ CKEDITOR.appendTo = function( elementOrId, config, data ) { return createInstance( elementOrId, config, CKEDITOR.editor.appendTo, data ); }; // Documented at ckeditor.js. CKEDITOR.add = function( editor ) { // For now, just put the editor in the pending list. It will be // processed as soon as the full code gets loaded. var pending = this._.pending || ( this._.pending = [] ); pending.push( editor ); }; /** * Replace all &lt;textarea&gt; elements available in the document with * editor instances. * @example * // Replace all &lt;textarea&gt; elements in the page. * CKEDITOR.replaceAll(); * @example * // Replace all &lt;textarea class="myClassName"&gt; elements in the page. * CKEDITOR.replaceAll( 'myClassName' ); * @example * // Selectively replace &lt;textarea&gt; elements, based on custom assertions. * CKEDITOR.replaceAll( function( textarea, config ) * { * // Custom code to evaluate the replace, returning false * // if it must not be done. * // It also passes the "config" parameter, so the * // developer can customize the instance. * } ); */ CKEDITOR.replaceAll = function() { var textareas = document.getElementsByTagName( 'textarea' ); for ( var i = 0 ; i < textareas.length ; i++ ) { var config = null, textarea = textareas[i], name = textarea.name; // The "name" and/or "id" attribute must exist. if ( !textarea.name && !textarea.id ) continue; if ( typeof arguments[0] == 'string' ) { // The textarea class name could be passed as the function // parameter. var classRegex = new RegExp( '(?:^|\\s)' + arguments[0] + '(?:$|\\s)' ); if ( !classRegex.test( textarea.className ) ) continue; } else if ( typeof arguments[0] == 'function' ) { // An assertion function could be passed as the function parameter. // It must explicitly return "false" to ignore a specific <textarea>. config = {}; if ( arguments[0]( textarea, config ) === false ) continue; } this.replace( textarea, config ); } }; (function() { var onload = function() { var loadFullCore = CKEDITOR.loadFullCore, loadFullCoreTimeout = CKEDITOR.loadFullCoreTimeout; // Replace all textareas with the default class name. if ( CKEDITOR.replaceByClassEnabled ) CKEDITOR.replaceAll( CKEDITOR.replaceClass ); CKEDITOR.status = 'basic_ready'; if ( loadFullCore && loadFullCore._load ) loadFullCore(); else if ( loadFullCoreTimeout ) { setTimeout( function() { if ( CKEDITOR.loadFullCore ) CKEDITOR.loadFullCore(); } , loadFullCoreTimeout * 1000 ); } }; if ( window.addEventListener ) window.addEventListener( 'load', onload, false ); else if ( window.attachEvent ) window.attachEvent( 'onload', onload ); })(); CKEDITOR.status = 'basic_loaded'; })(); }
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dtd} object, which holds the DTD * mapping for XHTML 1.0 Transitional. This file was automatically * generated from the file: xhtml1-transitional.dtd. */ /** * @namespace Holds and object representation of the HTML DTD to be used by the * editor in its internal operations.<br /> * <br /> * Each element in the DTD is represented by a property in this object. Each * property contains the list of elements that can be contained by the element. * Text is represented by the "#" property.<br /> * <br /> * Several special grouping properties are also available. Their names start * with the "$" character. * @example * // Check if "div" can be contained in a "p" element. * alert( !!CKEDITOR.dtd[ 'p' ][ 'div' ] ); "false" * @example * // Check if "p" can be contained in a "div" element. * alert( !!CKEDITOR.dtd[ 'div' ][ 'p' ] ); "true" * @example * // Check if "p" is a block element. * alert( !!CKEDITOR.dtd.$block[ 'p' ] ); "true" */ CKEDITOR.dtd = (function() { var X = CKEDITOR.tools.extend, A = {isindex:1,fieldset:1}, B = {input:1,button:1,select:1,textarea:1,label:1}, C = X({a:1},B), D = X({iframe:1},C), E = {hr:1,ul:1,menu:1,div:1,blockquote:1,noscript:1,table:1,center:1,address:1,dir:1,pre:1,h5:1,dl:1,h4:1,noframes:1,h6:1,ol:1,h1:1,h3:1,h2:1}, F = {ins:1,del:1,script:1,style:1}, G = X({b:1,acronym:1,bdo:1,'var':1,'#':1,abbr:1,code:1,br:1,i:1,cite:1,kbd:1,u:1,strike:1,s:1,tt:1,strong:1,q:1,samp:1,em:1,dfn:1,span:1},F), H = X({sub:1,img:1,object:1,sup:1,basefont:1,map:1,applet:1,font:1,big:1,small:1},G), I = X({p:1},H), J = X({iframe:1},H,B), K = {img:1,noscript:1,br:1,kbd:1,center:1,button:1,basefont:1,h5:1,h4:1,samp:1,h6:1,ol:1,h1:1,h3:1,h2:1,form:1,font:1,'#':1,select:1,menu:1,ins:1,abbr:1,label:1,code:1,table:1,script:1,cite:1,input:1,iframe:1,strong:1,textarea:1,noframes:1,big:1,small:1,span:1,hr:1,sub:1,bdo:1,'var':1,div:1,object:1,sup:1,strike:1,dir:1,map:1,dl:1,applet:1,del:1,isindex:1,fieldset:1,ul:1,b:1,acronym:1,a:1,blockquote:1,i:1,u:1,s:1,tt:1,address:1,q:1,pre:1,p:1,em:1,dfn:1}, L = X({a:1},J), M = {tr:1}, N = {'#':1}, O = X({param:1},K), P = X({form:1},A,D,E,I), Q = {li:1}, R = {style:1,script:1}, S = {base:1,link:1,meta:1,title:1}, T = X(S,R), U = {head:1,body:1}, V = {html:1}; var block = {address:1,blockquote:1,center:1,dir:1,div:1,dl:1,fieldset:1,form:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,hr:1,isindex:1,menu:1,noframes:1,ol:1,p:1,pre:1,table:1,ul:1}; return /** @lends CKEDITOR.dtd */ { // The "$" items have been added manually. // List of elements living outside body. $nonBodyContent: X(V,U,S), /** * List of block elements, like "p" or "div". * @type Object * @example */ $block : block, /** * List of block limit elements. * @type Object * @example */ $blockLimit : { body:1,div:1,td:1,th:1,caption:1,form:1 }, /** * List of inline (&lt;span&gt; like) elements. */ $inline : L, // Just like span. /** * list of elements that can be children at &lt;body&gt;. */ $body : X({script:1,style:1}, block), $cdata : {script:1,style:1}, /** * List of empty (self-closing) elements, like "br" or "img". * @type Object * @example */ $empty : {area:1,base:1,br:1,col:1,hr:1,img:1,input:1,link:1,meta:1,param:1}, /** * List of list item elements, like "li" or "dd". * @type Object * @example */ $listItem : {dd:1,dt:1,li:1}, /** * List of list root elements. * @type Object * @example */ $list: { ul:1,ol:1,dl:1}, /** * Elements that accept text nodes, but are not possible to edit into * the browser. * @type Object * @example */ $nonEditable : {applet:1,button:1,embed:1,iframe:1,map:1,object:1,option:1,script:1,textarea:1,param:1}, /** * List of elements that can be ignored if empty, like "b" or "span". * @type Object * @example */ $removeEmpty : {abbr:1,acronym:1,address:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,s:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1}, /** * List of elements that have tabindex set to zero by default. * @type Object * @example */ $tabIndex : {a:1,area:1,button:1,input:1,object:1,select:1,textarea:1}, /** * List of elements used inside the "table" element, like "tbody" or "td". * @type Object * @example */ $tableContent : {caption:1,col:1,colgroup:1,tbody:1,td:1,tfoot:1,th:1,thead:1,tr:1}, html: U, head: T, style: N, script: N, body: P, base: {}, link: {}, meta: {}, title: N, col : {}, tr : {td:1,th:1}, img : {}, colgroup : {col:1}, noscript : P, td : P, br : {}, th : P, center : P, kbd : L, button : X(I,E), basefont : {}, h5 : L, h4 : L, samp : L, h6 : L, ol : Q, h1 : L, h3 : L, option : N, h2 : L, form : X(A,D,E,I), select : {optgroup:1,option:1}, font : L, ins : L, menu : Q, abbr : L, label : L, table : {thead:1,col:1,tbody:1,tr:1,colgroup:1,caption:1,tfoot:1}, code : L, script : N, tfoot : M, cite : L, li : P, input : {}, iframe : P, strong : L, textarea : N, noframes : P, big : L, small : L, span : L, hr : {}, dt : L, sub : L, optgroup : {option:1}, param : {}, bdo : L, 'var' : L, div : P, object : O, sup : L, dd : P, strike : L, area : {}, dir : Q, map : X({area:1,form:1,p:1},A,F,E), applet : O, dl : {dt:1,dd:1}, del : L, isindex : {}, fieldset : X({legend:1},K), thead : M, ul : Q, acronym : L, b : L, a : J, blockquote : P, caption : L, i : L, u : L, tbody : M, s : L, address : X(D,I), tt : L, legend : L, q : L, pre : X(G,C), p : L, em : L, dfn : L }; })(); // PACKAGER_RENAME( CKEDITOR.dtd )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * Creates a {@link CKEDITOR.htmlParser} class instance. * @class Provides an "event like" system to parse strings of HTML data. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onTagOpen = function( tagName, attributes, selfClosing ) * { * alert( tagName ); * }; * parser.parse( '&lt;p&gt;Some &lt;b&gt;text&lt;/b&gt;.&lt;/p&gt;' ); */ CKEDITOR.htmlParser = function() { this._ = { htmlPartsRegex : new RegExp( '<(?:(?:\\/([^>]+)>)|(?:!--([\\S|\\s]*?)-->)|(?:([^\\s>]+)\\s*((?:(?:[^"\'>]+)|(?:"[^"]*")|(?:\'[^\']*\'))*)\\/?>))', 'g' ) }; }; (function() { var attribsRegex = /([\w\-:.]+)(?:(?:\s*=\s*(?:(?:"([^"]*)")|(?:'([^']*)')|([^\s>]+)))|(?=\s|$))/g, emptyAttribs = {checked:1,compact:1,declare:1,defer:1,disabled:1,ismap:1,multiple:1,nohref:1,noresize:1,noshade:1,nowrap:1,readonly:1,selected:1}; CKEDITOR.htmlParser.prototype = { /** * Function to be fired when a tag opener is found. This function * should be overriden when using this class. * @param {String} tagName The tag name. The name is guarantted to be * lowercased. * @param {Object} attributes An object containing all tag attributes. Each * property in this object represent and attribute name and its * value is the attribute value. * @param {Boolean} selfClosing true if the tag closes itself, false if the * tag doesn't. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onTagOpen = function( tagName, attributes, selfClosing ) * { * alert( tagName ); // e.g. "b" * }); * parser.parse( "&lt;!-- Example --&gt;&lt;b&gt;Hello&lt;/b&gt;" ); */ onTagOpen : function() {}, /** * Function to be fired when a tag closer is found. This function * should be overriden when using this class. * @param {String} tagName The tag name. The name is guarantted to be * lowercased. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onTagClose = function( tagName ) * { * alert( tagName ); // e.g. "b" * }); * parser.parse( "&lt;!-- Example --&gt;&lt;b&gt;Hello&lt;/b&gt;" ); */ onTagClose : function() {}, /** * Function to be fired when text is found. This function * should be overriden when using this class. * @param {String} text The text found. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onText = function( text ) * { * alert( text ); // e.g. "Hello" * }); * parser.parse( "&lt;!-- Example --&gt;&lt;b&gt;Hello&lt;/b&gt;" ); */ onText : function() {}, /** * Function to be fired when CDATA section is found. This function * should be overriden when using this class. * @param {String} cdata The CDATA been found. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onCDATA = function( cdata ) * { * alert( cdata ); // e.g. "var hello;" * }); * parser.parse( "&lt;script&gt;var hello;&lt;/script&gt;" ); */ onCDATA : function() {}, /** * Function to be fired when a commend is found. This function * should be overriden when using this class. * @param {String} comment The comment text. * @example * var parser = new CKEDITOR.htmlParser(); * parser.onComment = function( comment ) * { * alert( comment ); // e.g. " Example " * }); * parser.parse( "&lt;!-- Example --&gt;&lt;b&gt;Hello&lt;/b&gt;" ); */ onComment : function() {}, /** * Parses text, looking for HTML tokens, like tag openers or closers, * or comments. This function fires the onTagOpen, onTagClose, onText * and onComment function during its execution. * @param {String} html The HTML to be parsed. * @example * var parser = new CKEDITOR.htmlParser(); * // The onTagOpen, onTagClose, onText and onComment should be overriden * // at this point. * parser.parse( "&lt;!-- Example --&gt;&lt;b&gt;Hello&lt;/b&gt;" ); */ parse : function( html ) { var parts, tagName, nextIndex = 0, cdata; // The collected data inside a CDATA section. while ( ( parts = this._.htmlPartsRegex.exec( html ) ) ) { var tagIndex = parts.index; if ( tagIndex > nextIndex ) { var text = html.substring( nextIndex, tagIndex ); if ( cdata ) cdata.push( text ); else this.onText( text ); } nextIndex = this._.htmlPartsRegex.lastIndex; /* "parts" is an array with the following items: 0 : The entire match for opening/closing tags and comments. 1 : Group filled with the tag name for closing tags. 2 : Group filled with the comment text. 3 : Group filled with the tag name for opening tags. 4 : Group filled with the attributes part of opening tags. */ // Closing tag if ( ( tagName = parts[ 1 ] ) ) { tagName = tagName.toLowerCase(); if ( cdata && CKEDITOR.dtd.$cdata[ tagName ] ) { // Send the CDATA data. this.onCDATA( cdata.join('') ); cdata = null; } if ( !cdata ) { this.onTagClose( tagName ); continue; } } // If CDATA is enabled, just save the raw match. if ( cdata ) { cdata.push( parts[ 0 ] ); continue; } // Opening tag if ( ( tagName = parts[ 3 ] ) ) { tagName = tagName.toLowerCase(); // There are some tag names that can break things, so let's // simply ignore them when parsing. (#5224) if ( /="/.test( tagName ) ) continue; var attribs = {}, attribMatch, attribsPart = parts[ 4 ], selfClosing = !!( attribsPart && attribsPart.charAt( attribsPart.length - 1 ) == '/' ); if ( attribsPart ) { while ( ( attribMatch = attribsRegex.exec( attribsPart ) ) ) { var attName = attribMatch[1].toLowerCase(), attValue = attribMatch[2] || attribMatch[3] || attribMatch[4] || ''; if ( !attValue && emptyAttribs[ attName ] ) attribs[ attName ] = attName; else attribs[ attName ] = attValue; } } this.onTagOpen( tagName, attribs, selfClosing ); // Open CDATA mode when finding the appropriate tags. if ( !cdata && CKEDITOR.dtd.$cdata[ tagName ] ) cdata = []; continue; } // Comment if ( ( tagName = parts[ 2 ] ) ) this.onComment( tagName ); } if ( html.length > nextIndex ) this.onText( html.substring( nextIndex, html.length ) ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.resourceManager} class, which is * the base for resource managers, like plugins and themes. */ /** * Base class for resource managers, like plugins and themes. This class is not * intended to be used out of the CKEditor core code. * @param {String} basePath The path for the resources folder. * @param {String} fileName The name used for resource files. * @namespace * @example */ CKEDITOR.resourceManager = function( basePath, fileName ) { /** * The base directory containing all resources. * @name CKEDITOR.resourceManager.prototype.basePath * @type String * @example */ this.basePath = basePath; /** * The name used for resource files. * @name CKEDITOR.resourceManager.prototype.fileName * @type String * @example */ this.fileName = fileName; /** * Contains references to all resources that have already been registered * with {@link #add}. * @name CKEDITOR.resourceManager.prototype.registered * @type Object * @example */ this.registered = {}; /** * Contains references to all resources that have already been loaded * with {@link #load}. * @name CKEDITOR.resourceManager.prototype.loaded * @type Object * @example */ this.loaded = {}; /** * Contains references to all resources that have already been registered * with {@link #addExternal}. * @name CKEDITOR.resourceManager.prototype.externals * @type Object * @example */ this.externals = {}; /** * @private */ this._ = { // List of callbacks waiting for plugins to be loaded. waitingList : {} }; }; CKEDITOR.resourceManager.prototype = { /** * Registers a resource. * @param {String} name The resource name. * @param {Object} [definition] The resource definition. * @example * CKEDITOR.plugins.add( 'sample', { ... plugin definition ... } ); * @see CKEDITOR.pluginDefinition */ add : function( name, definition ) { if ( this.registered[ name ] ) throw '[CKEDITOR.resourceManager.add] The resource name "' + name + '" is already registered.'; CKEDITOR.fire( name + CKEDITOR.tools.capitalize( this.fileName ) + 'Ready', this.registered[ name ] = definition || {} ); }, /** * Gets the definition of a specific resource. * @param {String} name The resource name. * @type Object * @example * var definition = <b>CKEDITOR.plugins.get( 'sample' )</b>; */ get : function( name ) { return this.registered[ name ] || null; }, /** * Get the folder path for a specific loaded resource. * @param {String} name The resource name. * @type String * @example * alert( <b>CKEDITOR.plugins.getPath( 'sample' )</b> ); // "&lt;editor path&gt;/plugins/sample/" */ getPath : function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( ( external && external.dir ) || this.basePath + name + '/' ); }, /** * Get the file path for a specific loaded resource. * @param {String} name The resource name. * @type String * @example * alert( <b>CKEDITOR.plugins.getFilePath( 'sample' )</b> ); // "&lt;editor path&gt;/plugins/sample/plugin.js" */ getFilePath : function( name ) { var external = this.externals[ name ]; return CKEDITOR.getUrl( this.getPath( name ) + ( ( external && ( typeof external.file == 'string' ) ) ? external.file : this.fileName + '.js' ) ); }, /** * Registers one or more resources to be loaded from an external path * instead of the core base path. * @param {String} names The resource names, separated by commas. * @param {String} path The path of the folder containing the resource. * @param {String} [fileName] The resource file name. If not provided, the * default name is used; If provided with a empty string, will implicitly indicates that {@param path} * is already the full path. * @example * // Loads a plugin from '/myplugin/samples/plugin.js'. * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/' ); * @example * // Loads a plugin from '/myplugin/samples/my_plugin.js'. * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/', 'my_plugin.js' ); * @example * // Loads a plugin from '/myplugin/samples/my_plugin.js'. * CKEDITOR.plugins.addExternal( 'sample', '/myplugins/sample/my_plugin.js', '' ); */ addExternal : function( names, path, fileName ) { names = names.split( ',' ); for ( var i = 0 ; i < names.length ; i++ ) { var name = names[ i ]; this.externals[ name ] = { dir : path, file : fileName }; } }, /** * Loads one or more resources. * @param {String|Array} name The name of the resource to load. It may be a * string with a single resource name, or an array with several names. * @param {Function} callback A function to be called when all resources * are loaded. The callback will receive an array containing all * loaded names. * @param {Object} [scope] The scope object to be used for the callback * call. * @example * <b>CKEDITOR.plugins.load</b>( 'myplugin', function( plugins ) * { * alert( plugins['myplugin'] ); // "object" * }); */ load : function( names, callback, scope ) { // Ensure that we have an array of names. if ( !CKEDITOR.tools.isArray( names ) ) names = names ? [ names ] : []; var loaded = this.loaded, registered = this.registered, urls = [], urlsNames = {}, resources = {}; // Loop through all names. for ( var i = 0 ; i < names.length ; i++ ) { var name = names[ i ]; if ( !name ) continue; // If not available yet. if ( !loaded[ name ] && !registered[ name ] ) { var url = this.getFilePath( name ); urls.push( url ); if ( !( url in urlsNames ) ) urlsNames[ url ] = []; urlsNames[ url ].push( name ); } else resources[ name ] = this.get( name ); } CKEDITOR.scriptLoader.load( urls, function( completed, failed ) { if ( failed.length ) { throw '[CKEDITOR.resourceManager.load] Resource name "' + urlsNames[ failed[ 0 ] ].join( ',' ) + '" was not found at "' + failed[ 0 ] + '".'; } for ( var i = 0 ; i < completed.length ; i++ ) { var nameList = urlsNames[ completed[ i ] ]; for ( var j = 0 ; j < nameList.length ; j++ ) { var name = nameList[ j ]; resources[ name ] = this.get( name ); loaded[ name ] = 1; } } callback.call( scope, resources ); } , this); } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.event} class, which serves as the * base for classes and objects that require event handling features. */ if ( !CKEDITOR.event ) { /** * Creates an event class instance. This constructor is rearely used, being * the {@link #.implementOn} function used in class prototypes directly * instead. * @class This is a base class for classes and objects that require event * handling features.<br /> * <br /> * Do not confuse this class with {@link CKEDITOR.dom.event} which is * instead used for DOM events. The CKEDITOR.event class implements the * internal event system used by the CKEditor to fire API related events. * @example */ CKEDITOR.event = function() {}; /** * Implements the {@link CKEDITOR.event} features in an object. * @param {Object} targetObject The object into which implement the features. * @example * var myObject = { message : 'Example' }; * <b>CKEDITOR.event.implementOn( myObject }</b>; * myObject.on( 'testEvent', function() * { * alert( this.message ); // "Example" * }); * myObject.fire( 'testEvent' ); */ CKEDITOR.event.implementOn = function( targetObject ) { var eventProto = CKEDITOR.event.prototype; for ( var prop in eventProto ) { if ( targetObject[ prop ] == undefined ) targetObject[ prop ] = eventProto[ prop ]; } }; CKEDITOR.event.prototype = (function() { // Returns the private events object for a given object. var getPrivate = function( obj ) { var _ = ( obj.getPrivate && obj.getPrivate() ) || obj._ || ( obj._ = {} ); return _.events || ( _.events = {} ); }; var eventEntry = function( eventName ) { this.name = eventName; this.listeners = []; }; eventEntry.prototype = { // Get the listener index for a specified function. // Returns -1 if not found. getListenerIndex : function( listenerFunction ) { for ( var i = 0, listeners = this.listeners ; i < listeners.length ; i++ ) { if ( listeners[i].fn == listenerFunction ) return i; } return -1; } }; return /** @lends CKEDITOR.event.prototype */ { /** * Registers a listener to a specific event in the current object. * @param {String} eventName The event name to which listen. * @param {Function} listenerFunction The function listening to the * event. A single {@link CKEDITOR.eventInfo} object instanced * is passed to this function containing all the event data. * @param {Object} [scopeObj] The object used to scope the listener * call (the this object. If omitted, the current object is used. * @param {Object} [listenerData] Data to be sent as the * {@link CKEDITOR.eventInfo#listenerData} when calling the * listener. * @param {Number} [priority] The listener priority. Lower priority * listeners are called first. Listeners with the same priority * value are called in registration order. Defaults to 10. * @example * someObject.on( 'someEvent', function() * { * alert( this == someObject ); // "true" * }); * @example * someObject.on( 'someEvent', function() * { * alert( this == anotherObject ); // "true" * } * , anotherObject ); * @example * someObject.on( 'someEvent', function( event ) * { * alert( event.listenerData ); // "Example" * } * , null, 'Example' ); * @example * someObject.on( 'someEvent', function() { ... } ); // 2nd called * someObject.on( 'someEvent', function() { ... }, null, null, 100 ); // 3rd called * someObject.on( 'someEvent', function() { ... }, null, null, 1 ); // 1st called */ on : function( eventName, listenerFunction, scopeObj, listenerData, priority ) { // Get the event entry (create it if needed). var events = getPrivate( this ), event = events[ eventName ] || ( events[ eventName ] = new eventEntry( eventName ) ); if ( event.getListenerIndex( listenerFunction ) < 0 ) { // Get the listeners. var listeners = event.listeners; // Fill the scope. if ( !scopeObj ) scopeObj = this; // Default the priority, if needed. if ( isNaN( priority ) ) priority = 10; var me = this; // Create the function to be fired for this listener. var listenerFirer = function( editor, publisherData, stopFn, cancelFn ) { var ev = { name : eventName, sender : this, editor : editor, data : publisherData, listenerData : listenerData, stop : stopFn, cancel : cancelFn, removeListener : function() { me.removeListener( eventName, listenerFunction ); } }; listenerFunction.call( scopeObj, ev ); return ev.data; }; listenerFirer.fn = listenerFunction; listenerFirer.priority = priority; // Search for the right position for this new listener, based on its // priority. for ( var i = listeners.length - 1 ; i >= 0 ; i-- ) { // Find the item which should be before the new one. if ( listeners[ i ].priority <= priority ) { // Insert the listener in the array. listeners.splice( i + 1, 0, listenerFirer ); return; } } // If no position has been found (or zero length), put it in // the front of list. listeners.unshift( listenerFirer ); } }, /** * Fires an specific event in the object. All registered listeners are * called at this point. * @function * @param {String} eventName The event name to fire. * @param {Object} [data] Data to be sent as the * {@link CKEDITOR.eventInfo#data} when calling the * listeners. * @param {CKEDITOR.editor} [editor] The editor instance to send as the * {@link CKEDITOR.eventInfo#editor} when calling the * listener. * @returns {Boolean|Object} A booloan indicating that the event is to be * canceled, or data returned by one of the listeners. * @example * someObject.on( 'someEvent', function() { ... } ); * someObject.on( 'someEvent', function() { ... } ); * <b>someObject.fire( 'someEvent' )</b>; // both listeners are called * @example * someObject.on( 'someEvent', function( event ) * { * alert( event.data ); // "Example" * }); * <b>someObject.fire( 'someEvent', 'Example' )</b>; */ fire : (function() { // Create the function that marks the event as stopped. var stopped = false; var stopEvent = function() { stopped = true; }; // Create the function that marks the event as canceled. var canceled = false; var cancelEvent = function() { canceled = true; }; return function( eventName, data, editor ) { // Get the event entry. var event = getPrivate( this )[ eventName ]; // Save the previous stopped and cancelled states. We may // be nesting fire() calls. var previousStopped = stopped, previousCancelled = canceled; // Reset the stopped and canceled flags. stopped = canceled = false; if ( event ) { var listeners = event.listeners; if ( listeners.length ) { // As some listeners may remove themselves from the // event, the original array length is dinamic. So, // let's make a copy of all listeners, so we are // sure we'll call all of them. listeners = listeners.slice( 0 ); // Loop through all listeners. for ( var i = 0 ; i < listeners.length ; i++ ) { // Call the listener, passing the event data. var retData = listeners[i].call( this, editor, data, stopEvent, cancelEvent ); if ( typeof retData != 'undefined' ) data = retData; // No further calls is stopped or canceled. if ( stopped || canceled ) break; } } } var ret = canceled || ( typeof data == 'undefined' ? false : data ); // Restore the previous stopped and canceled states. stopped = previousStopped; canceled = previousCancelled; return ret; }; })(), /** * Fires an specific event in the object, releasing all listeners * registered to that event. The same listeners are not called again on * successive calls of it or of {@link #fire}. * @param {String} eventName The event name to fire. * @param {Object} [data] Data to be sent as the * {@link CKEDITOR.eventInfo#data} when calling the * listeners. * @param {CKEDITOR.editor} [editor] The editor instance to send as the * {@link CKEDITOR.eventInfo#editor} when calling the * listener. * @returns {Boolean|Object} A booloan indicating that the event is to be * canceled, or data returned by one of the listeners. * @example * someObject.on( 'someEvent', function() { ... } ); * someObject.fire( 'someEvent' ); // above listener called * <b>someObject.fireOnce( 'someEvent' )</b>; // above listener called * someObject.fire( 'someEvent' ); // no listeners called */ fireOnce : function( eventName, data, editor ) { var ret = this.fire( eventName, data, editor ); delete getPrivate( this )[ eventName ]; return ret; }, /** * Unregisters a listener function from being called at the specified * event. No errors are thrown if the listener has not been * registered previously. * @param {String} eventName The event name. * @param {Function} listenerFunction The listener function to unregister. * @example * var myListener = function() { ... }; * someObject.on( 'someEvent', myListener ); * someObject.fire( 'someEvent' ); // myListener called * <b>someObject.removeListener( 'someEvent', myListener )</b>; * someObject.fire( 'someEvent' ); // myListener not called */ removeListener : function( eventName, listenerFunction ) { // Get the event entry. var event = getPrivate( this )[ eventName ]; if ( event ) { var index = event.getListenerIndex( listenerFunction ); if ( index >= 0 ) event.listeners.splice( index, 1 ); } }, /** * Checks if there is any listener registered to a given event. * @param {String} eventName The event name. * @example * var myListener = function() { ... }; * someObject.on( 'someEvent', myListener ); * alert( someObject.<b>hasListeners( 'someEvent' )</b> ); // "true" * alert( someObject.<b>hasListeners( 'noEvent' )</b> ); // "false" */ hasListeners : function( eventName ) { var event = getPrivate( this )[ eventName ]; return ( event && event.listeners.length > 0 ) ; } }; })(); }
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.scriptLoader} object, used to load scripts * asynchronously. */ /** * Load scripts asynchronously. * @namespace * @example */ CKEDITOR.scriptLoader = (function() { var uniqueScripts = {}, waitingList = {}; return /** @lends CKEDITOR.scriptLoader */ { /** * Loads one or more external script checking if not already loaded * previously by this function. * @param {String|Array} scriptUrl One or more URLs pointing to the * scripts to be loaded. * @param {Function} [callback] A function to be called when the script * is loaded and executed. If a string is passed to "scriptUrl", a * boolean parameter is passed to the callback, indicating the * success of the load. If an array is passed instead, two array * parameters are passed to the callback; the first contains the * URLs that have been properly loaded, and the second the failed * ones. * @param {Object} [scope] The scope ("this" reference) to be used for * the callback call. Default to {@link CKEDITOR}. * @param {Boolean} [noCheck] Indicates that the script must be loaded * anyway, not checking if it has already loaded. * @param {Boolean} [showBusy] Changes the cursor of the document while + * the script is loaded. * @example * CKEDITOR.scriptLoader.load( '/myscript.js' ); * @example * CKEDITOR.scriptLoader.load( '/myscript.js', function( success ) * { * // Alerts "true" if the script has been properly loaded. * // HTTP error 404 should return "false". * alert( success ); * }); * @example * CKEDITOR.scriptLoader.load( [ '/myscript1.js', '/myscript2.js' ], function( completed, failed ) * { * alert( 'Number of scripts loaded: ' + completed.length ); * alert( 'Number of failures: ' + failed.length ); * }); */ load : function( scriptUrl, callback, scope, noCheck, showBusy ) { var isString = ( typeof scriptUrl == 'string' ); if ( isString ) scriptUrl = [ scriptUrl ]; if ( !scope ) scope = CKEDITOR; var scriptCount = scriptUrl.length, completed = [], failed = []; var doCallback = function( success ) { if ( callback ) { if ( isString ) callback.call( scope, success ); else callback.call( scope, completed, failed ); } }; if ( scriptCount === 0 ) { doCallback( true ); return; } var checkLoaded = function( url, success ) { ( success ? completed : failed ).push( url ); if ( --scriptCount <= 0 ) { showBusy && CKEDITOR.document.getDocumentElement().removeStyle( 'cursor' ); doCallback( success ); } }; var onLoad = function( url, success ) { // Mark this script as loaded. uniqueScripts[ url ] = 1; // Get the list of callback checks waiting for this file. var waitingInfo = waitingList[ url ]; delete waitingList[ url ]; // Check all callbacks waiting for this file. for ( var i = 0 ; i < waitingInfo.length ; i++ ) waitingInfo[ i ]( url, success ); }; var loadScript = function( url ) { if ( noCheck !== true && uniqueScripts[ url ] ) { checkLoaded( url, true ); return; } var waitingInfo = waitingList[ url ] || ( waitingList[ url ] = [] ); waitingInfo.push( checkLoaded ); // Load it only for the first request. if ( waitingInfo.length > 1 ) return; // Create the <script> element. var script = new CKEDITOR.dom.element( 'script' ); script.setAttributes( { type : 'text/javascript', src : url } ); if ( callback ) { if ( CKEDITOR.env.ie ) { // FIXME: For IE, we are not able to return false on error (like 404). /** @ignore */ script.$.onreadystatechange = function () { if ( script.$.readyState == 'loaded' || script.$.readyState == 'complete' ) { script.$.onreadystatechange = null; onLoad( url, true ); } }; } else { /** @ignore */ script.$.onload = function() { // Some browsers, such as Safari, may call the onLoad function // immediately. Which will break the loading sequence. (#3661) setTimeout( function() { onLoad( url, true ); }, 0 ); }; // FIXME: Opera and Safari will not fire onerror. /** @ignore */ script.$.onerror = function() { onLoad( url, false ); }; } } // Append it to <head>. script.appendTo( CKEDITOR.document.getHead() ); CKEDITOR.fire( 'download', url ); // @Packager.RemoveLine }; showBusy && CKEDITOR.document.getDocumentElement().setStyle( 'cursor', 'wait' ); for ( var i = 0 ; i < scriptCount ; i++ ) { loadScript( scriptUrl[ i ] ); } }, /** * Executes a JavaScript code into the current document. * @param {String} code The code to be executed. * @example * CKEDITOR.scriptLoader.loadCode( 'var x = 10;' ); * alert( x ); // "10" */ loadCode : function( code ) { // Create the <script> element. var script = new CKEDITOR.dom.element( 'script' ); script.setAttribute( 'type', 'text/javascript' ); script.appendText( code ); // Append it to <head>. script.appendTo( CKEDITOR.document.getHead() ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * Contains UI features related to an editor instance. * @constructor * @param {CKEDITOR.editor} editor The editor instance. * @example */ CKEDITOR.ui = function( editor ) { if ( editor.ui ) return editor.ui; /** * Object used to hold private stuff. * @private */ this._ = { handlers : {}, items : {}, editor : editor }; return this; }; // PACKAGER_RENAME( CKEDITOR.ui ) CKEDITOR.ui.prototype = { /** * Adds a UI item to the items collection. These items can be later used in * the interface. * @param {String} name The UI item name. * @param {Object} type The item type. * @param {Object} definition The item definition. The properties of this * object depend on the item type. * @example * // Add a new button named "MyBold". * editorInstance.ui.add( 'MyBold', CKEDITOR.UI_BUTTON, * { * label : 'My Bold', * command : 'bold' * }); */ add : function( name, type, definition ) { this._.items[ name ] = { type : type, // The name of {@link CKEDITOR.command} which associate with this UI. command : definition.command || null, args : Array.prototype.slice.call( arguments, 2 ) }; }, /** * Gets a UI object. * @param {String} name The UI item hame. * @example */ create : function( name ) { var item = this._.items[ name ], handler = item && this._.handlers[ item.type ], command = item && item.command && this._.editor.getCommand( item.command ); var result = handler && handler.create.apply( this, item.args ); // Add reference inside command object. if ( command ) command.uiItems.push( result ); return result; }, /** * Adds a handler for a UI item type. The handler is responsible for * transforming UI item definitions in UI objects. * @param {Object} type The item type. * @param {Object} handler The handler definition. * @example */ addHandler : function( type, handler ) { this._.handlers[ type ] = handler; } }; CKEDITOR.event.implementOn( CKEDITOR.ui ); /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. It just illustrates the features of hanlder objects to be * passed to the {@link CKEDITOR.ui.prototype.addHandler} function. * @name CKEDITOR.ui.handlerDefinition * @constructor * @example */ /** * Transforms an item definition into an UI item object. * @name CKEDITOR.handlerDefinition.prototype.create * @function * @param {Object} definition The item definition. * @example * editorInstance.ui.addHandler( CKEDITOR.UI_BUTTON, * { * create : function( definition ) * { * return new CKEDITOR.ui.button( definition ); * } * }); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.themes} object, which is used to * manage themes registration and loading. */ /** * Manages themes registration and loading. * @namespace * @augments CKEDITOR.resourceManager * @example */ CKEDITOR.themes = new CKEDITOR.resourceManager( '_source/'+ // @Packager.RemoveLine 'themes/', 'theme' );
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.skins} object, which is used to * manage skins loading. */ /** * Manages skins loading. * @namespace * @example */ CKEDITOR.skins = (function() { // Holds the list of loaded skins. var loaded = {}, paths = {}; var loadPart = function( editor, skinName, part, callback ) { // Get the skin definition. var skinDefinition = loaded[ skinName ]; if ( !editor.skin ) { editor.skin = skinDefinition; // Trigger init function if any. if ( skinDefinition.init ) skinDefinition.init( editor ); } var appendSkinPath = function( fileNames ) { for ( var n = 0 ; n < fileNames.length ; n++ ) { fileNames[ n ] = CKEDITOR.getUrl( paths[ skinName ] + fileNames[ n ] ); } }; function fixCSSTextRelativePath( cssStyleText, baseUrl ) { return cssStyleText.replace( /url\s*\(([\s'"]*)(.*?)([\s"']*)\)/g, function( match, opener, path, closer ) { if ( /^\/|^\w?:/.test( path ) ) return match; else return 'url(' + baseUrl + opener + path + closer + ')'; } ); } // Get the part definition. part = skinDefinition[ part ]; var partIsLoaded = !part || !!part._isLoaded; // Call the callback immediately if already loaded. if ( partIsLoaded ) callback && callback(); else { // Put the callback in a queue. var pending = part._pending || ( part._pending = [] ); pending.push( callback ); // We may have more than one skin part load request. Just the first // one must do the loading job. if ( pending.length > 1 ) return; // Check whether the "css" and "js" properties have been defined // for that part. var cssIsLoaded = !part.css || !part.css.length, jsIsLoaded = !part.js || !part.js.length; // This is the function that will trigger the callback calls on // load. var checkIsLoaded = function() { if ( cssIsLoaded && jsIsLoaded ) { // Mark the part as loaded. part._isLoaded = 1; // Call all pending callbacks. for ( var i = 0 ; i < pending.length ; i++ ) { if ( pending[ i ] ) pending[ i ](); } } }; // Load the "css" pieces. if ( !cssIsLoaded ) { var cssPart = part.css; if ( CKEDITOR.tools.isArray( cssPart ) ) { appendSkinPath( cssPart ); for ( var c = 0 ; c < cssPart.length ; c++ ) CKEDITOR.document.appendStyleSheet( cssPart[ c ] ); } else { cssPart = fixCSSTextRelativePath( cssPart, CKEDITOR.getUrl( paths[ skinName ] ) ); // Processing Inline CSS part. CKEDITOR.document.appendStyleText( cssPart ); } part.css = cssPart; cssIsLoaded = 1; } // Load the "js" pieces. if ( !jsIsLoaded ) { appendSkinPath( part.js ); CKEDITOR.scriptLoader.load( part.js, function() { jsIsLoaded = 1; checkIsLoaded(); }); } // We may have nothing to load, so check it immediately. checkIsLoaded(); } }; return /** @lends CKEDITOR.skins */ { /** * Registers a skin definition. * @param {String} skinName The skin name. * @param {Object} skinDefinition The skin definition. * @example */ add : function( skinName, skinDefinition ) { loaded[ skinName ] = skinDefinition; skinDefinition.skinPath = paths[ skinName ] || ( paths[ skinName ] = CKEDITOR.getUrl( '_source/' + // @Packager.RemoveLine 'skins/' + skinName + '/' ) ); }, /** * Loads a skin part. Skins are defined in parts, which are basically * separated CSS files. This function is mainly used by the core code and * should not have much use out of it. * @param {String} skinName The name of the skin to be loaded. * @param {String} skinPart The skin part to be loaded. Common skin parts * are "editor" and "dialog". * @param {Function} [callback] A function to be called once the skin * part files are loaded. * @example */ load : function( editor, skinPart, callback ) { var skinName = editor.skinName, skinPath = editor.skinPath; if ( loaded[ skinName ] ) loadPart( editor, skinName, skinPart, callback ); else { paths[ skinName ] = skinPath; CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( skinPath + 'skin.js' ), function() { loadPart( editor, skinName, skinPart, callback ); }); } } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.plugins} object, which is used to * manage plugins registration and loading. */ /** * Manages plugins registration and loading. * @namespace * @augments CKEDITOR.resourceManager * @example */ CKEDITOR.plugins = new CKEDITOR.resourceManager( '_source/' + // @Packager.RemoveLine 'plugins/', 'plugin' ); // PACKAGER_RENAME( CKEDITOR.plugins ) CKEDITOR.plugins.load = CKEDITOR.tools.override( CKEDITOR.plugins.load, function( originalLoad ) { return function( name, callback, scope ) { var allPlugins = {}; var loadPlugins = function( names ) { originalLoad.call( this, names, function( plugins ) { CKEDITOR.tools.extend( allPlugins, plugins ); var requiredPlugins = []; for ( var pluginName in plugins ) { var plugin = plugins[ pluginName ], requires = plugin && plugin.requires; if ( requires ) { for ( var i = 0 ; i < requires.length ; i++ ) { if ( !allPlugins[ requires[ i ] ] ) requiredPlugins.push( requires[ i ] ); } } } if ( requiredPlugins.length ) loadPlugins.call( this, requiredPlugins ); else { // Call the "onLoad" function for all plugins. for ( pluginName in allPlugins ) { plugin = allPlugins[ pluginName ]; if ( plugin.onLoad && !plugin.onLoad._called ) { plugin.onLoad(); plugin.onLoad._called = 1; } } // Call the callback. if ( callback ) callback.call( scope || window, allPlugins ); } } , this); }; loadPlugins.call( this, name ); }; }); CKEDITOR.plugins.setLang = function( pluginName, languageCode, languageEntries ) { var plugin = this.get( pluginName ), pluginLang = plugin.lang || ( plugin.lang = {} ); pluginLang[ languageCode ] = languageEntries; };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.tools} object, which contains * utility functions. */ (function() { var functions = []; CKEDITOR.on( 'reset', function() { functions = []; }); /** * Utility functions. * @namespace * @example */ CKEDITOR.tools = { /** * Compare the elements of two arrays. * @param {Array} arrayA An array to be compared. * @param {Array} arrayB The other array to be compared. * @returns {Boolean} "true" is the arrays have the same lenght and * their elements match. * @example * var a = [ 1, 'a', 3 ]; * var b = [ 1, 3, 'a' ]; * var c = [ 1, 'a', 3 ]; * var d = [ 1, 'a', 3, 4 ]; * * alert( CKEDITOR.tools.arrayCompare( a, b ) ); // false * alert( CKEDITOR.tools.arrayCompare( a, c ) ); // true * alert( CKEDITOR.tools.arrayCompare( a, d ) ); // false */ arrayCompare : function( arrayA, arrayB ) { if ( !arrayA && !arrayB ) return true; if ( !arrayA || !arrayB || arrayA.length != arrayB.length ) return false; for ( var i = 0 ; i < arrayA.length ; i++ ) { if ( arrayA[ i ] != arrayB[ i ] ) return false; } return true; }, /** * Creates a deep copy of an object. * Attention: there is no support for recursive references. * @param {Object} object The object to be cloned. * @returns {Object} The object clone. * @example * var obj = * { * name : 'John', * cars : * { * Mercedes : { color : 'blue' }, * Porsche : { color : 'red' } * } * }; * var clone = CKEDITOR.tools.clone( obj ); * clone.name = 'Paul'; * clone.cars.Porsche.color = 'silver'; * alert( obj.name ); // John * alert( clone.name ); // Paul * alert( obj.cars.Porsche.color ); // red * alert( clone.cars.Porsche.color ); // silver */ clone : function( obj ) { var clone; // Array. if ( obj && ( obj instanceof Array ) ) { clone = []; for ( var i = 0 ; i < obj.length ; i++ ) clone[ i ] = this.clone( obj[ i ] ); return clone; } // "Static" types. if ( obj === null || ( typeof( obj ) != 'object' ) || ( obj instanceof String ) || ( obj instanceof Number ) || ( obj instanceof Boolean ) || ( obj instanceof Date ) || ( obj instanceof RegExp) ) { return obj; } // Objects. clone = new obj.constructor(); for ( var propertyName in obj ) { var property = obj[ propertyName ]; clone[ propertyName ] = this.clone( property ); } return clone; }, /** * Turn the first letter of string to upper-case. * @param {String} str */ capitalize: function( str ) { return str.charAt( 0 ).toUpperCase() + str.substring( 1 ).toLowerCase(); }, /** * Copy the properties from one object to another. By default, properties * already present in the target object <strong>are not</strong> overwritten. * @param {Object} target The object to be extended. * @param {Object} source[,souce(n)] The objects from which copy * properties. Any number of objects can be passed to this function. * @param {Boolean} [overwrite] If 'true' is specified it indicates that * properties already present in the target object could be * overwritten by subsequent objects. * @param {Object} [properties] Only properties within the specified names * list will be received from the source object. * @returns {Object} the extended object (target). * @example * // Create the sample object. * var myObject = * { * prop1 : true * }; * * // Extend the above object with two properties. * CKEDITOR.tools.extend( myObject, * { * prop2 : true, * prop3 : true * } ); * * // Alert "prop1", "prop2" and "prop3". * for ( var p in myObject ) * alert( p ); */ extend : function( target ) { var argsLength = arguments.length, overwrite, propertiesList; if ( typeof ( overwrite = arguments[ argsLength - 1 ] ) == 'boolean') argsLength--; else if ( typeof ( overwrite = arguments[ argsLength - 2 ] ) == 'boolean' ) { propertiesList = arguments [ argsLength -1 ]; argsLength-=2; } for ( var i = 1 ; i < argsLength ; i++ ) { var source = arguments[ i ]; for ( var propertyName in source ) { // Only copy existed fields if in overwrite mode. if ( overwrite === true || target[ propertyName ] == undefined ) { // Only copy specified fields if list is provided. if ( !propertiesList || ( propertyName in propertiesList ) ) target[ propertyName ] = source[ propertyName ]; } } } return target; }, /** * Creates an object which is an instance of a class which prototype is a * predefined object. All properties defined in the source object are * automatically inherited by the resulting object, including future * changes to it. * @param {Object} source The source object to be used as the prototype for * the final object. * @returns {Object} The resulting copy. */ prototypedCopy : function( source ) { var copy = function() {}; copy.prototype = source; return new copy(); }, /** * Checks if an object is an Array. * @param {Object} object The object to be checked. * @type Boolean * @returns <i>true</i> if the object is an Array, otherwise <i>false</i>. * @example * alert( CKEDITOR.tools.isArray( [] ) ); // "true" * alert( CKEDITOR.tools.isArray( 'Test' ) ); // "false" */ isArray : function( object ) { return ( !!object && object instanceof Array ); }, /** * Whether the object contains no properties of it's own. * @param object */ isEmpty : function ( object ) { for ( var i in object ) { if ( object.hasOwnProperty( i ) ) return false; } return true; }, /** * Transforms a CSS property name to its relative DOM style name. * @param {String} cssName The CSS property name. * @returns {String} The transformed name. * @example * alert( CKEDITOR.tools.cssStyleToDomStyle( 'background-color' ) ); // "backgroundColor" * alert( CKEDITOR.tools.cssStyleToDomStyle( 'float' ) ); // "cssFloat" */ cssStyleToDomStyle : ( function() { var test = document.createElement( 'div' ).style; var cssFloat = ( typeof test.cssFloat != 'undefined' ) ? 'cssFloat' : ( typeof test.styleFloat != 'undefined' ) ? 'styleFloat' : 'float'; return function( cssName ) { if ( cssName == 'float' ) return cssFloat; else { return cssName.replace( /-./g, function( match ) { return match.substr( 1 ).toUpperCase(); }); } }; } )(), /** * Build the HTML snippet of a set of &lt;style>/&lt;link>. * @param css {String|Array} Each of which are url (absolute) of a CSS file or * a trunk of style text. */ buildStyleHtml : function ( css ) { css = [].concat( css ); var item, retval = []; for ( var i = 0; i < css.length; i++ ) { item = css[ i ]; // Is CSS style text ? if ( /@import|[{}]/.test(item) ) retval.push('<style>' + item + '</style>'); else retval.push('<link type="text/css" rel=stylesheet href="' + item + '">'); } return retval.join( '' ); }, /** * Replace special HTML characters in a string with their relative HTML * entity values. * @param {String} text The string to be encoded. * @returns {String} The encode string. * @example * alert( CKEDITOR.tools.htmlEncode( 'A > B & C < D' ) ); // "A &amp;gt; B &amp;amp; C &amp;lt; D" */ htmlEncode : function( text ) { var standard = function( text ) { var span = new CKEDITOR.dom.element( 'span' ); span.setText( text ); return span.getHtml(); }; var fix1 = ( standard( '\n' ).toLowerCase() == '<br>' ) ? function( text ) { // #3874 IE and Safari encode line-break into <br> return standard( text ).replace( /<br>/gi, '\n' ); } : standard; var fix2 = ( standard( '>' ) == '>' ) ? function( text ) { // WebKit does't encode the ">" character, which makes sense, but // it's different than other browsers. return fix1( text ).replace( />/g, '&gt;' ); } : fix1; var fix3 = ( standard( ' ' ) == '&nbsp; ' ) ? function( text ) { // #3785 IE8 changes spaces (>= 2) to &nbsp; return fix2( text ).replace( /&nbsp;/g, ' ' ); } : fix2; this.htmlEncode = fix3; return this.htmlEncode( text ); }, /** * Replace special HTML characters in HTMLElement's attribute with their relative HTML entity values. * @param {String} The attribute's value to be encoded. * @returns {String} The encode value. * @example * element.setAttribute( 'title', '<a " b >' ); * alert( CKEDITOR.tools.htmlEncodeAttr( element.getAttribute( 'title' ) ); // "&gt;a &quot; b &lt;" */ htmlEncodeAttr : function( text ) { return text.replace( /"/g, '&quot;' ).replace( /</g, '&lt;' ).replace( />/g, '&gt;' ); }, /** * Gets a unique number for this CKEDITOR execution session. It returns * progressive numbers starting at 1. * @function * @returns {Number} A unique number. * @example * alert( CKEDITOR.tools.<b>getNextNumber()</b> ); // "1" (e.g.) * alert( CKEDITOR.tools.<b>getNextNumber()</b> ); // "2" */ getNextNumber : (function() { var last = 0; return function() { return ++last; }; })(), /** * Gets a unique ID for CKEditor's interface elements. It returns a * string with the "cke_" prefix and a progressive number. * @function * @returns {String} A unique ID. * @example * alert( CKEDITOR.tools.<b>getNextId()</b> ); // "cke_1" (e.g.) * alert( CKEDITOR.tools.<b>getNextId()</b> ); // "cke_2" */ getNextId : function() { return 'cke_' + this.getNextNumber(); }, /** * Creates a function override. * @param {Function} originalFunction The function to be overridden. * @param {Function} functionBuilder A function that returns the new * function. The original function reference will be passed to this * function. * @returns {Function} The new function. * @example * var example = * { * myFunction : function( name ) * { * alert( 'Name: ' + name ); * } * }; * * example.myFunction = CKEDITOR.tools.override( example.myFunction, function( myFunctionOriginal ) * { * return function( name ) * { * alert( 'Override Name: ' + name ); * myFunctionOriginal.call( this, name ); * }; * }); */ override : function( originalFunction, functionBuilder ) { return functionBuilder( originalFunction ); }, /** * Executes a function after specified delay. * @param {Function} func The function to be executed. * @param {Number} [milliseconds] The amount of time (millisecods) to wait * to fire the function execution. Defaults to zero. * @param {Object} [scope] The object to hold the function execution scope * (the "this" object). By default the "window" object. * @param {Object|Array} [args] A single object, or an array of objects, to * pass as arguments to the function. * @param {Object} [ownerWindow] The window that will be used to set the * timeout. By default the current "window". * @returns {Object} A value that can be used to cancel the function execution. * @example * CKEDITOR.tools.<b>setTimeout( * function() * { * alert( 'Executed after 2 seconds' ); * }, * 2000 )</b>; */ setTimeout : function( func, milliseconds, scope, args, ownerWindow ) { if ( !ownerWindow ) ownerWindow = window; if ( !scope ) scope = ownerWindow; return ownerWindow.setTimeout( function() { if ( args ) func.apply( scope, [].concat( args ) ) ; else func.apply( scope ) ; }, milliseconds || 0 ); }, /** * Remove spaces from the start and the end of a string. The following * characters are removed: space, tab, line break, line feed. * @function * @param {String} str The text from which remove the spaces. * @returns {String} The modified string without the boundary spaces. * @example * alert( CKEDITOR.tools.trim( ' example ' ); // "example" */ trim : (function() { // We are not using \s because we don't want "non-breaking spaces" to be caught. var trimRegex = /(?:^[ \t\n\r]+)|(?:[ \t\n\r]+$)/g; return function( str ) { return str.replace( trimRegex, '' ) ; }; })(), /** * Remove spaces from the start (left) of a string. The following * characters are removed: space, tab, line break, line feed. * @function * @param {String} str The text from which remove the spaces. * @returns {String} The modified string excluding the removed spaces. * @example * alert( CKEDITOR.tools.ltrim( ' example ' ); // "example " */ ltrim : (function() { // We are not using \s because we don't want "non-breaking spaces" to be caught. var trimRegex = /^[ \t\n\r]+/g; return function( str ) { return str.replace( trimRegex, '' ) ; }; })(), /** * Remove spaces from the end (right) of a string. The following * characters are removed: space, tab, line break, line feed. * @function * @param {String} str The text from which remove the spaces. * @returns {String} The modified string excluding the removed spaces. * @example * alert( CKEDITOR.tools.ltrim( ' example ' ); // " example" */ rtrim : (function() { // We are not using \s because we don't want "non-breaking spaces" to be caught. var trimRegex = /[ \t\n\r]+$/g; return function( str ) { return str.replace( trimRegex, '' ) ; }; })(), /** * Returns the index of an element in an array. * @param {Array} array The array to be searched. * @param {Object} entry The element to be found. * @returns {Number} The (zero based) index of the first entry that matches * the entry, or -1 if not found. * @example * var letters = [ 'a', 'b', 0, 'c', false ]; * alert( CKEDITOR.tools.indexOf( letters, '0' ) ); "-1" because 0 !== '0' * alert( CKEDITOR.tools.indexOf( letters, false ) ); "4" because 0 !== false */ indexOf : // #2514: We should try to use Array.indexOf if it does exist. ( Array.prototype.indexOf ) ? function( array, entry ) { return array.indexOf( entry ); } : function( array, entry ) { for ( var i = 0, len = array.length ; i < len ; i++ ) { if ( array[ i ] === entry ) return i; } return -1; }, /** * Creates a function that will always execute in the context of a * specified object. * @param {Function} func The function to be executed. * @param {Object} obj The object to which bind the execution context. * @returns {Function} The function that can be used to execute the * "func" function in the context of "obj". * @example * var obj = { text : 'My Object' }; * * function alertText() * { * alert( this.text ); * } * * var newFunc = <b>CKEDITOR.tools.bind( alertText, obj )</b>; * newFunc(); // Alerts "My Object". */ bind : function( func, obj ) { return function() { return func.apply( obj, arguments ); }; }, /** * Class creation based on prototype inheritance, with supports of the * following features: * <ul> * <li> Static fields </li> * <li> Private fields </li> * <li> Public (prototype) fields </li> * <li> Chainable base class constructor </li> * </ul> * @param {Object} definition The class definition object. * @returns {Function} A class-like JavaScript function. */ createClass : function( definition ) { var $ = definition.$, baseClass = definition.base, privates = definition.privates || definition._, proto = definition.proto, statics = definition.statics; if ( privates ) { var originalConstructor = $; $ = function() { // Create (and get) the private namespace. var _ = this._ || ( this._ = {} ); // Make some magic so "this" will refer to the main // instance when coding private functions. for ( var privateName in privates ) { var priv = privates[ privateName ]; _[ privateName ] = ( typeof priv == 'function' ) ? CKEDITOR.tools.bind( priv, this ) : priv; } originalConstructor.apply( this, arguments ); }; } if ( baseClass ) { $.prototype = this.prototypedCopy( baseClass.prototype ); $.prototype.constructor = $; $.prototype.base = function() { this.base = baseClass.prototype.base; baseClass.apply( this, arguments ); this.base = arguments.callee; }; } if ( proto ) this.extend( $.prototype, proto, true ); if ( statics ) this.extend( $, statics, true ); return $; }, /** * Creates a function reference that can be called later using * CKEDITOR.tools.callFunction. This approach is specially useful to * make DOM attribute function calls to JavaScript defined functions. * @param {Function} fn The function to be executed on call. * @param {Object} [scope] The object to have the context on "fn" execution. * @returns {Number} A unique reference to be used in conjuction with * CKEDITOR.tools.callFunction. * @example * var ref = <b>CKEDITOR.tools.addFunction</b>( * function() * { * alert( 'Hello!'); * }); * CKEDITOR.tools.callFunction( ref ); // Hello! */ addFunction : function( fn, scope ) { return functions.push( function() { return fn.apply( scope || this, arguments ); }) - 1; }, /** * Removes the function reference created with {@see CKEDITOR.tools.addFunction}. * @param {Number} ref The function reference created with * CKEDITOR.tools.addFunction. */ removeFunction : function( ref ) { functions[ ref ] = null; }, /** * Executes a function based on the reference created with * CKEDITOR.tools.addFunction. * @param {Number} ref The function reference created with * CKEDITOR.tools.addFunction. * @param {[Any,[Any,...]} params Any number of parameters to be passed * to the executed function. * @returns {Any} The return value of the function. * @example * var ref = CKEDITOR.tools.addFunction( * function() * { * alert( 'Hello!'); * }); * <b>CKEDITOR.tools.callFunction( ref )</b>; // Hello! */ callFunction : function( ref ) { var fn = functions[ ref ]; return fn && fn.apply( window, Array.prototype.slice.call( arguments, 1 ) ); }, /** * Append the 'px' length unit to the size if it's missing. * @param length */ cssLength : (function() { var decimalRegex = /^\d+(?:\.\d+)?$/; return function( length ) { return length + ( decimalRegex.test( length ) ? 'px' : '' ); }; })(), /** * String specified by {@param str} repeats {@param times} times. * @param str * @param times */ repeat : function( str, times ) { return new Array( times + 1 ).join( str ); }, /** * Return the first successfully executed function's return value that * doesn't throw any exception. */ tryThese : function() { var returnValue; for ( var i = 0, length = arguments.length; i < length; i++ ) { var lambda = arguments[i]; try { returnValue = lambda(); break; } catch (e) {} } return returnValue; }, /** * Generate a combined key from a series of params. * @param {String} subKey One or more string used as sub keys. * @example * var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' ); * alert( key ); // "key1-key2-key3". */ genKey : function() { return Array.prototype.slice.call( arguments ).join( '-' ); } }; })(); // PACKAGER_RENAME( CKEDITOR.tools )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.xml} class, which represents a * loaded XML document. */ /** * Represents a loaded XML document. * @constructor * @param {object|string} xmlObjectOrData A native XML (DOM document) object or * a string containing the XML definition to be loaded. * @example * var xml = <b>new CKEDITOR.xml( '<books><book title="My Book" /></books>' )</b>; */ CKEDITOR.xml = function( xmlObjectOrData ) { var baseXml = null; if ( typeof xmlObjectOrData == 'object' ) baseXml = xmlObjectOrData; else { var data = ( xmlObjectOrData || '' ).replace( /&nbsp;/g, '\xA0' ); if ( window.DOMParser ) baseXml = (new DOMParser()).parseFromString( data, 'text/xml' ); else if ( window.ActiveXObject ) { try { baseXml = new ActiveXObject( 'MSXML2.DOMDocument' ); } catch(e) { try { baseXml = new ActiveXObject( 'Microsoft.XmlDom' ); } catch(e) {} } if ( baseXml ) { baseXml.async = false; baseXml.resolveExternals = false; baseXml.validateOnParse = false; baseXml.loadXML( data ); } } } /** * The native XML (DOM document) used by the class instance. * @type object * @example */ this.baseXml = baseXml; }; CKEDITOR.xml.prototype = { /** * Get a single node from the XML document, based on a XPath query. * @param {String} xpath The XPath query to execute. * @param {Object} [contextNode] The XML DOM node to be used as the context * for the XPath query. The document root is used by default. * @returns {Object} A XML node element or null if the query has no results. * @example * // Create the XML instance. * var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' ); * // Get the first <item> node. * var itemNode = <b>xml.selectSingleNode( 'list/item' )</b>; * // Alert "item". * alert( itemNode.nodeName ); */ selectSingleNode : function( xpath, contextNode ) { var baseXml = this.baseXml; if ( contextNode || ( contextNode = baseXml ) ) { if ( CKEDITOR.env.ie || contextNode.selectSingleNode ) // IE return contextNode.selectSingleNode( xpath ); else if ( baseXml.evaluate ) // Others { var result = baseXml.evaluate( xpath, contextNode, null, 9, null); return ( result && result.singleNodeValue ) || null; } } return null; }, /** * Gets a list node from the XML document, based on a XPath query. * @param {String} xpath The XPath query to execute. * @param {Object} [contextNode] The XML DOM node to be used as the context * for the XPath query. The document root is used by default. * @returns {ArrayLike} An array containing all matched nodes. The array will * be empty if the query has no results. * @example * // Create the XML instance. * var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' ); * // Get the first <item> node. * var itemNodes = xml.selectSingleNode( 'list/item' ); * // Alert "item" twice, one for each <item>. * for ( var i = 0 ; i < itemNodes.length ; i++ ) * alert( itemNodes[i].nodeName ); */ selectNodes : function( xpath, contextNode ) { var baseXml = this.baseXml, nodes = []; if ( contextNode || ( contextNode = baseXml ) ) { if ( CKEDITOR.env.ie || contextNode.selectNodes ) // IE return contextNode.selectNodes( xpath ); else if ( baseXml.evaluate ) // Others { var result = baseXml.evaluate( xpath, contextNode, null, 5, null); if ( result ) { var node; while ( ( node = result.iterateNext() ) ) nodes.push( node ); } } } return nodes; }, /** * Gets the string representation of hte inner contents of a XML node, * based on a XPath query. * @param {String} xpath The XPath query to execute. * @param {Object} [contextNode] The XML DOM node to be used as the context * for the XPath query. The document root is used by default. * @returns {String} The textual representation of the inner contents of * the node or null if the query has no results. * @example * // Create the XML instance. * var xml = new CKEDITOR.xml( '<list><item id="test1" /><item id="test2" /></list>' ); * // Alert "<item id="test1" /><item id="test2" />". * alert( xml.getInnerXml( 'list' ) ); */ getInnerXml : function( xpath, contextNode ) { var node = this.selectSingleNode( xpath, contextNode ), xml = []; if ( node ) { node = node.firstChild; while ( node ) { if ( node.xml ) // IE xml.push( node.xml ); else if ( window.XMLSerializer ) // Others xml.push( ( new XMLSerializer() ).serializeToString( node ) ); node = node.nextSibling; } } return xml.length ? xml.join( '' ) : null; } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.loader} objects, which is used to * load core scripts and their dependencies from _source. */ if ( typeof CKEDITOR == 'undefined' ) CKEDITOR = {}; if ( !CKEDITOR.loader ) { /** * Load core scripts and their dependencies from _source. * @namespace * @example */ CKEDITOR.loader = (function() { // Table of script names and their dependencies. var scripts = { 'core/_bootstrap' : [ 'core/config', 'core/ckeditor', 'core/plugins', 'core/scriptloader', 'core/tools', /* The following are entries that we want to force loading at the end to avoid dependence recursion */ 'core/dom/comment', 'core/dom/elementpath', 'core/dom/text', 'core/dom/rangelist' ], 'core/ajax' : [ 'core/xml' ], 'core/ckeditor' : [ 'core/ckeditor_basic', 'core/dom', 'core/dtd', 'core/dom/document', 'core/dom/element', 'core/editor', 'core/event', 'core/htmlparser', 'core/htmlparser/element', 'core/htmlparser/fragment', 'core/htmlparser/filter', 'core/htmlparser/basicwriter', 'core/tools' ], 'core/ckeditor_base' : [], 'core/ckeditor_basic' : [ 'core/editor_basic', 'core/env', 'core/event' ], 'core/command' : [], 'core/config' : [ 'core/ckeditor_base' ], 'core/dom' : [], 'core/dom/comment' : [ 'core/dom/node' ], 'core/dom/document' : [ 'core/dom', 'core/dom/domobject', 'core/dom/window' ], 'core/dom/documentfragment' : [ 'core/dom/element' ], 'core/dom/element' : [ 'core/dom', 'core/dom/document', 'core/dom/domobject', 'core/dom/node', 'core/dom/nodelist', 'core/tools' ], 'core/dom/elementpath' : [ 'core/dom/element' ], 'core/dom/event' : [], 'core/dom/node' : [ 'core/dom/domobject', 'core/tools' ], 'core/dom/nodelist' : [ 'core/dom/node' ], 'core/dom/domobject' : [ 'core/dom/event' ], 'core/dom/range' : [ 'core/dom/document', 'core/dom/documentfragment', 'core/dom/element', 'core/dom/walker' ], 'core/dom/rangelist' : [ 'core/dom/range' ], 'core/dom/text' : [ 'core/dom/node', 'core/dom/domobject' ], 'core/dom/walker' : [ 'core/dom/node' ], 'core/dom/window' : [ 'core/dom/domobject' ], 'core/dtd' : [ 'core/tools' ], 'core/editor' : [ 'core/command', 'core/config', 'core/editor_basic', 'core/focusmanager', 'core/lang', 'core/plugins', 'core/skins', 'core/themes', 'core/tools', 'core/ui' ], 'core/editor_basic' : [ 'core/event' ], 'core/env' : [], 'core/event' : [], 'core/focusmanager' : [], 'core/htmlparser' : [], 'core/htmlparser/comment' : [ 'core/htmlparser' ], 'core/htmlparser/element' : [ 'core/htmlparser', 'core/htmlparser/fragment' ], 'core/htmlparser/fragment' : [ 'core/htmlparser', 'core/htmlparser/comment', 'core/htmlparser/text', 'core/htmlparser/cdata' ], 'core/htmlparser/text' : [ 'core/htmlparser' ], 'core/htmlparser/cdata' : [ 'core/htmlparser' ], 'core/htmlparser/filter' : [ 'core/htmlparser' ], 'core/htmlparser/basicwriter': [ 'core/htmlparser' ], 'core/lang' : [], 'core/plugins' : [ 'core/resourcemanager' ], 'core/resourcemanager' : [ 'core/scriptloader', 'core/tools' ], 'core/scriptloader' : [ 'core/dom/element', 'core/env' ], 'core/skins' : [ 'core/scriptloader' ], 'core/themes' : [ 'core/resourcemanager' ], 'core/tools' : [ 'core/env' ], 'core/ui' : [], 'core/xml' : [ 'core/env' ] }; var basePath = (function() { // This is a copy of CKEDITOR.basePath, but requires the script having // "_source/core/loader.js". if ( CKEDITOR && CKEDITOR.basePath ) return CKEDITOR.basePath; // Find out the editor directory path, based on its <script> tag. var path = ''; var scripts = document.getElementsByTagName( 'script' ); for ( var i = 0 ; i < scripts.length ; i++ ) { var match = scripts[i].src.match( /(^|.*?[\\\/])(?:_source\/)?core\/loader.js(?:\?.*)?$/i ); if ( match ) { path = match[1]; break; } } // In IE (only) the script.src string is the raw valued entered in the // HTML. Other browsers return the full resolved URL instead. if ( path.indexOf('://') == -1 ) { // Absolute path. if ( path.indexOf( '/' ) === 0 ) path = location.href.match( /^.*?:\/\/[^\/]*/ )[0] + path; // Relative path. else path = location.href.match( /^[^\?]*\// )[0] + path; } return path; })(); var timestamp = 'ABH04T2'; var getUrl = function( resource ) { if ( CKEDITOR && CKEDITOR.getUrl ) return CKEDITOR.getUrl( resource ); return basePath + resource + ( resource.indexOf( '?' ) >= 0 ? '&' : '?' ) + 't=' + timestamp; }; var pendingLoad = []; /** @lends CKEDITOR.loader */ return { /** * The list of loaded scripts in their loading order. * @type Array * @example * // Alert the loaded script names. * alert( <b>CKEDITOR.loader.loadedScripts</b> ); */ loadedScripts : [], loadPending : function() { var scriptName = pendingLoad.shift(); if ( !scriptName ) return; var scriptSrc = getUrl( '_source/' + scriptName + '.js' ); var script = document.createElement( 'script' ); script.type = 'text/javascript'; script.src = scriptSrc; function onScriptLoaded() { // Append this script to the list of loaded scripts. CKEDITOR.loader.loadedScripts.push( scriptName ); // Load the next. CKEDITOR.loader.loadPending(); } // We must guarantee the execution order of the scripts, so we // need to load them one by one. (#4145) // The following if/else block has been taken from the scriptloader core code. if ( typeof(script.onreadystatechange) !== "undefined" ) { /** @ignore */ script.onreadystatechange = function() { if ( script.readyState == 'loaded' || script.readyState == 'complete' ) { script.onreadystatechange = null; onScriptLoaded(); } }; } else { /** @ignore */ script.onload = function() { // Some browsers, such as Safari, may call the onLoad function // immediately. Which will break the loading sequence. (#3661) setTimeout( function() { onScriptLoaded( scriptName ); }, 0 ); }; } document.body.appendChild( script ); }, /** * Loads a specific script, including its dependencies. This is not a * synchronous loading, which means that the code to be loaded will * not necessarily be available after this call. * @example * CKEDITOR.loader.load( 'core/dom/element' ); */ load : function( scriptName, defer ) { // Check if the script has already been loaded. if ( scriptName in this.loadedScripts ) return; // Get the script dependencies list. var dependencies = scripts[ scriptName ]; if ( !dependencies ) throw 'The script name"' + scriptName + '" is not defined.'; // Mark the script as loaded, even before really loading it, to // avoid cross references recursion. this.loadedScripts[ scriptName ] = true; // Load all dependencies first. for ( var i = 0 ; i < dependencies.length ; i++ ) this.load( dependencies[ i ], true ); var scriptSrc = getUrl( '_source/' + scriptName + '.js' ); // Append the <script> element to the DOM. // If the page is fully loaded, we can't use document.write // but if the script is run while the body is loading then it's safe to use it // Unfortunately, Firefox <3.6 doesn't support document.readyState, so it won't get this improvement if ( document.body && (!document.readyState || document.readyState == 'complete') ) { pendingLoad.push( scriptName ); if ( !defer ) this.loadPending(); } else { // Append this script to the list of loaded scripts. this.loadedScripts.push( scriptName ); document.write( '<script src="' + scriptSrc + '" type="text/javascript"><\/script>' ); } } }; })(); } // Check if any script has been defined for autoload. if ( CKEDITOR._autoLoad ) { CKEDITOR.loader.load( CKEDITOR._autoLoad ); delete CKEDITOR._autoLoad; }
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * Creates a command class instance. * @class Represents a command that can be executed on an editor instance. * @param {CKEDITOR.editor} editor The editor instance this command will be * related to. * @param {CKEDITOR.commandDefinition} commandDefinition The command * definition. * @augments CKEDITOR.event * @example * var command = new CKEDITOR.command( editor, * { * exec : function( editor ) * { * alert( editor.document.getBody().getHtml() ); * } * }); */ CKEDITOR.command = function( editor, commandDefinition ) { /** * Lists UI items that are associated to this command. This list can be * used to interact with the UI on command execution (by the execution code * itself, for example). * @type Array * @example * alert( 'Number of UI items associated to this command: ' + command.<b>uiItems</b>.length ); */ this.uiItems = []; /** * Executes the command. * @param {Object} [data] Any data to pass to the command. Depends on the * command implementation and requirements. * @returns {Boolean} A boolean indicating that the command has been * successfully executed. * @example * command.<b>exec()</b>; // The command gets executed. */ this.exec = function( data ) { if ( this.state == CKEDITOR.TRISTATE_DISABLED ) return false; if ( this.editorFocus ) // Give editor focus if necessary (#4355). editor.focus(); return ( commandDefinition.exec.call( this, editor, data ) !== false ); }; CKEDITOR.tools.extend( this, commandDefinition, // Defaults /** @lends CKEDITOR.command.prototype */ { /** * The editor modes within which the command can be executed. The * execution will have no action if the current mode is not listed * in this property. * @type Object * @default { wysiwyg : 1 } * @see CKEDITOR.editor.prototype.mode * @example * // Enable the command in both WYSIWYG and Source modes. * command.<b>modes</b> = { wysiwyg : 1, source : 1 }; * @example * // Enable the command in Source mode only. * command.<b>modes</b> = { source : 1 }; */ modes : { wysiwyg : 1 }, /** * Indicates that the editor will get the focus before executing * the command. * @type Boolean * @default true * @example * // Do not force the editor to have focus when executing the command. * command.<b>editorFocus</b> = false; */ editorFocus : 1, /** * Indicates the editor state. Possible values are: * <ul> * <li>{@link CKEDITOR.TRISTATE_DISABLED}: the command is * disabled. It's execution will have no effect. Same as * {@link disable}.</li> * <li>{@link CKEDITOR.TRISTATE_ON}: the command is enabled * and currently active in the editor (for context sensitive commands, * for example).</li> * <li>{@link CKEDITOR.TRISTATE_OFF}: the command is enabled * and currently inactive in the editor (for context sensitive * commands, for example).</li> * </ul> * Do not set this property directly, using the {@link #setState} * method instead. * @type Number * @default {@link CKEDITOR.TRISTATE_OFF} * @example * if ( command.<b>state</b> == CKEDITOR.TRISTATE_DISABLED ) * alert( 'This command is disabled' ); */ state : CKEDITOR.TRISTATE_OFF }); // Call the CKEDITOR.event constructor to initialize this instance. CKEDITOR.event.call( this ); }; CKEDITOR.command.prototype = { /** * Enables the command for execution. The command state (see * {@link CKEDITOR.command.prototype.state}) available before disabling it * is restored. * @example * command.<b>enable()</b>; * command.exec(); // Execute the command. */ enable : function() { if ( this.state == CKEDITOR.TRISTATE_DISABLED ) this.setState( ( !this.preserveState || ( typeof this.previousState == 'undefined' ) ) ? CKEDITOR.TRISTATE_OFF : this.previousState ); }, /** * Disables the command for execution. The command state (see * {@link CKEDITOR.command.prototype.state}) will be set to * {@link CKEDITOR.TRISTATE_DISABLED}. * @example * command.<b>disable()</b>; * command.exec(); // "false" - Nothing happens. */ disable : function() { this.setState( CKEDITOR.TRISTATE_DISABLED ); }, /** * Sets the command state. * @param {Number} newState The new state. See {@link #state}. * @returns {Boolean} Returns "true" if the command state changed. * @example * command.<b>setState( CKEDITOR.TRISTATE_ON )</b>; * command.exec(); // Execute the command. * command.<b>setState( CKEDITOR.TRISTATE_DISABLED )</b>; * command.exec(); // "false" - Nothing happens. * command.<b>setState( CKEDITOR.TRISTATE_OFF )</b>; * command.exec(); // Execute the command. */ setState : function( newState ) { // Do nothing if there is no state change. if ( this.state == newState ) return false; this.previousState = this.state; // Set the new state. this.state = newState; // Fire the "state" event, so other parts of the code can react to the // change. this.fire( 'state' ); return true; }, /** * Toggles the on/off (active/inactive) state of the command. This is * mainly used internally by context sensitive commands. * @example * command.<b>toggleState()</b>; */ toggleState : function() { if ( this.state == CKEDITOR.TRISTATE_OFF ) this.setState( CKEDITOR.TRISTATE_ON ); else if ( this.state == CKEDITOR.TRISTATE_ON ) this.setState( CKEDITOR.TRISTATE_OFF ); } }; CKEDITOR.event.implementOn( CKEDITOR.command.prototype, true ); /** * Indicates the preivous command state. * @name CKEDITOR.command.prototype.previousState * @type Number * @see #state * @example * alert( command.<b>previousState</b> ); */ /** * Fired when the command state changes. * @name CKEDITOR.command#state * @event * @example * command.on( <b>'state'</b> , function( e ) * { * // Alerts the new state. * alert( this.state ); * }); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.focusManager} class, which is used * to handle the focus on editor instances.. */ /** * Creates a focusManager class instance. * @class Manages the focus activity in an editor instance. This class is to be * used mainly by UI elements coders when adding interface elements that need * to set the focus state of the editor. * @param {CKEDITOR.editor} editor The editor instance. * @example * var focusManager = <b>new CKEDITOR.focusManager( editor )</b>; * focusManager.focus(); */ CKEDITOR.focusManager = function( editor ) { if ( editor.focusManager ) return editor.focusManager; /** * Indicates that the editor instance has focus. * @type Boolean * @example * alert( CKEDITOR.instances.editor1.focusManager.hasFocus ); // e.g "true" */ this.hasFocus = false; /** * Object used to hold private stuff. * @private */ this._ = { editor : editor }; return this; }; CKEDITOR.focusManager.prototype = { /** * Used to indicate that the editor instance has the focus.<br /> * <br /> * Note that this function will not explicitelly set the focus in the * editor (for example, making the caret blinking on it). Use * {@link CKEDITOR.editor#focus} for it instead. * @example * var editor = CKEDITOR.instances.editor1; * <b>editor.focusManager.focus()</b>; */ focus : function() { if ( this._.timer ) clearTimeout( this._.timer ); if ( !this.hasFocus ) { // If another editor has the current focus, we first "blur" it. In // this way the events happen in a more logical sequence, like: // "focus 1" > "blur 1" > "focus 2" // ... instead of: // "focus 1" > "focus 2" > "blur 1" if ( CKEDITOR.currentInstance ) CKEDITOR.currentInstance.focusManager.forceBlur(); var editor = this._.editor; editor.container.getChild( 1 ).addClass( 'cke_focus' ); this.hasFocus = true; editor.fire( 'focus' ); } }, /** * Used to indicate that the editor instance has lost the focus.<br /> * <br /> * Note that this functions acts asynchronously with a delay of 100ms to * avoid subsequent blur/focus effects. If you want the "blur" to happen * immediately, use the {@link #forceBlur} function instead. * @example * var editor = CKEDITOR.instances.editor1; * <b>editor.focusManager.blur()</b>; */ blur : function() { var focusManager = this; if ( focusManager._.timer ) clearTimeout( focusManager._.timer ); focusManager._.timer = setTimeout( function() { delete focusManager._.timer; focusManager.forceBlur(); } , 100 ); }, /** * Used to indicate that the editor instance has lost the focus. Unlike * {@link #blur}, this function is synchronous, marking the instance as * "blured" immediately. * @example * var editor = CKEDITOR.instances.editor1; * <b>editor.focusManager.forceBlur()</b>; */ forceBlur : function() { if ( this.hasFocus ) { var editor = this._.editor; editor.container.getChild( 1 ).removeClass( 'cke_focus' ); this.hasFocus = false; editor.fire( 'blur' ); } } }; /** * Fired when the editor instance receives the input focus. * @name CKEDITOR.editor#focus * @event * @param {CKEDITOR.editor} editor The editor instance. * @example * editor.on( 'focus', function( e ) * { * alert( 'The editor named ' + e.editor.name + ' is now focused' ); * }); */ /** * Fired when the editor instance loses the input focus. * @name CKEDITOR.editor#blur * @event * @param {CKEDITOR.editor} editor The editor instance. * @example * editor.on( 'blur', function( e ) * { * alert( 'The editor named ' + e.editor.name + ' lost the focus' ); * }); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.env} object, which constains * environment and browser information. */ if ( !CKEDITOR.env ) { /** * @namespace Environment and browser information. */ CKEDITOR.env = (function() { var agent = navigator.userAgent.toLowerCase(); var opera = window.opera; var env = /** @lends CKEDITOR.env */ { /** * Indicates that CKEditor is running on Internet Explorer. * @type Boolean * @example * if ( CKEDITOR.env.ie ) * alert( "I'm on IE!" ); */ ie : /*@cc_on!@*/false, /** * Indicates that CKEditor is running on Opera. * @type Boolean * @example * if ( CKEDITOR.env.opera ) * alert( "I'm on Opera!" ); */ opera : ( !!opera && opera.version ), /** * Indicates that CKEditor is running on a WebKit based browser, like * Safari. * @type Boolean * @example * if ( CKEDITOR.env.webkit ) * alert( "I'm on WebKit!" ); */ webkit : ( agent.indexOf( ' applewebkit/' ) > -1 ), /** * Indicates that CKEditor is running on Adobe AIR. * @type Boolean * @example * if ( CKEDITOR.env.air ) * alert( "I'm on AIR!" ); */ air : ( agent.indexOf( ' adobeair/' ) > -1 ), /** * Indicates that CKEditor is running on Macintosh. * @type Boolean * @example * if ( CKEDITOR.env.mac ) * alert( "I love apples!" ); */ mac : ( agent.indexOf( 'macintosh' ) > -1 ), /** * Indicates that CKEditor is running on a quirks mode environemnt. * @type Boolean * @example * if ( CKEDITOR.env.quirks ) * alert( "Nooooo!" ); */ quirks : ( document.compatMode == 'BackCompat' ), /** * Indicates that CKEditor is running on a mobile like environemnt. * @type Boolean * @example * if ( CKEDITOR.env.mobile ) * alert( "I'm running with CKEditor today!" ); */ mobile : ( agent.indexOf( 'mobile' ) > -1 ), /** * Indicates that the browser has a custom domain enabled. This has * been set with "document.domain". * @returns {Boolean} "true" if a custom domain is enabled. * @example * if ( CKEDITOR.env.isCustomDomain() ) * alert( "I'm in a custom domain!" ); */ isCustomDomain : function() { if ( !this.ie ) return false; var domain = document.domain, hostname = window.location.hostname; return domain != hostname && domain != ( '[' + hostname + ']' ); // IPv6 IP support (#5434) } }; /** * Indicates that CKEditor is running on a Gecko based browser, like * Firefox. * @name CKEDITOR.env.gecko * @type Boolean * @example * if ( CKEDITOR.env.gecko ) * alert( "I'm riding a gecko!" ); */ env.gecko = ( navigator.product == 'Gecko' && !env.webkit && !env.opera ); var version = 0; // Internet Explorer 6.0+ if ( env.ie ) { version = parseFloat( agent.match( /msie (\d+)/ )[1] ); /** * Indicates that CKEditor is running on Internet Explorer 8. * @name CKEDITOR.env.ie8 * @type Boolean * @example * if ( CKEDITOR.env.ie8 ) * alert( "I'm on IE8!" ); */ env.ie8 = !!document.documentMode; /** * Indicates that CKEditor is running on Internet Explorer 8 on * standards mode. * @name CKEDITOR.env.ie8Compat * @type Boolean * @example * if ( CKEDITOR.env.ie8Compat ) * alert( "Now I'm on IE8, for real!" ); */ env.ie8Compat = document.documentMode == 8; /** * Indicates that CKEditor is running on an IE7-like environment, which * includes IE7 itself and IE8's IE7 document mode. * @name CKEDITOR.env.ie7Compat * @type Boolean * @example * if ( CKEDITOR.env.ie8Compat ) * alert( "I'm on IE7 or on an IE7 like IE8!" ); */ env.ie7Compat = ( ( version == 7 && !document.documentMode ) || document.documentMode == 7 ); /** * Indicates that CKEditor is running on an IE6-like environment, which * includes IE6 itself and IE7 and IE8 quirks mode. * @name CKEDITOR.env.ie6Compat * @type Boolean * @example * if ( CKEDITOR.env.ie6Compat ) * alert( "I'm on IE6 or quirks mode!" ); */ env.ie6Compat = ( version < 7 || env.quirks ); } // Gecko. if ( env.gecko ) { var geckoRelease = agent.match( /rv:([\d\.]+)/ ); if ( geckoRelease ) { geckoRelease = geckoRelease[1].split( '.' ); version = geckoRelease[0] * 10000 + ( geckoRelease[1] || 0 ) * 100 + ( geckoRelease[2] || 0 ) * 1; } } // Opera 9.50+ if ( env.opera ) version = parseFloat( opera.version() ); // Adobe AIR 1.0+ // Checked before Safari because AIR have the WebKit rich text editor // features from Safari 3.0.4, but the version reported is 420. if ( env.air ) version = parseFloat( agent.match( / adobeair\/(\d+)/ )[1] ); // WebKit 522+ (Safari 3+) if ( env.webkit ) version = parseFloat( agent.match( / applewebkit\/(\d+)/ )[1] ); /** * Contains the browser version.<br /> * <br /> * For gecko based browsers (like Firefox) it contains the revision * number with first three parts concatenated with a padding zero * (e.g. for revision 1.9.0.2 we have 10900).<br /> * <br /> * For webkit based browser (like Safari and Chrome) it contains the * WebKit build version (e.g. 522). * @name CKEDITOR.env.version * @type Boolean * @example * if ( CKEDITOR.env.ie && <b>CKEDITOR.env.version</b> <= 6 ) * alert( "Ouch!" ); */ env.version = version; /** * Indicates that CKEditor is running on a compatible browser. * @name CKEDITOR.env.isCompatible * @type Boolean * @example * if ( CKEDITOR.env.isCompatible ) * alert( "Your browser is pretty cool!" ); */ env.isCompatible = !env.mobile && ( ( env.ie && version >= 6 ) || ( env.gecko && version >= 10801 ) || ( env.opera && version >= 9.5 ) || ( env.air && version >= 1 ) || ( env.webkit && version >= 522 ) || false ); /** * The CSS class to be appended on the main UI containers, making it * easy to apply browser specific styles to it. * @name CKEDITOR.env.cssClass * @type String * @example * myDiv.className = CKEDITOR.env.cssClass; */ env.cssClass = 'cke_browser_' + ( env.ie ? 'ie' : env.gecko ? 'gecko' : env.opera ? 'opera' : env.webkit ? 'webkit' : 'unknown' ); if ( env.quirks ) env.cssClass += ' cke_browser_quirks'; if ( env.ie ) { env.cssClass += ' cke_browser_ie' + ( env.version < 7 ? '6' : env.version >= 8 ? document.documentMode: '7' ); if ( env.quirks ) env.cssClass += ' cke_browser_iequirks'; } if ( env.gecko && version < 10900 ) env.cssClass += ' cke_browser_gecko18'; if ( env.air ) env.cssClass += ' cke_browser_air'; return env; })(); } // PACKAGER_RENAME( CKEDITOR.env ) // PACKAGER_RENAME( CKEDITOR.env.ie )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.config} object, which holds the * default configuration settings. */ /** * Used in conjuction with {@link CKEDITOR.config.enterMode} and * {@link CKEDITOR.config.shiftEnterMode} to make the editor produce &lt;p&gt; * tags when using the ENTER key. * @constant */ CKEDITOR.ENTER_P = 1; /** * Used in conjuction with {@link CKEDITOR.config.enterMode} and * {@link CKEDITOR.config.shiftEnterMode} to make the editor produce &lt;br&gt; * tags when using the ENTER key. * @constant */ CKEDITOR.ENTER_BR = 2; /** * Used in conjuction with {@link CKEDITOR.config.enterMode} and * {@link CKEDITOR.config.shiftEnterMode} to make the editor produce &lt;div&gt; * tags when using the ENTER key. * @constant */ CKEDITOR.ENTER_DIV = 3; /** * @namespace Holds the default configuration settings. Changes to this object are * reflected in all editor instances, if not specificaly specified for those * instances. */ CKEDITOR.config = { /** * The URL path for the custom configuration file to be loaded. If not * overloaded with inline configurations, it defaults to the "config.js" * file present in the root of the CKEditor installation directory.<br /><br /> * * CKEditor will recursively load custom configuration files defined inside * other custom configuration files. * @type String * @default '&lt;CKEditor folder&gt;/config.js' * @example * // Load a specific configuration file. * CKEDITOR.replace( 'myfiled', { customConfig : '/myconfig.js' } ); * @example * // Do not load any custom configuration file. * CKEDITOR.replace( 'myfiled', { customConfig : '' } ); */ customConfig : 'config.js', /** * Whether the replaced element (usually a textarea) is to be updated * automatically when posting the form containing the editor. * @type Boolean * @default true * @example * config.autoUpdateElement = true; */ autoUpdateElement : true, /** * The base href URL used to resolve relative and absolute URLs in the * editor content. * @type String * @default '' (empty) * @example * config.baseHref = 'http://www.example.com/path/'; */ baseHref : '', /** * The CSS file(s) to be used to apply style to the contents. It should * reflect the CSS used in the final pages where the contents are to be * used. * @type String|Array * @default '&lt;CKEditor folder&gt;/contents.css' * @example * config.contentsCss = '/css/mysitestyles.css'; * config.contentsCss = ['/css/mysitestyles.css', '/css/anotherfile.css']; */ contentsCss : CKEDITOR.basePath + 'contents.css', /** * The writting direction of the language used to write the editor * contents. Allowed values are: * <ul> * <li>'ui' - which indicate content direction will be the same with the user interface language direction;</li> * <li>'ltr' - for Left-To-Right language (like English);</li> * <li>'rtl' - for Right-To-Left languages (like Arabic).</li> * </ul> * @default 'ui' * @type String * @example * config.contentsLangDirection = 'rtl'; */ contentsLangDirection : 'ui', /** * Language code of the writting language which is used to author the editor * contents. * @default Same value with editor's UI language. * @type String * @example * config.contentsLanguage = 'fr'; */ contentsLanguage : '', /** * The user interface language localization to use. If empty, the editor * automatically localize the editor to the user language, if supported, * otherwise the {@link CKEDITOR.config.defaultLanguage} language is used. * @default '' (empty) * @type String * @example * // Load the German interface. * config.language = 'de'; */ language : '', /** * The language to be used if {@link CKEDITOR.config.language} is left empty and it's not * possible to localize the editor to the user language. * @default 'en' * @type String * @example * config.defaultLanguage = 'it'; */ defaultLanguage : 'en', /** * Sets the behavior for the ENTER key. It also dictates other behaviour * rules in the editor, like whether the &lt;br&gt; element is to be used * as a paragraph separator when indenting text. * The allowed values are the following constants, and their relative * behavior: * <ul> * <li>{@link CKEDITOR.ENTER_P} (1): new &lt;p&gt; paragraphs are created;</li> * <li>{@link CKEDITOR.ENTER_BR} (2): lines are broken with &lt;br&gt; elements;</li> * <li>{@link CKEDITOR.ENTER_DIV} (3): new &lt;div&gt; blocks are created.</li> * </ul> * <strong>Note</strong>: It's recommended to use the * {@link CKEDITOR.ENTER_P} value because of its semantic value and * correctness. The editor is optimized for this value. * @type Number * @default {@link CKEDITOR.ENTER_P} * @example * // Not recommended. * config.enterMode = CKEDITOR.ENTER_BR; */ enterMode : CKEDITOR.ENTER_P, /** * Force the respect of {@link CKEDITOR.config.enterMode} as line break regardless of the context, * E.g. If {@link CKEDITOR.config.enterMode} is set to {@link CKEDITOR.ENTER_P}, * press enter key inside a 'div' will create a new paragraph with 'p' instead of 'div'. * @since 3.2.1 * @default false * @example * // Not recommended. * config.forceEnterMode = true; */ forceEnterMode : false, /** * Just like the {@link CKEDITOR.config.enterMode} setting, it defines the behavior for the SHIFT+ENTER key. * The allowed values are the following constants, and their relative * behavior: * <ul> * <li>{@link CKEDITOR.ENTER_P} (1): new &lt;p&gt; paragraphs are created;</li> * <li>{@link CKEDITOR.ENTER_BR} (2): lines are broken with &lt;br&gt; elements;</li> * <li>{@link CKEDITOR.ENTER_DIV} (3): new &lt;div&gt; blocks are created.</li> * </ul> * @type Number * @default {@link CKEDITOR.ENTER_BR} * @example * config.shiftEnterMode = CKEDITOR.ENTER_P; */ shiftEnterMode : CKEDITOR.ENTER_BR, /** * A comma separated list of plugins that are not related to editor * instances. Reserved to plugins that extend the core code only.<br /><br /> * * There are no ways to override this setting, except by editing the source * code of CKEditor (_source/core/config.js). * @type String * @example */ corePlugins : '', /** * Sets the doctype to be used when loading the editor content as HTML. * @type String * @default '&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;' * @example * // Set the doctype to the HTML 4 (quirks) mode. * config.docType = '&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"&gt;'; */ docType : '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">', /** * Sets the "id" attribute to be used on the body element of the editing * area. This can be useful when reusing the original CSS file you're using * on your live website and you want to assing to the editor the same id * you're using for the region that'll hold the contents. In this way, * id specific CSS rules will be enabled. * @since 3.1 * @type String * @default '' (empty) * @example * config.bodyId = 'contents_id'; */ bodyId : '', /** * Sets the "class" attribute to be used on the body element of the editing * area. This can be useful when reusing the original CSS file you're using * on your live website and you want to assing to the editor the same class * name you're using for the region that'll hold the contents. In this way, * class specific CSS rules will be enabled. * @since 3.1 * @type String * @default '' (empty) * @example * config.bodyClass = 'contents'; */ bodyClass : '', /** * Indicates whether the contents to be edited are being inputted as a full * HTML page. A full page includes the &lt;html&gt;, &lt;head&gt; and * &lt;body&gt; tags. The final output will also reflect this setting, * including the &lt;body&gt; contents only if this setting is disabled. * @since 3.1 * @type Boolean * @default false * @example * config.fullPage = true; */ fullPage : false, /** * The height of editing area( content ), in relative or absolute, e.g. 30px, 5em. * Note: Percentage unit is not supported yet. e.g. 30%. * @type Number|String * @default '200' * @example * config.height = 500; * config.height = '25em'; * config.height = '300px'; */ height : 200, /** * Comma separated list of plugins to load and initialize for an editor * instance. This should be rarely changed, using instead the * {@link CKEDITOR.config.extraPlugins} and * {@link CKEDITOR.config.removePlugins} for customizations. * @type String * @example */ plugins : 'about,' + 'a11yhelp,' + 'basicstyles,' + 'bidi,' + 'blockquote,' + 'button,' + 'clipboard,' + 'colorbutton,' + 'colordialog,' + 'contextmenu,' + 'dialogadvtab,' + 'div,' + 'elementspath,' + 'enterkey,' + 'entities,' + 'filebrowser,' + 'find,' + 'flash,' + 'font,' + 'format,' + 'forms,' + 'horizontalrule,' + 'htmldataprocessor,' + 'iframe,' + 'image,' + 'indent,' + 'justify,' + 'keystrokes,' + 'link,' + 'list,' + 'liststyle,' + 'maximize,' + 'newpage,' + 'pagebreak,' + 'pastefromword,' + 'pastetext,' + 'popup,' + 'preview,' + 'print,' + 'removeformat,' + 'resize,' + 'save,' + 'scayt,' + 'smiley,' + 'showblocks,' + 'showborders,' + 'sourcearea,' + 'stylescombo,' + 'table,' + 'tabletools,' + 'specialchar,' + 'tab,' + 'templates,' + 'toolbar,' + 'undo,' + 'wysiwygarea,' + 'wsc', /** * List of additional plugins to be loaded. This is a tool setting which * makes it easier to add new plugins, whithout having to touch and * possibly breaking the {@link CKEDITOR.config.plugins} setting. * @type String * @example * config.extraPlugins = 'myplugin,anotherplugin'; */ extraPlugins : '', /** * List of plugins that must not be loaded. This is a tool setting which * makes it easier to avoid loading plugins definied in the * {@link CKEDITOR.config.plugins} setting, whithout having to touch it and * potentially breaking it. * @type String * @example * config.removePlugins = 'elementspath,save,font'; */ removePlugins : '', /** * List of regular expressions to be executed over the input HTML, * indicating HTML source code that matched must <strong>not</strong> present in WYSIWYG mode for editing. * @type Array * @default [] (empty array) * @example * config.protectedSource.push( /<\?[\s\S]*?\?>/g ); // PHP Code * config.protectedSource.push( /<%[\s\S]*?%>/g ); // ASP Code * config.protectedSource.push( /(<asp:[^\>]+>[\s|\S]*?<\/asp:[^\>]+>)|(<asp:[^\>]+\/>)/gi ); // ASP.Net Code */ protectedSource : [], /** * The editor tabindex value. * @type Number * @default 0 (zero) * @example * config.tabIndex = 1; */ tabIndex : 0, /** * The theme to be used to build the UI. * @type String * @default 'default' * @see CKEDITOR.config.skin * @example * config.theme = 'default'; */ theme : 'default', /** * The skin to load. It may be the name of the skin folder inside the * editor installation path, or the name and the path separated by a comma. * @type String * @default 'default' * @example * config.skin = 'v2'; * @example * config.skin = 'myskin,/customstuff/myskin/'; */ skin : 'kama', /** * The editor width in CSS size format or pixel integer. * @type String|Number * @default '' (empty) * @example * config.width = 850; * @example * config.width = '75%'; */ width : '', /** * The base Z-index for floating dialogs and popups. * @type Number * @default 10000 * @example * config.baseFloatZIndex = 2000 */ baseFloatZIndex : 10000 }; /** * Indicates that some of the editor features, like alignment and text * direction, should used the "computed value" of the feature to indicate it's * on/off state, instead of using the "real value".<br /> * <br /> * If enabled, in a left to right written document, the "Left Justify" * alignment button will show as active, even if the aligment style is not * explicitly applied to the current paragraph in the editor. * @name CKEDITOR.config.useComputedState * @type Boolean * @default true * @since 3.4 * @example * config.useComputedState = false; */ // PACKAGER_RENAME( CKEDITOR.config )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ if ( !CKEDITOR.editor ) { /** * No element is linked to the editor instance. * @constant * @example */ CKEDITOR.ELEMENT_MODE_NONE = 0; /** * The element is to be replaced by the editor instance. * @constant * @example */ CKEDITOR.ELEMENT_MODE_REPLACE = 1; /** * The editor is to be created inside the element. * @constant * @example */ CKEDITOR.ELEMENT_MODE_APPENDTO = 2; /** * Creates an editor class instance. This constructor should be rarely * used, in favor of the {@link CKEDITOR} editor creation functions. * @ class Represents an editor instance. * @param {Object} instanceConfig Configuration values for this specific * instance. * @param {CKEDITOR.dom.element} [element] The element linked to this * instance. * @param {Number} [mode] The mode in which the element is linked to this * instance. See {@link #elementMode}. * @param {String} [data] Since 3.3. Initial value for the instance. * @augments CKEDITOR.event * @example */ CKEDITOR.editor = function( instanceConfig, element, mode, data ) { this._ = { // Save the config to be processed later by the full core code. instanceConfig : instanceConfig, element : element, data : data }; /** * The mode in which the {@link #element} is linked to this editor * instance. It can be any of the following values: * <ul> * <li>{@link CKEDITOR.ELEMENT_MODE_NONE}: No element is linked to the * editor instance.</li> * <li>{@link CKEDITOR.ELEMENT_MODE_REPLACE}: The element is to be * replaced by the editor instance.</li> * <li>{@link CKEDITOR.ELEMENT_MODE_APPENDTO}: The editor is to be * created inside the element.</li> * </ul> * @name CKEDITOR.editor.prototype.elementMode * @type Number * @example * var editor = CKEDITOR.replace( 'editor1' ); * alert( <b>editor.elementMode</b> ); "1" */ this.elementMode = mode || CKEDITOR.ELEMENT_MODE_NONE; // Call the CKEDITOR.event constructor to initialize this instance. CKEDITOR.event.call( this ); this._init(); }; /** * Replaces a &lt;textarea&gt; or a DOM element (DIV) with a CKEditor * instance. For textareas, the initial value in the editor will be the * textarea value. For DOM elements, their innerHTML will be used * instead. We recommend using TEXTAREA and DIV elements only. Do not use * this function directly. Use {@link CKEDITOR.replace} instead. * @param {Object|String} elementOrIdOrName The DOM element (textarea), its * ID or name. * @param {Object} [config] The specific configurations to apply to this * editor instance. Configurations set here will override global CKEditor * settings. * @returns {CKEDITOR.editor} The editor instance created. * @example */ CKEDITOR.editor.replace = function( elementOrIdOrName, config ) { var element = elementOrIdOrName; if ( typeof element != 'object' ) { // Look for the element by id. We accept any kind of element here. element = document.getElementById( elementOrIdOrName ); // If not found, look for elements by name. In this case we accept only // textareas. if ( !element ) { var i = 0, textareasByName = document.getElementsByName( elementOrIdOrName ); while ( ( element = textareasByName[ i++ ] ) && element.tagName.toLowerCase() != 'textarea' ) { /*jsl:pass*/ } } if ( !element ) throw '[CKEDITOR.editor.replace] The element with id or name "' + elementOrIdOrName + '" was not found.'; } // Do not replace the textarea right now, just hide it. The effective // replacement will be done by the _init function. element.style.visibility = 'hidden'; // Create the editor instance. return new CKEDITOR.editor( config, element, CKEDITOR.ELEMENT_MODE_REPLACE ); }; /** * Creates a new editor instance inside a specific DOM element. Do not use * this function directly. Use {@link CKEDITOR.appendTo} instead. * @param {Object|String} elementOrId The DOM element or its ID. * @param {Object} [config] The specific configurations to apply to this * editor instance. Configurations set here will override global CKEditor * settings. * @param {String} [data] Since 3.3. Initial value for the instance. * @returns {CKEDITOR.editor} The editor instance created. * @example */ CKEDITOR.editor.appendTo = function( elementOrId, config, data ) { var element = elementOrId; if ( typeof element != 'object' ) { element = document.getElementById( elementOrId ); if ( !element ) throw '[CKEDITOR.editor.appendTo] The element with id "' + elementOrId + '" was not found.'; } // Create the editor instance. return new CKEDITOR.editor( config, element, CKEDITOR.ELEMENT_MODE_APPENDTO, data ); }; CKEDITOR.editor.prototype = { /** * Initializes the editor instance. This function will be overriden by the * full CKEDITOR.editor implementation (editor.js). * @private */ _init : function() { var pending = CKEDITOR.editor._pending || ( CKEDITOR.editor._pending = [] ); pending.push( this ); }, // Both fire and fireOnce will always pass this editor instance as the // "editor" param in CKEDITOR.event.fire. So, we override it to do that // automaticaly. /** @ignore */ fire : function( eventName, data ) { return CKEDITOR.event.prototype.fire.call( this, eventName, data, this ); }, /** @ignore */ fireOnce : function( eventName, data ) { return CKEDITOR.event.prototype.fireOnce.call( this, eventName, data, this ); } }; // "Inherit" (copy actually) from CKEDITOR.event. CKEDITOR.event.implementOn( CKEDITOR.editor.prototype, true ); }
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.editor} class, which represents an * editor instance. */ (function() { // The counter for automatic instance names. var nameCounter = 0; var getNewName = function() { var name = 'editor' + ( ++nameCounter ); return ( CKEDITOR.instances && CKEDITOR.instances[ name ] ) ? getNewName() : name; }; // ##### START: Config Privates // These function loads custom configuration files and cache the // CKEDITOR.editorConfig functions defined on them, so there is no need to // download them more than once for several instances. var loadConfigLoaded = {}; var loadConfig = function( editor ) { var customConfig = editor.config.customConfig; // Check if there is a custom config to load. if ( !customConfig ) return false; customConfig = CKEDITOR.getUrl( customConfig ); var loadedConfig = loadConfigLoaded[ customConfig ] || ( loadConfigLoaded[ customConfig ] = {} ); // If the custom config has already been downloaded, reuse it. if ( loadedConfig.fn ) { // Call the cached CKEDITOR.editorConfig defined in the custom // config file for the editor instance depending on it. loadedConfig.fn.call( editor, editor.config ); // If there is no other customConfig in the chain, fire the // "configLoaded" event. if ( CKEDITOR.getUrl( editor.config.customConfig ) == customConfig || !loadConfig( editor ) ) editor.fireOnce( 'customConfigLoaded' ); } else { // Load the custom configuration file. CKEDITOR.scriptLoader.load( customConfig, function() { // If the CKEDITOR.editorConfig function has been properly // defined in the custom configuration file, cache it. if ( CKEDITOR.editorConfig ) loadedConfig.fn = CKEDITOR.editorConfig; else loadedConfig.fn = function(){}; // Call the load config again. This time the custom // config is already cached and so it will get loaded. loadConfig( editor ); }); } return true; }; var initConfig = function( editor, instanceConfig ) { // Setup the lister for the "customConfigLoaded" event. editor.on( 'customConfigLoaded', function() { if ( instanceConfig ) { // Register the events that may have been set at the instance // configuration object. if ( instanceConfig.on ) { for ( var eventName in instanceConfig.on ) { editor.on( eventName, instanceConfig.on[ eventName ] ); } } // Overwrite the settings from the in-page config. CKEDITOR.tools.extend( editor.config, instanceConfig, true ); delete editor.config.on; } onConfigLoaded( editor ); }); // The instance config may override the customConfig setting to avoid // loading the default ~/config.js file. if ( instanceConfig && instanceConfig.customConfig != undefined ) editor.config.customConfig = instanceConfig.customConfig; // Load configs from the custom configuration files. if ( !loadConfig( editor ) ) editor.fireOnce( 'customConfigLoaded' ); }; // ##### END: Config Privates var onConfigLoaded = function( editor ) { // Set config related properties. var skin = editor.config.skin.split( ',' ), skinName = skin[ 0 ], skinPath = CKEDITOR.getUrl( skin[ 1 ] || ( '_source/' + // @Packager.RemoveLine 'skins/' + skinName + '/' ) ); /** * The name of the skin used by this editor instance. The skin name can * be set though the {@link CKEDITOR.config.skin} setting. * @name CKEDITOR.editor.prototype.skinName * @type String * @example * alert( editor.skinName ); // "kama" (e.g.) */ editor.skinName = skinName; /** * The full URL of the skin directory. * @name CKEDITOR.editor.prototype.skinPath * @type String * @example * alert( editor.skinPath ); // "http://example.com/ckeditor/skins/kama/" (e.g.) */ editor.skinPath = skinPath; /** * The CSS class name used for skin identification purposes. * @name CKEDITOR.editor.prototype.skinClass * @type String * @example * alert( editor.skinClass ); // "cke_skin_kama" (e.g.) */ editor.skinClass = 'cke_skin_' + skinName; /** * The <a href="http://en.wikipedia.org/wiki/Tabbing_navigation">tabbing * navigation</a> order that has been calculated for this editor * instance. This can be set by the {@link CKEDITOR.config.tabIndex} * setting or taken from the "tabindex" attribute of the * {@link #element} associated to the editor. * @name CKEDITOR.editor.prototype.tabIndex * @type Number * @default 0 (zero) * @example * alert( editor.tabIndex ); // "0" (e.g.) */ editor.tabIndex = editor.config.tabIndex || editor.element.getAttribute( 'tabindex' ) || 0; // Fire the "configLoaded" event. editor.fireOnce( 'configLoaded' ); // Load language file. loadSkin( editor ); }; var loadLang = function( editor ) { CKEDITOR.lang.load( editor.config.language, editor.config.defaultLanguage, function( languageCode, lang ) { /** * The code for the language resources that have been loaded * for the user internface elements of this editor instance. * @name CKEDITOR.editor.prototype.langCode * @type String * @example * alert( editor.langCode ); // "en" (e.g.) */ editor.langCode = languageCode; /** * An object holding all language strings used by the editor * interface. * @name CKEDITOR.editor.prototype.lang * @type CKEDITOR.lang * @example * alert( editor.lang.bold ); // "Negrito" (e.g. if language is Portuguese) */ // As we'll be adding plugin specific entries that could come // from different language code files, we need a copy of lang, // not a direct reference to it. editor.lang = CKEDITOR.tools.prototypedCopy( lang ); // We're not able to support RTL in Firefox 2 at this time. if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 && editor.lang.dir == 'rtl' ) editor.lang.dir = 'ltr'; var config = editor.config; config.contentsLangDirection == 'ui' && ( config.contentsLangDirection = editor.lang.dir ); loadPlugins( editor ); }); }; var loadPlugins = function( editor ) { var config = editor.config, plugins = config.plugins, extraPlugins = config.extraPlugins, removePlugins = config.removePlugins; if ( extraPlugins ) { // Remove them first to avoid duplications. var removeRegex = new RegExp( '(?:^|,)(?:' + extraPlugins.replace( /\s*,\s*/g, '|' ) + ')(?=,|$)' , 'g' ); plugins = plugins.replace( removeRegex, '' ); plugins += ',' + extraPlugins; } if ( removePlugins ) { removeRegex = new RegExp( '(?:^|,)(?:' + removePlugins.replace( /\s*,\s*/g, '|' ) + ')(?=,|$)' , 'g' ); plugins = plugins.replace( removeRegex, '' ); } // Load the Adobe AIR plugin conditionally. CKEDITOR.env.air && ( plugins += ',adobeair' ); // Load all plugins defined in the "plugins" setting. CKEDITOR.plugins.load( plugins.split( ',' ), function( plugins ) { // The list of plugins. var pluginsArray = []; // The language code to get loaded for each plugin. Null // entries will be appended for plugins with no language files. var languageCodes = []; // The list of URLs to language files. var languageFiles = []; /** * And object holding references to all plugins used by this * editor istance. * @name CKEDITOR.editor.prototype.plugins * @type Object * @example * alert( editor.plugins.dialog.path ); // "http://example.com/ckeditor/plugins/dialog/" (e.g.) */ editor.plugins = plugins; // Loop through all plugins, to build the list of language // files to get loaded. for ( var pluginName in plugins ) { var plugin = plugins[ pluginName ], pluginLangs = plugin.lang, pluginPath = CKEDITOR.plugins.getPath( pluginName ), lang = null; // Set the plugin path in the plugin. plugin.path = pluginPath; // If the plugin has "lang". if ( pluginLangs ) { // Resolve the plugin language. If the current language // is not available, get the first one (default one). lang = ( CKEDITOR.tools.indexOf( pluginLangs, editor.langCode ) >= 0 ? editor.langCode : pluginLangs[ 0 ] ); if ( !plugin.lang[ lang ] ) { // Put the language file URL into the list of files to // get downloaded. languageFiles.push( CKEDITOR.getUrl( pluginPath + 'lang/' + lang + '.js' ) ); } else { CKEDITOR.tools.extend( editor.lang, plugin.lang[ lang ] ); lang = null; } } // Save the language code, so we know later which // language has been resolved to this plugin. languageCodes.push( lang ); pluginsArray.push( plugin ); } // Load all plugin specific language files in a row. CKEDITOR.scriptLoader.load( languageFiles, function() { // Initialize all plugins that have the "beforeInit" and "init" methods defined. var methods = [ 'beforeInit', 'init', 'afterInit' ]; for ( var m = 0 ; m < methods.length ; m++ ) { for ( var i = 0 ; i < pluginsArray.length ; i++ ) { var plugin = pluginsArray[ i ]; // Uses the first loop to update the language entries also. if ( m === 0 && languageCodes[ i ] && plugin.lang ) CKEDITOR.tools.extend( editor.lang, plugin.lang[ languageCodes[ i ] ] ); // Call the plugin method (beforeInit and init). if ( plugin[ methods[ m ] ] ) plugin[ methods[ m ] ]( editor ); } } // Load the editor skin. editor.fire( 'pluginsLoaded' ); loadTheme( editor ); }); }); }; var loadSkin = function( editor ) { CKEDITOR.skins.load( editor, 'editor', function() { loadLang( editor ); }); }; var loadTheme = function( editor ) { var theme = editor.config.theme; CKEDITOR.themes.load( theme, function() { /** * The theme used by this editor instance. * @name CKEDITOR.editor.prototype.theme * @type CKEDITOR.theme * @example * alert( editor.theme ); "http://example.com/ckeditor/themes/default/" (e.g.) */ var editorTheme = editor.theme = CKEDITOR.themes.get( theme ); editorTheme.path = CKEDITOR.themes.getPath( theme ); editorTheme.build( editor ); if ( editor.config.autoUpdateElement ) attachToForm( editor ); }); }; var attachToForm = function( editor ) { var element = editor.element; // If are replacing a textarea, we must if ( editor.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE && element.is( 'textarea' ) ) { var form = element.$.form && new CKEDITOR.dom.element( element.$.form ); if ( form ) { function onSubmit() { editor.updateElement(); } form.on( 'submit',onSubmit ); // Setup the submit function because it doesn't fire the // "submit" event. if ( !form.$.submit.nodeName ) { form.$.submit = CKEDITOR.tools.override( form.$.submit, function( originalSubmit ) { return function() { editor.updateElement(); // For IE, the DOM submit function is not a // function, so we need thid check. if ( originalSubmit.apply ) originalSubmit.apply( this, arguments ); else originalSubmit(); }; }); } // Remove 'submit' events registered on form element before destroying.(#3988) editor.on( 'destroy', function() { form.removeListener( 'submit', onSubmit ); } ); } } }; function updateCommandsMode() { var command, commands = this._.commands, mode = this.mode; for ( var name in commands ) { command = commands[ name ]; command[ command.startDisabled ? 'disable' : command.modes[ mode ] ? 'enable' : 'disable' ](); } } /** * Initializes the editor instance. This function is called by the editor * contructor (editor_basic.js). * @private */ CKEDITOR.editor.prototype._init = function() { // Get the properties that have been saved in the editor_base // implementation. var element = CKEDITOR.dom.element.get( this._.element ), instanceConfig = this._.instanceConfig; delete this._.element; delete this._.instanceConfig; this._.commands = {}; this._.styles = []; /** * The DOM element that has been replaced by this editor instance. This * element holds the editor data on load and post. * @name CKEDITOR.editor.prototype.element * @type CKEDITOR.dom.element * @example * var editor = CKEDITOR.instances.editor1; * alert( <b>editor.element</b>.getName() ); "textarea" */ this.element = element; /** * The editor instance name. It hay be the replaced element id, name or * a default name using a progressive counter (editor1, editor2, ...). * @name CKEDITOR.editor.prototype.name * @type String * @example * var editor = CKEDITOR.instances.editor1; * alert( <b>editor.name</b> ); "editor1" */ this.name = ( element && ( this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) && ( element.getId() || element.getNameAtt() ) ) || getNewName(); if ( this.name in CKEDITOR.instances ) throw '[CKEDITOR.editor] The instance "' + this.name + '" already exists.'; /** * A unique random string assigned to each editor instance in the page. * @name CKEDITOR.editor.prototype.id * @type String */ this.id = CKEDITOR.tools.getNextId(); /** * The configurations for this editor instance. It inherits all * settings defined in (@link CKEDITOR.config}, combined with settings * loaded from custom configuration files and those defined inline in * the page when creating the editor. * @name CKEDITOR.editor.prototype.config * @type Object * @example * var editor = CKEDITOR.instances.editor1; * alert( <b>editor.config.theme</b> ); "default" e.g. */ this.config = CKEDITOR.tools.prototypedCopy( CKEDITOR.config ); /** * Namespace containing UI features related to this editor instance. * @name CKEDITOR.editor.prototype.ui * @type CKEDITOR.ui * @example */ this.ui = new CKEDITOR.ui( this ); /** * Controls the focus state of this editor instance. This property * is rarely used for normal API operations. It is mainly * destinated to developer adding UI elements to the editor interface. * @name CKEDITOR.editor.prototype.focusManager * @type CKEDITOR.focusManager * @example */ this.focusManager = new CKEDITOR.focusManager( this ); CKEDITOR.fire( 'instanceCreated', null, this ); this.on( 'mode', updateCommandsMode, null, null, 1 ); initConfig( this, instanceConfig ); }; })(); CKEDITOR.tools.extend( CKEDITOR.editor.prototype, /** @lends CKEDITOR.editor.prototype */ { /** * Adds a command definition to the editor instance. Commands added with * this function can be later executed with {@link #execCommand}. * @param {String} commandName The indentifier name of the command. * @param {CKEDITOR.commandDefinition} commandDefinition The command definition. * @example * editorInstance.addCommand( 'sample', * { * exec : function( editor ) * { * alert( 'Executing a command for the editor name "' + editor.name + '"!' ); * } * }); */ addCommand : function( commandName, commandDefinition ) { return this._.commands[ commandName ] = new CKEDITOR.command( this, commandDefinition ); }, /** * Add a trunk of css text to the editor which will be applied to the wysiwyg editing document. * Note: This function should be called before editor is loaded to take effect. * @param css {String} CSS text. * @example * editorInstance.addCss( 'body { background-color: grey; }' ); */ addCss : function( css ) { this._.styles.push( css ); }, /** * Destroys the editor instance, releasing all resources used by it. * If the editor replaced an element, the element will be recovered. * @param {Boolean} [noUpdate] If the instance is replacing a DOM * element, this parameter indicates whether or not to update the * element with the instance contents. * @example * alert( CKEDITOR.instances.editor1 ); e.g "object" * <b>CKEDITOR.instances.editor1.destroy()</b>; * alert( CKEDITOR.instances.editor1 ); "undefined" */ destroy : function( noUpdate ) { if ( !noUpdate ) this.updateElement(); if ( this.mode ) { // -> currentMode.unload( holderElement ); this._.modes[ this.mode ].unload( this.getThemeSpace( 'contents' ) ); } this.theme.destroy( this ); var toolbars, index = 0, j, items, instance; if ( this.toolbox ) { toolbars = this.toolbox.toolbars; for ( ; index < toolbars.length ; index++ ) { items = toolbars[ index ].items; for ( j = 0 ; j < items.length ; j++ ) { instance = items[ j ]; if ( instance.clickFn ) CKEDITOR.tools.removeFunction( instance.clickFn ); if ( instance.keyDownFn ) CKEDITOR.tools.removeFunction( instance.keyDownFn ); if ( instance.index ) CKEDITOR.ui.button._.instances[ instance.index ] = null; } } } if ( this.contextMenu ) CKEDITOR.tools.removeFunction( this.contextMenu._.functionId ); if ( this._.filebrowserFn ) CKEDITOR.tools.removeFunction( this._.filebrowserFn ); this.fire( 'destroy' ); CKEDITOR.remove( this ); CKEDITOR.fire( 'instanceDestroyed', null, this ); }, /** * Executes a command. * @param {String} commandName The indentifier name of the command. * @param {Object} [data] Data to be passed to the command * @returns {Boolean} "true" if the command has been successfuly * executed, otherwise "false". * @example * editorInstance.execCommand( 'Bold' ); */ execCommand : function( commandName, data ) { var command = this.getCommand( commandName ); var eventData = { name: commandName, commandData: data, command: command }; if ( command && command.state != CKEDITOR.TRISTATE_DISABLED ) { if ( this.fire( 'beforeCommandExec', eventData ) !== true ) { eventData.returnValue = command.exec( eventData.commandData ); // Fire the 'afterCommandExec' immediately if command is synchronous. if ( !command.async && this.fire( 'afterCommandExec', eventData ) !== true ) return eventData.returnValue; } } // throw 'Unknown command name "' + commandName + '"'; return false; }, /** * Gets one of the registered commands. Note that, after registering a * command definition with addCommand, it is transformed internally * into an instance of {@link CKEDITOR.command}, which will be then * returned by this function. * @param {String} commandName The name of the command to be returned. * This is the same used to register the command with addCommand. * @returns {CKEDITOR.command} The command object identified by the * provided name. */ getCommand : function( commandName ) { return this._.commands[ commandName ]; }, /** * Gets the editor data. The data will be in raw format. It is the same * data that is posted by the editor. * @type String * @returns (String) The editor data. * @example * if ( CKEDITOR.instances.editor1.<b>getData()</b> == '' ) * alert( 'There is no data available' ); */ getData : function() { this.fire( 'beforeGetData' ); var eventData = this._.data; if ( typeof eventData != 'string' ) { var element = this.element; if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) eventData = element.is( 'textarea' ) ? element.getValue() : element.getHtml(); else eventData = ''; } eventData = { dataValue : eventData }; // Fire "getData" so data manipulation may happen. this.fire( 'getData', eventData ); return eventData.dataValue; }, /** * Gets the "raw data" currently available in the editor. This is a * fast method which return the data as is, without processing, so it's * not recommended to use it on resulting pages. It can be used instead * combined with the {@link #loadSnapshot} so one can automatic save * the editor data from time to time while the user is using the * editor, to avoid data loss, without risking performance issues. * @example * alert( editor.getSnapshot() ); */ getSnapshot : function() { var data = this.fire( 'getSnapshot' ); if ( typeof data != 'string' ) { var element = this.element; if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) data = element.is( 'textarea' ) ? element.getValue() : element.getHtml(); } return data; }, /** * Loads "raw data" in the editor. This data is loaded with processing * straight to the editing area. It should not be used as a way to load * any kind of data, but instead in combination with * {@link #getSnapshot} produced data. * @example * var data = editor.getSnapshot(); * editor.<b>loadSnapshot( data )</b>; */ loadSnapshot : function( snapshot ) { this.fire( 'loadSnapshot', snapshot ); }, /** * Sets the editor data. The data must be provided in raw format (HTML).<br /> * <br /> * Note that this menthod is asynchronous. The "callback" parameter must * be used if interaction with the editor is needed after setting the data. * @param {String} data HTML code to replace the curent content in the * editor. * @param {Function} callback Function to be called after the setData * is completed. * @example * CKEDITOR.instances.editor1.<b>setData</b>( '&lt;p&gt;This is the editor data.&lt;/p&gt;' ); * @example * CKEDITOR.instances.editor1.<b>setData</b>( '&lt;p&gt;Some other editor data.&lt;/p&gt;', function() * { * this.checkDirty(); // true * }); */ setData : function( data , callback ) { if( callback ) { this.on( 'dataReady', function( evt ) { evt.removeListener(); callback.call( evt.editor ); } ); } // Fire "setData" so data manipulation may happen. var eventData = { dataValue : data }; this.fire( 'setData', eventData ); this._.data = eventData.dataValue; this.fire( 'afterSetData', eventData ); }, /** * Inserts HTML into the currently selected position in the editor. * @param {String} data HTML code to be inserted into the editor. * @example * CKEDITOR.instances.editor1.<b>insertHtml( '&lt;p&gt;This is a new paragraph.&lt;/p&gt;' )</b>; */ insertHtml : function( data ) { this.fire( 'insertHtml', data ); }, /** * Insert text content into the currently selected position in the * editor, in WYSIWYG mode, styles of the selected element will be applied to the inserted text, * spaces around the text will be leaving untouched. * <strong>Note:</strong> two subsequent line-breaks will introduce one paragraph, which element depends on {@link CKEDITOR.config.enterMode}; * A single line-break will be instead translated into one &lt;br /&gt;. * @since 3.5 * @param {String} text Text to be inserted into the editor. * @example * CKEDITOR.instances.editor1.<b>insertText( ' line1 \n\n line2' )</b>; */ insertText : function( text ) { this.fire( 'insertText', text ); }, /** * Inserts an element into the currently selected position in the * editor. * @param {CKEDITOR.dom.element} element The element to be inserted * into the editor. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;img src="hello.png" border="0" title="Hello" /&gt;' ); * CKEDITOR.instances.editor1.<b>insertElement( element )</b>; */ insertElement : function( element ) { this.fire( 'insertElement', element ); }, /** * Checks whether the current editor contents present changes when * compared to the contents loaded into the editor at startup, or to * the contents available in the editor when {@link #resetDirty} has * been called. * @returns {Boolean} "true" is the contents present changes. * @example * function beforeUnload( e ) * { * if ( CKEDITOR.instances.editor1.<b>checkDirty()</b> ) * return e.returnValue = "You'll loose the changes made in the editor."; * } * * if ( window.addEventListener ) * window.addEventListener( 'beforeunload', beforeUnload, false ); * else * window.attachEvent( 'onbeforeunload', beforeUnload ); */ checkDirty : function() { return ( this.mayBeDirty && this._.previousValue !== this.getSnapshot() ); }, /** * Resets the "dirty state" of the editor so subsequent calls to * {@link #checkDirty} will return "false" if the user will not make * further changes to the contents. * @example * alert( editor.checkDirty() ); // "true" (e.g.) * editor.<b>resetDirty()</b>; * alert( editor.checkDirty() ); // "false" */ resetDirty : function() { if ( this.mayBeDirty ) this._.previousValue = this.getSnapshot(); }, /** * Updates the &lt;textarea&gt; element that has been replaced by the editor with * the current data available in the editor. * @example * CKEDITOR.instances.editor1.updateElement(); * alert( document.getElementById( 'editor1' ).value ); // The current editor data. */ updateElement : function() { var element = this.element; if ( element && this.elementMode == CKEDITOR.ELEMENT_MODE_REPLACE ) { var data = this.getData(); if ( this.config.htmlEncodeOutput ) data = CKEDITOR.tools.htmlEncode( data ); if ( element.is( 'textarea' ) ) element.setValue( data ); else element.setHtml( data ); } } }); CKEDITOR.on( 'loaded', function() { // Run the full initialization for pending editors. var pending = CKEDITOR.editor._pending; if ( pending ) { delete CKEDITOR.editor._pending; for ( var i = 0 ; i < pending.length ; i++ ) pending[ i ]._init(); } }); /** * Whether escape HTML when editor update original input element. * @name CKEDITOR.config.htmlEncodeOutput * @since 3.1 * @type Boolean * @default false * @example * config.htmlEncodeOutput = true; */ /** * Fired when a CKEDITOR instance is created, but still before initializing it. * To interact with a fully initialized instance, use the * {@link CKEDITOR#instanceReady} event instead. * @name CKEDITOR#instanceCreated * @event * @param {CKEDITOR.editor} editor The editor instance that has been created. */ /** * Fired when a CKEDITOR instance is destroyed. * @name CKEDITOR#instanceDestroyed * @event * @param {CKEDITOR.editor} editor The editor instance that has been destroyed. */ /** * Fired when all plugins are loaded and initialized into the editor instance. * @name CKEDITOR#pluginsLoaded * @event * @param {CKEDITOR.editor} editor The editor instance that has been destroyed. */ /** * Fired before the command execution when {@link #execCommand} is called. * @name CKEDITOR.editor#beforeCommandExec * @event * @param {CKEDITOR.editor} editor This editor instance. * @param {String} data.name The command name. * @param {Object} data.commandData The data to be sent to the command. This * can be manipulated by the event listener. * @param {CKEDITOR.command} data.command The command itself. */ /** * Fired after the command execution when {@link #execCommand} is called. * @name CKEDITOR.editor#afterCommandExec * @event * @param {CKEDITOR.editor} editor This editor instance. * @param {String} data.name The command name. * @param {Object} data.commandData The data sent to the command. * @param {CKEDITOR.command} data.command The command itself. * @param {Object} data.returnValue The value returned by the command execution. */ /** * Fired every custom configuration file is loaded, before the final * configurations initialization.<br /> * <br /> * Custom configuration files can be loaded thorugh the * {@link CKEDITOR.config.customConfig} setting. Several files can be loading * by chaning this setting. * @name CKEDITOR.editor#customConfigLoaded * @event * @param {CKEDITOR.editor} editor This editor instance. * @example */ /** * Fired once the editor configuration is ready (loaded and processed). * @name CKEDITOR.editor#configLoaded * @event * @param {CKEDITOR.editor} editor This editor instance. * @example * if( editor.config.fullPage ) * alert( 'This is a full page editor' ); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the "virtual" {@link CKEDITOR.commandDefinition} class, * which contains the defintion of a command. This file is for * documentation purposes only. */ /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. * @name CKEDITOR.commandDefinition * @class Virtual class that illustrates the features of command objects to be * passed to the {@link CKEDITOR.editor.prototype.addCommand} function. * @example */ /** * The function to be fired when the commend is executed. * @name CKEDITOR.commandDefinition.prototype.exec * @function * @param {CKEDITOR.editor} editor The editor within which run the command. * @param {Object} [data] Additional data to be used to execute the command. * @returns {Boolean} Whether the command has been successfully executed. * Defaults to "true", if nothing is returned. * @example * editorInstance.addCommand( 'sample', * { * exec : function( editor ) * { * alert( 'Executing a command for the editor name "' + editor.name + '"!' ); * } * }); */ /** * Whether the command need to be hooked into the redo/undo system. * @name CKEDITOR.commandDefinition.prototype.canUndo * @type {Boolean} * @default true * @field * @example * editorInstance.addCommand( 'alertName', * { * exec : function( editor ) * { * alert( editor.name ); * }, * canUndo : false // No support for undo/redo * }); */ /** * Whether the command is asynchronous, which means that the * {@link CKEDITOR.editor#event:afterCommandExec} event will be fired by the * command itself manually, and that the return value of this command is not to * be returned by the {@link CKEDITOR.command#exec} function. * @name CKEDITOR.commandDefinition.prototype.async * @default false * @type {Boolean} * @example * editorInstance.addCommand( 'loadOptions', * { * exec : function( editor ) * { * // Asynchronous operation below. * CKEDITOR.ajax.loadXml( 'data.xml', function() * { * editor.fire( 'afterCommandExec' ); * )); * }, * async : true // The command need some time to complete after exec function returns. * }); */ /** * Whether the command should give focus to the editor before execution. * @name CKEDITOR.commandDefinition.prototype.editorFocus * @type {Boolean} * @default true * @see CKEDITOR.command#editorFocus * @example * editorInstance.addCommand( 'maximize', * { * exec : function( editor ) * { * // ... * }, * editorFocus : false // The command doesn't require focusing the editing document. * }); */ /** * Whether the command state should be set to {@link CKEDITOR.TRISTATE_DISABLED} on startup. * @name CKEDITOR.commandDefinition.prototype.startDisabled * @type {Boolean} * @default false * @example * editorInstance.addCommand( 'unlink', * { * exec : function( editor ) * { * // ... * }, * startDisabled : true // Command is unavailable until selection is inside a link. * }); */ /** * The editor modes within which the command can be executed. The execution * will have no action if the current mode is not listed in this property. * @name CKEDITOR.commandDefinition.prototype.modes * @type Object * @default { wysiwyg : 1 } * @see CKEDITOR.command#modes * @example * editorInstance.addCommand( 'link', * { * exec : function( editor ) * { * // ... * }, * modes : { wysiwyg : 1 } // Command is available in wysiwyg mode only. * }); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { /** * Represents a list os CKEDITOR.dom.range objects, which can be easily * iterated sequentially. * @constructor * @param {CKEDITOR.dom.range|Array} [ranges] The ranges contained on this list. * Note that, if an array of ranges is specified, the range sequence * should match its DOM order. This class will not help to sort them. */ CKEDITOR.dom.rangeList = function( ranges ) { if ( ranges instanceof CKEDITOR.dom.rangeList ) return ranges; if ( !ranges ) ranges = []; else if ( ranges instanceof CKEDITOR.dom.range ) ranges = [ ranges ]; return CKEDITOR.tools.extend( ranges, mixins ); }; var mixins = /** @lends CKEDITOR.dom.rangeList.prototype */ { /** * Creates an instance of the rangeList iterator, it should be used * only when the ranges processing could be DOM intrusive, which * means it may pollute and break other ranges in this list. * Otherwise, it's enough to just iterate over this array in a for loop. * @returns {CKEDITOR.dom.rangeListIterator} */ createIterator : function() { var rangeList = this, bookmark = CKEDITOR.dom.walker.bookmark(), guard = function( node ) { return ! ( node.is && node.is( 'tr' ) ); }, bookmarks = [], current; /** * @lends CKEDITOR.dom.rangeListIterator.prototype */ return { /** * Retrieves the next range in the list. * @param {Boolean} mergeConsequent Whether join two adjacent ranges into single, e.g. consequent table cells. */ getNextRange : function( mergeConsequent ) { current = current == undefined ? 0 : current + 1; var range = rangeList[ current ]; // Multiple ranges might be mangled by each other. if ( range && rangeList.length > 1 ) { // Bookmarking all other ranges on the first iteration, // the range correctness after it doesn't matter since we'll // restore them before the next iteration. if ( !current ) { // Make sure bookmark correctness by reverse processing. for ( var i = rangeList.length - 1; i >= 0; i-- ) bookmarks.unshift( rangeList[ i ].createBookmark( true ) ); } if ( mergeConsequent ) { // Figure out how many ranges should be merged. var mergeCount = 0; while ( rangeList[ current + mergeCount + 1 ] ) { var doc = range.document, found = 0, left = doc.getById( bookmarks[ mergeCount ].endNode ), right = doc.getById( bookmarks[ mergeCount + 1 ].startNode ), next; // Check subsequent range. while ( 1 ) { next = left.getNextSourceNode( false ); if ( !right.equals( next ) ) { // This could be yet another bookmark or // walking across block boundaries. if ( bookmark( next ) || ( next.type == CKEDITOR.NODE_ELEMENT && next.isBlockBoundary() ) ) { left = next; continue; } } else found = 1; break; } if ( !found ) break; mergeCount++; } } range.moveToBookmark( bookmarks.shift() ); // Merge ranges finally after moving to bookmarks. while( mergeCount-- ) { next = rangeList[ ++current ]; next.moveToBookmark( bookmarks.shift() ); range.setEnd( next.endContainer, next.endOffset ); } } return range; } }; }, createBookmarks : function( serializable ) { var retval = [], bookmark; for ( var i = 0; i < this.length ; i++ ) { retval.push( bookmark = this[ i ].createBookmark( serializable, true) ); // Updating the container & offset values for ranges // that have been touched. for ( var j = i + 1; j < this.length; j++ ) { this[ j ] = updateDirtyRange( bookmark, this[ j ] ); this[ j ] = updateDirtyRange( bookmark, this[ j ], true ); } } return retval; }, createBookmarks2 : function( normalized ) { var bookmarks = []; for ( var i = 0 ; i < this.length ; i++ ) bookmarks.push( this[ i ].createBookmark2( normalized ) ); return bookmarks; }, /** * Move each range in the list to the position specified by a list of bookmarks. * @param {Array} bookmarks The list of bookmarks, each one matching a range in the list. */ moveToBookmarks : function( bookmarks ) { for ( var i = 0 ; i < this.length ; i++ ) this[ i ].moveToBookmark( bookmarks[ i ] ); } }; // Update the specified range which has been mangled by previous insertion of // range bookmark nodes.(#3256) function updateDirtyRange( bookmark, dirtyRange, checkEnd ) { var serializable = bookmark.serializable, container = dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ], offset = checkEnd ? 'endOffset' : 'startOffset'; var bookmarkStart = serializable ? dirtyRange.document.getById( bookmark.startNode ) : bookmark.startNode; var bookmarkEnd = serializable ? dirtyRange.document.getById( bookmark.endNode ) : bookmark.endNode; if ( container.equals( bookmarkStart.getPrevious() ) ) { dirtyRange.startOffset = dirtyRange.startOffset - container.getLength() - bookmarkEnd.getPrevious().getLength(); container = bookmarkEnd.getNext(); } else if ( container.equals( bookmarkEnd.getPrevious() ) ) { dirtyRange.startOffset = dirtyRange.startOffset - container.getLength(); container = bookmarkEnd.getNext(); } container.equals( bookmarkStart.getParent() ) && dirtyRange[ offset ]++; container.equals( bookmarkEnd.getParent() ) && dirtyRange[ offset ]++; // Update and return this range. dirtyRange[ checkEnd ? 'endContainer' : 'startContainer' ] = container; return dirtyRange; } })(); /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. It just describes the return type of {@link CKEDITOR.dom.rangeList#createIterator}. * @name CKEDITOR.dom.rangeListIterator * @constructor * @example */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { // This function is to be called under a "walker" instance scope. function iterate( rtl, breakOnFalse ) { // Return null if we have reached the end. if ( this._.end ) return null; var node, range = this.range, guard, userGuard = this.guard, type = this.type, getSourceNodeFn = ( rtl ? 'getPreviousSourceNode' : 'getNextSourceNode' ); // This is the first call. Initialize it. if ( !this._.start ) { this._.start = 1; // Trim text nodes and optmize the range boundaries. DOM changes // may happen at this point. range.trim(); // A collapsed range must return null at first call. if ( range.collapsed ) { this.end(); return null; } } // Create the LTR guard function, if necessary. if ( !rtl && !this._.guardLTR ) { // Gets the node that stops the walker when going LTR. var limitLTR = range.endContainer, blockerLTR = limitLTR.getChild( range.endOffset ); this._.guardLTR = function( node, movingOut ) { return ( ( !movingOut || !limitLTR.equals( node ) ) && ( !blockerLTR || !node.equals( blockerLTR ) ) && ( node.type != CKEDITOR.NODE_ELEMENT || !movingOut || node.getName() != 'body' ) ); }; } // Create the RTL guard function, if necessary. if ( rtl && !this._.guardRTL ) { // Gets the node that stops the walker when going LTR. var limitRTL = range.startContainer, blockerRTL = ( range.startOffset > 0 ) && limitRTL.getChild( range.startOffset - 1 ); this._.guardRTL = function( node, movingOut ) { return ( ( !movingOut || !limitRTL.equals( node ) ) && ( !blockerRTL || !node.equals( blockerRTL ) ) && ( node.type != CKEDITOR.NODE_ELEMENT || !movingOut || node.getName() != 'body' ) ); }; } // Define which guard function to use. var stopGuard = rtl ? this._.guardRTL : this._.guardLTR; // Make the user defined guard function participate in the process, // otherwise simply use the boundary guard. if ( userGuard ) { guard = function( node, movingOut ) { if ( stopGuard( node, movingOut ) === false ) return false; return userGuard( node, movingOut ); }; } else guard = stopGuard; if ( this.current ) node = this.current[ getSourceNodeFn ]( false, type, guard ); else { // Get the first node to be returned. if ( rtl ) { node = range.endContainer; if ( range.endOffset > 0 ) { node = node.getChild( range.endOffset - 1 ); if ( guard( node ) === false ) node = null; } else node = ( guard ( node, true ) === false ) ? null : node.getPreviousSourceNode( true, type, guard ); } else { node = range.startContainer; node = node.getChild( range.startOffset ); if ( node ) { if ( guard( node ) === false ) node = null; } else node = ( guard ( range.startContainer, true ) === false ) ? null : range.startContainer.getNextSourceNode( true, type, guard ) ; } } while ( node && !this._.end ) { this.current = node; if ( !this.evaluator || this.evaluator( node ) !== false ) { if ( !breakOnFalse ) return node; } else if ( breakOnFalse && this.evaluator ) return false; node = node[ getSourceNodeFn ]( false, type, guard ); } this.end(); return this.current = null; } function iterateToLast( rtl ) { var node, last = null; while ( ( node = iterate.call( this, rtl ) ) ) last = node; return last; } CKEDITOR.dom.walker = CKEDITOR.tools.createClass( { /** * Utility class to "walk" the DOM inside a range boundaries. If * necessary, partially included nodes (text nodes) are broken to * reflect the boundaries limits, so DOM and range changes may happen. * Outside changes to the range may break the walker. * * The walker may return nodes that are not totaly included into the * range boundaires. Let's take the following range representation, * where the square brackets indicate the boundaries: * * [&lt;p&gt;Some &lt;b&gt;sample] text&lt;/b&gt; * * While walking forward into the above range, the following nodes are * returned: &lt;p&gt;, "Some ", &lt;b&gt; and "sample". Going * backwards instead we have: "sample" and "Some ". So note that the * walker always returns nodes when "entering" them, but not when * "leaving" them. The guard function is instead called both when * entering and leaving nodes. * * @constructor * @param {CKEDITOR.dom.range} range The range within which walk. */ $ : function( range ) { this.range = range; /** * A function executed for every matched node, to check whether * it's to be considered into the walk or not. If not provided, all * matched nodes are considered good. * If the function returns "false" the node is ignored. * @name CKEDITOR.dom.walker.prototype.evaluator * @property * @type Function */ // this.evaluator = null; /** * A function executed for every node the walk pass by to check * whether the walk is to be finished. It's called when both * entering and exiting nodes, as well as for the matched nodes. * If this function returns "false", the walking ends and no more * nodes are evaluated. * @name CKEDITOR.dom.walker.prototype.guard * @property * @type Function */ // this.guard = null; /** @private */ this._ = {}; }, // statics : // { // /* Creates a CKEDITOR.dom.walker instance to walk inside DOM boundaries set by nodes. // * @param {CKEDITOR.dom.node} startNode The node from wich the walk // * will start. // * @param {CKEDITOR.dom.node} [endNode] The last node to be considered // * in the walk. No more nodes are retrieved after touching or // * passing it. If not provided, the walker stops at the // * &lt;body&gt; closing boundary. // * @returns {CKEDITOR.dom.walker} A DOM walker for the nodes between the // * provided nodes. // */ // createOnNodes : function( startNode, endNode, startInclusive, endInclusive ) // { // var range = new CKEDITOR.dom.range(); // if ( startNode ) // range.setStartAt( startNode, startInclusive ? CKEDITOR.POSITION_BEFORE_START : CKEDITOR.POSITION_AFTER_END ) ; // else // range.setStartAt( startNode.getDocument().getBody(), CKEDITOR.POSITION_AFTER_START ) ; // // if ( endNode ) // range.setEndAt( endNode, endInclusive ? CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START ) ; // else // range.setEndAt( startNode.getDocument().getBody(), CKEDITOR.POSITION_BEFORE_END ) ; // // return new CKEDITOR.dom.walker( range ); // } // }, // proto : { /** * Stop walking. No more nodes are retrieved if this function gets * called. */ end : function() { this._.end = 1; }, /** * Retrieves the next node (at right). * @returns {CKEDITOR.dom.node} The next node or null if no more * nodes are available. */ next : function() { return iterate.call( this ); }, /** * Retrieves the previous node (at left). * @returns {CKEDITOR.dom.node} The previous node or null if no more * nodes are available. */ previous : function() { return iterate.call( this, 1 ); }, /** * Check all nodes at right, executing the evaluation fuction. * @returns {Boolean} "false" if the evaluator function returned * "false" for any of the matched nodes. Otherwise "true". */ checkForward : function() { return iterate.call( this, 0, 1 ) !== false; }, /** * Check all nodes at left, executing the evaluation fuction. * @returns {Boolean} "false" if the evaluator function returned * "false" for any of the matched nodes. Otherwise "true". */ checkBackward : function() { return iterate.call( this, 1, 1 ) !== false; }, /** * Executes a full walk forward (to the right), until no more nodes * are available, returning the last valid node. * @returns {CKEDITOR.dom.node} The last node at the right or null * if no valid nodes are available. */ lastForward : function() { return iterateToLast.call( this ); }, /** * Executes a full walk backwards (to the left), until no more nodes * are available, returning the last valid node. * @returns {CKEDITOR.dom.node} The last node at the left or null * if no valid nodes are available. */ lastBackward : function() { return iterateToLast.call( this, 1 ); }, reset : function() { delete this.current; this._ = {}; } } }); /* * Anything whose display computed style is block, list-item, table, * table-row-group, table-header-group, table-footer-group, table-row, * table-column-group, table-column, table-cell, table-caption, or whose node * name is hr, br (when enterMode is br only) is a block boundary. */ var blockBoundaryDisplayMatch = { block : 1, 'list-item' : 1, table : 1, 'table-row-group' : 1, 'table-header-group' : 1, 'table-footer-group' : 1, 'table-row' : 1, 'table-column-group' : 1, 'table-column' : 1, 'table-cell' : 1, 'table-caption' : 1 }; CKEDITOR.dom.element.prototype.isBlockBoundary = function( customNodeNames ) { var nodeNameMatches = CKEDITOR.tools.extend( {}, CKEDITOR.dtd.$block, customNodeNames || {} ); // Don't consider floated formatting as block boundary, fall back to dtd check in that case. (#6297) return this.getComputedStyle( 'float' ) == 'none' && blockBoundaryDisplayMatch[ this.getComputedStyle( 'display' ) ] || nodeNameMatches[ this.getName() ]; }; CKEDITOR.dom.walker.blockBoundary = function( customNodeNames ) { return function( node , type ) { return ! ( node.type == CKEDITOR.NODE_ELEMENT && node.isBlockBoundary( customNodeNames ) ); }; }; CKEDITOR.dom.walker.listItemBoundary = function() { return this.blockBoundary( { br : 1 } ); }; /** * Whether the to-be-evaluated node is a bookmark node OR bookmark node * inner contents. * @param {Boolean} contentOnly Whether only test againt the text content of * bookmark node instead of the element itself(default). * @param {Boolean} isReject Whether should return 'false' for the bookmark * node instead of 'true'(default). */ CKEDITOR.dom.walker.bookmark = function( contentOnly, isReject ) { function isBookmarkNode( node ) { return ( node && node.getName && node.getName() == 'span' && node.data( 'cke-bookmark' ) ); } return function( node ) { var isBookmark, parent; // Is bookmark inner text node? isBookmark = ( node && !node.getName && ( parent = node.getParent() ) && isBookmarkNode( parent ) ); // Is bookmark node? isBookmark = contentOnly ? isBookmark : isBookmark || isBookmarkNode( node ); return !! ( isReject ^ isBookmark ); }; }; /** * Whether the node is a text node containing only whitespaces characters. * @param isReject */ CKEDITOR.dom.walker.whitespaces = function( isReject ) { return function( node ) { var isWhitespace = node && ( node.type == CKEDITOR.NODE_TEXT ) && !CKEDITOR.tools.trim( node.getText() ); return !! ( isReject ^ isWhitespace ); }; }; /** * Whether the node is invisible in wysiwyg mode. * @param isReject */ CKEDITOR.dom.walker.invisible = function( isReject ) { var whitespace = CKEDITOR.dom.walker.whitespaces(); return function( node ) { // Nodes that take no spaces in wysiwyg: // 1. White-spaces but not including NBSP; // 2. Empty inline elements, e.g. <b></b> we're checking here // 'offsetHeight' instead of 'offsetWidth' for properly excluding // all sorts of empty paragraph, e.g. <br />. var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight; return !! ( isReject ^ isInvisible ); }; }; var tailNbspRegex = /^[\t\r\n ]*(?:&nbsp;|\xa0)$/, isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( 1 ), isNotBookmark = CKEDITOR.dom.walker.bookmark( 0, 1 ), fillerEvaluator = function( element ) { return isNotBookmark( element ) && isNotWhitespaces( element ); }; // Check if there's a filler node at the end of an element, and return it. CKEDITOR.dom.element.prototype.getBogus = function() { var tail = this.getLast( fillerEvaluator ); if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' ) : tail.getText && tailNbspRegex.test( tail.getText() ) ) ) { return tail; } return false; }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.event} class, which * represents the a native DOM event object. */ /** * Represents a native DOM event object. * @constructor * @param {Object} domEvent A native DOM event object. * @example */ CKEDITOR.dom.event = function( domEvent ) { /** * The native DOM event object represented by this class instance. * @type Object * @example */ this.$ = domEvent; }; CKEDITOR.dom.event.prototype = { /** * Gets the key code associated to the event. * @returns {Number} The key code. * @example * alert( event.getKey() ); "65" is "a" has been pressed */ getKey : function() { return this.$.keyCode || this.$.which; }, /** * Gets a number represeting the combination of the keys pressed during the * event. It is the sum with the current key code and the {@link CKEDITOR.CTRL}, * {@link CKEDITOR.SHIFT} and {@link CKEDITOR.ALT} constants. * @returns {Number} The number representing the keys combination. * @example * alert( event.getKeystroke() == 65 ); // "a" key * alert( event.getKeystroke() == CKEDITOR.CTRL + 65 ); // CTRL + "a" key * alert( event.getKeystroke() == CKEDITOR.CTRL + CKEDITOR.SHIFT + 65 ); // CTRL + SHIFT + "a" key */ getKeystroke : function() { var keystroke = this.getKey(); if ( this.$.ctrlKey || this.$.metaKey ) keystroke += CKEDITOR.CTRL; if ( this.$.shiftKey ) keystroke += CKEDITOR.SHIFT; if ( this.$.altKey ) keystroke += CKEDITOR.ALT; return keystroke; }, /** * Prevents the original behavior of the event to happen. It can optionally * stop propagating the event in the event chain. * @param {Boolean} [stopPropagation] Stop propagating this event in the * event chain. * @example * var element = CKEDITOR.document.getById( 'myElement' ); * element.on( 'click', function( ev ) * { * // The DOM event object is passed by the "data" property. * var domEvent = ev.data; * // Prevent the click to chave any effect in the element. * domEvent.preventDefault(); * }); */ preventDefault : function( stopPropagation ) { var $ = this.$; if ( $.preventDefault ) $.preventDefault(); else $.returnValue = false; if ( stopPropagation ) this.stopPropagation(); }, stopPropagation : function() { var $ = this.$; if ( $.stopPropagation ) $.stopPropagation(); else $.cancelBubble = true; }, /** * Returns the DOM node where the event was targeted to. * @returns {CKEDITOR.dom.node} The target DOM node. * @example * var element = CKEDITOR.document.getById( 'myElement' ); * element.on( 'click', function( ev ) * { * // The DOM event object is passed by the "data" property. * var domEvent = ev.data; * // Add a CSS class to the event target. * domEvent.getTarget().addClass( 'clicked' ); * }); */ getTarget : function() { var rawNode = this.$.target || this.$.srcElement; return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; } }; /** * CTRL key (1000). * @constant * @example */ CKEDITOR.CTRL = 1000; /** * SHIFT key (2000). * @constant * @example */ CKEDITOR.SHIFT = 2000; /** * ALT key (4000). * @constant * @example */ CKEDITOR.ALT = 4000;
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which * represents a DOM document. */ /** * Represents a DOM window. * @constructor * @augments CKEDITOR.dom.domObject * @param {Object} domWindow A native DOM window. * @example * var document = new CKEDITOR.dom.window( window ); */ CKEDITOR.dom.window = function( domWindow ) { CKEDITOR.dom.domObject.call( this, domWindow ); }; CKEDITOR.dom.window.prototype = new CKEDITOR.dom.domObject(); CKEDITOR.tools.extend( CKEDITOR.dom.window.prototype, /** @lends CKEDITOR.dom.window.prototype */ { /** * Moves the selection focus to this window. * @function * @example * var win = new CKEDITOR.dom.window( window ); * <b>win.focus()</b>; */ focus : function() { // Webkit is sometimes failed to focus iframe, blur it first(#3835). if ( CKEDITOR.env.webkit && this.$.parent ) this.$.parent.focus(); this.$.focus(); }, /** * Gets the width and height of this window's viewable area. * @function * @returns {Object} An object with the "width" and "height" * properties containing the size. * @example * var win = new CKEDITOR.dom.window( window ); * var size = <b>win.getViewPaneSize()</b>; * alert( size.width ); * alert( size.height ); */ getViewPaneSize : function() { var doc = this.$.document, stdMode = doc.compatMode == 'CSS1Compat'; return { width : ( stdMode ? doc.documentElement.clientWidth : doc.body.clientWidth ) || 0, height : ( stdMode ? doc.documentElement.clientHeight : doc.body.clientHeight ) || 0 }; }, /** * Gets the current position of the window's scroll. * @function * @returns {Object} An object with the "x" and "y" properties * containing the scroll position. * @example * var win = new CKEDITOR.dom.window( window ); * var pos = <b>win.getScrollPosition()</b>; * alert( pos.x ); * alert( pos.y ); */ getScrollPosition : function() { var $ = this.$; if ( 'pageXOffset' in $ ) { return { x : $.pageXOffset || 0, y : $.pageYOffset || 0 }; } else { var doc = $.document; return { x : doc.documentElement.scrollLeft || doc.body.scrollLeft || 0, y : doc.documentElement.scrollTop || doc.body.scrollTop || 0 }; } } });
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.node} class, which is the base * class for classes that represent DOM nodes. */ /** * Base class for classes representing DOM nodes. This constructor may return * and instance of classes that inherits this class, like * {@link CKEDITOR.dom.element} or {@link CKEDITOR.dom.text}. * @augments CKEDITOR.dom.domObject * @param {Object} domNode A native DOM node. * @constructor * @see CKEDITOR.dom.element * @see CKEDITOR.dom.text * @example */ CKEDITOR.dom.node = function( domNode ) { if ( domNode ) { switch ( domNode.nodeType ) { // Safari don't consider document as element node type. (#3389) case CKEDITOR.NODE_DOCUMENT : return new CKEDITOR.dom.document( domNode ); case CKEDITOR.NODE_ELEMENT : return new CKEDITOR.dom.element( domNode ); case CKEDITOR.NODE_TEXT : return new CKEDITOR.dom.text( domNode ); } // Call the base constructor. CKEDITOR.dom.domObject.call( this, domNode ); } return this; }; CKEDITOR.dom.node.prototype = new CKEDITOR.dom.domObject(); /** * Element node type. * @constant * @example */ CKEDITOR.NODE_ELEMENT = 1; /** * Document node type. * @constant * @example */ CKEDITOR.NODE_DOCUMENT = 9; /** * Text node type. * @constant * @example */ CKEDITOR.NODE_TEXT = 3; /** * Comment node type. * @constant * @example */ CKEDITOR.NODE_COMMENT = 8; CKEDITOR.NODE_DOCUMENT_FRAGMENT = 11; CKEDITOR.POSITION_IDENTICAL = 0; CKEDITOR.POSITION_DISCONNECTED = 1; CKEDITOR.POSITION_FOLLOWING = 2; CKEDITOR.POSITION_PRECEDING = 4; CKEDITOR.POSITION_IS_CONTAINED = 8; CKEDITOR.POSITION_CONTAINS = 16; CKEDITOR.tools.extend( CKEDITOR.dom.node.prototype, /** @lends CKEDITOR.dom.node.prototype */ { /** * Makes this node child of another element. * @param {CKEDITOR.dom.element} element The target element to which append * this node. * @returns {CKEDITOR.dom.element} The target element. * @example * var p = new CKEDITOR.dom.element( 'p' ); * var strong = new CKEDITOR.dom.element( 'strong' ); * strong.appendTo( p ); * * // result: "&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;" */ appendTo : function( element, toStart ) { element.append( this, toStart ); return element; }, clone : function( includeChildren, cloneId ) { var $clone = this.$.cloneNode( includeChildren ); var removeIds = function( node ) { if ( node.nodeType != CKEDITOR.NODE_ELEMENT ) return; if ( !cloneId ) node.removeAttribute( 'id', false ); node.removeAttribute( 'data-cke-expando', false ); if ( includeChildren ) { var childs = node.childNodes; for ( var i=0; i < childs.length; i++ ) removeIds( childs[ i ] ); } }; // The "id" attribute should never be cloned to avoid duplication. removeIds( $clone ); return new CKEDITOR.dom.node( $clone ); }, hasPrevious : function() { return !!this.$.previousSibling; }, hasNext : function() { return !!this.$.nextSibling; }, /** * Inserts this element after a node. * @param {CKEDITOR.dom.node} node The that will preceed this element. * @returns {CKEDITOR.dom.node} The node preceeding this one after * insertion. * @example * var em = new CKEDITOR.dom.element( 'em' ); * var strong = new CKEDITOR.dom.element( 'strong' ); * strong.insertAfter( em ); * * // result: "&lt;em&gt;&lt;/em&gt;&lt;strong&gt;&lt;/strong&gt;" */ insertAfter : function( node ) { node.$.parentNode.insertBefore( this.$, node.$.nextSibling ); return node; }, /** * Inserts this element before a node. * @param {CKEDITOR.dom.node} node The that will be after this element. * @returns {CKEDITOR.dom.node} The node being inserted. * @example * var em = new CKEDITOR.dom.element( 'em' ); * var strong = new CKEDITOR.dom.element( 'strong' ); * strong.insertBefore( em ); * * // result: "&lt;strong&gt;&lt;/strong&gt;&lt;em&gt;&lt;/em&gt;" */ insertBefore : function( node ) { node.$.parentNode.insertBefore( this.$, node.$ ); return node; }, insertBeforeMe : function( node ) { this.$.parentNode.insertBefore( node.$, this.$ ); return node; }, /** * Retrieves a uniquely identifiable tree address for this node. * The tree address returns is an array of integers, with each integer * indicating a child index of a DOM node, starting from * document.documentElement. * * For example, assuming <body> is the second child from <html> (<head> * being the first), and we'd like to address the third child under the * fourth child of body, the tree address returned would be: * [1, 3, 2] * * The tree address cannot be used for finding back the DOM tree node once * the DOM tree structure has been modified. */ getAddress : function( normalized ) { var address = []; var $documentElement = this.getDocument().$.documentElement; var node = this.$; while ( node && node != $documentElement ) { var parentNode = node.parentNode; var currentIndex = -1; if ( parentNode ) { for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) { var candidate = parentNode.childNodes[i]; if ( normalized && candidate.nodeType == 3 && candidate.previousSibling && candidate.previousSibling.nodeType == 3 ) { continue; } currentIndex++; if ( candidate == node ) break; } address.unshift( currentIndex ); } node = parentNode; } return address; }, /** * Gets the document containing this element. * @returns {CKEDITOR.dom.document} The document. * @example * var element = CKEDITOR.document.getById( 'example' ); * alert( <b>element.getDocument().equals( CKEDITOR.document )</b> ); // "true" */ getDocument : function() { return new CKEDITOR.dom.document( this.$.ownerDocument || this.$.parentNode.ownerDocument ); }, getIndex : function() { var $ = this.$; var currentNode = $.parentNode && $.parentNode.firstChild; var currentIndex = -1; while ( currentNode ) { currentIndex++; if ( currentNode == $ ) return currentIndex; currentNode = currentNode.nextSibling; } return -1; }, getNextSourceNode : function( startFromSibling, nodeType, guard ) { // If "guard" is a node, transform it in a function. if ( guard && !guard.call ) { var guardNode = guard; guard = function( node ) { return !node.equals( guardNode ); }; } var node = ( !startFromSibling && this.getFirst && this.getFirst() ), parent; // Guarding when we're skipping the current element( no children or 'startFromSibling' ). // send the 'moving out' signal even we don't actually dive into. if ( !node ) { if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false ) return null; node = this.getNext(); } while ( !node && ( parent = ( parent || this ).getParent() ) ) { // The guard check sends the "true" paramenter to indicate that // we are moving "out" of the element. if ( guard && guard( parent, true ) === false ) return null; node = parent.getNext(); } if ( !node ) return null; if ( guard && guard( node ) === false ) return null; if ( nodeType && nodeType != node.type ) return node.getNextSourceNode( false, nodeType, guard ); return node; }, getPreviousSourceNode : function( startFromSibling, nodeType, guard ) { if ( guard && !guard.call ) { var guardNode = guard; guard = function( node ) { return !node.equals( guardNode ); }; } var node = ( !startFromSibling && this.getLast && this.getLast() ), parent; // Guarding when we're skipping the current element( no children or 'startFromSibling' ). // send the 'moving out' signal even we don't actually dive into. if ( !node ) { if ( this.type == CKEDITOR.NODE_ELEMENT && guard && guard( this, true ) === false ) return null; node = this.getPrevious(); } while ( !node && ( parent = ( parent || this ).getParent() ) ) { // The guard check sends the "true" paramenter to indicate that // we are moving "out" of the element. if ( guard && guard( parent, true ) === false ) return null; node = parent.getPrevious(); } if ( !node ) return null; if ( guard && guard( node ) === false ) return null; if ( nodeType && node.type != nodeType ) return node.getPreviousSourceNode( false, nodeType, guard ); return node; }, getPrevious : function( evaluator ) { var previous = this.$, retval; do { previous = previous.previousSibling; retval = previous && new CKEDITOR.dom.node( previous ); } while ( retval && evaluator && !evaluator( retval ) ) return retval; }, /** * Gets the node that follows this element in its parent's child list. * @param {Function} evaluator Filtering the result node. * @returns {CKEDITOR.dom.node} The next node or null if not available. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;div&gt;&lt;b&gt;Example&lt;/b&gt; &lt;i&gt;next&lt;/i&gt;&lt;/div&gt;' ); * var first = <b>element.getFirst().getNext()</b>; * alert( first.getName() ); // "i" */ getNext : function( evaluator ) { var next = this.$, retval; do { next = next.nextSibling; retval = next && new CKEDITOR.dom.node( next ); } while ( retval && evaluator && !evaluator( retval ) ) return retval; }, /** * Gets the parent element for this node. * @returns {CKEDITOR.dom.element} The parent element. * @example * var node = editor.document.getBody().getFirst(); * var parent = node.<b>getParent()</b>; * alert( node.getName() ); // "body" */ getParent : function() { var parent = this.$.parentNode; return ( parent && parent.nodeType == 1 ) ? new CKEDITOR.dom.node( parent ) : null; }, getParents : function( closerFirst ) { var node = this; var parents = []; do { parents[ closerFirst ? 'push' : 'unshift' ]( node ); } while ( ( node = node.getParent() ) ) return parents; }, getCommonAncestor : function( node ) { if ( node.equals( this ) ) return this; if ( node.contains && node.contains( this ) ) return node; var start = this.contains ? this : this.getParent(); do { if ( start.contains( node ) ) return start; } while ( ( start = start.getParent() ) ); return null; }, getPosition : function( otherNode ) { var $ = this.$; var $other = otherNode.$; if ( $.compareDocumentPosition ) return $.compareDocumentPosition( $other ); // IE and Safari have no support for compareDocumentPosition. if ( $ == $other ) return CKEDITOR.POSITION_IDENTICAL; // Only element nodes support contains and sourceIndex. if ( this.type == CKEDITOR.NODE_ELEMENT && otherNode.type == CKEDITOR.NODE_ELEMENT ) { if ( $.contains ) { if ( $.contains( $other ) ) return CKEDITOR.POSITION_CONTAINS + CKEDITOR.POSITION_PRECEDING; if ( $other.contains( $ ) ) return CKEDITOR.POSITION_IS_CONTAINED + CKEDITOR.POSITION_FOLLOWING; } if ( 'sourceIndex' in $ ) { return ( $.sourceIndex < 0 || $other.sourceIndex < 0 ) ? CKEDITOR.POSITION_DISCONNECTED : ( $.sourceIndex < $other.sourceIndex ) ? CKEDITOR.POSITION_PRECEDING : CKEDITOR.POSITION_FOLLOWING; } } // For nodes that don't support compareDocumentPosition, contains // or sourceIndex, their "address" is compared. var addressOfThis = this.getAddress(), addressOfOther = otherNode.getAddress(), minLevel = Math.min( addressOfThis.length, addressOfOther.length ); // Determinate preceed/follow relationship. for ( var i = 0 ; i <= minLevel - 1 ; i++ ) { if ( addressOfThis[ i ] != addressOfOther[ i ] ) { if ( i < minLevel ) { return addressOfThis[ i ] < addressOfOther[ i ] ? CKEDITOR.POSITION_PRECEDING : CKEDITOR.POSITION_FOLLOWING; } break; } } // Determinate contains/contained relationship. return ( addressOfThis.length < addressOfOther.length ) ? CKEDITOR.POSITION_CONTAINS + CKEDITOR.POSITION_PRECEDING : CKEDITOR.POSITION_IS_CONTAINED + CKEDITOR.POSITION_FOLLOWING; }, /** * Gets the closes ancestor node of a specified node name. * @param {String} name Node name of ancestor node. * @param {Boolean} includeSelf (Optional) Whether to include the current * node in the calculation or not. * @returns {CKEDITOR.dom.node} Ancestor node. */ getAscendant : function( name, includeSelf ) { var $ = this.$; if ( !includeSelf ) $ = $.parentNode; while ( $ ) { if ( $.nodeName && $.nodeName.toLowerCase() == name ) return new CKEDITOR.dom.node( $ ); $ = $.parentNode; } return null; }, hasAscendant : function( name, includeSelf ) { var $ = this.$; if ( !includeSelf ) $ = $.parentNode; while ( $ ) { if ( $.nodeName && $.nodeName.toLowerCase() == name ) return true; $ = $.parentNode; } return false; }, move : function( target, toStart ) { target.append( this.remove(), toStart ); }, /** * Removes this node from the document DOM. * @param {Boolean} [preserveChildren] Indicates that the children * elements must remain in the document, removing only the outer * tags. * @example * var element = CKEDITOR.dom.element.getById( 'MyElement' ); * <b>element.remove()</b>; */ remove : function( preserveChildren ) { var $ = this.$; var parent = $.parentNode; if ( parent ) { if ( preserveChildren ) { // Move all children before the node. for ( var child ; ( child = $.firstChild ) ; ) { parent.insertBefore( $.removeChild( child ), $ ); } } parent.removeChild( $ ); } return this; }, replace : function( nodeToReplace ) { this.insertBefore( nodeToReplace ); nodeToReplace.remove(); }, trim : function() { this.ltrim(); this.rtrim(); }, ltrim : function() { var child; while ( this.getFirst && ( child = this.getFirst() ) ) { if ( child.type == CKEDITOR.NODE_TEXT ) { var trimmed = CKEDITOR.tools.ltrim( child.getText() ), originalLength = child.getLength(); if ( !trimmed ) { child.remove(); continue; } else if ( trimmed.length < originalLength ) { child.split( originalLength - trimmed.length ); // IE BUG: child.remove() may raise JavaScript errors here. (#81) this.$.removeChild( this.$.firstChild ); } } break; } }, rtrim : function() { var child; while ( this.getLast && ( child = this.getLast() ) ) { if ( child.type == CKEDITOR.NODE_TEXT ) { var trimmed = CKEDITOR.tools.rtrim( child.getText() ), originalLength = child.getLength(); if ( !trimmed ) { child.remove(); continue; } else if ( trimmed.length < originalLength ) { child.split( trimmed.length ); // IE BUG: child.getNext().remove() may raise JavaScript errors here. // (#81) this.$.lastChild.parentNode.removeChild( this.$.lastChild ); } } break; } if ( !CKEDITOR.env.ie && !CKEDITOR.env.opera ) { child = this.$.lastChild; if ( child && child.type == 1 && child.nodeName.toLowerCase() == 'br' ) { // Use "eChildNode.parentNode" instead of "node" to avoid IE bug (#324). child.parentNode.removeChild( child ) ; } } }, /** * Checks is this node is read-only (should not be changed). It * additionaly returns the element, if any, which defines the read-only * state of this node. It may be the node itself or any of its parent * nodes. * @returns {CKEDITOR.dom.element|Boolean} An element containing * read-only attributes or "false" if none is found. * @since 3.5 * @example * // For the following HTML: * // <div contenteditable="false">Some <b>text</b></div> * * // If "ele" is the above <div> * ele.getReadOnlyRoot(); // the <div> element * * // If "ele" is the above <b> * ele.getReadOnlyRoot(); // the <div> element */ isReadOnly : function() { var current = this; while( current ) { if ( current.type == CKEDITOR.NODE_ELEMENT ) { if ( current.is( 'body' ) || current.getCustomData( '_cke_notReadOnly' ) ) break; if ( current.getAttribute( 'contentEditable' ) == 'false' ) return current; else if ( current.getAttribute( 'contentEditable' ) == 'true' ) break; } current = current.getParent(); } return false; } } );
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.comment} class, which represents * a DOM comment node. */ CKEDITOR.dom.comment = CKEDITOR.tools.createClass( { base : CKEDITOR.dom.node, $ : function( text, ownerDocument ) { if ( typeof text == 'string' ) text = ( ownerDocument ? ownerDocument.$ : document ).createComment( text ); this.base( text ); }, proto : { type : CKEDITOR.NODE_COMMENT, getOuterHtml : function() { return '<!--' + this.$.nodeValue + '-->'; } } });
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.document} class, which * represents a DOM document. */ /** * Represents a DOM document. * @constructor * @augments CKEDITOR.dom.domObject * @param {Object} domDocument A native DOM document. * @example * var document = new CKEDITOR.dom.document( document ); */ CKEDITOR.dom.document = function( domDocument ) { CKEDITOR.dom.domObject.call( this, domDocument ); }; // PACKAGER_RENAME( CKEDITOR.dom.document ) CKEDITOR.dom.document.prototype = new CKEDITOR.dom.domObject(); CKEDITOR.tools.extend( CKEDITOR.dom.document.prototype, /** @lends CKEDITOR.dom.document.prototype */ { /** * Appends a CSS file to the document. * @param {String} cssFileUrl The CSS file URL. * @example * <b>CKEDITOR.document.appendStyleSheet( '/mystyles.css' )</b>; */ appendStyleSheet : function( cssFileUrl ) { if ( this.$.createStyleSheet ) this.$.createStyleSheet( cssFileUrl ); else { var link = new CKEDITOR.dom.element( 'link' ); link.setAttributes( { rel :'stylesheet', type : 'text/css', href : cssFileUrl }); this.getHead().append( link ); } }, appendStyleText : function( cssStyleText ) { if ( this.$.createStyleSheet ) { var styleSheet = this.$.createStyleSheet( "" ); styleSheet.cssText = cssStyleText ; } else { var style = new CKEDITOR.dom.element( 'style', this ); style.append( new CKEDITOR.dom.text( cssStyleText, this ) ); this.getHead().append( style ); } }, createElement : function( name, attribsAndStyles ) { var element = new CKEDITOR.dom.element( name, this ); if ( attribsAndStyles ) { if ( attribsAndStyles.attributes ) element.setAttributes( attribsAndStyles.attributes ); if ( attribsAndStyles.styles ) element.setStyles( attribsAndStyles.styles ); } return element; }, createText : function( text ) { return new CKEDITOR.dom.text( text, this ); }, focus : function() { this.getWindow().focus(); }, /** * Gets and element based on its id. * @param {String} elementId The element id. * @returns {CKEDITOR.dom.element} The element instance, or null if not found. * @example * var element = <b>CKEDITOR.document.getById( 'myElement' )</b>; * alert( element.getId() ); // "myElement" */ getById : function( elementId ) { var $ = this.$.getElementById( elementId ); return $ ? new CKEDITOR.dom.element( $ ) : null; }, getByAddress : function( address, normalized ) { var $ = this.$.documentElement; for ( var i = 0 ; $ && i < address.length ; i++ ) { var target = address[ i ]; if ( !normalized ) { $ = $.childNodes[ target ]; continue; } var currentIndex = -1; for (var j = 0 ; j < $.childNodes.length ; j++ ) { var candidate = $.childNodes[ j ]; if ( normalized === true && candidate.nodeType == 3 && candidate.previousSibling && candidate.previousSibling.nodeType == 3 ) { continue; } currentIndex++; if ( currentIndex == target ) { $ = candidate; break; } } } return $ ? new CKEDITOR.dom.node( $ ) : null; }, getElementsByTag : function( tagName, namespace ) { if ( !( CKEDITOR.env.ie && ! ( document.documentMode > 8 ) ) && namespace ) tagName = namespace + ':' + tagName; return new CKEDITOR.dom.nodeList( this.$.getElementsByTagName( tagName ) ); }, /** * Gets the &lt;head&gt; element for this document. * @returns {CKEDITOR.dom.element} The &lt;head&gt; element. * @example * var element = <b>CKEDITOR.document.getHead()</b>; * alert( element.getName() ); // "head" */ getHead : function() { var head = this.$.getElementsByTagName( 'head' )[0]; if ( !head ) head = this.getDocumentElement().append( new CKEDITOR.dom.element( 'head' ), true ); else head = new CKEDITOR.dom.element( head ); return ( this.getHead = function() { return head; })(); }, /** * Gets the &lt;body&gt; element for this document. * @returns {CKEDITOR.dom.element} The &lt;body&gt; element. * @example * var element = <b>CKEDITOR.document.getBody()</b>; * alert( element.getName() ); // "body" */ getBody : function() { var body = new CKEDITOR.dom.element( this.$.body ); return ( this.getBody = function() { return body; })(); }, /** * Gets the DOM document element for this document. * @returns {CKEDITOR.dom.element} The DOM document element. */ getDocumentElement : function() { var documentElement = new CKEDITOR.dom.element( this.$.documentElement ); return ( this.getDocumentElement = function() { return documentElement; })(); }, /** * Gets the window object that holds this document. * @returns {CKEDITOR.dom.window} The window object. */ getWindow : function() { var win = new CKEDITOR.dom.window( this.$.parentWindow || this.$.defaultView ); return ( this.getWindow = function() { return win; })(); }, /** * Defines the document contents through document.write. Note that the * previous document contents will be lost (cleaned). * @since 3.5 * @param {String} html The HTML defining the document contents. * @example * document.write( * '&lt;html&gt;' + * '&lt;head&gt;&lt;title&gt;Sample Doc&lt;/title&gt;&lt;/head&gt;' + * '&lt;body&gt;Document contents created by code&lt;/body&gt;' + * '&lt;/html&gt;' ); */ write : function( html ) { // Don't leave any history log in IE. (#5657) this.$.open( 'text/html', 'replace' ); // Support for custom document.domain in IE. CKEDITOR.env.isCustomDomain() && ( this.$.domain = document.domain ); this.$.write( html ); this.$.close(); } });
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { // Elements that may be considered the "Block boundary" in an element path. var pathBlockElements = { address:1,blockquote:1,dl:1,h1:1,h2:1,h3:1,h4:1,h5:1,h6:1,p:1,pre:1,li:1,dt:1,dd:1 }; // Elements that may be considered the "Block limit" in an element path. var pathBlockLimitElements = { body:1,div:1,table:1,tbody:1,tr:1,td:1,th:1,caption:1,form:1 }; // Check if an element contains any block element. var checkHasBlock = function( element ) { var childNodes = element.getChildren(); for ( var i = 0, count = childNodes.count() ; i < count ; i++ ) { var child = childNodes.getItem( i ); if ( child.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$block[ child.getName() ] ) return true; } return false; }; /** * @class */ CKEDITOR.dom.elementPath = function( lastNode ) { var block = null; var blockLimit = null; var elements = []; var e = lastNode; while ( e ) { if ( e.type == CKEDITOR.NODE_ELEMENT ) { if ( !this.lastElement ) this.lastElement = e; var elementName = e.getName(); if ( CKEDITOR.env.ie && e.$.scopeName != 'HTML' ) elementName = e.$.scopeName.toLowerCase() + ':' + elementName; if ( !blockLimit ) { if ( !block && pathBlockElements[ elementName ] ) block = e; if ( pathBlockLimitElements[ elementName ] ) { // DIV is considered the Block, if no block is available (#525) // and if it doesn't contain other blocks. if ( !block && elementName == 'div' && !checkHasBlock( e ) ) block = e; else blockLimit = e; } } elements.push( e ); if ( elementName == 'body' ) break; } e = e.getParent(); } this.block = block; this.blockLimit = blockLimit; this.elements = elements; }; })(); CKEDITOR.dom.elementPath.prototype = { /** * Compares this element path with another one. * @param {CKEDITOR.dom.elementPath} otherPath The elementPath object to be * compared with this one. * @returns {Boolean} "true" if the paths are equal, containing the same * number of elements and the same elements in the same order. */ compare : function( otherPath ) { var thisElements = this.elements; var otherElements = otherPath && otherPath.elements; if ( !otherElements || thisElements.length != otherElements.length ) return false; for ( var i = 0 ; i < thisElements.length ; i++ ) { if ( !thisElements[ i ].equals( otherElements[ i ] ) ) return false; } return true; }, contains : function( tagNames ) { var elements = this.elements; for ( var i = 0 ; i < elements.length ; i++ ) { if ( elements[ i ].getName() in tagNames ) return elements[ i ]; } return null; } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.text} class, which represents * a DOM text node. */ /** * Represents a DOM text node. * @constructor * @augments CKEDITOR.dom.node * @param {Object|String} text A native DOM text node or a string containing * the text to use to create a new text node. * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain * the node in case of new node creation. Defaults to the current document. * @example * var nativeNode = document.createTextNode( 'Example' ); * var text = CKEDITOR.dom.text( nativeNode ); * @example * var text = CKEDITOR.dom.text( 'Example' ); */ CKEDITOR.dom.text = function( text, ownerDocument ) { if ( typeof text == 'string' ) text = ( ownerDocument ? ownerDocument.$ : document ).createTextNode( text ); // Theoretically, we should call the base constructor here // (not CKEDITOR.dom.node though). But, IE doesn't support expando // properties on text node, so the features provided by domObject will not // work for text nodes (which is not a big issue for us). // // CKEDITOR.dom.domObject.call( this, element ); /** * The native DOM text node represented by this class instance. * @type Object * @example * var element = new CKEDITOR.dom.text( 'Example' ); * alert( element.$.nodeType ); // "3" */ this.$ = text; }; CKEDITOR.dom.text.prototype = new CKEDITOR.dom.node(); CKEDITOR.tools.extend( CKEDITOR.dom.text.prototype, /** @lends CKEDITOR.dom.text.prototype */ { /** * The node type. This is a constant value set to * {@link CKEDITOR.NODE_TEXT}. * @type Number * @example */ type : CKEDITOR.NODE_TEXT, getLength : function() { return this.$.nodeValue.length; }, getText : function() { return this.$.nodeValue; }, /** * Breaks this text node into two nodes at the specified offset, * keeping both in the tree as siblings. This node then only contains * all the content up to the offset point. A new text node, which is * inserted as the next sibling of this node, contains all the content * at and after the offset point. When the offset is equal to the * length of this node, the new node has no data. * @param {Number} The position at which to split, starting from zero. * @returns {CKEDITOR.dom.text} The new text node. */ split : function( offset ) { // If the offset is after the last char, IE creates the text node // on split, but don't include it into the DOM. So, we have to do // that manually here. if ( CKEDITOR.env.ie && offset == this.getLength() ) { var next = this.getDocument().createText( '' ); next.insertAfter( this ); return next; } var doc = this.getDocument(); var retval = new CKEDITOR.dom.text( this.$.splitText( offset ), doc ); // IE BUG: IE8 does not update the childNodes array in DOM after splitText(), // we need to make some DOM changes to make it update. (#3436) if ( CKEDITOR.env.ie8 ) { var workaround = new CKEDITOR.dom.text( '', doc ); workaround.insertAfter( retval ); workaround.remove(); } return retval; }, /** * Extracts characters from indexA up to but not including indexB. * @param {Number} indexA An integer between 0 and one less than the * length of the text. * @param {Number} [indexB] An integer between 0 and the length of the * string. If omitted, extracts characters to the end of the text. */ substring : function( indexA, indexB ) { // We need the following check due to a Firefox bug // https://bugzilla.mozilla.org/show_bug.cgi?id=458886 if ( typeof indexB != 'number' ) return this.$.nodeValue.substr( indexA ); else return this.$.nodeValue.substring( indexA, indexB ); } });
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.editor} class, which is the base * for other classes representing DOM objects. */ /** * Represents a DOM object. This class is not intended to be used directly. It * serves as the base class for other classes representing specific DOM * objects. * @constructor * @param {Object} nativeDomObject A native DOM object. * @augments CKEDITOR.event * @example */ CKEDITOR.dom.domObject = function( nativeDomObject ) { if ( nativeDomObject ) { /** * The native DOM object represented by this class instance. * @type Object * @example * var element = new CKEDITOR.dom.element( 'span' ); * alert( element.$.nodeType ); // "1" */ this.$ = nativeDomObject; } }; CKEDITOR.dom.domObject.prototype = (function() { // Do not define other local variables here. We want to keep the native // listener closures as clean as possible. var getNativeListener = function( domObject, eventName ) { return function( domEvent ) { // In FF, when reloading the page with the editor focused, it may // throw an error because the CKEDITOR global is not anymore // available. So, we check it here first. (#2923) if ( typeof CKEDITOR != 'undefined' ) domObject.fire( eventName, new CKEDITOR.dom.event( domEvent ) ); }; }; return /** @lends CKEDITOR.dom.domObject.prototype */ { getPrivate : function() { var priv; // Get the main private function from the custom data. Create it if not // defined. if ( !( priv = this.getCustomData( '_' ) ) ) this.setCustomData( '_', ( priv = {} ) ); return priv; }, /** @ignore */ on : function( eventName ) { // We customize the "on" function here. The basic idea is that we'll have // only one listener for a native event, which will then call all listeners // set to the event. // Get the listeners holder object. var nativeListeners = this.getCustomData( '_cke_nativeListeners' ); if ( !nativeListeners ) { nativeListeners = {}; this.setCustomData( '_cke_nativeListeners', nativeListeners ); } // Check if we have a listener for that event. if ( !nativeListeners[ eventName ] ) { var listener = nativeListeners[ eventName ] = getNativeListener( this, eventName ); if ( this.$.attachEvent ) this.$.attachEvent( 'on' + eventName, listener ); else if ( this.$.addEventListener ) this.$.addEventListener( eventName, listener, !!CKEDITOR.event.useCapture ); } // Call the original implementation. return CKEDITOR.event.prototype.on.apply( this, arguments ); }, /** @ignore */ removeListener : function( eventName ) { // Call the original implementation. CKEDITOR.event.prototype.removeListener.apply( this, arguments ); // If we don't have listeners for this event, clean the DOM up. if ( !this.hasListeners( eventName ) ) { var nativeListeners = this.getCustomData( '_cke_nativeListeners' ); var listener = nativeListeners && nativeListeners[ eventName ]; if ( listener ) { if ( this.$.detachEvent ) this.$.detachEvent( 'on' + eventName, listener ); else if ( this.$.removeEventListener ) this.$.removeEventListener( eventName, listener, false ); delete nativeListeners[ eventName ]; } } }, /** * Removes any listener set on this object. * To avoid memory leaks we must assure that there are no * references left after the object is no longer needed. */ removeAllListeners : function() { var nativeListeners = this.getCustomData( '_cke_nativeListeners' ); for ( var eventName in nativeListeners ) { var listener = nativeListeners[ eventName ]; if ( this.$.detachEvent ) this.$.detachEvent( 'on' + eventName, listener ); else if ( this.$.removeEventListener ) this.$.removeEventListener( eventName, listener, false ); delete nativeListeners[ eventName ]; } } }; })(); (function( domObjectProto ) { var customData = {}; CKEDITOR.on( 'reset', function() { customData = {}; }); /** * Determines whether the specified object is equal to the current object. * @name CKEDITOR.dom.domObject.prototype.equals * @function * @param {Object} object The object to compare with the current object. * @returns {Boolean} "true" if the object is equal. * @example * var doc = new CKEDITOR.dom.document( document ); * alert( doc.equals( CKEDITOR.document ) ); // "true" * alert( doc == CKEDITOR.document ); // "false" */ domObjectProto.equals = function( object ) { return ( object && object.$ === this.$ ); }; /** * Sets a data slot value for this object. These values are shared by all * instances pointing to that same DOM object. * <strong>Note:</strong> The created data slot is only guarantied to be available on this unique dom node, * thus any wish to continue access it from other element clones (either created by clone node or from innerHtml) * will fail, for such usage, please use {@link CKEDITOR.dom.element::setAttribute} instead. * @name CKEDITOR.dom.domObject.prototype.setCustomData * @function * @param {String} key A key used to identify the data slot. * @param {Object} value The value to set to the data slot. * @returns {CKEDITOR.dom.domObject} This DOM object instance. * @see CKEDITOR.dom.domObject.prototype.getCustomData * @example * var element = new CKEDITOR.dom.element( 'span' ); * element.setCustomData( 'hasCustomData', true ); */ domObjectProto.setCustomData = function( key, value ) { var expandoNumber = this.getUniqueId(), dataSlot = customData[ expandoNumber ] || ( customData[ expandoNumber ] = {} ); dataSlot[ key ] = value; return this; }; /** * Gets the value set to a data slot in this object. * @name CKEDITOR.dom.domObject.prototype.getCustomData * @function * @param {String} key The key used to identify the data slot. * @returns {Object} This value set to the data slot. * @see CKEDITOR.dom.domObject.prototype.setCustomData * @example * var element = new CKEDITOR.dom.element( 'span' ); * alert( element.getCustomData( 'hasCustomData' ) ); // e.g. 'true' */ domObjectProto.getCustomData = function( key ) { var expandoNumber = this.$[ 'data-cke-expando' ], dataSlot = expandoNumber && customData[ expandoNumber ]; return dataSlot && dataSlot[ key ]; }; /** * @name CKEDITOR.dom.domObject.prototype.removeCustomData */ domObjectProto.removeCustomData = function( key ) { var expandoNumber = this.$[ 'data-cke-expando' ], dataSlot = expandoNumber && customData[ expandoNumber ], retval = dataSlot && dataSlot[ key ]; if ( typeof retval != 'undefined' ) delete dataSlot[ key ]; return retval || null; }; /** * Removes any data stored on this object. * To avoid memory leaks we must assure that there are no * references left after the object is no longer needed. * @name CKEDITOR.dom.domObject.prototype.clearCustomData * @function */ domObjectProto.clearCustomData = function() { // Clear all event listeners this.removeAllListeners(); var expandoNumber = this.$[ 'data-cke-expando' ]; expandoNumber && delete customData[ expandoNumber ]; }; /** * Gets an ID that can be used to identiquely identify this DOM object in * the running session. * @name CKEDITOR.dom.domObject.prototype.getUniqueId * @function * @returns {Number} A unique ID. */ domObjectProto.getUniqueId = function() { return this.$[ 'data-cke-expando' ] || ( this.$[ 'data-cke-expando' ] = CKEDITOR.tools.getNextNumber() ); }; // Implement CKEDITOR.event. CKEDITOR.event.implementOn( domObjectProto ); })( CKEDITOR.dom.domObject.prototype );
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @class */ CKEDITOR.dom.nodeList = function( nativeList ) { this.$ = nativeList; }; CKEDITOR.dom.nodeList.prototype = { count : function() { return this.$.length; }, getItem : function( index ) { var $node = this.$[ index ]; return $node ? new CKEDITOR.dom.node( $node ) : null; } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @class DocumentFragment is a "lightweight" or "minimal" Document object. It is * commonly used to extract a portion of a document's tree or to create a new * fragment of a document. Various operations may take DocumentFragment objects * as arguments and results in all the child nodes of the DocumentFragment being * moved to the child list of this node. * @param {Object} ownerDocument */ CKEDITOR.dom.documentFragment = function( ownerDocument ) { ownerDocument = ownerDocument || CKEDITOR.document; this.$ = ownerDocument.$.createDocumentFragment(); }; CKEDITOR.tools.extend( CKEDITOR.dom.documentFragment.prototype, CKEDITOR.dom.element.prototype, { type : CKEDITOR.NODE_DOCUMENT_FRAGMENT, insertAfterNode : function( node ) { node = node.$; node.parentNode.insertBefore( this.$, node.nextSibling ); } }, true, { 'append' : 1, 'appendBogus' : 1, 'getFirst' : 1, 'getLast' : 1, 'appendTo' : 1, 'moveChildren' : 1, 'insertBefore' : 1, 'insertAfterNode' : 1, 'replace' : 1, 'trim' : 1, 'type' : 1, 'ltrim' : 1, 'rtrim' : 1, 'getDocument' : 1, 'getChildCount' : 1, 'getChild' : 1, 'getChildren' : 1 } );
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @class */ CKEDITOR.dom.range = function( document ) { this.startContainer = null; this.startOffset = null; this.endContainer = null; this.endOffset = null; this.collapsed = true; this.document = document; }; (function() { // Updates the "collapsed" property for the given range object. var updateCollapsed = function( range ) { range.collapsed = ( range.startContainer && range.endContainer && range.startContainer.equals( range.endContainer ) && range.startOffset == range.endOffset ); }; // This is a shared function used to delete, extract and clone the range // contents. // V2 var execContentsAction = function( range, action, docFrag ) { range.optimizeBookmark(); var startNode = range.startContainer; var endNode = range.endContainer; var startOffset = range.startOffset; var endOffset = range.endOffset; var removeStartNode; var removeEndNode; // For text containers, we must simply split the node and point to the // second part. The removal will be handled by the rest of the code . if ( endNode.type == CKEDITOR.NODE_TEXT ) endNode = endNode.split( endOffset ); else { // If the end container has children and the offset is pointing // to a child, then we should start from it. if ( endNode.getChildCount() > 0 ) { // If the offset points after the last node. if ( endOffset >= endNode.getChildCount() ) { // Let's create a temporary node and mark it for removal. endNode = endNode.append( range.document.createText( '' ) ); removeEndNode = true; } else endNode = endNode.getChild( endOffset ); } } // For text containers, we must simply split the node. The removal will // be handled by the rest of the code . if ( startNode.type == CKEDITOR.NODE_TEXT ) { startNode.split( startOffset ); // In cases the end node is the same as the start node, the above // splitting will also split the end, so me must move the end to // the second part of the split. if ( startNode.equals( endNode ) ) endNode = startNode.getNext(); } else { // If the start container has children and the offset is pointing // to a child, then we should start from its previous sibling. // If the offset points to the first node, we don't have a // sibling, so let's use the first one, but mark it for removal. if ( !startOffset ) { // Let's create a temporary node and mark it for removal. startNode = startNode.getFirst().insertBeforeMe( range.document.createText( '' ) ); removeStartNode = true; } else if ( startOffset >= startNode.getChildCount() ) { // Let's create a temporary node and mark it for removal. startNode = startNode.append( range.document.createText( '' ) ); removeStartNode = true; } else startNode = startNode.getChild( startOffset ).getPrevious(); } // Get the parent nodes tree for the start and end boundaries. var startParents = startNode.getParents(); var endParents = endNode.getParents(); // Compare them, to find the top most siblings. var i, topStart, topEnd; for ( i = 0 ; i < startParents.length ; i++ ) { topStart = startParents[ i ]; topEnd = endParents[ i ]; // The compared nodes will match until we find the top most // siblings (different nodes that have the same parent). // "i" will hold the index in the parents array for the top // most element. if ( !topStart.equals( topEnd ) ) break; } var clone = docFrag, levelStartNode, levelClone, currentNode, currentSibling; // Remove all successive sibling nodes for every node in the // startParents tree. for ( var j = i ; j < startParents.length ; j++ ) { levelStartNode = startParents[j]; // For Extract and Clone, we must clone this level. if ( clone && !levelStartNode.equals( startNode ) ) // action = 0 = Delete levelClone = clone.append( levelStartNode.clone() ); currentNode = levelStartNode.getNext(); while ( currentNode ) { // Stop processing when the current node matches a node in the // endParents tree or if it is the endNode. if ( currentNode.equals( endParents[ j ] ) || currentNode.equals( endNode ) ) break; // Cache the next sibling. currentSibling = currentNode.getNext(); // If cloning, just clone it. if ( action == 2 ) // 2 = Clone clone.append( currentNode.clone( true ) ); else { // Both Delete and Extract will remove the node. currentNode.remove(); // When Extracting, move the removed node to the docFrag. if ( action == 1 ) // 1 = Extract clone.append( currentNode ); } currentNode = currentSibling; } if ( clone ) clone = levelClone; } clone = docFrag; // Remove all previous sibling nodes for every node in the // endParents tree. for ( var k = i ; k < endParents.length ; k++ ) { levelStartNode = endParents[ k ]; // For Extract and Clone, we must clone this level. if ( action > 0 && !levelStartNode.equals( endNode ) ) // action = 0 = Delete levelClone = clone.append( levelStartNode.clone() ); // The processing of siblings may have already been done by the parent. if ( !startParents[ k ] || levelStartNode.$.parentNode != startParents[ k ].$.parentNode ) { currentNode = levelStartNode.getPrevious(); while ( currentNode ) { // Stop processing when the current node matches a node in the // startParents tree or if it is the startNode. if ( currentNode.equals( startParents[ k ] ) || currentNode.equals( startNode ) ) break; // Cache the next sibling. currentSibling = currentNode.getPrevious(); // If cloning, just clone it. if ( action == 2 ) // 2 = Clone clone.$.insertBefore( currentNode.$.cloneNode( true ), clone.$.firstChild ) ; else { // Both Delete and Extract will remove the node. currentNode.remove(); // When Extracting, mode the removed node to the docFrag. if ( action == 1 ) // 1 = Extract clone.$.insertBefore( currentNode.$, clone.$.firstChild ); } currentNode = currentSibling; } } if ( clone ) clone = levelClone; } if ( action == 2 ) // 2 = Clone. { // No changes in the DOM should be done, so fix the split text (if any). var startTextNode = range.startContainer; if ( startTextNode.type == CKEDITOR.NODE_TEXT ) { startTextNode.$.data += startTextNode.$.nextSibling.data; startTextNode.$.parentNode.removeChild( startTextNode.$.nextSibling ); } var endTextNode = range.endContainer; if ( endTextNode.type == CKEDITOR.NODE_TEXT && endTextNode.$.nextSibling ) { endTextNode.$.data += endTextNode.$.nextSibling.data; endTextNode.$.parentNode.removeChild( endTextNode.$.nextSibling ); } } else { // Collapse the range. // If a node has been partially selected, collapse the range between // topStart and topEnd. Otherwise, simply collapse it to the start. (W3C specs). if ( topStart && topEnd && ( startNode.$.parentNode != topStart.$.parentNode || endNode.$.parentNode != topEnd.$.parentNode ) ) { var endIndex = topEnd.getIndex(); // If the start node is to be removed, we must correct the // index to reflect the removal. if ( removeStartNode && topEnd.$.parentNode == startNode.$.parentNode ) endIndex--; range.setStart( topEnd.getParent(), endIndex ); } // Collapse it to the start. range.collapse( true ); } // Cleanup any marked node. if ( removeStartNode ) startNode.remove(); if ( removeEndNode && endNode.$.parentNode ) endNode.remove(); }; var inlineChildReqElements = { abbr:1,acronym:1,b:1,bdo:1,big:1,cite:1,code:1,del:1,dfn:1,em:1,font:1,i:1,ins:1,label:1,kbd:1,q:1,samp:1,small:1,span:1,strike:1,strong:1,sub:1,sup:1,tt:1,u:1,'var':1 }; // Creates the appropriate node evaluator for the dom walker used inside // check(Start|End)OfBlock. function getCheckStartEndBlockEvalFunction( isStart ) { var hadBr = false, bookmarkEvaluator = CKEDITOR.dom.walker.bookmark( true ); return function( node ) { // First ignore bookmark nodes. if ( bookmarkEvaluator( node ) ) return true; if ( node.type == CKEDITOR.NODE_TEXT ) { // If there's any visible text, then we're not at the start. if ( CKEDITOR.tools.trim( node.getText() ).length ) return false; } else if ( node.type == CKEDITOR.NODE_ELEMENT ) { // If there are non-empty inline elements (e.g. <img />), then we're not // at the start. if ( !inlineChildReqElements[ node.getName() ] ) { // If we're working at the end-of-block, forgive the first <br /> in non-IE // browsers. if ( !isStart && !CKEDITOR.env.ie && node.getName() == 'br' && !hadBr ) hadBr = true; else return false; } } return true; }; } // Evaluator for CKEDITOR.dom.element::checkBoundaryOfElement, reject any // text node and non-empty elements unless it's being bookmark text. function elementBoundaryEval( node ) { // Reject any text node unless it's being bookmark // OR it's spaces. (#3883) return node.type != CKEDITOR.NODE_TEXT && node.getName() in CKEDITOR.dtd.$removeEmpty || !CKEDITOR.tools.trim( node.getText() ) || !!node.getParent().data( 'cke-bookmark' ); } var whitespaceEval = new CKEDITOR.dom.walker.whitespaces(), bookmarkEval = new CKEDITOR.dom.walker.bookmark(); function nonWhitespaceOrBookmarkEval( node ) { // Whitespaces and bookmark nodes are to be ignored. return !whitespaceEval( node ) && !bookmarkEval( node ); } CKEDITOR.dom.range.prototype = { clone : function() { var clone = new CKEDITOR.dom.range( this.document ); clone.startContainer = this.startContainer; clone.startOffset = this.startOffset; clone.endContainer = this.endContainer; clone.endOffset = this.endOffset; clone.collapsed = this.collapsed; return clone; }, collapse : function( toStart ) { if ( toStart ) { this.endContainer = this.startContainer; this.endOffset = this.startOffset; } else { this.startContainer = this.endContainer; this.startOffset = this.endOffset; } this.collapsed = true; }, /** * The content nodes of the range are cloned and added to a document fragment, which is returned. * <strong> Note: </strong> Text selection may lost after invoking this method. (caused by text node splitting). */ cloneContents : function() { var docFrag = new CKEDITOR.dom.documentFragment( this.document ); if ( !this.collapsed ) execContentsAction( this, 2, docFrag ); return docFrag; }, /** * Deletes the content nodes of the range permanently from the DOM tree. */ deleteContents : function() { if ( this.collapsed ) return; execContentsAction( this, 0 ); }, /** * The content nodes of the range are cloned and added to a document fragment, * meanwhile they're removed permanently from the DOM tree. */ extractContents : function() { var docFrag = new CKEDITOR.dom.documentFragment( this.document ); if ( !this.collapsed ) execContentsAction( this, 1, docFrag ); return docFrag; }, /** * Creates a bookmark object, which can be later used to restore the * range by using the moveToBookmark function. * This is an "intrusive" way to create a bookmark. It includes <span> tags * in the range boundaries. The advantage of it is that it is possible to * handle DOM mutations when moving back to the bookmark. * Attention: the inclusion of nodes in the DOM is a design choice and * should not be changed as there are other points in the code that may be * using those nodes to perform operations. See GetBookmarkNode. * @param {Boolean} [serializable] Indicates that the bookmark nodes * must contain ids, which can be used to restore the range even * when these nodes suffer mutations (like a clonation or innerHTML * change). * @returns {Object} And object representing a bookmark. */ createBookmark : function( serializable ) { var startNode, endNode; var baseId; var clone; var collapsed = this.collapsed; startNode = this.document.createElement( 'span' ); startNode.data( 'cke-bookmark', 1 ); startNode.setStyle( 'display', 'none' ); // For IE, it must have something inside, otherwise it may be // removed during DOM operations. startNode.setHtml( '&nbsp;' ); if ( serializable ) { baseId = 'cke_bm_' + CKEDITOR.tools.getNextNumber(); startNode.setAttribute( 'id', baseId + 'S' ); } // If collapsed, the endNode will not be created. if ( !collapsed ) { endNode = startNode.clone(); endNode.setHtml( '&nbsp;' ); if ( serializable ) endNode.setAttribute( 'id', baseId + 'E' ); clone = this.clone(); clone.collapse(); clone.insertNode( endNode ); } clone = this.clone(); clone.collapse( true ); clone.insertNode( startNode ); // Update the range position. if ( endNode ) { this.setStartAfter( startNode ); this.setEndBefore( endNode ); } else this.moveToPosition( startNode, CKEDITOR.POSITION_AFTER_END ); return { startNode : serializable ? baseId + 'S' : startNode, endNode : serializable ? baseId + 'E' : endNode, serializable : serializable, collapsed : collapsed }; }, /** * Creates a "non intrusive" and "mutation sensible" bookmark. This * kind of bookmark should be used only when the DOM is supposed to * remain stable after its creation. * @param {Boolean} [normalized] Indicates that the bookmark must * normalized. When normalized, the successive text nodes are * considered a single node. To sucessful load a normalized * bookmark, the DOM tree must be also normalized before calling * moveToBookmark. * @returns {Object} An object representing the bookmark. */ createBookmark2 : function( normalized ) { var startContainer = this.startContainer, endContainer = this.endContainer; var startOffset = this.startOffset, endOffset = this.endOffset; var collapsed = this.collapsed; var child, previous; // If there is no range then get out of here. // It happens on initial load in Safari #962 and if the editor it's // hidden also in Firefox if ( !startContainer || !endContainer ) return { start : 0, end : 0 }; if ( normalized ) { // Find out if the start is pointing to a text node that will // be normalized. if ( startContainer.type == CKEDITOR.NODE_ELEMENT ) { child = startContainer.getChild( startOffset ); // In this case, move the start information to that text // node. if ( child && child.type == CKEDITOR.NODE_TEXT && startOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { startContainer = child; startOffset = 0; } } // Normalize the start. while ( startContainer.type == CKEDITOR.NODE_TEXT && ( previous = startContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { startContainer = previous; startOffset += previous.getLength(); } // Process the end only if not normalized. if ( !collapsed ) { // Find out if the start is pointing to a text node that // will be normalized. if ( endContainer.type == CKEDITOR.NODE_ELEMENT ) { child = endContainer.getChild( endOffset ); // In this case, move the start information to that // text node. if ( child && child.type == CKEDITOR.NODE_TEXT && endOffset > 0 && child.getPrevious().type == CKEDITOR.NODE_TEXT ) { endContainer = child; endOffset = 0; } } // Normalize the end. while ( endContainer.type == CKEDITOR.NODE_TEXT && ( previous = endContainer.getPrevious() ) && previous.type == CKEDITOR.NODE_TEXT ) { endContainer = previous; endOffset += previous.getLength(); } } } return { start : startContainer.getAddress( normalized ), end : collapsed ? null : endContainer.getAddress( normalized ), startOffset : startOffset, endOffset : endOffset, normalized : normalized, collapsed : collapsed, is2 : true // It's a createBookmark2 bookmark. }; }, moveToBookmark : function( bookmark ) { if ( bookmark.is2 ) // Created with createBookmark2(). { // Get the start information. var startContainer = this.document.getByAddress( bookmark.start, bookmark.normalized ), startOffset = bookmark.startOffset; // Get the end information. var endContainer = bookmark.end && this.document.getByAddress( bookmark.end, bookmark.normalized ), endOffset = bookmark.endOffset; // Set the start boundary. this.setStart( startContainer, startOffset ); // Set the end boundary. If not available, collapse it. if ( endContainer ) this.setEnd( endContainer, endOffset ); else this.collapse( true ); } else // Created with createBookmark(). { var serializable = bookmark.serializable, startNode = serializable ? this.document.getById( bookmark.startNode ) : bookmark.startNode, endNode = serializable ? this.document.getById( bookmark.endNode ) : bookmark.endNode; // Set the range start at the bookmark start node position. this.setStartBefore( startNode ); // Remove it, because it may interfere in the setEndBefore call. startNode.remove(); // Set the range end at the bookmark end node position, or simply // collapse it if it is not available. if ( endNode ) { this.setEndBefore( endNode ); endNode.remove(); } else this.collapse( true ); } }, getBoundaryNodes : function() { var startNode = this.startContainer, endNode = this.endContainer, startOffset = this.startOffset, endOffset = this.endOffset, childCount; if ( startNode.type == CKEDITOR.NODE_ELEMENT ) { childCount = startNode.getChildCount(); if ( childCount > startOffset ) startNode = startNode.getChild( startOffset ); else if ( childCount < 1 ) startNode = startNode.getPreviousSourceNode(); else // startOffset > childCount but childCount is not 0 { // Try to take the node just after the current position. startNode = startNode.$; while ( startNode.lastChild ) startNode = startNode.lastChild; startNode = new CKEDITOR.dom.node( startNode ); // Normally we should take the next node in DFS order. But it // is also possible that we've already reached the end of // document. startNode = startNode.getNextSourceNode() || startNode; } } if ( endNode.type == CKEDITOR.NODE_ELEMENT ) { childCount = endNode.getChildCount(); if ( childCount > endOffset ) endNode = endNode.getChild( endOffset ).getPreviousSourceNode( true ); else if ( childCount < 1 ) endNode = endNode.getPreviousSourceNode(); else // endOffset > childCount but childCount is not 0 { // Try to take the node just before the current position. endNode = endNode.$; while ( endNode.lastChild ) endNode = endNode.lastChild; endNode = new CKEDITOR.dom.node( endNode ); } } // Sometimes the endNode will come right before startNode for collapsed // ranges. Fix it. (#3780) if ( startNode.getPosition( endNode ) & CKEDITOR.POSITION_FOLLOWING ) startNode = endNode; return { startNode : startNode, endNode : endNode }; }, /** * Find the node which fully contains the range. * @param includeSelf * @param {Boolean} ignoreTextNode Whether ignore CKEDITOR.NODE_TEXT type. */ getCommonAncestor : function( includeSelf , ignoreTextNode ) { var start = this.startContainer, end = this.endContainer, ancestor; if ( start.equals( end ) ) { if ( includeSelf && start.type == CKEDITOR.NODE_ELEMENT && this.startOffset == this.endOffset - 1 ) ancestor = start.getChild( this.startOffset ); else ancestor = start; } else ancestor = start.getCommonAncestor( end ); return ignoreTextNode && !ancestor.is ? ancestor.getParent() : ancestor; }, /** * Transforms the startContainer and endContainer properties from text * nodes to element nodes, whenever possible. This is actually possible * if either of the boundary containers point to a text node, and its * offset is set to zero, or after the last char in the node. */ optimize : function() { var container = this.startContainer; var offset = this.startOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setStartBefore( container ); else if ( offset >= container.getLength() ) this.setStartAfter( container ); } container = this.endContainer; offset = this.endOffset; if ( container.type != CKEDITOR.NODE_ELEMENT ) { if ( !offset ) this.setEndBefore( container ); else if ( offset >= container.getLength() ) this.setEndAfter( container ); } }, /** * Move the range out of bookmark nodes if they'd been the container. */ optimizeBookmark: function() { var startNode = this.startContainer, endNode = this.endContainer; if ( startNode.is && startNode.is( 'span' ) && startNode.data( 'cke-bookmark' ) ) this.setStartAt( startNode, CKEDITOR.POSITION_BEFORE_START ); if ( endNode && endNode.is && endNode.is( 'span' ) && endNode.data( 'cke-bookmark' ) ) this.setEndAt( endNode, CKEDITOR.POSITION_AFTER_END ); }, trim : function( ignoreStart, ignoreEnd ) { var startContainer = this.startContainer, startOffset = this.startOffset, collapsed = this.collapsed; if ( ( !ignoreStart || collapsed ) && startContainer && startContainer.type == CKEDITOR.NODE_TEXT ) { // If the offset is zero, we just insert the new node before // the start. if ( !startOffset ) { startOffset = startContainer.getIndex(); startContainer = startContainer.getParent(); } // If the offset is at the end, we'll insert it after the text // node. else if ( startOffset >= startContainer.getLength() ) { startOffset = startContainer.getIndex() + 1; startContainer = startContainer.getParent(); } // In other case, we split the text node and insert the new // node at the split point. else { var nextText = startContainer.split( startOffset ); startOffset = startContainer.getIndex() + 1; startContainer = startContainer.getParent(); // Check all necessity of updating the end boundary. if ( this.startContainer.equals( this.endContainer ) ) this.setEnd( nextText, this.endOffset - this.startOffset ); else if ( startContainer.equals( this.endContainer ) ) this.endOffset += 1; } this.setStart( startContainer, startOffset ); if ( collapsed ) { this.collapse( true ); return; } } var endContainer = this.endContainer; var endOffset = this.endOffset; if ( !( ignoreEnd || collapsed ) && endContainer && endContainer.type == CKEDITOR.NODE_TEXT ) { // If the offset is zero, we just insert the new node before // the start. if ( !endOffset ) { endOffset = endContainer.getIndex(); endContainer = endContainer.getParent(); } // If the offset is at the end, we'll insert it after the text // node. else if ( endOffset >= endContainer.getLength() ) { endOffset = endContainer.getIndex() + 1; endContainer = endContainer.getParent(); } // In other case, we split the text node and insert the new // node at the split point. else { endContainer.split( endOffset ); endOffset = endContainer.getIndex() + 1; endContainer = endContainer.getParent(); } this.setEnd( endContainer, endOffset ); } }, enlarge : function( unit ) { switch ( unit ) { case CKEDITOR.ENLARGE_ELEMENT : if ( this.collapsed ) return; // Get the common ancestor. var commonAncestor = this.getCommonAncestor(); var body = this.document.getBody(); // For each boundary // a. Depending on its position, find out the first node to be checked (a sibling) or, if not available, to be enlarge. // b. Go ahead checking siblings and enlarging the boundary as much as possible until the common ancestor is not reached. After reaching the common ancestor, just save the enlargeable node to be used later. var startTop, endTop; var enlargeable, sibling, commonReached; // Indicates that the node can be added only if whitespace // is available before it. var needsWhiteSpace = false; var isWhiteSpace; var siblingText; // Process the start boundary. var container = this.startContainer; var offset = this.startOffset; if ( container.type == CKEDITOR.NODE_TEXT ) { if ( offset ) { // Check if there is any non-space text before the // offset. Otherwise, container is null. container = !CKEDITOR.tools.trim( container.substring( 0, offset ) ).length && container; // If we found only whitespace in the node, it // means that we'll need more whitespace to be able // to expand. For example, <i> can be expanded in // "A <i> [B]</i>", but not in "A<i> [B]</i>". needsWhiteSpace = !!container; } if ( container ) { if ( !( sibling = container.getPrevious() ) ) enlargeable = container.getParent(); } } else { // If we have offset, get the node preceeding it as the // first sibling to be checked. if ( offset ) sibling = container.getChild( offset - 1 ) || container.getLast(); // If there is no sibling, mark the container to be // enlarged. if ( !sibling ) enlargeable = container; } while ( enlargeable || sibling ) { if ( enlargeable && !sibling ) { // If we reached the common ancestor, mark the flag // for it. if ( !commonReached && enlargeable.equals( commonAncestor ) ) commonReached = true; if ( !body.contains( enlargeable ) ) break; // If we don't need space or this element breaks // the line, then enlarge it. if ( !needsWhiteSpace || enlargeable.getComputedStyle( 'display' ) != 'inline' ) { needsWhiteSpace = false; // If the common ancestor has been reached, // we'll not enlarge it immediately, but just // mark it to be enlarged later if the end // boundary also enlarges it. if ( commonReached ) startTop = enlargeable; else this.setStartBefore( enlargeable ); } sibling = enlargeable.getPrevious(); } // Check all sibling nodes preceeding the enlargeable // node. The node wil lbe enlarged only if none of them // blocks it. while ( sibling ) { // This flag indicates that this node has // whitespaces at the end. isWhiteSpace = false; if ( sibling.type == CKEDITOR.NODE_TEXT ) { siblingText = sibling.getText(); if ( /[^\s\ufeff]/.test( siblingText ) ) sibling = null; isWhiteSpace = /[\s\ufeff]$/.test( siblingText ); } else { // If this is a visible element. // We need to check for the bookmark attribute because IE insists on // rendering the display:none nodes we use for bookmarks. (#3363) if ( sibling.$.offsetWidth > 0 && !sibling.data( 'cke-bookmark' ) ) { // We'll accept it only if we need // whitespace, and this is an inline // element with whitespace only. if ( needsWhiteSpace && CKEDITOR.dtd.$removeEmpty[ sibling.getName() ] ) { // It must contains spaces and inline elements only. siblingText = sibling.getText(); if ( (/[^\s\ufeff]/).test( siblingText ) ) // Spaces + Zero Width No-Break Space (U+FEFF) sibling = null; else { var allChildren = sibling.$.all || sibling.$.getElementsByTagName( '*' ); for ( var i = 0, child ; child = allChildren[ i++ ] ; ) { if ( !CKEDITOR.dtd.$removeEmpty[ child.nodeName.toLowerCase() ] ) { sibling = null; break; } } } if ( sibling ) isWhiteSpace = !!siblingText.length; } else sibling = null; } } // A node with whitespaces has been found. if ( isWhiteSpace ) { // Enlarge the last enlargeable node, if we // were waiting for spaces. if ( needsWhiteSpace ) { if ( commonReached ) startTop = enlargeable; else if ( enlargeable ) this.setStartBefore( enlargeable ); } else needsWhiteSpace = true; } if ( sibling ) { var next = sibling.getPrevious(); if ( !enlargeable && !next ) { // Set the sibling as enlargeable, so it's // parent will be get later outside this while. enlargeable = sibling; sibling = null; break; } sibling = next; } else { // If sibling has been set to null, then we // need to stop enlarging. enlargeable = null; } } if ( enlargeable ) enlargeable = enlargeable.getParent(); } // Process the end boundary. This is basically the same // code used for the start boundary, with small changes to // make it work in the oposite side (to the right). This // makes it difficult to reuse the code here. So, fixes to // the above code are likely to be replicated here. container = this.endContainer; offset = this.endOffset; // Reset the common variables. enlargeable = sibling = null; commonReached = needsWhiteSpace = false; if ( container.type == CKEDITOR.NODE_TEXT ) { // Check if there is any non-space text after the // offset. Otherwise, container is null. container = !CKEDITOR.tools.trim( container.substring( offset ) ).length && container; // If we found only whitespace in the node, it // means that we'll need more whitespace to be able // to expand. For example, <i> can be expanded in // "A <i> [B]</i>", but not in "A<i> [B]</i>". needsWhiteSpace = !( container && container.getLength() ); if ( container ) { if ( !( sibling = container.getNext() ) ) enlargeable = container.getParent(); } } else { // Get the node right after the boudary to be checked // first. sibling = container.getChild( offset ); if ( !sibling ) enlargeable = container; } while ( enlargeable || sibling ) { if ( enlargeable && !sibling ) { if ( !commonReached && enlargeable.equals( commonAncestor ) ) commonReached = true; if ( !body.contains( enlargeable ) ) break; if ( !needsWhiteSpace || enlargeable.getComputedStyle( 'display' ) != 'inline' ) { needsWhiteSpace = false; if ( commonReached ) endTop = enlargeable; else if ( enlargeable ) this.setEndAfter( enlargeable ); } sibling = enlargeable.getNext(); } while ( sibling ) { isWhiteSpace = false; if ( sibling.type == CKEDITOR.NODE_TEXT ) { siblingText = sibling.getText(); if ( /[^\s\ufeff]/.test( siblingText ) ) sibling = null; isWhiteSpace = /^[\s\ufeff]/.test( siblingText ); } else { // If this is a visible element. // We need to check for the bookmark attribute because IE insists on // rendering the display:none nodes we use for bookmarks. (#3363) if ( sibling.$.offsetWidth > 0 && !sibling.data( 'cke-bookmark' ) ) { // We'll accept it only if we need // whitespace, and this is an inline // element with whitespace only. if ( needsWhiteSpace && CKEDITOR.dtd.$removeEmpty[ sibling.getName() ] ) { // It must contains spaces and inline elements only. siblingText = sibling.getText(); if ( (/[^\s\ufeff]/).test( siblingText ) ) sibling = null; else { allChildren = sibling.$.all || sibling.$.getElementsByTagName( '*' ); for ( i = 0 ; child = allChildren[ i++ ] ; ) { if ( !CKEDITOR.dtd.$removeEmpty[ child.nodeName.toLowerCase() ] ) { sibling = null; break; } } } if ( sibling ) isWhiteSpace = !!siblingText.length; } else sibling = null; } } if ( isWhiteSpace ) { if ( needsWhiteSpace ) { if ( commonReached ) endTop = enlargeable; else this.setEndAfter( enlargeable ); } } if ( sibling ) { next = sibling.getNext(); if ( !enlargeable && !next ) { enlargeable = sibling; sibling = null; break; } sibling = next; } else { // If sibling has been set to null, then we // need to stop enlarging. enlargeable = null; } } if ( enlargeable ) enlargeable = enlargeable.getParent(); } // If the common ancestor can be enlarged by both boundaries, then include it also. if ( startTop && endTop ) { commonAncestor = startTop.contains( endTop ) ? endTop : startTop; this.setStartBefore( commonAncestor ); this.setEndAfter( commonAncestor ); } break; case CKEDITOR.ENLARGE_BLOCK_CONTENTS: case CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS: // Enlarging the start boundary. var walkerRange = new CKEDITOR.dom.range( this.document ); body = this.document.getBody(); walkerRange.setStartAt( body, CKEDITOR.POSITION_AFTER_START ); walkerRange.setEnd( this.startContainer, this.startOffset ); var walker = new CKEDITOR.dom.walker( walkerRange ), blockBoundary, // The node on which the enlarging should stop. tailBr, // In case BR as block boundary. notBlockBoundary = CKEDITOR.dom.walker.blockBoundary( ( unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ) ? { br : 1 } : null ), // Record the encountered 'blockBoundary' for later use. boundaryGuard = function( node ) { var retval = notBlockBoundary( node ); if ( !retval ) blockBoundary = node; return retval; }, // Record the encounted 'tailBr' for later use. tailBrGuard = function( node ) { var retval = boundaryGuard( node ); if ( !retval && node.is && node.is( 'br' ) ) tailBr = node; return retval; }; walker.guard = boundaryGuard; enlargeable = walker.lastBackward(); // It's the body which stop the enlarging if no block boundary found. blockBoundary = blockBoundary || body; // Start the range either after the end of found block (<p>...</p>[text) // or at the start of block (<p>[text...), by comparing the document position // with 'enlargeable' node. this.setStartAt( blockBoundary, !blockBoundary.is( 'br' ) && ( !enlargeable && this.checkStartOfBlock() || enlargeable && blockBoundary.contains( enlargeable ) ) ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_AFTER_END ); // Enlarging the end boundary. walkerRange = this.clone(); walkerRange.collapse(); walkerRange.setEndAt( body, CKEDITOR.POSITION_BEFORE_END ); walker = new CKEDITOR.dom.walker( walkerRange ); // tailBrGuard only used for on range end. walker.guard = ( unit == CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS ) ? tailBrGuard : boundaryGuard; blockBoundary = null; // End the range right before the block boundary node. enlargeable = walker.lastForward(); // It's the body which stop the enlarging if no block boundary found. blockBoundary = blockBoundary || body; // Close the range either before the found block start (text]<p>...</p>) or at the block end (...text]</p>) // by comparing the document position with 'enlargeable' node. this.setEndAt( blockBoundary, ( !enlargeable && this.checkEndOfBlock() || enlargeable && blockBoundary.contains( enlargeable ) ) ? CKEDITOR.POSITION_BEFORE_END : CKEDITOR.POSITION_BEFORE_START ); // We must include the <br> at the end of range if there's // one and we're expanding list item contents if ( tailBr ) this.setEndAfter( tailBr ); } }, /** * Descrease the range to make sure that boundaries * always anchor beside text nodes or innermost element. * @param {Number} mode ( CKEDITOR.SHRINK_ELEMENT | CKEDITOR.SHRINK_TEXT ) The shrinking mode. * <dl> * <dt>CKEDITOR.SHRINK_ELEMENT</dt> * <dd>Shrink the range boundaries to the edge of the innermost element.</dd> * <dt>CKEDITOR.SHRINK_TEXT</dt> * <dd>Shrink the range boudaries to anchor by the side of enclosed text node, range remains if there's no text nodes on boundaries at all.</dd> * </dl> * @param {Boolean} selectContents Whether result range anchors at the inner OR outer boundary of the node. */ shrink : function( mode, selectContents ) { // Unable to shrink a collapsed range. if ( !this.collapsed ) { mode = mode || CKEDITOR.SHRINK_TEXT; var walkerRange = this.clone(); var startContainer = this.startContainer, endContainer = this.endContainer, startOffset = this.startOffset, endOffset = this.endOffset, collapsed = this.collapsed; // Whether the start/end boundary is moveable. var moveStart = 1, moveEnd = 1; if ( startContainer && startContainer.type == CKEDITOR.NODE_TEXT ) { if ( !startOffset ) walkerRange.setStartBefore( startContainer ); else if ( startOffset >= startContainer.getLength( ) ) walkerRange.setStartAfter( startContainer ); else { // Enlarge the range properly to avoid walker making // DOM changes caused by triming the text nodes later. walkerRange.setStartBefore( startContainer ); moveStart = 0; } } if ( endContainer && endContainer.type == CKEDITOR.NODE_TEXT ) { if ( !endOffset ) walkerRange.setEndBefore( endContainer ); else if ( endOffset >= endContainer.getLength( ) ) walkerRange.setEndAfter( endContainer ); else { walkerRange.setEndAfter( endContainer ); moveEnd = 0; } } var walker = new CKEDITOR.dom.walker( walkerRange ), isBookmark = CKEDITOR.dom.walker.bookmark(); walker.evaluator = function( node ) { return node.type == ( mode == CKEDITOR.SHRINK_ELEMENT ? CKEDITOR.NODE_ELEMENT : CKEDITOR.NODE_TEXT ); }; var currentElement; walker.guard = function( node, movingOut ) { if ( isBookmark( node ) ) return true; // Stop when we're shrink in element mode while encountering a text node. if ( mode == CKEDITOR.SHRINK_ELEMENT && node.type == CKEDITOR.NODE_TEXT ) return false; // Stop when we've already walked "through" an element. if ( movingOut && node.equals( currentElement ) ) return false; if ( !movingOut && node.type == CKEDITOR.NODE_ELEMENT ) currentElement = node; return true; }; if ( moveStart ) { var textStart = walker[ mode == CKEDITOR.SHRINK_ELEMENT ? 'lastForward' : 'next'](); textStart && this.setStartAt( textStart, selectContents ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_BEFORE_START ); } if ( moveEnd ) { walker.reset(); var textEnd = walker[ mode == CKEDITOR.SHRINK_ELEMENT ? 'lastBackward' : 'previous'](); textEnd && this.setEndAt( textEnd, selectContents ? CKEDITOR.POSITION_BEFORE_END : CKEDITOR.POSITION_AFTER_END ); } return !!( moveStart || moveEnd ); } }, /** * Inserts a node at the start of the range. The range will be expanded * the contain the node. */ insertNode : function( node ) { this.optimizeBookmark(); this.trim( false, true ); var startContainer = this.startContainer; var startOffset = this.startOffset; var nextNode = startContainer.getChild( startOffset ); if ( nextNode ) node.insertBefore( nextNode ); else startContainer.append( node ); // Check if we need to update the end boundary. if ( node.getParent().equals( this.endContainer ) ) this.endOffset++; // Expand the range to embrace the new node. this.setStartBefore( node ); }, moveToPosition : function( node, position ) { this.setStartAt( node, position ); this.collapse( true ); }, selectNodeContents : function( node ) { this.setStart( node, 0 ); this.setEnd( node, node.type == CKEDITOR.NODE_TEXT ? node.getLength() : node.getChildCount() ); }, /** * Sets the start position of a Range. * @param {CKEDITOR.dom.node} startNode The node to start the range. * @param {Number} startOffset An integer greater than or equal to zero * representing the offset for the start of the range from the start * of startNode. */ setStart : function( startNode, startOffset ) { // W3C requires a check for the new position. If it is after the end // boundary, the range should be collapsed to the new start. It seams // we will not need this check for our use of this class so we can // ignore it for now. // Fixing invalid range start inside dtd empty elements. if( startNode.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$empty[ startNode.getName() ] ) startOffset = startNode.getIndex(), startNode = startNode.getParent(); this.startContainer = startNode; this.startOffset = startOffset; if ( !this.endContainer ) { this.endContainer = startNode; this.endOffset = startOffset; } updateCollapsed( this ); }, /** * Sets the end position of a Range. * @param {CKEDITOR.dom.node} endNode The node to end the range. * @param {Number} endOffset An integer greater than or equal to zero * representing the offset for the end of the range from the start * of endNode. */ setEnd : function( endNode, endOffset ) { // W3C requires a check for the new position. If it is before the start // boundary, the range should be collapsed to the new end. It seams we // will not need this check for our use of this class so we can ignore // it for now. // Fixing invalid range end inside dtd empty elements. if( endNode.type == CKEDITOR.NODE_ELEMENT && CKEDITOR.dtd.$empty[ endNode.getName() ] ) endOffset = endNode.getIndex() + 1, endNode = endNode.getParent(); this.endContainer = endNode; this.endOffset = endOffset; if ( !this.startContainer ) { this.startContainer = endNode; this.startOffset = endOffset; } updateCollapsed( this ); }, setStartAfter : function( node ) { this.setStart( node.getParent(), node.getIndex() + 1 ); }, setStartBefore : function( node ) { this.setStart( node.getParent(), node.getIndex() ); }, setEndAfter : function( node ) { this.setEnd( node.getParent(), node.getIndex() + 1 ); }, setEndBefore : function( node ) { this.setEnd( node.getParent(), node.getIndex() ); }, setStartAt : function( node, position ) { switch( position ) { case CKEDITOR.POSITION_AFTER_START : this.setStart( node, 0 ); break; case CKEDITOR.POSITION_BEFORE_END : if ( node.type == CKEDITOR.NODE_TEXT ) this.setStart( node, node.getLength() ); else this.setStart( node, node.getChildCount() ); break; case CKEDITOR.POSITION_BEFORE_START : this.setStartBefore( node ); break; case CKEDITOR.POSITION_AFTER_END : this.setStartAfter( node ); } updateCollapsed( this ); }, setEndAt : function( node, position ) { switch( position ) { case CKEDITOR.POSITION_AFTER_START : this.setEnd( node, 0 ); break; case CKEDITOR.POSITION_BEFORE_END : if ( node.type == CKEDITOR.NODE_TEXT ) this.setEnd( node, node.getLength() ); else this.setEnd( node, node.getChildCount() ); break; case CKEDITOR.POSITION_BEFORE_START : this.setEndBefore( node ); break; case CKEDITOR.POSITION_AFTER_END : this.setEndAfter( node ); } updateCollapsed( this ); }, fixBlock : function( isStart, blockTag ) { var bookmark = this.createBookmark(), fixedBlock = this.document.createElement( blockTag ); this.collapse( isStart ); this.enlarge( CKEDITOR.ENLARGE_BLOCK_CONTENTS ); this.extractContents().appendTo( fixedBlock ); fixedBlock.trim(); if ( !CKEDITOR.env.ie ) fixedBlock.appendBogus(); this.insertNode( fixedBlock ); this.moveToBookmark( bookmark ); return fixedBlock; }, splitBlock : function( blockTag ) { var startPath = new CKEDITOR.dom.elementPath( this.startContainer ), endPath = new CKEDITOR.dom.elementPath( this.endContainer ); var startBlockLimit = startPath.blockLimit, endBlockLimit = endPath.blockLimit; var startBlock = startPath.block, endBlock = endPath.block; var elementPath = null; // Do nothing if the boundaries are in different block limits. if ( !startBlockLimit.equals( endBlockLimit ) ) return null; // Get or fix current blocks. if ( blockTag != 'br' ) { if ( !startBlock ) { startBlock = this.fixBlock( true, blockTag ); endBlock = new CKEDITOR.dom.elementPath( this.endContainer ).block; } if ( !endBlock ) endBlock = this.fixBlock( false, blockTag ); } // Get the range position. var isStartOfBlock = startBlock && this.checkStartOfBlock(), isEndOfBlock = endBlock && this.checkEndOfBlock(); // Delete the current contents. // TODO: Why is 2.x doing CheckIsEmpty()? this.deleteContents(); if ( startBlock && startBlock.equals( endBlock ) ) { if ( isEndOfBlock ) { elementPath = new CKEDITOR.dom.elementPath( this.startContainer ); this.moveToPosition( endBlock, CKEDITOR.POSITION_AFTER_END ); endBlock = null; } else if ( isStartOfBlock ) { elementPath = new CKEDITOR.dom.elementPath( this.startContainer ); this.moveToPosition( startBlock, CKEDITOR.POSITION_BEFORE_START ); startBlock = null; } else { endBlock = this.splitElement( startBlock ); // In Gecko, the last child node must be a bogus <br>. // Note: bogus <br> added under <ul> or <ol> would cause // lists to be incorrectly rendered. if ( !CKEDITOR.env.ie && !startBlock.is( 'ul', 'ol') ) startBlock.appendBogus() ; } } return { previousBlock : startBlock, nextBlock : endBlock, wasStartOfBlock : isStartOfBlock, wasEndOfBlock : isEndOfBlock, elementPath : elementPath }; }, /** * Branch the specified element from the collapsed range position and * place the caret between the two result branches. * Note: The range must be collapsed and been enclosed by this element. * @param {CKEDITOR.dom.element} element * @return {CKEDITOR.dom.element} Root element of the new branch after the split. */ splitElement : function( toSplit ) { if ( !this.collapsed ) return null; // Extract the contents of the block from the selection point to the end // of its contents. this.setEndAt( toSplit, CKEDITOR.POSITION_BEFORE_END ); var documentFragment = this.extractContents(); // Duplicate the element after it. var clone = toSplit.clone( false ); // Place the extracted contents into the duplicated element. documentFragment.appendTo( clone ); clone.insertAfter( toSplit ); this.moveToPosition( toSplit, CKEDITOR.POSITION_AFTER_END ); return clone; }, /** * Check whether a range boundary is at the inner boundary of a given * element. * @param {CKEDITOR.dom.element} element The target element to check. * @param {Number} checkType The boundary to check for both the range * and the element. It can be CKEDITOR.START or CKEDITOR.END. * @returns {Boolean} "true" if the range boundary is at the inner * boundary of the element. */ checkBoundaryOfElement : function( element, checkType ) { var checkStart = ( checkType == CKEDITOR.START ); // Create a copy of this range, so we can manipulate it for our checks. var walkerRange = this.clone(); // Collapse the range at the proper size. walkerRange.collapse( checkStart ); // Expand the range to element boundary. walkerRange[ checkStart ? 'setStartAt' : 'setEndAt' ] ( element, checkStart ? CKEDITOR.POSITION_AFTER_START : CKEDITOR.POSITION_BEFORE_END ); // Create the walker, which will check if we have anything useful // in the range. var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = elementBoundaryEval; return walker[ checkStart ? 'checkBackward' : 'checkForward' ](); }, // Calls to this function may produce changes to the DOM. The range may // be updated to reflect such changes. checkStartOfBlock : function() { var startContainer = this.startContainer, startOffset = this.startOffset; // If the starting node is a text node, and non-empty before the offset, // then we're surely not at the start of block. if ( startOffset && startContainer.type == CKEDITOR.NODE_TEXT ) { var textBefore = CKEDITOR.tools.ltrim( startContainer.substring( 0, startOffset ) ); if ( textBefore.length ) return false; } // Antecipate the trim() call here, so the walker will not make // changes to the DOM, which would not get reflected into this // range otherwise. this.trim(); // We need to grab the block element holding the start boundary, so // let's use an element path for it. var path = new CKEDITOR.dom.elementPath( this.startContainer ); // Creates a range starting at the block start until the range start. var walkerRange = this.clone(); walkerRange.collapse( true ); walkerRange.setStartAt( path.block || path.blockLimit, CKEDITOR.POSITION_AFTER_START ); var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = getCheckStartEndBlockEvalFunction( true ); return walker.checkBackward(); }, checkEndOfBlock : function() { var endContainer = this.endContainer, endOffset = this.endOffset; // If the ending node is a text node, and non-empty after the offset, // then we're surely not at the end of block. if ( endContainer.type == CKEDITOR.NODE_TEXT ) { var textAfter = CKEDITOR.tools.rtrim( endContainer.substring( endOffset ) ); if ( textAfter.length ) return false; } // Antecipate the trim() call here, so the walker will not make // changes to the DOM, which would not get reflected into this // range otherwise. this.trim(); // We need to grab the block element holding the start boundary, so // let's use an element path for it. var path = new CKEDITOR.dom.elementPath( this.endContainer ); // Creates a range starting at the block start until the range start. var walkerRange = this.clone(); walkerRange.collapse( false ); walkerRange.setEndAt( path.block || path.blockLimit, CKEDITOR.POSITION_BEFORE_END ); var walker = new CKEDITOR.dom.walker( walkerRange ); walker.evaluator = getCheckStartEndBlockEvalFunction( false ); return walker.checkForward(); }, /** * Moves the range boundaries to the first/end editing point inside an * element. For example, in an element tree like * "&lt;p&gt;&lt;b&gt;&lt;i&gt;&lt;/i&gt;&lt;/b&gt; Text&lt;/p&gt;", the start editing point is * "&lt;p&gt;&lt;b&gt;&lt;i&gt;^&lt;/i&gt;&lt;/b&gt; Text&lt;/p&gt;" (inside &lt;i&gt;). * @param {CKEDITOR.dom.element} el The element into which look for the * editing spot. * @param {Boolean} isMoveToEnd Whether move to the end editable position. */ moveToElementEditablePosition : function( el, isMoveToEnd ) { var isEditable; // Empty elements are rejected. if ( CKEDITOR.dtd.$empty[ el.getName() ] ) return false; while ( el && el.type == CKEDITOR.NODE_ELEMENT ) { isEditable = el.isEditable(); // If an editable element is found, move inside it. if ( isEditable ) this.moveToPosition( el, isMoveToEnd ? CKEDITOR.POSITION_BEFORE_END : CKEDITOR.POSITION_AFTER_START ); // Stop immediately if we've found a non editable inline element (e.g <img>). else if ( CKEDITOR.dtd.$inline[ el.getName() ] ) { this.moveToPosition( el, isMoveToEnd ? CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START ); return true; } // Non-editable non-inline elements are to be bypassed, getting the next one. if ( CKEDITOR.dtd.$empty[ el.getName() ] ) el = el[ isMoveToEnd ? 'getPrevious' : 'getNext' ]( nonWhitespaceOrBookmarkEval ); else el = el[ isMoveToEnd ? 'getLast' : 'getFirst' ]( nonWhitespaceOrBookmarkEval ); // Stop immediately if we've found a text node. if ( el && el.type == CKEDITOR.NODE_TEXT ) { this.moveToPosition( el, isMoveToEnd ? CKEDITOR.POSITION_AFTER_END : CKEDITOR.POSITION_BEFORE_START ); return true; } } return isEditable; }, /** *@see {CKEDITOR.dom.range.moveToElementEditablePosition} */ moveToElementEditStart : function( target ) { return this.moveToElementEditablePosition( target ); }, /** *@see {CKEDITOR.dom.range.moveToElementEditablePosition} */ moveToElementEditEnd : function( target ) { return this.moveToElementEditablePosition( target, true ); }, /** * Get the single node enclosed within the range if there's one. */ getEnclosedNode : function() { var walkerRange = this.clone(); // Optimize and analyze the range to avoid DOM destructive nature of walker. (#5780) walkerRange.optimize(); if ( walkerRange.startContainer.type != CKEDITOR.NODE_ELEMENT || walkerRange.endContainer.type != CKEDITOR.NODE_ELEMENT ) return null; var walker = new CKEDITOR.dom.walker( walkerRange ), isNotBookmarks = CKEDITOR.dom.walker.bookmark( true ), isNotWhitespaces = CKEDITOR.dom.walker.whitespaces( true ), evaluator = function( node ) { return isNotWhitespaces( node ) && isNotBookmarks( node ); }; walkerRange.evaluator = evaluator; var node = walker.next(); walker.reset(); return node && node.equals( walker.previous() ) ? node : null; }, getTouchedStartNode : function() { var container = this.startContainer ; if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT ) return container ; return container.getChild( this.startOffset ) || container ; }, getTouchedEndNode : function() { var container = this.endContainer ; if ( this.collapsed || container.type != CKEDITOR.NODE_ELEMENT ) return container ; return container.getChild( this.endOffset - 1 ) || container ; } }; })(); CKEDITOR.POSITION_AFTER_START = 1; // <element>^contents</element> "^text" CKEDITOR.POSITION_BEFORE_END = 2; // <element>contents^</element> "text^" CKEDITOR.POSITION_BEFORE_START = 3; // ^<element>contents</element> ^"text" CKEDITOR.POSITION_AFTER_END = 4; // <element>contents</element>^ "text" CKEDITOR.ENLARGE_ELEMENT = 1; CKEDITOR.ENLARGE_BLOCK_CONTENTS = 2; CKEDITOR.ENLARGE_LIST_ITEM_CONTENTS = 3; // Check boundary types. // @see CKEDITOR.dom.range.prototype.checkBoundaryOfElement CKEDITOR.START = 1; CKEDITOR.END = 2; CKEDITOR.STARTEND = 3; // Shrink range types. // @see CKEDITOR.dom.range.prototype.shrink CKEDITOR.SHRINK_ELEMENT = 1; CKEDITOR.SHRINK_TEXT = 2;
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom.element} class, which * represents a DOM element. */ /** * Represents a DOM element. * @constructor * @augments CKEDITOR.dom.node * @param {Object|String} element A native DOM element or the element name for * new elements. * @param {CKEDITOR.dom.document} [ownerDocument] The document that will contain * the element in case of element creation. * @example * // Create a new &lt;span&gt; element. * var element = new CKEDITOR.dom.element( 'span' ); * @example * // Create an element based on a native DOM element. * var element = new CKEDITOR.dom.element( document.getElementById( 'myId' ) ); */ CKEDITOR.dom.element = function( element, ownerDocument ) { if ( typeof element == 'string' ) element = ( ownerDocument ? ownerDocument.$ : document ).createElement( element ); // Call the base constructor (we must not call CKEDITOR.dom.node). CKEDITOR.dom.domObject.call( this, element ); }; // PACKAGER_RENAME( CKEDITOR.dom.element ) /** * The the {@link CKEDITOR.dom.element} representing and element. If the * element is a native DOM element, it will be transformed into a valid * CKEDITOR.dom.element object. * @returns {CKEDITOR.dom.element} The transformed element. * @example * var element = new CKEDITOR.dom.element( 'span' ); * alert( element == <b>CKEDITOR.dom.element.get( element )</b> ); "true" * @example * var element = document.getElementById( 'myElement' ); * alert( <b>CKEDITOR.dom.element.get( element )</b>.getName() ); e.g. "p" */ CKEDITOR.dom.element.get = function( element ) { return element && ( element.$ ? element : new CKEDITOR.dom.element( element ) ); }; CKEDITOR.dom.element.prototype = new CKEDITOR.dom.node(); /** * Creates an instance of the {@link CKEDITOR.dom.element} class based on the * HTML representation of an element. * @param {String} html The element HTML. It should define only one element in * the "root" level. The "root" element can have child nodes, but not * siblings. * @returns {CKEDITOR.dom.element} The element instance. * @example * var element = <b>CKEDITOR.dom.element.createFromHtml( '&lt;strong class="anyclass"&gt;My element&lt;/strong&gt;' )</b>; * alert( element.getName() ); // "strong" */ CKEDITOR.dom.element.createFromHtml = function( html, ownerDocument ) { var temp = new CKEDITOR.dom.element( 'div', ownerDocument ); temp.setHtml( html ); // When returning the node, remove it from its parent to detach it. return temp.getFirst().remove(); }; CKEDITOR.dom.element.setMarker = function( database, element, name, value ) { var id = element.getCustomData( 'list_marker_id' ) || ( element.setCustomData( 'list_marker_id', CKEDITOR.tools.getNextNumber() ).getCustomData( 'list_marker_id' ) ), markerNames = element.getCustomData( 'list_marker_names' ) || ( element.setCustomData( 'list_marker_names', {} ).getCustomData( 'list_marker_names' ) ); database[id] = element; markerNames[name] = 1; return element.setCustomData( name, value ); }; CKEDITOR.dom.element.clearAllMarkers = function( database ) { for ( var i in database ) CKEDITOR.dom.element.clearMarkers( database, database[i], 1 ); }; CKEDITOR.dom.element.clearMarkers = function( database, element, removeFromDatabase ) { var names = element.getCustomData( 'list_marker_names' ), id = element.getCustomData( 'list_marker_id' ); for ( var i in names ) element.removeCustomData( i ); element.removeCustomData( 'list_marker_names' ); if ( removeFromDatabase ) { element.removeCustomData( 'list_marker_id' ); delete database[id]; } }; CKEDITOR.tools.extend( CKEDITOR.dom.element.prototype, /** @lends CKEDITOR.dom.element.prototype */ { /** * The node type. This is a constant value set to * {@link CKEDITOR.NODE_ELEMENT}. * @type Number * @example */ type : CKEDITOR.NODE_ELEMENT, /** * Adds a CSS class to the element. It appends the class to the * already existing names. * @param {String} className The name of the class to be added. * @example * var element = new CKEDITOR.dom.element( 'div' ); * element.addClass( 'classA' ); // &lt;div class="classA"&gt; * element.addClass( 'classB' ); // &lt;div class="classA classB"&gt; * element.addClass( 'classA' ); // &lt;div class="classA classB"&gt; */ addClass : function( className ) { var c = this.$.className; if ( c ) { var regex = new RegExp( '(?:^|\\s)' + className + '(?:\\s|$)', '' ); if ( !regex.test( c ) ) c += ' ' + className; } this.$.className = c || className; }, /** * Removes a CSS class name from the elements classes. Other classes * remain untouched. * @param {String} className The name of the class to remove. * @example * var element = new CKEDITOR.dom.element( 'div' ); * element.addClass( 'classA' ); // &lt;div class="classA"&gt; * element.addClass( 'classB' ); // &lt;div class="classA classB"&gt; * element.removeClass( 'classA' ); // &lt;div class="classB"&gt; * element.removeClass( 'classB' ); // &lt;div&gt; */ removeClass : function( className ) { var c = this.getAttribute( 'class' ); if ( c ) { var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', 'i' ); if ( regex.test( c ) ) { c = c.replace( regex, '' ).replace( /^\s+/, '' ); if ( c ) this.setAttribute( 'class', c ); else this.removeAttribute( 'class' ); } } }, hasClass : function( className ) { var regex = new RegExp( '(?:^|\\s+)' + className + '(?=\\s|$)', '' ); return regex.test( this.getAttribute('class') ); }, /** * Append a node as a child of this element. * @param {CKEDITOR.dom.node|String} node The node or element name to be * appended. * @param {Boolean} [toStart] Indicates that the element is to be * appended at the start. * @returns {CKEDITOR.dom.node} The appended node. * @example * var p = new CKEDITOR.dom.element( 'p' ); * * var strong = new CKEDITOR.dom.element( 'strong' ); * <b>p.append( strong );</b> * * var em = <b>p.append( 'em' );</b> * * // result: "&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;em&gt;&lt;/em&gt;&lt;/p&gt;" */ append : function( node, toStart ) { if ( typeof node == 'string' ) node = this.getDocument().createElement( node ); if ( toStart ) this.$.insertBefore( node.$, this.$.firstChild ); else this.$.appendChild( node.$ ); return node; }, appendHtml : function( html ) { if ( !this.$.childNodes.length ) this.setHtml( html ); else { var temp = new CKEDITOR.dom.element( 'div', this.getDocument() ); temp.setHtml( html ); temp.moveChildren( this ); } }, /** * Append text to this element. * @param {String} text The text to be appended. * @returns {CKEDITOR.dom.node} The appended node. * @example * var p = new CKEDITOR.dom.element( 'p' ); * p.appendText( 'This is' ); * p.appendText( ' some text' ); * * // result: "&lt;p&gt;This is some text&lt;/p&gt;" */ appendText : function( text ) { if ( this.$.text != undefined ) this.$.text += text; else this.append( new CKEDITOR.dom.text( text ) ); }, appendBogus : function() { var lastChild = this.getLast() ; // Ignore empty/spaces text. while ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT && !CKEDITOR.tools.rtrim( lastChild.getText() ) ) lastChild = lastChild.getPrevious(); if ( !lastChild || !lastChild.is || !lastChild.is( 'br' ) ) { var bogus = CKEDITOR.env.opera ? this.getDocument().createText('') : this.getDocument().createElement( 'br' ); CKEDITOR.env.gecko && bogus.setAttribute( 'type', '_moz' ); this.append( bogus ); } }, /** * Breaks one of the ancestor element in the element position, moving * this element between the broken parts. * @param {CKEDITOR.dom.element} parent The anscestor element to get broken. * @example * // Before breaking: * // &lt;b&gt;This &lt;i&gt;is some&lt;span /&gt; sample&lt;/i&gt; test text&lt;/b&gt; * // If "element" is &lt;span /&gt; and "parent" is &lt;i&gt;: * // &lt;b&gt;This &lt;i&gt;is some&lt;/i&gt;&lt;span /&gt;&lt;i&gt; sample&lt;/i&gt; test text&lt;/b&gt; * element.breakParent( parent ); * @example * // Before breaking: * // &lt;b&gt;This &lt;i&gt;is some&lt;span /&gt; sample&lt;/i&gt; test text&lt;/b&gt; * // If "element" is &lt;span /&gt; and "parent" is &lt;b&gt;: * // &lt;b&gt;This &lt;i&gt;is some&lt;/i&gt;&lt;/b&gt;&lt;span /&gt;&lt;b&gt;&lt;i&gt; sample&lt;/i&gt; test text&lt;/b&gt; * element.breakParent( parent ); */ breakParent : function( parent ) { var range = new CKEDITOR.dom.range( this.getDocument() ); // We'll be extracting part of this element, so let's use our // range to get the correct piece. range.setStartAfter( this ); range.setEndAfter( parent ); // Extract it. var docFrag = range.extractContents(); // Move the element outside the broken element. range.insertNode( this.remove() ); // Re-insert the extracted piece after the element. docFrag.insertAfterNode( this ); }, contains : CKEDITOR.env.ie || CKEDITOR.env.webkit ? function( node ) { var $ = this.$; return node.type != CKEDITOR.NODE_ELEMENT ? $.contains( node.getParent().$ ) : $ != node.$ && $.contains( node.$ ); } : function( node ) { return !!( this.$.compareDocumentPosition( node.$ ) & 16 ); }, /** * Moves the selection focus to this element. * @param {Boolean} defer Whether to asynchronously defer the * execution by 100 ms. * @example * var element = CKEDITOR.document.getById( 'myTextarea' ); * <b>element.focus()</b>; */ focus : ( function() { function exec() { // IE throws error if the element is not visible. try { this.$.focus(); } catch (e) {} } return function( defer ) { if ( defer ) CKEDITOR.tools.setTimeout( exec, 100, this ); else exec.call( this ); }; })(), /** * Gets the inner HTML of this element. * @returns {String} The inner HTML of this element. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;div&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/div&gt;' ); * alert( <b>p.getHtml()</b> ); // "&lt;b&gt;Example&lt;/b&gt;" */ getHtml : function() { var retval = this.$.innerHTML; // Strip <?xml:namespace> tags in IE. (#3341). return CKEDITOR.env.ie ? retval.replace( /<\?[^>]*>/g, '' ) : retval; }, getOuterHtml : function() { if ( this.$.outerHTML ) { // IE includes the <?xml:namespace> tag in the outerHTML of // namespaced element. So, we must strip it here. (#3341) return this.$.outerHTML.replace( /<\?[^>]*>/, '' ); } var tmpDiv = this.$.ownerDocument.createElement( 'div' ); tmpDiv.appendChild( this.$.cloneNode( true ) ); return tmpDiv.innerHTML; }, /** * Sets the inner HTML of this element. * @param {String} html The HTML to be set for this element. * @returns {String} The inserted HTML. * @example * var p = new CKEDITOR.dom.element( 'p' ); * <b>p.setHtml( '&lt;b&gt;Inner&lt;/b&gt; HTML' );</b> * * // result: "&lt;p&gt;&lt;b&gt;Inner&lt;/b&gt; HTML&lt;/p&gt;" */ setHtml : function( html ) { return ( this.$.innerHTML = html ); }, /** * Sets the element contents as plain text. * @param {String} text The text to be set. * @returns {String} The inserted text. * @example * var element = new CKEDITOR.dom.element( 'div' ); * element.setText( 'A > B & C < D' ); * alert( element.innerHTML ); // "A &amp;gt; B &amp;amp; C &amp;lt; D" */ setText : function( text ) { CKEDITOR.dom.element.prototype.setText = ( this.$.innerText != undefined ) ? function ( text ) { return this.$.innerText = text; } : function ( text ) { return this.$.textContent = text; }; return this.setText( text ); }, /** * Gets the value of an element attribute. * @function * @param {String} name The attribute name. * @returns {String} The attribute value or null if not defined. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;input type="text" /&gt;' ); * alert( <b>element.getAttribute( 'type' )</b> ); // "text" */ getAttribute : (function() { var standard = function( name ) { return this.$.getAttribute( name, 2 ); }; if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ) { return function( name ) { switch ( name ) { case 'class': name = 'className'; break; case 'tabindex': var tabIndex = standard.call( this, name ); // IE returns tabIndex=0 by default for all // elements. For those elements, // getAtrribute( 'tabindex', 2 ) returns 32768 // instead. So, we must make this check to give a // uniform result among all browsers. if ( tabIndex !== 0 && this.$.tabIndex === 0 ) tabIndex = null; return tabIndex; break; case 'checked': { var attr = this.$.attributes.getNamedItem( name ), attrValue = attr.specified ? attr.nodeValue // For value given by parser. : this.$.checked; // For value created via DOM interface. return attrValue ? 'checked' : null; } case 'hspace': return this.$.hspace; case 'style': // IE does not return inline styles via getAttribute(). See #2947. return this.$.style.cssText; } return standard.call( this, name ); }; } else return standard; })(), getChildren : function() { return new CKEDITOR.dom.nodeList( this.$.childNodes ); }, /** * Gets the current computed value of one of the element CSS style * properties. * @function * @param {String} propertyName The style property name. * @returns {String} The property value. * @example * var element = new CKEDITOR.dom.element( 'span' ); * alert( <b>element.getComputedStyle( 'display' )</b> ); // "inline" */ getComputedStyle : CKEDITOR.env.ie ? function( propertyName ) { return this.$.currentStyle[ CKEDITOR.tools.cssStyleToDomStyle( propertyName ) ]; } : function( propertyName ) { return this.getWindow().$.getComputedStyle( this.$, '' ).getPropertyValue( propertyName ); }, /** * Gets the DTD entries for this element. * @returns {Object} An object containing the list of elements accepted * by this element. */ getDtd : function() { var dtd = CKEDITOR.dtd[ this.getName() ]; this.getDtd = function() { return dtd; }; return dtd; }, getElementsByTag : CKEDITOR.dom.document.prototype.getElementsByTag, /** * Gets the computed tabindex for this element. * @function * @returns {Number} The tabindex value. * @example * var element = CKEDITOR.document.getById( 'myDiv' ); * alert( <b>element.getTabIndex()</b> ); // e.g. "-1" */ getTabIndex : CKEDITOR.env.ie ? function() { var tabIndex = this.$.tabIndex; // IE returns tabIndex=0 by default for all elements. In // those cases we must check that the element really has // the tabindex attribute set to zero, or it is one of // those element that should have zero by default. if ( tabIndex === 0 && !CKEDITOR.dtd.$tabIndex[ this.getName() ] && parseInt( this.getAttribute( 'tabindex' ), 10 ) !== 0 ) tabIndex = -1; return tabIndex; } : CKEDITOR.env.webkit ? function() { var tabIndex = this.$.tabIndex; // Safari returns "undefined" for elements that should not // have tabindex (like a div). So, we must try to get it // from the attribute. // https://bugs.webkit.org/show_bug.cgi?id=20596 if ( tabIndex == undefined ) { tabIndex = parseInt( this.getAttribute( 'tabindex' ), 10 ); // If the element don't have the tabindex attribute, // then we should return -1. if ( isNaN( tabIndex ) ) tabIndex = -1; } return tabIndex; } : function() { return this.$.tabIndex; }, /** * Gets the text value of this element. * * Only in IE (which uses innerText), &lt;br&gt; will cause linebreaks, * and sucessive whitespaces (including line breaks) will be reduced to * a single space. This behavior is ok for us, for now. It may change * in the future. * @returns {String} The text value. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;div&gt;Same &lt;i&gt;text&lt;/i&gt;.&lt;/div&gt;' ); * alert( <b>element.getText()</b> ); // "Sample text." */ getText : function() { return this.$.textContent || this.$.innerText || ''; }, /** * Gets the window object that contains this element. * @returns {CKEDITOR.dom.window} The window object. * @example */ getWindow : function() { return this.getDocument().getWindow(); }, /** * Gets the value of the "id" attribute of this element. * @returns {String} The element id, or null if not available. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;p id="myId"&gt;&lt;/p&gt;' ); * alert( <b>element.getId()</b> ); // "myId" */ getId : function() { return this.$.id || null; }, /** * Gets the value of the "name" attribute of this element. * @returns {String} The element name, or null if not available. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;input name="myName"&gt;&lt;/input&gt;' ); * alert( <b>element.getNameAtt()</b> ); // "myName" */ getNameAtt : function() { return this.$.name || null; }, /** * Gets the element name (tag name). The returned name is guaranteed to * be always full lowercased. * @returns {String} The element name. * @example * var element = new CKEDITOR.dom.element( 'span' ); * alert( <b>element.getName()</b> ); // "span" */ getName : function() { // Cache the lowercased name inside a closure. var nodeName = this.$.nodeName.toLowerCase(); if ( CKEDITOR.env.ie && ! ( document.documentMode > 8 ) ) { var scopeName = this.$.scopeName; if ( scopeName != 'HTML' ) nodeName = scopeName.toLowerCase() + ':' + nodeName; } return ( this.getName = function() { return nodeName; })(); }, /** * Gets the value set to this element. This value is usually available * for form field elements. * @returns {String} The element value. */ getValue : function() { return this.$.value; }, /** * Gets the first child node of this element. * @param {Function} evaluator Filtering the result node. * @returns {CKEDITOR.dom.node} The first child node or null if not * available. * @example * var element = CKEDITOR.dom.element.createFromHtml( '&lt;div&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/div&gt;' ); * var first = <b>element.getFirst()</b>; * alert( first.getName() ); // "b" */ getFirst : function( evaluator ) { var first = this.$.firstChild, retval = first && new CKEDITOR.dom.node( first ); if ( retval && evaluator && !evaluator( retval ) ) retval = retval.getNext( evaluator ); return retval; }, /** * @param {Function} evaluator Filtering the result node. */ getLast : function( evaluator ) { var last = this.$.lastChild, retval = last && new CKEDITOR.dom.node( last ); if ( retval && evaluator && !evaluator( retval ) ) retval = retval.getPrevious( evaluator ); return retval; }, getStyle : function( name ) { return this.$.style[ CKEDITOR.tools.cssStyleToDomStyle( name ) ]; }, /** * Checks if the element name matches one or more names. * @param {String} name[,name[,...]] One or more names to be checked. * @returns {Boolean} true if the element name matches any of the names. * @example * var element = new CKEDITOR.element( 'span' ); * alert( <b>element.is( 'span' )</b> ); "true" * alert( <b>element.is( 'p', 'span' )</b> ); "true" * alert( <b>element.is( 'p' )</b> ); "false" * alert( <b>element.is( 'p', 'div' )</b> ); "false" */ is : function() { var name = this.getName(); for ( var i = 0 ; i < arguments.length ; i++ ) { if ( arguments[ i ] == name ) return true; } return false; }, isEditable : function() { // Get the element name. var name = this.getName(); // Get the element DTD (defaults to span for unknown elements). var dtd = !CKEDITOR.dtd.$nonEditable[ name ] && ( CKEDITOR.dtd[ name ] || CKEDITOR.dtd.span ); // In the DTD # == text node. return ( dtd && dtd['#'] ); }, isIdentical : function( otherElement ) { if ( this.getName() != otherElement.getName() ) return false; var thisAttribs = this.$.attributes, otherAttribs = otherElement.$.attributes; var thisLength = thisAttribs.length, otherLength = otherAttribs.length; for ( var i = 0 ; i < thisLength ; i++ ) { var attribute = thisAttribs[ i ]; if ( attribute.nodeName == '_moz_dirty' ) continue; if ( ( !CKEDITOR.env.ie || ( attribute.specified && attribute.nodeName != 'data-cke-expando' ) ) && attribute.nodeValue != otherElement.getAttribute( attribute.nodeName ) ) return false; } // For IE, we have to for both elements, because it's difficult to // know how the atttibutes collection is organized in its DOM. if ( CKEDITOR.env.ie ) { for ( i = 0 ; i < otherLength ; i++ ) { attribute = otherAttribs[ i ]; if ( attribute.specified && attribute.nodeName != 'data-cke-expando' && attribute.nodeValue != this.getAttribute( attribute.nodeName ) ) return false; } } return true; }, /** * Checks if this element is visible. May not work if the element is * child of an element with visibility set to "hidden", but works well * on the great majority of cases. * @return {Boolean} True if the element is visible. */ isVisible : function() { var isVisible = !!this.$.offsetHeight && this.getComputedStyle( 'visibility' ) != 'hidden', elementWindow, elementWindowFrame; // Webkit and Opera report non-zero offsetHeight despite that // element is inside an invisible iframe. (#4542) if ( isVisible && ( CKEDITOR.env.webkit || CKEDITOR.env.opera ) ) { elementWindow = this.getWindow(); if ( !elementWindow.equals( CKEDITOR.document.getWindow() ) && ( elementWindowFrame = elementWindow.$.frameElement ) ) { isVisible = new CKEDITOR.dom.element( elementWindowFrame ).isVisible(); } } return isVisible; }, /** * Whether it's an empty inline elements which has no visual impact when removed. */ isEmptyInlineRemoveable : function() { if ( !CKEDITOR.dtd.$removeEmpty[ this.getName() ] ) return false; var children = this.getChildren(); for ( var i = 0, count = children.count(); i < count; i++ ) { var child = children.getItem( i ); if ( child.type == CKEDITOR.NODE_ELEMENT && child.data( 'cke-bookmark' ) ) continue; if ( child.type == CKEDITOR.NODE_ELEMENT && !child.isEmptyInlineRemoveable() || child.type == CKEDITOR.NODE_TEXT && CKEDITOR.tools.trim( child.getText() ) ) { return false; } } return true; }, /** * Indicates that the element has defined attributes. * @returns {Boolean} True if the element has attributes. * @example * var element = CKEDITOR.dom.element.createFromHtml( '<div title="Test">Example</div>' ); * alert( <b>element.hasAttributes()</b> ); "true" * @example * var element = CKEDITOR.dom.element.createFromHtml( '<div>Example</div>' ); * alert( <b>element.hasAttributes()</b> ); "false" */ hasAttributes : CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ? function() { var attributes = this.$.attributes; for ( var i = 0 ; i < attributes.length ; i++ ) { var attribute = attributes[i]; switch ( attribute.nodeName ) { case 'class' : // IE has a strange bug. If calling removeAttribute('className'), // the attributes collection will still contain the "class" // attribute, which will be marked as "specified", even if the // outerHTML of the element is not displaying the class attribute. // Note : I was not able to reproduce it outside the editor, // but I've faced it while working on the TC of #1391. if ( this.getAttribute( 'class' ) ) return true; // Attributes to be ignored. case 'data-cke-expando' : continue; /*jsl:fallthru*/ default : if ( attribute.specified ) return true; } } return false; } : function() { var attrs = this.$.attributes, attrsNum = attrs.length; // The _moz_dirty attribute might get into the element after pasting (#5455) var execludeAttrs = { 'data-cke-expando' : 1, _moz_dirty : 1 }; return attrsNum > 0 && ( attrsNum > 2 || !execludeAttrs[ attrs[0].nodeName ] || ( attrsNum == 2 && !execludeAttrs[ attrs[1].nodeName ] ) ); }, /** * Indicates whether a specified attribute is defined for this element. * @returns {Boolean} True if the specified attribute is defined. * @param (String) name The attribute name. * @example */ hasAttribute : function( name ) { var $attr = this.$.attributes.getNamedItem( name ); return !!( $attr && $attr.specified ); }, /** * Hides this element (display:none). * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.hide()</b>; */ hide : function() { this.setStyle( 'display', 'none' ); }, moveChildren : function( target, toStart ) { var $ = this.$; target = target.$; if ( $ == target ) return; var child; if ( toStart ) { while ( ( child = $.lastChild ) ) target.insertBefore( $.removeChild( child ), target.firstChild ); } else { while ( ( child = $.firstChild ) ) target.appendChild( $.removeChild( child ) ); } }, mergeSiblings : ( function() { function mergeElements( element, sibling, isNext ) { if ( sibling && sibling.type == CKEDITOR.NODE_ELEMENT ) { // Jumping over bookmark nodes and empty inline elements, e.g. <b><i></i></b>, // queuing them to be moved later. (#5567) var pendingNodes = []; while ( sibling.data( 'cke-bookmark' ) || sibling.isEmptyInlineRemoveable() ) { pendingNodes.push( sibling ); sibling = isNext ? sibling.getNext() : sibling.getPrevious(); if ( !sibling || sibling.type != CKEDITOR.NODE_ELEMENT ) return; } if ( element.isIdentical( sibling ) ) { // Save the last child to be checked too, to merge things like // <b><i></i></b><b><i></i></b> => <b><i></i></b> var innerSibling = isNext ? element.getLast() : element.getFirst(); // Move pending nodes first into the target element. while( pendingNodes.length ) pendingNodes.shift().move( element, !isNext ); sibling.moveChildren( element, !isNext ); sibling.remove(); // Now check the last inner child (see two comments above). if ( innerSibling && innerSibling.type == CKEDITOR.NODE_ELEMENT ) innerSibling.mergeSiblings(); } } } return function() { // Merge empty links and anchors also. (#5567) if ( !( CKEDITOR.dtd.$removeEmpty[ this.getName() ] || this.is( 'a' ) ) ) return; mergeElements( this, this.getNext(), true ); mergeElements( this, this.getPrevious() ); }; } )(), /** * Shows this element (display it). * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.show()</b>; */ show : function() { this.setStyles( { display : '', visibility : '' }); }, /** * Sets the value of an element attribute. * @param {String} name The name of the attribute. * @param {String} value The value to be set to the attribute. * @function * @returns {CKEDITOR.dom.element} This element instance. * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.setAttribute( 'class', 'myClass' )</b>; * <b>element.setAttribute( 'title', 'This is an example' )</b>; */ setAttribute : (function() { var standard = function( name, value ) { this.$.setAttribute( name, value ); return this; }; if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ) { return function( name, value ) { if ( name == 'class' ) this.$.className = value; else if ( name == 'style' ) this.$.style.cssText = value; else if ( name == 'tabindex' ) // Case sensitive. this.$.tabIndex = value; else if ( name == 'checked' ) this.$.checked = value; else standard.apply( this, arguments ); return this; }; } else return standard; })(), /** * Sets the value of several element attributes. * @param {Object} attributesPairs An object containing the names and * values of the attributes. * @returns {CKEDITOR.dom.element} This element instance. * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.setAttributes({ * 'class' : 'myClass', * 'title' : 'This is an example' })</b>; */ setAttributes : function( attributesPairs ) { for ( var name in attributesPairs ) this.setAttribute( name, attributesPairs[ name ] ); return this; }, /** * Sets the element value. This function is usually used with form * field element. * @param {String} value The element value. * @returns {CKEDITOR.dom.element} This element instance. */ setValue : function( value ) { this.$.value = value; return this; }, /** * Removes an attribute from the element. * @param {String} name The attribute name. * @function * @example * var element = CKEDITOR.dom.element.createFromHtml( '<div class="classA"></div>' ); * element.removeAttribute( 'class' ); */ removeAttribute : (function() { var standard = function( name ) { this.$.removeAttribute( name ); }; if ( CKEDITOR.env.ie && ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) ) { return function( name ) { if ( name == 'class' ) name = 'className'; else if ( name == 'tabindex' ) name = 'tabIndex'; standard.call( this, name ); }; } else return standard; })(), removeAttributes : function ( attributes ) { if ( CKEDITOR.tools.isArray( attributes ) ) { for ( var i = 0 ; i < attributes.length ; i++ ) this.removeAttribute( attributes[ i ] ); } else { for ( var attr in attributes ) attributes.hasOwnProperty( attr ) && this.removeAttribute( attr ); } }, /** * Removes a style from the element. * @param {String} name The style name. * @function * @example * var element = CKEDITOR.dom.element.createFromHtml( '<div style="display:none"></div>' ); * element.removeStyle( 'display' ); */ removeStyle : function( name ) { this.setStyle( name, '' ); if ( this.$.style.removeAttribute ) this.$.style.removeAttribute( CKEDITOR.tools.cssStyleToDomStyle( name ) ); if ( !this.$.style.cssText ) this.removeAttribute( 'style' ); }, /** * Sets the value of an element style. * @param {String} name The name of the style. The CSS naming notation * must be used (e.g. "background-color"). * @param {String} value The value to be set to the style. * @returns {CKEDITOR.dom.element} This element instance. * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.setStyle( 'background-color', '#ff0000' )</b>; * <b>element.setStyle( 'margin-top', '10px' )</b>; * <b>element.setStyle( 'float', 'right' )</b>; */ setStyle : function( name, value ) { this.$.style[ CKEDITOR.tools.cssStyleToDomStyle( name ) ] = value; return this; }, /** * Sets the value of several element styles. * @param {Object} stylesPairs An object containing the names and * values of the styles. * @returns {CKEDITOR.dom.element} This element instance. * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.setStyles({ * 'position' : 'absolute', * 'float' : 'right' })</b>; */ setStyles : function( stylesPairs ) { for ( var name in stylesPairs ) this.setStyle( name, stylesPairs[ name ] ); return this; }, /** * Sets the opacity of an element. * @param {Number} opacity A number within the range [0.0, 1.0]. * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * <b>element.setOpacity( 0.75 )</b>; */ setOpacity : function( opacity ) { if ( CKEDITOR.env.ie ) { opacity = Math.round( opacity * 100 ); this.setStyle( 'filter', opacity >= 100 ? '' : 'progid:DXImageTransform.Microsoft.Alpha(opacity=' + opacity + ')' ); } else this.setStyle( 'opacity', opacity ); }, /** * Makes the element and its children unselectable. * @function * @example * var element = CKEDITOR.dom.element.getById( 'myElement' ); * element.unselectable(); */ unselectable : CKEDITOR.env.gecko ? function() { this.$.style.MozUserSelect = 'none'; this.on( 'dragstart', function( evt ) { evt.data.preventDefault(); } ); } : CKEDITOR.env.webkit ? function() { this.$.style.KhtmlUserSelect = 'none'; this.on( 'dragstart', function( evt ) { evt.data.preventDefault(); } ); } : function() { if ( CKEDITOR.env.ie || CKEDITOR.env.opera ) { var element = this.$, e, i = 0; element.unselectable = 'on'; while ( ( e = element.all[ i++ ] ) ) { switch ( e.tagName.toLowerCase() ) { case 'iframe' : case 'textarea' : case 'input' : case 'select' : /* Ignore the above tags */ break; default : e.unselectable = 'on'; } } } }, getPositionedAncestor : function() { var current = this; while ( current.getName() != 'html' ) { if ( current.getComputedStyle( 'position' ) != 'static' ) return current; current = current.getParent(); } return null; }, getDocumentPosition : function( refDocument ) { var x = 0, y = 0, body = this.getDocument().getBody(), quirks = this.getDocument().$.compatMode == 'BackCompat'; var doc = this.getDocument(); if ( document.documentElement[ "getBoundingClientRect" ] ) { var box = this.$.getBoundingClientRect(), $doc = doc.$, $docElem = $doc.documentElement; var clientTop = $docElem.clientTop || body.$.clientTop || 0, clientLeft = $docElem.clientLeft || body.$.clientLeft || 0, needAdjustScrollAndBorders = true; /* * #3804: getBoundingClientRect() works differently on IE and non-IE * browsers, regarding scroll positions. * * On IE, the top position of the <html> element is always 0, no matter * how much you scrolled down. * * On other browsers, the top position of the <html> element is negative * scrollTop. */ if ( CKEDITOR.env.ie ) { var inDocElem = doc.getDocumentElement().contains( this ), inBody = doc.getBody().contains( this ); needAdjustScrollAndBorders = ( quirks && inBody ) || ( !quirks && inDocElem ); } if ( needAdjustScrollAndBorders ) { x = box.left + ( !quirks && $docElem.scrollLeft || body.$.scrollLeft ); x -= clientLeft; y = box.top + ( !quirks && $docElem.scrollTop || body.$.scrollTop ); y -= clientTop; } } else { var current = this, previous = null, offsetParent; while ( current && !( current.getName() == 'body' || current.getName() == 'html' ) ) { x += current.$.offsetLeft - current.$.scrollLeft; y += current.$.offsetTop - current.$.scrollTop; // Opera includes clientTop|Left into offsetTop|Left. if ( !current.equals( this ) ) { x += ( current.$.clientLeft || 0 ); y += ( current.$.clientTop || 0 ); } var scrollElement = previous; while ( scrollElement && !scrollElement.equals( current ) ) { x -= scrollElement.$.scrollLeft; y -= scrollElement.$.scrollTop; scrollElement = scrollElement.getParent(); } previous = current; current = ( offsetParent = current.$.offsetParent ) ? new CKEDITOR.dom.element( offsetParent ) : null; } } if ( refDocument ) { var currentWindow = this.getWindow(), refWindow = refDocument.getWindow(); if ( !currentWindow.equals( refWindow ) && currentWindow.$.frameElement ) { var iframePosition = ( new CKEDITOR.dom.element( currentWindow.$.frameElement ) ).getDocumentPosition( refDocument ); x += iframePosition.x; y += iframePosition.y; } } if ( !document.documentElement[ "getBoundingClientRect" ] ) { // In Firefox, we'll endup one pixel before the element positions, // so we must add it here. if ( CKEDITOR.env.gecko && !quirks ) { x += this.$.clientLeft ? 1 : 0; y += this.$.clientTop ? 1 : 0; } } return { x : x, y : y }; }, scrollIntoView : function( alignTop ) { // Get the element window. var win = this.getWindow(), winHeight = win.getViewPaneSize().height; // Starts from the offset that will be scrolled with the negative value of // the visible window height. var offset = winHeight * -1; // Append the view pane's height if align to top. // Append element height if we are aligning to the bottom. if ( alignTop ) offset += winHeight; else { offset += this.$.offsetHeight || 0; // Consider the margin in the scroll, which is ok for our current needs, but // needs investigation if we will be using this function in other places. offset += parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0; } // Append the offsets for the entire element hierarchy. var elementPosition = this.getDocumentPosition(); offset += elementPosition.y; // offset value might be out of range(nagative), fix it(#3692). offset = offset < 0 ? 0 : offset; // Scroll the window to the desired position, if not already visible(#3795). var currentScroll = win.getScrollPosition().y; if ( offset > currentScroll || offset < currentScroll - winHeight ) win.$.scrollTo( 0, offset ); }, setState : function( state ) { switch ( state ) { case CKEDITOR.TRISTATE_ON : this.addClass( 'cke_on' ); this.removeClass( 'cke_off' ); this.removeClass( 'cke_disabled' ); break; case CKEDITOR.TRISTATE_DISABLED : this.addClass( 'cke_disabled' ); this.removeClass( 'cke_off' ); this.removeClass( 'cke_on' ); break; default : this.addClass( 'cke_off' ); this.removeClass( 'cke_on' ); this.removeClass( 'cke_disabled' ); break; } }, /** * Returns the inner document of this IFRAME element. * @returns {CKEDITOR.dom.document} The inner document. */ getFrameDocument : function() { var $ = this.$; try { // In IE, with custom document.domain, it may happen that // the iframe is not yet available, resulting in "Access // Denied" for the following property access. $.contentWindow.document; } catch ( e ) { // Trick to solve this issue, forcing the iframe to get ready // by simply setting its "src" property. $.src = $.src; // In IE6 though, the above is not enough, so we must pause the // execution for a while, giving it time to think. if ( CKEDITOR.env.ie && CKEDITOR.env.version < 7 ) { window.showModalDialog( 'javascript:document.write("' + '<script>' + 'window.setTimeout(' + 'function(){window.close();}' + ',50);' + '</script>")' ); } } return $ && new CKEDITOR.dom.document( $.contentWindow.document ); }, /** * Copy all the attributes from one node to the other, kinda like a clone * skipAttributes is an object with the attributes that must NOT be copied. * @param {CKEDITOR.dom.element} dest The destination element. * @param {Object} skipAttributes A dictionary of attributes to skip. * @example */ copyAttributes : function( dest, skipAttributes ) { var attributes = this.$.attributes; skipAttributes = skipAttributes || {}; for ( var n = 0 ; n < attributes.length ; n++ ) { var attribute = attributes[n]; // Lowercase attribute name hard rule is broken for // some attribute on IE, e.g. CHECKED. var attrName = attribute.nodeName.toLowerCase(), attrValue; // We can set the type only once, so do it with the proper value, not copying it. if ( attrName in skipAttributes ) continue; if ( attrName == 'checked' && ( attrValue = this.getAttribute( attrName ) ) ) dest.setAttribute( attrName, attrValue ); // IE BUG: value attribute is never specified even if it exists. else if ( attribute.specified || ( CKEDITOR.env.ie && attribute.nodeValue && attrName == 'value' ) ) { attrValue = this.getAttribute( attrName ); if ( attrValue === null ) attrValue = attribute.nodeValue; dest.setAttribute( attrName, attrValue ); } } // The style: if ( this.$.style.cssText !== '' ) dest.$.style.cssText = this.$.style.cssText; }, /** * Changes the tag name of the current element. * @param {String} newTag The new tag for the element. */ renameNode : function( newTag ) { // If it's already correct exit here. if ( this.getName() == newTag ) return; var doc = this.getDocument(); // Create the new node. var newNode = new CKEDITOR.dom.element( newTag, doc ); // Copy all attributes. this.copyAttributes( newNode ); // Move children to the new node. this.moveChildren( newNode ); // Replace the node. this.getParent() && this.$.parentNode.replaceChild( newNode.$, this.$ ); newNode.$[ 'data-cke-expando' ] = this.$[ 'data-cke-expando' ]; this.$ = newNode.$; }, /** * Gets a DOM tree descendant under the current node. * @param {Array|Number} indices The child index or array of child indices under the node. * @returns {CKEDITOR.dom.node} The specified DOM child under the current node. Null if child does not exist. * @example * var strong = p.getChild(0); */ getChild : function( indices ) { var rawNode = this.$; if ( !indices.slice ) rawNode = rawNode.childNodes[ indices ]; else { while ( indices.length > 0 && rawNode ) rawNode = rawNode.childNodes[ indices.shift() ]; } return rawNode ? new CKEDITOR.dom.node( rawNode ) : null; }, getChildCount : function() { return this.$.childNodes.length; }, disableContextMenu : function() { this.on( 'contextmenu', function( event ) { // Cancel the browser context menu. if ( !event.data.getTarget().hasClass( 'cke_enable_context_menu' ) ) event.data.preventDefault(); } ); }, /** * Gets element's direction. Supports both CSS 'direction' prop and 'dir' attr. */ getDirection : function( useComputed ) { return useComputed ? this.getComputedStyle( 'direction' ) : this.getStyle( 'direction' ) || this.getAttribute( 'dir' ); }, /** * Gets, sets and removes custom data to be stored as HTML5 data-* attributes. * @name CKEDITOR.dom.element.data * @param {String} name The name of the attribute, execluding the 'data-' part. * @param {String} [value] The value to set. If set to false, the attribute will be removed. */ data : function ( name, value ) { name = 'data-' + name; if ( value === undefined ) return this.getAttribute( name ); else if ( value === false ) this.removeAttribute( name ); else this.setAttribute( name, value ); } }); ( function() { var sides = { width : [ "border-left-width", "border-right-width","padding-left", "padding-right" ], height : [ "border-top-width", "border-bottom-width", "padding-top", "padding-bottom" ] }; function marginAndPaddingSize( type ) { var adjustment = 0; for ( var i = 0, len = sides[ type ].length; i < len; i++ ) adjustment += parseInt( this.getComputedStyle( sides [ type ][ i ] ) || 0, 10 ) || 0; return adjustment; } /** * Update the element's size with box model awareness. * @name CKEDITOR.dom.element.setSize * @param {String} type [width|height] * @param {Number} size The length unit in px. * @param isBorderBox Apply the {@param width} and {@param height} based on border box model. */ CKEDITOR.dom.element.prototype.setSize = function( type, size, isBorderBox ) { if ( typeof size == 'number' ) { if ( isBorderBox && !( CKEDITOR.env.ie && CKEDITOR.env.quirks ) ) size -= marginAndPaddingSize.call( this, type ); this.setStyle( type, size + 'px' ); } }; /** * Get the element's size, possibly with box model awareness. * @name CKEDITOR.dom.element.getSize * @param {String} type [width|height] * @param {Boolean} contentSize Get the {@param width} or {@param height} based on border box model. */ CKEDITOR.dom.element.prototype.getSize = function( type, contentSize ) { var size = Math.max( this.$[ 'offset' + CKEDITOR.tools.capitalize( type ) ], this.$[ 'client' + CKEDITOR.tools.capitalize( type ) ] ) || 0; if ( contentSize ) size -= marginAndPaddingSize.call( this, type ); return size; }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the "virtual" {@link CKEDITOR.dataProcessor} class, which * defines the basic structure of data processor objects to be * set to {@link CKEDITOR.editor.dataProcessor}. */ /** * If defined, points to the data processor which is responsible to translate * and transform the editor data on input and output. * Generaly it will point to an instance of {@link CKEDITOR.htmlDataProcessor}, * which handles HTML data. The editor may also handle other data formats by * using different data processors provided by specific plugins. * @name CKEDITOR.editor.prototype.dataProcessor * @type CKEDITOR.dataProcessor */ /** * This class is here for documentation purposes only and is not really part of * the API. It serves as the base ("interface") for data processors * implementation. * @name CKEDITOR.dataProcessor * @class Represents a data processor, which is responsible to translate and * transform the editor data on input and output. * @example */ /** * Transforms input data into HTML to be loaded in the editor. * While the editor is able to handle non HTML data (like BBCode), at runtime * it can handle HTML data only. The role of the data processor is transforming * the input data into HTML through this function. * @name CKEDITOR.dataProcessor.prototype.toHtml * @function * @param {String} data The input data to be transformed. * @param {String} [fixForBody] The tag name to be used if the data must be * fixed because it is supposed to be loaded direcly into the &lt;body&gt; * tag. This is generally not used by non-HTML data processors. * @example * // Tranforming BBCode data, having a custom BBCode data processor. * var data = 'This is [b]an example[/b].'; * var html = editor.dataProcessor.toHtml( data ); // '&lt;p&gt;This is &lt;b&gt;an example&lt;/b&gt;.&lt;/p&gt;' */ /** * Transforms HTML into data to be outputted by the editor, in the format * expected by the data processor. * While the editor is able to handle non HTML data (like BBCode), at runtime * it can handle HTML data only. The role of the data processor is transforming * the HTML data containined by the editor into a specific data format through * this function. * @name CKEDITOR.dataProcessor.prototype.toDataFormat * @function * @param {String} html The HTML to be transformed. * @param {String} fixForBody The tag name to be used if the output data is * coming from &lt;body&gt; and may be eventually fixed for it. This is * generally not used by non-HTML data processors. * // Tranforming into BBCode data, having a custom BBCode data processor. * var html = '&lt;p&gt;This is &lt;b&gt;an example&lt;/b&gt;.&lt;/p&gt;'; * var data = editor.dataProcessor.toDataFormat( html ); // 'This is [b]an example[/b].' */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the "virtual" {@link CKEDITOR.eventInfo} class, which * contains the defintions of the event object passed to event listeners. * This file is for documentation purposes only. */ /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. * @class Virtual class that illustrates the features of the event object to be * passed to event listeners by a {@link CKEDITOR.event} based object. * @name CKEDITOR.eventInfo * @example * // Do not do this. * var myEvent = new CKEDITOR.eventInfo(); // Error: CKEDITOR.eventInfo is undefined */ /** * The event name. * @name CKEDITOR.eventInfo.prototype.name * @field * @type String * @example * someObject.on( 'someEvent', function( event ) * { * alert( <b>event.name</b> ); // "someEvent" * }); * someObject.fire( 'someEvent' ); */ /** * The object that publishes (sends) the event. * @name CKEDITOR.eventInfo.prototype.sender * @field * @type Object * @example * someObject.on( 'someEvent', function( event ) * { * alert( <b>event.sender</b> == someObject ); // "true" * }); * someObject.fire( 'someEvent' ); */ /** * The editor instance that holds the sender. May be the same as sender. May be * null if the sender is not part of an editor instance, like a component * running in standalone mode. * @name CKEDITOR.eventInfo.prototype.editor * @field * @type CKEDITOR.editor * @example * myButton.on( 'someEvent', function( event ) * { * alert( <b>event.editor</b> == myEditor ); // "true" * }); * myButton.fire( 'someEvent', null, <b>myEditor</b> ); */ /** * Any kind of additional data. Its format and usage is event dependent. * @name CKEDITOR.eventInfo.prototype.data * @field * @type Object * @example * someObject.on( 'someEvent', function( event ) * { * alert( <b>event.data</b> ); // "Example" * }); * someObject.fire( 'someEvent', <b>'Example'</b> ); */ /** * Any extra data appended during the listener registration. * @name CKEDITOR.eventInfo.prototype.listenerData * @field * @type Object * @example * someObject.on( 'someEvent', function( event ) * { * alert( <b>event.listenerData</b> ); // "Example" * } * , null, <b>'Example'</b> ); */ /** * Indicates that no further listeners are to be called. * @name CKEDITOR.eventInfo.prototype.stop * @function * @example * someObject.on( 'someEvent', function( event ) * { * <b>event.stop()</b>; * }); * someObject.on( 'someEvent', function( event ) * { * // This one will not be called. * }); * alert( someObject.fire( 'someEvent' ) ); // "false" */ /** * Indicates that the event is to be cancelled (if cancelable). * @name CKEDITOR.eventInfo.prototype.cancel * @function * @example * someObject.on( 'someEvent', function( event ) * { * <b>event.cancel()</b>; * }); * someObject.on( 'someEvent', function( event ) * { * // This one will not be called. * }); * alert( someObject.fire( 'someEvent' ) ); // "true" */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the "virtual" {@link CKEDITOR.pluginDefinition} class, which * contains the defintion of a plugin. This file is for documentation * purposes only. */ /** * (Virtual Class) Do not call this constructor. This class is not really part * of the API. It just illustrates the features of plugin objects to be * passed to the {@link CKEDITOR.plugins.add} function. * @name CKEDITOR.pluginDefinition * @constructor * @example */ /** * A list of plugins that are required by this plugin. Note that this property * doesn't guarantee the loading order of the plugins. * @name CKEDITOR.pluginDefinition.prototype.requires * @type Array * @example * CKEDITOR.plugins.add( 'sample', * { * requires : [ 'button', 'selection' ] * }); */ /** * Function called on initialization of every editor instance created in the * page before the init() call task. The beforeInit function will be called for * all plugins, after that the init function is called for all of them. This * feature makes it possible to initialize things that could be used in the * init function of other plugins. * @name CKEDITOR.pluginDefinition.prototype.beforeInit * @function * @param {CKEDITOR.editor} editor The editor instance being initialized. * @example * CKEDITOR.plugins.add( 'sample', * { * beforeInit : function( editor ) * { * alert( 'Editor "' + editor.name + '" is to be initialized!' ); * } * }); */ /** * Function called on initialization of every editor instance created in the * page. * @name CKEDITOR.pluginDefinition.prototype.init * @function * @param {CKEDITOR.editor} editor The editor instance being initialized. * @example * CKEDITOR.plugins.add( 'sample', * { * init : function( editor ) * { * alert( 'Editor "' + editor.name + '" is being initialized!' ); * } * }); */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview API initialization code. */ (function() { // Disable HC detaction in WebKit. (#5429) if ( CKEDITOR.env.webkit ) { CKEDITOR.env.hc = false; return; } // Check is High Contrast is active by creating a temporary element with a // background image. var useSpacer = CKEDITOR.env.ie && CKEDITOR.env.version < 7, useBlank = CKEDITOR.env.ie && CKEDITOR.env.version == 7; var backgroundImageUrl = useSpacer ? ( CKEDITOR.basePath + 'images/spacer.gif' ) : useBlank ? 'about:blank' : 'data:image/png;base64,'; var hcDetect = CKEDITOR.dom.element.createFromHtml( '<div style="width:0px;height:0px;' + 'position:absolute;left:-10000px;' + 'background-image:url(' + backgroundImageUrl + ')"></div>', CKEDITOR.document ); hcDetect.appendTo( CKEDITOR.document.getHead() ); // Update CKEDITOR.env. // Catch exception needed sometimes for FF. (#4230) try { CKEDITOR.env.hc = ( hcDetect.getComputedStyle( 'background-image' ) == 'none' ); } catch (e) { CKEDITOR.env.hc = false; } if ( CKEDITOR.env.hc ) CKEDITOR.env.cssClass += ' cke_hc'; hcDetect.remove(); })(); // Load core plugins. CKEDITOR.plugins.load( CKEDITOR.config.corePlugins.split( ',' ), function() { CKEDITOR.status = 'loaded'; CKEDITOR.fire( 'loaded' ); // Process all instances created by the "basic" implementation. var pending = CKEDITOR._.pending; if ( pending ) { delete CKEDITOR._.pending; for ( var i = 0 ; i < pending.length ; i++ ) CKEDITOR.add( pending[ i ] ); } }); // Needed for IE6 to not request image (HTTP 200 or 304) for every CSS background. (#6187) if ( CKEDITOR.env.ie ) { // Remove IE mouse flickering on IE6 because of background images. try { document.execCommand( 'BackgroundImageCache', false, true ); } catch (e) { // We have been reported about loading problems caused by the above // line. For safety, let's just ignore errors. } } /** * Indicates that CKEditor is running on a High Contrast environment. * @name CKEDITOR.env.hc * @example * if ( CKEDITOR.env.hc ) * alert( 'You're running on High Contrast mode. The editor interface will get adapted to provide you a better experience.' ); */ /** * Fired when a CKEDITOR core object is fully loaded and ready for interaction. * @name CKEDITOR#loaded * @event */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.ajax} object, which holds ajax methods for * data loading. */ /** * @namespace Ajax methods for data loading. * @example */ CKEDITOR.ajax = (function() { var createXMLHttpRequest = function() { // In IE, using the native XMLHttpRequest for local files may throw // "Access is Denied" errors. if ( !CKEDITOR.env.ie || location.protocol != 'file:' ) try { return new XMLHttpRequest(); } catch(e) {} try { return new ActiveXObject( 'Msxml2.XMLHTTP' ); } catch (e) {} try { return new ActiveXObject( 'Microsoft.XMLHTTP' ); } catch (e) {} return null; }; var checkStatus = function( xhr ) { // HTTP Status Codes: // 2xx : Success // 304 : Not Modified // 0 : Returned when running locally (file://) // 1223 : IE may change 204 to 1223 (see http://dev.jquery.com/ticket/1450) return ( xhr.readyState == 4 && ( ( xhr.status >= 200 && xhr.status < 300 ) || xhr.status == 304 || xhr.status === 0 || xhr.status == 1223 ) ); }; var getResponseText = function( xhr ) { if ( checkStatus( xhr ) ) return xhr.responseText; return null; }; var getResponseXml = function( xhr ) { if ( checkStatus( xhr ) ) { var xml = xhr.responseXML; return new CKEDITOR.xml( xml && xml.firstChild ? xml : xhr.responseText ); } return null; }; var load = function( url, callback, getResponseFn ) { var async = !!callback; var xhr = createXMLHttpRequest(); if ( !xhr ) return null; xhr.open( 'GET', url, async ); if ( async ) { // TODO: perform leak checks on this closure. /** @ignore */ xhr.onreadystatechange = function() { if ( xhr.readyState == 4 ) { callback( getResponseFn( xhr ) ); xhr = null; } }; } xhr.send(null); return async ? '' : getResponseFn( xhr ); }; return /** @lends CKEDITOR.ajax */ { /** * Loads data from an URL as plain text. * @param {String} url The URL from which load data. * @param {Function} [callback] A callback function to be called on * data load. If not provided, the data will be loaded * asynchronously, passing the data value the function on load. * @returns {String} The loaded data. For asynchronous requests, an * empty string. For invalid requests, null. * @example * // Load data synchronously. * var data = CKEDITOR.ajax.load( 'somedata.txt' ); * alert( data ); * @example * // Load data asynchronously. * var data = CKEDITOR.ajax.load( 'somedata.txt', function( data ) * { * alert( data ); * } ); */ load : function( url, callback ) { return load( url, callback, getResponseText ); }, /** * Loads data from an URL as XML. * @param {String} url The URL from which load data. * @param {Function} [callback] A callback function to be called on * data load. If not provided, the data will be loaded * asynchronously, passing the data value the function on load. * @returns {CKEDITOR.xml} An XML object holding the loaded data. For asynchronous requests, an * empty string. For invalid requests, null. * @example * // Load XML synchronously. * var xml = CKEDITOR.ajax.loadXml( 'somedata.xml' ); * alert( xml.getInnerXml( '//' ) ); * @example * // Load XML asynchronously. * var data = CKEDITOR.ajax.loadXml( 'somedata.xml', function( xml ) * { * alert( xml.getInnerXml( '//' ) ); * } ); */ loadXml : function( url, callback ) { return load( url, callback, getResponseXml ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Contains the first and essential part of the {@link CKEDITOR} * object definition. */ // #### Compressed Code // Must be updated on changes in the script, as well as updated in the // ckeditor_source.js and ckeditor_basic_source.js files. // if(!window.CKEDITOR)window.CKEDITOR=(function(){var a={timestamp:'',version:'3.5',rev:'6230',_:{},status:'unloaded',basePath:(function(){var d=window.CKEDITOR_BASEPATH||'';if(!d){var e=document.getElementsByTagName('script');for(var f=0;f<e.length;f++){var g=e[f].src.match(/(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i);if(g){d=g[1];break;}}}if(d.indexOf(':/')==-1)if(d.indexOf('/')===0)d=location.href.match(/^.*?:\/\/[^\/]*/)[0]+d;else d=location.href.match(/^[^\?]*\/(?:)/)[0]+d;return d;})(),getUrl:function(d){if(d.indexOf(':/')==-1&&d.indexOf('/')!==0)d=this.basePath+d;if(this.timestamp&&d.charAt(d.length-1)!='/')d+=(d.indexOf('?')>=0?'&':'?')+('t=')+this.timestamp;return d;}},b=window.CKEDITOR_GETURL;if(b){var c=a.getUrl;a.getUrl=function(d){return b.call(a,d)||c.call(a,d);};}return a;})(); // #### Raw code // ATTENTION: read the above "Compressed Code" notes when changing this code. if ( !window.CKEDITOR ) { /** * @name CKEDITOR * @namespace This is the API entry point. The entire CKEditor code runs under this object. * @example */ window.CKEDITOR = (function() { var CKEDITOR = /** @lends CKEDITOR */ { /** * A constant string unique for each release of CKEditor. Its value * is used, by default, to build the URL for all resources loaded * by the editor code, guaranteing clean cache results when * upgrading. * @type String * @example * alert( CKEDITOR.timestamp ); // e.g. '87dm' */ // The production implementation contains a fixed timestamp, unique // for each release, generated by the releaser. // (Base 36 value of each component of YYMMDDHH - 4 chars total - e.g. 87bm == 08071122) timestamp : 'ABH04T2', /** * Contains the CKEditor version number. * @type String * @example * alert( CKEDITOR.version ); // e.g. 'CKEditor 3.4.1' */ version : '3.5', /** * Contains the CKEditor revision number. * The revision number is incremented automatically, following each * modification to the CKEditor source code. * @type String * @example * alert( CKEDITOR.revision ); // e.g. '3975' */ revision : '6230', /** * Private object used to hold core stuff. It should not be used out of * the API code as properties defined here may change at any time * without notice. * @private */ _ : {}, /** * Indicates the API loading status. The following status are available: * <ul> * <li><b>unloaded</b>: the API is not yet loaded.</li> * <li><b>basic_loaded</b>: the basic API features are available.</li> * <li><b>basic_ready</b>: the basic API is ready to load the full core code.</li> * <li><b>loading</b>: the full API is being loaded.</li> * <li><b>ready</b>: the API can be fully used.</li> * </ul> * @type String * @example * if ( <b>CKEDITOR.status</b> == 'ready' ) * { * // The API can now be fully used. * } */ status : 'unloaded', /** * Contains the full URL for the CKEditor installation directory. * It's possible to manually provide the base path by setting a * global variable named CKEDITOR_BASEPATH. This global variable * must be set "before" the editor script loading. * @type String * @example * alert( <b>CKEDITOR.basePath</b> ); // "http://www.example.com/ckeditor/" (e.g.) */ basePath : (function() { // ATTENTION: fixes on this code must be ported to // var basePath in "core/loader.js". // Find out the editor directory path, based on its <script> tag. var path = window.CKEDITOR_BASEPATH || ''; if ( !path ) { var scripts = document.getElementsByTagName( 'script' ); for ( var i = 0 ; i < scripts.length ; i++ ) { var match = scripts[i].src.match( /(^|.*[\\\/])ckeditor(?:_basic)?(?:_source)?.js(?:\?.*)?$/i ); if ( match ) { path = match[1]; break; } } } // In IE (only) the script.src string is the raw valued entered in the // HTML. Other browsers return the full resolved URL instead. if ( path.indexOf(':/') == -1 ) { // Absolute path. if ( path.indexOf( '/' ) === 0 ) path = location.href.match( /^.*?:\/\/[^\/]*/ )[0] + path; // Relative path. else path = location.href.match( /^[^\?]*\/(?:)/ )[0] + path; } if ( !path ) throw 'The CKEditor installation path could not be automatically detected. Please set the global variable "CKEDITOR_BASEPATH" before creating editor instances.'; return path; })(), /** * Gets the full URL for CKEditor resources. By default, URLs * returned by this function contains a querystring parameter ("t") * set to the {@link CKEDITOR.timestamp} value.<br /> * <br /> * It's possible to provide a custom implementation to this * function by setting a global variable named CKEDITOR_GETURL. * This global variable must be set "before" the editor script * loading. If the custom implementation returns nothing (==null), the * default implementation is used. * @param {String} resource The resource to which get the full URL. * It may be a full, absolute or relative URL. * @returns {String} The full URL. * @example * // e.g. http://www.example.com/ckeditor/skins/default/editor.css?t=87dm * alert( CKEDITOR.getUrl( 'skins/default/editor.css' ) ); * @example * // e.g. http://www.example.com/skins/default/editor.css?t=87dm * alert( CKEDITOR.getUrl( '/skins/default/editor.css' ) ); * @example * // e.g. http://www.somesite.com/skins/default/editor.css?t=87dm * alert( CKEDITOR.getUrl( 'http://www.somesite.com/skins/default/editor.css' ) ); */ getUrl : function( resource ) { // If this is not a full or absolute path. if ( resource.indexOf(':/') == -1 && resource.indexOf( '/' ) !== 0 ) resource = this.basePath + resource; // Add the timestamp, except for directories. if ( this.timestamp && resource.charAt( resource.length - 1 ) != '/' && !(/[&?]t=/).test( resource ) ) resource += ( resource.indexOf( '?' ) >= 0 ? '&' : '?' ) + 't=' + this.timestamp; return resource; } }; // Make it possible to override the getUrl function with a custom // implementation pointing to a global named CKEDITOR_GETURL. var newGetUrl = window.CKEDITOR_GETURL; if ( newGetUrl ) { var originalGetUrl = CKEDITOR.getUrl; CKEDITOR.getUrl = function ( resource ) { return newGetUrl.call( CKEDITOR, resource ) || originalGetUrl.call( CKEDITOR, resource ); }; } return CKEDITOR; })(); } // PACKAGER_RENAME( CKEDITOR )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { /** * A lightweight representation of HTML text. * @constructor * @example */ CKEDITOR.htmlParser.cdata = function( value ) { /** * The CDATA value. * @type String * @example */ this.value = value; }; CKEDITOR.htmlParser.cdata.prototype = { /** * CDATA has the same type as {@link CKEDITOR.htmlParser.text} This is * a constant value set to {@link CKEDITOR.NODE_TEXT}. * @type Number * @example */ type : CKEDITOR.NODE_TEXT, /** * Writes write the CDATA with no special manipulations. * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. */ writeHtml : function( writer ) { writer.write( this.value ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { CKEDITOR.htmlParser.filter = CKEDITOR.tools.createClass( { $ : function( rules ) { this._ = { elementNames : [], attributeNames : [], elements : { $length : 0 }, attributes : { $length : 0 } }; if ( rules ) this.addRules( rules, 10 ); }, proto : { addRules : function( rules, priority ) { if ( typeof priority != 'number' ) priority = 10; // Add the elementNames. addItemsToList( this._.elementNames, rules.elementNames, priority ); // Add the attributeNames. addItemsToList( this._.attributeNames, rules.attributeNames, priority ); // Add the elements. addNamedItems( this._.elements, rules.elements, priority ); // Add the attributes. addNamedItems( this._.attributes, rules.attributes, priority ); // Add the text. this._.text = transformNamedItem( this._.text, rules.text, priority ) || this._.text; // Add the comment. this._.comment = transformNamedItem( this._.comment, rules.comment, priority ) || this._.comment; // Add root fragment. this._.root = transformNamedItem( this._.root, rules.root, priority ) || this._.root; }, onElementName : function( name ) { return filterName( name, this._.elementNames ); }, onAttributeName : function( name ) { return filterName( name, this._.attributeNames ); }, onText : function( text ) { var textFilter = this._.text; return textFilter ? textFilter.filter( text ) : text; }, onComment : function( commentText, comment ) { var textFilter = this._.comment; return textFilter ? textFilter.filter( commentText, comment ) : commentText; }, onFragment : function( element ) { var rootFilter = this._.root; return rootFilter ? rootFilter.filter( element ) : element; }, onElement : function( element ) { // We must apply filters set to the specific element name as // well as those set to the generic $ name. So, add both to an // array and process them in a small loop. var filters = [ this._.elements[ '^' ], this._.elements[ element.name ], this._.elements.$ ], filter, ret; for ( var i = 0 ; i < 3 ; i++ ) { filter = filters[ i ]; if ( filter ) { ret = filter.filter( element, this ); if ( ret === false ) return null; if ( ret && ret != element ) return this.onNode( ret ); // The non-root element has been dismissed by one of the filters. if ( element.parent && !element.name ) break; } } return element; }, onNode : function( node ) { var type = node.type; return type == CKEDITOR.NODE_ELEMENT ? this.onElement( node ) : type == CKEDITOR.NODE_TEXT ? new CKEDITOR.htmlParser.text( this.onText( node.value ) ) : type == CKEDITOR.NODE_COMMENT ? new CKEDITOR.htmlParser.comment( this.onComment( node.value ) ): null; }, onAttribute : function( element, name, value ) { var filter = this._.attributes[ name ]; if ( filter ) { var ret = filter.filter( value, element, this ); if ( ret === false ) return false; if ( typeof ret != 'undefined' ) return ret; } return value; } } }); function filterName( name, filters ) { for ( var i = 0 ; name && i < filters.length ; i++ ) { var filter = filters[ i ]; name = name.replace( filter[ 0 ], filter[ 1 ] ); } return name; } function addItemsToList( list, items, priority ) { if ( typeof items == 'function' ) items = [ items ]; var i, j, listLength = list.length, itemsLength = items && items.length; if ( itemsLength ) { // Find the index to insert the items at. for ( i = 0 ; i < listLength && list[ i ].pri < priority ; i++ ) { /*jsl:pass*/ } // Add all new items to the list at the specific index. for ( j = itemsLength - 1 ; j >= 0 ; j-- ) { var item = items[ j ]; if ( item ) { item.pri = priority; list.splice( i, 0, item ); } } } } function addNamedItems( hashTable, items, priority ) { if ( items ) { for ( var name in items ) { var current = hashTable[ name ]; hashTable[ name ] = transformNamedItem( current, items[ name ], priority ); if ( !current ) hashTable.$length++; } } } function transformNamedItem( current, item, priority ) { if ( item ) { item.pri = priority; if ( current ) { // If the current item is not an Array, transform it. if ( !current.splice ) { if ( current.pri > priority ) current = [ item, current ]; else current = [ current, item ]; current.filter = callItems; } else addItemsToList( current, item, priority ); return current; } else { item.filter = item; return item; } } } // Invoke filters sequentially on the array, break the iteration // when it doesn't make sense to continue anymore. function callItems( currentEntry ) { var isNode = currentEntry.type || currentEntry instanceof CKEDITOR.htmlParser.fragment; for ( var i = 0 ; i < this.length ; i++ ) { // Backup the node info before filtering. if ( isNode ) { var orgType = currentEntry.type, orgName = currentEntry.name; } var item = this[ i ], ret = item.apply( window, arguments ); if ( ret === false ) return ret; // We're filtering node (element/fragment). if ( isNode ) { // No further filtering if it's not anymore // fitable for the subsequent filters. if ( ret && ( ret.name != orgName || ret.type != orgType ) ) { return ret; } } // Filtering value (nodeName/textValue/attrValue). else { // No further filtering if it's not // any more values. if ( typeof ret != 'string' ) return ret; } ret != undefined && ( currentEntry = ret ); } return currentEntry; } })(); // "entities" plugin /* { text : function( text ) { // TODO : Process entities. return text.toUpperCase(); } }; */
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * A lightweight representation of an HTML comment. * @constructor * @example */ CKEDITOR.htmlParser.comment = function( value ) { /** * The comment text. * @type String * @example */ this.value = value; /** @private */ this._ = { isBlockLike : false }; }; CKEDITOR.htmlParser.comment.prototype = { /** * The node type. This is a constant value set to {@link CKEDITOR.NODE_COMMENT}. * @type Number * @example */ type : CKEDITOR.NODE_COMMENT, /** * Writes the HTML representation of this comment to a CKEDITOR.htmlWriter. * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. * @example */ writeHtml : function( writer, filter ) { var comment = this.value; if ( filter ) { if ( !( comment = filter.onComment( comment, this ) ) ) return; if ( typeof comment != 'string' ) { comment.parent = this.parent; comment.writeHtml( writer, filter ); return; } } writer.comment( comment ); } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { var spacesRegex = /[\t\r\n ]{2,}|[\t\r\n]/g; /** * A lightweight representation of HTML text. * @constructor * @example */ CKEDITOR.htmlParser.text = function( value ) { /** * The text value. * @type String * @example */ this.value = value; /** @private */ this._ = { isBlockLike : false }; }; CKEDITOR.htmlParser.text.prototype = { /** * The node type. This is a constant value set to {@link CKEDITOR.NODE_TEXT}. * @type Number * @example */ type : CKEDITOR.NODE_TEXT, /** * Writes the HTML representation of this text to a CKEDITOR.htmlWriter. * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. * @example */ writeHtml : function( writer, filter ) { var text = this.value; if ( filter && !( text = filter.onText( text, this ) ) ) return; writer.text( text ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ CKEDITOR.htmlParser.basicWriter = CKEDITOR.tools.createClass( { $ : function() { this._ = { output : [] }; }, proto : { /** * Writes the tag opening part for a opener tag. * @param {String} tagName The element name for this tag. * @param {Object} attributes The attributes defined for this tag. The * attributes could be used to inspect the tag. * @example * // Writes "&lt;p". * writer.openTag( 'p', { class : 'MyClass', id : 'MyId' } ); */ openTag : function( tagName, attributes ) { this._.output.push( '<', tagName ); }, /** * Writes the tag closing part for a opener tag. * @param {String} tagName The element name for this tag. * @param {Boolean} isSelfClose Indicates that this is a self-closing tag, * like "br" or "img". * @example * // Writes "&gt;". * writer.openTagClose( 'p', false ); * @example * // Writes " /&gt;". * writer.openTagClose( 'br', true ); */ openTagClose : function( tagName, isSelfClose ) { if ( isSelfClose ) this._.output.push( ' />' ); else this._.output.push( '>' ); }, /** * Writes an attribute. This function should be called after opening the * tag with {@link #openTagClose}. * @param {String} attName The attribute name. * @param {String} attValue The attribute value. * @example * // Writes ' class="MyClass"'. * writer.attribute( 'class', 'MyClass' ); */ attribute : function( attName, attValue ) { // Browsers don't always escape special character in attribute values. (#4683, #4719). if ( typeof attValue == 'string' ) attValue = CKEDITOR.tools.htmlEncodeAttr( attValue ); this._.output.push( ' ', attName, '="', attValue, '"' ); }, /** * Writes a closer tag. * @param {String} tagName The element name for this tag. * @example * // Writes "&lt;/p&gt;". * writer.closeTag( 'p' ); */ closeTag : function( tagName ) { this._.output.push( '</', tagName, '>' ); }, /** * Writes text. * @param {String} text The text value * @example * // Writes "Hello Word". * writer.text( 'Hello Word' ); */ text : function( text ) { this._.output.push( text ); }, /** * Writes a comment. * @param {String} comment The comment text. * @example * // Writes "&lt;!-- My comment --&gt;". * writer.comment( ' My comment ' ); */ comment : function( comment ) { this._.output.push( '<!--', comment, '-->' ); }, /** * Writes any kind of data to the ouput. * @example * writer.write( 'This is an &lt;b&gt;example&lt;/b&gt;.' ); */ write : function( data ) { this._.output.push( data ); }, /** * Empties the current output buffer. * @example * writer.reset(); */ reset : function() { this._.output = []; this._.indent = false; }, /** * Empties the current output buffer. * @param {Boolean} reset Indicates that the {@link reset} function is to * be automatically called after retrieving the HTML. * @returns {String} The HTML written to the writer so far. * @example * var html = writer.getHtml(); */ getHtml : function( reset ) { var html = this._.output.join( '' ); if ( reset ) this.reset(); return html; } } });
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * A lightweight representation of an HTML DOM structure. * @constructor * @example */ CKEDITOR.htmlParser.fragment = function() { /** * The nodes contained in the root of this fragment. * @type Array * @example * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<b>Sample</b> Text' ); * alert( fragment.children.length ); "2" */ this.children = []; /** * Get the fragment parent. Should always be null. * @type Object * @default null * @example */ this.parent = null; /** @private */ this._ = { isBlockLike : true, hasInlineStarted : false }; }; (function() { // Elements which the end tag is marked as optional in the HTML 4.01 DTD // (expect empty elements). var optionalClose = {colgroup:1,dd:1,dt:1,li:1,option:1,p:1,td:1,tfoot:1,th:1,thead:1,tr:1}; // Block-level elements whose internal structure should be respected during // parser fixing. var nonBreakingBlocks = CKEDITOR.tools.extend( {table:1,ul:1,ol:1,dl:1}, CKEDITOR.dtd.table, CKEDITOR.dtd.ul, CKEDITOR.dtd.ol, CKEDITOR.dtd.dl ), listBlocks = CKEDITOR.dtd.$list, listItems = CKEDITOR.dtd.$listItem; /** * Creates a {@link CKEDITOR.htmlParser.fragment} from an HTML string. * @param {String} fragmentHtml The HTML to be parsed, filling the fragment. * @param {Number} [fixForBody=false] Wrap body with specified element if needed. * @returns CKEDITOR.htmlParser.fragment The fragment created. * @example * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '<b>Sample</b> Text' ); * alert( fragment.children[0].name ); "b" * alert( fragment.children[1].value ); " Text" */ CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody ) { var parser = new CKEDITOR.htmlParser(), html = [], fragment = new CKEDITOR.htmlParser.fragment(), pendingInline = [], pendingBRs = [], currentNode = fragment, // Indicate we're inside a <pre> element, spaces should be touched differently. inPre = false, returnPoint; function checkPending( newTagName ) { var pendingBRsSent; if ( pendingInline.length > 0 ) { for ( var i = 0 ; i < pendingInline.length ; i++ ) { var pendingElement = pendingInline[ i ], pendingName = pendingElement.name, pendingDtd = CKEDITOR.dtd[ pendingName ], currentDtd = currentNode.name && CKEDITOR.dtd[ currentNode.name ]; if ( ( !currentDtd || currentDtd[ pendingName ] ) && ( !newTagName || !pendingDtd || pendingDtd[ newTagName ] || !CKEDITOR.dtd[ newTagName ] ) ) { if ( !pendingBRsSent ) { sendPendingBRs(); pendingBRsSent = 1; } // Get a clone for the pending element. pendingElement = pendingElement.clone(); // Add it to the current node and make it the current, // so the new element will be added inside of it. pendingElement.parent = currentNode; currentNode = pendingElement; // Remove the pending element (back the index by one // to properly process the next entry). pendingInline.splice( i, 1 ); i--; } } } } function sendPendingBRs( brsToIgnore ) { while ( pendingBRs.length - ( brsToIgnore || 0 ) > 0 ) currentNode.add( pendingBRs.shift() ); } function addElement( element, target, enforceCurrent ) { target = target || currentNode || fragment; // If the target is the fragment and this element can't go inside // body (if fixForBody). if ( fixForBody && !target.type ) { var elementName, realElementName; if ( element.attributes && ( realElementName = element.attributes[ 'data-cke-real-element-type' ] ) ) elementName = realElementName; else elementName = element.name; if ( elementName && !( elementName in CKEDITOR.dtd.$body ) && !( elementName in CKEDITOR.dtd.$nonBodyContent ) ) { var savedCurrent = currentNode; // Create a <p> in the fragment. currentNode = target; parser.onTagOpen( fixForBody, {} ); // The new target now is the <p>. target = currentNode; if ( enforceCurrent ) currentNode = savedCurrent; } } // Rtrim empty spaces on block end boundary. (#3585) if ( element._.isBlockLike && element.name != 'pre' ) { var length = element.children.length, lastChild = element.children[ length - 1 ], text; if ( lastChild && lastChild.type == CKEDITOR.NODE_TEXT ) { if ( !( text = CKEDITOR.tools.rtrim( lastChild.value ) ) ) element.children.length = length -1; else lastChild.value = text; } } target.add( element ); if ( element.returnPoint ) { currentNode = element.returnPoint; delete element.returnPoint; } } parser.onTagOpen = function( tagName, attributes, selfClosing ) { var element = new CKEDITOR.htmlParser.element( tagName, attributes ); // "isEmpty" will be always "false" for unknown elements, so we // must force it if the parser has identified it as a selfClosing tag. if ( element.isUnknown && selfClosing ) element.isEmpty = true; // This is a tag to be removed if empty, so do not add it immediately. if ( CKEDITOR.dtd.$removeEmpty[ tagName ] ) { pendingInline.push( element ); return; } else if ( tagName == 'pre' ) inPre = true; else if ( tagName == 'br' && inPre ) { currentNode.add( new CKEDITOR.htmlParser.text( '\n' ) ); return; } if ( tagName == 'br' ) { pendingBRs.push( element ); return; } var currentName = currentNode.name; var currentDtd = currentName && ( CKEDITOR.dtd[ currentName ] || ( currentNode._.isBlockLike ? CKEDITOR.dtd.div : CKEDITOR.dtd.span ) ); // If the element cannot be child of the current element. if ( currentDtd // Fragment could receive any elements. && !element.isUnknown && !currentNode.isUnknown && !currentDtd[ tagName ] ) { var reApply = false, addPoint; // New position to start adding nodes. // Fixing malformed nested lists by moving it into a previous list item. (#3828) if ( tagName in listBlocks && currentName in listBlocks ) { var children = currentNode.children, lastChild = children[ children.length - 1 ]; // Establish the list item if it's not existed. if ( !( lastChild && lastChild.name in listItems ) ) addElement( ( lastChild = new CKEDITOR.htmlParser.element( 'li' ) ), currentNode ); returnPoint = currentNode, addPoint = lastChild; } // If the element name is the same as the current element name, // then just close the current one and append the new one to the // parent. This situation usually happens with <p>, <li>, <dt> and // <dd>, specially in IE. Do not enter in this if block in this case. else if ( tagName == currentName ) { addElement( currentNode, currentNode.parent ); } else if ( tagName in CKEDITOR.dtd.$listItem ) { parser.onTagOpen( 'ul', {} ); addPoint = currentNode; reApply = true; } else { if ( nonBreakingBlocks[ currentName ] ) { if ( !returnPoint ) returnPoint = currentNode; } else { addElement( currentNode, currentNode.parent, true ); if ( !optionalClose[ currentName ] ) { // The current element is an inline element, which // cannot hold the new one. Put it in the pending list, // and try adding the new one after it. pendingInline.unshift( currentNode ); } } reApply = true; } if ( addPoint ) currentNode = addPoint; // Try adding it to the return point, or the parent element. else currentNode = currentNode.returnPoint || currentNode.parent; if ( reApply ) { parser.onTagOpen.apply( this, arguments ); return; } } checkPending( tagName ); sendPendingBRs(); element.parent = currentNode; element.returnPoint = returnPoint; returnPoint = 0; if ( element.isEmpty ) addElement( element ); else currentNode = element; }; parser.onTagClose = function( tagName ) { // Check if there is any pending tag to be closed. for ( var i = pendingInline.length - 1 ; i >= 0 ; i-- ) { // If found, just remove it from the list. if ( tagName == pendingInline[ i ].name ) { pendingInline.splice( i, 1 ); return; } } var pendingAdd = [], newPendingInline = [], candidate = currentNode; while ( candidate.type && candidate.name != tagName ) { // If this is an inline element, add it to the pending list, if we're // really closing one of the parents element later, they will continue // after it. if ( !candidate._.isBlockLike ) newPendingInline.unshift( candidate ); // This node should be added to it's parent at this point. But, // it should happen only if the closing tag is really closing // one of the nodes. So, for now, we just cache it. pendingAdd.push( candidate ); candidate = candidate.parent; } if ( candidate.type ) { // Add all elements that have been found in the above loop. for ( i = 0 ; i < pendingAdd.length ; i++ ) { var node = pendingAdd[ i ]; addElement( node, node.parent ); } currentNode = candidate; if ( currentNode.name == 'pre' ) inPre = false; if ( candidate._.isBlockLike ) sendPendingBRs(); addElement( candidate, candidate.parent ); // The parent should start receiving new nodes now, except if // addElement changed the currentNode. if ( candidate == currentNode ) currentNode = currentNode.parent; pendingInline = pendingInline.concat( newPendingInline ); } if ( tagName == 'body' ) fixForBody = false; }; parser.onText = function( text ) { // Trim empty spaces at beginning of element contents except <pre>. if ( !currentNode._.hasInlineStarted && !inPre ) { text = CKEDITOR.tools.ltrim( text ); if ( text.length === 0 ) return; } sendPendingBRs(); checkPending(); if ( fixForBody && ( !currentNode.type || currentNode.name == 'body' ) && CKEDITOR.tools.trim( text ) ) { this.onTagOpen( fixForBody, {} ); } // Shrinking consequential spaces into one single for all elements // text contents. if ( !inPre ) text = text.replace( /[\t\r\n ]{2,}|[\t\r\n]/g, ' ' ); currentNode.add( new CKEDITOR.htmlParser.text( text ) ); }; parser.onCDATA = function( cdata ) { currentNode.add( new CKEDITOR.htmlParser.cdata( cdata ) ); }; parser.onComment = function( comment ) { checkPending(); currentNode.add( new CKEDITOR.htmlParser.comment( comment ) ); }; // Parse it. parser.parse( fragmentHtml ); // Send all pending BRs except one, which we consider a unwanted bogus. (#5293) sendPendingBRs( !CKEDITOR.env.ie && 1 ); // Close all pending nodes. while ( currentNode.type ) { var parent = currentNode.parent, node = currentNode; if ( fixForBody && ( !parent.type || parent.name == 'body' ) && !CKEDITOR.dtd.$body[ node.name ] ) { currentNode = parent; parser.onTagOpen( fixForBody, {} ); parent = currentNode; } parent.add( node ); currentNode = parent; } return fragment; }; CKEDITOR.htmlParser.fragment.prototype = { /** * Adds a node to this fragment. * @param {Object} node The node to be added. It can be any of of the * following types: {@link CKEDITOR.htmlParser.element}, * {@link CKEDITOR.htmlParser.text} and * {@link CKEDITOR.htmlParser.comment}. * @example */ add : function( node ) { var len = this.children.length, previous = len > 0 && this.children[ len - 1 ] || null; if ( previous ) { // If the block to be appended is following text, trim spaces at // the right of it. if ( node._.isBlockLike && previous.type == CKEDITOR.NODE_TEXT ) { previous.value = CKEDITOR.tools.rtrim( previous.value ); // If we have completely cleared the previous node. if ( previous.value.length === 0 ) { // Remove it from the list and add the node again. this.children.pop(); this.add( node ); return; } } previous.next = node; } node.previous = previous; node.parent = this; this.children.push( node ); this._.hasInlineStarted = node.type == CKEDITOR.NODE_TEXT || ( node.type == CKEDITOR.NODE_ELEMENT && !node._.isBlockLike ); }, /** * Writes the fragment HTML to a CKEDITOR.htmlWriter. * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. * @example * var writer = new CKEDITOR.htmlWriter(); * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( '&lt;P&gt;&lt;B&gt;Example' ); * fragment.writeHtml( writer ) * alert( writer.getHtml() ); "&lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;" */ writeHtml : function( writer, filter ) { var isChildrenFiltered; this.filterChildren = function() { var writer = new CKEDITOR.htmlParser.basicWriter(); this.writeChildrenHtml.call( this, writer, filter, true ); var html = writer.getHtml(); this.children = new CKEDITOR.htmlParser.fragment.fromHtml( html ).children; isChildrenFiltered = 1; }; // Filtering the root fragment before anything else. !this.name && filter && filter.onFragment( this ); this.writeChildrenHtml( writer, isChildrenFiltered ? null : filter ); }, writeChildrenHtml : function( writer, filter ) { for ( var i = 0 ; i < this.children.length ; i++ ) this.children[i].writeHtml( writer, filter ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * A lightweight representation of an HTML element. * @param {String} name The element name. * @param {Object} attributes And object holding all attributes defined for * this element. * @constructor * @example */ CKEDITOR.htmlParser.element = function( name, attributes ) { /** * The element name. * @type String * @example */ this.name = name; /** * Holds the attributes defined for this element. * @type Object * @example */ this.attributes = attributes || ( attributes = {} ); /** * The nodes that are direct children of this element. * @type Array * @example */ this.children = []; var tagName = attributes[ 'data-cke-real-element-type' ] || name; var dtd = CKEDITOR.dtd, isBlockLike = !!( dtd.$nonBodyContent[ tagName ] || dtd.$block[ tagName ] || dtd.$listItem[ tagName ] || dtd.$tableContent[ tagName ] || dtd.$nonEditable[ tagName ] || tagName == 'br' ), isEmpty = !!dtd.$empty[ name ]; this.isEmpty = isEmpty; this.isUnknown = !dtd[ name ]; /** @private */ this._ = { isBlockLike : isBlockLike, hasInlineStarted : isEmpty || !isBlockLike }; }; (function() { // Used to sort attribute entries in an array, where the first element of // each object is the attribute name. var sortAttribs = function( a, b ) { a = a[0]; b = b[0]; return a < b ? -1 : a > b ? 1 : 0; }; CKEDITOR.htmlParser.element.prototype = { /** * The node type. This is a constant value set to {@link CKEDITOR.NODE_ELEMENT}. * @type Number * @example */ type : CKEDITOR.NODE_ELEMENT, /** * Adds a node to the element children list. * @param {Object} node The node to be added. It can be any of of the * following types: {@link CKEDITOR.htmlParser.element}, * {@link CKEDITOR.htmlParser.text} and * {@link CKEDITOR.htmlParser.comment}. * @function * @example */ add : CKEDITOR.htmlParser.fragment.prototype.add, /** * Clone this element. * @returns {CKEDITOR.htmlParser.element} The element clone. * @example */ clone : function() { return new CKEDITOR.htmlParser.element( this.name, this.attributes ); }, /** * Writes the element HTML to a CKEDITOR.htmlWriter. * @param {CKEDITOR.htmlWriter} writer The writer to which write the HTML. * @example */ writeHtml : function( writer, filter ) { var attributes = this.attributes; // Ignore cke: prefixes when writing HTML. var element = this, writeName = element.name, a, newAttrName, value; var isChildrenFiltered; /** * Providing an option for bottom-up filtering order ( element * children to be pre-filtered before the element itself ). */ element.filterChildren = function() { if ( !isChildrenFiltered ) { var writer = new CKEDITOR.htmlParser.basicWriter(); CKEDITOR.htmlParser.fragment.prototype.writeChildrenHtml.call( element, writer, filter ); element.children = new CKEDITOR.htmlParser.fragment.fromHtml( writer.getHtml() ).children; isChildrenFiltered = 1; } }; if ( filter ) { while ( true ) { if ( !( writeName = filter.onElementName( writeName ) ) ) return; element.name = writeName; if ( !( element = filter.onElement( element ) ) ) return; element.parent = this.parent; if ( element.name == writeName ) break; // If the element has been replaced with something of a // different type, then make the replacement write itself. if ( element.type != CKEDITOR.NODE_ELEMENT ) { element.writeHtml( writer, filter ); return; } writeName = element.name; // This indicate that the element has been dropped by // filter but not the children. if ( !writeName ) { this.writeChildrenHtml.call( element, writer, isChildrenFiltered ? null : filter ); return; } } // The element may have been changed, so update the local // references. attributes = element.attributes; } // Open element tag. writer.openTag( writeName, attributes ); // Copy all attributes to an array. var attribsArray = []; // Iterate over the attributes twice since filters may alter // other attributes. for ( var i = 0 ; i < 2; i++ ) { for ( a in attributes ) { newAttrName = a; value = attributes[ a ]; if ( i == 1 ) attribsArray.push( [ a, value ] ); else if ( filter ) { while ( true ) { if ( !( newAttrName = filter.onAttributeName( a ) ) ) { delete attributes[ a ]; break; } else if ( newAttrName != a ) { delete attributes[ a ]; a = newAttrName; continue; } else break; } if ( newAttrName ) { if ( ( value = filter.onAttribute( element, newAttrName, value ) ) === false ) delete attributes[ newAttrName ]; else attributes [ newAttrName ] = value; } } } } // Sort the attributes by name. if ( writer.sortAttributes ) attribsArray.sort( sortAttribs ); // Send the attributes. var len = attribsArray.length; for ( i = 0 ; i < len ; i++ ) { var attrib = attribsArray[ i ]; writer.attribute( attrib[0], attrib[1] ); } // Close the tag. writer.openTagClose( writeName, element.isEmpty ); if ( !element.isEmpty ) { this.writeChildrenHtml.call( element, writer, isChildrenFiltered ? null : filter ); // Close the element. writer.closeTag( writeName ); } }, writeChildrenHtml : function( writer, filter ) { // Send children. CKEDITOR.htmlParser.fragment.prototype.writeChildrenHtml.apply( this, arguments ); } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ (function() { var loadedLangs = {}; /** * @namespace Holds language related functions. */ CKEDITOR.lang = { /** * The list of languages available in the editor core. * @type Object * @example * alert( CKEDITOR.lang.en ); // "true" */ languages : { 'af' : 1, 'ar' : 1, 'bg' : 1, 'bn' : 1, 'bs' : 1, 'ca' : 1, 'cs' : 1, 'cy' : 1, 'da' : 1, 'de' : 1, 'el' : 1, 'en-au' : 1, 'en-ca' : 1, 'en-gb' : 1, 'en' : 1, 'eo' : 1, 'es' : 1, 'et' : 1, 'eu' : 1, 'fa' : 1, 'fi' : 1, 'fo' : 1, 'fr-ca' : 1, 'fr' : 1, 'gl' : 1, 'gu' : 1, 'he' : 1, 'hi' : 1, 'hr' : 1, 'hu' : 1, 'is' : 1, 'it' : 1, 'ja' : 1, 'km' : 1, 'ko' : 1, 'lt' : 1, 'lv' : 1, 'mn' : 1, 'ms' : 1, 'nb' : 1, 'nl' : 1, 'no' : 1, 'pl' : 1, 'pt-br' : 1, 'pt' : 1, 'ro' : 1, 'ru' : 1, 'sk' : 1, 'sl' : 1, 'sr-latn' : 1, 'sr' : 1, 'sv' : 1, 'th' : 1, 'tr' : 1, 'uk' : 1, 'vi' : 1, 'zh-cn' : 1, 'zh' : 1 }, /** * Loads a specific language file, or auto detect it. A callback is * then called when the file gets loaded. * @param {String} languageCode The code of the language file to be * loaded. If null or empty, autodetection will be performed. The * same happens if the language is not supported. * @param {String} defaultLanguage The language to be used if * languageCode is not supported or if the autodetection fails. * @param {Function} callback A function to be called once the * language file is loaded. Two parameters are passed to this * function: the language code and the loaded language entries. * @example */ load : function( languageCode, defaultLanguage, callback ) { // If no languageCode - fallback to browser or default. // If languageCode - fallback to no-localized version or default. if ( !languageCode || !CKEDITOR.lang.languages[ languageCode ] ) languageCode = this.detect( defaultLanguage, languageCode ); if ( !this[ languageCode ] ) { CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( '_source/' + // @Packager.RemoveLine 'lang/' + languageCode + '.js' ), function() { callback( languageCode, this[ languageCode ] ); } , this ); } else callback( languageCode, this[ languageCode ] ); }, /** * Returns the language that best fit the user language. For example, * suppose that the user language is "pt-br". If this language is * supported by the editor, it is returned. Otherwise, if only "pt" is * supported, it is returned instead. If none of the previous are * supported, a default language is then returned. * @param {String} defaultLanguage The default language to be returned * if the user language is not supported. * @param {String} [probeLanguage] A language code to try to use, * instead of the browser based autodetection. * @returns {String} The detected language code. * @example * alert( CKEDITOR.lang.detect( 'en' ) ); // e.g., in a German browser: "de" */ detect : function( defaultLanguage, probeLanguage ) { var languages = this.languages; probeLanguage = probeLanguage || navigator.userLanguage || navigator.language; var parts = probeLanguage .toLowerCase() .match( /([a-z]+)(?:-([a-z]+))?/ ), lang = parts[1], locale = parts[2]; if ( languages[ lang + '-' + locale ] ) lang = lang + '-' + locale; else if ( !languages[ lang ] ) lang = null; CKEDITOR.lang.detect = lang ? function() { return lang; } : function( defaultLanguage ) { return defaultLanguage; }; return lang || defaultLanguage; } }; })();
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.dom} object, which contains DOM * manipulation objects and function. */ /** * @namespace DOM manipulation objects, classes and functions. * @see CKEDITOR.dom.element * @see CKEDITOR.dom.node * @example */ CKEDITOR.dom = {}; // PACKAGER_RENAME( CKEDITOR.dom )
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.lang} object, for the * Dutch language. */ /**#@+ @type String @example */ /** * Constains the dictionary of language entries. * @namespace */ CKEDITOR.lang['nl'] = { /** * The language reading direction. Possible values are "rtl" for * Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right * languages (like English). * @default 'ltr' */ dir : 'ltr', /* * Screenreader titles. Please note that screenreaders are not always capable * of reading non-English words. So be careful while translating it. */ editorTitle : 'Tekstverwerker, %1, druk op ALT 0 voor hulp.', // ARIA descriptions. toolbar : 'Werkbalk', editor : 'Tekstverwerker', // Toolbar buttons without dialogs. source : 'Code', newPage : 'Nieuwe pagina', save : 'Opslaan', preview : 'Voorbeeld', cut : 'Knippen', copy : 'Kopiëren', paste : 'Plakken', print : 'Printen', underline : 'Onderstreept', bold : 'Vet', italic : 'Schuingedrukt', selectAll : 'Alles selecteren', removeFormat : 'Opmaak verwijderen', strike : 'Doorhalen', subscript : 'Subscript', superscript : 'Superscript', horizontalrule : 'Horizontale lijn invoegen', pagebreak : 'Pagina-einde invoegen', pagebreakAlt : 'Page Break', // MISSING unlink : 'Link verwijderen', undo : 'Ongedaan maken', redo : 'Opnieuw uitvoeren', // Common messages and labels. common : { browseServer : 'Bladeren op server', url : 'URL', protocol : 'Protocol', upload : 'Upload', uploadSubmit : 'Naar server verzenden', image : 'Afbeelding', flash : 'Flash', form : 'Formulier', checkbox : 'Aanvinkvakje', radio : 'Selectievakje', textField : 'Tekstveld', textarea : 'Tekstvak', hiddenField : 'Verborgen veld', button : 'Knop', select : 'Selectieveld', imageButton : 'Afbeeldingsknop', notSet : '<niet ingevuld>', id : 'Kenmerk', name : 'Naam', langDir : 'Schrijfrichting', langDirLtr : 'Links naar rechts (LTR)', langDirRtl : 'Rechts naar links (RTL)', langCode : 'Taalcode', longDescr : 'Lange URL-omschrijving', cssClass : 'Stylesheet-klassen', advisoryTitle : 'Aanbevolen titel', cssStyle : 'Stijl', ok : 'OK', cancel : 'Annuleren', close : 'Sluiten', preview : 'Voorbeeld', generalTab : 'Algemeen', advancedTab : 'Geavanceerd', validateNumberFailed : 'Deze waarde is geen geldig getal.', confirmNewPage : 'Alle aangebrachte wijzigingen gaan verloren. Weet u zeker dat u een nieuwe pagina wilt openen?', confirmCancel : 'Enkele opties zijn gewijzigd. Weet u zeker dat u dit dialoogvenster wilt sluiten?', options : 'Opties', target : 'Doel', targetNew : 'Nieuw venster (_blank)', targetTop : 'Hele venster (_top)', targetSelf : 'Zelfde venster (_self)', targetParent : 'Origineel venster (_parent)', langDirLTR : 'Links naar rechts (LTR)', langDirRTL : 'Rechts naar links (RTL)', styles : 'Stijlen', cssClasses : 'Stylesheet klassen', width : 'Breedte', height : 'Hoogte', align : 'Uitlijning', alignLeft : 'Links', alignRight : 'Rechts', alignCenter : 'Centreren', alignTop : 'Boven', alignMiddle : 'Midden', alignBottom : 'Beneden', invalidHeight : 'De hoogte moet een getal zijn.', invalidWidth : 'De breedte moet een getal zijn.', // Put the voice-only part of the label in the span. unavailable : '%1<span class="cke_accessibility">, niet beschikbaar</span>' }, contextmenu : { options : 'Context menu opties' }, // Special char dialog. specialChar : { toolbar : 'Speciaal teken invoegen', title : 'Selecteer speciaal teken', options : 'Speciale tekens opties' }, // Link dialog. link : { toolbar : 'Link invoegen/wijzigen', other : '<ander>', menu : 'Link wijzigen', title : 'Link', info : 'Linkomschrijving', target : 'Doel', upload : 'Upload', advanced : 'Geavanceerd', type : 'Linktype', toUrl : 'URL', toAnchor : 'Interne link in pagina', toEmail : 'E-mail', targetFrame : '<frame>', targetPopup : '<popup window>', targetFrameName : 'Naam doelframe', targetPopupName : 'Naam popupvenster', popupFeatures : 'Instellingen popupvenster', popupResizable : 'Herschaalbaar', popupStatusBar : 'Statusbalk', popupLocationBar: 'Locatiemenu', popupToolbar : 'Menubalk', popupMenuBar : 'Menubalk', popupFullScreen : 'Volledig scherm (IE)', popupScrollBars : 'Schuifbalken', popupDependent : 'Afhankelijk (Netscape)', popupLeft : 'Positie links', popupTop : 'Positie boven', id : 'Id', langDir : 'Schrijfrichting', langDirLTR : 'Links naar rechts (LTR)', langDirRTL : 'Rechts naar links (RTL)', acccessKey : 'Toegangstoets', name : 'Naam', langCode : 'Schrijfrichting', tabIndex : 'Tabvolgorde', advisoryTitle : 'Aanbevolen titel', advisoryContentType : 'Aanbevolen content-type', cssClasses : 'Stylesheet-klassen', charset : 'Karakterset van gelinkte bron', styles : 'Stijl', selectAnchor : 'Kies een interne link', anchorName : 'Op naam interne link', anchorId : 'Op kenmerk interne link', emailAddress : 'E-mailadres', emailSubject : 'Onderwerp bericht', emailBody : 'Inhoud bericht', noAnchors : '(Geen interne links in document gevonden)', noUrl : 'Geef de link van de URL', noEmail : 'Geef een e-mailadres' }, // Anchor dialog anchor : { toolbar : 'Interne link', menu : 'Eigenschappen interne link', title : 'Eigenschappen interne link', name : 'Naam interne link', errorName : 'Geef de naam van de interne link op' }, // List style dialog list: { numberedTitle : 'Eigenschappen genummerde lijst', bulletedTitle : 'Eigenschappen lijst met opsommingstekens', type : 'Type', start : 'Start', validateStartNumber :'Starnummer van de lijst moet een heel nummer zijn.', circle : 'Cirkel', disc : 'Schijf', square : 'Vierkant', none : 'Geen', notset : '<niet gezet>', armenian : 'Armeense numering', georgian : 'Greorgische numering (an, ban, gan, etc.)', lowerRoman : 'Romeins kleine letters (i, ii, iii, iv, v, etc.)', upperRoman : 'Romeins hoofdletters (I, II, III, IV, V, etc.)', lowerAlpha : 'Kleine letters (a, b, c, d, e, etc.)', upperAlpha : 'Hoofdletters (A, B, C, D, E, etc.)', lowerGreek : 'Grieks kleine letters (alpha, beta, gamma, etc.)', decimal : 'Cijfers (1, 2, 3, etc.)', decimalLeadingZero : 'Cijfers beginnen met nul (01, 02, 03, etc.)' }, // Find And Replace Dialog findAndReplace : { title : 'Zoeken en vervangen', find : 'Zoeken', replace : 'Vervangen', findWhat : 'Zoeken naar:', replaceWith : 'Vervangen met:', notFoundMsg : 'De opgegeven tekst is niet gevonden.', matchCase : 'Hoofdlettergevoelig', matchWord : 'Hele woord moet voorkomen', matchCyclic : 'Doorlopend zoeken', replaceAll : 'Alles vervangen', replaceSuccessMsg : '%1 resulaten vervangen.' }, // Table Dialog table : { toolbar : 'Tabel', title : 'Eigenschappen tabel', menu : 'Eigenschappen tabel', deleteTable : 'Tabel verwijderen', rows : 'Rijen', columns : 'Kolommen', border : 'Breedte rand', widthPx : 'pixels', widthPc : 'procent', widthUnit : 'eenheid breedte', cellSpace : 'Afstand tussen cellen', cellPad : 'Ruimte in de cel', caption : 'Naam', summary : 'Samenvatting', headers : 'Koppen', headersNone : 'Geen', headersColumn : 'Eerste kolom', headersRow : 'Eerste rij', headersBoth : 'Beide', invalidRows : 'Het aantal rijen moet een getal zijn groter dan 0.', invalidCols : 'Het aantal kolommen moet een getal zijn groter dan 0.', invalidBorder : 'De rand breedte moet een getal zijn.', invalidWidth : 'De tabel breedte moet een getal zijn.', invalidHeight : 'De tabel hoogte moet een getal zijn.', invalidCellSpacing : 'Afstand tussen cellen moet een getal zijn.', invalidCellPadding : 'Ruimte in de cel moet een getal zijn.', cell : { menu : 'Cel', insertBefore : 'Voeg cel in voor', insertAfter : 'Voeg cel in achter', deleteCell : 'Cellen verwijderen', merge : 'Cellen samenvoegen', mergeRight : 'Voeg samen naar rechts', mergeDown : 'Voeg samen naar beneden', splitHorizontal : 'Splits cellen horizontaal', splitVertical : 'Splits cellen verticaal', title : 'Cel eigenschappen', cellType : 'Cel type', rowSpan : 'Rijen samenvoegen', colSpan : 'Kolommen samenvoegen', wordWrap : 'Automatische terugloop', hAlign : 'Horizontale uitlijning', vAlign : 'Verticale uitlijning', alignBaseline : 'Basislijn', bgColor : 'Achtergrondkleur', borderColor : 'Kleur rand', data : 'Inhoud', header : 'Kop', yes : 'Ja', no : 'Nee', invalidWidth : 'De celbreedte moet een getal zijn.', invalidHeight : 'De celhoogte moet een getal zijn.', invalidRowSpan : 'Rijen samenvoegen moet een heel getal zijn.', invalidColSpan : 'Kolommen samenvoegen moet een heel getal zijn.', chooseColor : 'Kies' }, row : { menu : 'Rij', insertBefore : 'Voeg rij in voor', insertAfter : 'Voeg rij in achter', deleteRow : 'Rijen verwijderen' }, column : { menu : 'Kolom', insertBefore : 'Voeg kolom in voor', insertAfter : 'Voeg kolom in achter', deleteColumn : 'Kolommen verwijderen' } }, // Button Dialog. button : { title : 'Eigenschappen knop', text : 'Tekst (waarde)', type : 'Soort', typeBtn : 'Knop', typeSbm : 'Versturen', typeRst : 'Leegmaken' }, // Checkbox and Radio Button Dialogs. checkboxAndRadio : { checkboxTitle : 'Eigenschappen aanvinkvakje', radioTitle : 'Eigenschappen selectievakje', value : 'Waarde', selected : 'Geselecteerd' }, // Form Dialog. form : { title : 'Eigenschappen formulier', menu : 'Eigenschappen formulier', action : 'Actie', method : 'Methode', encoding : 'Codering' }, // Select Field Dialog. select : { title : 'Eigenschappen selectieveld', selectInfo : 'Informatie', opAvail : 'Beschikbare opties', value : 'Waarde', size : 'Grootte', lines : 'Regels', chkMulti : 'Gecombineerde selecties toestaan', opText : 'Tekst', opValue : 'Waarde', btnAdd : 'Toevoegen', btnModify : 'Wijzigen', btnUp : 'Omhoog', btnDown : 'Omlaag', btnSetValue : 'Als geselecteerde waarde instellen', btnDelete : 'Verwijderen' }, // Textarea Dialog. textarea : { title : 'Eigenschappen tekstvak', cols : 'Kolommen', rows : 'Rijen' }, // Text Field Dialog. textfield : { title : 'Eigenschappen tekstveld', name : 'Naam', value : 'Waarde', charWidth : 'Breedte (tekens)', maxChars : 'Maximum aantal tekens', type : 'Soort', typeText : 'Tekst', typePass : 'Wachtwoord' }, // Hidden Field Dialog. hidden : { title : 'Eigenschappen verborgen veld', name : 'Naam', value : 'Waarde' }, // Image Dialog. image : { title : 'Eigenschappen afbeelding', titleButton : 'Eigenschappen afbeeldingsknop', menu : 'Eigenschappen afbeelding', infoTab : 'Informatie afbeelding', btnUpload : 'Naar server verzenden', upload : 'Upload', alt : 'Alternatieve tekst', lockRatio : 'Afmetingen vergrendelen', unlockRatio : 'Afmetingen ontgrendelen', resetSize : 'Afmetingen resetten', border : 'Rand', hSpace : 'HSpace', vSpace : 'VSpace', alertUrl : 'Geef de URL van de afbeelding', linkTab : 'Link', button2Img : 'Wilt u de geselecteerde afbeeldingsknop vervangen door een eenvoudige afbeelding?', img2Button : 'Wilt u de geselecteerde afbeelding vervangen door een afbeeldingsknop?', urlMissing : 'De URL naar de afbeelding ontbreekt.', validateBorder : 'Rand moet een heel nummer zijn.', validateHSpace : 'HSpace moet een heel nummer zijn.', validateVSpace : 'VSpace moet een heel nummer zijn.' }, // Flash Dialog flash : { properties : 'Eigenschappen Flash', propertiesTab : 'Eigenschappen', title : 'Eigenschappen Flash', chkPlay : 'Automatisch afspelen', chkLoop : 'Herhalen', chkMenu : 'Flashmenu\'s inschakelen', chkFull : 'Schermvullend toestaan', scale : 'Schaal', scaleAll : 'Alles tonen', scaleNoBorder : 'Geen rand', scaleFit : 'Precies passend', access : 'Script toegang', accessAlways : 'Altijd', accessSameDomain: 'Zelfde domeinnaam', accessNever : 'Nooit', alignAbsBottom : 'Absoluut-onder', alignAbsMiddle : 'Absoluut-midden', alignBaseline : 'Basislijn', alignTextTop : 'Boven tekst', quality : 'Kwaliteit', qualityBest : 'Beste', qualityHigh : 'Hoog', qualityAutoHigh : 'Automatisch hoog', qualityMedium : 'Gemiddeld', qualityAutoLow : 'Automatisch laag', qualityLow : 'Laag', windowModeWindow: 'Venster', windowModeOpaque: 'Ondoorzichtig', windowModeTransparent : 'Doorzichtig', windowMode : 'Venster modus', flashvars : 'Variabelen voor Flash', bgcolor : 'Achtergrondkleur', hSpace : 'HSpace', vSpace : 'VSpace', validateSrc : 'Geef de link van de URL', validateHSpace : 'De HSpace moet een getal zijn.', validateVSpace : 'De VSpace moet een getal zijn.' }, // Speller Pages Dialog spellCheck : { toolbar : 'Spellingscontrole', title : 'Spellingscontrole', notAvailable : 'Excuses, deze dienst is momenteel niet beschikbaar.', errorLoading : 'Er is een fout opgetreden bij het laden van de diesnt: %s.', notInDic : 'Niet in het woordenboek', changeTo : 'Wijzig in', btnIgnore : 'Negeren', btnIgnoreAll : 'Alles negeren', btnReplace : 'Vervangen', btnReplaceAll : 'Alles vervangen', btnUndo : 'Ongedaan maken', noSuggestions : '-Geen suggesties-', progress : 'Bezig met spellingscontrole...', noMispell : 'Klaar met spellingscontrole: geen fouten gevonden', noChanges : 'Klaar met spellingscontrole: geen woorden aangepast', oneChange : 'Klaar met spellingscontrole: één woord aangepast', manyChanges : 'Klaar met spellingscontrole: %1 woorden aangepast', ieSpellDownload : 'De spellingscontrole niet geïnstalleerd. Wilt u deze nu downloaden?' }, smiley : { toolbar : 'Smiley', title : 'Smiley invoegen', options : 'Smiley opties' }, elementsPath : { eleLabel : 'Elementenpad', eleTitle : '%1 element' }, numberedlist : 'Genummerde lijst', bulletedlist : 'Opsomming', indent : 'Inspringen vergroten', outdent : 'Inspringen verkleinen', justify : { left : 'Links uitlijnen', center : 'Centreren', right : 'Rechts uitlijnen', block : 'Uitvullen' }, blockquote : 'Citaatblok', clipboard : { title : 'Plakken', cutError : 'De beveiligingsinstelling van de browser verhinderen het automatisch knippen. Gebruik de sneltoets Ctrl/Cmd+X van het toetsenbord.', copyError : 'De beveiligingsinstelling van de browser verhinderen het automatisch kopiëren. Gebruik de sneltoets Ctrl/Cmd+C van het toetsenbord.', pasteMsg : 'Plak de tekst in het volgende vak gebruik makend van uw toetsenbord (<strong>Ctrl/Cmd+V</strong>) en klik op <strong>OK</strong>.', securityMsg : 'Door de beveiligingsinstellingen van uw browser is het niet mogelijk om direct vanuit het klembord in de editor te plakken. Middels opnieuw plakken in dit venster kunt u de tekst alsnog plakken in de editor.', pasteArea : 'Plakgebied' }, pastefromword : { confirmCleanup : 'De tekst die u plakte lijkt gekopieerd te zijn vanuit Word. Wilt u de tekst opschonen voordat deze geplakt wordt?', toolbar : 'Plakken als Word-gegevens', title : 'Plakken als Word-gegevens', error : 'Het was niet mogelijk om de geplakte tekst op te schonen door een interne fout' }, pasteText : { button : 'Plakken als platte tekst', title : 'Plakken als platte tekst' }, templates : { button : 'Sjablonen', title : 'Inhoud sjabonen', options : 'Template opties', insertOption : 'Vervang de huidige inhoud', selectPromptMsg : 'Selecteer het sjabloon dat in de editor geopend moet worden (de actuele inhoud gaat verloren):', emptyListMsg : '(Geen sjablonen gedefinieerd)' }, showBlocks : 'Toon blokken', stylesCombo : { label : 'Stijl', panelTitle : 'Opmaakstijlen', panelTitle1 : 'Blok stijlen', panelTitle2 : 'In-line stijlen', panelTitle3 : 'Object stijlen' }, format : { label : 'Opmaak', panelTitle : 'Opmaak', tag_p : 'Normaal', tag_pre : 'Met opmaak', tag_address : 'Adres', tag_h1 : 'Kop 1', tag_h2 : 'Kop 2', tag_h3 : 'Kop 3', tag_h4 : 'Kop 4', tag_h5 : 'Kop 5', tag_h6 : 'Kop 6', tag_div : 'Normaal (DIV)' }, div : { title : 'Div aanmaken', toolbar : 'Div aanmaken', cssClassInputLabel : 'Stylesheet klassen', styleSelectLabel : 'Stijl', IdInputLabel : 'Id', languageCodeInputLabel : ' Taalcode', inlineStyleInputLabel : 'Inline stijl', advisoryTitleInputLabel : 'informatieve titel', langDirLabel : 'Schrijfrichting', langDirLTRLabel : 'Links naar rechts (LTR)', langDirRTLLabel : 'Rechts naar links (RTL)', edit : 'Div wijzigen', remove : 'Div verwijderen' }, iframe : { title : 'iFrame Properties', // MISSING toolbar : 'iFrame', // MISSING noUrl : 'Please type the iFrame URL', // MISSING scrolling : 'Enable scrollbars', // MISSING border : 'Show frame border' // MISSING }, font : { label : 'Lettertype', voiceLabel : 'Lettertype', panelTitle : 'Lettertype' }, fontSize : { label : 'Lettergrootte', voiceLabel : 'Lettergrootte', panelTitle : 'Lettergrootte' }, colorButton : { textColorTitle : 'Tekstkleur', bgColorTitle : 'Achtergrondkleur', panelTitle : 'Kleuren', auto : 'Automatisch', more : 'Meer kleuren...' }, colors : { '000' : 'Zwart', '800000' : 'Kastanjebruin', '8B4513' : 'Chocoladebruin', '2F4F4F' : 'Donkerleigrijs', '008080' : 'Blauwgroen', '000080' : 'Marine', '4B0082' : 'Indigo', '696969' : 'Donkergrijs', 'B22222' : 'Baksteen', 'A52A2A' : 'Bruin', 'DAA520' : 'Donkergeel', '006400' : 'Donkergroen', '40E0D0' : 'Turquoise', '0000CD' : 'Middenblauw', '800080' : 'Paars', '808080' : 'Grijs', 'F00' : 'Rood', 'FF8C00' : 'Donkeroranje', 'FFD700' : 'Goud', '008000' : 'Groen', '0FF' : 'Cyaan', '00F' : 'Blauw', 'EE82EE' : 'Violet', 'A9A9A9' : 'Donkergrijs', 'FFA07A' : 'Lichtzalm', 'FFA500' : 'Oranje', 'FFFF00' : 'Geel', '00FF00' : 'Felgroen', 'AFEEEE' : 'Lichtturquoise', 'ADD8E6' : 'Lichtblauw', 'DDA0DD' : 'Pruim', 'D3D3D3' : 'Lichtgrijs', 'FFF0F5' : 'Linnen', 'FAEBD7' : 'Ivoor', 'FFFFE0' : 'Lichtgeel', 'F0FFF0' : 'Honingdauw', 'F0FFFF' : 'Azuur', 'F0F8FF' : 'Licht hemelsblauw', 'E6E6FA' : 'Lavendel', 'FFF' : 'Wit' }, scayt : { title : 'Controleer de spelling tijdens het typen', opera_title : 'Niet ondersteund door Opera', enable : 'SCAYT inschakelen', disable : 'SCAYT uitschakelen', about : 'Over SCAYT', toggle : 'SCAYT in/uitschakelen', options : 'Opties', langs : 'Talen', moreSuggestions : 'Meer suggesties', ignore : 'Negeren', ignoreAll : 'Alles negeren', addWord : 'Woord toevoegen', emptyDic : 'De naam van het woordenboek mag niet leeg zijn.', optionsTab : 'Opties', allCaps : 'Negeer woorden helemaal in hoofdletters', ignoreDomainNames : 'Negeer domeinnamen', mixedCase : 'Negeer woorden met hoofd- en kleine letters', mixedWithDigits : 'Negeer woorden met cijfers', languagesTab : 'Talen', dictionariesTab : 'Woordenboeken', dic_field_name : 'Naam woordenboek', dic_create : 'Aanmaken', dic_restore : 'Terugzetten', dic_delete : 'Verwijderen', dic_rename : 'Hernoemen', dic_info : 'Initieel wordt het gebruikerswoordenboek opgeslagen in een cookie. Cookies zijn echter beperkt in grootte. Zodra het gebruikerswoordenboek het punt bereikt waarop het niet meer in een cookie opgeslagen kan worden, dan wordt het woordenboek op de server opgeslagen. Om je persoonlijke woordenboek op je eigen server op te slaan, moet je een mapnaam opgeven. Indien je al een woordenboek hebt opgeslagen, typ dan de naam en klik op de Terugzetten knop.', aboutTab : 'Over' }, about : { title : 'Over CKEditor', dlgTitle : 'Over CKEditor', moreInfo : 'Voor licentie informatie, bezoek onze website:', copy : 'Copyright &copy; $1. Alle rechten voorbehouden.' }, maximize : 'Maximaliseren', minimize : 'Minimaliseren', fakeobjects : { anchor : 'Anker', flash : 'Flash animatie', iframe : 'iFrame', // MISSING hiddenfield : 'Hidden Field', // MISSING unknown : 'Onbekend object' }, resize : 'Sleep om te herschalen', colordialog : { title : 'Selecteer kleur', options : 'Kleuropties', highlight : 'Actief', selected : 'Geselecteerd', clear : 'Wissen' }, toolbarCollapse : 'Werkbalk inklappen', toolbarExpand : 'Werkbalk uitklappen', bidi : { ltr : 'Schrijfrichting van links naar rechts', rtl : 'Schrijfrichting van rechts naar links' } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.lang} object, for the * Italian language. */ /**#@+ @type String @example */ /** * Constains the dictionary of language entries. * @namespace */ CKEDITOR.lang['it'] = { /** * The language reading direction. Possible values are "rtl" for * Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right * languages (like English). * @default 'ltr' */ dir : 'ltr', /* * Screenreader titles. Please note that screenreaders are not always capable * of reading non-English words. So be careful while translating it. */ editorTitle : 'Rich text editor, %1, press ALT 0 for help.', // MISSING // ARIA descriptions. toolbar : 'Toolbar', // MISSING editor : 'Rich Text Editor', // MISSING // Toolbar buttons without dialogs. source : 'Codice Sorgente', newPage : 'Nuova pagina vuota', save : 'Salva', preview : 'Anteprima', cut : 'Taglia', copy : 'Copia', paste : 'Incolla', print : 'Stampa', underline : 'Sottolineato', bold : 'Grassetto', italic : 'Corsivo', selectAll : 'Seleziona tutto', removeFormat : 'Elimina formattazione', strike : 'Barrato', subscript : 'Pedice', superscript : 'Apice', horizontalrule : 'Inserisci riga orizzontale', pagebreak : 'Inserisci interruzione di pagina', pagebreakAlt : 'Page Break', // MISSING unlink : 'Elimina collegamento', undo : 'Annulla', redo : 'Ripristina', // Common messages and labels. common : { browseServer : 'Cerca sul server', url : 'URL', protocol : 'Protocollo', upload : 'Carica', uploadSubmit : 'Invia al server', image : 'Immagine', flash : 'Oggetto Flash', form : 'Modulo', checkbox : 'Checkbox', radio : 'Radio Button', textField : 'Campo di testo', textarea : 'Area di testo', hiddenField : 'Campo nascosto', button : 'Bottone', select : 'Menu di selezione', imageButton : 'Bottone immagine', notSet : '<non impostato>', id : 'Id', name : 'Nome', langDir : 'Direzione scrittura', langDirLtr : 'Da Sinistra a Destra (LTR)', langDirRtl : 'Da Destra a Sinistra (RTL)', langCode : 'Codice Lingua', longDescr : 'URL descrizione estesa', cssClass : 'Nome classe CSS', advisoryTitle : 'Titolo', cssStyle : 'Stile', ok : 'OK', cancel : 'Annulla', close : 'Close', // MISSING preview : 'Preview', // MISSING generalTab : 'Generale', advancedTab : 'Avanzate', validateNumberFailed : 'Il valore inserito non è un numero.', confirmNewPage : 'Ogni modifica non salvata sarà persa. Sei sicuro di voler caricare una nuova pagina?', confirmCancel : 'Alcune delle opzioni sono state cambiate. Sei sicuro di voler chiudere la finestra di dialogo?', options : 'Options', // MISSING target : 'Target', // MISSING targetNew : 'New Window (_blank)', // MISSING targetTop : 'Topmost Window (_top)', // MISSING targetSelf : 'Same Window (_self)', // MISSING targetParent : 'Parent Window (_parent)', // MISSING langDirLTR : 'Left to Right (LTR)', // MISSING langDirRTL : 'Right to Left (RTL)', // MISSING styles : 'Style', // MISSING cssClasses : 'Stylesheet Classes', // MISSING width : 'Larghezza', height : 'Altezza', align : 'Allineamento', alignLeft : 'Sinistra', alignRight : 'Destra', alignCenter : 'Centrato', alignTop : 'In Alto', alignMiddle : 'Centrato', alignBottom : 'In Basso', invalidHeight : 'L\'altezza dev\'essere un numero', invalidWidth : 'La Larghezza dev\'essere un numero', // Put the voice-only part of the label in the span. unavailable : '%1<span class="cke_accessibility">, non disponibile</span>' }, contextmenu : { options : 'Context Menu Options' // MISSING }, // Special char dialog. specialChar : { toolbar : 'Inserisci carattere speciale', title : 'Seleziona carattere speciale', options : 'Special Character Options' // MISSING }, // Link dialog. link : { toolbar : 'Inserisci/Modifica collegamento', other : '<altro>', menu : 'Modifica collegamento', title : 'Collegamento', info : 'Informazioni collegamento', target : 'Destinazione', upload : 'Carica', advanced : 'Avanzate', type : 'Tipo di Collegamento', toUrl : 'URL', // MISSING toAnchor : 'Ancora nella pagina', toEmail : 'E-Mail', targetFrame : '<riquadro>', targetPopup : '<finestra popup>', targetFrameName : 'Nome del riquadro di destinazione', targetPopupName : 'Nome finestra popup', popupFeatures : 'Caratteristiche finestra popup', popupResizable : 'Ridimensionabile', popupStatusBar : 'Barra di stato', popupLocationBar: 'Barra degli indirizzi', popupToolbar : 'Barra degli strumenti', popupMenuBar : 'Barra del menu', popupFullScreen : 'A tutto schermo (IE)', popupScrollBars : 'Barre di scorrimento', popupDependent : 'Dipendente (Netscape)', popupLeft : 'Posizione da sinistra', popupTop : 'Posizione dall\'alto', id : 'Id', langDir : 'Direzione scrittura', langDirLTR : 'Da Sinistra a Destra (LTR)', langDirRTL : 'Da Destra a Sinistra (RTL)', acccessKey : 'Scorciatoia<br />da tastiera', name : 'Nome', langCode : 'Direzione scrittura', tabIndex : 'Ordine di tabulazione', advisoryTitle : 'Titolo', advisoryContentType : 'Tipo della risorsa collegata', cssClasses : 'Nome classe CSS', charset : 'Set di caretteri della risorsa collegata', styles : 'Stile', selectAnchor : 'Scegli Ancora', anchorName : 'Per Nome', anchorId : 'Per id elemento', emailAddress : 'Indirizzo E-Mail', emailSubject : 'Oggetto del messaggio', emailBody : 'Corpo del messaggio', noAnchors : '(Nessuna ancora disponibile nel documento)', noUrl : 'Devi inserire l\'URL del collegamento', noEmail : 'Devi inserire un\'indirizzo e-mail' }, // Anchor dialog anchor : { toolbar : 'Inserisci/Modifica Ancora', menu : 'Proprietà ancora', title : 'Proprietà ancora', name : 'Nome ancora', errorName : 'Inserici il nome dell\'ancora' }, // List style dialog list: { numberedTitle : 'Numbered List Properties', // MISSING bulletedTitle : 'Bulleted List Properties', // MISSING type : 'Type', // MISSING start : 'Start', // MISSING validateStartNumber :'List start number must be a whole number.', // MISSING circle : 'Circle', // MISSING disc : 'Disc', // MISSING square : 'Square', // MISSING none : 'None', // MISSING notset : '<not set>', // MISSING armenian : 'Armenian numbering', // MISSING georgian : 'Georgian numbering (an, ban, gan, etc.)', // MISSING lowerRoman : 'Lower Roman (i, ii, iii, iv, v, etc.)', // MISSING upperRoman : 'Upper Roman (I, II, III, IV, V, etc.)', // MISSING lowerAlpha : 'Lower Alpha (a, b, c, d, e, etc.)', // MISSING upperAlpha : 'Upper Alpha (A, B, C, D, E, etc.)', // MISSING lowerGreek : 'Lower Greek (alpha, beta, gamma, etc.)', // MISSING decimal : 'Decimal (1, 2, 3, etc.)', // MISSING decimalLeadingZero : 'Decimal leading zero (01, 02, 03, etc.)' // MISSING }, // Find And Replace Dialog findAndReplace : { title : 'Cerca e Sostituisci', find : 'Trova', replace : 'Sostituisci', findWhat : 'Trova:', replaceWith : 'Sostituisci con:', notFoundMsg : 'L\'elemento cercato non è stato trovato.', matchCase : 'Maiuscole/minuscole', matchWord : 'Solo parole intere', matchCyclic : 'Ricerca ciclica', replaceAll : 'Sostituisci tutto', replaceSuccessMsg : '%1 occorrenza(e) sostituite.' }, // Table Dialog table : { toolbar : 'Tabella', title : 'Proprietà tabella', menu : 'Proprietà tabella', deleteTable : 'Cancella Tabella', rows : 'Righe', columns : 'Colonne', border : 'Dimensione bordo', widthPx : 'pixel', widthPc : 'percento', widthUnit : 'width unit', // MISSING cellSpace : 'Spaziatura celle', cellPad : 'Padding celle', caption : 'Intestazione', summary : 'Indice', headers : 'Intestazione', headersNone : 'Nessuna', headersColumn : 'Prima Colonna', headersRow : 'Prima Riga', headersBoth : 'Entrambe', invalidRows : 'Il numero di righe dev\'essere un numero maggiore di 0.', invalidCols : 'Il numero di colonne dev\'essere un numero maggiore di 0.', invalidBorder : 'La dimensione del bordo dev\'essere un numero.', invalidWidth : 'La larghezza della tabella dev\'essere un numero.', invalidHeight : 'L\'altezza della tabella dev\'essere un numero.', invalidCellSpacing : 'La spaziatura tra le celle dev\'essere un numero.', invalidCellPadding : 'Il pagging delle celle dev\'essere un numero', cell : { menu : 'Cella', insertBefore : 'Inserisci Cella Prima', insertAfter : 'Inserisci Cella Dopo', deleteCell : 'Elimina celle', merge : 'Unisce celle', mergeRight : 'Unisci a Destra', mergeDown : 'Unisci in Basso', splitHorizontal : 'Dividi Cella Orizzontalmente', splitVertical : 'Dividi Cella Verticalmente', title : 'Proprietà della cella', cellType : 'Tipo di cella', rowSpan : 'Su più righe', colSpan : 'Su più colonne', wordWrap : 'Ritorno a capo', hAlign : 'Allineamento orizzontale', vAlign : 'Allineamento verticale', alignBaseline : 'Linea Base', bgColor : 'Colore di Sfondo', borderColor : 'Colore del Bordo', data : 'Dati', header : 'Intestazione', yes : 'Si', no : 'No', invalidWidth : 'La larghezza della cella dev\'essere un numero.', invalidHeight : 'L\'altezza della cella dev\'essere un numero.', invalidRowSpan : 'Il numero di righe dev\'essere un numero intero.', invalidColSpan : 'Il numero di colonne dev\'essere un numero intero.', chooseColor : 'Choose' // MISSING }, row : { menu : 'Riga', insertBefore : 'Inserisci Riga Prima', insertAfter : 'Inserisci Riga Dopo', deleteRow : 'Elimina righe' }, column : { menu : 'Colonna', insertBefore : 'Inserisci Colonna Prima', insertAfter : 'Inserisci Colonna Dopo', deleteColumn : 'Elimina colonne' } }, // Button Dialog. button : { title : 'Proprietà bottone', text : 'Testo (Value)', type : 'Tipo', typeBtn : 'Bottone', typeSbm : 'Invio', typeRst : 'Annulla' }, // Checkbox and Radio Button Dialogs. checkboxAndRadio : { checkboxTitle : 'Proprietà checkbox', radioTitle : 'Proprietà radio button', value : 'Valore', selected : 'Selezionato' }, // Form Dialog. form : { title : 'Proprietà modulo', menu : 'Proprietà modulo', action : 'Azione', method : 'Metodo', encoding : 'Codifica' }, // Select Field Dialog. select : { title : 'Proprietà menu di selezione', selectInfo : 'Info', opAvail : 'Opzioni disponibili', value : 'Valore', size : 'Dimensione', lines : 'righe', chkMulti : 'Permetti selezione multipla', opText : 'Testo', opValue : 'Valore', btnAdd : 'Aggiungi', btnModify : 'Modifica', btnUp : 'Su', btnDown : 'Gi', btnSetValue : 'Imposta come predefinito', btnDelete : 'Rimuovi' }, // Textarea Dialog. textarea : { title : 'Proprietà area di testo', cols : 'Colonne', rows : 'Righe' }, // Text Field Dialog. textfield : { title : 'Proprietà campo di testo', name : 'Nome', value : 'Valore', charWidth : 'Larghezza', maxChars : 'Numero massimo di caratteri', type : 'Tipo', typeText : 'Testo', typePass : 'Password' }, // Hidden Field Dialog. hidden : { title : 'Proprietà campo nascosto', name : 'Nome', value : 'Valore' }, // Image Dialog. image : { title : 'Proprietà immagine', titleButton : 'Proprietà bottone immagine', menu : 'Proprietà immagine', infoTab : 'Informazioni immagine', btnUpload : 'Invia al server', upload : 'Carica', alt : 'Testo alternativo', lockRatio : 'Blocca rapporto', unlockRatio : 'Unlock Ratio', // MISSING resetSize : 'Reimposta dimensione', border : 'Bordo', hSpace : 'HSpace', vSpace : 'VSpace', alertUrl : 'Devi inserire l\'URL per l\'immagine', linkTab : 'Collegamento', button2Img : 'Vuoi trasformare il bottone immagine selezionato in un\'immagine semplice?', img2Button : 'Vuoi trasferomare l\'immagine selezionata in un bottone immagine?', urlMissing : 'Image source URL is missing.', // MISSING validateBorder : 'Border must be a whole number.', // MISSING validateHSpace : 'HSpace must be a whole number.', // MISSING validateVSpace : 'VSpace must be a whole number.' // MISSING }, // Flash Dialog flash : { properties : 'Proprietà Oggetto Flash', propertiesTab : 'Proprietà', title : 'Proprietà Oggetto Flash', chkPlay : 'Avvio Automatico', chkLoop : 'Riavvio automatico', chkMenu : 'Abilita Menu di Flash', chkFull : 'Permetti la modalità tutto schermo', scale : 'Ridimensiona', scaleAll : 'Mostra Tutto', scaleNoBorder : 'Senza Bordo', scaleFit : 'Dimensione Esatta', access : 'Accesso Script', accessAlways : 'Sempre', accessSameDomain: 'Solo stesso dominio', accessNever : 'Mai', alignAbsBottom : 'In basso assoluto', alignAbsMiddle : 'Centrato assoluto', alignBaseline : 'Linea base', alignTextTop : 'In alto al testo', quality : 'Qualità', qualityBest : 'Massima', qualityHigh : 'Alta', qualityAutoHigh : 'Alta Automatica', qualityMedium : 'Intermedia', qualityAutoLow : 'Bassa Automatica', qualityLow : 'Bassa', windowModeWindow: 'Finestra', windowModeOpaque: 'Opaca', windowModeTransparent : 'Trasparente', windowMode : 'Modalità finestra', flashvars : 'Variabili per Flash', bgcolor : 'Colore sfondo', hSpace : 'HSpace', vSpace : 'VSpace', validateSrc : 'Devi inserire l\'URL del collegamento', validateHSpace : 'L\'HSpace dev\'essere un numero.', validateVSpace : 'Il VSpace dev\'essere un numero.' }, // Speller Pages Dialog spellCheck : { toolbar : 'Correttore ortografico', title : 'Controllo ortografico', notAvailable : 'Il servizio non è momentaneamente disponibile.', errorLoading : 'Errore nel caricamento dell\'host col servizio applicativo: %s.', notInDic : 'Non nel dizionario', changeTo : 'Cambia in', btnIgnore : 'Ignora', btnIgnoreAll : 'Ignora tutto', btnReplace : 'Cambia', btnReplaceAll : 'Cambia tutto', btnUndo : 'Annulla', noSuggestions : '- Nessun suggerimento -', progress : 'Controllo ortografico in corso', noMispell : 'Controllo ortografico completato: nessun errore trovato', noChanges : 'Controllo ortografico completato: nessuna parola cambiata', oneChange : 'Controllo ortografico completato: 1 parola cambiata', manyChanges : 'Controllo ortografico completato: %1 parole cambiate', ieSpellDownload : 'Contollo ortografico non installato. Lo vuoi scaricare ora?' }, smiley : { toolbar : 'Emoticon', title : 'Inserisci emoticon', options : 'Smiley Options' // MISSING }, elementsPath : { eleLabel : 'Elements path', // MISSING eleTitle : '%1 elemento' }, numberedlist : 'Elenco numerato', bulletedlist : 'Elenco puntato', indent : 'Aumenta rientro', outdent : 'Riduci rientro', justify : { left : 'Allinea a sinistra', center : 'Centra', right : 'Allinea a destra', block : 'Giustifica' }, blockquote : 'Citazione', clipboard : { title : 'Incolla', cutError : 'Le impostazioni di sicurezza del browser non permettono di tagliare automaticamente il testo. Usa la tastiera (Ctrl/Cmd+X).', copyError : 'Le impostazioni di sicurezza del browser non permettono di copiare automaticamente il testo. Usa la tastiera (Ctrl/Cmd+C).', pasteMsg : 'Incolla il testo all\'interno dell\'area sottostante usando la scorciatoia di tastiere (<STRONG>Ctrl/Cmd+V</STRONG>) e premi <STRONG>OK</STRONG>.', securityMsg : 'A causa delle impostazioni di sicurezza del browser,l\'editor non è in grado di accedere direttamente agli appunti. E\' pertanto necessario incollarli di nuovo in questa finestra.', pasteArea : 'Paste Area' // MISSING }, pastefromword : { confirmCleanup : 'Il testo da incollare sembra provenire da Word. Desideri pulirlo prima di incollare?', toolbar : 'Incolla da Word', title : 'Incolla da Word', error : 'It was not possible to clean up the pasted data due to an internal error' // MISSING }, pasteText : { button : 'Incolla come testo semplice', title : 'Incolla come testo semplice' }, templates : { button : 'Modelli', title : 'Contenuto dei modelli', options : 'Template Options', // MISSING insertOption : 'Cancella il contenuto corrente', selectPromptMsg : 'Seleziona il modello da aprire nell\'editor<br />(il contenuto attuale verrà eliminato):', emptyListMsg : '(Nessun modello definito)' }, showBlocks : 'Visualizza Blocchi', stylesCombo : { label : 'Stile', panelTitle : 'Formatting Styles', // MISSING panelTitle1 : 'Stili per blocchi', panelTitle2 : 'Stili in linea', panelTitle3 : 'Stili per oggetti' }, format : { label : 'Formato', panelTitle : 'Formato', tag_p : 'Normale', tag_pre : 'Formattato', tag_address : 'Indirizzo', tag_h1 : 'Titolo 1', tag_h2 : 'Titolo 2', tag_h3 : 'Titolo 3', tag_h4 : 'Titolo 4', tag_h5 : 'Titolo 5', tag_h6 : 'Titolo 6', tag_div : 'Paragrafo (DIV)' }, div : { title : 'Create Div Container', // MISSING toolbar : 'Create Div Container', // MISSING cssClassInputLabel : 'Stylesheet Classes', // MISSING styleSelectLabel : 'Style', // MISSING IdInputLabel : 'Id', // MISSING languageCodeInputLabel : ' Language Code', // MISSING inlineStyleInputLabel : 'Inline Style', // MISSING advisoryTitleInputLabel : 'Advisory Title', // MISSING langDirLabel : 'Language Direction', // MISSING langDirLTRLabel : 'Left to Right (LTR)', // MISSING langDirRTLLabel : 'Right to Left (RTL)', // MISSING edit : 'Edit Div', // MISSING remove : 'Remove Div' // MISSING }, iframe : { title : 'iFrame Properties', // MISSING toolbar : 'iFrame', // MISSING noUrl : 'Please type the iFrame URL', // MISSING scrolling : 'Enable scrollbars', // MISSING border : 'Show frame border' // MISSING }, font : { label : 'Font', voiceLabel : 'Font', panelTitle : 'Font' }, fontSize : { label : 'Dimensione', voiceLabel : 'Dimensione Font', panelTitle : 'Dimensione' }, colorButton : { textColorTitle : 'Colore testo', bgColorTitle : 'Colore sfondo', panelTitle : 'Colors', // MISSING auto : 'Automatico', more : 'Altri colori...' }, colors : { '000' : 'Black', // MISSING '800000' : 'Maroon', // MISSING '8B4513' : 'Saddle Brown', // MISSING '2F4F4F' : 'Dark Slate Gray', // MISSING '008080' : 'Teal', // MISSING '000080' : 'Navy', // MISSING '4B0082' : 'Indigo', // MISSING '696969' : 'Dark Gray', // MISSING 'B22222' : 'Fire Brick', // MISSING 'A52A2A' : 'Brown', // MISSING 'DAA520' : 'Golden Rod', // MISSING '006400' : 'Dark Green', // MISSING '40E0D0' : 'Turquoise', // MISSING '0000CD' : 'Medium Blue', // MISSING '800080' : 'Purple', // MISSING '808080' : 'Gray', // MISSING 'F00' : 'Red', // MISSING 'FF8C00' : 'Dark Orange', // MISSING 'FFD700' : 'Gold', // MISSING '008000' : 'Green', // MISSING '0FF' : 'Cyan', // MISSING '00F' : 'Blue', // MISSING 'EE82EE' : 'Violet', // MISSING 'A9A9A9' : 'Dim Gray', // MISSING 'FFA07A' : 'Light Salmon', // MISSING 'FFA500' : 'Orange', // MISSING 'FFFF00' : 'Yellow', // MISSING '00FF00' : 'Lime', // MISSING 'AFEEEE' : 'Pale Turquoise', // MISSING 'ADD8E6' : 'Light Blue', // MISSING 'DDA0DD' : 'Plum', // MISSING 'D3D3D3' : 'Light Grey', // MISSING 'FFF0F5' : 'Lavender Blush', // MISSING 'FAEBD7' : 'Antique White', // MISSING 'FFFFE0' : 'Light Yellow', // MISSING 'F0FFF0' : 'Honeydew', // MISSING 'F0FFFF' : 'Azure', // MISSING 'F0F8FF' : 'Alice Blue', // MISSING 'E6E6FA' : 'Lavender', // MISSING 'FFF' : 'White' // MISSING }, scayt : { title : 'Controllo Ortografico Mentre Scrivi', opera_title : 'Not supported by Opera', // MISSING enable : 'Abilita COMS', disable : 'Disabilita COMS', about : 'About COMS', toggle : 'Inverti abilitazione SCOMS', options : 'Opzioni', langs : 'Lingue', moreSuggestions : 'Altri suggerimenti', ignore : 'Ignora', ignoreAll : 'Ignora tutti', addWord : 'Aggiungi Parola', emptyDic : 'Il nome del dizionario non può essere vuoto.', optionsTab : 'Opzioni', allCaps : 'Ignore All-Caps Words', // MISSING ignoreDomainNames : 'Ignore Domain Names', // MISSING mixedCase : 'Ignore Words with Mixed Case', // MISSING mixedWithDigits : 'Ignore Words with Numbers', // MISSING languagesTab : 'Lingue', dictionariesTab : 'Dizionari', dic_field_name : 'Dictionary name', // MISSING dic_create : 'Create', // MISSING dic_restore : 'Restore', // MISSING dic_delete : 'Delete', // MISSING dic_rename : 'Rename', // MISSING dic_info : 'Initially the User Dictionary is stored in a Cookie. However, Cookies are limited in size. When the User Dictionary grows to a point where it cannot be stored in a Cookie, then the dictionary may be stored on our server. To store your personal dictionary on our server you should specify a name for your dictionary. If you already have a stored dictionary, please type its name and click the Restore button.', // MISSING aboutTab : 'About' }, about : { title : 'About CKEditor', dlgTitle : 'About CKEditor', moreInfo : 'Per le informazioni sulla licenza si prega di visitare il nostro sito:', copy : 'Copyright &copy; $1. Tutti i diritti riservati.' }, maximize : 'Massimizza', minimize : 'Minimize', // MISSING fakeobjects : { anchor : 'Ancora', flash : 'Animazione Flash', iframe : 'iFrame', // MISSING hiddenfield : 'Hidden Field', // MISSING unknown : 'Oggetto sconosciuto' }, resize : 'Trascina per ridimensionare', colordialog : { title : 'Select color', // MISSING options : 'Color Options', // MISSING highlight : 'Highlight', // MISSING selected : 'Selected Color', // MISSING clear : 'Clear' // MISSING }, toolbarCollapse : 'Collapse Toolbar', // MISSING toolbarExpand : 'Expand Toolbar', // MISSING bidi : { ltr : 'Text direction from left to right', // MISSING rtl : 'Text direction from right to left' // MISSING } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.lang} object, for the * German language. */ /**#@+ @type String @example */ /** * Constains the dictionary of language entries. * @namespace */ CKEDITOR.lang['de'] = { /** * The language reading direction. Possible values are "rtl" for * Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right * languages (like English). * @default 'ltr' */ dir : 'ltr', /* * Screenreader titles. Please note that screenreaders are not always capable * of reading non-English words. So be careful while translating it. */ editorTitle : 'Rich text editor, %1, press ALT 0 for help.', // MISSING // ARIA descriptions. toolbar : 'Toolbar', // MISSING editor : 'Rich Text Editor', // MISSING // Toolbar buttons without dialogs. source : 'Quellcode', newPage : 'Neue Seite', save : 'Speichern', preview : 'Vorschau', cut : 'Ausschneiden', copy : 'Kopieren', paste : 'Einfügen', print : 'Drucken', underline : 'Unterstrichen', bold : 'Fett', italic : 'Kursiv', selectAll : 'Alles auswählen', removeFormat : 'Formatierungen entfernen', strike : 'Durchgestrichen', subscript : 'Tiefgestellt', superscript : 'Hochgestellt', horizontalrule : 'Horizontale Linie einfügen', pagebreak : 'Seitenumbruch einfügen', pagebreakAlt : 'Page Break', // MISSING unlink : 'Link entfernen', undo : 'Rückgängig', redo : 'Wiederherstellen', // Common messages and labels. common : { browseServer : 'Server durchsuchen', url : 'URL', protocol : 'Protokoll', upload : 'Upload', uploadSubmit : 'Zum Server senden', image : 'Bild', flash : 'Flash', form : 'Formular', checkbox : 'Checkbox', radio : 'Radiobutton', textField : 'Textfeld einzeilig', textarea : 'Textfeld mehrzeilig', hiddenField : 'verstecktes Feld', button : 'Klickbutton', select : 'Auswahlfeld', imageButton : 'Bildbutton', notSet : '<nichts>', id : 'ID', name : 'Name', langDir : 'Schreibrichtung', langDirLtr : 'Links nach Rechts (LTR)', langDirRtl : 'Rechts nach Links (RTL)', langCode : 'Sprachenkürzel', longDescr : 'Langform URL', cssClass : 'Stylesheet Klasse', advisoryTitle : 'Titel Beschreibung', cssStyle : 'Style', ok : 'OK', cancel : 'Abbrechen', close : 'Schließen', preview : 'Vorschau', generalTab : 'Allgemein', advancedTab : 'Erweitert', validateNumberFailed : 'Dieser Wert ist keine Nummer.', confirmNewPage : 'Alle nicht gespeicherten Änderungen gehen verlohren. Sind sie sicher die neue Seite zu laden?', confirmCancel : 'Einige Optionen wurden geändert. Wollen Sie den Dialog dennoch schließen?', options : 'Optionen', target : 'Zielseite', targetNew : 'Neues Fenster (_blank)', targetTop : 'Oberstes Fenster (_top)', targetSelf : 'Gleiches Fenster (_self)', targetParent : 'Oberes Fenster (_parent)', langDirLTR : 'Links nach Rechts (LNR)', langDirRTL : 'Rechts nach Links (RNL)', styles : 'Style', cssClasses : 'Stylesheet Klasse', width : 'Breite', height : 'Höhe', align : 'Ausrichtung', alignLeft : 'Links', alignRight : 'Rechts', alignCenter : 'Zentriert', alignTop : 'Oben', alignMiddle : 'Mitte', alignBottom : 'Unten', invalidHeight : 'Höhe muss eine Zahl sein.', invalidWidth : 'Breite muss eine Zahl sein.', // Put the voice-only part of the label in the span. unavailable : '%1<span class="cke_accessibility">, nicht verfügbar</span>' }, contextmenu : { options : 'Context Menu Optionen' }, // Special char dialog. specialChar : { toolbar : 'Sonderzeichen einfügen/editieren', title : 'Sonderzeichen auswählen', options : 'Sonderzeichen Optionen' }, // Link dialog. link : { toolbar : 'Link einfügen/editieren', other : '<andere>', menu : 'Link editieren', title : 'Link', info : 'Link-Info', target : 'Zielseite', upload : 'Upload', advanced : 'Erweitert', type : 'Link-Typ', toUrl : 'URL', toAnchor : 'Anker in dieser Seite', toEmail : 'E-Mail', targetFrame : '<Frame>', targetPopup : '<Pop-up Fenster>', targetFrameName : 'Ziel-Fenster-Name', targetPopupName : 'Pop-up Fenster-Name', popupFeatures : 'Pop-up Fenster-Eigenschaften', popupResizable : 'Größe änderbar', popupStatusBar : 'Statusleiste', popupLocationBar: 'Adress-Leiste', popupToolbar : 'Werkzeugleiste', popupMenuBar : 'Menü-Leiste', popupFullScreen : 'Vollbild (IE)', popupScrollBars : 'Rollbalken', popupDependent : 'Abhängig (Netscape)', popupLeft : 'Linke Position', popupTop : 'Obere Position', id : 'Id', langDir : 'Schreibrichtung', langDirLTR : 'Links nach Rechts (LTR)', langDirRTL : 'Rechts nach Links (RTL)', acccessKey : 'Zugriffstaste', name : 'Name', langCode : 'Schreibrichtung', tabIndex : 'Tab-Index', advisoryTitle : 'Titel Beschreibung', advisoryContentType : 'Inhaltstyp', cssClasses : 'Stylesheet Klasse', charset : 'Ziel-Zeichensatz', styles : 'Style', selectAnchor : 'Anker auswählen', anchorName : 'nach Anker Name', anchorId : 'nach Element Id', emailAddress : 'E-Mail Addresse', emailSubject : 'Betreffzeile', emailBody : 'Nachrichtentext', noAnchors : '(keine Anker im Dokument vorhanden)', noUrl : 'Bitte geben Sie die Link-URL an', noEmail : 'Bitte geben Sie e-Mail Adresse an' }, // Anchor dialog anchor : { toolbar : 'Anker einfügen/editieren', menu : 'Anker-Eigenschaften', title : 'Anker-Eigenschaften', name : 'Anker Name', errorName : 'Bitte geben Sie den Namen des Ankers ein' }, // List style dialog list: { numberedTitle : 'Nummerierte Listen-Eigenschaften', bulletedTitle : 'Listen-Eigenschaften', type : 'Typ', start : 'Start', validateStartNumber :'List Startnummer muss eine ganze Zahl sein.', circle : 'Ring', disc : 'Kreis', square : 'Quadrat', none : 'Keine', notset : '<nicht gesetzt>', armenian : 'Armenisch Nummerierung', georgian : 'Georgisch Nummerierung (an, ban, gan, etc.)', lowerRoman : 'Klein römisch (i, ii, iii, iv, v, etc.)', upperRoman : 'Groß römisch (I, II, III, IV, V, etc.)', lowerAlpha : 'Klein alpha (a, b, c, d, e, etc.)', upperAlpha : 'Groß alpha (A, B, C, D, E, etc.)', lowerGreek : 'Klein griechisch (alpha, beta, gamma, etc.)', decimal : 'Dezimal (1, 2, 3, etc.)', decimalLeadingZero : 'Dezimal mit führende Null (01, 02, 03, etc.)' }, // Find And Replace Dialog findAndReplace : { title : 'Suchen und Ersetzen', find : 'Suchen', replace : 'Ersetzen', findWhat : 'Suche nach:', replaceWith : 'Ersetze mit:', notFoundMsg : 'Der gesuchte Text wurde nicht gefunden.', matchCase : 'Groß-Kleinschreibung beachten', matchWord : 'Nur ganze Worte suchen', matchCyclic : 'zyklische suche', replaceAll : 'Alle Ersetzen', replaceSuccessMsg : '%1 vorkommen ersetzt.' }, // Table Dialog table : { toolbar : 'Tabelle', title : 'Tabellen-Eigenschaften', menu : 'Tabellen-Eigenschaften', deleteTable : 'Tabelle löschen', rows : 'Zeile', columns : 'Spalte', border : 'Rahmen', widthPx : 'Pixel', widthPc : '%', widthUnit : 'Breite Einheit', cellSpace : 'Zellenabstand außen', cellPad : 'Zellenabstand innen', caption : 'Überschrift', summary : 'Inhaltsübersicht', headers : 'Headers', headersNone : 'Keine', headersColumn : 'Erste Spalte', headersRow : 'Erste Zeile', headersBoth : 'Beide', invalidRows : 'Die Anzahl der Zeilen muß größer als 0 sein.', invalidCols : 'Die Anzahl der Spalten muß größer als 0 sein..', invalidBorder : 'Die Rahmenbreite muß eine Zahl sein.', invalidWidth : 'Die Tabellenbreite muss eine Zahl sein.', invalidHeight : 'Die Tabellenbreite muß eine Zahl sein.', invalidCellSpacing : 'Der Zellenabstand außen muß eine Zahl sein.', invalidCellPadding : 'Der Zellenabstand innen muß eine Zahl sein.', cell : { menu : 'Zelle', insertBefore : 'Zelle davor einfügen', insertAfter : 'Zelle danach einfügen', deleteCell : 'Zelle löschen', merge : 'Zellen verbinden', mergeRight : 'nach rechts verbinden', mergeDown : 'nach unten verbinden', splitHorizontal : 'Zelle horizontal teilen', splitVertical : 'Zelle vertikal teilen', title : 'Zellen Eigenschaften', cellType : 'Zellart', rowSpan : 'Anzahl Zeilen verbinden', colSpan : 'Anzahl Spalten verbinden', wordWrap : 'Zeilenumbruch', hAlign : 'Horizontale Ausrichtung', vAlign : 'Vertikale Ausrichtung', alignBaseline : 'Grundlinie', bgColor : 'Hintergrundfarbe', borderColor : 'Rahmenfarbe', data : 'Daten', header : 'Überschrift', yes : 'Ja', no : 'Nein', invalidWidth : 'Zellenbreite muß eine Zahl sein.', invalidHeight : 'Zellenhöhe muß eine Zahl sein.', invalidRowSpan : '"Anzahl Zeilen verbinden" muss eine Ganzzahl sein.', invalidColSpan : '"Anzahl Spalten verbinden" muss eine Ganzzahl sein.', chooseColor : 'Wählen' }, row : { menu : 'Zeile', insertBefore : 'Zeile oberhalb einfügen', insertAfter : 'Zeile unterhalb einfügen', deleteRow : 'Zeile entfernen' }, column : { menu : 'Spalte', insertBefore : 'Spalte links davor einfügen', insertAfter : 'Spalte rechts danach einfügen', deleteColumn : 'Spalte löschen' } }, // Button Dialog. button : { title : 'Button-Eigenschaften', text : 'Text (Wert)', type : 'Typ', typeBtn : 'Button', typeSbm : 'Absenden', typeRst : 'Zurücksetzen' }, // Checkbox and Radio Button Dialogs. checkboxAndRadio : { checkboxTitle : 'Checkbox-Eigenschaften', radioTitle : 'Optionsfeld-Eigenschaften', value : 'Wert', selected : 'ausgewählt' }, // Form Dialog. form : { title : 'Formular-Eigenschaften', menu : 'Formular-Eigenschaften', action : 'Action', method : 'Method', encoding : 'Zeichenkodierung' }, // Select Field Dialog. select : { title : 'Auswahlfeld-Eigenschaften', selectInfo : 'Info', opAvail : 'Mögliche Optionen', value : 'Wert', size : 'Größe', lines : 'Linien', chkMulti : 'Erlaube Mehrfachauswahl', opText : 'Text', opValue : 'Wert', btnAdd : 'Hinzufügen', btnModify : 'Ändern', btnUp : 'Hoch', btnDown : 'Runter', btnSetValue : 'Setze als Standardwert', btnDelete : 'Entfernen' }, // Textarea Dialog. textarea : { title : 'Textfeld (mehrzeilig) Eigenschaften', cols : 'Spalten', rows : 'Reihen' }, // Text Field Dialog. textfield : { title : 'Textfeld (einzeilig) Eigenschaften', name : 'Name', value : 'Wert', charWidth : 'Zeichenbreite', maxChars : 'Max. Zeichen', type : 'Typ', typeText : 'Text', typePass : 'Passwort' }, // Hidden Field Dialog. hidden : { title : 'Verstecktes Feld-Eigenschaften', name : 'Name', value : 'Wert' }, // Image Dialog. image : { title : 'Bild-Eigenschaften', titleButton : 'Bildbutton-Eigenschaften', menu : 'Bild-Eigenschaften', infoTab : 'Bild-Info', btnUpload : 'Zum Server senden', upload : 'Hochladen', alt : 'Alternativer Text', lockRatio : 'Größenverhältnis beibehalten', unlockRatio : 'Ratio Freischalten', resetSize : 'Größe zurücksetzen', border : 'Rahmen', hSpace : 'Horizontal-Abstand', vSpace : 'Vertikal-Abstand', alertUrl : 'Bitte geben Sie die Bild-URL an', linkTab : 'Link', button2Img : 'Möchten Sie den gewählten Bild-Button in ein einfaches Bild umwandeln?', img2Button : 'Möchten Sie das gewählten Bild in einen Bild-Button umwandeln?', urlMissing : 'Imagequelle URL fehlt.', validateBorder : 'Rahmen muß eine ganze Zahl sein.', validateHSpace : 'Horizontal-Abstand muß eine ganze Zahl sein.', validateVSpace : 'Vertikal-Abstand must be a whole number.' }, // Flash Dialog flash : { properties : 'Flash-Eigenschaften', propertiesTab : 'Eigenschaften', title : 'Flash-Eigenschaften', chkPlay : 'autom. Abspielen', chkLoop : 'Endlosschleife', chkMenu : 'Flash-Menü aktivieren', chkFull : 'Vollbildmodus erlauben', scale : 'Skalierung', scaleAll : 'Alles anzeigen', scaleNoBorder : 'ohne Rand', scaleFit : 'Passgenau', access : 'Skript Zugang', accessAlways : 'Immer', accessSameDomain: 'Gleiche Domain', accessNever : 'Nie', alignAbsBottom : 'Abs Unten', alignAbsMiddle : 'Abs Mitte', alignBaseline : 'Baseline', alignTextTop : 'Text Oben', quality : 'Qualität', qualityBest : 'Beste', qualityHigh : 'Hoch', qualityAutoHigh : 'Auto Hoch', qualityMedium : 'Medium', qualityAutoLow : 'Auto Niedrig', qualityLow : 'Niedrig', windowModeWindow: 'Fenster', windowModeOpaque: 'Deckend', windowModeTransparent : 'Transparent', windowMode : 'Fenster Modus', flashvars : 'Variablen für Flash', bgcolor : 'Hintergrundfarbe', hSpace : 'Horizontal-Abstand', vSpace : 'Vertikal-Abstand', validateSrc : 'Bitte geben Sie die Link-URL an', validateHSpace : 'HSpace muss eine Zahl sein.', validateVSpace : 'VSpace muss eine Zahl sein.' }, // Speller Pages Dialog spellCheck : { toolbar : 'Rechtschreibprüfung', title : 'Rechtschreibprüfung', notAvailable : 'Entschuldigung, aber dieser Dienst steht im Moment nicht zur verfügung.', errorLoading : 'Fehler beim laden des Dienstanbieters: %s.', notInDic : 'Nicht im Wörterbuch', changeTo : 'Ändern in', btnIgnore : 'Ignorieren', btnIgnoreAll : 'Alle Ignorieren', btnReplace : 'Ersetzen', btnReplaceAll : 'Alle Ersetzen', btnUndo : 'Rückgängig', noSuggestions : ' - keine Vorschläge - ', progress : 'Rechtschreibprüfung läuft...', noMispell : 'Rechtschreibprüfung abgeschlossen - keine Fehler gefunden', noChanges : 'Rechtschreibprüfung abgeschlossen - keine Worte geändert', oneChange : 'Rechtschreibprüfung abgeschlossen - ein Wort geändert', manyChanges : 'Rechtschreibprüfung abgeschlossen - %1 Wörter geändert', ieSpellDownload : 'Rechtschreibprüfung nicht installiert. Möchten Sie sie jetzt herunterladen?' }, smiley : { toolbar : 'Smiley', title : 'Smiley auswählen', options : 'Smiley Optionen' }, elementsPath : { eleLabel : 'Elements Pfad', eleTitle : '%1 Element' }, numberedlist : 'Nummerierte Liste', bulletedlist : 'Liste', indent : 'Einzug erhöhen', outdent : 'Einzug verringern', justify : { left : 'Linksbündig', center : 'Zentriert', right : 'Rechtsbündig', block : 'Blocksatz' }, blockquote : 'Zitatblock', clipboard : { title : 'Einfügen', cutError : 'Die Sicherheitseinstellungen Ihres Browsers lassen es nicht zu, den Text automatisch auszuschneiden. Bitte benutzen Sie die System-Zwischenablage über STRG-X (ausschneiden) und STRG-V (einfügen).', copyError : 'Die Sicherheitseinstellungen Ihres Browsers lassen es nicht zu, den Text automatisch kopieren. Bitte benutzen Sie die System-Zwischenablage über STRG-C (kopieren).', pasteMsg : 'Bitte fügen Sie den Text in der folgenden Box über die Tastatur (mit <STRONG>Strg+V</STRONG>) ein und bestätigen Sie mit <STRONG>OK</STRONG>.', securityMsg : 'Aufgrund von Sicherheitsbeschränkungen Ihres Browsers kann der Editor nicht direkt auf die Zwischenablage zugreifen. Bitte fügen Sie den Inhalt erneut in diesem Fenster ein.', pasteArea : 'Einfügebereich' }, pastefromword : { confirmCleanup : 'Der Text, den Sie einfügen möchten, scheint aus MS-Word kopiert zu sein. Möchten Sie ihn zuvor bereinigen lassen?', toolbar : 'aus MS-Word einfügen', title : 'aus MS-Word einfügen', error : 'Aufgrund eines internen Fehlers war es nicht möglich die eingefügten Daten zu bereinigen' }, pasteText : { button : 'Als Text einfügen', title : 'Als Text einfügen' }, templates : { button : 'Vorlagen', title : 'Vorlagen', options : 'Vorlagen Optionen', insertOption : 'Aktuellen Inhalt ersetzen', selectPromptMsg : 'Klicken Sie auf eine Vorlage, um sie im Editor zu öffnen (der aktuelle Inhalt wird dabei gelöscht!):', emptyListMsg : '(keine Vorlagen definiert)' }, showBlocks : 'Blöcke anzeigen', stylesCombo : { label : 'Stil', panelTitle : 'Formatierungenstil', panelTitle1 : 'Block Stilart', panelTitle2 : 'Inline Stilart', panelTitle3 : 'Objekt Stilart' }, format : { label : 'Format', panelTitle : 'Format', tag_p : 'Normal', tag_pre : 'Formatiert', tag_address : 'Addresse', tag_h1 : 'Überschrift 1', tag_h2 : 'Überschrift 2', tag_h3 : 'Überschrift 3', tag_h4 : 'Überschrift 4', tag_h5 : 'Überschrift 5', tag_h6 : 'Überschrift 6', tag_div : 'Normal (DIV)' }, div : { title : 'Div Container erzeugen', toolbar : 'Div Container erzeugen', cssClassInputLabel : 'Stylesheet Klasse', styleSelectLabel : 'Stil', IdInputLabel : 'Id', languageCodeInputLabel : ' Sprache Code', inlineStyleInputLabel : 'Inline Style', advisoryTitleInputLabel : 'Beratungs Titel', langDirLabel : 'Sprache Richtung', langDirLTRLabel : 'Links nach Rechs (LTR)', langDirRTLLabel : 'Rechs nach Links (RTL)', edit : 'Div Bearbeiten', remove : 'Div Entfernen' }, iframe : { title : 'iFrame Properties', // MISSING toolbar : 'iFrame', // MISSING noUrl : 'Please type the iFrame URL', // MISSING scrolling : 'Enable scrollbars', // MISSING border : 'Show frame border' // MISSING }, font : { label : 'Schriftart', voiceLabel : 'Schriftart', panelTitle : 'Schriftart' }, fontSize : { label : 'Größe', voiceLabel : 'Schrifgröße', panelTitle : 'Größe' }, colorButton : { textColorTitle : 'Textfarbe', bgColorTitle : 'Hintergrundfarbe', panelTitle : 'Farben', auto : 'Automatisch', more : 'Weitere Farben...' }, colors : { '000' : 'Schwarz', '800000' : 'Kastanienbraun', '8B4513' : 'Braun', '2F4F4F' : 'Dunkles Schiefergrau', '008080' : 'Blaugrün', '000080' : 'Navy', '4B0082' : 'Indigo', '696969' : 'Dunkelgrau', 'B22222' : 'Ziegelrot', 'A52A2A' : 'Braun', 'DAA520' : 'Goldgelb', '006400' : 'Dunkelgrün', '40E0D0' : 'Türkis', '0000CD' : 'Medium Blau', '800080' : 'Lila', '808080' : 'Grau', 'F00' : 'Rot', 'FF8C00' : 'Dunkelorange', 'FFD700' : 'Gold', '008000' : 'Grün', '0FF' : 'Cyan', '00F' : 'Blau', 'EE82EE' : 'Hellviolett', 'A9A9A9' : 'Dunkelgrau', 'FFA07A' : 'Helles Lachsrosa', 'FFA500' : 'Orange', 'FFFF00' : 'Gelb', '00FF00' : 'Lime', 'AFEEEE' : 'Blaß-Türkis', 'ADD8E6' : 'Hellblau', 'DDA0DD' : 'Pflaumenblau', 'D3D3D3' : 'Hellgrau', 'FFF0F5' : 'Lavendel', 'FAEBD7' : 'Antik Weiß', 'FFFFE0' : 'Hellgelb', 'F0FFF0' : 'Honigtau', 'F0FFFF' : 'Azurblau', 'F0F8FF' : 'Alice Blau', 'E6E6FA' : 'Lavendel', 'FFF' : 'Weiß' }, scayt : { title : 'Rechtschreibprüfung während der Texteingabe', opera_title : 'Nicht von Opera unterstützt', enable : 'SCAYT einschalten', disable : 'SCAYT ausschalten', about : 'Über SCAYT', toggle : 'SCAYT umschalten', options : 'Optionen', langs : 'Sprachen', moreSuggestions : 'Mehr Vorschläge', ignore : 'Ignorieren', ignoreAll : 'Alle ignorieren', addWord : 'Wort hinzufügen', emptyDic : 'Wörterbuchname sollte leer sein.', optionsTab : 'Optionen', allCaps : 'Groß geschriebenen Wörter ignorieren', ignoreDomainNames : 'Domain-Namen ignorieren', mixedCase : 'Wörter mit gemischte Setzkasten ignorieren', mixedWithDigits : 'Wörter mit Zahlen ignorieren', languagesTab : 'Sprachen', dictionariesTab : 'Wörterbücher', dic_field_name : 'Wörterbuchname', dic_create : 'Erzeugen', dic_restore : 'Wiederherstellen', dic_delete : 'Löschen', dic_rename : 'Umbenennen', dic_info : 'Anfangs wird das Benutzerwörterbuch in einem Cookie gespeichert. Allerdings sind Cookies in der Größe begrenzt. Wenn das Benutzerwörterbuch bis zu einem Punkt wächst, wo es nicht mehr in einem Cookie gespeichert werden kann, wird das Benutzerwörterbuch auf dem Server gespeichert. Um Ihr persönliches Wörterbuch auf dem Server zu speichern, müssen Sie einen Namen für das Wörterbuch angeben. Falls Sie schon ein gespeicherte Wörterbuch haben, geben Sie bitte dessen Namen ein und klicken Sie auf die Schaltfläche Wiederherstellen.', aboutTab : 'Über' }, about : { title : 'Über CKEditor', dlgTitle : 'Über CKEditor', moreInfo : 'Für Informationen über unsere Lizenzbestimmungen besuchen sie bitte unsere Webseite:', copy : 'Copyright &copy; $1. Alle Rechte vorbehalten.' }, maximize : 'Maximieren', minimize : 'Minimieren', fakeobjects : { anchor : 'Anker', flash : 'Flash Animation', iframe : 'iFrame', // MISSING hiddenfield : 'Hidden Field', // MISSING unknown : 'Unbekanntes Objekt' }, resize : 'Zum Vergrößern ziehen', colordialog : { title : 'Farbe wählen', options : 'Farbeoptionen', highlight : 'Hervorheben', selected : 'Ausgewählte Farbe', clear : 'Entfernen' }, toolbarCollapse : 'Symbolleiste einklappen', toolbarExpand : 'Symbolleiste ausklappen', bidi : { ltr : 'Leserichtung von Links nach Rechts', rtl : 'Leserichtung von Rechts nach Links' } };
JavaScript
/* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved. For licensing, see LICENSE.html or http://ckeditor.com/license */ /** * @fileOverview Defines the {@link CKEDITOR.lang} object, for the * Polish language. */ /**#@+ @type String @example */ /** * Constains the dictionary of language entries. * @namespace */ CKEDITOR.lang['pl'] = { /** * The language reading direction. Possible values are "rtl" for * Right-To-Left languages (like Arabic) and "ltr" for Left-To-Right * languages (like English). * @default 'ltr' */ dir : 'ltr', /* * Screenreader titles. Please note that screenreaders are not always capable * of reading non-English words. So be careful while translating it. */ editorTitle : 'Rich text editor, %1, press ALT 0 for help.', // MISSING // ARIA descriptions. toolbar : 'Toolbar', // MISSING editor : 'Rich Text Editor', // MISSING // Toolbar buttons without dialogs. source : 'Źródło dokumentu', newPage : 'Nowa strona', save : 'Zapisz', preview : 'Podgląd', cut : 'Wytnij', copy : 'Kopiuj', paste : 'Wklej', print : 'Drukuj', underline : 'Podkreślenie', bold : 'Pogrubienie', italic : 'Kursywa', selectAll : 'Zaznacz wszystko', removeFormat : 'Usuń formatowanie', strike : 'Przekreślenie', subscript : 'Indeks dolny', superscript : 'Indeks górny', horizontalrule : 'Wstaw poziomą linię', pagebreak : 'Wstaw odstęp', pagebreakAlt : 'Page Break', // MISSING unlink : 'Usuń hiperłącze', undo : 'Cofnij', redo : 'Ponów', // Common messages and labels. common : { browseServer : 'Przeglądaj', url : 'Adres URL', protocol : 'Protokół', upload : 'Wyślij', uploadSubmit : 'Wyślij', image : 'Obrazek', flash : 'Flash', form : 'Formularz', checkbox : 'Pole wyboru (checkbox)', radio : 'Pole wyboru (radio)', textField : 'Pole tekstowe', textarea : 'Obszar tekstowy', hiddenField : 'Pole ukryte', button : 'Przycisk', select : 'Lista wyboru', imageButton : 'Przycisk-obrazek', notSet : '<nie ustawione>', id : 'Id', name : 'Nazwa', langDir : 'Kierunek tekstu', langDirLtr : 'Od lewej do prawej (LTR)', langDirRtl : 'Od prawej do lewej (RTL)', langCode : 'Kod języka', longDescr : 'Długi opis hiperłącza', cssClass : 'Nazwa klasy CSS', advisoryTitle : 'Opis obiektu docelowego', cssStyle : 'Styl', ok : 'OK', cancel : 'Anuluj', close : 'Close', // MISSING preview : 'Preview', // MISSING generalTab : 'Ogólne', advancedTab : 'Zaawansowane', validateNumberFailed : 'Ta wartość nie jest liczbą.', confirmNewPage : 'Wszystkie niezapisane zmiany zostaną utracone. Czy na pewno wczytać nową stronę?', confirmCancel : 'Pewne opcje zostały zmienione. Czy na pewno zamknąć okno dialogowe?', options : 'Options', // MISSING target : 'Target', // MISSING targetNew : 'New Window (_blank)', // MISSING targetTop : 'Topmost Window (_top)', // MISSING targetSelf : 'Same Window (_self)', // MISSING targetParent : 'Parent Window (_parent)', // MISSING langDirLTR : 'Left to Right (LTR)', // MISSING langDirRTL : 'Right to Left (RTL)', // MISSING styles : 'Style', // MISSING cssClasses : 'Stylesheet Classes', // MISSING width : 'Szerokość', height : 'Wysokość', align : 'Wyrównaj', alignLeft : 'Do lewej', alignRight : 'Do prawej', alignCenter : 'Do środka', alignTop : 'Do góry', alignMiddle : 'Do środka', alignBottom : 'Do dołu', invalidHeight : 'Wysokość musi być liczbą.', invalidWidth : 'Szerokość musi być liczbą.', // Put the voice-only part of the label in the span. unavailable : '%1<span class="cke_accessibility">, niedostępne</span>' }, contextmenu : { options : 'Context Menu Options' // MISSING }, // Special char dialog. specialChar : { toolbar : 'Wstaw znak specjalny', title : 'Wybierz znak specjalny', options : 'Special Character Options' // MISSING }, // Link dialog. link : { toolbar : 'Wstaw/edytuj hiperłącze', other : '<inny>', menu : 'Edytuj hiperłącze', title : 'Hiperłącze', info : 'Informacje ', target : 'Cel', upload : 'Wyślij', advanced : 'Zaawansowane', type : 'Typ hiperłącza', toUrl : 'URL', // MISSING toAnchor : 'Odnośnik wewnątrz strony', toEmail : 'Adres e-mail', targetFrame : '<ramka>', targetPopup : '<wyskakujące okno>', targetFrameName : 'Nazwa Ramki Docelowej', targetPopupName : 'Nazwa wyskakującego okna', popupFeatures : 'Właściwości wyskakującego okna', popupResizable : 'Skalowalny', popupStatusBar : 'Pasek statusu', popupLocationBar: 'Pasek adresu', popupToolbar : 'Pasek narzędzi', popupMenuBar : 'Pasek menu', popupFullScreen : 'Pełny ekran (IE)', popupScrollBars : 'Paski przewijania', popupDependent : 'Okno zależne (Netscape)', popupLeft : 'Pozycja w poziomie', popupTop : 'Pozycja w pionie', id : 'Id', langDir : 'Kierunek tekstu', langDirLTR : 'Od lewej do prawej (LTR)', langDirRTL : 'Od prawej do lewej (RTL)', acccessKey : 'Klawisz dostępu', name : 'Nazwa', langCode : 'Kierunek tekstu', tabIndex : 'Indeks tabeli', advisoryTitle : 'Opis obiektu docelowego', advisoryContentType : 'Typ MIME obiektu docelowego', cssClasses : 'Nazwa klasy CSS', charset : 'Kodowanie znaków obiektu docelowego', styles : 'Styl', selectAnchor : 'Wybierz etykietę', anchorName : 'Wg etykiety', anchorId : 'Wg identyfikatora elementu', emailAddress : 'Adres e-mail', emailSubject : 'Temat', emailBody : 'Treść', noAnchors : '(W dokumencie nie zdefiniowano żadnych etykiet)', noUrl : 'Podaj adres URL', noEmail : 'Podaj adres e-mail' }, // Anchor dialog anchor : { toolbar : 'Wstaw/edytuj kotwicę', menu : 'Właściwości kotwicy', title : 'Właściwości kotwicy', name : 'Nazwa kotwicy', errorName : 'Wpisz nazwę kotwicy' }, // List style dialog list: { numberedTitle : 'Numbered List Properties', // MISSING bulletedTitle : 'Bulleted List Properties', // MISSING type : 'Type', // MISSING start : 'Start', // MISSING validateStartNumber :'List start number must be a whole number.', // MISSING circle : 'Circle', // MISSING disc : 'Disc', // MISSING square : 'Square', // MISSING none : 'None', // MISSING notset : '<not set>', // MISSING armenian : 'Armenian numbering', // MISSING georgian : 'Georgian numbering (an, ban, gan, etc.)', // MISSING lowerRoman : 'Lower Roman (i, ii, iii, iv, v, etc.)', // MISSING upperRoman : 'Upper Roman (I, II, III, IV, V, etc.)', // MISSING lowerAlpha : 'Lower Alpha (a, b, c, d, e, etc.)', // MISSING upperAlpha : 'Upper Alpha (A, B, C, D, E, etc.)', // MISSING lowerGreek : 'Lower Greek (alpha, beta, gamma, etc.)', // MISSING decimal : 'Decimal (1, 2, 3, etc.)', // MISSING decimalLeadingZero : 'Decimal leading zero (01, 02, 03, etc.)' // MISSING }, // Find And Replace Dialog findAndReplace : { title : 'Znajdź i zamień', find : 'Znajdź', replace : 'Zamień', findWhat : 'Znajdź:', replaceWith : 'Zastąp przez:', notFoundMsg : 'Nie znaleziono szukanego hasła.', matchCase : 'Uwzględnij wielkość liter', matchWord : 'Całe słowa', matchCyclic : 'Cykliczne dopasowanie', replaceAll : 'Zastąp wszystko', replaceSuccessMsg : '%1 wystąpień zastąpionych.' }, // Table Dialog table : { toolbar : 'Tabela', title : 'Właściwości tabeli', menu : 'Właściwości tabeli', deleteTable : 'Usuń tabelę', rows : 'Liczba wierszy', columns : 'Liczba kolumn', border : 'Grubość ramki', widthPx : 'piksele', widthPc : '%', widthUnit : 'width unit', // MISSING cellSpace : 'Odstęp pomiędzy komórkami', cellPad : 'Margines wewnętrzny komórek', caption : 'Tytuł', summary : 'Podsumowanie', headers : 'Nagłowki', headersNone : 'Brak', headersColumn : 'Pierwsza kolumna', headersRow : 'Pierwszy wiersz', headersBoth : 'Oba', invalidRows : 'Liczba wierszy musi być liczbą większą niż 0.', invalidCols : 'Liczba kolumn musi być liczbą większą niż 0.', invalidBorder : 'Liczba obramowań musi być liczbą.', invalidWidth : 'Szerokość tabeli musi być liczbą.', invalidHeight : 'Wysokość tabeli musi być liczbą.', invalidCellSpacing : 'Odstęp komórek musi być liczbą.', invalidCellPadding : 'Dopełnienie komórek musi być liczbą.', cell : { menu : 'Komórka', insertBefore : 'Wstaw komórkę z lewej', insertAfter : 'Wstaw komórkę z prawej', deleteCell : 'Usuń komórki', merge : 'Połącz komórki', mergeRight : 'Połącz z komórką z prawej', mergeDown : 'Połącz z komórką poniżej', splitHorizontal : 'Podziel komórkę poziomo', splitVertical : 'Podziel komórkę pionowo', title : 'Właściwości komórki', cellType : 'Typ komórki', rowSpan : 'Scalenie wierszy', colSpan : 'Scalenie komórek', wordWrap : 'Zawijanie słów', hAlign : 'Wyrównanie poziome', vAlign : 'Wyrównanie pionowe', alignBaseline : 'Linia bazowa', bgColor : 'Kolor tła', borderColor : 'Kolor obramowania', data : 'Dane', header : 'Nagłowek', yes : 'Tak', no : 'Nie', invalidWidth : 'Szerokość komórki musi być liczbą.', invalidHeight : 'Wysokość komórki musi być liczbą.', invalidRowSpan : 'Scalenie wierszy musi być liczbą całkowitą.', invalidColSpan : 'Scalenie komórek musi być liczbą całkowitą.', chooseColor : 'Wybierz' }, row : { menu : 'Wiersz', insertBefore : 'Wstaw wiersz powyżej', insertAfter : 'Wstaw wiersz poniżej', deleteRow : 'Usuń wiersze' }, column : { menu : 'Kolumna', insertBefore : 'Wstaw kolumnę z lewej', insertAfter : 'Wstaw kolumnę z prawej', deleteColumn : 'Usuń kolumny' } }, // Button Dialog. button : { title : 'Właściwości przycisku', text : 'Tekst (Wartość)', type : 'Typ', typeBtn : 'Przycisk', typeSbm : 'Wyślij', typeRst : 'Wyzeruj' }, // Checkbox and Radio Button Dialogs. checkboxAndRadio : { checkboxTitle : 'Właściwości pola wyboru (checkbox)', radioTitle : 'Właściwości pola wyboru (radio)', value : 'Wartość', selected : 'Zaznaczone' }, // Form Dialog. form : { title : 'Właściwości formularza', menu : 'Właściwości formularza', action : 'Akcja', method : 'Metoda', encoding : 'Kodowanie' }, // Select Field Dialog. select : { title : 'Właściwości listy wyboru', selectInfo : 'Informacje', opAvail : 'Dostępne opcje', value : 'Wartość', size : 'Rozmiar', lines : 'linii', chkMulti : 'Wielokrotny wybór', opText : 'Tekst', opValue : 'Wartość', btnAdd : 'Dodaj', btnModify : 'Zmień', btnUp : 'Do góry', btnDown : 'Do dołu', btnSetValue : 'Ustaw wartość zaznaczoną', btnDelete : 'Usuń' }, // Textarea Dialog. textarea : { title : 'Właściwości obszaru tekstowego', cols : 'Kolumnu', rows : 'Wiersze' }, // Text Field Dialog. textfield : { title : 'Właściwości pola tekstowego', name : 'Nazwa', value : 'Wartość', charWidth : 'Szerokość w znakach', maxChars : 'Max. szerokość', type : 'Typ', typeText : 'Tekst', typePass : 'Hasło' }, // Hidden Field Dialog. hidden : { title : 'Właściwości pola ukrytego', name : 'Nazwa', value : 'Wartość' }, // Image Dialog. image : { title : 'Właściwości obrazka', titleButton : 'Właściwości przycisku obrazka', menu : 'Właściwości obrazka', infoTab : 'Informacje o obrazku', btnUpload : 'Wyślij', upload : 'Wyślij', alt : 'Tekst zastępczy', lockRatio : 'Zablokuj proporcje', unlockRatio : 'Unlock Ratio', // MISSING resetSize : 'Przywróć rozmiar', border : 'Ramka', hSpace : 'Odstęp poziomy', vSpace : 'Odstęp pionowy', alertUrl : 'Podaj adres obrazka.', linkTab : 'Hiperłącze', button2Img : 'Czy chcesz przekonwertować zaznaczony przycisk graficzny do zwykłego obrazka?', img2Button : 'Czy chcesz przekonwertować zaznaczony obrazek do przycisku graficznego?', urlMissing : 'Podaj adres URL obrazka.', validateBorder : 'Border must be a whole number.', // MISSING validateHSpace : 'HSpace must be a whole number.', // MISSING validateVSpace : 'VSpace must be a whole number.' // MISSING }, // Flash Dialog flash : { properties : 'Właściwości elementu Flash', propertiesTab : 'Właściwości', title : 'Właściwości elementu Flash', chkPlay : 'Autoodtwarzanie', chkLoop : 'Pętla', chkMenu : 'Włącz menu', chkFull : 'Dopuść pełny ekran', scale : 'Skaluj', scaleAll : 'Pokaż wszystko', scaleNoBorder : 'Bez Ramki', scaleFit : 'Dokładne dopasowanie', access : 'Dostęp skryptów', accessAlways : 'Zawsze', accessSameDomain: 'Ta sama domena', accessNever : 'Nigdy', alignAbsBottom : 'Do dołu', alignAbsMiddle : 'Do środka w pionie', alignBaseline : 'Do linii bazowej', alignTextTop : 'Do góry tekstu', quality : 'Jakość', qualityBest : 'Najlepsza', qualityHigh : 'Wysoka', qualityAutoHigh : 'Auto wysoka', qualityMedium : 'Średnia', qualityAutoLow : 'Auto niska', qualityLow : 'Niska', windowModeWindow: 'Okno', windowModeOpaque: 'Nieprzeźroczyste', windowModeTransparent : 'Przeźroczyste', windowMode : 'Tryb okna', flashvars : 'Zmienne dla Flasha', bgcolor : 'Kolor tła', hSpace : 'Odstęp poziomy', vSpace : 'Odstęp pionowy', validateSrc : 'Podaj adres URL', validateHSpace : 'Odstęp poziomy musi być liczbą.', validateVSpace : 'Odstęp pionowy musi być liczbą.' }, // Speller Pages Dialog spellCheck : { toolbar : 'Sprawdź pisownię', title : 'Sprawdź pisownię', notAvailable : 'Przepraszamy, ale usługa jest obecnie niedostępna.', errorLoading : 'Błąd wczytywania hosta aplikacji usługi: %s.', notInDic : 'Słowa nie ma w słowniku', changeTo : 'Zmień na', btnIgnore : 'Ignoruj', btnIgnoreAll : 'Ignoruj wszystkie', btnReplace : 'Zmień', btnReplaceAll : 'Zmień wszystkie', btnUndo : 'Cofnij', noSuggestions : '- Brak sugestii -', progress : 'Trwa sprawdzanie...', noMispell : 'Sprawdzanie zakończone: nie znaleziono błędów', noChanges : 'Sprawdzanie zakończone: nie zmieniono żadnego słowa', oneChange : 'Sprawdzanie zakończone: zmieniono jedno słowo', manyChanges : 'Sprawdzanie zakończone: zmieniono %l słów', ieSpellDownload : 'Słownik nie jest zainstalowany. Chcesz go ściągnąć?' }, smiley : { toolbar : 'Emotikona', title : 'Wstaw emotikonę', options : 'Smiley Options' // MISSING }, elementsPath : { eleLabel : 'Elements path', // MISSING eleTitle : 'element %1' }, numberedlist : 'Lista numerowana', bulletedlist : 'Lista wypunktowana', indent : 'Zwiększ wcięcie', outdent : 'Zmniejsz wcięcie', justify : { left : 'Wyrównaj do lewej', center : 'Wyrównaj do środka', right : 'Wyrównaj do prawej', block : 'Wyrównaj do lewej i prawej' }, blockquote : 'Cytat', clipboard : { title : 'Wklej', cutError : 'Ustawienia bezpieczeństwa Twojej przeglądarki nie pozwalają na automatyczne wycinanie tekstu. Użyj skrótu klawiszowego Ctrl/Cmd+X.', copyError : 'Ustawienia bezpieczeństwa Twojej przeglądarki nie pozwalają na automatyczne kopiowanie tekstu. Użyj skrótu klawiszowego Ctrl/Cmd+C.', pasteMsg : 'Proszę wkleić w poniższym polu używając klawiaturowego skrótu (<STRONG>Ctrl/Cmd+V</STRONG>) i kliknąć <STRONG>OK</STRONG>.', securityMsg : 'Zabezpieczenia przeglądarki uniemożliwiają wklejenie danych bezpośrednio do edytora. Proszę dane wkleić ponownie w tym okienku.', pasteArea : 'Paste Area' // MISSING }, pastefromword : { confirmCleanup : 'Tekst, który chcesz wkleić, prawdopodobnie pochodzi z programu Word. Czy chcesz go wyczyścic przed wklejeniem?', toolbar : 'Wklej z Worda', title : 'Wklej z Worda', error : 'It was not possible to clean up the pasted data due to an internal error' // MISSING }, pasteText : { button : 'Wklej jako czysty tekst', title : 'Wklej jako czysty tekst' }, templates : { button : 'Szablony', title : 'Szablony zawartości', options : 'Template Options', // MISSING insertOption : 'Zastąp aktualną zawartość', selectPromptMsg : 'Wybierz szablon do otwarcia w edytorze<br>(obecna zawartość okna edytora zostanie utracona):', emptyListMsg : '(Brak zdefiniowanych szablonów)' }, showBlocks : 'Pokaż bloki', stylesCombo : { label : 'Styl', panelTitle : 'Formatting Styles', // MISSING panelTitle1 : 'Style blokowe', panelTitle2 : 'Style liniowe', panelTitle3 : 'Style obiektowe' }, format : { label : 'Format', panelTitle : 'Format', tag_p : 'Normalny', tag_pre : 'Tekst sformatowany', tag_address : 'Adres', tag_h1 : 'Nagłówek 1', tag_h2 : 'Nagłówek 2', tag_h3 : 'Nagłówek 3', tag_h4 : 'Nagłówek 4', tag_h5 : 'Nagłówek 5', tag_h6 : 'Nagłówek 6', tag_div : 'Normalny (DIV)' }, div : { title : 'Create Div Container', // MISSING toolbar : 'Create Div Container', // MISSING cssClassInputLabel : 'Stylesheet Classes', // MISSING styleSelectLabel : 'Style', // MISSING IdInputLabel : 'Id', // MISSING languageCodeInputLabel : ' Language Code', // MISSING inlineStyleInputLabel : 'Inline Style', // MISSING advisoryTitleInputLabel : 'Advisory Title', // MISSING langDirLabel : 'Language Direction', // MISSING langDirLTRLabel : 'Left to Right (LTR)', // MISSING langDirRTLLabel : 'Right to Left (RTL)', // MISSING edit : 'Edit Div', // MISSING remove : 'Remove Div' // MISSING }, iframe : { title : 'iFrame Properties', // MISSING toolbar : 'iFrame', // MISSING noUrl : 'Please type the iFrame URL', // MISSING scrolling : 'Enable scrollbars', // MISSING border : 'Show frame border' // MISSING }, font : { label : 'Czcionka', voiceLabel : 'Czcionka', panelTitle : 'Czcionka' }, fontSize : { label : 'Rozmiar', voiceLabel : 'Rozmiar czcionki', panelTitle : 'Rozmiar' }, colorButton : { textColorTitle : 'Kolor tekstu', bgColorTitle : 'Kolor tła', panelTitle : 'Colors', // MISSING auto : 'Automatycznie', more : 'Więcej kolorów...' }, colors : { '000' : 'Black', // MISSING '800000' : 'Maroon', // MISSING '8B4513' : 'Saddle Brown', // MISSING '2F4F4F' : 'Dark Slate Gray', // MISSING '008080' : 'Teal', // MISSING '000080' : 'Navy', // MISSING '4B0082' : 'Indigo', // MISSING '696969' : 'Dark Gray', // MISSING 'B22222' : 'Fire Brick', // MISSING 'A52A2A' : 'Brown', // MISSING 'DAA520' : 'Golden Rod', // MISSING '006400' : 'Dark Green', // MISSING '40E0D0' : 'Turquoise', // MISSING '0000CD' : 'Medium Blue', // MISSING '800080' : 'Purple', // MISSING '808080' : 'Gray', // MISSING 'F00' : 'Red', // MISSING 'FF8C00' : 'Dark Orange', // MISSING 'FFD700' : 'Gold', // MISSING '008000' : 'Green', // MISSING '0FF' : 'Cyan', // MISSING '00F' : 'Blue', // MISSING 'EE82EE' : 'Violet', // MISSING 'A9A9A9' : 'Dim Gray', // MISSING 'FFA07A' : 'Light Salmon', // MISSING 'FFA500' : 'Orange', // MISSING 'FFFF00' : 'Yellow', // MISSING '00FF00' : 'Lime', // MISSING 'AFEEEE' : 'Pale Turquoise', // MISSING 'ADD8E6' : 'Light Blue', // MISSING 'DDA0DD' : 'Plum', // MISSING 'D3D3D3' : 'Light Grey', // MISSING 'FFF0F5' : 'Lavender Blush', // MISSING 'FAEBD7' : 'Antique White', // MISSING 'FFFFE0' : 'Light Yellow', // MISSING 'F0FFF0' : 'Honeydew', // MISSING 'F0FFFF' : 'Azure', // MISSING 'F0F8FF' : 'Alice Blue', // MISSING 'E6E6FA' : 'Lavender', // MISSING 'FFF' : 'White' // MISSING }, scayt : { title : 'Sprawdź pisownię podczas pisania (SCAYT)', opera_title : 'Not supported by Opera', // MISSING enable : 'Włącz SCAYT', disable : 'Wyłącz SCAYT', about : 'Na temat SCAYT', toggle : 'Przełącz SCAYT', options : 'Opcje', langs : 'Języki', moreSuggestions : 'Więcej sugestii', ignore : 'Ignoruj', ignoreAll : 'Ignoruj wszystkie', addWord : 'Dodaj słowo', emptyDic : 'Nazwa słownika nie może być pusta.', optionsTab : 'Opcje', allCaps : 'Ignore All-Caps Words', // MISSING ignoreDomainNames : 'Ignore Domain Names', // MISSING mixedCase : 'Ignore Words with Mixed Case', // MISSING mixedWithDigits : 'Ignore Words with Numbers', // MISSING languagesTab : 'Języki', dictionariesTab : 'Słowniki', dic_field_name : 'Dictionary name', // MISSING dic_create : 'Create', // MISSING dic_restore : 'Restore', // MISSING dic_delete : 'Delete', // MISSING dic_rename : 'Rename', // MISSING dic_info : 'Initially the User Dictionary is stored in a Cookie. However, Cookies are limited in size. When the User Dictionary grows to a point where it cannot be stored in a Cookie, then the dictionary may be stored on our server. To store your personal dictionary on our server you should specify a name for your dictionary. If you already have a stored dictionary, please type its name and click the Restore button.', // MISSING aboutTab : 'Na temat SCAYT' }, about : { title : 'Na temat CKEditor', dlgTitle : 'Na temat CKEditor', moreInfo : 'Informacje na temat licencji można znaleźć na naszej stronie:', copy : 'Copyright &copy; $1. Wszelkie prawa zastrzeżone.' }, maximize : 'Maksymalizuj', minimize : 'Minimalizuj', fakeobjects : { anchor : 'Kotwica', flash : 'Animacja Flash', iframe : 'iFrame', // MISSING hiddenfield : 'Hidden Field', // MISSING unknown : 'Nieznany obiekt' }, resize : 'Przeciągnij, aby zmienić rozmiar', colordialog : { title : 'Wybierz kolor', options : 'Color Options', // MISSING highlight : 'Zaznacz', selected : 'Wybrany', clear : 'Wyczyść' }, toolbarCollapse : 'Collapse Toolbar', // MISSING toolbarExpand : 'Expand Toolbar', // MISSING bidi : { ltr : 'Text direction from left to right', // MISSING rtl : 'Text direction from right to left' // MISSING } };
JavaScript