No regular expressions were active.
1 |
|
/**
|
|
1 |
|
/**
|
2 |
|
*
$Id:
editor_plu
gin_src.js
251
200
7
-0
4
-1
0
20:
16:1
5
Z
spocke
$
|
|
2 |
|
*
$Id:
editor_plu
gin_src.js
609
200
8
-0
2
-1
8
16:1
9:27
Z
spocke
$
|
3 |
|
*
|
|
3 |
|
*
|
4 |
|
* @author
Moxiecode
|
|
4 |
|
* @author
Moxiecode
|
5 |
|
*
@copyright
Copyright
©
2004-200
7
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
|
5 |
|
*
@copyright
Copyright
©
2004-200
8
,
Moxiecode
Systems
AB,
All
rights
reserved.
|
6 |
|
*/
|
|
6 |
|
*/
|
7 |
|
|
|
7 |
|
|
8 |
|
/* Import
plugin spe
cific lang
uage pack
*/
|
|
8 |
|
(function(
) {
|
9 |
|
tinyMCE.im
portPlugin
LanguagePa
ck('save')
;
|
|
9 |
|
tinymc
e.create('
tinymce.pl
ugins.Save
', {
|
|
|
10 |
|
in
it : funct
ion(ed, ur
l) {
|
|
|
11 |
|
var t =
this;
|
|
|
12 |
|
|
|
|
13 |
|
t.editor
= ed;
|
|
|
14 |
|
|
|
|
15 |
|
// Regis
ter comman
ds
|
|
|
16 |
|
ed.addCo
mmand('mce
Save', t._
save, t);
|
|
|
17 |
|
ed.addCo
mmand('mce
Cancel', t
._cancel,
t);
|
|
|
18 |
|
|
|
|
19 |
|
// Regis
ter button
s
|
|
|
20 |
|
ed.addBu
tton('save
', {title
: 'save.sa
ve_desc',
cmd : 'mce
Save'});
|
|
|
21 |
|
ed.addBu
tton('canc
el', {titl
e : 'save.
cancel_des
c', cmd :
'mceCancel
'});
|
|
|
22 |
|
|
|
|
23 |
|
ed.onNod
eChange.ad
d(t._nodeC
hange, t);
|
|
|
24 |
|
ed.addSh
ortcut('ct
rl+s', ed.
getLang('s
ave.save_d
esc'), 'mc
eSave');
|
|
|
25 |
|
},
|
10 |
|
|
|
26 |
|
|
11 |
|
var TinyMC
E_SavePlug
in = {
|
|
|
12 |
|
getInf
o : functi
on() {
|
|
27 |
|
ge
tInfo : fu
nction() {
|
13 |
|
re
turn {
|
|
28 |
|
return {
|
14 |
|
longname
: 'Save',
|
|
29 |
|
long
name : 'Sa
ve',
|
15 |
|
author :
'Moxiecod
e Systems
AB',
|
|
30 |
|
auth
or : 'Moxi
ecode Syst
ems AB',
|
16 |
|
authorur
l : 'http:
//tinymce.
moxiecode.
com',
|
|
31 |
|
auth
orurl : 'h
ttp://tiny
mce.moxiec
ode.com',
|
17 |
|
infourl
: 'http://
wiki.moxie
code.com/i
ndex.php/T
inyMCE:Plu
gins/save'
,
|
|
32 |
|
info
url : 'htt
p://wiki.m
oxiecode.c
om/index.p
hp/TinyMCE
:Plugins/s
ave',
|
18 |
|
version
:
tiny
MCE
.majorVers
ion
+
"."
+
tiny
MCE
.minorVers
ion
|
|
33 |
|
version
:
tiny
mce
.majorVers
ion
+
"."
+
tiny
mce
.minorVers
ion
|
19 |
|
};
|
|
34 |
|
};
|
20 |
|
},
|
|
35 |
|
},
|
21 |
|
|
|
36 |
|
|
22 |
|
initIn
stance : f
unction(in
st) {
|
|
37 |
|
//
Private m
ethods
|
23 |
|
in
st.addShor
tcut('ctrl
', 's', 'l
ang_save_d
esc', 'mce
Save');
|
|
|
24 |
|
},
|
|
|
25 |
|
|
|
38 |
|
|
26 |
|
/**
|
|
39 |
|
_nod
e
C
ha
n
ge
:
function(
ed,
c
m,
n)
{
|
27 |
|
* Ret
urns the H
TML conten
ts of the
save contr
ol.
|
|
40 |
|
var ed =
this.edit
or;
|
28 |
|
*/
|
|
|
29 |
|
g
e
t
C
o
n
trolHTML
:
function(
c
n)
{
|
|
|
30 |
|
sw
itch (cn)
{
|
|
|
31 |
|
case "sa
ve":
|
|
|
32 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_save_
desc', '{$
pluginurl}
/images/sa
ve.gif', '
mceSave');
|
|
|
33 |
|
|
|
41 |
|
|
34 |
|
case "ca
ncel":
|
|
42 |
|
if (ed.g
etParam('s
ave_enable
whendirty'
)) {
|
35 |
|
retu
rn tinyMCE
.getButton
HTML(cn, '
lang_cance
l_desc', '
{$pluginur
l}/images/
cancel.gif
', 'mceCan
cel');
|
|
43 |
|
cm.s
etDisabled
('save', !
ed.isDirty
());
|
|
|
44 |
|
cm.s
etDisabled
('cancel',
!ed.isDir
ty());
|
36 |
|
}
|
|
45 |
|
}
|
37 |
|
|
|
|
38 |
|
re
turn "";
|
|
|
39 |
|
},
|
|
46 |
|
},
|
40 |
|
|
|
47 |
|
|
41 |
|
/**
|
|
48 |
|
//
Private m
ethods
|
42 |
|
* Exe
cutes the
save comma
nd.
|
|
|
43 |
|
*/
|
|
|
44 |
|
execCo
mmand : fu
nction(edi
tor_id, el
ement, com
mand, user
_interface
, value) {
|
|
|
45 |
|
//
Handle co
mmands
|
|
|
46 |
|
sw
itch (comm
and) {
|
|
|
47 |
|
case "mc
eSave":
|
|
|
48 |
|
retu
rn this._s
ave(editor
_id, eleme
nt, comman
d, user_in
terface, v
alue);
|
|
|
49 |
|
|
|
49 |
|
|
50 |
|
case "mc
eCancel":
|
|
50 |
|
_s
ave : func
tion() {
|
51 |
|
retu
rn this._c
ancel(edit
or_id, ele
ment, comm
and, user_
interface,
value);
|
|
51 |
|
var
ed
=
th
i
s
.edi
t
or
,
formObj,
os,
i,
elementId;
|
52 |
|
}
|
|
|
53 |
|
|
|
|
54 |
|
//
Pass to n
ext handle
r in chain
|
|
|
55 |
|
re
turn false
;
|
|
|
56 |
|
},
|
|
|
57 |
|
|
|
|
58 |
|
_save
: function
(editor_id
, element,
command,
user_inter
face, valu
e) {
|
|
|
59 |
|
var
i
n
s
t
,
formObj,
os,
i,
elementId;
|
|
|
60 |
|
|
|
|
61 |
|
if
(tinyMCE.
getParam("
fullscreen
_is_enable
d"))
|
|
|
62 |
|
return t
rue;
|
|
|
63 |
|
|
|
52 |
|
|
64 |
|
in
st = tinyM
CE.selecte
dInstance;
|
|
53 |
|
formObj
=
t
in
ymce.DOM.g
e
t
(ed.id)
.form
||
tiny
m
ce.DOM.get
Par
ent
(ed
.
id,
'
form
')
;
|
65 |
|
formObj
=
in
s
t
.form
Ele
m
ent
.
form
;
|
|
|
66 |
|
|
|
54 |
|
|
67 |
|
if
(
tinyMCE
.getParam(
"save_enab
lewhendirt
y")
&&
!
inst
.isDirty()
)
|
|
55 |
|
if
(
ed
.getParam(
"save_enab
lewhendirt
y")
&&
!
ed
.isDirty()
)
|
68 |
|
return t
rue;
|
|
56 |
|
retu
rn true;
|
69 |
|
|
|
57 |
|
|
70 |
|
if
(formObj)
{
|
|
|
71 |
|
tinyMCE.
triggerSav
e();
|
|
58 |
|
tinyMCE.
triggerSav
e();
|
72 |
|
|
|
59 |
|
|
73 |
|
// Use c
allback in
stead
|
|
60 |
|
// Use c
allback in
stead
|
74 |
|
if
(
(
os
=
tinyMCE
.getParam(
"save_onsa
vecallback
"))
)
{
|
|
61 |
|
if
(
os
=
ed
.getParam(
"save_onsa
vecallback
"))
{
|
75 |
|
if (
eval(os +
'(inst);')
) {
|
|
62 |
|
if (
ed.execCal
lback('sav
e_onsaveca
llback', e
d)) {
|
76 |
|
inst
.startCont
ent
=
tiny
MCE
.trim(
inst
.get
B
o
dy().in
n
e
r
HTML
);
|
|
63 |
|
ed
.startCont
ent
=
tiny
mce
.trim(
ed
.get
C
o
n
t
e
nt({fo
r
mat
:
'raw'})
);
|
77 |
|
/*inst.und
oLevels =
new Array(
);
|
|
64 |
|
ed.nodeCha
nged();
|
78 |
|
inst.undoI
ndex = 0;
|
|
|
79 |
|
inst.typin
gUndoIndex
= -1;
|
|
|
80 |
|
inst.undoR
edo = true
;
|
|
|
81 |
|
inst.undoL
evels[inst
.undoLevel
s.length]
= inst.sta
rtContent;
*/
|
|
|
82 |
|
tinyMCE.tr
iggerNodeC
hange(fals
e, true);
|
|
|
83 |
|
}
|
|
|
84 |
|
|
|
|
85 |
|
retu
rn true;
|
|
|
86 |
|
}
|
|
65 |
|
}
|
87 |
|
|
|
66 |
|
|
88 |
|
// Disab
le all UI
form eleme
nts that T
inyMCE cre
ated
|
|
67 |
|
retu
rn;
|
89 |
|
for (i=0
; i<formOb
j.elements
.length; i
++) {
|
|
|
90 |
|
elem
entId = fo
rmObj.elem
ents[i].na
me ? formO
bj.element
s[i].name
: formObj.
elements[i
].id;
|
|
|
91 |
|
|
|
|
92 |
|
if (
elementId.
indexOf('m
ce_editor_
') == 0)
|
|
|
93 |
|
formObj.el
ements[i].
disabled =
true;
|
|
|
94 |
|
}
|
|
68 |
|
}
|
95 |
|
|
|
69 |
|
|
96 |
|
inst
.isNotDirt
y
=
true;
|
|
70 |
|
if (form
Obj) {
|
|
|
71 |
|
ed
.isNotDirt
y
=
true;
|
97 |
|
|
|
72 |
|
|
98 |
|
if (form
Obj.onsubm
it == null
|| formOb
j.onsubmit
() != fals
e)
|
|
73 |
|
if (
formObj.on
submit ==
null || fo
rmObj.onsu
bmit() !=
false)
|
99 |
|
inst.formE
lement.
form
.submit();
|
|
74 |
|
form
Obj
.submit();
|
100 |
|
|
|
75 |
|
|
101 |
|
tinyMCE.
triggerNod
eChange(fa
lse, true)
;
|
|
76 |
|
ed.n
odeChanged
();
|
102 |
|
}
else
|
|
77 |
|
} else
|
103 |
|
alert("Err
or:
No
form
element
found.");
|
|
78 |
|
ed.windowM
anager.
alert("Err
or:
No
form
element
found.");
|
104 |
|
|
|
79 |
|
|
105 |
|
re
turn true;
|
|
80 |
|
return t
rue;
|
106 |
|
},
|
|
81 |
|
},
|
107 |
|
|
|
82 |
|
|
108 |
|
_cance
l : functi
on(editor_
id, elemen
t, command
, user_int
erface, va
lue) {
|
|
83 |
|
_c
ancel : fu
nction() {
|
109 |
|
var
inst
=
t
i
nyMCE.getI
n
s
tanceById(
editor
_id)
,
os,
h
=
tiny
MCE
.trim(
inst
.startCont
ent);
|
|
84 |
|
var
ed
=
t
h
i
s
.
editor
,
os,
h
=
tiny
mce
.trim(
ed
.startCont
ent);
|
110 |
|
|
|
85 |
|
|
111 |
|
//
Use callb
ack instea
d
|
|
86 |
|
// Use c
allback in
stead
|
112 |
|
if
(
(
os
=
tinyMCE
.getParam(
"save_onca
ncelcallba
ck"))
)
{
|
|
87 |
|
if
(
os
=
ed
.getParam(
"save_onca
ncelcallba
ck"))
{
|
113 |
|
if (eval
(os + '(in
st);'))
|
|
88 |
|
ed.e
xecCallbac
k('save_on
cancelcall
back', ed)
;
|
114 |
|
return
true
;
|
|
89 |
|
return
;
|
115 |
|
}
|
|
90 |
|
}
|
116 |
|
|
|
91 |
|
|
117 |
|
in
st.setHTML
(h);
|
|
92 |
|
ed
.
setC
ontent
(
h
);
|
118 |
|
|
|
93 |
|
ed.undoM
anager.cle
ar();
|
119 |
|
in
st.undoRed
o.undoLeve
ls = [];
|
|
94 |
|
ed.nodeC
hanged();
|
120 |
|
inst.undoR
ed
o
.
add({
c
ontent
:
h
}
);
|
|
|
121 |
|
in
st.undoRed
o.undoInde
x = 0;
|
|
|
122 |
|
in
st.undoRed
o.typingUn
doIndex =
-1;
|
|
|
123 |
|
|
|
|
124 |
|
ti
nyMCE.trig
gerNodeCha
nge(false,
true);
|
|
|
125 |
|
|
|
|
126 |
|
re
turn true;
|
|
|
127 |
|
},
|
|
|
128 |
|
|
|
|
129 |
|
handle
NodeChange
: functio
n(editor_i
d, node, u
ndo_index,
undo_leve
ls, visual
_aid, any_
selection)
{
|
|
|
130 |
|
va
r inst;
|
|
|
131 |
|
|
|
|
132 |
|
if
(tinyMCE.
getParam("
fullscreen
_is_enable
d")) {
|
|
|
133 |
|
tinyMCE.
switchClas
s(editor_i
d + '_save
', 'mceBut
tonDisable
d');
|
|
|
134 |
|
return t
rue;
|
|
|
135 |
|
}
|
|
95 |
|
}
|
|
|
96 |
|
});
|
136 |
|
|
|
97 |
|
|
137 |
|
if
(tinyMCE.
getParam("
save_enabl
ewhendirty
")) {
|
|
98 |
|
// Reg
ister plug
in
|
138 |
|
inst = t
inyMCE.get
InstanceBy
Id(editor_
id);
|
|
99 |
|
tiny
mce
.
Plugin
Manager.ad
d
(
'
save
'
,
t
iny
mc
e
.p
lugin
s.Save
);
|
139 |
|
|
|
100 |
|
})();
|
140 |
|
if (inst
.isDirty()
) {
|
|
|
141 |
|
tiny
MCE.switch
Class(edit
or_id + '_
save', 'mc
eButtonNor
mal');
|
|
|
142 |
|
retu
rn true;
|
|
|
143 |
|
}
|
|
|
144 |
|
|
|
|
145 |
|
tinyMCE.
switchClas
s(editor_i
d + '_save
', 'mceBut
tonDisable
d');
|
|
|
146 |
|
}
|
|
|
147 |
|
|
|
|
148 |
|
re
turn true;
|
|
|
149 |
|
}
|
|
|
150 |
|
};
|
|
|
151 |
|
|
|
|
152 |
|
tiny
MCE
.
add
Plugin
(
"
save
"
,
T
iny
MCE_Sav
e
P
lugin
);
|
|
|