From 0969f6b6cce878ece23e256b21fe4126d993e41b Mon Sep 17 00:00:00 2001
From: chris2tof
<%= f.submit t(:update) %> <%= link_back %>
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/admin/page_parts/_form.html.erb b/app/views/admin/page_parts/_form.html.erb index 7434eb31..7dc218db 100644 --- a/app/views/admin/page_parts/_form.html.erb +++ b/app/views/admin/page_parts/_form.html.erb @@ -1,3 +1,3 @@ <%= f.error_messages %> -<%= f.text_area :content, :width=>'700px', :height=>'200px' %> \ No newline at end of file +<%= f.cktext_area :content, :toolbar=>'Full', :width=>'700px', :height=>'200px' %> \ No newline at end of file diff --git a/config/application.rb b/config/application.rb index b2aeefc3..9c9b79ba 100644 --- a/config/application.rb +++ b/config/application.rb @@ -25,6 +25,7 @@ module PrototypeR4 # Custom directories with classes and modules you want to be autoloadable. # config.autoload_paths += %W(#{config.root}/extras) config.autoload_paths = %W(#{config.root}/lib) + config.autoload_paths += %W( #{config.root}/app/models/ckeditor ) # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named. diff --git a/config/initializers/ckeditor.rb b/config/initializers/ckeditor.rb new file mode 100644 index 00000000..01ddab06 --- /dev/null +++ b/config/initializers/ckeditor.rb @@ -0,0 +1,54 @@ +# Use this hook to configure ckeditor +if Object.const_defined?("Ckeditor") + Ckeditor.setup do |config| + # The file_post_name allows you to set the value name used to post the file. + # This is not related to the file name. The default value is 'data'. + # For maximum compatibility it is recommended that the default value is used. + #config.swf_file_post_name = "data" + + # A text description that is displayed to the user in the File Browser dialog. + #config.swf_file_types_description = "Files" + + # The file_types setting accepts a semi-colon separated list of file extensions + # that are allowed to be selected by the user. Use '*.*' to allow all file types. + #config.swf_file_types = "*.doc;*.wpd;*.pdf;*.swf;*.xls" + + # The file_size_limit setting defines the maximum allowed size of a file to be uploaded. + # This setting accepts a value and unit. Valid units are B, KB, MB and GB. + # If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited. + # Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server. + #config.swf_file_size_limit = "10 MB" + + # Defines the number of files allowed to be uploaded by SWFUpload. + # This setting also sets the upper bound of the file_queue_limit setting. + # Once the user has uploaded or queued the maximum number of files she will + # no longer be able to queue additional files. The value of 0 (zero) is interpreted as unlimited. + # Only successful uploads (uploads the trigger the uploadSuccess event) are counted toward the upload limit. + # The setStats function can be used to modify the number of successful uploads. + # Note: This value is not tracked across pages and is reset when a page is refreshed. + # File quotas should be managed by the web server. + #config.swf_file_upload_limit = 5 + + # The same as for downloads files, only to upload images + #config.swf_image_file_types_description = "Images" + #config.swf_image_file_types = "*.jpg;*.jpeg;*.png;*.gif" + #config.swf_image_file_size_limit = "5 MB" + #config.swf_image_file_upload_limit = 10 + + # Path for view all uploaded files + #config.file_manager_uri = "/ckeditor/attachments" + + # Path for upload files process + #config.file_manager_upload_uri = "/ckeditor/attachments" + + # Path for view all uploaded images + #config.file_manager_image_uri = "/ckeditor/pictures" + + # Path for upload images process + #config.file_manager_image_upload_uri = "/ckeditor/pictures" + + # Model's names witch processing in ckeditor_controller + #config.file_manager_image_model = "Ckeditor::Picture" + #config.file_manager_file_model = "Ckeditor::AttachmentFile" + end +end diff --git a/lib/parser.rb b/lib/parser.rb index d47bc9a4..a34588d5 100644 --- a/lib/parser.rb +++ b/lib/parser.rb @@ -180,7 +180,7 @@ module Parser ret << " class='editable'" if part ret << " style='border:solid 1px; margin:5px; padding:5px;'>" ret << " ' if part ret << part.content rescue '' ret << tag.expand diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 5b8c9b33..ea707041 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -2,7 +2,7 @@ // This file is automatically included by javascript_include_tag :defaults $(function () { - $('#sidebar a, #main a').live('click', + $('#sidebar a, #main a.nav').live('click', function () { $.getScript(this.href); history.pushState(null, document.title, this.href); diff --git a/public/javascripts/ckeditor/.htaccess b/public/javascripts/ckeditor/.htaccess new file mode 100644 index 00000000..94d69cdd --- /dev/null +++ b/public/javascripts/ckeditor/.htaccess @@ -0,0 +1,24 @@ +# +# Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +# For licensing, see LICENSE.html or http://ckeditor.com/license +# + +# +# On some specific Linux installations you could face problems with Firefox. +# It could give you errors when loading the editor saying that some illegal +# characters were found (three strange chars in the beginning of the file). +# This could happen if you map the .js or .css files to PHP, for example. +# +# Those characters are the Byte Order Mask (BOM) of the Unicode encoded files. +# All FCKeditor files are Unicode encoded. +# + +AddType application/x-javascript .js +AddType text/css .css + +# +# If PHP is mapped to handle XML files, you could have some issues. The +# following will disable it. +# + +AddType text/xml .xml diff --git a/public/javascripts/ckeditor/CHANGES.html b/public/javascripts/ckeditor/CHANGES.html new file mode 100644 index 00000000..900c1694 --- /dev/null +++ b/public/javascripts/ckeditor/CHANGES.html @@ -0,0 +1,1239 @@ + + + + ++ New features:
+rel
attribute for links.resize
event on dialog window instances is now possible.width
and height
values.+ Fixed issues:
+embed
tag.ENTER_BR
.editor::insertHtml
from a dialog window in some situations.enterMode
set for BR
and DIV
.value
attribute from their sibling.\b
) was used in the PHP integration.Xml.js
and Ajax.js
are now available as plugins ('xml' and 'ajax').ENTER_BR
at the end of a block breaks due to an IE9 regression.cke_protected
.api.html
sample in Opera does not work as expected.br
element is added in a nested list.+ Fixed issues:
++ New features:
+dialog_buttonsOrder
option now works in Internet Explorer.data-cke-nostyle
attribute (which was introduced for escaping the element from been influenced by the style system since 3.5) is deprecated in favor of the new data-nostyle
attribute.+ Fixed issues:
+href
attribute.ENTER_BR
.legend
element inside a fieldset
.div
element should be used as a formatting block in ENTER_BR
.ENTER_BR
change direction in one line out of multiple.config.enterMode
from PHP fails.br
tags.input type="submit"
button submitted the form.disableObjectResizing
setting now works in IE.href
of a relative path mangles containing text.type="text"
was missing in text fields.meta
tag in the page.forcePasteAsPlainText
is used, the cursor disappears after paste.focus
event not fired in an instance, when a dialog window closes.value
attribute of text input dialog window field was missing.name
field of Link dialog window was missing.pre
elements are output differently in various browsers.br
element is no longer inserted after a form.+ New features:
++ Fixed issues:
++ Fixed issues:
+onmousedown
handler to the toolbar area.nbsp
elements) were incorrectly added into empty table cells and list items.enterBr
doesnot preserve line breaks.indentClasses
config does not work.body
element on elements path turns the selection on and off immediately.<span>
if SCAYT is enabled.<not set>
as an option.+ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ Fixed issues:
++ New features:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ New features:
++ Fixed issues:
++ Changelog starts at this release.
+ + + diff --git a/public/javascripts/ckeditor/INSTALL.html b/public/javascripts/ckeditor/INSTALL.html new file mode 100644 index 00000000..fd2440ed --- /dev/null +++ b/public/javascripts/ckeditor/INSTALL.html @@ -0,0 +1,92 @@ + + + + ++ CKEditor is a text editor to be used inside web pages. It's not a replacement + for desktop text editors like Word or OpenOffice, but a component to be used as + part of web applications and web sites.
++ Installing CKEditor is an easy task. Just follow these simple steps:
++ Note: CKEditor is by default installed in the "ckeditor" + folder. You can place the files in whichever you want though.
++ The editor comes with a few sample pages that can be used to verify that installation + proceeded properly. Take a look at the _samples directory.
++ To test your installation, just call the following page at your web site:
++http://<your site>/<CKEditor installation path>/_samples/index.html + +For example: +http://www.example.com/ckeditor/_samples/index.html+
+ The full editor documentation is available online at the following address:
+ http://docs.cksource.com/ckeditor
+ CKEditor™ - The text editor for Internet™ -
+ http://ckeditor.com
+ Copyright © 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+
+ Licensed under the terms of any of the following licenses at your choice: +
++ You are not required to, but if you want to explicitly declare the license you have + chosen to be bound to when using, reproducing, modifying and distributing this software, + just include a text file titled "LEGAL" in your version of this software, indicating + your license choice. In any case, your choice will not restrict any recipient of + your version of this software to use, reproduce, modify and distribute this software + under any of the above licenses. +
++ Where not otherwise indicated, all CKEditor content is authored by CKSource engineers + and consists of CKSource-owned intellectual property. In some specific instances, + CKEditor will incorporate work done by developers outside of CKSource with their + express permission. +
++ YUI Test: At _source/tests/yuitest.js + can be found part of the source code of YUI, which is licensed under the terms of + the BSD License. YUI is + Copyright © 2008, Yahoo! Inc. +
++ CKEditor is a trademark of CKSource - Frederico Knabben. All other brand and product + names are trademarks, registered trademarks or service marks of their respective + holders. +
+ + diff --git a/public/javascripts/ckeditor/_samples/adobeair/application.xml b/public/javascripts/ckeditor/_samples/adobeair/application.xml new file mode 100644 index 00000000..a6635a6f --- /dev/null +++ b/public/javascripts/ckeditor/_samples/adobeair/application.xml @@ -0,0 +1,32 @@ + + ++ This is a sample HTML/JavaScript Adobe AIR application with CKEditor with default features. +
++ + +
+ + + diff --git a/public/javascripts/ckeditor/_samples/ajax.html b/public/javascripts/ckeditor/_samples/ajax.html new file mode 100644 index 00000000..c6fe8924 --- /dev/null +++ b/public/javascripts/ckeditor/_samples/ajax.html @@ -0,0 +1,98 @@ + + + + +
+ This sample shows how to create and destroy CKEditor instances on the fly. After the removal of CKEditor the content created inside the editing
+ area will be displayed in a <div>
element.
+
+ For details of how to create this setup check the source code of this sample page + for JavaScript code responsible for the creation and destruction of a CKEditor instance. +
+Click the buttons to create and remove a CKEditor instance.
++ + +
+ ++ This sample shows how to use the + CKEditor JavaScript API + to interact with the editor at runtime. +
++ For details on how to create this setup check the source code of this sample page. +
++ This sample shows how to use the + CKEditor Dialog API + to customize CKEditor dialog windows without changing the original editor code. + The following customizations are being done in the example below: +
++For details on how to create this setup check the source code of this sample page. +
+The ckeditor.asp file provides a wrapper to ease the work of creating CKEditor instances from classic Asp.
+To use it, you must first include it into your page:
+
+ <!-- #INCLUDE file="../../ckeditor.asp" -->
+
+ Of course, you should adjust the path to make it point to the correct location, and maybe use a full path (with virtual="" instead of file="")
+
After that script is included, you can use it in different ways, based on the following pattern:
+ +dim editor +set editor = New CKEditor+
editor.basePath = "../../"+
editor.replaceInstance "editor1"+
editor.replaceAll empty+
editor.editor "editor1", initialValue+
Before step 3 you can use a number of methods and properties to adjust the behavior of this class and the CKEditor instances +that will be created:
+qeQfX6#omubywM&5`BUrl zo`!AbS!ccWo?mBZuG}F47jm-nSe`gJW_;Dq%gFhjXvcZ1x-VyFYGhVxeAbDex2%i2 zsnwy#x%WEH)!qn}(9&PIA0s@>wJo`JuM1ouagHg+MkNW;Y$8qEyx0S?%=f&n%O?8F z)McL}jU446;~?#2Xjv#q9${X;W~hpBM*Ty*SY`;G#<*0+EejuSG|92fOidr%Ye`yb z);+hh*Q_U5dBL%$wY^%`^X9b`->y-gW-%mY>4W5KAxw;nsqcY~fL06>>o2_>$lky* zkMlGOaIATlo2Q)>yROpNdk;xNAH!9v7}YJS4R3T%uADrKeF4t>ymx$4-h1$nlBF+l zH{(}3l1=rsPmD!7Qrh8g-vZ3NZi@42OCRn@|D`U5L(}Ar)&P-HLswkR3Y>Ml6UJN9 zUQJlq;IfqD67m?~gg9 7Np z{pDQGUS0II$VD1kS1NND%U-EBx~OJ&-jCXhA@&o>r(N?My}Acox6FCm>!zDknnkYe zX9KC$j%9x7Nw;~f!P62$n_c!K G$|NT|p&&niRBHI>HIDC?2qQMhG?nzEKV2mGtb<8nIk6#GQ3Bcj~5 zR%s}0LY<|u8{c0WDtAbqVm-)yi~E7jwP8wA>XoHe^rjzDYgj|qEG^d?9>z|moNriK zt-J9u)s}DRQQh}L9id5bP18?nF2)X?L~%F8=@ib=x4G|=Si2*w=dO0%m=IT}EG^AF zFFBqK5qmv6VU#&bVbznS9IDkgb)LJbVi$wGk%f!*YaPdJ5YeAyw~p?VvpQ2S^reFH zXymCEXeW9s&QiJSBd==mNwp(WTV+`+ZN(FJulZU|;5_m5*sn0JmYJA0Eys2D*^sMc zed%7qlrE{g1m@S}zJMivp7esJer!h(s2lFF3`UDE?RDm|YKI){c*4qENVP92G|6TB zVqE97P7o!S*UD4Qqp90mXQhw}ml0m3&kMbS5r=XxpWjltwV0Bnk23R?Gi2^6%d;fT zlX(}4dn`unSb9nK{Zp#FoFy0Txp+7Cbgw5~_LNV3)>#8P?A6R?ot6>F(+n 5w_tkzKqH@a%k zHBWsN^C5TF3~l{e*2;4J=3xe6$*a4uUyWaK9%tm$vj6XngRC`DIOfdO7H^zUN-eO= zS>3ld=e;b`Y>WLsnmDCA12D>L8I9bx;gorC }-XiN44w#y64;ovk2ZClqWK# zJAG*!IUFa(a>c|uR>LSWI?IUeX%uqos GKbn!`9dxXzS>cEmHK%S>FAUC#>@P zmv<*QZkld?rLpYX_fm5tdH%~gW~^y35?b1ar~WXNKHufWk-0BRWu&x}!&5Kf+=FqY z9|pOg9PMi3m5~6r>X-@hsV+24hVWckhSbtSsv03R^^jUPeU&sac13WJ@$2fe6>;OZ znobj_$5IqBydp*!x@t(9Ps|NnRrrxZ%go7}u{|7mA7;!!O)Wi@wVb3!S{9x2CN0h* zJoKWLx^mYCvX2^$847RTH3Da90@oO(xr${i<&GQM7-w7DC*?~-oCB%3rP`GiI}MgK zhWmch!&<6h+Ex(k_2ro1X)VE4Cvt0%fH$?I*2QXFV$z9J?vqEM=j7QpQhkc_T=y5` zc>CX!fjca&=hAW)6}=IEvQO4uZg`9^*uvKuH;xz-F|0|yFkighV7yG@8=FRNAmg@& z9qxh} l$9VJX?Vkk4TV?6jia{*yt?S ~ax6}bvaBrDdDWF b GN; z?-b`S!Fiox6(%@;Xvj+EY=};>GDJr&+fhoQOH7n+tI|lfkd;Mr#8Py!_~O;pxrR54 zSSq2!#?kwx;T4=INr_D+HWFT4bo73quz`Z}hlVr+=Q)N~aDLnH>YR-ROIEBSU3BzP zpGCT1g7XR$H%xG59Z6!rnRO(+I%nk-d1gCGNpu`oplbMC*L+=c5;_PhMJLLOUIgBG zhBu7fS%x=`-pPhHk=|ItD-xn4b $=`1m|SI`9JVVN$Q*xR&Zt=Nn*j7btJulGwVot1!sy*cu{gE z(OH_LGd50)R(~L_E;qxLl6r5Q{(knP~ZYDS<3(hCu)kR0ntRq33taDbxf-~EZ zj4L>^9Z9d?OwkFiMRaKD;GCLH#%Ua4b|Y>JmN!m}R=bfWQQkN)TJ1Ju $Q%ftPh8 zWhFRsZYE_VI5S-tS8!%RqD1f^E^A+SEhR#C1uW}G7oGCzqElYM8KTmOB`d)hGQso% z<|TaP41_k`Z4A_Zj%Q&8LWCkBIjO!;k7<0K>Ys^; !3 Bdp-LgM(pEJ6OcJ5Ygv>~Po7!X%Xv-f*X8Gk0#$kwEJW&$(fgi&JUqJq> z90eWz2qeGj_ZMQkpmpjqqF< =vUiR$m)Wx$Zoh}Wb1YgZ2N4;emS zP^f?P+SUD|2Mq4lH)8mZX#aZtRjXC48Bjf_T8$clU;3Z_c?ozj{zOAjS%jm>$fkw~ zD{qZk$+&4ZaFs=vxXSWh8@b9N%v{M_@W!d*Zb(XIyeead`|mV$l_kXrRt--f%}o_c zP%cBYY#_>LJ_Pn)>`KK;qqVCyklLGY6X4#0dmC;d+$6Zka8ux>!cBvl4)+e+47iza zv*2dKy$d%7?mf8o;pW1905=Z~>q>1t+yc0GxP@?w;1 S{%IkPgwygB&>i{(`X5dr}DL6bEy{2I_bk^NK$e(-h_}}YT dfEyxZ3kIlT^*EJ?qTL{pB3Dmys;j?7TVP=IbPUao&)K z JX=m zrfW+sFEhytW2qQEv*?$*YZAQB;KAscMN8aqb6nlBT(zK7(!j@It|bLN|Kld8Jn2&k zX0t3kj3*9W8S`?vFl=3J_+zV28f2hep$6z&E?n`|8@J}m$~d=e&%K1)YA|12<>fhf z0UJ4xy;hpJs=kM>Mx|=<&2nMN{be4dTW+tKTg(c$)BaShxLNAnn;y;e3Ju$->2*cR zOB>$slo!1`T-UPHiZ^^6FXW{#7N&CP%rNKWqKzCI+?wZfxp-{7CYz#Rv;W4FTB)?@ zze65!Zk390H;YzyYE_Pls4TBnM(HdUG~JKMDVoiBim|xAJ}+WB7h|cVMS7!A@+B MtM)%9G9Y9jLTW(l%6=5^W|dl&QeDAZJ~)+ zwDw26xLg_K2>KMST)Ms-<)I(8l--lQk(+wymb#?BLMKOB7j5#=oS9{e@g#po55?T1 zYFy1y6YfW7*$2oiR5e=bmv>ncmLATVzD16L#w^6rV|c?stu{Q=;8So`7j->ww!Bv2 zO`cu#&->ohFe~NqQg~<7bBczq()bFr^96mDo;B_;mf*o4mqi|)+DaOYi&^y56L4-n8qdG?wLJv_Z}j zR1d4xL)1nwrdu?_(@5YL(=F!1ETftyK8_K^#h{sGR_Q&bR7|Z|c8uKXY%1$KOG|Xm z!_%IVH?{9rX&5zS(REL~L8`q<8s*D5EML_0$|P7Cc{{WzRRd<0mg8RXUhH_KiJ$Xs zrfNf`S&F4Ubl?A&`@{?=_Jz#7RXOH8GVj$Ff7?NuN_SO7P#AFms8`zQy%)BSqtB zE+-q#I&U%4X6Z{k>AP&5shWthaC5Kg=AJplnW|;fa5n=~`|{Fg!Z4g?JMYVgS3NBn z;*CBUJ7G4#!J-}Ba8PSdqrZEKb!>lq575I1^S6uyaxC+{{TZgK(zr%-ysGP5D)pMN zG=!w`VLA(xGib}G;i;X<@huetW0sNG6EEv3UFFgA8n8RlXf7+!R1CJctSKlbwI}5; zYGLS=%WgudCgxJv)szMqQZ-@cvg;*JOl2yn?3`OVR5H6=oUo=+H0_mkBVsPSwe#L8Te2{wlNOU_mRXV~ zEv6BVP^_9#F}7w|vAEYlrEh9Sijo=x$F&s8B6{q fOz!?D8DL$tajb=R9#!_uM=fF0;%LJ#$re#W-HL zHMEw-(mPHh ' + + '?DL`zTVj=P#S4?w?Rx=U;sBg`#P?k-W+oXx9- zBE*fcs(+19Ew$I9R#2vz@oX6EpEq@8Sy{N(*R-uH-01-|$}7WhmcGLsPqu*Jn6sv8 z+K#WR=&!oSHzwR0Fv}oc1Xu4+c=ifYC49NRphjY0s)XJE;T5Jz=xrgq!c+;py@eOo zhNZQJk@T7kn9(aZ^W}cQ*=)d!SixBuFr!y+mIln|6`WfjuHYPoH+)zkJy&J}W*`m| zd1gW)&tZbIG+;)o;7r30BF`|90agtaXD~J1h+?|B^$|@kzBATrzzoEiAm+>cy69+a zMH(<8R+uW02F&Ocrb?s%GkS%olCCNnfx-w1EdfYbIcLLczzlH%1?Tn #0pa-(tsJg!c<9bhv-O50}P_}%?8XsY&Kv JS~{ zN&{xZ3eM7i8N6l#X7rj2n9-}7SD`I6dIe``z>HpzXV#Id1;Lq>vW&zQ(U}dHxnl9= zDl$ov60!}N449Evm{*Yo%;?pPfhl5Psze$vBUYFy>F*F7Inzjn;A}Qv24b@TGkSH- zhSo8zG+;)o;4BT8!5b#>EDe~^YcgO)ugQQJy*g(a*P&PBnRTR#jtNNvX24oRXEtEw ziq(Xv5{gdtS0)2yBo; Hqqyo!n|OqE1BL`S !FjdfjJ^$Vr2#V#qrJk*ghU%O8!#hQ zaFzzl=ruT})L_8}|235mo`jb{h-)@rMz0tLX?RJrGFlVSG-<$$STS0aGq7T`k_OC( z6{A& ^YXR&dT~cm?Nz zhF5U*H@t!~6Ox+aEF2UbX|+!UYc^oU;_IW8-si-L(MlRHBUX%7(tsJgVziP5%;*)P z6~}#{8)gG$z$WUP^)_fWU`DLqEDe~^D>zF7X7mcq(tsJfW&>vQ>YVj-lT8N9h!vb! zM YQnXi(bK58Ze_*aFzzl;58dCqgQaIoh_+Xg0nPWMy$?R z&sDPEOeGYVOctCeI^nfyozWAf)SS%*%#e`TfEm4Fw2}tQ=oO=tG+;)rK3eJJjT7Ub zG++j-*?<|nCIe>l3eM7i8NGtDG+;)r;LPq=)`H;7N;ycunhluID>zF7X7mcq(tsJg zf-?mxWu {1RsbwcI%>}*C-LX zE8VMWo$?9=hFa-ZU3AJTSqaXpqw6pQkdYNb@uhB`OPGluJxV9zf;)eD%%`wmmX?^Z z_f-RZ8e($9V@}haTTxP%n5j!B1EnE G7uX*{LWJdAP+x=X!W#`*z7EcFn%+czApG$L>sJT+aOM3(DetV1-|*n ztJIwU+hUuuFW^A@t&KP(!M{E%V{!bh1IGhnZb$PQ3I4)A2 +LekBIjEzD zE9xrX#Tbf9G}2&>8W}PCVRXF>rf>2~KFpCn%!O2j(GI#w$WZ_+ztF5m4g9SPR|DZS z;rP`Ie?Wc#I!LR6zqRl;5U>(VkOU!38Y1D}AkaDgD=Eq+!-64)P;67x!Pk$P;EIQH z2_=qs?vL_ELlSk6N)>#MjsGgcF<0FB4@YQK$dCV+n`-!54gV_X{3}6XF=D%q7ZWN8 zNtFU$O4^(|M}Bxb=K6A*zmeZQkU1}2L<^agwD2+WWF0!{jP>bSBGzbS)Uc|{%8)%T z3sgaFX|jc-tBi87POW)Xl9akq2U^CO u8{1K+$U`45^P==Q^}M9c*HeD@O;H}2#{7+WNr|U(J}5`k?o!rs ztB(EC?IINV?%FCM(Y}U3108LgbX8D`G&;e4jvM$<2x04}3YdE9V9Yv@G~2{rQUCSv zHxmDN^`GA#;|t={`6{^1NQ;`z?NPpjL&>GY>EAA2**CO7Z|^E)@B5y?qDS(!uZx02 zd3i+kkj_20_i09 oi%DfQ*fy%5V@2d#{Uc=8M4q2e+& zds#=X&T*ZWj`|s?QeM_{OCm4U7Lsym&L&q{BK`X4(b<<)7A-#%d8&;buNlhH6g_cG z*g)k7+eG|p2A$@p))@b)f#wDDij9P8gpj77s{uMkuc*qHQmW1xno@3gk%D#B2awWr z&g}q5?VreP%BgzJZ97qqa@NIB%4*)mIrr>k|B2jtmkZCOX@UGv_UxTvQqe6{XR7C> z#owWBX{|BX)1_V4Q`U6J+x$0Jlt8xlI?y7=i{15s>4Tnt$D-6$N6%oTOG#4ZG*pSq z960a(|D(5_Q+=BJzmC~0M>6*_qSR+0=3F^=Jxxy7w}wFrUl+Y#KlC;7l6W-oW?nU< zb@ph^p}RDmCeQpzJ$o$XG!*%);-X #jXo`)K#=-OSa~{LD-% z*HFx_Oi!)+)QZquNnBgmzdOWJE&jW6Z_ZtMNzBstcRZ)p$-ko>%(+Of6SFk_9na}? z^6#hzb1u^B#4L?}$8&m}{5$HwoQw22F-zm$@tj^K|BiYv=OVpM%+mOGJU?xnaA&~v z{F=K@^0fMO>~{0~nJ+1*pSYkQ?`UY)TF^9qT;9N;p}S9YRSht{)m5Xq^;=y*wQAO? fUadCXFyJq?Rl_m)a2qCv<0BFhk^c98u>}4fd_aIc;R45Ut z=++=<(5&IsK#}2m*1GRszw=zzd9HJw^Vf5(>+G&xy}j33pY>V8cd) 0 %{^v->5@V!fVLiHU zaMio-w`%UCr(LNu6r25ATSe(P({;k)*w@cqbb4eM&p0oM^`v~os8_g^lFwqh8IHWY zp) dTPCD_r_;S{-`cv-{3CuyPr*#Inj3YO-+4rN znOdk(Ct^e#MwHD$Eu2qmiiY)OzcdA{3nDT4{m$jr)~WMZsNA1NeU)Bbk#1OR>|K7L zhl?m{%8{UlN?1ba?@||)(mMG&wACz;$dLpjRw1S3RLPwq)Ybx-rI#WlzXyM$1z0Sf zarg7;G=reo58}_YCy4~jYf5BmzKfdgQp$sR`!3*mg|p`kzA(#EVCR3}m>rqQGae1~ zV*Vb+vwW~XR%5HDYWDR-8L3fFz4JFj8Ofh~9x3B?EKxTU!pyM0>~9-y9}I j%N`ou~^tq?&oOBJ;06QUPxk!$D>Oyw%d=r}wo^paSk zA{4)IiE?*Z9g@=GA-T*VPH!3|a}oCltyxn>&8BVv4;`9Y7F>yhZ_}DjmCfw*ELYb{ zEj<+ E0V{ZQFKbIYfj8cbUi<{y-MJJVw#p0}KaqOCe(< z#p0nkzDk_V)5o_JdJ9Y6L5!*m_nTqB6<3j9anR*eLGk8`)ArwEmzbD&BF+e+#TZJ~ zuM*8Tl&smZN>cEZXOU7SVvhtPZ=dRYCEkI0IZF}4%M;0zEF91Zow2XFqO%BXUMXav zwcmO9p;Dyf+>A`R=%o+lzeOyUTJ+nVBS%##^lQ`ldDMzfB+9p0b0%{dQC{iWkZCtx zop|0e&b$A%``RVS-lZ(#e8kwi4GGj6zY98B*Na4MbCG!FV(*V$bA8V^M=_kmsykuY zOqoa} U4L0zz z2eUg*tgu!+h(r#?Akm*pEh9HmB;-(uWVXF(r)b?wr=Nv`q!-c5XLGKso$ZN)tnlW4 zyLJI5v4Ium-648;?P6i?Dh1V5a8$lV0+q)1g39Wek;rEsB+@FCy;v$Yd$G`AI1o9A z; 6w>_INy2HOHEQzuO~$BwFUDoltuPj zlF_Od)Ru@hNvq^HiJXLy7a_xEcgj0oSdE88<6QQ?MM}$e7E0v)=`~k$-JcuoA;vq# z=mf`BOC_h%Thdom^%>$^LA1ltg lo5_Nh>px#etgqe8kw4<~P0w3$cwE&6agW*{Z-qH7r7e4|T5-h+&Q0C5^**B= zp9x!G0}|*pDhuj0Dn&DDxJZ)aaG&BO;d^H08nq?LrTgee%Ay&mtNe(6C}?k$c;Yb} zGquAZbggHq0*!-y qhdK8- zA3#V7CPH5SJ*O`tWLtRdjI4Y_6HTbg?NL%R?B^n>jpqv%`SeAVyh98l9^%?NyIUA7 z_gdxsC^;PoUmrY|=dcaJKIdvgZe4$``}y2b>9+@Xe&vYrK0xC5)kWMZ@r#>rzn1^> zJM>DT*y^7|0=f%D%kEyfchFUBNikx~N64`FvMWm~#a5ORD#j}c_NKAM5j8g9ECbRp zTFFH+k+1qYmg+V7HU=--VscI&Nv&X_aItmXd5k(V`}5$r#Uz~;u1|6$l1wymD%A3> z2;Is;RbtIZJ2paFJ2s4m{?KYhJiR;O8>(`gwWBr5t1^qrmmuv1Ph{eLvV3I0$s*+a zlg?=U?33(?tXnQCy>j}t!zCR_&4a1BPxUdYrXuS2Jw(?CH5K$ea9G&Cnc^LY1niY^ z{Y7`!plMmWTS}aEn%y`4Zf_i4p*Bx^t#0LWuXS;TLWto~goIeWxvX75%!53xo%07Y z F0=1d0vM*vGGeQvyq9^|jv8 zI|sZp;FM5{Xe*kB+De*jP*6h=+NE=~dFadwTGcb8b%BLC=;k$ v5k3C1 z&kM40#hZ?PuSneNXseTaJ#?|RlI<=yPX&pX=H@PTc~w6_V0mqPewoocA+q zue#^X5;I_MXd4fr;Zv<{H}~(?>c4G#B^Z@=BHGrJH3g5uc~tcx (Y}}hR{baF1k;L(Hm%j>e#(JcKwuB!& zQDd}tbK&b_LvPdIEHZOmuwch4Df2DuLoFVyVVe!VM3*htC!4M);(k3!&u_-XrpmB~ zDeKMeX^6cXeYJg|-sLBMWh=Z{uWDB4lo|A)@fl(vd*p~*5f_D^m1q?TMPVo$tws?j z5=EhCv>wHv4JZ!9qm5`Y+~`Lw`Nj+uc98B~u)<`8$y@zYom3s9iRmDX*)7&BhW|~~ z;maXS>~$|dnnG|J{$KgCpJof0rT=sT3Qc+flcu *r z!@?1qkPedl?g^|N;S%iwEdAjNO#kUm{0&5J0y4)p6TOA#Y?= INqglHOF z2U(6v5VC*|hgE>G-`T+65hLQ;5yu|*?RyYmCh@sQ7y9)f^aUnO`2$OTl+bk1r5{d6 zk7TPyvc=j59GtBl$rk$?h~5Om* 0S zaAe?C>q)Eiq}6(8 I0&%oBXf=lwNAyNgis=hS7w&f>M6*Sk zh~7l>W>RxA(OW>fp)F9K3&i^eYhR$-G>u+?j*d$ZssOi5un9AP&0{orBPqpXflm0T z0>pJ1QN)Bja2RC*o5#3l2Mv#F2MtHwLBm0|}b zER;jq=8(2Iq-_pqn?qYNb)1HMK4A%A1z`&9FqCEh6Mkk9okN%p ifd zRuHmK0qLuN^i@FmDj LC8XU za8hV|h?zy01N8h^Kr{=LkkS$;O{bO6q9zXjSyNd+=6DX_Vd57MeT?Xngk?Y$L_P^~ zm;uByfOS3)AG0S(CfKhar5Us`n$83th%>~xf{=wONDdXy;{h6+Q=xaPa|jOuqhNH{ zIY#tJ!ZILhDxX$Kn}AVQ!p I$%XvKiPr)k@e-96qfIT4m6x zA#w>}1z|lf3D&d*_GbxU1tFhSOA{T-pq-{&`jHRB{hlT}7CWV&zrl#Gt_R{AaGgdV z&fzr4;WWtsvz<68w6oAx79k%fI#vSIfl-{L@h9?Wbr7Kxh{sh2`7{ux5r|{fLCjVl zj)pa#b`J8%r`1EN2Er>qJob9hFJ?P&GHB;v)O?^Sj2-I=!g^p5%<2Ww?*&@SR6S^& zi3Z|i&@Ms_*}zO#N32T-D+ud>c-|Vwd}3A*T@Or}s-rbRv >%tSgzr6|w1IY& zM7|0;_6lgcB3Hq0C2S{72JITj^BT$X8p#torQqW{v91T=JaL^yAkOm|iFS=d!)zzc z30f=3vlX0r&^S-5TL{|-I|#c7Zxixq*J-S=MxZFHV;jk*jpWlt^1)6i_&6V|>w!2Q zT&EG31o^a)eA-ApnC-+#p|z7$!{mcb|5*p@o@^p)BkUmTBD_t=r`>?n&!=@j{8Au3 z3OY!S*l7gaJk<=uGl|&_#4FxO>!oD_W8fUuNv;u{v{rfr@%iwrB0h?{$mqJr=(@=0 zuu}>?9v#;8Ks-8JrxA!}y9?sC6Y^=dAWkDD951&?hPO$Ew@EAPG=h&ayiGF1YzN&v zsmP+zo5vJcGk{`rCf#^S9OySG0X#acNE{Z?%0#OG{U+JOQ6-KJp&s#>bV+(CRUBwM zB>}_{ux1ghOtcCRN06jPOsEpALwsGL^?=(Z#Ocz|N|BHSWKOF9hmj7@Z&DXHF{KAI zo?_Bvpj3=d9EdZQ0bhzxn)q^rEaE5=twP8qjvAp3adZipba{FgMI6YSmH;OFlp$J? zkVPD2px>kl5Z@bMtxBi^bbt)8qX&$bkf1BjSug_%5KWm-2Z%FQ1d0Kf)8as!xgzu> zO?(;R%Mr4OqfDp*jDR~CTwje)o%lM0dO+qhldeRlOya}3L40KrUm4m;gJw?45Xup< z2-SdolR7|Sm|I+jNmn7eLIqlhgFZSg4ID-?K)j~dR|ev-t3c*Dz;EC6h*o6bwoE!3 zR#Obff_=q?nv%d_Bn|AM$N-tsa>P*t;+UAqKpc||@tJg0&|*M53all8##1uHkpntR z$`h?X$Rbn$;ys3`Mkq#CgI40eZ4-*XhzS; zKyS=bk&YXQZ9cxAO<)XG2yIPS2|r0YT}F(BR> zm~7&x0Ucm1up>sF4-^OD9fB!C97Q0WF-#RgHlZreVNwf-S93lY7p}vk>%+`T0C6T* zD-g1Pev`^Xs{kV=)PY@;dBiaQvZf4y%xNQ_@stIyi(*F{dqPJ-dAb3_WCM+%z5&!X zAv7hv8POKNE{Y}5_QZD}+L2I#ZV0)l0P(##)@-^FnSW!5CP6nQ=M!Uy&jQ^%273hv zGYI+X0V5`$Z=fL%XN$E7(0Iy>(2CFo$eOYP`c2vsIuPHT(1TEdZbEju37lsXKo27p zaNC3m5NCx;4S>vPLqa1U?gcv*z+q%Zv^}9Cp%bAqp*wIGDbr11HrPOXPBR6^0ElB^ znh;tM+5&M*Q#iZY6YW8KNxB(0Y+%AqeIRq%0Ep)wYa>Dv;+PR_0USn_L|YNs5IPb% z5xNsf(9OwOn3J_IhnZy47eJmWbPM8GfFnj<2)#%E6MiZZtpda~7sC9g0`a&o^@wjk zXb5CY83B!_On`oqW 50)VC$2 zwq);N-;k6V0dXeSu>j(Ig0(%NBcT%^lMcHc&VhC?=lVn&5}FXl0*L1y*RdgVAan#W zr`>?fWA4Q9AY{_*!50JKm{>~y@l4vou9hZ_JP@B}FjasFKh=Q7Q}cjb6n!AxvDh&r zG$D>Da2S~pZ9%jpp%rm#2qD=NU(s zZ3Cd+qzTY?$_mJwwjp#U^dMx@ouH;TeKFKj0OB(?rasVk%7FNWKzz=@bxeUc2dozY zab!#zLR%nn+JR_CLO0;iaSx)|^d%5Sh3-r;bS4?PKpaClrZLcX$`sf|F(X=n?n?HL zE7X^uyAkaMnn`zuItoC127@yk p{l56zWURmqKnV zAU*>ug*t5F=mPNyE``X3L>m#>5ZV(u5V{l6=#ngQX9$G*Kp@-)vY6AEM9Z>dS@_$q zIV}8b*c?{+&v4*2$_C&MY8DOq!t^<;<}nfA(Qzg);ineSI>evDngbDbihqS~uBga{ z3jh55p)NAQ;)xxNnrQkj~C;vig^&WsQ|2)DtA7Smhi3%hUT+8u80(`&G~OSLr %OH%^`}KHTHym)f4@t{@vp6FHiDU+kcn-Qr6OGkSP`Y{Tc&z zOH5ceygkCYTE^l=gt6S$N3V|uk7d7pL(KXOA@PyxqggRgtMpj-O_cv#t@$_{YuWm! zjksML%Q+ev8Z20#uM05LW7$SUu{e>dBjV#&oUpjC4V%J3(KIy{@}Z#^bW@mzgoY7A zID@RoWB3NnP{lo!d)&s}YnG7j%oQfPr91EM4@wS@q+2lWCSM#((q}$Q){
+MI$32rNv!FqQ{Ypu?euYz!_%0zI_-VJaBSKB$@c0?J^~B3Y zK4}61R4^0{r|u4(7S|O(h>jTldfj6tQb3Bx2446$N{Od_rv}iXXfx=UbZf?OhJXNm zv14Bsd3|DUcjK~<=PH}muDT@i_M`jn$uvbB?M+_zL1N40#j)@l+D39TNlVGK$TTXY z^nu|V%0-uwfc~~AB+}=JXm^y>ob6PKKr<&Q(aa~;PLEbxJN-?)6^Xo#N1_XZhb}D) zZbstV7E0`gta2Yj9}xR-+?)M{2X7H@2W(KrAt`^kdW2>$e9#QZ=s&}x0=;vbx{ -s0V)ctrMbWMI|8u+~`|Z(pBuBp&IB0x32j=NvvJ?+t18Rx_g*cO#!l z9+G;N=dHaVkZSa0^9dfS{G0ZnJ`d@Nl@|=*=~ekCnyId=73;-CLPMEoHzZQ&M7eLz z+gSmBQ&}o&GG%`kHvd?zYF~*M(WOY@te2Q!m4m}gq}*AFl8QBvb{Pv92iA&w3#?hc z-ai{Z0c#s`^8YKiMviOp=Z`%B3;YEd%y$JN?t6sdXvwaJ%^08kxq6PCXqNla3AgT2 z$dE0Pm_;v{aq!27GBqpL_)Rm;Sq;q`e7MX_>SdR9Z`ak!GCamIeI#3!d2gkUJ!1HA z5c_#`X-@u7{59i^PK@q-kpohT@)paq2geLZ@`S67nuM)*-s=kw%X?UqJmIhfF 1SXDajnaJY5=yH(4OYIXu+q`F$aW&>W ^9X+e&+?af zA;u%EoPpx9mfYOHAKnO^`a>&p6IcGe$(xl|cyR1&BahhA#z!{n?eh$VPM zDtVn-eBZ~}qxoeXJird*F@9+GKHYt}L$V~un8QO&L0XbH KL$2lqEYhE5@frF `ck|+qZG;iIK6*EZhG%Ac)eu^F{Bo0X;uy)VQMK-d+&EPApg3_aV9FC;?aCW zcUSot1f!62e8xHc?6_}3i)G1@y71J)4>)`Gv!5U-6($lhGxxk0i0Ixnl;G8KHd;0w z ~7CmOM&;GD3E?tGG$Y>4qW$PwHBRPF483 zc~_OS$~{_wM5;@XInTYcc4jjrs0g`=?QyBSLJyf^J5?o1nUe3msAWd|gcz2kNc!#_ z=9 }=;0| (SW>TDJxoQ-6 +!1s(+i_dwN& _sB1 0oaNm;pS#Dk-UeN0 z-`_nKb|z=6Zv}oh?1Yx0W$>^p3?2wap>=TG`ukDvPVr>8jL`qX4aL829wy-;u4RXB zE!LXis|{8I j8FJb8AoXzREx0L2A>Q0y-oHx|etG(!Dseq)X?QsX zQX!XkmfiZOQ1sv7I=>K-VxS0tfk6tdn}_Hk8FV}qHk1g8ghXtcgQ4b)RWSl~PWq2e z54v}m=_F7x@6ZjEZL(wA9ASd~zG5@};}x3*5fvWP+7?X 2W4pME&q4-fGL z=nMe{T|j^#ASfsxB*GLC5f&DaoHbjNDI+N>D <2eWf>59J*`l3#p+UvlzPX<7N1vvud{&tJIMaP?a2^|tmK9i4ao z?7esY!Na~s&j(+;eD(Ux+jm2szkK~RGWz|;*f<^+1=0Q<7Vv*LE-@Gvl}@M81@X8j z)XjL{VswVGfq=NJmtaV&go@!VAxXQe U{tb+7tG#R#8ZVb4>q N(m+&|s;`LzL64#cEl<*vb6}%l$3TB;7 zjLplgb)Tv%ep>VGz^p5)GFk(d 1CU%!5NtkPvIcISQ8Z~9ZW0`5GV@G6bWc$hK%H1U9M`pca!DyLEIcC|9+(ftCC zJa??!5+E>*HeLyv-2CADo^3tpR~BD;BR0CR{LjB4=f8hFH5jP=QNroUz&fd`?JAa^ z&+NY?#&8xaWqo`Ze{0nmp?KX5Pqu~|+EnJ5e%ZO*DC@`PJ)dSeo*dHfXmTDM%ldM# zEpf^3Da%Hrs
) + // 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 thes?nAOAjlW1`}v04Lphm*^~^Mf su2YO37Qs(&bMH zj|5o1f4P13?E7A=-o^E~{3|<$-+x;0sM~#El&jjychOZhM1@yc &-7K>?(D~`M z)zLpq<^`>Nmv4W2(2D1qxji!Yq0QS{>$WQ-+b;BXkvQP8d+^VWv*(ZP*!E%K!n?GJ zK$F5tX3_x(M-Su}aIM?oY|=N@_J>AChkn`hbKiNjX%z6Nc6c=Bk#6o(Ma_2JfJ~p# z!zaHrJhUtu_fae}{u j(KW28%s(_^n&oz@5> HMZfCk K8va+9^T {s&2QVzix}DXj-EXecOrBx%(+`H{Vv* zw?164c<11vpti?02UYd`0%~$4Zl3? 4``X`W 1@URg3TLz*MB~>b8!3xKalO#V_X<=&Ybi0 zgIUkv80wL0PA+B9$Cm`R&i?d3scg;HCwH`+vizIJs89MfITa<}7QAx3 d~fCWkzm83X|%?=U>eyz9eZ$fWF+s}#~sV>%#3(c zX*jzsm1`8UW8>Iz_TxS6mlONezUG{IuyJyGduObw)PiNLi_Y!)wsTl7vTLO2 ;;33W}o>R wx3)Q>#~YoK3mi(U7;BF>@MiSIGJywqj}O zL~Kb5+p4Nc^=w8_XZX$=p=l%Kix&M LqrL2g2BD`$FN4u`?Y+f3i}!1lpD%pB&Us`Jo3n3A%JQuXj~VpM zSrV;p-nM1r`t0Z1P2b&WD;RXwjXJO}`lW%}o(p{$OGe+X*e^+WyvFDq^KF3c$-GTx zb*~h;9b6!C=jv $GL4oZC_je&_1*EXM#$vt)E`tG>Z2#4>_cOV((v&)0E0+ z=!nuiab@^P&GzWvgARYp`04X?Wk%rT@vtT4R!Pf>huiYPG#;7!CKh?HZ{D4}Fy%x3 zf+rtu<4@(b_t@NST7JLy-X-g@TMgzV$2fcMK8<Fo#iRQ7YflXB zPgqB))#q(_W%KdU36%>ohYV+F|502nku!JjL)TExsQ}AdmHe;0_wQYDtX$LIRJT$4 zNbiW I~t`Iz4AHjVfS*c{+ A38R39Bf{ cpY zY>RYk9*QlPT9LH CSTB3BnCW$6wY3#;_+sys%|D&KWx&GWdF^5WUz zNeAN+cp1g)l<8MtZ rVdCLd+wUDt6q>w6{!)pouVlmJ-<(}W|w*|g&`)9czZu9O|DwkJ)Y^U zIpg;J!q96SRCo878;l}ZPw8Dk!%Fqnd*n)gypnh7-TO$0z2?bwNs+ G|%E zccOBd*Zf?+7G$*lU^oOcS_aU*e{($eIi~2|_FX6U%kDLfk=(>SqJQRtaB%Yy)47Qk zOY1iDjIv;2^5@43t<9jm+b?Ft-mAH+AY-u2`hI-ro=2bMB9>Yt1p1%#Zc%EpY`a#q ze0Pe?x&dyhgPiP>oXi_rVr|mv^j7K5A5^<{7$sIo6iQxRtLuyIj4HnM7;yET z5&egi}p!V~&a{=?>R-Def6J{i%^X^REn2K-N{pxD@Tm3$7K21G8 zzPA6`WZ _nQq5{n)1}ER({I09KiOJyXX$~# zJHLBW^j&Dnxo#=nCOUfjqg}!0&+oo}eZRcs!Pc$YV}<^DbpA%xxixdfva;mo8*1Jy z*^n$#J+xn5^8Kdv)0-+b_DA*BBnL=s$qYQYXLm RBjW9`uMEp2GPI>)t5%%R zJ+yw|fk}oVU(UV>;io);DD>W0tJ~Q^RQu`aJ{$NR1OAJ!0Qy^r=3g#EEUEO{Zf2o9 z7ExbM=M~ONMSBGV=+I8~%VOD`!Z?Ny+Wd3&+?};qMITkDXc+$vK8*n%O@u6CSRql7 xtD_gGM1_UNt5{jikFomaTNEL* A~t>MCVV*k_sOSXZM{{fd;5vc$G literal 0 HcmV?d00001 diff --git a/public/javascripts/ckeditor/_samples/assets/output_xhtml.css b/public/javascripts/ckeditor/_samples/assets/output_xhtml.css new file mode 100644 index 00000000..79ffb98d --- /dev/null +++ b/public/javascripts/ckeditor/_samples/assets/output_xhtml.css @@ -0,0 +1,204 @@ +/* + * Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. + * For licensing, see LICENSE.html or http://ckeditor.com/license + * + * Styles used by the XHTML 1.1 sample page (xhtml.html). + */ + +/** + * Basic definitions for the editing area. + */ +body +{ + font-family: Arial, Verdana, sans-serif; + font-size: 80%; + color: #000000; + background-color: #ffffff; + padding: 5px; + margin: 0px; +} + +/** + * Core styles. + */ + +.Bold +{ + font-weight: bold; +} + +.Italic +{ + font-style: italic; +} + +.Underline +{ + text-decoration: underline; +} + +.StrikeThrough +{ + text-decoration: line-through; +} + +.Subscript +{ + vertical-align: sub; + font-size: smaller; +} + +.Superscript +{ + vertical-align: super; + font-size: smaller; +} + +/** + * Font faces. + */ + +.FontComic +{ + font-family: 'Comic Sans MS'; +} + +.FontCourier +{ + font-family: 'Courier New'; +} + +.FontTimes +{ + font-family: 'Times New Roman'; +} + +/** + * Font sizes. + */ + +.FontSmaller +{ + font-size: smaller; +} + +.FontLarger +{ + font-size: larger; +} + +.FontSmall +{ + font-size: 8pt; +} + +.FontBig +{ + font-size: 14pt; +} + +.FontDouble +{ + font-size: 200%; +} + +/** + * Font colors. + */ +.FontColor1 +{ + color: #ff9900; +} + +.FontColor2 +{ + color: #0066cc; +} + +.FontColor3 +{ + color: #ff0000; +} + +.FontColor1BG +{ + background-color: #ff9900; +} + +.FontColor2BG +{ + background-color: #0066cc; +} + +.FontColor3BG +{ + background-color: #ff0000; +} + +/** + * Indentation. + */ + +.Indent1 +{ + margin-left: 40px; +} + +.Indent2 +{ + margin-left: 80px; +} + +.Indent3 +{ + margin-left: 120px; +} + +/** + * Alignment. + */ + +.JustifyLeft +{ + text-align: left; +} + +.JustifyRight +{ + text-align: right; +} + +.JustifyCenter +{ + text-align: center; +} + +.JustifyFull +{ + text-align: justify; +} + +/** + * Other. + */ + +code +{ + font-family: courier, monospace; + background-color: #eeeeee; + padding-left: 1px; + padding-right: 1px; + border: #c0c0c0 1px solid; +} + +kbd +{ + padding: 0px 1px 0px 1px; + border-width: 1px 2px 2px 1px; + border-style: solid; +} + +blockquote +{ + color: #808080; +} diff --git a/public/javascripts/ckeditor/_samples/assets/swfobject.js b/public/javascripts/ckeditor/_samples/assets/swfobject.js new file mode 100644 index 00000000..ef6d3b75 --- /dev/null +++ b/public/javascripts/ckeditor/_samples/assets/swfobject.js @@ -0,0 +1,18 @@ +/** + * 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 + * + */ +/* +Copyright (c) 2007 Geoff Stearns + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +/*jsl:ignoreall*/ +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(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="
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. + *+ *
+ * @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- CKEDITOR.SHRINK_ELEMENT
+ *- Shrink the range boundaries to the edge of the innermost element.
+ *- CKEDITOR.SHRINK_TEXT
+ *- 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.
+ *
. + // Note: bogus
added underor
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(); + }, + + /** + * Check if elements at which the range boundaries anchor are read-only, + * with respect to "contenteditable" attribute. + */ + checkReadOnly : ( function() + { + function checkNodesEditable( node, anotherEnd ) + { + while( node ) + { + if ( node.type == CKEDITOR.NODE_ELEMENT ) + { + if ( node.getAttribute( 'contentEditable' ) == 'false' + && !node.data( 'cke-editable' ) ) + { + return 0; + } + // Range enclosed entirely in an editable element. + else if ( node.is( 'body' ) + || node.getAttribute( 'contentEditable' ) == 'true' + && ( node.contains( anotherEnd ) || node.equals( anotherEnd ) ) ) + { + break; + } + } + node = node.getParent(); + } + + return 1; + } + + return function() + { + var startNode = this.startContainer, + endNode = this.endContainer; + + // Check if elements path at both boundaries are editable. + return !( checkNodesEditable( startNode, endNode ) && checkNodesEditable( endNode, startNode ) ); + }; + })(), + + /** + * Moves the range boundaries to the first/end editing point inside an + * element. For example, in an element tree like + * "<p><b><i></i></b> Text</p>", the start editing point is + * "<p><b><i>^</i></b> Text</p>" (inside <i>). + * @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 ). + 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; //
^contents "^text" +CKEDITOR.POSITION_BEFORE_END = 2; //contents^ "text^" +CKEDITOR.POSITION_BEFORE_START = 3; // ^contents ^"text" +CKEDITOR.POSITION_AFTER_END = 4; //contents ^ "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; diff --git a/public/javascripts/ckeditor/_source/core/dom/rangelist.js b/public/javascripts/ckeditor/_source/core/dom/rangelist.js new file mode 100644 index 00000000..26855062 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/dom/rangelist.js @@ -0,0 +1,213 @@ +/* +Copyright (c) 2003-2011, 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 + */ diff --git a/public/javascripts/ckeditor/_source/core/dom/text.js b/public/javascripts/ckeditor/_source/core/dom/text.js new file mode 100644 index 00000000..4abf8fc3 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/dom/text.js @@ -0,0 +1,128 @@ +/* +Copyright (c) 2003-2011, 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; + }, + + setText : function( text ) + { + this.$.nodeValue = text; + }, + + /** + * 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 ); + } + }); diff --git a/public/javascripts/ckeditor/_source/core/dom/walker.js b/public/javascripts/ckeditor/_source/core/dom/walker.js new file mode 100644 index 00000000..e993f4d3 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/dom/walker.js @@ -0,0 +1,460 @@ +/* +Copyright (c) 2003-2011, 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: + * + * [<p>Some <b>sample] text</b> + * + * While walking forward into the above range, the following nodes are + * returned: <p>, "Some ", <b> 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 +// * <body> 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. we're checking here + // 'offsetHeight' instead of 'offsetWidth' for properly excluding + // all sorts of empty paragraph, e.g.
. + var isInvisible = whitespace( node ) || node.is && !node.$.offsetHeight; + return !! ( isReject ^ isInvisible ); + }; + }; + + CKEDITOR.dom.walker.nodeType = function( type, isReject ) + { + return function( node ) + { + return !! ( isReject ^ ( node.type == type ) ); + }; + }; + + var tailNbspRegex = /^[\t\r\n ]*(?: |\xa0)$/, + isWhitespaces = CKEDITOR.dom.walker.whitespaces(), + isBookmark = CKEDITOR.dom.walker.bookmark(), + toSkip = function( node ) + { + return isBookmark( node ) + || isWhitespaces( node ) + || node.type == CKEDITOR.NODE_ELEMENT + && node.getName() in CKEDITOR.dtd.$inline + && !( node.getName() in CKEDITOR.dtd.$empty ); + }; + + // Check if there's a filler node at the end of an element, and return it. + CKEDITOR.dom.element.prototype.getBogus = function() + { + // Bogus are not always at the end, e.g. (#7070). + var tail = this; + do { tail = tail.getPreviousSourceNode(); } + while ( toSkip( tail ) ) + + if ( tail && ( !CKEDITOR.env.ie ? tail.is && tail.is( 'br' ) + : tail.getText && tailNbspRegex.test( tail.getText() ) ) ) + { + return tail; + } + return false; + }; + +})(); diff --git a/public/javascripts/ckeditor/_source/core/dom/window.js b/public/javascripts/ckeditor/_source/core/dom/window.js new file mode 100644 index 00000000..c5492b6f --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/dom/window.js @@ -0,0 +1,96 @@ +/* +Copyright (c) 2003-2011, 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 ); + * win.focus(); + */ + 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 = win.getViewPaneSize(); + * 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 = win.getScrollPosition(); + * 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 + }; + } + } + }); diff --git a/public/javascripts/ckeditor/_source/core/dtd.js b/public/javascripts/ckeditor/_source/core/dtd.js new file mode 100644 index 00000000..105e9967 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/dtd.js @@ -0,0 +1,238 @@ +/* +Copyright (c) 2003-2011, 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.
+ *
+ * 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.
+ *
+ * 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 (<span> like) elements. + */ + $inline : L, // Just like span. + + /** + * list of elements that can be children at <body>. + */ + $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 ) diff --git a/public/javascripts/ckeditor/_source/core/editor.js b/public/javascripts/ckeditor/_source/core/editor.js new file mode 100644 index 00000000..352c4b22 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/editor.js @@ -0,0 +1,985 @@ +/* +Copyright (c) 2003-2011, 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 tabbing + * navigation 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.langEntries || !plugin.langEntries[ 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.langEntries[ 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.langEntries[ 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.length ) + { + 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( editor.element.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( editor.name ); "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( editor.config.theme ); "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" + * CKEDITOR.instances.editor1.destroy(); + * alert( CKEDITOR.instances.editor1 ); "undefined" + */ + destroy : function( noUpdate ) + { + if ( !noUpdate ) + this.updateElement(); + + this.fire( 'destroy' ); + this.theme && this.theme.destroy( this ); + + 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.getData() == '' ) + * 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.loadSnapshot( data ); + */ + loadSnapshot : function( snapshot ) + { + this.fire( 'loadSnapshot', snapshot ); + }, + + /** + * Sets the editor data. The data must be provided in raw format (HTML).
+ *
+ * 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. + *@param {Boolean} internal Whether suppress any event firing when copying data internally inside editor. + * @example + * CKEDITOR.instances.editor1.setData( '<p>This is the editor data.</p>' ); + * @example + * CKEDITOR.instances.editor1.setData( '<p>Some other editor data.</p>', function() + * { + * this.checkDirty(); // true + * }); + */ + setData : function( data , callback, internal ) + { + if( callback ) + { + this.on( 'dataReady', function( evt ) + { + evt.removeListener(); + callback.call( evt.editor ); + } ); + } + + // Fire "setData" so data manipulation may happen. + var eventData = { dataValue : data }; + !internal && this.fire( 'setData', eventData ); + + this._.data = eventData.dataValue; + + !internal && 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.insertHtml( '<p>This is a new paragraph.</p>' ); + */ + 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. + * Note: 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 <br />. + * @since 3.5 + * @param {String} text Text to be inserted into the editor. + * @example + * CKEDITOR.instances.editor1.insertText( ' line1 \n\n line2' ); + */ + 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( '<img src="hello.png" border="0" title="Hello" />' ); + * CKEDITOR.instances.editor1.insertElement( element ); + */ + 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.checkDirty() ) + * 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.resetDirty(); + * alert( editor.checkDirty() ); // "false" + */ + resetDirty : function() + { + if ( this.mayBeDirty ) + this._.previousValue = this.getSnapshot(); + }, + + /** + * Updates the <textarea> 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.editor#pluginsLoaded + * @event + * @param {CKEDITOR.editor} editor This editor instance. + */ + +/** + * 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.
+ *
+ * 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' ); + */ + +/** + * Fired when this editor instance is destroyed. The editor at this + * point isn't usable and this event should be used to perform clean up + * in any plugin. + * @name CKEDITOR.editor#destroy + * @event + */ + +/** + * Internal event to get the current data. + * @name CKEDITOR.editor#beforeGetData + * @event + */ + +/** + * Internal event to perform the #getSnapshot call. + * @name CKEDITOR.editor#getSnapshot + * @event + */ + +/** + * Internal event to perform the #loadSnapshot call. + * @name CKEDITOR.editor#loadSnapshot + * @event + */ + + +/** + * Event fired before the #getData call returns allowing additional manipulation. + * @name CKEDITOR.editor#getData + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {String} data.dataValue The data that will be returned. + */ + +/** + * Event fired before the #setData call is executed allowing additional manipulation. + * @name CKEDITOR.editor#setData + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {String} data.dataValue The data that will be used. + */ + +/** + * Event fired at the end of the #setData call is executed. Usually it's better to use the + * {@link CKEDITOR.editor.prototype.dataReady} event. + * @name CKEDITOR.editor#afterSetData + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {String} data.dataValue The data that has been set. + */ + +/** + * Internal event to perform the #insertHtml call + * @name CKEDITOR.editor#insertHtml + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {String} data The HTML to insert. + */ + +/** + * Internal event to perform the #insertText call + * @name CKEDITOR.editor#insertText + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {String} text The text to insert. + */ + +/** + * Internal event to perform the #insertElement call + * @name CKEDITOR.editor#insertElement + * @event + * @param {CKEDITOR.editor} editor This editor instance. + * @param {Object} element The element to insert. + */ diff --git a/public/javascripts/ckeditor/_source/core/editor_basic.js b/public/javascripts/ckeditor/_source/core/editor_basic.js new file mode 100644 index 00000000..8d109c82 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/editor_basic.js @@ -0,0 +1,186 @@ +/* +Copyright (c) 2003-2011, 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: + *+ *
+ * @name CKEDITOR.editor.prototype.elementMode + * @type Number + * @example + * var editor = CKEDITOR.replace( 'editor1' ); + * alert( editor.elementMode ); "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 <textarea> 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 ); + + // Elements that should go into head are unacceptable (#6791). + if ( element && element.tagName.toLowerCase() in {style:1,script:1,base:1,link:1,meta:1,title:1} ) + element = null; + + // 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 ); +} diff --git a/public/javascripts/ckeditor/_source/core/env.js b/public/javascripts/ckeditor/_source/core/env.js new file mode 100644 index 00000000..dab70d9a --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/env.js @@ -0,0 +1,282 @@ +/* +Copyright (c) 2003-2011, 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 Internet Explorer 9's standards mode. + * @name CKEDITOR.env.ie9Compat + * @type Boolean + * @example + * if ( CKEDITOR.env.ie9Compat ) + * alert( "IE9, the beauty of the web!" ); + */ + env.ie9Compat = document.documentMode == 9; + + /** + * 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.- {@link CKEDITOR.ELEMENT_MODE_NONE}: No element is linked to the + * editor instance.
+ *- {@link CKEDITOR.ELEMENT_MODE_REPLACE}: The element is to be + * replaced by the editor instance.
+ *- {@link CKEDITOR.ELEMENT_MODE_APPENDTO}: The editor is to be + * created inside the element.
+ *
+ *
+ * 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).
+ *
+ * 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 && CKEDITOR.env.version <= 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 ) diff --git a/public/javascripts/ckeditor/_source/core/event.js b/public/javascripts/ckeditor/_source/core/event.js new file mode 100644 index 00000000..fa190603 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/event.js @@ -0,0 +1,342 @@ +/* +Copyright (c) 2003-2011, 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.
+ *
+ * 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' }; + * CKEDITOR.event.implementOn( myObject }; + * 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() { ... } ); + * someObject.fire( 'someEvent' ); // both listeners are called + * @example + * someObject.on( 'someEvent', function( event ) + * { + * alert( event.data ); // "Example" + * }); + * someObject.fire( 'someEvent', 'Example' ); + */ + 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 + * someObject.fireOnce( 'someEvent' ); // 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 + * someObject.removeListener( 'someEvent', myListener ); + * 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.hasListeners( 'someEvent' ) ); // "true" + * alert( someObject.hasListeners( 'noEvent' ) ); // "false" + */ + hasListeners : function( eventName ) + { + var event = getPrivate( this )[ eventName ]; + return ( event && event.listeners.length > 0 ) ; + } + }; + })(); +} diff --git a/public/javascripts/ckeditor/_source/core/eventInfo.js b/public/javascripts/ckeditor/_source/core/eventInfo.js new file mode 100644 index 00000000..0f313e86 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/eventInfo.js @@ -0,0 +1,120 @@ +/* +Copyright (c) 2003-2011, 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( event.name ); // "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( event.sender == 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( event.editor == myEditor ); // "true" + * }); + * myButton.fire( 'someEvent', null, myEditor ); + */ + +/** + * 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( event.data ); // "Example" + * }); + * someObject.fire( 'someEvent', 'Example' ); + */ + +/** + * Any extra data appended during the listener registration. + * @name CKEDITOR.eventInfo.prototype.listenerData + * @field + * @type Object + * @example + * someObject.on( 'someEvent', function( event ) + * { + * alert( event.listenerData ); // "Example" + * } + * , null, 'Example' ); + */ + +/** + * Indicates that no further listeners are to be called. + * @name CKEDITOR.eventInfo.prototype.stop + * @function + * @example + * someObject.on( 'someEvent', function( event ) + * { + * event.stop(); + * }); + * 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 ) + * { + * event.cancel(); + * }); + * someObject.on( 'someEvent', function( event ) + * { + * // This one will not be called. + * }); + * alert( someObject.fire( 'someEvent' ) ); // "true" + */ diff --git a/public/javascripts/ckeditor/_source/core/focusmanager.js b/public/javascripts/ckeditor/_source/core/focusmanager.js new file mode 100644 index 00000000..e59900de --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/focusmanager.js @@ -0,0 +1,152 @@ +/* +Copyright (c) 2003-2011, 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 = new CKEDITOR.focusManager( editor ); + * 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.
+ *
+ * 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; + * editor.focusManager.focus(); + */ + 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.
+ *
+ * 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; + * editor.focusManager.blur(); + */ + 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; + * editor.focusManager.forceBlur(); + */ + 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' ); + * }); + */ diff --git a/public/javascripts/ckeditor/_source/core/htmlparser.js b/public/javascripts/ckeditor/_source/core/htmlparser.js new file mode 100644 index 00000000..93a86b79 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser.js @@ -0,0 +1,224 @@ +/* +Copyright (c) 2003-2011, 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( '<p>Some <b>text</b>.</p>' ); + */ +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( "<!-- Example --><b>Hello</b>" ); + */ + 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( "<!-- Example --><b>Hello</b>" ); + */ + 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( "<!-- Example --><b>Hello</b>" ); + */ + 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( "<script>var hello;</script>" ); + */ + 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( "<!-- Example --><b>Hello</b>" ); + */ + 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( "<!-- Example --><b>Hello</b>" ); + */ + 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 ) ); + } + }; +})(); diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/basicwriter.js b/public/javascripts/ckeditor/_source/core/htmlparser/basicwriter.js new file mode 100644 index 00000000..010ae74e --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/basicwriter.js @@ -0,0 +1,145 @@ +/* +Copyright (c) 2003-2011, 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 "<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 ">". + * writer.openTagClose( 'p', false ); + * @example + * // Writes " />". + * 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 "</p>". + * 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 "<!-- My comment -->". + * writer.comment( ' My comment ' ); + */ + comment : function( comment ) + { + this._.output.push( '' ); + }, + + /** + * Writes any kind of data to the ouput. + * @example + * writer.write( 'This is an <b>example</b>.' ); + */ + 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; + } + } +}); diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/cdata.js b/public/javascripts/ckeditor/_source/core/htmlparser/cdata.js new file mode 100644 index 00000000..422f603e --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/cdata.js @@ -0,0 +1,43 @@ +/* +Copyright (c) 2003-2011, 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 ); + } + }; +})(); diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/comment.js b/public/javascripts/ckeditor/_source/core/htmlparser/comment.js new file mode 100644 index 00000000..a55b489c --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/comment.js @@ -0,0 +1,60 @@ +/* +Copyright (c) 2003-2011, 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 ); + } +}; diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/element.js b/public/javascripts/ckeditor/_source/core/htmlparser/element.js new file mode 100644 index 00000000..84a452ef --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/element.js @@ -0,0 +1,249 @@ +/* +Copyright (c) 2003-2011, 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 || ''; + + // Reveal the real semantic of our internal custom tag name (#6639). + var internalTag = tagName.match( /^cke:(.*)/ ); + internalTag && ( tagName = internalTag[ 1 ] ); + + 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(), 0, element.clone() ).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 ); + + } + }; +})(); diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/filter.js b/public/javascripts/ckeditor/_source/core/htmlparser/filter.js new file mode 100644 index 00000000..a1f16e2a --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/filter.js @@ -0,0 +1,288 @@ +/* +Copyright (c) 2003-2011, 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(); + } +}; +*/ diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/fragment.js b/public/javascripts/ckeditor/_source/core/htmlparser/fragment.js new file mode 100644 index 00000000..8c3ad5d3 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/fragment.js @@ -0,0 +1,492 @@ +/* +Copyright (c) 2003-2011, 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( 'Sample 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() +{ + // 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 ); + + var listBlocks = { ol:1, ul:1 }; + + // Dtd of the fragment element, basically it accept anything except for intermediate structure, e.g. orphan- . + var rootDtd = CKEDITOR.tools.extend( {}, { html: 1 }, CKEDITOR.dtd.html, CKEDITOR.dtd.body, CKEDITOR.dtd.head, { style:1,script:1 } ); + + /** + * 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. + * @param {CKEDITOR.htmlParser.element} contextNode Parse the html as the content of this element. + * @returns CKEDITOR.htmlParser.fragment The fragment created. + * @example + * var fragment = CKEDITOR.htmlParser.fragment.fromHtml( 'Sample Text' ); + * alert( fragment.children[0].name ); "b" + * alert( fragment.children[1].value ); " Text" + */ + CKEDITOR.htmlParser.fragment.fromHtml = function( fragmentHtml, fixForBody, contextNode ) + { + var parser = new CKEDITOR.htmlParser(), + fragment = contextNode || new CKEDITOR.htmlParser.fragment(), + pendingInline = [], + pendingBRs = [], + currentNode = fragment, + // Indicate we're inside a
element, spaces should be touched differently. + inPre = false; + + 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() + { + while ( pendingBRs.length ) + currentNode.add( pendingBRs.shift() ); + } + + /* + * Beside of simply append specified element to target, this function also takes + * care of other dirty lifts like forcing block in body, trimming spaces at + * the block boundaries etc. + * + * @param {Element} element The element to be added as the last child of {@link target}. + * @param {Element} target The parent element to relieve the new node. + * @param {Boolean} [moveCurrent=false] Don't change the "currentNode" global unless + * there's a return point node specified on the element, otherwise move current onto {@link target} node. + */ + function addElement( element, target, moveCurrent ) + { + // Ignore any element that has already been added. + if ( element.previous !== undefined ) + return; + + target = target || currentNode || fragment; + + // Current element might be mangled by fix body below, + // save it for restore later. + var savedCurrent = currentNode; + + // If the target is the fragment and this inline element can't go inside + // body (if fixForBody). + if ( fixForBody && ( !target.type || target.name == 'body' ) ) + { + 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 == 'body' || element.isOrphan ) ) + { + // Create ain the fragment. + currentNode = target; + parser.onTagOpen( fixForBody, {} ); + + // The new target now is the
. + element.returnPoint = target = currentNode; + } + } + + // 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; + } + else + currentNode = moveCurrent ? target : savedCurrent; + } + + parser.onTagOpen = function( tagName, attributes, selfClosing, optionalClose ) + { + 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; + + element.isOptionalClose = optionalClose; + + // 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; + } + + while( 1 ) + { + var currentName = currentNode.name; + + var currentDtd = currentName ? ( CKEDITOR.dtd[ currentName ] + || ( currentNode._.isBlockLike ? CKEDITOR.dtd.div : CKEDITOR.dtd.span ) ) + : rootDtd; + + // If the element cannot be child of the current element. + if ( !element.isUnknown && !currentNode.isUnknown && !currentDtd[ tagName ] ) + { + // Current node doesn't have a close tag, time for a close + // as this element isn't fit in. (#7497) + if ( currentNode.isOptionalClose ) + parser.onTagClose( currentName ); + // Fixing malformed nested lists by moving it into a previous list item. (#3828) + else 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 == 'li' ) ) + addElement( ( lastChild = new CKEDITOR.htmlParser.element( 'li' ) ), currentNode ); + + !element.returnPoint && ( element.returnPoint = currentNode ); + currentNode = lastChild; + } + // Establish new list root for orphan list items. + else if ( tagName in CKEDITOR.dtd.$listItem && currentName != tagName ) + parser.onTagOpen( tagName == 'li' ? 'ul' : 'dl', {}, 0, 1 ); + // We're inside a structural block like table and list, AND the incoming element + // is not of the same type (e.g.
td1 td2 ), we simply add this new one before it, + // and most importantly, return back to here once this element is added, + // e.g.+ else if ( currentName in nonBreakingBlocks && currentName != tagName ) + { + !element.returnPoint && ( element.returnPoint = currentNode ); + currentNode = currentNode.parent; + } + else + { + // The current element is an inline element, which + // need to be continued even after the close, so put + // it in the pending list. + if ( currentName in CKEDITOR.dtd.$inline ) + pendingInline.unshift( currentNode ); + + // The most common case where we just need to close the + // current one and append the new one to the parent. + if ( currentNode.parent ) + addElement( currentNode, currentNode.parent, 1 ); + // We've tried our best to fix the embarrassment here, while + // this element still doesn't find it's parent, mark it as + // orphan and show our tolerance to it. + else + { + element.isOrphan = 1; + break; + } + } + } + else + break; + } + + checkPending( tagName ); + sendPendingBRs(); + + element.parent = currentNode; + + 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 != fragment && 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 ); + + // Make sure return point is properly restored. + candidate = candidate.returnPoint || candidate.parent; + } + + if ( candidate != fragment ) + { + // 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
td1 p1
td2 . + 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, {}, 0, 1 ); + } + + // 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 ) + { + sendPendingBRs(); + 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, make sure return point is properly restored. + while ( currentNode != fragment ) + addElement( currentNode, currentNode.parent, 1 ); + + 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( '<P><B>Example' ); + * fragment.writeHtml( writer ) + * alert( writer.getHtml() ); "<p><b>Example</b></p>" + */ + 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 ); + } + }; +})(); diff --git a/public/javascripts/ckeditor/_source/core/htmlparser/text.js b/public/javascripts/ckeditor/_source/core/htmlparser/text.js new file mode 100644 index 00000000..02f89358 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/htmlparser/text.js @@ -0,0 +1,55 @@ +/* +Copyright (c) 2003-2011, 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 ); + } + }; +})(); diff --git a/public/javascripts/ckeditor/_source/core/lang.js b/public/javascripts/ckeditor/_source/core/lang.js new file mode 100644 index 00000000..3dc043d7 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/lang.js @@ -0,0 +1,156 @@ +/* +Copyright (c) 2003-2011, 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; + } + }; + +})(); diff --git a/public/javascripts/ckeditor/_source/core/loader.js b/public/javascripts/ckeditor/_source/core/loader.js new file mode 100644 index 00000000..0cda9c74 --- /dev/null +++ b/public/javascripts/ckeditor/_source/core/loader.js @@ -0,0 +1,240 @@ +/* +Copyright (c) 2003-2011, 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/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' : [] + }; + + 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 ' + + ''; + + var src = + CKEDITOR.env.air ? + 'javascript:void(0)' : + isCustomDomain ? + 'javascript:void((function(){' + + 'document.open();' + + 'document.domain=\'' + document.domain + '\';' + + 'document.close();' + + '})())"' + : + ''; + + var iframe = CKEDITOR.dom.element.createFromHtml( + '' ); + + iframe.on( 'load', function( e ) + { + e.removeListener(); + + var doc = iframe.getFrameDocument(); + doc.write( htmlToLoad ); + + if ( CKEDITOR.env.air ) + onPasteFrameLoad.call( this, doc.getWindow().$ ); + }, + this ); + + iframe.setCustomData( 'dialog', this ); + + var field = this.getContentElement( 'general', 'editing_area' ), + container = field.getElement(); + container.setHtml( '' ); + container.append( iframe ); + + // IE need a redirect on focus to make + // the cursor blinking inside iframe. (#5461) + if ( CKEDITOR.env.ie ) + { + var focusGrabber = CKEDITOR.dom.element.createFromHtml( '' ); + focusGrabber.on( 'focus', function() + { + iframe.$.contentWindow.focus(); + }); + container.append( focusGrabber ); + + // Override focus handler on field. + field.focus = function() + { + focusGrabber.focus(); + this.fire( 'focus' ); + }; + } + + field.getInputElement = function(){ return iframe; }; + + // Force container to scale in IE. + if ( CKEDITOR.env.ie ) + { + container.setStyle( 'display', 'block' ); + container.setStyle( 'height', ( iframe.$.offsetHeight + 2 ) + 'px' ); + } + }, + + onHide : function() + { + if ( CKEDITOR.env.ie ) + this.getParentEditor().document.getBody().$.contentEditable = 'true'; + }, + + onLoad : function() + { + if ( ( CKEDITOR.env.ie7Compat || CKEDITOR.env.ie6Compat ) && editor.lang.dir == 'rtl' ) + this.parts.contents.setStyle( 'overflow', 'hidden' ); + }, + + onOk : function() + { + var container = this.getContentElement( 'general', 'editing_area' ).getElement(), + iframe = container.getElementsByTag( 'iframe' ).getItem( 0 ), + editor = this.getParentEditor(), + body = iframe.getFrameDocument().getBody(), + bogus = body.getBogus(), + html; + bogus && bogus.remove(); + // Saving the contents in variable so changes until paste is complete will not take place (#7500) + html = body.getHtml(); + + setTimeout( function(){ + editor.fire( 'paste', { 'html' : html } ); + }, 0 ); + + }, + + contents : [ + { + id : 'general', + label : editor.lang.common.generalTab, + elements : [ + { + type : 'html', + id : 'securityMsg', + html : '' + lang.securityMsg + '' + }, + { + type : 'html', + id : 'pasteMsg', + html : ''+lang.pasteMsg +'' + }, + { + type : 'html', + id : 'editing_area', + style : 'width: 100%; height: 100%;', + html : '', + focus : function() + { + var win = this.getInputElement().$.contentWindow; + + // #3291 : JAWS needs the 500ms delay to detect that the editor iframe + // iframe is no longer editable. So that it will put the focus into the + // Paste from Word dialog's editable area instead. + setTimeout( function() + { + win.focus(); + }, 500 ); + } + } + ] + } + ] + }; +}); diff --git a/public/javascripts/ckeditor/_source/plugins/clipboard/plugin.js b/public/javascripts/ckeditor/_source/plugins/clipboard/plugin.js new file mode 100644 index 00000000..51f53e97 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/clipboard/plugin.js @@ -0,0 +1,452 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +/** + * @file Clipboard support + */ + +(function() +{ + // Tries to execute any of the paste, cut or copy commands in IE. Returns a + // boolean indicating that the operation succeeded. + var execIECommand = function( editor, command ) + { + var doc = editor.document, + body = doc.getBody(); + + var enabled = 0; + var onExec = function() + { + enabled = 1; + }; + + // The following seems to be the only reliable way to detect that + // clipboard commands are enabled in IE. It will fire the + // onpaste/oncut/oncopy events only if the security settings allowed + // the command to execute. + body.on( command, onExec ); + + // IE6/7: document.execCommand has problem to paste into positioned element. + ( CKEDITOR.env.version > 7 ? doc.$ : doc.$.selection.createRange() ) [ 'execCommand' ]( command ); + + body.removeListener( command, onExec ); + + return enabled; + }; + + // Attempts to execute the Cut and Copy operations. + var tryToCutCopy = + CKEDITOR.env.ie ? + function( editor, type ) + { + return execIECommand( editor, type ); + } + : // !IE. + function( editor, type ) + { + try + { + // Other browsers throw an error if the command is disabled. + return editor.document.$.execCommand( type, false, null ); + } + catch( e ) + { + return false; + } + }; + + // A class that represents one of the cut or copy commands. + var cutCopyCmd = function( type ) + { + this.type = type; + this.canUndo = this.type == 'cut'; // We can't undo copy to clipboard. + this.startDisabled = true; + }; + + cutCopyCmd.prototype = + { + exec : function( editor, data ) + { + this.type == 'cut' && fixCut( editor ); + + var success = tryToCutCopy( editor, this.type ); + + if ( !success ) + alert( editor.lang.clipboard[ this.type + 'Error' ] ); // Show cutError or copyError. + + return success; + } + }; + + // Paste command. + var pasteCmd = + { + canUndo : false, + + exec : + CKEDITOR.env.ie ? + function( editor ) + { + // Prevent IE from pasting at the begining of the document. + editor.focus(); + + if ( !editor.document.getBody().fire( 'beforepaste' ) + && !execIECommand( editor, 'paste' ) ) + { + editor.fire( 'pasteDialog' ); + return false; + } + } + : + function( editor ) + { + try + { + if ( !editor.document.getBody().fire( 'beforepaste' ) + && !editor.document.$.execCommand( 'Paste', false, null ) ) + { + throw 0; + } + } + catch ( e ) + { + setTimeout( function() + { + editor.fire( 'pasteDialog' ); + }, 0 ); + return false; + } + } + }; + + // Listens for some clipboard related keystrokes, so they get customized. + var onKey = function( event ) + { + if ( this.mode != 'wysiwyg' ) + return; + + switch ( event.data.keyCode ) + { + // Paste + case CKEDITOR.CTRL + 86 : // CTRL+V + case CKEDITOR.SHIFT + 45 : // SHIFT+INS + + var body = this.document.getBody(); + + // Simulate 'beforepaste' event for all none-IEs. + if ( !CKEDITOR.env.ie && body.fire( 'beforepaste' ) ) + event.cancel(); + // Simulate 'paste' event for Opera/Firefox2. + else if ( CKEDITOR.env.opera + || CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) + body.fire( 'paste' ); + return; + + // Cut + case CKEDITOR.CTRL + 88 : // CTRL+X + case CKEDITOR.SHIFT + 46 : // SHIFT+DEL + + // Save Undo snapshot. + var editor = this; + this.fire( 'saveSnapshot' ); // Save before paste + setTimeout( function() + { + editor.fire( 'saveSnapshot' ); // Save after paste + }, 0 ); + } + }; + + function cancel( evt ) { evt.cancel(); } + + // Allow to peek clipboard content by redirecting the + // pasting content into a temporary bin and grab the content of it. + function getClipboardData( evt, mode, callback ) + { + var doc = this.document; + + // Avoid recursions on 'paste' event or consequent paste too fast. (#5730) + if ( doc.getById( 'cke_pastebin' ) ) + return; + + // If the browser supports it, get the data directly + if ( mode == 'text' && evt.data && evt.data.$.clipboardData ) + { + // evt.data.$.clipboardData.types contains all the flavours in Mac's Safari, but not on windows. + var plain = evt.data.$.clipboardData.getData( 'text/plain' ); + if ( plain ) + { + evt.data.preventDefault(); + callback( plain ); + return; + } + } + + var sel = this.getSelection(), + range = new CKEDITOR.dom.range( doc ); + + // Create container to paste into + var pastebin = new CKEDITOR.dom.element( mode == 'text' ? 'textarea' : CKEDITOR.env.webkit ? 'body' : 'div', doc ); + pastebin.setAttribute( 'id', 'cke_pastebin' ); + // Safari requires a filler node inside the div to have the content pasted into it. (#4882) + CKEDITOR.env.webkit && pastebin.append( doc.createText( '\xa0' ) ); + doc.getBody().append( pastebin ); + + pastebin.setStyles( + { + position : 'absolute', + // Position the bin exactly at the position of the selected element + // to avoid any subsequent document scroll. + top : sel.getStartElement().getDocumentPosition().y + 'px', + width : '1px', + height : '1px', + overflow : 'hidden' + }); + + // It's definitely a better user experience if we make the paste-bin pretty unnoticed + // by pulling it off the screen. + pastebin.setStyle( this.config.contentsLangDirection == 'ltr' ? 'left' : 'right', '-1000px' ); + + var bms = sel.createBookmarks(); + + this.on( 'selectionChange', cancel, null, null, 0 ); + + // Turn off design mode temporarily before give focus to the paste bin. + if ( mode == 'text' ) + { + if ( CKEDITOR.env.ie ) + { + var ieRange = doc.getBody().$.createTextRange(); + ieRange.moveToElementText( pastebin.$ ); + ieRange.execCommand( 'Paste' ); + evt.data.preventDefault(); + } + else + pastebin.$.focus(); + } + else + { + range.setStartAt( pastebin, CKEDITOR.POSITION_AFTER_START ); + range.setEndAt( pastebin, CKEDITOR.POSITION_BEFORE_END ); + range.select( true ); + } + + var editor = this; + // Wait a while and grab the pasted contents + window.setTimeout( function() + { + mode == 'text' && CKEDITOR.env.gecko && editor.focusGrabber.focus(); + pastebin.remove(); + editor.removeListener( 'selectionChange', cancel ); + + // Grab the HTML contents. + // We need to look for a apple style wrapper on webkit it also adds + // a div wrapper if you copy/paste the body of the editor. + // Remove hidden div and restore selection. + var bogusSpan; + pastebin = ( CKEDITOR.env.webkit + && ( bogusSpan = pastebin.getFirst() ) + && ( bogusSpan.is && bogusSpan.hasClass( 'Apple-style-span' ) ) ? + bogusSpan : pastebin ); + + sel.selectBookmarks( bms ); + callback( pastebin[ 'get' + ( mode == 'text' ? 'Value' : 'Html' ) ]() ); + }, 0 ); + } + + // Cutting off control type element in IE standards breaks the selection entirely. (#4881) + function fixCut( editor ) + { + if ( !CKEDITOR.env.ie || CKEDITOR.env.quirks ) + return; + + var sel = editor.getSelection(); + var control; + if( ( sel.getType() == CKEDITOR.SELECTION_ELEMENT ) && ( control = sel.getSelectedElement() ) ) + { + var range = sel.getRanges()[ 0 ]; + var dummy = editor.document.createText( '' ); + dummy.insertBefore( control ); + range.setStartBefore( dummy ); + range.setEndAfter( control ); + sel.selectRanges( [ range ] ); + + // Clear up the fix if the paste wasn't succeeded. + setTimeout( function() + { + // Element still online? + if ( control.getParent() ) + { + dummy.remove(); + sel.selectElement( control ); + } + }, 0 ); + } + } + + var depressBeforeEvent; + function stateFromNamedCommand( command, editor ) + { + // IE Bug: queryCommandEnabled('paste') fires also 'beforepaste(copy/cut)', + // guard to distinguish from the ordinary sources( either + // keyboard paste or execCommand ) (#4874). + CKEDITOR.env.ie && ( depressBeforeEvent = 1 ); + + var retval = editor.document.$.queryCommandEnabled( command ) ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED; + depressBeforeEvent = 0; + return retval; + } + + var inReadOnly; + function setToolbarStates() + { + if ( this.mode != 'wysiwyg' ) + return; + + this.getCommand( 'cut' ).setState( inReadOnly ? CKEDITOR.TRISTATE_DISABLED : stateFromNamedCommand( 'Cut', this ) ); + this.getCommand( 'copy' ).setState( stateFromNamedCommand( 'Copy', this ) ); + var pasteState = inReadOnly ? CKEDITOR.TRISTATE_DISABLED : + CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', this ); + this.fire( 'pasteState', pasteState ); + } + + // Register the plugin. + CKEDITOR.plugins.add( 'clipboard', + { + requires : [ 'dialog', 'htmldataprocessor' ], + init : function( editor ) + { + // Inserts processed data into the editor at the end of the + // events chain. + editor.on( 'paste', function( evt ) + { + var data = evt.data; + if ( data[ 'html' ] ) + editor.insertHtml( data[ 'html' ] ); + else if ( data[ 'text' ] ) + editor.insertText( data[ 'text' ] ); + + setTimeout( function () { editor.fire( 'afterPaste' ); }, 0 ); + + }, null, null, 1000 ); + + editor.on( 'pasteDialog', function( evt ) + { + setTimeout( function() + { + // Open default paste dialog. + editor.openDialog( 'paste' ); + }, 0 ); + }); + + editor.on( 'pasteState', function( evt ) + { + editor.getCommand( 'paste' ).setState( evt.data ); + }); + + function addButtonCommand( buttonName, commandName, command, ctxMenuOrder ) + { + var lang = editor.lang[ commandName ]; + + editor.addCommand( commandName, command ); + editor.ui.addButton( buttonName, + { + label : lang, + command : commandName + }); + + // If the "menu" plugin is loaded, register the menu item. + if ( editor.addMenuItems ) + { + editor.addMenuItem( commandName, + { + label : lang, + command : commandName, + group : 'clipboard', + order : ctxMenuOrder + }); + } + } + + addButtonCommand( 'Cut', 'cut', new cutCopyCmd( 'cut' ), 1 ); + addButtonCommand( 'Copy', 'copy', new cutCopyCmd( 'copy' ), 4 ); + addButtonCommand( 'Paste', 'paste', pasteCmd, 8 ); + + CKEDITOR.dialog.add( 'paste', CKEDITOR.getUrl( this.path + 'dialogs/paste.js' ) ); + + editor.on( 'key', onKey, editor ); + + var mode = editor.config.forcePasteAsPlainText ? 'text' : 'html'; + + // We'll be catching all pasted content in one line, regardless of whether the + // it's introduced by a document command execution (e.g. toolbar buttons) or + // user paste behaviors. (e.g. Ctrl-V) + editor.on( 'contentDom', function() + { + var body = editor.document.getBody(); + body.on( ( ( mode == 'text' && CKEDITOR.env.ie ) || CKEDITOR.env.webkit ) ? 'paste' : 'beforepaste', + function( evt ) + { + if ( depressBeforeEvent ) + return; + + getClipboardData.call( editor, evt, mode, function ( data ) + { + // The very last guard to make sure the + // paste has successfully happened. + if ( !CKEDITOR.tools.trim( data.toLowerCase().replace( /]+data-cke-bookmark[^<]*?<\/span>/g,'' ) ) ) + return; + + var dataTransfer = {}; + dataTransfer[ mode ] = data; + editor.fire( 'paste', dataTransfer ); + } ); + }); + + body.on( 'beforecut', function() { !depressBeforeEvent && fixCut( editor ); } ); + + body.on( 'mouseup', function(){ setTimeout( function(){ setToolbarStates.call( editor ); }, 0 ); }, editor ); + body.on( 'keyup', setToolbarStates, editor ); + }); + + // For improved performance, we're checking the readOnly state on selectionChange instead of hooking a key event for that. + editor.on( 'selectionChange', function( evt ) + { + inReadOnly = evt.data.selection.getRanges()[ 0 ].checkReadOnly(); + setToolbarStates.call( editor ); + }); + + // If the "contextmenu" plugin is loaded, register the listeners. + if ( editor.contextMenu ) + { + editor.contextMenu.addListener( function( element, selection ) + { + var readOnly = selection.getRanges()[ 0 ].checkReadOnly(); + return { + cut : !readOnly && stateFromNamedCommand( 'Cut', editor ), + copy : stateFromNamedCommand( 'Copy', editor ), + paste : !readOnly && ( CKEDITOR.env.webkit ? CKEDITOR.TRISTATE_OFF : stateFromNamedCommand( 'Paste', editor ) ) + }; + }); + } + } + }); +})(); + +/** + * Fired when a clipboard operation is about to be taken into the editor. + * Listeners can manipulate the data to be pasted before having it effectively + * inserted into the document. + * @name CKEDITOR.editor#paste + * @since 3.1 + * @event + * @param {String} [data.html] The HTML data to be pasted. If not available, e.data.text will be defined. + * @param {String} [data.text] The plain text data to be pasted, available when plain text operations are to used. If not available, e.data.html will be defined. + */ + +/** + * Internal event to open the Paste dialog + * @name CKEDITOR.editor#pasteDialog + * @event + */ diff --git a/public/javascripts/ckeditor/_source/plugins/colorbutton/plugin.js b/public/javascripts/ckeditor/_source/plugins/colorbutton/plugin.js new file mode 100644 index 00000000..77c002ad --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/colorbutton/plugin.js @@ -0,0 +1,291 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +CKEDITOR.plugins.add( 'colorbutton', +{ + requires : [ 'panelbutton', 'floatpanel', 'styles' ], + + init : function( editor ) + { + var config = editor.config, + lang = editor.lang.colorButton; + + var clickFn; + + if ( !CKEDITOR.env.hc ) + { + addButton( 'TextColor', 'fore', lang.textColorTitle ); + addButton( 'BGColor', 'back', lang.bgColorTitle ); + } + + function addButton( name, type, title ) + { + var colorBoxId = CKEDITOR.tools.getNextId() + '_colorBox'; + editor.ui.add( name, CKEDITOR.UI_PANELBUTTON, + { + label : title, + title : title, + className : 'cke_button_' + name.toLowerCase(), + modes : { wysiwyg : 1 }, + + panel : + { + css : editor.skin.editor.css, + attributes : { role : 'listbox', 'aria-label' : lang.panelTitle } + }, + + onBlock : function( panel, block ) + { + block.autoSize = true; + block.element.addClass( 'cke_colorblock' ); + block.element.setHtml( renderColors( panel, type, colorBoxId ) ); + // The block should not have scrollbars (#5933, #6056) + block.element.getDocument().getBody().setStyle( 'overflow', 'hidden' ); + + CKEDITOR.ui.fire( 'ready', this ); + + var keys = block.keys; + var rtl = editor.lang.dir == 'rtl'; + keys[ rtl ? 37 : 39 ] = 'next'; // ARROW-RIGHT + keys[ 40 ] = 'next'; // ARROW-DOWN + keys[ 9 ] = 'next'; // TAB + keys[ rtl ? 39 : 37 ] = 'prev'; // ARROW-LEFT + keys[ 38 ] = 'prev'; // ARROW-UP + keys[ CKEDITOR.SHIFT + 9 ] = 'prev'; // SHIFT + TAB + keys[ 32 ] = 'click'; // SPACE + }, + + // The automatic colorbox should represent the real color (#6010) + onOpen : function() + { + var selection = editor.getSelection(), + block = selection && selection.getStartElement(), + path = new CKEDITOR.dom.elementPath( block ), + color; + + // Find the closest block element. + block = path.block || path.blockLimit || editor.document.getBody(); + + // The background color might be transparent. In that case, look up the color in the DOM tree. + do + { + color = block && block.getComputedStyle( type == 'back' ? 'background-color' : 'color' ) || 'transparent'; + } + while ( type == 'back' && color == 'transparent' && block && ( block = block.getParent() ) ); + + // The box should never be transparent. + if ( !color || color == 'transparent' ) + color = '#ffffff'; + + this._.panel._.iframe.getFrameDocument().getById( colorBoxId ).setStyle( 'background-color', color ); + } + }); + } + + + function renderColors( panel, type, colorBoxId ) + { + var output = [], + colors = config.colorButton_colors.split( ',' ), + total = colors.length + ( config.colorButton_enableMore ? 2 : 1 ); + + var clickFn = CKEDITOR.tools.addFunction( function( color, type ) + { + if ( color == '?' ) + { + var applyColorStyle = arguments.callee; + function onColorDialogClose( evt ) + { + this.removeListener( 'ok', onColorDialogClose ); + this.removeListener( 'cancel', onColorDialogClose ); + + evt.name == 'ok' && applyColorStyle( this.getContentElement( 'picker', 'selectedColor' ).getValue(), type ); + } + + editor.openDialog( 'colordialog', function() + { + this.on( 'ok', onColorDialogClose ); + this.on( 'cancel', onColorDialogClose ); + } ); + + return; + } + + editor.focus(); + + panel.hide(); + + + editor.fire( 'saveSnapshot' ); + + // Clean up any conflicting style within the range. + new CKEDITOR.style( config['colorButton_' + type + 'Style'], { color : 'inherit' } ).remove( editor.document ); + + if ( color ) + { + var colorStyle = config['colorButton_' + type + 'Style']; + + colorStyle.childRule = type == 'back' ? + function( element ) + { + // It's better to apply background color as the innermost style. (#3599) + // Except for "unstylable elements". (#6103) + return isUnstylable( element ); + } + : + function( element ) + { + // Fore color style must be applied inside links instead of around it. + return element.getName() != 'a' || isUnstylable( element ); + }; + + new CKEDITOR.style( colorStyle, { color : color } ).apply( editor.document ); + } + + editor.fire( 'saveSnapshot' ); + }); + + // Render the "Automatic" button. + output.push( + '' + + '' + + '
' + + '' + + ' ' + + '' + + '' + + ' ' + + '', + lang.auto, + ' ' + + '' ); + + // Render the color boxes. + for ( var i = 0 ; i < colors.length ; i++ ) + { + if ( ( i % 8 ) === 0 ) + output.push( '
' ); + + return output.join( '' ); + } + + function isUnstylable( ele ) + { + return ( ele.getAttribute( 'contentEditable' ) == 'false' ) || ele.getAttribute( 'data-nostyle' ); + } + } +}); + +/** + * Whether to enable the "More Colors..." button in the color selectors. + * @default true + * @type Boolean + * @example + * config.colorButton_enableMore = false; + */ + +/** + * Defines the colors to be displayed in the color selectors. It's a string + * containing the hexadecimal notation for HTML colors, without the "#" prefix. + * + * Since 3.3: A name may be optionally defined by prefixing the entries with the + * name and the slash character. For example, "FontColor1/FF9900" will be + * displayed as the color #FF9900 in the selector, but will be outputted as "FontColor1". + * @type String + * @default '000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF' + * @example + * // Brazil colors only. + * config.colorButton_colors = '00923E,F8C100,28166F'; + * @example + * config.colorButton_colors = 'FontColor1/FF9900,FontColor2/0066CC,FontColor3/F00' + */ +CKEDITOR.config.colorButton_colors = + '000,800000,8B4513,2F4F4F,008080,000080,4B0082,696969,' + + 'B22222,A52A2A,DAA520,006400,40E0D0,0000CD,800080,808080,' + + 'F00,FF8C00,FFD700,008000,0FF,00F,EE82EE,A9A9A9,' + + 'FFA07A,FFA500,FFFF00,00FF00,AFEEEE,ADD8E6,DDA0DD,D3D3D3,' + + 'FFF0F5,FAEBD7,FFFFE0,F0FFF0,F0FFFF,F0F8FF,E6E6FA,FFF'; + +/** + * Holds the style definition to be used to apply the text foreground color. + * @type Object + * @example + * // This is basically the default setting value. + * config.colorButton_foreStyle = + * { + * element : 'span', + * styles : { 'color' : '#(color)' } + * }; + */ +CKEDITOR.config.colorButton_foreStyle = + { + element : 'span', + styles : { 'color' : '#(color)' }, + overrides : [ { element : 'font', attributes : { 'color' : null } } ] + }; + +/** + * Holds the style definition to be used to apply the text background color. + * @type Object + * @example + * // This is basically the default setting value. + * config.colorButton_backStyle = + * { + * element : 'span', + * styles : { 'background-color' : '#(color)' } + * }; + */ +CKEDITOR.config.colorButton_backStyle = + { + element : 'span', + styles : { 'background-color' : '#(color)' } + }; diff --git a/public/javascripts/ckeditor/_source/plugins/colordialog/dialogs/colordialog.js b/public/javascripts/ckeditor/_source/plugins/colordialog/dialogs/colordialog.js new file mode 100644 index 00000000..61d411be --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/colordialog/dialogs/colordialog.js @@ -0,0 +1,340 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +CKEDITOR.dialog.add( 'colordialog', function( editor ) + { + // Define some shorthands. + var $el = CKEDITOR.dom.element, + $doc = CKEDITOR.document, + $tools = CKEDITOR.tools, + lang = editor.lang.colordialog; + + // Reference the dialog. + var dialog; + + var spacer = + { + type : 'html', + html : ' ' + }; + + function clearSelected() + { + $doc.getById( selHiColorId ).removeStyle( 'background-color' ); + dialog.getContentElement( 'picker', 'selectedColor' ).setValue( '' ); + } + + function updateSelected( evt ) + { + if ( ! ( evt instanceof CKEDITOR.dom.event ) ) + evt = new CKEDITOR.dom.event( evt ); + + var target = evt.getTarget(), + color; + + if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) ) + dialog.getContentElement( 'picker', 'selectedColor' ).setValue( color ); + } + + function updateHighlight( event ) + { + if ( ! ( event instanceof CKEDITOR.dom.event ) ) + event = event.data; + + var target = event.getTarget(), + color; + + if ( target.getName() == 'a' && ( color = target.getChild( 0 ).getHtml() ) ) + { + $doc.getById( hicolorId ).setStyle( 'background-color', color ); + $doc.getById( hicolorTextId ).setHtml( color ); + } + } + + function clearHighlight() + { + $doc.getById( hicolorId ).removeStyle( 'background-color' ); + $doc.getById( hicolorTextId ).setHtml( ' ' ); + } + + var onMouseout = $tools.addFunction( clearHighlight ), + onClick = updateSelected, + onClickHandler = CKEDITOR.tools.addFunction( onClick ), + onFocus = updateHighlight, + onBlur = clearHighlight; + + var onKeydownHandler = CKEDITOR.tools.addFunction( function( ev ) + { + ev = new CKEDITOR.dom.event( ev ); + var element = ev.getTarget(); + var relative, nodeToMove; + var keystroke = ev.getKeystroke(), + rtl = editor.lang.dir == 'rtl'; + + switch ( keystroke ) + { + // UP-ARROW + case 38 : + // relative is TR + if ( ( relative = element.getParent().getParent().getPrevious() ) ) + { + nodeToMove = relative.getChild( [element.getParent().getIndex(), 0] ); + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + } + ev.preventDefault(); + break; + // DOWN-ARROW + case 40 : + // relative is TR + if ( ( relative = element.getParent().getParent().getNext() ) ) + { + nodeToMove = relative.getChild( [ element.getParent().getIndex(), 0 ] ); + if ( nodeToMove && nodeToMove.type == 1 ) + { + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + } + } + ev.preventDefault(); + break; + // SPACE + // ENTER is already handled as onClick + case 32 : + onClick( ev ); + ev.preventDefault(); + break; + + // RIGHT-ARROW + case rtl ? 37 : 39 : + // relative is TD + if ( ( relative = element.getParent().getNext() ) ) + { + nodeToMove = relative.getChild( 0 ); + if ( nodeToMove.type == 1 ) + { + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + ev.preventDefault( true ); + } + else + onBlur( null, element ); + } + // relative is TR + else if ( ( relative = element.getParent().getParent().getNext() ) ) + { + nodeToMove = relative.getChild( [ 0, 0 ] ); + if ( nodeToMove && nodeToMove.type == 1 ) + { + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + ev.preventDefault( true ); + } + else + onBlur( null, element ); + } + break; + + // LEFT-ARROW + case rtl ? 39 : 37 : + // relative is TD + if ( ( relative = element.getParent().getPrevious() ) ) + { + nodeToMove = relative.getChild( 0 ); + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + ev.preventDefault( true ); + } + // relative is TR + else if ( ( relative = element.getParent().getParent().getPrevious() ) ) + { + nodeToMove = relative.getLast().getChild( 0 ); + nodeToMove.focus(); + onBlur( ev, element ); + onFocus( ev, nodeToMove ); + ev.preventDefault( true ); + } + else + onBlur( null, element ); + break; + default : + // Do not stop not handled events. + return; + } + }); + + function createColorTable() + { + // Create the base colors array. + var aColors = [ '00', '33', '66', '99', 'cc', 'ff' ]; + + // This function combines two ranges of three values from the color array into a row. + function appendColorRow( rangeA, rangeB ) + { + for ( var i = rangeA ; i < rangeA + 3 ; i++ ) + { + var row = table.$.insertRow( -1 ); + + for ( var j = rangeB ; j < rangeB + 3 ; j++ ) + { + for ( var n = 0 ; n < 6 ; n++ ) + { + appendColorCell( row, '#' + aColors[j] + aColors[n] + aColors[i] ); + } + } + } + } + + // This function create a single color cell in the color table. + function appendColorCell( targetRow, color ) + { + var cell = new $el( targetRow.insertCell( -1 ) ); + cell.setAttribute( 'class', 'ColorCell' ); + cell.setStyle( 'background-color', color ); + + cell.setStyle( 'width', '15px' ); + cell.setStyle( 'height', '15px' ); + + var index = cell.$.cellIndex + 1 + 18 * targetRow.rowIndex; + cell.append( CKEDITOR.dom.element.createFromHtml( + '' + color + ' ', CKEDITOR.document ) ); + } + + appendColorRow( 0, 0 ); + appendColorRow( 3, 0 ); + appendColorRow( 0, 3 ); + appendColorRow( 3, 3 ); + + // Create the last row. + var oRow = table.$.insertRow(-1) ; + + // Create the gray scale colors cells. + for ( var n = 0 ; n < 6 ; n++ ) + { + appendColorCell( oRow, '#' + aColors[n] + aColors[n] + aColors[n] ) ; + } + + // Fill the row with black cells. + for ( var i = 0 ; i < 12 ; i++ ) + { + appendColorCell( oRow, '#000000' ) ; + } + } + + var table = new $el( 'table' ); + createColorTable(); + var html = table.getHtml(); + + var numbering = function( id ) + { + return CKEDITOR.tools.getNextId() + '_' + id; + }, + hicolorId = numbering( 'hicolor' ), + hicolorTextId = numbering( 'hicolortext' ), + selHiColorId = numbering( 'selhicolor' ), + tableLabelId = numbering( 'color_table_label' ); + + return { + title : lang.title, + minWidth : 360, + minHeight : 220, + onLoad : function() + { + // Update reference. + dialog = this; + }, + contents : [ + { + id : 'picker', + label : lang.title, + accessKey : 'I', + elements : + [ + { + type : 'hbox', + padding : 0, + widths : [ '70%', '10%', '30%' ], + children : + [ + { + type : 'html', + html : '' ); + + var parts = colors[ i ].split( '/' ), + colorName = parts[ 0 ], + colorCode = parts[ 1 ] || colorName; + + // The data can be only a color code (without #) or colorName + color code + // If only a color code is provided, then the colorName is the color with the hash + // Convert the color from RGB to RRGGBB for better compatibility with IE and . See #5676 + if (!parts[1]) + colorName = '#' + colorName.replace( /^(.)(.)(.)$/, '$1$1$2$2$3$3' ); + + var colorLabel = editor.lang.colors[ colorCode ] || colorCode; + output.push( + ' ' + + '' + + '' + + '' + + '' + + ' ' ); + } + + // Render the "More Colors" button. + if ( config.colorButton_enableMore === undefined || config.colorButton_enableMore ) + { + output.push( + '' + + ' ' + + '', + lang.more, + '' + + ' ' ); // tr is later in the code. + } + + output.push( '' + + ( !CKEDITOR.env.webkit ? html : '' ) + + '
' + lang.options +'', + onLoad : function() + { + var table = CKEDITOR.document.getById( this.domId ); + table.on( 'mouseover', updateHighlight ); + // In WebKit, the table content must be inserted after this event call (#6150) + CKEDITOR.env.webkit && table.setHtml( html ); + }, + focus: function() + { + var firstColor = this.getElement().getElementsByTag( 'a' ).getItem( 0 ); + firstColor.focus(); + } + }, + spacer, + { + type : 'vbox', + padding : 0, + widths : [ '70%', '5%', '25%' ], + children : + [ + { + type : 'html', + html : '' + lang.highlight +'\ + \ +' + lang.selected + '\ + ' + }, + { + type : 'text', + label : lang.selected, + labelStyle: 'display:none', + id : 'selectedColor', + style : 'width: 74px', + onChange : function() + { + // Try to update color preview with new value. If fails, then set it no none. + try + { + $doc.getById( selHiColorId ).setStyle( 'background-color', this.getValue() ); + } + catch ( e ) + { + clearSelected(); + } + } + }, + spacer, + { + type : 'button', + id : 'clear', + style : 'margin-top: 5px', + label : lang.clear, + onClick : clearSelected + } + ] + } + ] + } + ] + } + ] + }; + } + ); diff --git a/public/javascripts/ckeditor/_source/plugins/colordialog/plugin.js b/public/javascripts/ckeditor/_source/plugins/colordialog/plugin.js new file mode 100644 index 00000000..7006d682 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/colordialog/plugin.js @@ -0,0 +1,13 @@ +( function() +{ + CKEDITOR.plugins.colordialog = + { + init : function( editor ) + { + editor.addCommand( 'colordialog', new CKEDITOR.dialogCommand( 'colordialog' ) ); + CKEDITOR.dialog.add( 'colordialog', this.path + 'dialogs/colordialog.js' ); + } + }; + + CKEDITOR.plugins.add( 'colordialog', CKEDITOR.plugins.colordialog ); +} )(); diff --git a/public/javascripts/ckeditor/_source/plugins/contextmenu/plugin.js b/public/javascripts/ckeditor/_source/plugins/contextmenu/plugin.js new file mode 100644 index 00000000..31bc859c --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/contextmenu/plugin.js @@ -0,0 +1,177 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +CKEDITOR.plugins.add( 'contextmenu', +{ + requires : [ 'menu' ], + + // Make sure the base class (CKEDITOR.menu) is loaded before it (#3318). + onLoad : function() + { + CKEDITOR.plugins.contextMenu = CKEDITOR.tools.createClass( + { + base : CKEDITOR.menu, + + $ : function( editor ) + { + this.base.call( this, editor, + { + panel: + { + className : editor.skinClass + ' cke_contextmenu', + attributes : + { + 'aria-label' : editor.lang.contextmenu.options + } + } + }); + }, + + proto : + { + addTarget : function( element, nativeContextMenuOnCtrl ) + { + // Opera doesn't support 'contextmenu' event, we have duo approaches employed here: + // 1. Inherit the 'button override' hack we introduced in v2 (#4530), while this require the Opera browser + // option 'Allow script to detect context menu/right click events' to be always turned on. + // 2. Considering the fact that ctrl/meta key is not been occupied + // for multiple range selecting (like Gecko), we use this key + // combination as a fallback for triggering context-menu. (#4530) + if ( CKEDITOR.env.opera && !( 'oncontextmenu' in document.body )) + { + var contextMenuOverrideButton; + element.on( 'mousedown', function( evt ) + { + evt = evt.data; + if ( evt.$.button != 2 ) + { + if ( evt.getKeystroke() == CKEDITOR.CTRL + 1 ) + element.fire( 'contextmenu', evt ); + return; + } + + if ( nativeContextMenuOnCtrl + && ( CKEDITOR.env.mac ? evt.$.metaKey : evt.$.ctrlKey ) ) + return; + + var target = evt.getTarget(); + + if ( !contextMenuOverrideButton ) + { + var ownerDoc = target.getDocument(); + contextMenuOverrideButton = ownerDoc.createElement( 'input' ) ; + contextMenuOverrideButton.$.type = 'button' ; + ownerDoc.getBody().append( contextMenuOverrideButton ) ; + } + + contextMenuOverrideButton.setAttribute( 'style', 'position:absolute;top:' + ( evt.$.clientY - 2 ) + + 'px;left:' + ( evt.$.clientX - 2 ) + + 'px;width:5px;height:5px;opacity:0.01' ); + + } ); + + element.on( 'mouseup', function ( evt ) + { + if ( contextMenuOverrideButton ) + { + contextMenuOverrideButton.remove(); + contextMenuOverrideButton = undefined; + // Simulate 'contextmenu' event. + element.fire( 'contextmenu', evt.data ); + } + } ); + } + + element.on( 'contextmenu', function( event ) + { + var domEvent = event.data; + + if ( nativeContextMenuOnCtrl && + // Safari on Windows always show 'ctrlKey' as true in 'contextmenu' event, + // which make this property unreliable. (#4826) + ( CKEDITOR.env.webkit ? holdCtrlKey : ( CKEDITOR.env.mac ? domEvent.$.metaKey : domEvent.$.ctrlKey ) ) ) + return; + + + // Cancel the browser context menu. + domEvent.preventDefault(); + + var offsetParent = domEvent.getTarget().getDocument().getDocumentElement(), + offsetX = domEvent.$.clientX, + offsetY = domEvent.$.clientY; + + CKEDITOR.tools.setTimeout( function() + { + this.open( offsetParent, null, offsetX, offsetY ); + }, + 0, this ); + }, + this ); + + if ( CKEDITOR.env.opera ) + { + // 'contextmenu' event triggered by Windows menu key is unpreventable, + // cancel the key event itself. (#6534) + element.on( 'keypress' , function ( evt ) + { + var domEvent = evt.data; + + if ( domEvent.$.keyCode === 0 ) + domEvent.preventDefault(); + }); + } + + if ( CKEDITOR.env.webkit ) + { + var holdCtrlKey, + onKeyDown = function( event ) + { + holdCtrlKey = CKEDITOR.env.mac ? event.data.$.metaKey : event.data.$.ctrlKey ; + }, + resetOnKeyUp = function() + { + holdCtrlKey = 0; + }; + + element.on( 'keydown', onKeyDown ); + element.on( 'keyup', resetOnKeyUp ); + element.on( 'contextmenu', resetOnKeyUp ); + } + }, + + open : function( offsetParent, corner, offsetX, offsetY ) + { + this.editor.focus(); + offsetParent = offsetParent || CKEDITOR.document.getDocumentElement(); + this.show( offsetParent, corner, offsetX, offsetY ); + } + } + }); + }, + + beforeInit : function( editor ) + { + editor.contextMenu = new CKEDITOR.plugins.contextMenu( editor ); + + editor.addCommand( 'contextMenu', + { + exec : function() + { + editor.contextMenu.open( editor.document.getBody() ); + } + }); + } +}); + +/** + * Whether to show the browser native context menu when the CTRL or the + * META (Mac) key is pressed while opening the context menu. + * @name CKEDITOR.config.browserContextMenuOnCtrl + * @since 3.0.2 + * @type Boolean + * @default true + * @example + * config.browserContextMenuOnCtrl = false; + */ diff --git a/public/javascripts/ckeditor/_source/plugins/dialog/dialogDefinition.js b/public/javascripts/ckeditor/_source/plugins/dialog/dialogDefinition.js new file mode 100644 index 00000000..d0f04c22 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/dialog/dialogDefinition.js @@ -0,0 +1,1081 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +/** + * @fileOverview Defines the "virtual" dialog, dialog content and dialog button + * definition classes. + */ + +/** + * The definition of a dialog window. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create dialogs. + *+ * @name CKEDITOR.dialog.definition + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * CKEDITOR.dialog.add( 'testOnly', function( editor ) + * { + * return { + * title : 'Test Dialog', + * resizable : CKEDITOR.DIALOG_RESIZE_BOTH, + * minWidth : 500, + * minHeight : 400, + * contents : [ + * { + * id : 'tab1', + * label : 'First Tab', + * title : 'First Tab Title', + * accessKey : 'Q', + * elements : [ + * { + * type : 'text', + * label : 'Test Text 1', + * id : 'testText1', + * 'default' : 'hello world!' + * } + * ] + * } + * ] + * }; + * }); + */ + +/** + * The dialog title, displayed in the dialog's header. Required. + * @name CKEDITOR.dialog.definition.prototype.title + * @field + * @type String + * @example + */ + +/** + * How the dialog can be resized, must be one of the four contents defined below. + *
+ * CKEDITOR.DIALOG_RESIZE_NONE
+ * CKEDITOR.DIALOG_RESIZE_WIDTH
+ * CKEDITOR.DIALOG_RESIZE_HEIGHT
+ * CKEDITOR.DIALOG_RESIZE_BOTH
+ * @name CKEDITOR.dialog.definition.prototype.resizable + * @field + * @type Number + * @default CKEDITOR.DIALOG_RESIZE_NONE + * @example + */ + +/** + * The minimum width of the dialog, in pixels. + * @name CKEDITOR.dialog.definition.prototype.minWidth + * @field + * @type Number + * @default 600 + * @example + */ + +/** + * The minimum height of the dialog, in pixels. + * @name CKEDITOR.dialog.definition.prototype.minHeight + * @field + * @type Number + * @default 400 + * @example + */ + + +/** + * The initial width of the dialog, in pixels. + * @name CKEDITOR.dialog.definition.prototype.width + * @field + * @type Number + * @default @CKEDITOR.dialog.definition.prototype.minWidth + * @since 3.5.3 + * @example + */ + +/** + * The initial height of the dialog, in pixels. + * @name CKEDITOR.dialog.definition.prototype.height + * @field + * @type Number + * @default @CKEDITOR.dialog.definition.prototype.minHeight + * @since 3.5.3 + * @example + */ + +/** + * The buttons in the dialog, defined as an array of + * {@link CKEDITOR.dialog.definition.button} objects. + * @name CKEDITOR.dialog.definition.prototype.buttons + * @field + * @type Array + * @default [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ] + * @example + */ + +/** + * The contents in the dialog, defined as an array of + * {@link CKEDITOR.dialog.definition.content} objects. Required. + * @name CKEDITOR.dialog.definition.prototype.contents + * @field + * @type Array + * @example + */ + +/** + * The function to execute when OK is pressed. + * @name CKEDITOR.dialog.definition.prototype.onOk + * @field + * @type Function + * @example + */ + +/** + * The function to execute when Cancel is pressed. + * @name CKEDITOR.dialog.definition.prototype.onCancel + * @field + * @type Function + * @example + */ + +/** + * The function to execute when the dialog is displayed for the first time. + * @name CKEDITOR.dialog.definition.prototype.onLoad + * @field + * @type Function + * @example + */ + +/** + * The function to execute when the dialog is loaded (executed every time the dialog is opened). + * @name CKEDITOR.dialog.definition.prototype.onShow + * @field + * @type Function + * @example + */ + +/** + *This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create dialog content pages.+ * @name CKEDITOR.dialog.definition.content + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + */ + +/** + * The id of the content page. + * @name CKEDITOR.dialog.definition.content.prototype.id + * @field + * @type String + * @example + */ + +/** + * The tab label of the content page. + * @name CKEDITOR.dialog.definition.content.prototype.label + * @field + * @type String + * @example + */ + +/** + * The popup message of the tab label. + * @name CKEDITOR.dialog.definition.content.prototype.title + * @field + * @type String + * @example + */ + +/** + * The CTRL hotkey for switching to the tab. + * @name CKEDITOR.dialog.definition.content.prototype.accessKey + * @field + * @type String + * @example + * contentDefinition.accessKey = 'Q'; // Switch to this page when CTRL-Q is pressed. + */ + +/** + * The UI elements contained in this content page, defined as an array of + * {@link CKEDITOR.dialog.definition.uiElement} objects. + * @name CKEDITOR.dialog.definition.content.prototype.elements + * @field + * @type Array + * @example + */ + +/** + * The definition of user interface element (textarea, radio etc). + *This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create dialog UI elements.+ * @name CKEDITOR.dialog.definition.uiElement + * @constructor + * @see CKEDITOR.ui.dialog.uiElement + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + */ + +/** + * The id of the UI element. + * @name CKEDITOR.dialog.definition.uiElement.prototype.id + * @field + * @type String + * @example + */ + +/** + * The type of the UI element. Required. + * @name CKEDITOR.dialog.definition.uiElement.prototype.type + * @field + * @type String + * @example + */ + +/** + * The popup label of the UI element. + * @name CKEDITOR.dialog.definition.uiElement.prototype.title + * @field + * @type String + * @example + */ + +/** + * CSS class names to append to the UI element. + * @name CKEDITOR.dialog.definition.uiElement.prototype.className + * @field + * @type String + * @example + */ + +/** + * Inline CSS classes to append to the UI element. + * @name CKEDITOR.dialog.definition.uiElement.prototype.style + * @field + * @type String + * @example + */ + +/** + * Function to execute the first time the UI element is displayed. + * @name CKEDITOR.dialog.definition.uiElement.prototype.onLoad + * @field + * @type Function + * @example + */ + +/** + * Function to execute whenever the UI element's parent dialog is displayed. + * @name CKEDITOR.dialog.definition.uiElement.prototype.onShow + * @field + * @type Function + * @example + */ + +/** + * Function to execute whenever the UI element's parent dialog is closed. + * @name CKEDITOR.dialog.definition.uiElement.prototype.onHide + * @field + * @type Function + * @example + */ + +// ----- hbox ----- + +/** + * Horizontal layout box for dialog UI elements, auto-expends to available width of container. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create horizontal layouts. + *+ * @name CKEDITOR.dialog.definition.hbox + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'hbox', + * widths : [ '25%', '25%', '50%' ], + * children : + * [ + * { + * type : 'text', + * id : 'id1', + * width : '40px', + * }, + * { + * type : 'text', + * id : 'id2', + * width : '40px', + * }, + * { + * type : 'text', + * id : 'id3' + * } + * ] + * } + */ + +/** + * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this container. + * @name CKEDITOR.dialog.definition.hbox.prototype.children + * @field + * @type Array + * @example + */ + +/** + * (Optional) The widths of child cells. + * @name CKEDITOR.dialog.definition.hbox.prototype.widths + * @field + * @type Array + * @example + */ + +/** + * (Optional) The height of the layout. + * @name CKEDITOR.dialog.definition.hbox.prototype.height + * @field + * @type Number + * @example + */ + +/** + * The CSS styles to apply to this element. + * @name CKEDITOR.dialog.definition.hbox.prototype.styles + * @field + * @type String + * @example + */ + +/** + * (Optional) The padding width inside child cells. Example: 0, 1. + * @name CKEDITOR.dialog.definition.hbox.prototype.padding + * @field + * @type Number + * @example + */ + +/** + * (Optional) The alignment of the whole layout. Example: center, top. + * @name CKEDITOR.dialog.definition.hbox.prototype.align + * @field + * @type String + * @example + */ + +// ----- vbox ----- + +/** + * Vertical layout box for dialog UI elements. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.hbox} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create vertical layouts. + *+ * + * @name CKEDITOR.dialog.definition.vbox + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'vbox', + * align : 'right', + * width : '200px', + * children : + * [ + * { + * type : 'text', + * id : 'age', + * label : 'Age' + * }, + * { + * type : 'text', + * id : 'sex', + * label : 'Sex' + * }, + * { + * type : 'text', + * id : 'nationality', + * label : 'Nationality' + * } + * ] + * } + */ + +/** + * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this container. + * @name CKEDITOR.dialog.definition.vbox.prototype.children + * @field + * @type Array + * @example + */ + +/** + * (Optional) The width of the layout. + * @name CKEDITOR.dialog.definition.vbox.prototype.width + * @field + * @type Array + * @example + */ + +/** + * (Optional) The heights of individual cells. + * @name CKEDITOR.dialog.definition.vbox.prototype.heights + * @field + * @type Number + * @example + */ + +/** + * The CSS styles to apply to this element. + * @name CKEDITOR.dialog.definition.vbox.prototype.styles + * @field + * @type String + * @example + */ + +/** + * (Optional) The padding width inside child cells. Example: 0, 1. + * @name CKEDITOR.dialog.definition.vbox.prototype.padding + * @field + * @type Number + * @example + */ + +/** + * (Optional) The alignment of the whole layout. Example: center, top. + * @name CKEDITOR.dialog.definition.vbox.prototype.align + * @field + * @type String + * @example + */ + +/** + * (Optional) Whether the layout should expand vertically to fill its container. + * @name CKEDITOR.dialog.definition.vbox.prototype.expand + * @field + * @type Boolean + * @example + */ + +// ----- button ------ + +/** + * The definition of a button. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.vbox} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create buttons. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.button + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'button', + * id : 'buttonId', + * label : 'Click me', + * title : 'My title', + * onClick : function() { + * // this = CKEDITOR.ui.dialog.button + * alert( 'Clicked: ' + this.id ); + * } + * } + */ + +/** + * Whether the button is disabled. + * @name CKEDITOR.dialog.definition.button.prototype.disabled + * @type Boolean + * @field + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.button.prototype.label + * @type String + * @field + * @example + */ + +// ----- checkbox ------ + +/** + * The definition of a checkbox element. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.button} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create groups of checkbox buttons. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.checkbox + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'checkbox', + * id : 'agree', + * label : 'I agree', + * 'default' : 'checked', + * onClick : function() { + * // this = CKEDITOR.ui.dialog.checkbox + * alert( 'Checked: ' + this.getValue() ); + * } + * } + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.checkbox.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.checkbox.prototype.label + * @type String + * @field + * @example + */ + +/** + * The default state. + * @name CKEDITOR.dialog.definition.checkbox.prototype.default + * @type String + * @field + * @default + * '' (unchecked) + * @example + */ + +// ----- file ----- + +/** + * The definition of a file upload input. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.checkbox} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create file upload elements. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.file + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'file', + * id : 'upload', + * label : 'Select file from your computer', + * size : 38 + * }, + * { + * type : 'fileButton', + * id : 'fileId', + * label : 'Upload file', + * 'for' : [ 'tab1', 'upload' ] + * filebrowser : { + * onSelect : function( fileUrl, data ) { + * alert( 'Successfully uploaded: ' + fileUrl ); + * } + * } + * } + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.file.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.file.prototype.label + * @type String + * @field + * @example + */ + +/** + * (Optional) The action attribute of the form element associated with this file upload input. + * If empty, CKEditor will use path to server connector for currently opened folder. + * @name CKEDITOR.dialog.definition.file.prototype.action + * @type String + * @field + * @example + */ + +/** + * The size of the UI element. + * @name CKEDITOR.dialog.definition.file.prototype.size + * @type Number + * @field + * @example + */ + +// ----- fileButton ----- + +/** + * The definition of a button for submitting the file in a file upload input. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.file} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create a button for submitting the file in a file upload input. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.fileButton + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'file', + * id : 'upload', + * label : 'Select file from your computer', + * size : 38 + * }, + * { + * type : 'fileButton', + * id : 'fileId', + * label : 'Upload file', + * 'for' : [ 'tab1', 'upload' ] + * filebrowser : { + * onSelect : function( fileUrl, data ) { + * alert( 'Successfully uploaded: ' + fileUrl ); + * } + * } + * } + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.fileButton.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.fileButton.prototype.label + * @type String + * @field + * @example + */ + +/** + * The instruction for CKEditor how to deal with file upload. + * By default, the file and fileButton elements will not work "as expected" if this attribute is not set. + * @name CKEDITOR.dialog.definition.fileButton.prototype.filebrowser + * @type String|Object + * @field + * @example + * // Update field with id 'txtUrl' in the 'tab1' tab when file is uploaded. + * filebrowser : 'tab1:txtUrl' + * + * // Call custom onSelect function when file is successfully uploaded. + * filebrowser : { + * onSelect : function( fileUrl, data ) { + * alert( 'Successfully uploaded: ' + fileUrl ); + * } + * } + */ + +/** + * An array that contains pageId and elementId of the file upload input element for which this button is created. + * @name CKEDITOR.dialog.definition.fileButton.prototype.for + * @type String + * @field + * @example + * [ pageId, elementId ] + */ + +// ----- html ----- + +/** + * The definition of a raw HTML element. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.fileButton} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create elements made from raw HTML code. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}.
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.html} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *
+ * To access HTML elements use {@link CKEDITOR.dom.document#getById} + * @name CKEDITOR.dialog.definition.html + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example 1: + * { + * type : 'html', + * html : '<h3>This is some sample HTML content.</h3>' + * } + * @example + * // Example 2: + * // Complete sample with document.getById() call when the "Ok" button is clicked. + * var dialogDefinition = + * { + * title : 'Sample dialog', + * minWidth : 300, + * minHeight : 200, + * onOk : function() { + * // "this" is now a CKEDITOR.dialog object. + * var document = this.getElement().getDocument(); + * // document = CKEDITOR.dom.document + * var element = document.getById( 'myDiv' ); + * if ( element ) + * alert( element.getHtml() ); + * }, + * contents : [ + * { + * id : 'tab1', + * label : '', + * title : '', + * elements : + * [ + * { + * type : 'html', + * html : '<div id="myDiv">Sample <b>text</b>.</div><div id="otherId">Another div.</div>' + * }, + * ] + * } + * ], + * buttons : [ CKEDITOR.dialog.cancelButton, CKEDITOR.dialog.okButton ] + * }; + */ + +/** + * (Required) HTML code of this element. + * @name CKEDITOR.dialog.definition.html.prototype.html + * @type String + * @field + * @example + */ + +// ----- radio ------ + +/** + * The definition of a radio group. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create groups of radio buttons. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.radio + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'radio', + * id : 'country', + * label : 'Which country is bigger', + * items : [ [ 'France', 'FR' ], [ 'Germany', 'DE' ] ] , + * style : 'color:green', + * 'default' : 'DE', + * onClick : function() { + * // this = CKEDITOR.ui.dialog.radio + * alert( 'Current value: ' + this.getValue() ); + * } + * } + */ + +/** + * The default value. + * @name CKEDITOR.dialog.definition.radio.prototype.default + * @type String + * @field + * @example + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.radio.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * An array of options. Each option is a 1- or 2-item array of format [ 'Description', 'Value' ]. If 'Value' is missing, then the value would be assumed to be the same as the description. + * @name CKEDITOR.dialog.definition.radio.prototype.items + * @field + * @type Array + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.radio.prototype.label + * @type String + * @field + * @example + */ + +// ----- selectElement ------ + +/** + * The definition of a select element. + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.radio} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create select elements. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.select + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'select', + * id : 'sport', + * label : 'Select your favourite sport', + * items : [ [ 'Basketball' ], [ 'Baseball' ], [ 'Hockey' ], [ 'Football' ] ], + * 'default' : 'Football', + * onChange : function( api ) { + * // this = CKEDITOR.ui.dialog.select + * alert( 'Current value: ' + this.getValue() ); + * } + * } + */ + +/** + * The default value. + * @name CKEDITOR.dialog.definition.select.prototype.default + * @type String + * @field + * @example + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.select.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * An array of options. Each option is a 1- or 2-item array of format [ 'Description', 'Value' ]. If 'Value' is missing, then the value would be assumed to be the same as the description. + * @name CKEDITOR.dialog.definition.select.prototype.items + * @field + * @type Array + * @example + */ + +/** + * (Optional) Set this to true if you'd like to have a multiple-choice select box. + * @name CKEDITOR.dialog.definition.select.prototype.multiple + * @type Boolean + * @field + * @example + * @default false + */ + +/** + * (Optional) The number of items to display in the select box. + * @name CKEDITOR.dialog.definition.select.prototype.size + * @type Number + * @field + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.select.prototype.label + * @type String + * @field + * @example + */ + +// ----- textInput ----- + +/** + * The definition of a text field (single line). + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.select} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create text fields. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.textInput + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * { + * type : 'text', + * id : 'name', + * label : 'Your name', + * 'default' : '', + * validate : function() { + * if ( !this.getValue() ) + * { + * api.openMsgDialog( '', 'Name cannot be empty.' ); + * return false; + * } + * } + * } + */ + +/** + * The default value. + * @name CKEDITOR.dialog.definition.textInput.prototype.default + * @type String + * @field + * @example + */ + +/** + * (Optional) The maximum length. + * @name CKEDITOR.dialog.definition.textInput.prototype.maxLength + * @type Number + * @field + * @example + */ + +/** + * (Optional) The size of the input field. + * @name CKEDITOR.dialog.definition.textInput.prototype.size + * @type Number + * @field + * @example + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.textInput.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.textInput.prototype.label + * @type String + * @field + * @example + */ + +// ----- textarea ------ + +/** + * The definition of a text field (multiple lines). + *
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.textInput} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *+ * This class is not really part of the API. It just illustrates the properties + * that developers can use to define and create textarea. + *+ * For a complete example of dialog definition, please check {@link CKEDITOR.dialog.add}. + * @name CKEDITOR.dialog.definition.textarea + * @extends CKEDITOR.dialog.definition.uiElement + * @constructor + * @example + * // There is no constructor for this class, the user just has to define an + * // object with the appropriate properties. + * + * // Example: + * { + * type : 'textarea', + * id : 'message', + * label : 'Your comment', + * 'default' : '', + * validate : function() { + * if ( this.getValue().length < 5 ) + * { + * api.openMsgDialog( 'The comment is too short.' ); + * return false; + * } + * } + * } + */ + +/** + * The number of rows. + * @name CKEDITOR.dialog.definition.textarea.prototype.rows + * @type Number + * @field + * @example + */ + +/** + * The number of columns. + * @name CKEDITOR.dialog.definition.textarea.prototype.cols + * @type Number + * @field + * @example + */ + +/** + * (Optional) The validation function. + * @name CKEDITOR.dialog.definition.textarea.prototype.validate + * @field + * @type Function + * @example + */ + +/** + * The default value. + * @name CKEDITOR.dialog.definition.textarea.prototype.default + * @type String + * @field + * @example + */ + +/** + * The label of the UI element. + * @name CKEDITOR.dialog.definition.textarea.prototype.label + * @type String + * @field + * @example + */ diff --git a/public/javascripts/ckeditor/_source/plugins/dialog/plugin.js b/public/javascripts/ckeditor/_source/plugins/dialog/plugin.js new file mode 100644 index 00000000..ce287993 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/dialog/plugin.js @@ -0,0 +1,3201 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +/** + * @fileOverview The floating dialog plugin. + */ + +/** + * No resize for this dialog. + * @constant + */ +CKEDITOR.DIALOG_RESIZE_NONE = 0; + +/** + * Only allow horizontal resizing for this dialog, disable vertical resizing. + * @constant + */ +CKEDITOR.DIALOG_RESIZE_WIDTH = 1; + +/** + * Only allow vertical resizing for this dialog, disable horizontal resizing. + * @constant + */ +CKEDITOR.DIALOG_RESIZE_HEIGHT = 2; + +/* + * Allow the dialog to be resized in both directions. + * @constant + */ +CKEDITOR.DIALOG_RESIZE_BOTH = 3; + +(function() +{ + var cssLength = CKEDITOR.tools.cssLength; + function isTabVisible( tabId ) + { + return !!this._.tabs[ tabId ][ 0 ].$.offsetHeight; + } + + function getPreviousVisibleTab() + { + var tabId = this._.currentTabId, + length = this._.tabIdList.length, + tabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, tabId ) + length; + + for ( var i = tabIndex - 1 ; i > tabIndex - length ; i-- ) + { + if ( isTabVisible.call( this, this._.tabIdList[ i % length ] ) ) + return this._.tabIdList[ i % length ]; + } + + return null; + } + + function getNextVisibleTab() + { + var tabId = this._.currentTabId, + length = this._.tabIdList.length, + tabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, tabId ); + + for ( var i = tabIndex + 1 ; i < tabIndex + length ; i++ ) + { + if ( isTabVisible.call( this, this._.tabIdList[ i % length ] ) ) + return this._.tabIdList[ i % length ]; + } + + return null; + } + + + function clearOrRecoverTextInputValue( container, isRecover ) + { + var inputs = container.$.getElementsByTagName( 'input' ); + for ( var i = 0, length = inputs.length; i < length ; i++ ) + { + var item = new CKEDITOR.dom.element( inputs[ i ] ); + + if ( item.getAttribute( 'type' ).toLowerCase() == 'text' ) + { + if ( isRecover ) + { + item.setAttribute( 'value', item.getCustomData( 'fake_value' ) || '' ); + item.removeCustomData( 'fake_value' ); + } + else + { + item.setCustomData( 'fake_value', item.getAttribute( 'value' ) ); + item.setAttribute( 'value', '' ); + } + } + } + } + + /** + * This is the base class for runtime dialog objects. An instance of this + * class represents a single named dialog for a single editor instance. + * @param {Object} editor The editor which created the dialog. + * @param {String} dialogName The dialog's registered name. + * @constructor + * @example + * var dialogObj = new CKEDITOR.dialog( editor, 'smiley' ); + */ + CKEDITOR.dialog = function( editor, dialogName ) + { + // Load the dialog definition. + var definition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], + defaultDefinition = CKEDITOR.tools.clone( defaultDialogDefinition ), + buttonsOrder = editor.config.dialog_buttonsOrder || 'OS', + dir = editor.lang.dir; + + if ( ( buttonsOrder == 'OS' && CKEDITOR.env.mac ) || // The buttons in MacOS Apps are in reverse order (#4750) + ( buttonsOrder == 'rtl' && dir == 'ltr' ) || + ( buttonsOrder == 'ltr' && dir == 'rtl' ) ) + defaultDefinition.buttons.reverse(); + + + // Completes the definition with the default values. + definition = CKEDITOR.tools.extend( definition( editor ), defaultDefinition ); + + // Clone a functionally independent copy for this dialog. + definition = CKEDITOR.tools.clone( definition ); + + // Create a complex definition object, extending it with the API + // functions. + definition = new definitionObject( this, definition ); + + var doc = CKEDITOR.document; + + var themeBuilt = editor.theme.buildDialog( editor ); + + // Initialize some basic parameters. + this._ = + { + editor : editor, + element : themeBuilt.element, + name : dialogName, + contentSize : { width : 0, height : 0 }, + size : { width : 0, height : 0 }, + contents : {}, + buttons : {}, + accessKeyMap : {}, + + // Initialize the tab and page map. + tabs : {}, + tabIdList : [], + currentTabId : null, + currentTabIndex : null, + pageCount : 0, + lastTab : null, + tabBarMode : false, + + // Initialize the tab order array for input widgets. + focusList : [], + currentFocusIndex : 0, + hasFocus : false + }; + + this.parts = themeBuilt.parts; + + CKEDITOR.tools.setTimeout( function() + { + editor.fire( 'ariaWidget', this.parts.contents ); + }, + 0, this ); + + // Set the startup styles for the dialog, avoiding it enlarging the + // page size on the dialog creation. + var startStyles = { + position : CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed', + top : 0, + visibility : 'hidden' + }; + + startStyles[ dir == 'rtl' ? 'right' : 'left' ] = 0; + this.parts.dialog.setStyles( startStyles ); + + + // Call the CKEDITOR.event constructor to initialize this instance. + CKEDITOR.event.call( this ); + + // Fire the "dialogDefinition" event, making it possible to customize + // the dialog definition. + this.definition = definition = CKEDITOR.fire( 'dialogDefinition', + { + name : dialogName, + definition : definition + } + , editor ).definition; + + var tabsToRemove = {}; + // Cache tabs that should be removed. + if ( !( 'removeDialogTabs' in editor._ ) && editor.config.removeDialogTabs ) + { + var removeContents = editor.config.removeDialogTabs.split( ';' ); + + for ( i = 0; i < removeContents.length; i++ ) + { + var parts = removeContents[ i ].split( ':' ); + if ( parts.length == 2 ) + { + var removeDialogName = parts[ 0 ]; + if ( !tabsToRemove[ removeDialogName ] ) + tabsToRemove[ removeDialogName ] = []; + tabsToRemove[ removeDialogName ].push( parts[ 1 ] ); + } + } + editor._.removeDialogTabs = tabsToRemove; + } + + // Remove tabs of this dialog. + if ( editor._.removeDialogTabs && ( tabsToRemove = editor._.removeDialogTabs[ dialogName ] ) ) + { + for ( i = 0; i < tabsToRemove.length; i++ ) + definition.removeContents( tabsToRemove[ i ] ); + } + + // Initialize load, show, hide, ok and cancel events. + if ( definition.onLoad ) + this.on( 'load', definition.onLoad ); + + if ( definition.onShow ) + this.on( 'show', definition.onShow ); + + if ( definition.onHide ) + this.on( 'hide', definition.onHide ); + + if ( definition.onOk ) + { + this.on( 'ok', function( evt ) + { + // Dialog confirm might probably introduce content changes (#5415). + editor.fire( 'saveSnapshot' ); + setTimeout( function () { editor.fire( 'saveSnapshot' ); }, 0 ); + if ( definition.onOk.call( this, evt ) === false ) + evt.data.hide = false; + }); + } + + if ( definition.onCancel ) + { + this.on( 'cancel', function( evt ) + { + if ( definition.onCancel.call( this, evt ) === false ) + evt.data.hide = false; + }); + } + + var me = this; + + // Iterates over all items inside all content in the dialog, calling a + // function for each of them. + var iterContents = function( func ) + { + var contents = me._.contents, + stop = false; + + for ( var i in contents ) + { + for ( var j in contents[i] ) + { + stop = func.call( this, contents[i][j] ); + if ( stop ) + return; + } + } + }; + + this.on( 'ok', function( evt ) + { + iterContents( function( item ) + { + if ( item.validate ) + { + var isValid = item.validate( this ); + + if ( typeof isValid == 'string' ) + { + alert( isValid ); + isValid = false; + } + + if ( isValid === false ) + { + if ( item.select ) + item.select(); + else + item.focus(); + + evt.data.hide = false; + evt.stop(); + return true; + } + } + }); + }, this, null, 0 ); + + this.on( 'cancel', function( evt ) + { + iterContents( function( item ) + { + if ( item.isChanged() ) + { + if ( !confirm( editor.lang.common.confirmCancel ) ) + evt.data.hide = false; + return true; + } + }); + }, this, null, 0 ); + + this.parts.close.on( 'click', function( evt ) + { + if ( this.fire( 'cancel', { hide : true } ).hide !== false ) + this.hide(); + evt.data.preventDefault(); + }, this ); + + // Sort focus list according to tab order definitions. + function setupFocus() + { + var focusList = me._.focusList; + focusList.sort( function( a, b ) + { + // Mimics browser tab order logics; + if ( a.tabIndex != b.tabIndex ) + return b.tabIndex - a.tabIndex; + // Sort is not stable in some browsers, + // fall-back the comparator to 'focusIndex'; + else + return a.focusIndex - b.focusIndex; + }); + + var size = focusList.length; + for ( var i = 0; i < size; i++ ) + focusList[ i ].focusIndex = i; + } + + function changeFocus( forward ) + { + var focusList = me._.focusList, + offset = forward ? 1 : -1; + if ( focusList.length < 1 ) + return; + + var current = me._.currentFocusIndex; + + // Trigger the 'blur' event of any input element before anything, + // since certain UI updates may depend on it. + try + { + focusList[ current ].getInputElement().$.blur(); + } + catch( e ){} + + var startIndex = ( current + offset + focusList.length ) % focusList.length, + currentIndex = startIndex; + while ( !focusList[ currentIndex ].isFocusable() ) + { + currentIndex = ( currentIndex + offset + focusList.length ) % focusList.length; + if ( currentIndex == startIndex ) + break; + } + focusList[ currentIndex ].focus(); + + // Select whole field content. + if ( focusList[ currentIndex ].type == 'text' ) + focusList[ currentIndex ].select(); + } + + this.changeFocus = changeFocus; + + var processed; + + function focusKeydownHandler( evt ) + { + // If I'm not the top dialog, ignore. + if ( me != CKEDITOR.dialog._.currentTop ) + return; + + var keystroke = evt.data.getKeystroke(), + rtl = editor.lang.dir == 'rtl'; + + processed = 0; + if ( keystroke == 9 || keystroke == CKEDITOR.SHIFT + 9 ) + { + var shiftPressed = ( keystroke == CKEDITOR.SHIFT + 9 ); + + // Handling Tab and Shift-Tab. + if ( me._.tabBarMode ) + { + // Change tabs. + var nextId = shiftPressed ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me ); + me.selectPage( nextId ); + me._.tabs[ nextId ][ 0 ].focus(); + } + else + { + // Change the focus of inputs. + changeFocus( !shiftPressed ); + } + + processed = 1; + } + else if ( keystroke == CKEDITOR.ALT + 121 && !me._.tabBarMode && me.getPageCount() > 1 ) + { + // Alt-F10 puts focus into the current tab item in the tab bar. + me._.tabBarMode = true; + me._.tabs[ me._.currentTabId ][ 0 ].focus(); + processed = 1; + } + else if ( ( keystroke == 37 || keystroke == 39 ) && me._.tabBarMode ) + { + // Arrow keys - used for changing tabs. + nextId = ( keystroke == ( rtl ? 39 : 37 ) ? getPreviousVisibleTab.call( me ) : getNextVisibleTab.call( me ) ); + me.selectPage( nextId ); + me._.tabs[ nextId ][ 0 ].focus(); + processed = 1; + } + else if ( ( keystroke == 13 || keystroke == 32 ) && me._.tabBarMode ) + { + this.selectPage( this._.currentTabId ); + this._.tabBarMode = false; + this._.currentFocusIndex = -1; + changeFocus( true ); + processed = 1; + } + + if ( processed ) + { + evt.stop(); + evt.data.preventDefault(); + } + } + + function focusKeyPressHandler( evt ) + { + processed && evt.data.preventDefault(); + } + + var dialogElement = this._.element; + // Add the dialog keyboard handlers. + this.on( 'show', function() + { + dialogElement.on( 'keydown', focusKeydownHandler, this, null, 0 ); + // Some browsers instead, don't cancel key events in the keydown, but in the + // keypress. So we must do a longer trip in those cases. (#4531) + if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) ) + dialogElement.on( 'keypress', focusKeyPressHandler, this ); + + } ); + this.on( 'hide', function() + { + dialogElement.removeListener( 'keydown', focusKeydownHandler ); + if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) ) + dialogElement.removeListener( 'keypress', focusKeyPressHandler ); + } ); + this.on( 'iframeAdded', function( evt ) + { + var doc = new CKEDITOR.dom.document( evt.data.iframe.$.contentWindow.document ); + doc.on( 'keydown', focusKeydownHandler, this, null, 0 ); + } ); + + // Auto-focus logic in dialog. + this.on( 'show', function() + { + // Setup tabIndex on showing the dialog instead of on loading + // to allow dynamic tab order happen in dialog definition. + setupFocus(); + + if ( editor.config.dialog_startupFocusTab + && me._.pageCount > 1 ) + { + me._.tabBarMode = true; + me._.tabs[ me._.currentTabId ][ 0 ].focus(); + } + else if ( !this._.hasFocus ) + { + this._.currentFocusIndex = -1; + + // Decide where to put the initial focus. + if ( definition.onFocus ) + { + var initialFocus = definition.onFocus.call( this ); + // Focus the field that the user specified. + initialFocus && initialFocus.focus(); + } + // Focus the first field in layout order. + else + changeFocus( true ); + + /* + * IE BUG: If the initial focus went into a non-text element (e.g. button), + * then IE would still leave the caret inside the editing area. + */ + if ( this._.editor.mode == 'wysiwyg' && CKEDITOR.env.ie ) + { + var $selection = editor.document.$.selection, + $range = $selection.createRange(); + + if ( $range ) + { + if ( $range.parentElement && $range.parentElement().ownerDocument == editor.document.$ + || $range.item && $range.item( 0 ).ownerDocument == editor.document.$ ) + { + var $myRange = document.body.createTextRange(); + $myRange.moveToElementText( this.getElement().getFirst().$ ); + $myRange.collapse( true ); + $myRange.select(); + } + } + } + } + }, this, null, 0xffffffff ); + + // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (#2661). + // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken. + if ( CKEDITOR.env.ie6Compat ) + { + this.on( 'load', function( evt ) + { + var outer = this.getElement(), + inner = outer.getFirst(); + inner.remove(); + inner.appendTo( outer ); + }, this ); + } + + initDragAndDrop( this ); + initResizeHandles( this ); + + // Insert the title. + ( new CKEDITOR.dom.text( definition.title, CKEDITOR.document ) ).appendTo( this.parts.title ); + + // Insert the tabs and contents. + for ( var i = 0 ; i < definition.contents.length ; i++ ) + { + var page = definition.contents[i]; + page && this.addPage( page ); + } + + this.parts[ 'tabs' ].on( 'click', function( evt ) + { + var target = evt.data.getTarget(); + // If we aren't inside a tab, bail out. + if ( target.hasClass( 'cke_dialog_tab' ) ) + { + // Get the ID of the tab, without the 'cke_' prefix and the unique number suffix. + var id = target.$.id; + this.selectPage( id.substring( 4, id.lastIndexOf( '_' ) ) ); + + if ( this._.tabBarMode ) + { + this._.tabBarMode = false; + this._.currentFocusIndex = -1; + changeFocus( true ); + } + evt.data.preventDefault(); + } + }, this ); + + // Insert buttons. + var buttonsHtml = [], + buttons = CKEDITOR.dialog._.uiElementBuilders.hbox.build( this, + { + type : 'hbox', + className : 'cke_dialog_footer_buttons', + widths : [], + children : definition.buttons + }, buttonsHtml ).getChild(); + this.parts.footer.setHtml( buttonsHtml.join( '' ) ); + + for ( i = 0 ; i < buttons.length ; i++ ) + this._.buttons[ buttons[i].id ] = buttons[i]; + }; + + // Focusable interface. Use it via dialog.addFocusable. + function Focusable( dialog, element, index ) + { + this.element = element; + this.focusIndex = index; + // TODO: support tabIndex for focusables. + this.tabIndex = 0; + this.isFocusable = function() + { + return !element.getAttribute( 'disabled' ) && element.isVisible(); + }; + this.focus = function() + { + dialog._.currentFocusIndex = this.focusIndex; + this.element.focus(); + }; + // Bind events + element.on( 'keydown', function( e ) + { + if ( e.data.getKeystroke() in { 32:1, 13:1 } ) + this.fire( 'click' ); + } ); + element.on( 'focus', function() + { + this.fire( 'mouseover' ); + } ); + element.on( 'blur', function() + { + this.fire( 'mouseout' ); + } ); + } + + CKEDITOR.dialog.prototype = + { + destroy : function() + { + this.hide(); + this._.element.remove(); + }, + + /** + * Resizes the dialog. + * @param {Number} width The width of the dialog in pixels. + * @param {Number} height The height of the dialog in pixels. + * @function + * @example + * dialogObj.resize( 800, 640 ); + */ + resize : (function() + { + return function( width, height ) + { + if ( this._.contentSize && this._.contentSize.width == width && this._.contentSize.height == height ) + return; + + CKEDITOR.dialog.fire( 'resize', + { + dialog : this, + skin : this._.editor.skinName, + width : width, + height : height + }, this._.editor ); + + this.fire( 'resize', + { + skin : this._.editor.skinName, + width : width, + height : height + }, this._.editor ); + + // Update dialog position when dimension get changed in RTL. + if ( this._.editor.lang.dir == 'rtl' && this._.position ) + this._.position.x = CKEDITOR.document.getWindow().getViewPaneSize().width - + this._.contentSize.width - parseInt( this._.element.getFirst().getStyle( 'right' ), 10 ); + + this._.contentSize = { width : width, height : height }; + }; + })(), + + /** + * Gets the current size of the dialog in pixels. + * @returns {Object} An object with "width" and "height" properties. + * @example + * var width = dialogObj.getSize().width; + */ + getSize : function() + { + var element = this._.element.getFirst(); + return { width : element.$.offsetWidth || 0, height : element.$.offsetHeight || 0}; + }, + + /** + * Moves the dialog to an (x, y) coordinate relative to the window. + * @function + * @param {Number} x The target x-coordinate. + * @param {Number} y The target y-coordinate. + * @param {Boolean} save Flag indicate whether the dialog position should be remembered on next open up. + * @example + * dialogObj.move( 10, 40 ); + */ + move : (function() + { + var isFixed; + return function( x, y, save ) + { + // The dialog may be fixed positioned or absolute positioned. Ask the + // browser what is the current situation first. + var element = this._.element.getFirst(), + rtl = this._.editor.lang.dir == 'rtl'; + + if ( isFixed === undefined ) + isFixed = element.getComputedStyle( 'position' ) == 'fixed'; + + if ( isFixed && this._.position && this._.position.x == x && this._.position.y == y ) + return; + + // Save the current position. + this._.position = { x : x, y : y }; + + // If not fixed positioned, add scroll position to the coordinates. + if ( !isFixed ) + { + var scrollPosition = CKEDITOR.document.getWindow().getScrollPosition(); + x += scrollPosition.x; + y += scrollPosition.y; + } + + // Translate coordinate for RTL. + if ( rtl ) + { + var dialogSize = this.getSize(), + viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(); + x = viewPaneSize.width - dialogSize.width - x; + } + + var styles = { 'top' : ( y > 0 ? y : 0 ) + 'px' }; + styles[ rtl ? 'right' : 'left' ] = ( x > 0 ? x : 0 ) + 'px'; + + element.setStyles( styles ); + + save && ( this._.moved = 1 ); + }; + })(), + + /** + * Gets the dialog's position in the window. + * @returns {Object} An object with "x" and "y" properties. + * @example + * var dialogX = dialogObj.getPosition().x; + */ + getPosition : function(){ return CKEDITOR.tools.extend( {}, this._.position ); }, + + /** + * Shows the dialog box. + * @example + * dialogObj.show(); + */ + show : function() + { + // Insert the dialog's element to the root document. + var element = this._.element; + var definition = this.definition; + if ( !( element.getParent() && element.getParent().equals( CKEDITOR.document.getBody() ) ) ) + element.appendTo( CKEDITOR.document.getBody() ); + else + element.setStyle( 'display', 'block' ); + + // FIREFOX BUG: Fix vanishing caret for Firefox 2 or Gecko 1.8. + if ( CKEDITOR.env.gecko && CKEDITOR.env.version < 10900 ) + { + var dialogElement = this.parts.dialog; + dialogElement.setStyle( 'position', 'absolute' ); + setTimeout( function() + { + dialogElement.setStyle( 'position', 'fixed' ); + }, 0 ); + } + + + // First, set the dialog to an appropriate size. + this.resize( this._.contentSize && this._.contentSize.width || definition.width || definition.minWidth, + this._.contentSize && this._.contentSize.height || definition.height || definition.minHeight ); + + // Reset all inputs back to their default value. + this.reset(); + + // Select the first tab by default. + this.selectPage( this.definition.contents[0].id ); + + // Set z-index. + if ( CKEDITOR.dialog._.currentZIndex === null ) + CKEDITOR.dialog._.currentZIndex = this._.editor.config.baseFloatZIndex; + this._.element.getFirst().setStyle( 'z-index', CKEDITOR.dialog._.currentZIndex += 10 ); + + // Maintain the dialog ordering and dialog cover. + // Also register key handlers if first dialog. + if ( CKEDITOR.dialog._.currentTop === null ) + { + CKEDITOR.dialog._.currentTop = this; + this._.parentDialog = null; + showCover( this._.editor ); + + element.on( 'keydown', accessKeyDownHandler ); + element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); + + // Prevent some keys from bubbling up. (#4269) + for ( var event in { keyup :1, keydown :1, keypress :1 } ) + element.on( event, preventKeyBubbling ); + } + else + { + this._.parentDialog = CKEDITOR.dialog._.currentTop; + var parentElement = this._.parentDialog.getElement().getFirst(); + parentElement.$.style.zIndex -= Math.floor( this._.editor.config.baseFloatZIndex / 2 ); + CKEDITOR.dialog._.currentTop = this; + } + + // Register the Esc hotkeys. + registerAccessKey( this, this, '\x1b', null, function() + { + this.getButton( 'cancel' ) && this.getButton( 'cancel' ).click(); + } ); + + // Reset the hasFocus state. + this._.hasFocus = false; + + CKEDITOR.tools.setTimeout( function() + { + this.layout(); + this.parts.dialog.setStyle( 'visibility', '' ); + + // Execute onLoad for the first show. + this.fireOnce( 'load', {} ); + CKEDITOR.ui.fire( 'ready', this ); + + this.fire( 'show', {} ); + this._.editor.fire( 'dialogShow', this ); + + // Save the initial values of the dialog. + this.foreach( function( contentObj ) { contentObj.setInitValue && contentObj.setInitValue(); } ); + + }, + 100, this ); + }, + + /** + * Rearrange the dialog to its previous position or the middle of the window. + * @since 3.5 + */ + layout : function() + { + var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(), + dialogSize = this.getSize(); + + this.move( this._.moved ? this._.position.x : ( viewSize.width - dialogSize.width ) / 2, + this._.moved ? this._.position.y : ( viewSize.height - dialogSize.height ) / 2 ); + }, + + /** + * Executes a function for each UI element. + * @param {Function} fn Function to execute for each UI element. + * @returns {CKEDITOR.dialog} The current dialog object. + */ + foreach : function( fn ) + { + for ( var i in this._.contents ) + { + for ( var j in this._.contents[i] ) + fn( this._.contents[i][j] ); + } + return this; + }, + + /** + * Resets all input values in the dialog. + * @example + * dialogObj.reset(); + * @returns {CKEDITOR.dialog} The current dialog object. + */ + reset : (function() + { + var fn = function( widget ){ if ( widget.reset ) widget.reset( 1 ); }; + return function(){ this.foreach( fn ); return this; }; + })(), + + setupContent : function() + { + var args = arguments; + this.foreach( function( widget ) + { + if ( widget.setup ) + widget.setup.apply( widget, args ); + }); + }, + + commitContent : function() + { + var args = arguments; + this.foreach( function( widget ) + { + if ( widget.commit ) + widget.commit.apply( widget, args ); + }); + }, + + /** + * Hides the dialog box. + * @example + * dialogObj.hide(); + */ + hide : function() + { + if ( !this.parts.dialog.isVisible() ) + return; + + this.fire( 'hide', {} ); + this._.editor.fire( 'dialogHide', this ); + var element = this._.element; + element.setStyle( 'display', 'none' ); + this.parts.dialog.setStyle( 'visibility', 'hidden' ); + // Unregister all access keys associated with this dialog. + unregisterAccessKey( this ); + + // Close any child(top) dialogs first. + while( CKEDITOR.dialog._.currentTop != this ) + CKEDITOR.dialog._.currentTop.hide(); + + // Maintain dialog ordering and remove cover if needed. + if ( !this._.parentDialog ) + hideCover(); + else + { + var parentElement = this._.parentDialog.getElement().getFirst(); + parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) ); + } + CKEDITOR.dialog._.currentTop = this._.parentDialog; + + // Deduct or clear the z-index. + if ( !this._.parentDialog ) + { + CKEDITOR.dialog._.currentZIndex = null; + + // Remove access key handlers. + element.removeListener( 'keydown', accessKeyDownHandler ); + element.removeListener( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); + + // Remove bubbling-prevention handler. (#4269) + for ( var event in { keyup :1, keydown :1, keypress :1 } ) + element.removeListener( event, preventKeyBubbling ); + + var editor = this._.editor; + editor.focus(); + + if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie ) + { + var selection = editor.getSelection(); + selection && selection.unlock( true ); + } + } + else + CKEDITOR.dialog._.currentZIndex -= 10; + + delete this._.parentDialog; + // Reset the initial values of the dialog. + this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); + }, + + /** + * Adds a tabbed page into the dialog. + * @param {Object} contents Content definition. + * @example + */ + addPage : function( contents ) + { + var pageHtml = [], + titleHtml = contents.label ? ' title="' + CKEDITOR.tools.htmlEncode( contents.label ) + '"' : '', + elements = contents.elements, + vbox = CKEDITOR.dialog._.uiElementBuilders.vbox.build( this, + { + type : 'vbox', + className : 'cke_dialog_page_contents', + children : contents.elements, + expand : !!contents.expand, + padding : contents.padding, + style : contents.style || 'width: 100%;height:100%' + }, pageHtml ); + + // Create the HTML for the tab and the content block. + var page = CKEDITOR.dom.element.createFromHtml( pageHtml.join( '' ) ); + page.setAttribute( 'role', 'tabpanel' ); + + var env = CKEDITOR.env; + var tabId = 'cke_' + contents.id + '_' + CKEDITOR.tools.getNextNumber(), + tab = CKEDITOR.dom.element.createFromHtml( [ + ' 0 ? ' cke_last' : 'cke_first' ), + titleHtml, + ( !!contents.hidden ? ' style="display:none"' : '' ), + ' id="', tabId, '"', + env.gecko && env.version >= 10900 && !env.hc ? '' : ' href="javascript:void(0)"', + ' tabIndex="-1"', + ' hidefocus="true"', + ' role="tab">', + contents.label, + '' + ].join( '' ) ); + + page.setAttribute( 'aria-labelledby', tabId ); + + // Take records for the tabs and elements created. + this._.tabs[ contents.id ] = [ tab, page ]; + this._.tabIdList.push( contents.id ); + !contents.hidden && this._.pageCount++; + this._.lastTab = tab; + this.updateStyle(); + + var contentMap = this._.contents[ contents.id ] = {}, + cursor, + children = vbox.getChild(); + + while ( ( cursor = children.shift() ) ) + { + contentMap[ cursor.id ] = cursor; + if ( typeof( cursor.getChild ) == 'function' ) + children.push.apply( children, cursor.getChild() ); + } + + // Attach the DOM nodes. + + page.setAttribute( 'name', contents.id ); + page.appendTo( this.parts.contents ); + + tab.unselectable(); + this.parts.tabs.append( tab ); + + // Add access key handlers if access key is defined. + if ( contents.accessKey ) + { + registerAccessKey( this, this, 'CTRL+' + contents.accessKey, + tabAccessKeyDown, tabAccessKeyUp ); + this._.accessKeyMap[ 'CTRL+' + contents.accessKey ] = contents.id; + } + }, + + /** + * Activates a tab page in the dialog by its id. + * @param {String} id The id of the dialog tab to be activated. + * @example + * dialogObj.selectPage( 'tab_1' ); + */ + selectPage : function( id ) + { + if ( this._.currentTabId == id ) + return; + + // Returning true means that the event has been canceled + if ( this.fire( 'selectPage', { page : id, currentPage : this._.currentTabId } ) === true ) + return; + + // Hide the non-selected tabs and pages. + for ( var i in this._.tabs ) + { + var tab = this._.tabs[i][0], + page = this._.tabs[i][1]; + if ( i != id ) + { + tab.removeClass( 'cke_dialog_tab_selected' ); + page.hide(); + } + page.setAttribute( 'aria-hidden', i != id ); + } + + var selected = this._.tabs[ id ]; + selected[ 0 ].addClass( 'cke_dialog_tab_selected' ); + + // [IE] an invisible input[type='text'] will enlarge it's width + // if it's value is long when it shows, so we clear it's value + // before it shows and then recover it (#5649) + if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat ) + { + clearOrRecoverTextInputValue( selected[ 1 ] ); + selected[ 1 ].show(); + setTimeout( function() + { + clearOrRecoverTextInputValue( selected[ 1 ], 1 ); + }, 0 ); + } + else + selected[ 1 ].show(); + + this._.currentTabId = id; + this._.currentTabIndex = CKEDITOR.tools.indexOf( this._.tabIdList, id ); + }, + + // Dialog state-specific style updates. + updateStyle : function() + { + // If only a single page shown, a different style is used in the central pane. + this.parts.dialog[ ( this._.pageCount === 1 ? 'add' : 'remove' ) + 'Class' ]( 'cke_single_page' ); + }, + + /** + * Hides a page's tab away from the dialog. + * @param {String} id The page's Id. + * @example + * dialog.hidePage( 'tab_3' ); + */ + hidePage : function( id ) + { + var tab = this._.tabs[id] && this._.tabs[id][0]; + if ( !tab || this._.pageCount == 1 || !tab.isVisible() ) + return; + // Switch to other tab first when we're hiding the active tab. + else if ( id == this._.currentTabId ) + this.selectPage( getPreviousVisibleTab.call( this ) ); + + tab.hide(); + this._.pageCount--; + this.updateStyle(); + }, + + /** + * Unhides a page's tab. + * @param {String} id The page's Id. + * @example + * dialog.showPage( 'tab_2' ); + */ + showPage : function( id ) + { + var tab = this._.tabs[id] && this._.tabs[id][0]; + if ( !tab ) + return; + tab.show(); + this._.pageCount++; + this.updateStyle(); + }, + + /** + * Gets the root DOM element of the dialog. + * @returns {CKEDITOR.dom.element} The <span> element containing this dialog. + * @example + * var dialogElement = dialogObj.getElement().getFirst(); + * dialogElement.setStyle( 'padding', '5px' ); + */ + getElement : function() + { + return this._.element; + }, + + /** + * Gets the name of the dialog. + * @returns {String} The name of this dialog. + * @example + * var dialogName = dialogObj.getName(); + */ + getName : function() + { + return this._.name; + }, + + /** + * Gets a dialog UI element object from a dialog page. + * @param {String} pageId id of dialog page. + * @param {String} elementId id of UI element. + * @example + * @returns {CKEDITOR.ui.dialog.uiElement} The dialog UI element. + */ + getContentElement : function( pageId, elementId ) + { + var page = this._.contents[ pageId ]; + return page && page[ elementId ]; + }, + + /** + * Gets the value of a dialog UI element. + * @param {String} pageId id of dialog page. + * @param {String} elementId id of UI element. + * @example + * @returns {Object} The value of the UI element. + */ + getValueOf : function( pageId, elementId ) + { + return this.getContentElement( pageId, elementId ).getValue(); + }, + + /** + * Sets the value of a dialog UI element. + * @param {String} pageId id of the dialog page. + * @param {String} elementId id of the UI element. + * @param {Object} value The new value of the UI element. + * @example + */ + setValueOf : function( pageId, elementId, value ) + { + return this.getContentElement( pageId, elementId ).setValue( value ); + }, + + /** + * Gets the UI element of a button in the dialog's button row. + * @param {String} id The id of the button. + * @example + * @returns {CKEDITOR.ui.dialog.button} The button object. + */ + getButton : function( id ) + { + return this._.buttons[ id ]; + }, + + /** + * Simulates a click to a dialog button in the dialog's button row. + * @param {String} id The id of the button. + * @example + * @returns The return value of the dialog's "click" event. + */ + click : function( id ) + { + return this._.buttons[ id ].click(); + }, + + /** + * Disables a dialog button. + * @param {String} id The id of the button. + * @example + */ + disableButton : function( id ) + { + return this._.buttons[ id ].disable(); + }, + + /** + * Enables a dialog button. + * @param {String} id The id of the button. + * @example + */ + enableButton : function( id ) + { + return this._.buttons[ id ].enable(); + }, + + /** + * Gets the number of pages in the dialog. + * @returns {Number} Page count. + */ + getPageCount : function() + { + return this._.pageCount; + }, + + /** + * Gets the editor instance which opened this dialog. + * @returns {CKEDITOR.editor} Parent editor instances. + */ + getParentEditor : function() + { + return this._.editor; + }, + + /** + * Gets the element that was selected when opening the dialog, if any. + * @returns {CKEDITOR.dom.element} The element that was selected, or null. + */ + getSelectedElement : function() + { + return this.getParentEditor().getSelection().getSelectedElement(); + }, + + /** + * Adds element to dialog's focusable list. + * + * @param {CKEDITOR.dom.element} element + * @param {Number} [index] + */ + addFocusable: function( element, index ) { + if ( typeof index == 'undefined' ) + { + index = this._.focusList.length; + this._.focusList.push( new Focusable( this, element, index ) ); + } + else + { + this._.focusList.splice( index, 0, new Focusable( this, element, index ) ); + for ( var i = index + 1 ; i < this._.focusList.length ; i++ ) + this._.focusList[ i ].focusIndex++; + } + } + }; + + CKEDITOR.tools.extend( CKEDITOR.dialog, + /** + * @lends CKEDITOR.dialog + */ + { + /** + * Registers a dialog. + * @param {String} name The dialog's name. + * @param {Function|String} dialogDefinition + * A function returning the dialog's definition, or the URL to the .js file holding the function. + * The function should accept an argument "editor" which is the current editor instance, and + * return an object conforming to {@link CKEDITOR.dialog.definition}. + * @see CKEDITOR.dialog.definition + * @example + * // Full sample plugin, which does not only register a dialog window but also adds an item to the context menu. + * // To open the dialog window, choose "Open dialog" in the context menu. + * CKEDITOR.plugins.add( 'myplugin', + * { + * init: function( editor ) + * { + * editor.addCommand( 'mydialog',new CKEDITOR.dialogCommand( 'mydialog' ) ); + * + * if ( editor.contextMenu ) + * { + * editor.addMenuGroup( 'mygroup', 10 ); + * editor.addMenuItem( 'My Dialog', + * { + * label : 'Open dialog', + * command : 'mydialog', + * group : 'mygroup' + * }); + * editor.contextMenu.addListener( function( element ) + * { + * return { 'My Dialog' : CKEDITOR.TRISTATE_OFF }; + * }); + * } + * + * CKEDITOR.dialog.add( 'mydialog', function( api ) + * { + * // CKEDITOR.dialog.definition + * var dialogDefinition = + * { + * title : 'Sample dialog', + * minWidth : 390, + * minHeight : 130, + * contents : [ + * { + * id : 'tab1', + * label : 'Label', + * title : 'Title', + * expand : true, + * padding : 0, + * elements : + * [ + * { + * type : 'html', + * html : '<p>This is some sample HTML content.</p>' + * }, + * { + * type : 'textarea', + * id : 'textareaId', + * rows : 4, + * cols : 40 + * } + * ] + * } + * ], + * buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ], + * onOk : function() { + * // "this" is now a CKEDITOR.dialog object. + * // Accessing dialog elements: + * var textareaObj = this.getContentElement( 'tab1', 'textareaId' ); + * alert( "You have entered: " + textareaObj.getValue() ); + * } + * }; + * + * return dialogDefinition; + * } ); + * } + * } ); + * + * CKEDITOR.replace( 'editor1', { extraPlugins : 'myplugin' } ); + */ + add : function( name, dialogDefinition ) + { + // Avoid path registration from multiple instances override definition. + if ( !this._.dialogDefinitions[name] + || typeof dialogDefinition == 'function' ) + this._.dialogDefinitions[name] = dialogDefinition; + }, + + exists : function( name ) + { + return !!this._.dialogDefinitions[ name ]; + }, + + getCurrent : function() + { + return CKEDITOR.dialog._.currentTop; + }, + + /** + * The default OK button for dialogs. Fires the "ok" event and closes the dialog if the event succeeds. + * @static + * @field + * @example + * @type Function + */ + okButton : (function() + { + var retval = function( editor, override ) + { + override = override || {}; + return CKEDITOR.tools.extend( { + id : 'ok', + type : 'button', + label : editor.lang.common.ok, + 'class' : 'cke_dialog_ui_button_ok', + onClick : function( evt ) + { + var dialog = evt.data.dialog; + if ( dialog.fire( 'ok', { hide : true } ).hide !== false ) + dialog.hide(); + } + }, override, true ); + }; + retval.type = 'button'; + retval.override = function( override ) + { + return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); }, + { type : 'button' }, true ); + }; + return retval; + })(), + + /** + * The default cancel button for dialogs. Fires the "cancel" event and closes the dialog if no UI element value changed. + * @static + * @field + * @example + * @type Function + */ + cancelButton : (function() + { + var retval = function( editor, override ) + { + override = override || {}; + return CKEDITOR.tools.extend( { + id : 'cancel', + type : 'button', + label : editor.lang.common.cancel, + 'class' : 'cke_dialog_ui_button_cancel', + onClick : function( evt ) + { + var dialog = evt.data.dialog; + if ( dialog.fire( 'cancel', { hide : true } ).hide !== false ) + dialog.hide(); + } + }, override, true ); + }; + retval.type = 'button'; + retval.override = function( override ) + { + return CKEDITOR.tools.extend( function( editor ){ return retval( editor, override ); }, + { type : 'button' }, true ); + }; + return retval; + })(), + + /** + * Registers a dialog UI element. + * @param {String} typeName The name of the UI element. + * @param {Function} builder The function to build the UI element. + * @example + */ + addUIElement : function( typeName, builder ) + { + this._.uiElementBuilders[ typeName ] = builder; + } + }); + + CKEDITOR.dialog._ = + { + uiElementBuilders : {}, + + dialogDefinitions : {}, + + currentTop : null, + + currentZIndex : null + }; + + // "Inherit" (copy actually) from CKEDITOR.event. + CKEDITOR.event.implementOn( CKEDITOR.dialog ); + CKEDITOR.event.implementOn( CKEDITOR.dialog.prototype, true ); + + var defaultDialogDefinition = + { + resizable : CKEDITOR.DIALOG_RESIZE_BOTH, + minWidth : 600, + minHeight : 400, + buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ] + }; + + // Tool function used to return an item from an array based on its id + // property. + var getById = function( array, id, recurse ) + { + for ( var i = 0, item ; ( item = array[ i ] ) ; i++ ) + { + if ( item.id == id ) + return item; + if ( recurse && item[ recurse ] ) + { + var retval = getById( item[ recurse ], id, recurse ) ; + if ( retval ) + return retval; + } + } + return null; + }; + + // Tool function used to add an item into an array. + var addById = function( array, newItem, nextSiblingId, recurse, nullIfNotFound ) + { + if ( nextSiblingId ) + { + for ( var i = 0, item ; ( item = array[ i ] ) ; i++ ) + { + if ( item.id == nextSiblingId ) + { + array.splice( i, 0, newItem ); + return newItem; + } + + if ( recurse && item[ recurse ] ) + { + var retval = addById( item[ recurse ], newItem, nextSiblingId, recurse, true ); + if ( retval ) + return retval; + } + } + + if ( nullIfNotFound ) + return null; + } + + array.push( newItem ); + return newItem; + }; + + // Tool function used to remove an item from an array based on its id. + var removeById = function( array, id, recurse ) + { + for ( var i = 0, item ; ( item = array[ i ] ) ; i++ ) + { + if ( item.id == id ) + return array.splice( i, 1 ); + if ( recurse && item[ recurse ] ) + { + var retval = removeById( item[ recurse ], id, recurse ); + if ( retval ) + return retval; + } + } + return null; + }; + + /** + * This class is not really part of the API. It is the "definition" property value + * passed to "dialogDefinition" event handlers. + * @constructor + * @name CKEDITOR.dialog.definitionObject + * @extends CKEDITOR.dialog.definition + * @example + * CKEDITOR.on( 'dialogDefinition', function( evt ) + * { + * var definition = evt.data.definition; + * var content = definition.getContents( 'page1' ); + * ... + * } ); + */ + var definitionObject = function( dialog, dialogDefinition ) + { + // TODO : Check if needed. + this.dialog = dialog; + + // Transform the contents entries in contentObjects. + var contents = dialogDefinition.contents; + for ( var i = 0, content ; ( content = contents[i] ) ; i++ ) + contents[ i ] = content && new contentObject( dialog, content ); + + CKEDITOR.tools.extend( this, dialogDefinition ); + }; + + definitionObject.prototype = + /** @lends CKEDITOR.dialog.definitionObject.prototype */ + { + /** + * Gets a content definition. + * @param {String} id The id of the content definition. + * @returns {CKEDITOR.dialog.definition.content} The content definition + * matching id. + */ + getContents : function( id ) + { + return getById( this.contents, id ); + }, + + /** + * Gets a button definition. + * @param {String} id The id of the button definition. + * @returns {CKEDITOR.dialog.definition.button} The button definition + * matching id. + */ + getButton : function( id ) + { + return getById( this.buttons, id ); + }, + + /** + * Adds a content definition object under this dialog definition. + * @param {CKEDITOR.dialog.definition.content} contentDefinition The + * content definition. + * @param {String} [nextSiblingId] The id of an existing content + * definition which the new content definition will be inserted + * before. Omit if the new content definition is to be inserted as + * the last item. + * @returns {CKEDITOR.dialog.definition.content} The inserted content + * definition. + */ + addContents : function( contentDefinition, nextSiblingId ) + { + return addById( this.contents, contentDefinition, nextSiblingId ); + }, + + /** + * Adds a button definition object under this dialog definition. + * @param {CKEDITOR.dialog.definition.button} buttonDefinition The + * button definition. + * @param {String} [nextSiblingId] The id of an existing button + * definition which the new button definition will be inserted + * before. Omit if the new button definition is to be inserted as + * the last item. + * @returns {CKEDITOR.dialog.definition.button} The inserted button + * definition. + */ + addButton : function( buttonDefinition, nextSiblingId ) + { + return addById( this.buttons, buttonDefinition, nextSiblingId ); + }, + + /** + * Removes a content definition from this dialog definition. + * @param {String} id The id of the content definition to be removed. + * @returns {CKEDITOR.dialog.definition.content} The removed content + * definition. + */ + removeContents : function( id ) + { + removeById( this.contents, id ); + }, + + /** + * Removes a button definition from the dialog definition. + * @param {String} id The id of the button definition to be removed. + * @returns {CKEDITOR.dialog.definition.button} The removed button + * definition. + */ + removeButton : function( id ) + { + removeById( this.buttons, id ); + } + }; + + /** + * This class is not really part of the API. It is the template of the + * objects representing content pages inside the + * CKEDITOR.dialog.definitionObject. + * @constructor + * @name CKEDITOR.dialog.definition.contentObject + * @example + * CKEDITOR.on( 'dialogDefinition', function( evt ) + * { + * var definition = evt.data.definition; + * var content = definition.getContents( 'page1' ); + * content.remove( 'textInput1' ); + * ... + * } ); + */ + function contentObject( dialog, contentDefinition ) + { + this._ = + { + dialog : dialog + }; + + CKEDITOR.tools.extend( this, contentDefinition ); + } + + contentObject.prototype = + /** @lends CKEDITOR.dialog.definition.contentObject.prototype */ + { + /** + * Gets a UI element definition under the content definition. + * @param {String} id The id of the UI element definition. + * @returns {CKEDITOR.dialog.definition.uiElement} + */ + get : function( id ) + { + return getById( this.elements, id, 'children' ); + }, + + /** + * Adds a UI element definition to the content definition. + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition The + * UI elemnet definition to be added. + * @param {String} nextSiblingId The id of an existing UI element + * definition which the new UI element definition will be inserted + * before. Omit if the new button definition is to be inserted as + * the last item. + * @returns {CKEDITOR.dialog.definition.uiElement} The element + * definition inserted. + */ + add : function( elementDefinition, nextSiblingId ) + { + return addById( this.elements, elementDefinition, nextSiblingId, 'children' ); + }, + + /** + * Removes a UI element definition from the content definition. + * @param {String} id The id of the UI element definition to be + * removed. + * @returns {CKEDITOR.dialog.definition.uiElement} The element + * definition removed. + * @example + */ + remove : function( id ) + { + removeById( this.elements, id, 'children' ); + } + }; + + function initDragAndDrop( dialog ) + { + var lastCoords = null, + abstractDialogCoords = null, + element = dialog.getElement().getFirst(), + editor = dialog.getParentEditor(), + magnetDistance = editor.config.dialog_magnetDistance, + margins = editor.skin.margins || [ 0, 0, 0, 0 ]; + + if ( typeof magnetDistance == 'undefined' ) + magnetDistance = 20; + + function mouseMoveHandler( evt ) + { + var dialogSize = dialog.getSize(), + viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(), + x = evt.data.$.screenX, + y = evt.data.$.screenY, + dx = x - lastCoords.x, + dy = y - lastCoords.y, + realX, realY; + + lastCoords = { x : x, y : y }; + abstractDialogCoords.x += dx; + abstractDialogCoords.y += dy; + + if ( abstractDialogCoords.x + margins[3] < magnetDistance ) + realX = - margins[3]; + else if ( abstractDialogCoords.x - margins[1] > viewPaneSize.width - dialogSize.width - magnetDistance ) + realX = viewPaneSize.width - dialogSize.width + ( editor.lang.dir == 'rtl' ? 0 : margins[1] ); + else + realX = abstractDialogCoords.x; + + if ( abstractDialogCoords.y + margins[0] < magnetDistance ) + realY = - margins[0]; + else if ( abstractDialogCoords.y - margins[2] > viewPaneSize.height - dialogSize.height - magnetDistance ) + realY = viewPaneSize.height - dialogSize.height + margins[2]; + else + realY = abstractDialogCoords.y; + + dialog.move( realX, realY, 1 ); + + evt.data.preventDefault(); + } + + function mouseUpHandler( evt ) + { + CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); + CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); + + if ( CKEDITOR.env.ie6Compat ) + { + var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); + coverDoc.removeListener( 'mousemove', mouseMoveHandler ); + coverDoc.removeListener( 'mouseup', mouseUpHandler ); + } + } + + dialog.parts.title.on( 'mousedown', function( evt ) + { + lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY }; + + CKEDITOR.document.on( 'mousemove', mouseMoveHandler ); + CKEDITOR.document.on( 'mouseup', mouseUpHandler ); + abstractDialogCoords = dialog.getPosition(); + + if ( CKEDITOR.env.ie6Compat ) + { + var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); + coverDoc.on( 'mousemove', mouseMoveHandler ); + coverDoc.on( 'mouseup', mouseUpHandler ); + } + + evt.data.preventDefault(); + }, dialog ); + } + + function initResizeHandles( dialog ) + { + var def = dialog.definition, + resizable = def.resizable; + + if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE ) + return; + + var editor = dialog.getParentEditor(); + var wrapperWidth, wrapperHeight, + viewSize, origin, startSize, + dialogCover; + + var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) + { + startSize = dialog.getSize(); + + var content = dialog.parts.contents, + iframeDialog = content.$.getElementsByTagName( 'iframe' ).length; + + // Shim to help capturing "mousemove" over iframe. + if ( iframeDialog ) + { + dialogCover = CKEDITOR.dom.element.createFromHtml( '' ); + content.append( dialogCover ); + } + + // Calculate the offset between content and chrome size. + wrapperHeight = startSize.height - dialog.parts.contents.getSize( 'height', ! ( CKEDITOR.env.gecko || CKEDITOR.env.opera || CKEDITOR.env.ie && CKEDITOR.env.quirks ) ); + wrapperWidth = startSize.width - dialog.parts.contents.getSize( 'width', 1 ); + + origin = { x : $event.screenX, y : $event.screenY }; + + viewSize = CKEDITOR.document.getWindow().getViewPaneSize(); + + CKEDITOR.document.on( 'mousemove', mouseMoveHandler ); + CKEDITOR.document.on( 'mouseup', mouseUpHandler ); + + if ( CKEDITOR.env.ie6Compat ) + { + var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); + coverDoc.on( 'mousemove', mouseMoveHandler ); + coverDoc.on( 'mouseup', mouseUpHandler ); + } + + $event.preventDefault && $event.preventDefault(); + }); + + // Prepend the grip to the dialog. + dialog.on( 'load', function() + { + var direction = ''; + if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH ) + direction = ' cke_resizer_horizontal'; + else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT ) + direction = ' cke_resizer_vertical'; + var resizer = CKEDITOR.dom.element.createFromHtml( '' ); + dialog.parts.footer.append( resizer, 1 ); + }); + editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } ); + + function mouseMoveHandler( evt ) + { + var rtl = editor.lang.dir == 'rtl', + dx = ( evt.data.$.screenX - origin.x ) * ( rtl ? -1 : 1 ), + dy = evt.data.$.screenY - origin.y, + width = startSize.width, + height = startSize.height, + internalWidth = width + dx * ( dialog._.moved ? 1 : 2 ), + internalHeight = height + dy * ( dialog._.moved ? 1 : 2 ), + element = dialog._.element.getFirst(), + right = rtl && element.getComputedStyle( 'right' ), + position = dialog.getPosition(); + + if ( position.y + internalHeight > viewSize.height ) + internalHeight = viewSize.height - position.y; + + if ( ( rtl ? right : position.x ) + internalWidth > viewSize.width ) + internalWidth = viewSize.width - ( rtl ? right : position.x ); + + // Make sure the dialog will not be resized to the wrong side when it's in the leftmost position for RTL. + if ( ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) ) + width = Math.max( def.minWidth || 0, internalWidth - wrapperWidth ); + + if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH ) + height = Math.max( def.minHeight || 0, internalHeight - wrapperHeight ); + + dialog.resize( width, height ); + + if ( !dialog._.moved ) + dialog.layout(); + + evt.data.preventDefault(); + } + + function mouseUpHandler() + { + CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); + CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); + + if ( dialogCover ) + { + dialogCover.remove(); + dialogCover = null; + } + + if ( CKEDITOR.env.ie6Compat ) + { + var coverDoc = currentCover.getChild( 0 ).getFrameDocument(); + coverDoc.removeListener( 'mouseup', mouseUpHandler ); + coverDoc.removeListener( 'mousemove', mouseMoveHandler ); + } + } + } + + var resizeCover; + // Caching resuable covers and allowing only one cover + // on screen. + var covers = {}, + currentCover; + + function showCover( editor ) + { + var win = CKEDITOR.document.getWindow(); + var config = editor.config, + backgroundColorStyle = config.dialog_backgroundCoverColor || 'white', + backgroundCoverOpacity = config.dialog_backgroundCoverOpacity, + baseFloatZIndex = config.baseFloatZIndex, + coverKey = CKEDITOR.tools.genKey( + backgroundColorStyle, + backgroundCoverOpacity, + baseFloatZIndex ), + coverElement = covers[ coverKey ]; + + if ( !coverElement ) + { + var html = [ + '
Once the dialog is opened, the created element becomes a {@link CKEDITOR.ui.dialog.textarea} object and can be accessed with {@link CKEDITOR.dialog#getContentElement}. + *' + ]; + + if ( CKEDITOR.env.ie6Compat ) + { + // Support for custom document.domain in IE. + var isCustomDomain = CKEDITOR.env.isCustomDomain(), + iframeHtml = ''; + + html.push( + '' ); + } + + html.push( '' ); + + coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) ); + coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 ); + + coverElement.appendTo( CKEDITOR.document.getBody() ); + covers[ coverKey ] = coverElement; + } + else + coverElement. show(); + + currentCover = coverElement; + var resizeFunc = function() + { + var size = win.getViewPaneSize(); + coverElement.setStyles( + { + width : size.width + 'px', + height : size.height + 'px' + } ); + }; + + var scrollFunc = function() + { + var pos = win.getScrollPosition(), + cursor = CKEDITOR.dialog._.currentTop; + coverElement.setStyles( + { + left : pos.x + 'px', + top : pos.y + 'px' + }); + + if ( cursor ) + { + do + { + var dialogPos = cursor.getPosition(); + cursor.move( dialogPos.x, dialogPos.y ); + } while ( ( cursor = cursor._.parentDialog ) ); + } + }; + + resizeCover = resizeFunc; + win.on( 'resize', resizeFunc ); + resizeFunc(); + // Using Safari/Mac, focus must be kept where it is (#7027) + if ( !( CKEDITOR.env.mac && CKEDITOR.env.webkit ) ) + coverElement.focus(); + + if ( CKEDITOR.env.ie6Compat ) + { + // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll. + // So we need to invent a really funny way to make it work. + var myScrollHandler = function() + { + scrollFunc(); + arguments.callee.prevScrollHandler.apply( this, arguments ); + }; + win.$.setTimeout( function() + { + myScrollHandler.prevScrollHandler = window.onscroll || function(){}; + window.onscroll = myScrollHandler; + }, 0 ); + scrollFunc(); + } + } + + function hideCover() + { + if ( !currentCover ) + return; + + var win = CKEDITOR.document.getWindow(); + currentCover.hide(); + win.removeListener( 'resize', resizeCover ); + + if ( CKEDITOR.env.ie6Compat ) + { + win.$.setTimeout( function() + { + var prevScrollHandler = window.onscroll && window.onscroll.prevScrollHandler; + window.onscroll = prevScrollHandler || null; + }, 0 ); + } + resizeCover = null; + } + + function removeCovers() + { + for ( var coverId in covers ) + covers[ coverId ].remove(); + covers = {}; + } + + var accessKeyProcessors = {}; + + var accessKeyDownHandler = function( evt ) + { + var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey, + alt = evt.data.$.altKey, + shift = evt.data.$.shiftKey, + key = String.fromCharCode( evt.data.$.keyCode ), + keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key]; + + if ( !keyProcessor || !keyProcessor.length ) + return; + + keyProcessor = keyProcessor[keyProcessor.length - 1]; + keyProcessor.keydown && keyProcessor.keydown.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key ); + evt.data.preventDefault(); + }; + + var accessKeyUpHandler = function( evt ) + { + var ctrl = evt.data.$.ctrlKey || evt.data.$.metaKey, + alt = evt.data.$.altKey, + shift = evt.data.$.shiftKey, + key = String.fromCharCode( evt.data.$.keyCode ), + keyProcessor = accessKeyProcessors[( ctrl ? 'CTRL+' : '' ) + ( alt ? 'ALT+' : '') + ( shift ? 'SHIFT+' : '' ) + key]; + + if ( !keyProcessor || !keyProcessor.length ) + return; + + keyProcessor = keyProcessor[keyProcessor.length - 1]; + if ( keyProcessor.keyup ) + { + keyProcessor.keyup.call( keyProcessor.uiElement, keyProcessor.dialog, keyProcessor.key ); + evt.data.preventDefault(); + } + }; + + var registerAccessKey = function( uiElement, dialog, key, downFunc, upFunc ) + { + var procList = accessKeyProcessors[key] || ( accessKeyProcessors[key] = [] ); + procList.push( { + uiElement : uiElement, + dialog : dialog, + key : key, + keyup : upFunc || uiElement.accessKeyUp, + keydown : downFunc || uiElement.accessKeyDown + } ); + }; + + var unregisterAccessKey = function( obj ) + { + for ( var i in accessKeyProcessors ) + { + var list = accessKeyProcessors[i]; + for ( var j = list.length - 1 ; j >= 0 ; j-- ) + { + if ( list[j].dialog == obj || list[j].uiElement == obj ) + list.splice( j, 1 ); + } + if ( list.length === 0 ) + delete accessKeyProcessors[i]; + } + }; + + var tabAccessKeyUp = function( dialog, key ) + { + if ( dialog._.accessKeyMap[key] ) + dialog.selectPage( dialog._.accessKeyMap[key] ); + }; + + var tabAccessKeyDown = function( dialog, key ) + { + }; + + // ESC, ENTER + var preventKeyBubblingKeys = { 27 :1, 13 :1 }; + var preventKeyBubbling = function( e ) + { + if ( e.data.getKeystroke() in preventKeyBubblingKeys ) + e.data.stopPropagation(); + }; + + (function() + { + CKEDITOR.ui.dialog = + { + /** + * The base class of all dialog UI elements. + * @constructor + * @param {CKEDITOR.dialog} dialog Parent dialog object. + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition Element + * definition. Accepted fields: + *+ *
+ * @param {Array} htmlList + * List of HTML code to be added to the dialog's content area. + * @param {Function|String} nodeNameArg + * A function returning a string, or a simple string for the node name for + * the root DOM node. Default is 'div'. + * @param {Function|Object} stylesArg + * A function returning an object, or a simple object for CSS styles applied + * to the DOM node. Default is empty object. + * @param {Function|Object} attributesArg + * A fucntion returning an object, or a simple object for attributes applied + * to the DOM node. Default is empty object. + * @param {Function|String} contentsArg + * A function returning a string, or a simple string for the HTML code inside + * the root DOM node. Default is empty string. + * @example + */ + uiElement : function( dialog, elementDefinition, htmlList, nodeNameArg, stylesArg, attributesArg, contentsArg ) + { + if ( arguments.length < 4 ) + return; + + var nodeName = ( nodeNameArg.call ? nodeNameArg( elementDefinition ) : nodeNameArg ) || 'div', + html = [ '<', nodeName, ' ' ], + styles = ( stylesArg && stylesArg.call ? stylesArg( elementDefinition ) : stylesArg ) || {}, + attributes = ( attributesArg && attributesArg.call ? attributesArg( elementDefinition ) : attributesArg ) || {}, + innerHTML = ( contentsArg && contentsArg.call ? contentsArg.call( this, dialog, elementDefinition ) : contentsArg ) || '', + domId = this.domId = attributes.id || CKEDITOR.tools.getNextId() + '_uiElement', + id = this.id = elementDefinition.id, + i; + + // Set the id, a unique id is required for getElement() to work. + attributes.id = domId; + + // Set the type and definition CSS class names. + var classes = {}; + if ( elementDefinition.type ) + classes[ 'cke_dialog_ui_' + elementDefinition.type ] = 1; + if ( elementDefinition.className ) + classes[ elementDefinition.className ] = 1; + var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split( ' ' ) : []; + for ( i = 0 ; i < attributeClasses.length ; i++ ) + { + if ( attributeClasses[i] ) + classes[ attributeClasses[i] ] = 1; + } + var finalClasses = []; + for ( i in classes ) + finalClasses.push( i ); + attributes['class'] = finalClasses.join( ' ' ); + + // Set the popup tooltop. + if ( elementDefinition.title ) + attributes.title = elementDefinition.title; + + // Write the inline CSS styles. + var styleStr = ( elementDefinition.style || '' ).split( ';' ); + for ( i in styles ) + styleStr.push( i + ':' + styles[i] ); + if ( elementDefinition.hidden ) + styleStr.push( 'display:none' ); + for ( i = styleStr.length - 1 ; i >= 0 ; i-- ) + { + if ( styleStr[i] === '' ) + styleStr.splice( i, 1 ); + } + if ( styleStr.length > 0 ) + attributes.style = ( attributes.style ? ( attributes.style + '; ' ) : '' ) + styleStr.join( '; ' ); + + // Write the attributes. + for ( i in attributes ) + html.push( i + '="' + CKEDITOR.tools.htmlEncode( attributes[i] ) + '" '); + + // Write the content HTML. + html.push( '>', innerHTML, '', nodeName, '>' ); + + // Add contents to the parent HTML array. + htmlList.push( html.join( '' ) ); + + ( this._ || ( this._ = {} ) ).dialog = dialog; + + // Override isChanged if it is defined in element definition. + if ( typeof( elementDefinition.isChanged ) == 'boolean' ) + this.isChanged = function(){ return elementDefinition.isChanged; }; + if ( typeof( elementDefinition.isChanged ) == 'function' ) + this.isChanged = elementDefinition.isChanged; + + // Add events. + CKEDITOR.event.implementOn( this ); + + this.registerEvents( elementDefinition ); + if ( this.accessKeyUp && this.accessKeyDown && elementDefinition.accessKey ) + registerAccessKey( this, dialog, 'CTRL+' + elementDefinition.accessKey ); + + var me = this; + dialog.on( 'load', function() + { + if ( me.getInputElement() ) + { + me.getInputElement().on( 'focus', function() + { + dialog._.tabBarMode = false; + dialog._.hasFocus = true; + me.fire( 'focus' ); + }, me ); + } + } ); + + // Register the object as a tab focus if it can be included. + if ( this.keyboardFocusable ) + { + this.tabIndex = elementDefinition.tabIndex || 0; + + this.focusIndex = dialog._.focusList.push( this ) - 1; + this.on( 'focus', function() + { + dialog._.currentFocusIndex = me.focusIndex; + } ); + } + + // Completes this object with everything we have in the + // definition. + CKEDITOR.tools.extend( this, elementDefinition ); + }, + + /** + * Horizontal layout box for dialog UI elements, auto-expends to available width of container. + * @constructor + * @extends CKEDITOR.ui.dialog.uiElement + * @param {CKEDITOR.dialog} dialog + * Parent dialog object. + * @param {Array} childObjList + * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this + * container. + * @param {Array} childHtmlList + * Array of HTML code that correspond to the HTML output of all the + * objects in childObjList. + * @param {Array} htmlList + * Array of HTML code that this element will output to. + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition + * The element definition. Accepted fields: + *- id (Required) The id of the UI element. See {@link + * CKEDITOR.dialog#getContentElement}
+ *- type (Required) The type of the UI element. The + * value to this field specifies which UI element class will be used to + * generate the final widget.
+ *- title (Optional) The popup tooltip for the UI + * element.
+ *- hidden (Optional) A flag that tells if the element + * should be initially visible.
+ *- className (Optional) Additional CSS class names + * to add to the UI element. Separated by space.
+ *- style (Optional) Additional CSS inline styles + * to add to the UI element. A semicolon (;) is required after the last + * style declaration.
+ *- accessKey (Optional) The alphanumeric access key + * for this element. Access keys are automatically prefixed by CTRL.
+ *- on* (Optional) Any UI element definition field that + * starts with on followed immediately by a capital letter and + * probably more letters is an event handler. Event handlers may be further + * divided into registered event handlers and DOM event handlers. Please + * refer to {@link CKEDITOR.ui.dialog.uiElement#registerEvents} and + * {@link CKEDITOR.ui.dialog.uiElement#eventProcessors} for more + * information.
+ *+ *
+ * @example + */ + hbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) + { + if ( arguments.length < 4 ) + return; + + this._ || ( this._ = {} ); + + var children = this._.children = childObjList, + widths = elementDefinition && elementDefinition.widths || null, + height = elementDefinition && elementDefinition.height || null, + styles = {}, + i; + /** @ignore */ + var innerHTML = function() + { + var html = [ '- widths (Optional) The widths of child cells.
+ *- height (Optional) The height of the layout.
+ *- padding (Optional) The padding width inside child + * cells.
+ *- align (Optional) The alignment of the whole layout + *
+ *' ]; + for ( i = 0 ; i < childHtmlList.length ; i++ ) + { + var className = 'cke_dialog_ui_hbox_child', + styles = []; + if ( i === 0 ) + className = 'cke_dialog_ui_hbox_first'; + if ( i == childHtmlList.length - 1 ) + className = 'cke_dialog_ui_hbox_last'; + html.push( ' ' ); + return html.join( '' ); + }; + + var attribs = { role : 'presentation' }; + elementDefinition && elementDefinition.align && ( attribs.align = elementDefinition.align ); + + CKEDITOR.ui.dialog.uiElement.call( + this, + dialog, + elementDefinition || { type : 'hbox' }, + htmlList, + 'table', + styles, + attribs, + innerHTML ); + }, + + /** + * Vertical layout box for dialog UI elements. + * @constructor + * @extends CKEDITOR.ui.dialog.hbox + * @param {CKEDITOR.dialog} dialog + * Parent dialog object. + * @param {Array} childObjList + * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this + * container. + * @param {Array} childHtmlList + * Array of HTML code that correspond to the HTML output of all the + * objects in childObjList. + * @param {Array} htmlList + * Array of HTML code that this element will output to. + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition + * The element definition. Accepted fields: + *0 ) + html.push( 'style="' + styles.join('; ') + '" ' ); + html.push( '>', childHtmlList[i], ' ' ); + } + html.push( '+ *
+ * @example + */ + vbox : function( dialog, childObjList, childHtmlList, htmlList, elementDefinition ) + { + if ( arguments.length < 3 ) + return; + + this._ || ( this._ = {} ); + + var children = this._.children = childObjList, + width = elementDefinition && elementDefinition.width || null, + heights = elementDefinition && elementDefinition.heights || null; + /** @ignore */ + var innerHTML = function() + { + var html = [ '- width (Optional) The width of the layout.
+ *- heights (Optional) The heights of individual cells. + *
+ *- align (Optional) The alignment of the layout.
+ *- padding (Optional) The padding width inside child + * cells.
+ *- expand (Optional) Whether the layout should expand + * vertically to fill its container.
+ *' ); + for ( var i = 0 ; i < childHtmlList.length ; i++ ) + { + var styles = []; + html.push( '
' ); + return html.join( '' ); + }; + CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition || { type : 'vbox' }, htmlList, 'div', null, { role : 'presentation' }, innerHTML ); + } + }; + })(); + + CKEDITOR.ui.dialog.uiElement.prototype = + { + /** + * Gets the root DOM element of this dialog UI object. + * @returns {CKEDITOR.dom.element} Root DOM element of UI object. + * @example + * uiElement.getElement().hide(); + */ + getElement : function() + { + return CKEDITOR.document.getById( this.domId ); + }, + + /** + * Gets the DOM element that the user inputs values. + * This function is used by setValue(), getValue() and focus(). It should + * be overrided in child classes where the input element isn't the root + * element. + * @returns {CKEDITOR.dom.element} The element where the user input values. + * @example + * var rawValue = textInput.getInputElement().$.value; + */ + getInputElement : function() + { + return this.getElement(); + }, + + /** + * Gets the parent dialog object containing this UI element. + * @returns {CKEDITOR.dialog} Parent dialog object. + * @example + * var dialog = uiElement.getDialog(); + */ + getDialog : function() + { + return this._.dialog; + }, + + /** + * Sets the value of this dialog UI object. + * @param {Object} value The new value. + * @param {Boolean} noChangeEvent Internal commit, to supress 'change' event on this element. + * @returns {CKEDITOR.dialog.uiElement} The current UI element. + * @example + * uiElement.setValue( 'Dingo' ); + */ + setValue : function( value, noChangeEvent ) + { + this.getInputElement().setValue( value ); + !noChangeEvent && this.fire( 'change', { value : value } ); + return this; + }, + + /** + * Gets the current value of this dialog UI object. + * @returns {Object} The current value. + * @example + * var myValue = uiElement.getValue(); + */ + getValue : function() + { + return this.getInputElement().getValue(); + }, + + /** + * Tells whether the UI object's value has changed. + * @returns {Boolean} true if changed, false if not changed. + * @example + * if ( uiElement.isChanged() ) + * confirm( 'Value changed! Continue?' ); + */ + isChanged : function() + { + // Override in input classes. + return false; + }, + + /** + * Selects the parent tab of this element. Usually called by focus() or overridden focus() methods. + * @returns {CKEDITOR.dialog.uiElement} The current UI element. + * @example + * focus : function() + * { + * this.selectParentTab(); + * // do something else. + * } + */ + selectParentTab : function() + { + var element = this.getInputElement(), + cursor = element, + tabId; + while ( ( cursor = cursor.getParent() ) && cursor.$.className.search( 'cke_dialog_page_contents' ) == -1 ) + { /*jsl:pass*/ } + + // Some widgets don't have parent tabs (e.g. OK and Cancel buttons). + if ( !cursor ) + return this; + + tabId = cursor.getAttribute( 'name' ); + // Avoid duplicate select. + if ( this._.dialog._.currentTabId != tabId ) + this._.dialog.selectPage( tabId ); + return this; + }, + + /** + * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page. + * @returns {CKEDITOR.dialog.uiElement} The current UI element. + * @example + * uiElement.focus(); + */ + focus : function() + { + this.selectParentTab().getInputElement().focus(); + return this; + }, + + /** + * Registers the on* event handlers defined in the element definition. + * The default behavior of this function is: + *' ); + } + html.push( ' 0 ) + html.push( 'style="', styles.join( '; ' ), '" ' ); + html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], ' + *
+ * This function is only called at UI element instantiation, but can + * be overridded in child classes if they require more flexibility. + * @param {CKEDITOR.dialog.definition.uiElement} definition The UI element + * definition. + * @returns {CKEDITOR.dialog.uiElement} The current UI element. + * @example + */ + registerEvents : function( definition ) + { + var regex = /^on([A-Z]\w+)/, + match; + + var registerDomEvent = function( uiElement, dialog, eventName, func ) + { + dialog.on( 'load', function() + { + uiElement.getInputElement().on( eventName, func, uiElement ); + }); + }; + + for ( var i in definition ) + { + if ( !( match = i.match( regex ) ) ) + continue; + if ( this.eventProcessors[i] ) + this.eventProcessors[i].call( this, this._.dialog, definition[i] ); + else + registerDomEvent( this, this._.dialog, match[1].toLowerCase(), definition[i] ); + } + + return this; + }, + + /** + * The event processor list used by + * {@link CKEDITOR.ui.dialog.uiElement#getInputElement} at UI element + * instantiation. The default list defines three on* events: + *- + * If the on* event is defined in the class's eventProcesors list, + * then the registration is delegated to the corresponding function + * in the eventProcessors list. + *
+ *- + * If the on* event is not defined in the eventProcessors list, then + * register the event handler under the corresponding DOM event of + * the UI element's input DOM element (as defined by the return value + * of {@link CKEDITOR.ui.dialog.uiElement#getInputElement}). + *
+ *+ *
+ * @field + * @type Object + * @example + * // This connects the 'click' event in CKEDITOR.ui.dialog.button to onClick + * // handlers in the UI element's definitions. + * CKEDITOR.ui.dialog.button.eventProcessors = CKEDITOR.tools.extend( {}, + * CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors, + * { onClick : function( dialog, func ) { this.on( 'click', func ); } }, + * true ); + */ + eventProcessors : + { + onLoad : function( dialog, func ) + { + dialog.on( 'load', func, this ); + }, + + onShow : function( dialog, func ) + { + dialog.on( 'show', func, this ); + }, + + onHide : function( dialog, func ) + { + dialog.on( 'hide', func, this ); + } + }, + + /** + * The default handler for a UI element's access key down event, which + * tries to put focus to the UI element.- onLoad - Called when the element's parent dialog opens for the + * first time
+ *- onShow - Called whenever the element's parent dialog opens.
+ *- onHide - Called whenever the element's parent dialog closes.
+ *
+ * Can be overridded in child classes for more sophisticaed behavior. + * @param {CKEDITOR.dialog} dialog The parent dialog object. + * @param {String} key The key combination pressed. Since access keys + * are defined to always include the CTRL key, its value should always + * include a 'CTRL+' prefix. + * @example + */ + accessKeyDown : function( dialog, key ) + { + this.focus(); + }, + + /** + * The default handler for a UI element's access key up event, which + * does nothing.
+ * Can be overridded in child classes for more sophisticated behavior. + * @param {CKEDITOR.dialog} dialog The parent dialog object. + * @param {String} key The key combination pressed. Since access keys + * are defined to always include the CTRL key, its value should always + * include a 'CTRL+' prefix. + * @example + */ + accessKeyUp : function( dialog, key ) + { + }, + + /** + * Disables a UI element. + * @example + */ + disable : function() + { + var element = this.getInputElement(); + element.setAttribute( 'disabled', 'true' ); + element.addClass( 'cke_disabled' ); + }, + + /** + * Enables a UI element. + * @example + */ + enable : function() + { + var element = this.getInputElement(); + element.removeAttribute( 'disabled' ); + element.removeClass( 'cke_disabled' ); + }, + + /** + * Determines whether an UI element is enabled or not. + * @returns {Boolean} Whether the UI element is enabled. + * @example + */ + isEnabled : function() + { + return !this.getInputElement().getAttribute( 'disabled' ); + }, + + /** + * Determines whether an UI element is visible or not. + * @returns {Boolean} Whether the UI element is visible. + * @example + */ + isVisible : function() + { + return this.getInputElement().isVisible(); + }, + + /** + * Determines whether an UI element is focus-able or not. + * Focus-able is defined as being both visible and enabled. + * @returns {Boolean} Whether the UI element can be focused. + * @example + */ + isFocusable : function() + { + if ( !this.isEnabled() || !this.isVisible() ) + return false; + return true; + } + }; + + CKEDITOR.ui.dialog.hbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement, + /** + * @lends CKEDITOR.ui.dialog.hbox.prototype + */ + { + /** + * Gets a child UI element inside this container. + * @param {Array|Number} indices An array or a single number to indicate the child's + * position in the container's descendant tree. Omit to get all the children in an array. + * @returns {Array|CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container + * if no argument given, or the specified UI element if indices is given. + * @example + * var checkbox = hbox.getChild( [0,1] ); + * checkbox.setValue( true ); + */ + getChild : function( indices ) + { + // If no arguments, return a clone of the children array. + if ( arguments.length < 1 ) + return this._.children.concat(); + + // If indices isn't array, make it one. + if ( !indices.splice ) + indices = [ indices ]; + + // Retrieve the child element according to tree position. + if ( indices.length < 2 ) + return this._.children[ indices[0] ]; + else + return ( this._.children[ indices[0] ] && this._.children[ indices[0] ].getChild ) ? + this._.children[ indices[0] ].getChild( indices.slice( 1, indices.length ) ) : + null; + } + }, true ); + + CKEDITOR.ui.dialog.vbox.prototype = new CKEDITOR.ui.dialog.hbox(); + + + + (function() + { + var commonBuilder = { + build : function( dialog, elementDefinition, output ) + { + var children = elementDefinition.children, + child, + childHtmlList = [], + childObjList = []; + for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ ) + { + var childHtml = []; + childHtmlList.push( childHtml ); + childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) ); + } + return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, childObjList, childHtmlList, output, elementDefinition ); + } + }; + + CKEDITOR.dialog.addUIElement( 'hbox', commonBuilder ); + CKEDITOR.dialog.addUIElement( 'vbox', commonBuilder ); + })(); + + /** + * Generic dialog command. It opens a specific dialog when executed. + * @constructor + * @augments CKEDITOR.commandDefinition + * @param {string} dialogName The name of the dialog to open when executing + * this command. + * @example + * // Register the "link" command, which opens the "link" dialog. + * editor.addCommand( 'link', new CKEDITOR.dialogCommand( 'link' ) ); + */ + CKEDITOR.dialogCommand = function( dialogName ) + { + this.dialogName = dialogName; + }; + + CKEDITOR.dialogCommand.prototype = + { + /** @ignore */ + exec : function( editor ) + { + editor.openDialog( this.dialogName ); + }, + + // Dialog commands just open a dialog ui, thus require no undo logic, + // undo support should dedicate to specific dialog implementation. + canUndo: false, + + editorFocus : CKEDITOR.env.ie || CKEDITOR.env.webkit + }; + + (function() + { + var notEmptyRegex = /^([a]|[^a])+$/, + integerRegex = /^\d*$/, + numberRegex = /^\d*(?:\.\d+)?$/; + + CKEDITOR.VALIDATE_OR = 1; + CKEDITOR.VALIDATE_AND = 2; + + CKEDITOR.dialog.validate = + { + functions : function() + { + return function() + { + /** + * It's important for validate functions to be able to accept the value + * as argument in addition to this.getValue(), so that it is possible to + * combine validate functions together to make more sophisticated + * validators. + */ + var value = this && this.getValue ? this.getValue() : arguments[0]; + + var msg = undefined, + relation = CKEDITOR.VALIDATE_AND, + functions = [], i; + + for ( i = 0 ; i < arguments.length ; i++ ) + { + if ( typeof( arguments[i] ) == 'function' ) + functions.push( arguments[i] ); + else + break; + } + + if ( i < arguments.length && typeof( arguments[i] ) == 'string' ) + { + msg = arguments[i]; + i++; + } + + if ( i < arguments.length && typeof( arguments[i]) == 'number' ) + relation = arguments[i]; + + var passed = ( relation == CKEDITOR.VALIDATE_AND ? true : false ); + for ( i = 0 ; i < functions.length ; i++ ) + { + if ( relation == CKEDITOR.VALIDATE_AND ) + passed = passed && functions[i]( value ); + else + passed = passed || functions[i]( value ); + } + + if ( !passed ) + { + if ( msg !== undefined ) + alert( msg ); + if ( this && ( this.select || this.focus ) ) + ( this.select || this.focus )(); + return false; + } + + return true; + }; + }, + + regex : function( regex, msg ) + { + /* + * Can be greatly shortened by deriving from functions validator if code size + * turns out to be more important than performance. + */ + return function() + { + var value = this && this.getValue ? this.getValue() : arguments[0]; + if ( !regex.test( value ) ) + { + if ( msg !== undefined ) + alert( msg ); + if ( this && ( this.select || this.focus ) ) + { + if ( this.select ) + this.select(); + else + this.focus(); + } + return false; + } + return true; + }; + }, + + notEmpty : function( msg ) + { + return this.regex( notEmptyRegex, msg ); + }, + + integer : function( msg ) + { + return this.regex( integerRegex, msg ); + }, + + 'number' : function( msg ) + { + return this.regex( numberRegex, msg ); + }, + + equals : function( value, msg ) + { + return this.functions( function( val ){ return val == value; }, msg ); + }, + + notEqual : function( value, msg ) + { + return this.functions( function( val ){ return val != value; }, msg ); + } + }; + + CKEDITOR.on( 'instanceDestroyed', function( evt ) + { + // Remove dialog cover on last instance destroy. + if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) ) + { + var currentTopDialog; + while ( ( currentTopDialog = CKEDITOR.dialog._.currentTop ) ) + currentTopDialog.hide(); + removeCovers(); + } + + var dialogs = evt.editor._.storedDialogs; + for ( var name in dialogs ) + dialogs[ name ].destroy(); + + }); + + })(); + + // Extend the CKEDITOR.editor class with dialog specific functions. + CKEDITOR.tools.extend( CKEDITOR.editor.prototype, + /** @lends CKEDITOR.editor.prototype */ + { + /** + * Loads and opens a registered dialog. + * @param {String} dialogName The registered name of the dialog. + * @param {Function} callback The function to be invoked after dialog instance created. + * @see CKEDITOR.dialog.add + * @example + * CKEDITOR.instances.editor1.openDialog( 'smiley' ); + * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered. + */ + openDialog : function( dialogName, callback ) + { + if ( this.mode == 'wysiwyg' && CKEDITOR.env.ie ) + { + var selection = this.getSelection(); + selection && selection.lock(); + } + + var dialogDefinitions = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], + dialogSkin = this.skin.dialog; + + if ( CKEDITOR.dialog._.currentTop === null ) + showCover( this ); + + // If the dialogDefinition is already loaded, open it immediately. + if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded ) + { + var storedDialogs = this._.storedDialogs || + ( this._.storedDialogs = {} ); + + var dialog = storedDialogs[ dialogName ] || + ( storedDialogs[ dialogName ] = new CKEDITOR.dialog( this, dialogName ) ); + + callback && callback.call( dialog, dialog ); + dialog.show(); + + return dialog; + } + else if ( dialogDefinitions == 'failed' ) + { + hideCover(); + throw new Error( '[CKEDITOR.dialog.openDialog] Dialog "' + dialogName + '" failed when loading definition.' ); + } + + var me = this; + + function onDialogFileLoaded( success ) + { + var dialogDefinition = CKEDITOR.dialog._.dialogDefinitions[ dialogName ], + skin = me.skin.dialog; + + // Check if both skin part and definition is loaded. + if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' ) + return; + + // In case of plugin error, mark it as loading failed. + if ( typeof dialogDefinition != 'function' ) + CKEDITOR.dialog._.dialogDefinitions[ dialogName ] = 'failed'; + + me.openDialog( dialogName, callback ); + } + + if ( typeof dialogDefinitions == 'string' ) + { + var loadDefinition = 1; + CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( dialogDefinitions ), onDialogFileLoaded, null, 0, 1 ); + } + + CKEDITOR.skins.load( this, 'dialog', onDialogFileLoaded ); + + return null; + } + }); +})(); + +CKEDITOR.plugins.add( 'dialog', + { + requires : [ 'dialogui' ] + }); + +// Dialog related configurations. + +/** + * The color of the dialog background cover. It should be a valid CSS color + * string. + * @name CKEDITOR.config.dialog_backgroundCoverColor + * @type String + * @default 'white' + * @example + * config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)'; + */ + +/** + * The opacity of the dialog background cover. It should be a number within the + * range [0.0, 1.0]. + * @name CKEDITOR.config.dialog_backgroundCoverOpacity + * @type Number + * @default 0.5 + * @example + * config.dialog_backgroundCoverOpacity = 0.7; + */ + +/** + * If the dialog has more than one tab, put focus into the first tab as soon as dialog is opened. + * @name CKEDITOR.config.dialog_startupFocusTab + * @type Boolean + * @default false + * @example + * config.dialog_startupFocusTab = true; + */ + +/** + * The distance of magnetic borders used in moving and resizing dialogs, + * measured in pixels. + * @name CKEDITOR.config.dialog_magnetDistance + * @type Number + * @default 20 + * @example + * config.dialog_magnetDistance = 30; + */ + +/** + * The guideline to follow when generating the dialog buttons. There are 3 possible options: + *+ *
+ * @name CKEDITOR.config.dialog_buttonsOrder + * @type String + * @default 'OS' + * @since 3.5 + * @example + * config.dialog_buttonsOrder = 'rtl'; + */ + +/** + * The dialog contents to removed. It's a string composed by dialog name and tab name with a colon between them. + * Separate each pair with semicolon (see example). + * Note: All names are case-sensitive. + * Note: Be cautious when specifying dialog tabs that are mandatory, like "info", dialog functionality might be broken because of this! + * @name CKEDITOR.config.removeDialogTabs + * @type String + * @since 3.5 + * @default '' + * @example + * config.removeDialogTabs = 'flash:advanced;image:Link'; + */ + +/** + * Fired when a dialog definition is about to be used to create a dialog into + * an editor instance. This event makes it possible to customize the definition + * before creating it. + *- 'OS' - the buttons will be displayed in the default order of the user's OS;
+ *- 'ltr' - for Left-To-Right order;
+ *- 'rtl' - for Right-To-Left order.
+ *Note that this event is called only the first time a specific dialog is + * opened. Successive openings will use the cached dialog, and this event will + * not get fired.
+ * @name CKEDITOR#dialogDefinition + * @event + * @param {CKEDITOR.dialog.definition} data The dialog defination that + * is being loaded. + * @param {CKEDITOR.editor} editor The editor instance that will use the + * dialog. + */ + +/** + * Fired when a tab is going to be selected in a dialog + * @name CKEDITOR.dialog#selectPage + * @event + * @param {String} page The id of the page that it's gonna be selected. + * @param {String} currentPage The id of the current page. + */ + +/** + * Fired when the user tries to dismiss a dialog + * @name CKEDITOR.dialog#cancel + * @event + * @param {Boolean} hide Whether the event should proceed or not. + */ + +/** + * Fired when the user tries to confirm a dialog + * @name CKEDITOR.dialog#ok + * @event + * @param {Boolean} hide Whether the event should proceed or not. + */ + +/** + * Fired when a dialog is shown + * @name CKEDITOR.dialog#show + * @event + */ + +/** + * Fired when a dialog is shown + * @name CKEDITOR.editor#dialogShow + * @event + */ + +/** + * Fired when a dialog is hidden + * @name CKEDITOR.dialog#hide + * @event + */ + +/** + * Fired when a dialog is hidden + * @name CKEDITOR.editor#dialogHide + * @event + */ + +/** + * Fired when a dialog is being resized. The event is fired on + * both the 'CKEDITOR.dialog' object and the dialog instance + * since 3.5.3, previously it's available only in the global object. + * @name CKEDITOR.dialog#resize + * @since 3.5 + * @event + * @param {CKEDITOR.dialog} dialog The dialog being resized (if + * it's fired on the dialog itself, this parameter isn't sent). + * @param {String} skin The skin name. + * @param {Number} width The new width. + * @param {Number} height The new height. + */ diff --git a/public/javascripts/ckeditor/_source/plugins/dialogadvtab/plugin.js b/public/javascripts/ckeditor/_source/plugins/dialogadvtab/plugin.js new file mode 100644 index 00000000..17486923 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/dialogadvtab/plugin.js @@ -0,0 +1,205 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +(function() +{ + +function setupAdvParams( element ) +{ + var attrName = this.att; + + var value = element && element.hasAttribute( attrName ) && element.getAttribute( attrName ) || ''; + + if ( value !== undefined ) + this.setValue( value ); +} + +function commitAdvParams() +{ + // Dialogs may use different parameters in the commit list, so, by + // definition, we take the first CKEDITOR.dom.element available. + var element; + + for ( var i = 0 ; i < arguments.length ; i++ ) + { + if ( arguments[ i ] instanceof CKEDITOR.dom.element ) + { + element = arguments[ i ]; + break; + } + } + + if ( element ) + { + var attrName = this.att, + value = this.getValue(); + + if ( value ) + element.setAttribute( attrName, value ); + else + element.removeAttribute( attrName, value ); + } +} + +CKEDITOR.plugins.add( 'dialogadvtab', +{ + /** + * + * @param tabConfig + * id, dir, classes, styles + */ + createAdvancedTab : function( editor, tabConfig ) + { + if ( !tabConfig ) + tabConfig = { id:1, dir:1, classes:1, styles:1 }; + + var lang = editor.lang.common; + + var result = + { + id : 'advanced', + label : lang.advancedTab, + title : lang.advancedTab, + elements : + [ + { + type : 'vbox', + padding : 1, + children : [] + } + ] + }; + + var contents = []; + + if ( tabConfig.id || tabConfig.dir ) + { + if ( tabConfig.id ) + { + contents.push( + { + id : 'advId', + att : 'id', + type : 'text', + label : lang.id, + setup : setupAdvParams, + commit : commitAdvParams + }); + } + + if ( tabConfig.dir ) + { + contents.push( + { + id : 'advLangDir', + att : 'dir', + type : 'select', + label : lang.langDir, + 'default' : '', + style : 'width:100%', + items : + [ + [ lang.notSet, '' ], + [ lang.langDirLTR, 'ltr' ], + [ lang.langDirRTL, 'rtl' ] + ], + setup : setupAdvParams, + commit : commitAdvParams + }); + } + + result.elements[ 0 ].children.push( + { + type : 'hbox', + widths : [ '50%', '50%' ], + children : [].concat( contents ) + }); + } + + if ( tabConfig.styles || tabConfig.classes ) + { + contents = []; + + if ( tabConfig.styles ) + { + contents.push( + { + id : 'advStyles', + att : 'style', + type : 'text', + label : lang.styles, + 'default' : '', + + getStyle : function( name, defaultValue ) + { + var match = this.getValue().match( new RegExp( name + '\\s*:\s*([^;]*)', 'i') ); + return match ? match[ 1 ] : defaultValue; + }, + + updateStyle : function( name, value ) + { + var styles = this.getValue(); + + // Remove the current value. + if ( styles ) + { + styles = styles + .replace( new RegExp( '\\s*' + name + '\s*:[^;]*(?:$|;\s*)', 'i' ), '' ) + .replace( /^[;\s]+/, '' ) + .replace( /\s+$/, '' ); + } + + if ( value ) + { + styles && !(/;\s*$/).test( styles ) && ( styles += '; ' ); + styles += name + ': ' + value; + } + + this.setValue( styles, 1 ); + + }, + + setup : setupAdvParams, + + commit : commitAdvParams + + }); + } + + if ( tabConfig.classes ) + { + contents.push( + { + type : 'hbox', + widths : [ '45%', '55%' ], + children : + [ + { + id : 'advCSSClasses', + att : 'class', + type : 'text', + label : lang.cssClasses, + 'default' : '', + setup : setupAdvParams, + commit : commitAdvParams + + } + ] + }); + } + + result.elements[ 0 ].children.push( + { + type : 'hbox', + widths : [ '50%', '50%' ], + children : [].concat( contents ) + }); + } + + return result; + } +}); + +})(); diff --git a/public/javascripts/ckeditor/_source/plugins/dialogui/plugin.js b/public/javascripts/ckeditor/_source/plugins/dialogui/plugin.js new file mode 100644 index 00000000..60f0c8b9 --- /dev/null +++ b/public/javascripts/ckeditor/_source/plugins/dialogui/plugin.js @@ -0,0 +1,1537 @@ +/* +Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved. +For licensing, see LICENSE.html or http://ckeditor.com/license +*/ + +/** @fileoverview The "dialogui" plugin. */ + +CKEDITOR.plugins.add( 'dialogui' ); + +(function() +{ + var initPrivateObject = function( elementDefinition ) + { + this._ || ( this._ = {} ); + this._['default'] = this._.initValue = elementDefinition['default'] || ''; + this._.required = elementDefinition[ 'required' ] || false; + var args = [ this._ ]; + for ( var i = 1 ; i < arguments.length ; i++ ) + args.push( arguments[i] ); + args.push( true ); + CKEDITOR.tools.extend.apply( CKEDITOR.tools, args ); + return this._; + }, + textBuilder = + { + build : function( dialog, elementDefinition, output ) + { + return new CKEDITOR.ui.dialog.textInput( dialog, elementDefinition, output ); + } + }, + commonBuilder = + { + build : function( dialog, elementDefinition, output ) + { + return new CKEDITOR.ui.dialog[elementDefinition.type]( dialog, elementDefinition, output ); + } + }, + containerBuilder = + { + build : function( dialog, elementDefinition, output ) + { + var children = elementDefinition.children, + child, + childHtmlList = [], + childObjList = []; + for ( var i = 0 ; ( i < children.length && ( child = children[i] ) ) ; i++ ) + { + var childHtml = []; + childHtmlList.push( childHtml ); + childObjList.push( CKEDITOR.dialog._.uiElementBuilders[ child.type ].build( dialog, child, childHtml ) ); + } + return new CKEDITOR.ui.dialog[ elementDefinition.type ]( dialog, childObjList, childHtmlList, output, elementDefinition ); + } + }, + commonPrototype = + { + isChanged : function() + { + return this.getValue() != this.getInitValue(); + }, + + reset : function( noChangeEvent ) + { + this.setValue( this.getInitValue(), noChangeEvent ); + }, + + setInitValue : function() + { + this._.initValue = this.getValue(); + }, + + resetInitValue : function() + { + this._.initValue = this._['default']; + }, + + getInitValue : function() + { + return this._.initValue; + } + }, + commonEventProcessors = CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors, + { + onChange : function( dialog, func ) + { + if ( !this._.domOnChangeRegistered ) + { + dialog.on( 'load', function() + { + this.getInputElement().on( 'change', function() + { + // Make sure 'onchange' doesn't get fired after dialog closed. (#5719) + if ( !dialog.parts.dialog.isVisible() ) + return; + + this.fire( 'change', { value : this.getValue() } ); + }, this ); + }, this ); + this._.domOnChangeRegistered = true; + } + + this.on( 'change', func ); + } + }, true ), + eventRegex = /^on([A-Z]\w+)/, + cleanInnerDefinition = function( def ) + { + // An inner UI element should not have the parent's type, title or events. + for ( var i in def ) + { + if ( eventRegex.test( i ) || i == 'title' || i == 'type' ) + delete def[i]; + } + return def; + }; + + CKEDITOR.tools.extend( CKEDITOR.ui.dialog, + /** @lends CKEDITOR.ui.dialog */ + { + /** + * Base class for all dialog elements with a textual label on the left. + * @constructor + * @example + * @extends CKEDITOR.ui.dialog.uiElement + * @param {CKEDITOR.dialog} dialog + * Parent dialog object. + * @param {CKEDITOR.dialog.definition.uiElement} elementDefinition + * The element definition. Accepted fields: + *+ *
+ * @param {Array} htmlList + * List of HTML code to output to. + * @param {Function} contentHtml + * A function returning the HTML code string to be added inside the content + * cell. + */ + labeledElement : function( dialog, elementDefinition, htmlList, contentHtml ) + { + if ( arguments.length < 4 ) + return; + + var _ = initPrivateObject.call( this, elementDefinition ); + _.labelId = CKEDITOR.tools.getNextId() + '_label'; + var children = this._.children = []; + /** @ignore */ + var innerHTML = function() + { + var html = [], + requiredClass = elementDefinition.required ? ' cke_required' : '' ; + if ( elementDefinition.labelLayout != 'horizontal' ) + html.push( '', + '- label (Required) The label string.
+ *- labelLayout (Optional) Put 'horizontal' here if the + * label element is to be layed out horizontally. Otherwise a vertical + * layout will be used.
+ *- widths (Optional) This applies only for horizontal + * layouts - an 2-element array of lengths to specify the widths of the + * label and the content element.
+ *', + contentHtml.call( this, dialog, elementDefinition ), + '' ); + else + { + var hboxDefinition = { + type : 'hbox', + widths : elementDefinition.widths, + padding : 0, + children : + [ + { + type : 'html', + html : '