3
Base plugin class for creating a JCE plugin object.
6
options - optional, an object containing options.
9
site - the base site url.
10
plugin - the plugin name
11
lang - the language code, eg: en.
12
params - parameter object.
15
var advlink = new Plugin('advlink', {params: {'key': 'value'}});
17
var Plugin = new Class({
24
getOptions : function(){
26
site : tinyMCEPopup.getParam('document_base_url'),
32
initialize : function(plugin, options){
33
this.setOptions(this.getOptions(), options);
34
this._plugin = plugin;
36
// fallback for no plugin set
38
var q = string.query(document.location.href);
39
this._plugin = q['plugin'];
41
// show any alert dialogs
43
// initialize tooltips
47
* Return site url option
48
* @param {String} The site url variable
51
return this.options.site;
54
* Store custom plugin parameters
55
* Example: {'animals': ['dog', 'cat', 'mouse']}
56
* @param {Object} The parameters object
58
setParams : function(p){
60
this.setParam(n, p[n]);
64
* Store a custom plugin parameter
65
* Example: 'animals', ['dog', 'cat', 'mouse']
66
* @param {string} The parameter key/name
67
* @param {string/array/object} The value
69
setParam : function(p, v){
70
this.options.params[p] = v;
73
* Return a custom plugin parameter
74
* @param {string} The parameter key/name
76
getParam : function(p){
77
return this.options.params[p] || false;
80
* Set the plugin as current
81
* @param {string} The plugin name
83
setPlugin : function(p){
87
* Return the current plugin
88
* @return {string} The plugin name
90
getPlugin : function(){
94
* Return a full resource url
95
* @param {string} The url type, eg: img, plugin
96
* @return {string} The url
98
getUrl : function( type ){
99
if( type == 'plugins' ){
100
type = 'tiny_mce/plugins/' + this.getPlugin();
102
return string.path(this.options.site, '/plugins/editors/jce/' + type);
105
* Return a full image url
106
* @param {string} The image name
107
* @return {string} The url
109
getImage : function(name){
110
var parts = name.split('.');
111
var path = parts[0].replace(/[^a-z0-9-_]/i, '');
112
var file = parts[1].replace(/[^a-z0-9-_]/i, '');
113
var ext = parts[2].replace(/[^a-z0-9-_]/i, '');
115
return this.getUrl(path) + '/img/' + file + '.' + ext;
118
* Resolve a TinyMCE language string
119
* @param {string} The variable name
120
* @param {string} The default translation
121
* @return {string} The language string
123
getLang : function(s, dv){
124
return tinyMCEPopup.getLang(s, dv);
127
* Loads a TinyMCE plugin or theme dialog language file. Requires asset.js
128
* @param {string} The variable name
129
* @param {string} The default translation
130
* @return {string} The language string
132
loadLanguage : function(name){
133
var path = '', parts = '', file = '';
135
parts = name.split('.');
136
path = parts[0].replace(/[^a-z0-9-_]/i, '');
137
file = parts[1].replace(/[^a-z0-9-_]/i, '');
138
path = path + '/' + file + '/';
140
var u = this.options.site + '/plugins/editors/jce/tiny_mce/' + path + 'langs/' + this.options.lang + '_dlg.js';
141
new Asset.javascript(u);
143
setVars: function(vars){
150
* Add a dialog object
151
* @param {String} The dialog name
152
* @param {String} The dialog object
154
addDialog : function(name, dialog){
155
this._dialog[name] = dialog;
158
* Get a dialog object
159
* @param {String} The dialog name
160
* @return the dialog object
162
getDialog : function(name){
163
return this._dialog[name] || '';
166
* Remove a dialog object
167
* Shortcut for closing a dialog too
168
* @param {String} The dialog name
170
removeDialog : function(name){
171
if(typeof this._dialog[name].close() != 'undefined'){
172
this._dialog[name].close();
174
delete this._dialog[name];
177
* Open help window for current language
179
openHelp : function(type){
180
if(!type) type = 'standard';
181
tinyMCE.activeEditor.windowManager.open({
182
url : this.options.site + 'index.php?option=com_jce&task=help&lang='+ this.options.lang +'&plugin='+ this._plugin +'&type='+ type +'&file=help',
187
close_previous : "no"
190
iframe : function(fn, cb){
194
onComplete: function(o){
198
r = o.result || {error: false};
209
* XHR request. Requires json.js
210
* @param {string} The target function to call
211
* @param {array} An array of arguments
212
* @param {function} The callback function on success
214
xhr : function(fn, args, cb){
215
new Json.Remote(document.location.href, {
216
onComplete: function(o){
220
r = o.result || {error: false};
227
onFailure: function(x){
228
alert('Request failed with status code: '+ x.status);
230
}).send({'fn': fn, 'args': args});
233
* Alerts. Requires window.js
235
showAlerts : function(){
236
var alerts = this.options.alerts || [];
238
var h = '<dl class="alert">';
239
alerts.each(function(a){
240
h += '<dt class="' + a['class'] + '">' + a['title'] + '</dt><dd>' + a['text'] + '</dd>';
243
new Alert(h, {height: 150 + alerts.length * 50});
246
initToolTip : function(elms){
247
this.tooltip = new Tips($$('.hastip'), {
248
className : 'tooltip',
250
offsets: {'x': 24, 'y': 24}
253
addToolTip : function(el){
254
if($type(el) != 'array'){
258
this.tooltip.build(e);
262
Plugin.implement(new Events, new Options);
263
/* IFrame class for pseudo ajax/json stuff */
264
var IFrame = new Class({
265
getOptions : function(){
271
onStart: Class.empty,
272
onComplete: Class.empty
275
initialize : function(options){
276
this.setOptions(this.getOptions(), options);
277
if (this.options.initialize) this.options.initialize.call(this);
279
if($(this.options.frame)){
280
$(this.options.frame).remove();
282
this.frame = new Element('iframe').setProperties({
283
'src': 'about:blank',
284
'name': this.options.frame,
285
'id': this.options.frame
286
}).setStyle('display', 'none').injectInside($E('form'))
289
window.frames[this.frame.id].name = this.frame.name;
291
this.options.form.setAttribute('target', this.frame.name);
293
this.action = this.options.form.action;
296
this.options.form.addEvent('submit', function(){
297
this.fireEvent('onStart');
300
this.frame.addEvent('load', function(){
301
var f = $(this.frame);
302
var el = f.contentWindow.document || f.contentDocument || window.frames[f.id].document;
303
if(el.location.href == 'about:blank') return;
304
var res = el.body.innerHTML;
306
this.fireEvent('onComplete', Json.evaluate(res, true));
311
if(this.options.auto){
312
this.options.form.submit();
315
setAction : function(){
317
if(this.options.action){
318
this.action += '&action=' + this.options.action;
320
this.options.form.setAttribute('action', this.action);
322
resetAction : function(){
323
this.action = this.action.replace(/&action=([^&]+)/i, '');
324
this.options.form.setAttribute('action', this.action);
327
IFrame.implement(new Options, new Events);
b'\\ No newline at end of file'