annotate static/js/tiny_mce/plugins/inlinepopups/editor_plugin_src.js @ 348:d1b11096595b

Fix #168; when nailing a spammer, clear their profile text fields. Guard against topics and forums that don't exist when deleting posts in the signal handler. Make the forum stats template tag only display the latest active users.
author Brian Neal <bgneal@gmail.com>
date Wed, 02 Mar 2011 02:18:28 +0000
parents 88b2b9cb8c1f
children 6c182ceb7147
rev   line source
bgneal@312 1 /**
bgneal@312 2 * editor_plugin_src.js
bgneal@312 3 *
bgneal@312 4 * Copyright 2009, Moxiecode Systems AB
bgneal@312 5 * Released under LGPL License.
bgneal@312 6 *
bgneal@312 7 * License: http://tinymce.moxiecode.com/license
bgneal@312 8 * Contributing: http://tinymce.moxiecode.com/contributing
bgneal@312 9 */
bgneal@312 10
bgneal@312 11 (function() {
bgneal@312 12 var DOM = tinymce.DOM, Element = tinymce.dom.Element, Event = tinymce.dom.Event, each = tinymce.each, is = tinymce.is;
bgneal@312 13
bgneal@312 14 tinymce.create('tinymce.plugins.InlinePopups', {
bgneal@312 15 init : function(ed, url) {
bgneal@312 16 // Replace window manager
bgneal@312 17 ed.onBeforeRenderUI.add(function() {
bgneal@312 18 ed.windowManager = new tinymce.InlineWindowManager(ed);
bgneal@312 19 DOM.loadCSS(url + '/skins/' + (ed.settings.inlinepopups_skin || 'clearlooks2') + "/window.css");
bgneal@312 20 });
bgneal@312 21 },
bgneal@312 22
bgneal@312 23 getInfo : function() {
bgneal@312 24 return {
bgneal@312 25 longname : 'InlinePopups',
bgneal@312 26 author : 'Moxiecode Systems AB',
bgneal@312 27 authorurl : 'http://tinymce.moxiecode.com',
bgneal@312 28 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/inlinepopups',
bgneal@312 29 version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@312 30 };
bgneal@312 31 }
bgneal@312 32 });
bgneal@312 33
bgneal@312 34 tinymce.create('tinymce.InlineWindowManager:tinymce.WindowManager', {
bgneal@312 35 InlineWindowManager : function(ed) {
bgneal@312 36 var t = this;
bgneal@312 37
bgneal@312 38 t.parent(ed);
bgneal@312 39 t.zIndex = 300000;
bgneal@312 40 t.count = 0;
bgneal@312 41 t.windows = {};
bgneal@312 42 },
bgneal@312 43
bgneal@312 44 open : function(f, p) {
bgneal@312 45 var t = this, id, opt = '', ed = t.editor, dw = 0, dh = 0, vp, po, mdf, clf, we, w, u;
bgneal@312 46
bgneal@312 47 f = f || {};
bgneal@312 48 p = p || {};
bgneal@312 49
bgneal@312 50 // Run native windows
bgneal@312 51 if (!f.inline)
bgneal@312 52 return t.parent(f, p);
bgneal@312 53
bgneal@312 54 // Only store selection if the type is a normal window
bgneal@312 55 if (!f.type)
bgneal@312 56 t.bookmark = ed.selection.getBookmark(1);
bgneal@312 57
bgneal@312 58 id = DOM.uniqueId();
bgneal@312 59 vp = DOM.getViewPort();
bgneal@312 60 f.width = parseInt(f.width || 320);
bgneal@312 61 f.height = parseInt(f.height || 240) + (tinymce.isIE ? 8 : 0);
bgneal@312 62 f.min_width = parseInt(f.min_width || 150);
bgneal@312 63 f.min_height = parseInt(f.min_height || 100);
bgneal@312 64 f.max_width = parseInt(f.max_width || 2000);
bgneal@312 65 f.max_height = parseInt(f.max_height || 2000);
bgneal@312 66 f.left = f.left || Math.round(Math.max(vp.x, vp.x + (vp.w / 2.0) - (f.width / 2.0)));
bgneal@312 67 f.top = f.top || Math.round(Math.max(vp.y, vp.y + (vp.h / 2.0) - (f.height / 2.0)));
bgneal@312 68 f.movable = f.resizable = true;
bgneal@312 69 p.mce_width = f.width;
bgneal@312 70 p.mce_height = f.height;
bgneal@312 71 p.mce_inline = true;
bgneal@312 72 p.mce_window_id = id;
bgneal@312 73 p.mce_auto_focus = f.auto_focus;
bgneal@312 74
bgneal@312 75 // Transpose
bgneal@312 76 // po = DOM.getPos(ed.getContainer());
bgneal@312 77 // f.left -= po.x;
bgneal@312 78 // f.top -= po.y;
bgneal@312 79
bgneal@312 80 t.features = f;
bgneal@312 81 t.params = p;
bgneal@312 82 t.onOpen.dispatch(t, f, p);
bgneal@312 83
bgneal@312 84 if (f.type) {
bgneal@312 85 opt += ' mceModal';
bgneal@312 86
bgneal@312 87 if (f.type)
bgneal@312 88 opt += ' mce' + f.type.substring(0, 1).toUpperCase() + f.type.substring(1);
bgneal@312 89
bgneal@312 90 f.resizable = false;
bgneal@312 91 }
bgneal@312 92
bgneal@312 93 if (f.statusbar)
bgneal@312 94 opt += ' mceStatusbar';
bgneal@312 95
bgneal@312 96 if (f.resizable)
bgneal@312 97 opt += ' mceResizable';
bgneal@312 98
bgneal@312 99 if (f.minimizable)
bgneal@312 100 opt += ' mceMinimizable';
bgneal@312 101
bgneal@312 102 if (f.maximizable)
bgneal@312 103 opt += ' mceMaximizable';
bgneal@312 104
bgneal@312 105 if (f.movable)
bgneal@312 106 opt += ' mceMovable';
bgneal@312 107
bgneal@312 108 // Create DOM objects
bgneal@312 109 t._addAll(DOM.doc.body,
bgneal@312 110 ['div', {id : id, 'class' : ed.settings.inlinepopups_skin || 'clearlooks2', style : 'width:100px;height:100px'},
bgneal@312 111 ['div', {id : id + '_wrapper', 'class' : 'mceWrapper' + opt},
bgneal@312 112 ['div', {id : id + '_top', 'class' : 'mceTop'},
bgneal@312 113 ['div', {'class' : 'mceLeft'}],
bgneal@312 114 ['div', {'class' : 'mceCenter'}],
bgneal@312 115 ['div', {'class' : 'mceRight'}],
bgneal@312 116 ['span', {id : id + '_title'}, f.title || '']
bgneal@312 117 ],
bgneal@312 118
bgneal@312 119 ['div', {id : id + '_middle', 'class' : 'mceMiddle'},
bgneal@312 120 ['div', {id : id + '_left', 'class' : 'mceLeft'}],
bgneal@312 121 ['span', {id : id + '_content'}],
bgneal@312 122 ['div', {id : id + '_right', 'class' : 'mceRight'}]
bgneal@312 123 ],
bgneal@312 124
bgneal@312 125 ['div', {id : id + '_bottom', 'class' : 'mceBottom'},
bgneal@312 126 ['div', {'class' : 'mceLeft'}],
bgneal@312 127 ['div', {'class' : 'mceCenter'}],
bgneal@312 128 ['div', {'class' : 'mceRight'}],
bgneal@312 129 ['span', {id : id + '_status'}, 'Content']
bgneal@312 130 ],
bgneal@312 131
bgneal@312 132 ['a', {'class' : 'mceMove', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 133 ['a', {'class' : 'mceMin', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],
bgneal@312 134 ['a', {'class' : 'mceMax', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],
bgneal@312 135 ['a', {'class' : 'mceMed', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],
bgneal@312 136 ['a', {'class' : 'mceClose', tabindex : '-1', href : 'javascript:;', onmousedown : 'return false;'}],
bgneal@312 137 ['a', {id : id + '_resize_n', 'class' : 'mceResize mceResizeN', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 138 ['a', {id : id + '_resize_s', 'class' : 'mceResize mceResizeS', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 139 ['a', {id : id + '_resize_w', 'class' : 'mceResize mceResizeW', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 140 ['a', {id : id + '_resize_e', 'class' : 'mceResize mceResizeE', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 141 ['a', {id : id + '_resize_nw', 'class' : 'mceResize mceResizeNW', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 142 ['a', {id : id + '_resize_ne', 'class' : 'mceResize mceResizeNE', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 143 ['a', {id : id + '_resize_sw', 'class' : 'mceResize mceResizeSW', tabindex : '-1', href : 'javascript:;'}],
bgneal@312 144 ['a', {id : id + '_resize_se', 'class' : 'mceResize mceResizeSE', tabindex : '-1', href : 'javascript:;'}]
bgneal@312 145 ]
bgneal@312 146 ]
bgneal@312 147 );
bgneal@312 148
bgneal@312 149 DOM.setStyles(id, {top : -10000, left : -10000});
bgneal@312 150
bgneal@312 151 // Fix gecko rendering bug, where the editors iframe messed with window contents
bgneal@312 152 if (tinymce.isGecko)
bgneal@312 153 DOM.setStyle(id, 'overflow', 'auto');
bgneal@312 154
bgneal@312 155 // Measure borders
bgneal@312 156 if (!f.type) {
bgneal@312 157 dw += DOM.get(id + '_left').clientWidth;
bgneal@312 158 dw += DOM.get(id + '_right').clientWidth;
bgneal@312 159 dh += DOM.get(id + '_top').clientHeight;
bgneal@312 160 dh += DOM.get(id + '_bottom').clientHeight;
bgneal@312 161 }
bgneal@312 162
bgneal@312 163 // Resize window
bgneal@312 164 DOM.setStyles(id, {top : f.top, left : f.left, width : f.width + dw, height : f.height + dh});
bgneal@312 165
bgneal@312 166 u = f.url || f.file;
bgneal@312 167 if (u) {
bgneal@312 168 if (tinymce.relaxedDomain)
bgneal@312 169 u += (u.indexOf('?') == -1 ? '?' : '&') + 'mce_rdomain=' + tinymce.relaxedDomain;
bgneal@312 170
bgneal@312 171 u = tinymce._addVer(u);
bgneal@312 172 }
bgneal@312 173
bgneal@312 174 if (!f.type) {
bgneal@312 175 DOM.add(id + '_content', 'iframe', {id : id + '_ifr', src : 'javascript:""', frameBorder : 0, style : 'border:0;width:10px;height:10px'});
bgneal@312 176 DOM.setStyles(id + '_ifr', {width : f.width, height : f.height});
bgneal@312 177 DOM.setAttrib(id + '_ifr', 'src', u);
bgneal@312 178 } else {
bgneal@312 179 DOM.add(id + '_wrapper', 'a', {id : id + '_ok', 'class' : 'mceButton mceOk', href : 'javascript:;', onmousedown : 'return false;'}, 'Ok');
bgneal@312 180
bgneal@312 181 if (f.type == 'confirm')
bgneal@312 182 DOM.add(id + '_wrapper', 'a', {'class' : 'mceButton mceCancel', href : 'javascript:;', onmousedown : 'return false;'}, 'Cancel');
bgneal@312 183
bgneal@312 184 DOM.add(id + '_middle', 'div', {'class' : 'mceIcon'});
bgneal@312 185 DOM.setHTML(id + '_content', f.content.replace('\n', '<br />'));
bgneal@312 186 }
bgneal@312 187
bgneal@312 188 // Register events
bgneal@312 189 mdf = Event.add(id, 'mousedown', function(e) {
bgneal@312 190 var n = e.target, w, vp;
bgneal@312 191
bgneal@312 192 w = t.windows[id];
bgneal@312 193 t.focus(id);
bgneal@312 194
bgneal@312 195 if (n.nodeName == 'A' || n.nodeName == 'a') {
bgneal@312 196 if (n.className == 'mceMax') {
bgneal@312 197 w.oldPos = w.element.getXY();
bgneal@312 198 w.oldSize = w.element.getSize();
bgneal@312 199
bgneal@312 200 vp = DOM.getViewPort();
bgneal@312 201
bgneal@312 202 // Reduce viewport size to avoid scrollbars
bgneal@312 203 vp.w -= 2;
bgneal@312 204 vp.h -= 2;
bgneal@312 205
bgneal@312 206 w.element.moveTo(vp.x, vp.y);
bgneal@312 207 w.element.resizeTo(vp.w, vp.h);
bgneal@312 208 DOM.setStyles(id + '_ifr', {width : vp.w - w.deltaWidth, height : vp.h - w.deltaHeight});
bgneal@312 209 DOM.addClass(id + '_wrapper', 'mceMaximized');
bgneal@312 210 } else if (n.className == 'mceMed') {
bgneal@312 211 // Reset to old size
bgneal@312 212 w.element.moveTo(w.oldPos.x, w.oldPos.y);
bgneal@312 213 w.element.resizeTo(w.oldSize.w, w.oldSize.h);
bgneal@312 214 w.iframeElement.resizeTo(w.oldSize.w - w.deltaWidth, w.oldSize.h - w.deltaHeight);
bgneal@312 215
bgneal@312 216 DOM.removeClass(id + '_wrapper', 'mceMaximized');
bgneal@312 217 } else if (n.className == 'mceMove')
bgneal@312 218 return t._startDrag(id, e, n.className);
bgneal@312 219 else if (DOM.hasClass(n, 'mceResize'))
bgneal@312 220 return t._startDrag(id, e, n.className.substring(13));
bgneal@312 221 }
bgneal@312 222 });
bgneal@312 223
bgneal@312 224 clf = Event.add(id, 'click', function(e) {
bgneal@312 225 var n = e.target;
bgneal@312 226
bgneal@312 227 t.focus(id);
bgneal@312 228
bgneal@312 229 if (n.nodeName == 'A' || n.nodeName == 'a') {
bgneal@312 230 switch (n.className) {
bgneal@312 231 case 'mceClose':
bgneal@312 232 t.close(null, id);
bgneal@312 233 return Event.cancel(e);
bgneal@312 234
bgneal@312 235 case 'mceButton mceOk':
bgneal@312 236 case 'mceButton mceCancel':
bgneal@312 237 f.button_func(n.className == 'mceButton mceOk');
bgneal@312 238 return Event.cancel(e);
bgneal@312 239 }
bgneal@312 240 }
bgneal@312 241 });
bgneal@312 242
bgneal@312 243 // Add window
bgneal@312 244 w = t.windows[id] = {
bgneal@312 245 id : id,
bgneal@312 246 mousedown_func : mdf,
bgneal@312 247 click_func : clf,
bgneal@312 248 element : new Element(id, {blocker : 1, container : ed.getContainer()}),
bgneal@312 249 iframeElement : new Element(id + '_ifr'),
bgneal@312 250 features : f,
bgneal@312 251 deltaWidth : dw,
bgneal@312 252 deltaHeight : dh
bgneal@312 253 };
bgneal@312 254
bgneal@312 255 w.iframeElement.on('focus', function() {
bgneal@312 256 t.focus(id);
bgneal@312 257 });
bgneal@312 258
bgneal@312 259 // Setup blocker
bgneal@312 260 if (t.count == 0 && t.editor.getParam('dialog_type', 'modal') == 'modal') {
bgneal@312 261 DOM.add(DOM.doc.body, 'div', {
bgneal@312 262 id : 'mceModalBlocker',
bgneal@312 263 'class' : (t.editor.settings.inlinepopups_skin || 'clearlooks2') + '_modalBlocker',
bgneal@312 264 style : {zIndex : t.zIndex - 1}
bgneal@312 265 });
bgneal@312 266
bgneal@312 267 DOM.show('mceModalBlocker'); // Reduces flicker in IE
bgneal@312 268 } else
bgneal@312 269 DOM.setStyle('mceModalBlocker', 'z-index', t.zIndex - 1);
bgneal@312 270
bgneal@312 271 if (tinymce.isIE6 || /Firefox\/2\./.test(navigator.userAgent) || (tinymce.isIE && !DOM.boxModel))
bgneal@312 272 DOM.setStyles('mceModalBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2});
bgneal@312 273
bgneal@312 274 t.focus(id);
bgneal@312 275 t._fixIELayout(id, 1);
bgneal@312 276
bgneal@312 277 // Focus ok button
bgneal@312 278 if (DOM.get(id + '_ok'))
bgneal@312 279 DOM.get(id + '_ok').focus();
bgneal@312 280
bgneal@312 281 t.count++;
bgneal@312 282
bgneal@312 283 return w;
bgneal@312 284 },
bgneal@312 285
bgneal@312 286 focus : function(id) {
bgneal@312 287 var t = this, w;
bgneal@312 288
bgneal@312 289 if (w = t.windows[id]) {
bgneal@312 290 w.zIndex = this.zIndex++;
bgneal@312 291 w.element.setStyle('zIndex', w.zIndex);
bgneal@312 292 w.element.update();
bgneal@312 293
bgneal@312 294 id = id + '_wrapper';
bgneal@312 295 DOM.removeClass(t.lastId, 'mceFocus');
bgneal@312 296 DOM.addClass(id, 'mceFocus');
bgneal@312 297 t.lastId = id;
bgneal@312 298 }
bgneal@312 299 },
bgneal@312 300
bgneal@312 301 _addAll : function(te, ne) {
bgneal@312 302 var i, n, t = this, dom = tinymce.DOM;
bgneal@312 303
bgneal@312 304 if (is(ne, 'string'))
bgneal@312 305 te.appendChild(dom.doc.createTextNode(ne));
bgneal@312 306 else if (ne.length) {
bgneal@312 307 te = te.appendChild(dom.create(ne[0], ne[1]));
bgneal@312 308
bgneal@312 309 for (i=2; i<ne.length; i++)
bgneal@312 310 t._addAll(te, ne[i]);
bgneal@312 311 }
bgneal@312 312 },
bgneal@312 313
bgneal@312 314 _startDrag : function(id, se, ac) {
bgneal@312 315 var t = this, mu, mm, d = DOM.doc, eb, w = t.windows[id], we = w.element, sp = we.getXY(), p, sz, ph, cp, vp, sx, sy, sex, sey, dx, dy, dw, dh;
bgneal@312 316
bgneal@312 317 // Get positons and sizes
bgneal@312 318 // cp = DOM.getPos(t.editor.getContainer());
bgneal@312 319 cp = {x : 0, y : 0};
bgneal@312 320 vp = DOM.getViewPort();
bgneal@312 321
bgneal@312 322 // Reduce viewport size to avoid scrollbars while dragging
bgneal@312 323 vp.w -= 2;
bgneal@312 324 vp.h -= 2;
bgneal@312 325
bgneal@312 326 sex = se.screenX;
bgneal@312 327 sey = se.screenY;
bgneal@312 328 dx = dy = dw = dh = 0;
bgneal@312 329
bgneal@312 330 // Handle mouse up
bgneal@312 331 mu = Event.add(d, 'mouseup', function(e) {
bgneal@312 332 Event.remove(d, 'mouseup', mu);
bgneal@312 333 Event.remove(d, 'mousemove', mm);
bgneal@312 334
bgneal@312 335 if (eb)
bgneal@312 336 eb.remove();
bgneal@312 337
bgneal@312 338 we.moveBy(dx, dy);
bgneal@312 339 we.resizeBy(dw, dh);
bgneal@312 340 sz = we.getSize();
bgneal@312 341 DOM.setStyles(id + '_ifr', {width : sz.w - w.deltaWidth, height : sz.h - w.deltaHeight});
bgneal@312 342 t._fixIELayout(id, 1);
bgneal@312 343
bgneal@312 344 return Event.cancel(e);
bgneal@312 345 });
bgneal@312 346
bgneal@312 347 if (ac != 'Move')
bgneal@312 348 startMove();
bgneal@312 349
bgneal@312 350 function startMove() {
bgneal@312 351 if (eb)
bgneal@312 352 return;
bgneal@312 353
bgneal@312 354 t._fixIELayout(id, 0);
bgneal@312 355
bgneal@312 356 // Setup event blocker
bgneal@312 357 DOM.add(d.body, 'div', {
bgneal@312 358 id : 'mceEventBlocker',
bgneal@312 359 'class' : 'mceEventBlocker ' + (t.editor.settings.inlinepopups_skin || 'clearlooks2'),
bgneal@312 360 style : {zIndex : t.zIndex + 1}
bgneal@312 361 });
bgneal@312 362
bgneal@312 363 if (tinymce.isIE6 || (tinymce.isIE && !DOM.boxModel))
bgneal@312 364 DOM.setStyles('mceEventBlocker', {position : 'absolute', left : vp.x, top : vp.y, width : vp.w - 2, height : vp.h - 2});
bgneal@312 365
bgneal@312 366 eb = new Element('mceEventBlocker');
bgneal@312 367 eb.update();
bgneal@312 368
bgneal@312 369 // Setup placeholder
bgneal@312 370 p = we.getXY();
bgneal@312 371 sz = we.getSize();
bgneal@312 372 sx = cp.x + p.x - vp.x;
bgneal@312 373 sy = cp.y + p.y - vp.y;
bgneal@312 374 DOM.add(eb.get(), 'div', {id : 'mcePlaceHolder', 'class' : 'mcePlaceHolder', style : {left : sx, top : sy, width : sz.w, height : sz.h}});
bgneal@312 375 ph = new Element('mcePlaceHolder');
bgneal@312 376 };
bgneal@312 377
bgneal@312 378 // Handle mouse move/drag
bgneal@312 379 mm = Event.add(d, 'mousemove', function(e) {
bgneal@312 380 var x, y, v;
bgneal@312 381
bgneal@312 382 startMove();
bgneal@312 383
bgneal@312 384 x = e.screenX - sex;
bgneal@312 385 y = e.screenY - sey;
bgneal@312 386
bgneal@312 387 switch (ac) {
bgneal@312 388 case 'ResizeW':
bgneal@312 389 dx = x;
bgneal@312 390 dw = 0 - x;
bgneal@312 391 break;
bgneal@312 392
bgneal@312 393 case 'ResizeE':
bgneal@312 394 dw = x;
bgneal@312 395 break;
bgneal@312 396
bgneal@312 397 case 'ResizeN':
bgneal@312 398 case 'ResizeNW':
bgneal@312 399 case 'ResizeNE':
bgneal@312 400 if (ac == "ResizeNW") {
bgneal@312 401 dx = x;
bgneal@312 402 dw = 0 - x;
bgneal@312 403 } else if (ac == "ResizeNE")
bgneal@312 404 dw = x;
bgneal@312 405
bgneal@312 406 dy = y;
bgneal@312 407 dh = 0 - y;
bgneal@312 408 break;
bgneal@312 409
bgneal@312 410 case 'ResizeS':
bgneal@312 411 case 'ResizeSW':
bgneal@312 412 case 'ResizeSE':
bgneal@312 413 if (ac == "ResizeSW") {
bgneal@312 414 dx = x;
bgneal@312 415 dw = 0 - x;
bgneal@312 416 } else if (ac == "ResizeSE")
bgneal@312 417 dw = x;
bgneal@312 418
bgneal@312 419 dh = y;
bgneal@312 420 break;
bgneal@312 421
bgneal@312 422 case 'mceMove':
bgneal@312 423 dx = x;
bgneal@312 424 dy = y;
bgneal@312 425 break;
bgneal@312 426 }
bgneal@312 427
bgneal@312 428 // Boundary check
bgneal@312 429 if (dw < (v = w.features.min_width - sz.w)) {
bgneal@312 430 if (dx !== 0)
bgneal@312 431 dx += dw - v;
bgneal@312 432
bgneal@312 433 dw = v;
bgneal@312 434 }
bgneal@312 435
bgneal@312 436 if (dh < (v = w.features.min_height - sz.h)) {
bgneal@312 437 if (dy !== 0)
bgneal@312 438 dy += dh - v;
bgneal@312 439
bgneal@312 440 dh = v;
bgneal@312 441 }
bgneal@312 442
bgneal@312 443 dw = Math.min(dw, w.features.max_width - sz.w);
bgneal@312 444 dh = Math.min(dh, w.features.max_height - sz.h);
bgneal@312 445 dx = Math.max(dx, vp.x - (sx + vp.x));
bgneal@312 446 dy = Math.max(dy, vp.y - (sy + vp.y));
bgneal@312 447 dx = Math.min(dx, (vp.w + vp.x) - (sx + sz.w + vp.x));
bgneal@312 448 dy = Math.min(dy, (vp.h + vp.y) - (sy + sz.h + vp.y));
bgneal@312 449
bgneal@312 450 // Move if needed
bgneal@312 451 if (dx + dy !== 0) {
bgneal@312 452 if (sx + dx < 0)
bgneal@312 453 dx = 0;
bgneal@312 454
bgneal@312 455 if (sy + dy < 0)
bgneal@312 456 dy = 0;
bgneal@312 457
bgneal@312 458 ph.moveTo(sx + dx, sy + dy);
bgneal@312 459 }
bgneal@312 460
bgneal@312 461 // Resize if needed
bgneal@312 462 if (dw + dh !== 0)
bgneal@312 463 ph.resizeTo(sz.w + dw, sz.h + dh);
bgneal@312 464
bgneal@312 465 return Event.cancel(e);
bgneal@312 466 });
bgneal@312 467
bgneal@312 468 return Event.cancel(se);
bgneal@312 469 },
bgneal@312 470
bgneal@312 471 resizeBy : function(dw, dh, id) {
bgneal@312 472 var w = this.windows[id];
bgneal@312 473
bgneal@312 474 if (w) {
bgneal@312 475 w.element.resizeBy(dw, dh);
bgneal@312 476 w.iframeElement.resizeBy(dw, dh);
bgneal@312 477 }
bgneal@312 478 },
bgneal@312 479
bgneal@312 480 close : function(win, id) {
bgneal@312 481 var t = this, w, d = DOM.doc, ix = 0, fw, id;
bgneal@312 482
bgneal@312 483 id = t._findId(id || win);
bgneal@312 484
bgneal@312 485 // Probably not inline
bgneal@312 486 if (!t.windows[id]) {
bgneal@312 487 t.parent(win);
bgneal@312 488 return;
bgneal@312 489 }
bgneal@312 490
bgneal@312 491 t.count--;
bgneal@312 492
bgneal@312 493 if (t.count == 0)
bgneal@312 494 DOM.remove('mceModalBlocker');
bgneal@312 495
bgneal@312 496 if (w = t.windows[id]) {
bgneal@312 497 t.onClose.dispatch(t);
bgneal@312 498 Event.remove(d, 'mousedown', w.mousedownFunc);
bgneal@312 499 Event.remove(d, 'click', w.clickFunc);
bgneal@312 500 Event.clear(id);
bgneal@312 501 Event.clear(id + '_ifr');
bgneal@312 502
bgneal@312 503 DOM.setAttrib(id + '_ifr', 'src', 'javascript:""'); // Prevent leak
bgneal@312 504 w.element.remove();
bgneal@312 505 delete t.windows[id];
bgneal@312 506
bgneal@312 507 // Find front most window and focus that
bgneal@312 508 each (t.windows, function(w) {
bgneal@312 509 if (w.zIndex > ix) {
bgneal@312 510 fw = w;
bgneal@312 511 ix = w.zIndex;
bgneal@312 512 }
bgneal@312 513 });
bgneal@312 514
bgneal@312 515 if (fw)
bgneal@312 516 t.focus(fw.id);
bgneal@312 517 }
bgneal@312 518 },
bgneal@312 519
bgneal@312 520 setTitle : function(w, ti) {
bgneal@312 521 var e;
bgneal@312 522
bgneal@312 523 w = this._findId(w);
bgneal@312 524
bgneal@312 525 if (e = DOM.get(w + '_title'))
bgneal@312 526 e.innerHTML = DOM.encode(ti);
bgneal@312 527 },
bgneal@312 528
bgneal@312 529 alert : function(txt, cb, s) {
bgneal@312 530 var t = this, w;
bgneal@312 531
bgneal@312 532 w = t.open({
bgneal@312 533 title : t,
bgneal@312 534 type : 'alert',
bgneal@312 535 button_func : function(s) {
bgneal@312 536 if (cb)
bgneal@312 537 cb.call(s || t, s);
bgneal@312 538
bgneal@312 539 t.close(null, w.id);
bgneal@312 540 },
bgneal@312 541 content : DOM.encode(t.editor.getLang(txt, txt)),
bgneal@312 542 inline : 1,
bgneal@312 543 width : 400,
bgneal@312 544 height : 130
bgneal@312 545 });
bgneal@312 546 },
bgneal@312 547
bgneal@312 548 confirm : function(txt, cb, s) {
bgneal@312 549 var t = this, w;
bgneal@312 550
bgneal@312 551 w = t.open({
bgneal@312 552 title : t,
bgneal@312 553 type : 'confirm',
bgneal@312 554 button_func : function(s) {
bgneal@312 555 if (cb)
bgneal@312 556 cb.call(s || t, s);
bgneal@312 557
bgneal@312 558 t.close(null, w.id);
bgneal@312 559 },
bgneal@312 560 content : DOM.encode(t.editor.getLang(txt, txt)),
bgneal@312 561 inline : 1,
bgneal@312 562 width : 400,
bgneal@312 563 height : 130
bgneal@312 564 });
bgneal@312 565 },
bgneal@312 566
bgneal@312 567 // Internal functions
bgneal@312 568
bgneal@312 569 _findId : function(w) {
bgneal@312 570 var t = this;
bgneal@312 571
bgneal@312 572 if (typeof(w) == 'string')
bgneal@312 573 return w;
bgneal@312 574
bgneal@312 575 each(t.windows, function(wo) {
bgneal@312 576 var ifr = DOM.get(wo.id + '_ifr');
bgneal@312 577
bgneal@312 578 if (ifr && w == ifr.contentWindow) {
bgneal@312 579 w = wo.id;
bgneal@312 580 return false;
bgneal@312 581 }
bgneal@312 582 });
bgneal@312 583
bgneal@312 584 return w;
bgneal@312 585 },
bgneal@312 586
bgneal@312 587 _fixIELayout : function(id, s) {
bgneal@312 588 var w, img;
bgneal@312 589
bgneal@312 590 if (!tinymce.isIE6)
bgneal@312 591 return;
bgneal@312 592
bgneal@312 593 // Fixes the bug where hover flickers and does odd things in IE6
bgneal@312 594 each(['n','s','w','e','nw','ne','sw','se'], function(v) {
bgneal@312 595 var e = DOM.get(id + '_resize_' + v);
bgneal@312 596
bgneal@312 597 DOM.setStyles(e, {
bgneal@312 598 width : s ? e.clientWidth : '',
bgneal@312 599 height : s ? e.clientHeight : '',
bgneal@312 600 cursor : DOM.getStyle(e, 'cursor', 1)
bgneal@312 601 });
bgneal@312 602
bgneal@312 603 DOM.setStyle(id + "_bottom", 'bottom', '-1px');
bgneal@312 604
bgneal@312 605 e = 0;
bgneal@312 606 });
bgneal@312 607
bgneal@312 608 // Fixes graphics glitch
bgneal@312 609 if (w = this.windows[id]) {
bgneal@312 610 // Fixes rendering bug after resize
bgneal@312 611 w.element.hide();
bgneal@312 612 w.element.show();
bgneal@312 613
bgneal@312 614 // Forced a repaint of the window
bgneal@312 615 //DOM.get(id).style.filter = '';
bgneal@312 616
bgneal@312 617 // IE has a bug where images used in CSS won't get loaded
bgneal@312 618 // sometimes when the cache in the browser is disabled
bgneal@312 619 // This fix tries to solve it by loading the images using the image object
bgneal@312 620 each(DOM.select('div,a', id), function(e, i) {
bgneal@312 621 if (e.currentStyle.backgroundImage != 'none') {
bgneal@312 622 img = new Image();
bgneal@312 623 img.src = e.currentStyle.backgroundImage.replace(/url\(\"(.+)\"\)/, '$1');
bgneal@312 624 }
bgneal@312 625 });
bgneal@312 626
bgneal@312 627 DOM.get(id).style.filter = '';
bgneal@312 628 }
bgneal@312 629 }
bgneal@312 630 });
bgneal@312 631
bgneal@312 632 // Register plugin
bgneal@312 633 tinymce.PluginManager.add('inlinepopups', tinymce.plugins.InlinePopups);
bgneal@312 634 })();
bgneal@312 635