Changeset 4080
- Timestamp:
- 08/09/2006 07:39:17 PM (18 years ago)
- Location:
- trunk/wp-includes/js
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/dbx.js
r3695 r4080 1 // DBX2.0 2:: Docking Boxes (dbx)1 // DBX2.05 :: Docking Boxes (dbx) 2 2 // ***************************************************** 3 3 // DOM scripting by brothercake -- http://www.brothercake.com/ 4 4 // GNU Lesser General Public License -- http://www.gnu.org/licenses/lgpl.html 5 5 //****************************************************** 6 var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1'); if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.state+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className) && !/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.boxes.push(this.eles[i]);this.eles[i].className += ' dbx-box-open';this.eles[i].className += ' dbxid' + this.order.length;this.order.push(this.order.length.toString() + '+');this.eles[i][dbx.etype](dbx.eprefix + 'mousedown', function(e){if(!e) { e = window.event; }self.mousedown(e, dbx.getTarget(e, 'dbx\-box'));}, false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.eles[i].className += ' dbx-handle-cursor';this.eles[i].setAttribute('title', this.eles[i].getAttribute('title') == null || this.eles[i].title == '' ? this.vocab.move : this.vocab.syntax.replace('%mytitle%', this.eles[i].title).replace('%dbxtitle%', this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix + 'key' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press'), function(e){if(!e) { e = window.event; }return self.keypress(e, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'focus', function(e){if(!e) { e = window.event; }self.createTooltip(null, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'blur', function(){self.removeTooltip();}, false);}}}dbx.addDataMember(this.gid, this.order.join(','));var dummy = this.container.appendChild(dbx.createElement('span'));dummy.className = 'dbx-box dbx-dummy';dummy.style.display = 'block';dummy.style.width = '0';dummy.style.height = '0';dummy.style.overflow = 'hidden';if(this.vertical) { dummy.className += ' dbx-offdummy'; }this.boxes.push(dummy);if(dbx.cookiestate != null && typeof dbx.cookiestate[this.gid] != 'undefined'){var num = dbx.cookiestate[this.gid].length;if(num == this.boxes.length - 1){for(i=0; i<num; i++){var index = parseInt(dbx.cookiestate[this.gid][i], 10);this.container.insertBefore(this.boxes[index], dummy);if(this.toggles && /\-$/.test(dbx.cookiestate[this.gid][i])){this.toggleBoxState(this.buttons[index], false);}}this.getBoxOrder();}}else if(!this.defopen && this.toggles){var len = this.buttons.length;for(i=0; i<len; i++){this.toggleBoxState(this.buttons[i], true);}}document[dbx.etype](dbx.eprefix + 'mouseout', function(e){if(typeof e.target == 'undefined') { e = window.event; e.relatedTarget = e.toElement; }if(e.relatedTarget == null){self.mouseup(e);}}, false);document[dbx.etype](dbx.eprefix + 'mousemove', function(e){self.mousemove(e);return false;}, false);document[dbx.etype](dbx.eprefix + 'mouseup', function(e){self.mouseup(e);}, false);this.keydown = false;document[dbx.etype](dbx.eprefix + 'keydown', function(){self.keydown = true;}, false);document[dbx.etype](dbx.eprefix + 'keyup', function(){self.keydown = false;}, false);};dbxGroup.prototype.addToggleBehavior = function(){var self = this;var button = arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor = 'pointer';button.href = 'javascript:void(null)';button.className = 'dbx-toggle dbx-toggle-open';button.setAttribute('title', this.vocab.toggle.replace('%toggle%', this.vocab.close));button.hasfocus = typeof window.opera != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? null : false;this.tooltip = null;button.onclick = function(){if(this.hasfocus === true || this.hasfocus === null){self.removeTooltip();self.toggleBoxState(this, true);}};button['onkey' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press')] = function(e){if(!e) { e = window.event; }return self.keypress(e, this);};button.onfocus = function(){var len = self.buttons.length;for(var i=0; i<len; i++){self.buttons[i].className = self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');}var isopen = (/dbx\-toggle\-open/.test(this.className));this.className += ' dbx-toggle-hilite-' + (isopen ? 'open' : 'closed');self.createTooltip(isopen, this);this.isactive = true;if(this.hasfocus !== null) { this.hasfocus = true; }};button.onblur = function(){this.className = this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');self.removeTooltip();if(this.hasfocus !== null) { this.hasfocus = false; }};return button;};dbxGroup.prototype.toggleBoxState = function(button, regen){var isopen = (/dbx\-toggle\-open/.test(button.className));var parent = dbx.getTarget(null, 'dbx\-box', button);dbx.box = parent;dbx.toggle = button;if(typeof dbx.container == 'undefined'){dbx.group = dbx.getTarget(null, 'dbx\-group', parent);}else { dbx.group = dbx.container; }if((!isopen && (typeof dbx.onboxopen == 'undefined' || dbx.onboxopen()))||(isopen && (typeof dbx.onboxclose == 'undefined' || dbx.onboxclose()))){button.className = 'dbx-toggle dbx-toggle-' + (isopen ? 'closed' : 'open');button.title = this.vocab.toggle.replace('%toggle%', isopen ? this.vocab.open : this.vocab.close);if(typeof button.isactive != 'undefined'){button.className += ' dbx-toggle-hilite-' + (isopen ? 'closed' : 'open')}parent.className = parent.className.replace(/[ ](dbx-box-)(open|closed)/, ' $1' + (isopen ? 'closed' : 'open'));if(regen) { this.getBoxOrder(); }}};dbxGroup.prototype.shiftBoxPosition = function(e, anchor, positive){var parent = dbx.getTarget(null, 'dbx\-box', anchor);dbx.group = this.container;dbx.box = parent;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){var positions = [];var len = this.boxes.length;for(var i=0; i<len; i++){positions[i] = [i, this.boxes[i][this.vertical ? 'offsetTop' : 'offsetLeft']];if(parent == this.boxes[i]) { this.idref = i; }}positions.sort(this.compare);for(i=0; i<len; i++){if(positions[i][0] == this.idref){if((positive && i < len - 2) || (!positive && i > 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className) && !/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1] + (/dbx\-box\-open/i.test(this.eles[j].className) ? '+' : '-'));}}dbx.savedata[this.gid] = this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone = function(){var clone = this.container.appendChild(arguments[0].cloneNode(true));clone.className += ' dbx-clone';clone.style.position = 'absolute';clone.style.visibility = 'hidden';clone.style.zIndex = arguments[1];clone.style.left = arguments[2].x + 'px';clone.style.top = arguments[2].y + 'px';clone.style.width = arguments[0].offsetWidth + 'px';clone.style.height = arguments[0].offsetHeight + 'px';return clone;};dbxGroup.prototype.createCloneBox = function(box){this.box = box;this.position = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.difference = { 'x' : (this.initial.x - this.position.x), 'y' : (this.initial.y - this.position.y) };this.boxclone = this.createClone(this.box, 30000, this.position);this.boxclone.style.cursor = 'move';this.dragok = true;};dbxGroup.prototype.removeCloneBox = function(){this.container.removeChild(this.boxclone);this.box.style.visibility = 'visible';this.box = null;};dbxGroup.prototype.moveOriginalToPosition = function(clientX, clientY){var cloneprops = {'xy' : this.vertical ? clientY - this.difference.y : clientX - this.difference.x,'wh' : this.vertical ? this.boxclone.offsetHeight : this.boxclone.offsetWidth};this.box.style.visibility = 'hidden';this.boxclone.style.visibility = 'visible';var len = this.boxes.length;for(var i=0; i<len; i++){var boxprops = {'xy' : this.vertical ? this.boxes[i].offsetTop : this.boxes[i].offsetLeft,'wh' : this.vertical ? this.boxes[i].offsetHeight : this.boxes[i].offsetWidth};if((this.positive && cloneprops.xy + cloneprops.wh > boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on' + ev[j]] = null;}}});}6 var dbx;function dbxManager(sid){dbx = this;if(!/^[-_a-z0-9]+$/i.test(sid)) { alert('Error from dbxManager:\n"' + sid + '" is an invalid session ID'); return; }this.supported = !(document.getElementsByTagName('*').length == 0 || (navigator.vendor == 'KDE' && typeof window.sidebar == 'undefined'));if(!this.supported) { return; }this.etype = typeof document.addEventListener != 'undefined' ? 'addEventListener' : typeof document.attachEvent != 'undefined' ? 'attachEvent' : 'none';this.eprefix = (this.etype == 'attachEvent' ? 'on' : '');if(typeof window.opera != 'undefined' && parseFloat(navigator.userAgent.toLowerCase().split(/opera[\/ ]/)[1].split(' ')[0], 10) < 7.5){this.etype = 'none';}if(this.etype == 'none') { this.supported = false; return; }this.running = 0;this.sid = sid;this.savedata = {};this.cookiestate = this.getCookieState();};dbxManager.prototype.setCookieState = function(){var now = new Date();now.setTime(now.getTime() + (365*24*60*60*1000));var str = '';for(j in this.savedata){if(typeof this.savedata[j]!='function'){str += j + '=' + this.savedata[j] + '&'}}this.state = str.replace(/^(.+)&$/, '$1');this.cookiestring = this.state.replace(/,/g, '|');this.cookiestring = this.cookiestring.replace(/=/g, ':');if(typeof this.onstatechange == 'undefined' || this.onstatechange()){document.cookie = 'dbx-' + this.sid + '='+ this.cookiestring+ '; expires=' + now.toGMTString()+ '; path=/';}};dbxManager.prototype.getCookieState = function(){this.cookiestate = null;if(document.cookie){if(document.cookie.indexOf('dbx-' + this.sid)!=-1){this.cookie = document.cookie.split('dbx-' + this.sid + '=')[1].split(';')[0].split('&');for(var i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookie[i] = this.cookie[i].replace(/\|/g, ',');this.cookie[i]= this.cookie[i].replace(/:/g, '=');this.cookie[i] = this.cookie[i].split('=');this.cookie[i][1] = this.cookie[i][1].split(',');}}this.cookiestate = {};for(i in this.cookie){if(typeof this.cookie[i]!='function'){this.cookiestate[this.cookie[i][0]] = this.cookie[i][1];}}}}return this.cookiestate;};dbxManager.prototype.addDataMember = function(gid, order){this.savedata[gid] = order;};dbxManager.prototype.createElement = function(tag){return typeof document.createElementNS != 'undefined' ? document.createElementNS('http://www.w3.org/1999/xhtml', tag) : document.createElement(tag);};dbxManager.prototype.getTarget = function(e, pattern, node){if(typeof node != 'undefined'){var target = node;}else{target = typeof e.target != 'undefined' ? e.target : e.srcElement;}var regex = new RegExp(pattern, '');while(!regex.test(target.className)){target = target.parentNode;}return target;};function dbxGroup(gid, dir, thresh, fix, ani, togs, def, open, close, move, toggle, kmove, ktoggle, syntax){if(!/^[-_a-z0-9]+$/i.test(gid)) { alert('Error from dbxGroup:\n"' + gid + '" is an invalid container ID'); return; }this.container = document.getElementById(gid);if(this.container == null || !dbx.supported) { return; }var self = this;this.gid = gid;this.dragok = false;this.box = null;this.vertical = dir == 'vertical';this.threshold = parseInt(thresh, 10);this.restrict = fix == 'yes';this.resolution = parseInt(ani, 10);this.toggles = togs == 'yes';this.defopen = def != 'closed';this.vocab = {'open' : open,'close' : close,'move' : move,'toggle' : toggle,'kmove' : kmove,'ktoggle' : ktoggle,'syntax' : syntax};this.container.style.position = 'relative';this.container.style.display = 'block';if(typeof window.opera != 'undefined'){this.container.style.display = 'run-in';}this.boxes = [];this.buttons = [];this.order = [];this.eles = this.container.getElementsByTagName('*');for(var i=0; i<this.eles.length; i++){if(/dbx\-box/i.test(this.eles[i].className) && !/dbx\-dummy/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.boxes.push(this.eles[i]);this.eles[i].className += ' dbx-box-open';this.eles[i].className += ' dbxid' + this.order.length;this.order.push(this.order.length.toString() + '+');this.eles[i][dbx.etype](dbx.eprefix + 'mousedown', function(e){if(!e) { e = window.event; }self.mousedown(e, dbx.getTarget(e, 'dbx\-box'));}, false);}if(/dbx\-handle/i.test(this.eles[i].className)){this.eles[i].style.position = 'relative';this.eles[i].style.display = 'block';this.eles[i].className += ' dbx-handle-cursor';this.eles[i].setAttribute('title', this.eles[i].getAttribute('title') == null || this.eles[i].title == '' ? this.vocab.move : this.vocab.syntax.replace('%mytitle%', this.eles[i].title).replace('%dbxtitle%', this.vocab.move));if(this.toggles){this.buttons.push(this.addToggleBehavior(this.eles[i]));}else{this.eles[i][dbx.etype](dbx.eprefix + 'key' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press'), function(e){if(!e) { e = window.event; }return self.keypress(e, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'focus', function(e){if(!e) { e = window.event; }self.createTooltip(null, dbx.getTarget(e, 'dbx\-handle'));}, false);this.eles[i][dbx.etype](dbx.eprefix + 'blur', function(){self.removeTooltip();}, false);}}}dbx.addDataMember(this.gid, this.order.join(','));var dummy = this.container.appendChild(dbx.createElement('span'));dummy.className = 'dbx-box dbx-dummy';dummy.style.display = 'block';dummy.style.width = '0';dummy.style.height = '0';dummy.style.overflow = 'hidden';if(this.vertical) { dummy.className += ' dbx-offdummy'; }this.boxes.push(dummy);if(dbx.cookiestate != null && typeof dbx.cookiestate[this.gid] != 'undefined'){var num = dbx.cookiestate[this.gid].length;if(num == this.boxes.length - 1){for(i=0; i<num; i++){var index = parseInt(dbx.cookiestate[this.gid][i], 10);this.container.insertBefore(this.boxes[index], dummy);if(this.toggles && /\-$/.test(dbx.cookiestate[this.gid][i])){this.toggleBoxState(this.buttons[index], false);}}this.getBoxOrder();}}else if(!this.defopen && this.toggles){var len = this.buttons.length;for(i=0; i<len; i++){this.toggleBoxState(this.buttons[i], true);}}document[dbx.etype](dbx.eprefix + 'mouseout', function(e){if(typeof e.target == 'undefined') { e = window.event; e.relatedTarget = e.toElement; }if(e.relatedTarget == null){self.mouseup(e);}}, false);document[dbx.etype](dbx.eprefix + 'mousemove', function(e){self.mousemove(e);return !self.dragok;}, false);document[dbx.etype](dbx.eprefix + 'mouseup', function(e){self.mouseup(e);}, false);this.keydown = false;document[dbx.etype](dbx.eprefix + 'keydown', function(){self.keydown = true;}, false);document[dbx.etype](dbx.eprefix + 'keyup', function(){self.keydown = false;}, false);};dbxGroup.prototype.addToggleBehavior = function(){var self = this;var button = arguments[0].appendChild(dbx.createElement('a'));button.appendChild(document.createTextNode('\u00a0'));button.style.cursor = 'pointer';button.href = 'javascript:void(null)';button.className = 'dbx-toggle dbx-toggle-open';button.setAttribute('title', this.vocab.toggle.replace('%toggle%', this.vocab.close));button.hasfocus = typeof window.opera != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? null : false;this.tooltip = null;button.onclick = function(){if(this.hasfocus === true || this.hasfocus === null){self.removeTooltip();self.toggleBoxState(this, true);}};button['onkey' + (typeof document.uniqueID != 'undefined' || navigator.vendor == 'Apple Computer, Inc.' ? 'down' : 'press')] = function(e){if(!e) { e = window.event; }return self.keypress(e, this);};button.onfocus = function(){var len = self.buttons.length;for(var i=0; i<len; i++){self.buttons[i].className = self.buttons[i].className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');}var isopen = (/dbx\-toggle\-open/.test(this.className));this.className += ' dbx-toggle-hilite-' + (isopen ? 'open' : 'closed');self.createTooltip(isopen, this);this.isactive = true;if(this.hasfocus !== null) { this.hasfocus = true; }};button.onblur = function(){this.className = this.className.replace(/[ ](dbx\-toggle\-hilite\-)(open|closed)/, '');self.removeTooltip();if(this.hasfocus !== null) { this.hasfocus = false; }};return button;};dbxGroup.prototype.toggleBoxState = function(button, regen){var isopen = (/dbx\-toggle\-open/.test(button.className));var parent = dbx.getTarget(null, 'dbx\-box', button);dbx.box = parent;dbx.toggle = button;if(typeof dbx.container == 'undefined'){dbx.group = dbx.getTarget(null, 'dbx\-group', parent);}else { dbx.group = dbx.container; }if((!isopen && (typeof dbx.onboxopen == 'undefined' || dbx.onboxopen()))||(isopen && (typeof dbx.onboxclose == 'undefined' || dbx.onboxclose()))){button.className = 'dbx-toggle dbx-toggle-' + (isopen ? 'closed' : 'open');button.title = this.vocab.toggle.replace('%toggle%', isopen ? this.vocab.open : this.vocab.close);if(typeof button.isactive != 'undefined'){button.className += ' dbx-toggle-hilite-' + (isopen ? 'closed' : 'open')}parent.className = parent.className.replace(/[ ](dbx-box-)(open|closed)/, ' $1' + (isopen ? 'closed' : 'open'));if(regen) { this.getBoxOrder(); }}};dbxGroup.prototype.shiftBoxPosition = function(e, anchor, positive){var parent = dbx.getTarget(null, 'dbx\-box', anchor);dbx.group = this.container;dbx.box = parent;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){var positions = [];var len = this.boxes.length;for(var i=0; i<len; i++){positions[i] = [i, this.boxes[i][this.vertical ? 'offsetTop' : 'offsetLeft']];if(parent == this.boxes[i]) { this.idref = i; }}positions.sort(this.compare);for(i=0; i<len; i++){if(positions[i][0] == this.idref){if((positive && i < len - 2) || (!positive && i > 0)){var sibling = this.boxes[positions[i + (positive ? 1 : -1)][0]];if(this.resolution > 0){var visipos = { 'x' : parent.offsetLeft, 'y' : parent.offsetTop };var siblingpos = { 'x' : sibling.offsetLeft, 'y' : sibling.offsetTop };}var obj = { 'insert' : (positive ? sibling : parent), 'before' : (positive ? parent : sibling) };this.container.insertBefore(obj.insert, obj.before);if(this.resolution > 0){var animators ={'sibling' : new dbxAnimator(this, sibling, siblingpos, this.resolution, true, anchor),'parent' : new dbxAnimator(this, parent, visipos, this.resolution, true, anchor)};}else{anchor.focus();}break;}}}this.getBoxOrder();}};dbxGroup.prototype.compare = function(a, b){return a[1] - b[1];};dbxGroup.prototype.createTooltip = function(isopen, anchor){if(this.keydown){this.tooltip = this.container.appendChild(dbx.createElement('span'));this.tooltip.style.visibility = 'hidden';this.tooltip.className = 'dbx-tooltip';if(isopen != null){this.tooltip.appendChild(document.createTextNode(this.vocab.kmove + this.vocab.ktoggle.replace('%toggle%', isopen ? this.vocab.close : this.vocab.open)));}else{this.tooltip.appendChild(document.createTextNode(this.vocab.kmove));}var parent = dbx.getTarget(null, 'dbx\-box', anchor);this.tooltip.style.left = parent.offsetLeft + 'px';this.tooltip.style.top = parent.offsetTop + 'px';var tooltip = this.tooltip;window.setTimeout(function(){if(tooltip != null) { tooltip.style.visibility = 'visible'; }}, 500);}};dbxGroup.prototype.removeTooltip = function(){if(this.tooltip != null){this.tooltip.parentNode.removeChild(this.tooltip);this.tooltip = null;}};dbxGroup.prototype.mousedown = function(e, box){var node = typeof e.target != 'undefined' ? e.target : e.srcElement;if(node.nodeName == '#text') { node = node.parentNode; }if(!/dbx\-(toggle|box|group)/i.test(node.className)){while(!/dbx\-(handle|box|group)/i.test(node.className)){node = node.parentNode;}}if(/dbx\-handle/i.test(node.className)){this.removeTooltip();this.released = false;this.initial = { 'x' : e.clientX, 'y' : e.clientY };this.current = { 'x' : 0, 'y' : 0 };this.createCloneBox(box);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return false; }}}};dbxGroup.prototype.mousemove = function(e){if(this.dragok && this.box != null){this.positive = this.vertical ? (e.clientY > this.current.y ? true : false) : (e.clientX > this.current.x ? true : false);this.current = { 'x' : e.clientX, 'y' : e.clientY };var overall = { 'x' : this.current.x - this.initial.x, 'y' : this.current.y - this.initial.y };if(((overall.x >= 0 && overall.x <= this.threshold) || (overall.x <= 0 && overall.x >= 0 - this.threshold))&&((overall.y >= 0 && overall.y <= this.threshold) || (overall.y <= 0 && overall.y >= 0 - this.threshold))){this.current.x -= overall.x;this.current.y -= overall.y;}if(this.released || overall.x > this.threshold || overall.x < (0 - this.threshold) || overall.y > this.threshold || overall.y < (0 - this.threshold)){dbx.group = this.container;dbx.box = this.box;dbx.event = e;if(typeof dbx.onboxdrag == 'undefined' || dbx.onboxdrag()){this.released = true;if(!this.restrict || !this.vertical) { this.boxclone.style.left = (this.current.x - this.difference.x) + 'px'; }if(!this.restrict || this.vertical) { this.boxclone.style.top = (this.current.y - this.difference.y) + 'px'; }this.moveOriginalToPosition(this.current.x, this.current.y);if(typeof e.preventDefault != 'undefined' ) { e.preventDefault(); }}}}return true;};dbxGroup.prototype.mouseup = function(e){if(this.box != null){this.moveOriginalToPosition(e.clientX, e.clientY);this.removeCloneBox();this.getBoxOrder();if(typeof document.onselectstart != 'undefined'){document.onselectstart = function() { return true; }}}this.dragok = false;};dbxGroup.prototype.keypress = function(e, anchor){if(/^(3[7-9])|(40)$/.test(e.keyCode)){this.removeTooltip();if((this.vertical && /^(38|40)$/.test(e.keyCode)) || (!this.vertical && /^(37|39)$/.test(e.keyCode))){this.shiftBoxPosition(e, anchor, /^[3][78]$/.test(e.keyCode) ? false : true);if(typeof e.preventDefault != 'undefined') { e.preventDefault(); }else { return false; }typeof e.stopPropagation != 'undefined' ? e.stopPropagation() : e.cancelBubble = true;this.keydown = false;}}return true;};dbxGroup.prototype.getBoxOrder = function(){this.order = [];var len = this.eles.length;for(var j=0; j<len; j++){if(/dbx\-box/i.test(this.eles[j].className) && !/dbx\-(clone|dummy)/i.test(this.eles[j].className)){this.order.push(this.eles[j].className.split('dbxid')[1] + (/dbx\-box\-open/i.test(this.eles[j].className) ? '+' : '-'));}}dbx.savedata[this.gid] = this.order.join(',');dbx.setCookieState();};dbxGroup.prototype.createClone = function(){var clone = this.container.appendChild(arguments[0].cloneNode(true));clone.className += ' dbx-clone';clone.style.position = 'absolute';clone.style.visibility = 'hidden';clone.style.zIndex = arguments[1];clone.style.left = arguments[2].x + 'px';clone.style.top = arguments[2].y + 'px';clone.style.width = arguments[0].offsetWidth + 'px';clone.style.height = arguments[0].offsetHeight + 'px';return clone;};dbxGroup.prototype.createCloneBox = function(box){this.box = box;this.position = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.difference = { 'x' : (this.initial.x - this.position.x), 'y' : (this.initial.y - this.position.y) };this.boxclone = this.createClone(this.box, 30000, this.position);this.boxclone.style.cursor = 'move';this.dragok = true;};dbxGroup.prototype.removeCloneBox = function(){this.container.removeChild(this.boxclone);this.box.style.visibility = 'visible';this.box = null;};dbxGroup.prototype.moveOriginalToPosition = function(clientX, clientY){var cloneprops = {'xy' : this.vertical ? clientY - this.difference.y : clientX - this.difference.x,'wh' : this.vertical ? this.boxclone.offsetHeight : this.boxclone.offsetWidth};this.box.style.visibility = 'hidden';this.boxclone.style.visibility = 'visible';var len = this.boxes.length;for(var i=0; i<len; i++){var boxprops = {'xy' : this.vertical ? this.boxes[i].offsetTop : this.boxes[i].offsetLeft,'wh' : this.vertical ? this.boxes[i].offsetHeight : this.boxes[i].offsetWidth};if((this.positive && cloneprops.xy + cloneprops.wh > boxprops.xy && cloneprops.xy < boxprops.xy)||(!this.positive && cloneprops.xy < boxprops.xy && cloneprops.xy + cloneprops.wh > boxprops.xy)){if(this.boxes[i] == this.box) { return; }var sibling = this.box.nextSibling;while(sibling.className == null || !/dbx\-box/.test(sibling.className)){sibling = sibling.nextSibling;}if(this.boxes[i] == sibling) { return; }if(this.resolution > 0){if(this.box[this.vertical ? 'offsetTop' : 'offsetLeft'] < boxprops.xy){var visibox = this.boxes[i].previousSibling;while(visibox.className == null || !/dbx\-box/.test(visibox.className)){visibox = visibox.previousSibling;}}else{visibox = this.boxes[i];}var visipos = { 'x' : visibox.offsetLeft, 'y' : visibox.offsetTop };}var prepos = { 'x' : this.box.offsetLeft, 'y' : this.box.offsetTop };this.container.insertBefore(this.box, this.boxes[i]);this.initial.x += (this.box.offsetLeft - prepos.x);this.initial.y += (this.box.offsetTop - prepos.y);if(this.resolution > 0 && visibox != this.box){var animator = new dbxAnimator(this, visibox, visipos, this.resolution, false, null);}else{}break;}}};function dbxAnimator(caller, box, pos, res, kbd, anchor){this.caller = caller;this.box = box;this.timer = null;var before = pos[this.caller.vertical ? 'y' : 'x'];var after = this.box[this.caller.vertical ? 'offsetTop' : 'offsetLeft'];if(before != after){if(dbx.running > this.caller.boxes.length - 1) { return; }var clone = this.caller.createClone(this.box, 29999, arguments[2]);clone.style.visibility = 'visible';this.box.style.visibility = 'hidden';this.animateClone(clone,before,after > before ? after - before : 0 - (before - after),this.caller.vertical ? 'top' : 'left',res,kbd,anchor);}};dbxAnimator.prototype.animateClone = function(clone, current, change, dir, res, kbd, anchor){var self = this;var count = 0;dbx.running ++;this.timer = window.setInterval(function(){count ++;current += change / res;clone.style[dir] = current + 'px';if(count == res){window.clearTimeout(self.timer);self.timer = null;dbx.running --;self.caller.container.removeChild(clone);self.box.style.visibility = 'visible';if(kbd){if(anchor != null && anchor.parentNode.style.visibility != 'hidden'){anchor.focus();}else if(self.caller.toggles){var button = self.caller.buttons[parseInt(self.box.className.split('dbxid')[1],10)];if(button != null && typeof button.isactive != 'undefined'){button.focus();}}}}}, 20);};if(typeof window.attachEvent != 'undefined'){window.attachEvent('onunload', function(){var ev = ['mousedown', 'mousemove', 'mouseup', 'mouseout', 'click', 'keydown', 'keyup', 'focus', 'blur', 'selectstart', 'statechange', 'boxdrag', 'boxopen', 'boxclose'];var el = ev.length;var dl = document.all.length;for(var i=0; i<dl; i++){for(var j=0; j<el; j++){document.all[i]['on' + ev[j]] = null;}}});} -
trunk/wp-includes/js/tinymce/plugins/directionality/editor_plugin.js
r3244 r4080 1 /** 2 * $RCSfile: editor_plugin_src.js,v $ 3 * $Revision: 1.16 $ 4 * $Date: 2006/02/10 21:34:28 $ 5 * 6 * @author Moxiecode 7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 8 */ 9 1 10 /* Import plugin specific language pack */ 2 tinyMCE.importPluginLanguagePack('directionality', 'en, sv,fr_ca,zh_cn,cs,da,he,no,de,hu,ru,ru_KOI8-R,ru_UTF-8,es,cy,is,pl');11 tinyMCE.importPluginLanguagePack('directionality', 'en,tr,sv,fr_ca,zh_cn,cs,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,es,cy,is,pl,nl,fr,pt_br'); 3 12 4 function TinyMCE_directionality_getInfo() { 5 return { 6 longname : 'Directionality', 7 author : 'Moxiecode Systems', 8 authorurl : 'http://tinymce.moxiecode.com', 9 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html', 10 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 11 }; 13 var TinyMCE_DirectionalityPlugin = { 14 getInfo : function() { 15 return { 16 longname : 'Directionality', 17 author : 'Moxiecode Systems', 18 authorurl : 'http://tinymce.moxiecode.com', 19 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_directionality.html', 20 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 21 }; 22 }, 23 24 getControlHTML : function(cn) { 25 switch (cn) { 26 case "ltr": 27 return tinyMCE.getButtonHTML(cn, 'lang_directionality_ltr_desc', '{$pluginurl}/images/ltr.gif', 'mceDirectionLTR'); 28 29 case "rtl": 30 return tinyMCE.getButtonHTML(cn, 'lang_directionality_rtl_desc', '{$pluginurl}/images/rtl.gif', 'mceDirectionRTL'); 31 } 32 33 return ""; 34 }, 35 36 execCommand : function(editor_id, element, command, user_interface, value) { 37 // Handle commands 38 switch (command) { 39 case "mceDirectionLTR": 40 var inst = tinyMCE.getInstanceById(editor_id); 41 var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 42 43 if (elm) 44 elm.setAttribute("dir", "ltr"); 45 46 tinyMCE.triggerNodeChange(false); 47 return true; 48 49 case "mceDirectionRTL": 50 var inst = tinyMCE.getInstanceById(editor_id); 51 var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 52 53 if (elm) 54 elm.setAttribute("dir", "rtl"); 55 56 tinyMCE.triggerNodeChange(false); 57 return true; 58 } 59 60 // Pass to next handler in chain 61 return false; 62 }, 63 64 handleNodeChange : function(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { 65 function getAttrib(elm, name) { 66 return elm.getAttribute(name) ? elm.getAttribute(name) : ""; 67 } 68 69 if (node == null) 70 return; 71 72 var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 73 if (!elm) { 74 tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonDisabled'); 75 tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonDisabled'); 76 return true; 77 } 78 79 tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonNormal'); 80 tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonNormal'); 81 82 var dir = getAttrib(elm, "dir"); 83 if (dir == "ltr" || dir == "") 84 tinyMCE.switchClass(editor_id + '_ltr', 'mceButtonSelected'); 85 else 86 tinyMCE.switchClass(editor_id + '_rtl', 'mceButtonSelected'); 87 88 return true; 89 } 12 90 }; 13 91 14 function TinyMCE_directionality_getControlHTML(control_name) { 15 switch (control_name) { 16 case "ltr": 17 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\');return false;'; 18 return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_ltr" src="{$pluginurl}/images/ltr.gif" title="{$lang_directionality_ltr_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>' 19 + '<div class="zerosize"><input type="button" accesskey="." onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionLTR\',false);" /></div>'; 20 21 case "rtl": 22 var cmd = 'tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\');return false;'; 23 return '<a href="javascript:' + cmd + '" onclick="' + cmd + '" target="_self" onmousedown="return false;"><img id="{$editor_id}_rtl" src="{$pluginurl}/images/rtl.gif" title="{$lang_directionality_rtl_desc}" width="20" height="20" class="mceButtonNormal" onmouseover="tinyMCE.switchClass(this,\'mceButtonOver\');" onmouseout="tinyMCE.restoreClass(this);" onmousedown="tinyMCE.restoreAndSwitchClass(this,\'mceButtonDown\');" /></a>' 24 + '<div class="zerosize"><input type="button" accesskey="," onclick="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'mceDirectionRTL\',false);" /></div>'; 25 } 26 27 return ""; 28 } 29 30 function TinyMCE_directionality_execCommand(editor_id, element, command, user_interface, value) { 31 // Handle commands 32 switch (command) { 33 case "mceDirectionLTR": 34 var inst = tinyMCE.getInstanceById(editor_id); 35 var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 36 37 if (elm) 38 elm.setAttribute("dir", "ltr"); 39 40 tinyMCE.triggerNodeChange(false); 41 return true; 42 43 case "mceDirectionRTL": 44 var inst = tinyMCE.getInstanceById(editor_id); 45 var elm = tinyMCE.getParentElement(inst.getFocusElement(), "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 46 47 if (elm) 48 elm.setAttribute("dir", "rtl"); 49 50 tinyMCE.triggerNodeChange(false); 51 return true; 52 } 53 54 // Pass to next handler in chain 55 return false; 56 } 57 58 function TinyMCE_directionality_handleNodeChange(editor_id, node, undo_index, undo_levels, visual_aid, any_selection) { 59 function getAttrib(elm, name) { 60 return elm.getAttribute(name) ? elm.getAttribute(name) : ""; 61 } 62 63 tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonNormal', false); 64 tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonNormal', false); 65 66 if (node == null) 67 return; 68 69 var elm = tinyMCE.getParentElement(node, "p,div,td,h1,h2,h3,h4,h5,h6,pre,address"); 70 if (!elm) { 71 tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonDisabled', true); 72 tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonDisabled', true); 73 return; 74 } 75 76 var dir = getAttrib(elm, "dir"); 77 if (dir == "ltr" || dir == "") 78 tinyMCE.switchClassSticky(editor_id + '_ltr', 'mceButtonSelected', false); 79 else 80 tinyMCE.switchClassSticky(editor_id + '_rtl', 'mceButtonSelected', false); 81 82 return true; 83 } 92 tinyMCE.addPlugin("directionality", TinyMCE_DirectionalityPlugin); -
trunk/wp-includes/js/tinymce/plugins/paste/editor_plugin.js
r3664 r4080 1 /** 2 * $RCSfile: editor_plugin_src.js,v $ 3 * $Revision: 1.36 $ 4 * $Date: 2006/03/20 12:03:44 $ 5 * 6 * @author Moxiecode 7 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved. 8 */ 9 10 /* Import plugin specific language pack */ 11 tinyMCE.importPluginLanguagePack('paste', 'en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br'); 12 13 var TinyMCE_PastePlugin = { 14 getInfo : function() { 15 return { 16 longname : 'Paste text/word', 17 author : 'Moxiecode Systems', 18 authorurl : 'http://tinymce.moxiecode.com', 19 infourl : 'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html', 20 version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion 21 }; 22 }, 23 24 initInstance : function(inst) { 25 if (tinyMCE.isMSIE && tinyMCE.getParam("paste_auto_cleanup_on_paste", false)) 26 tinyMCE.addEvent(inst.getBody(), "paste", TinyMCE_PastePlugin._handlePasteEvent); 27 }, 28 29 getControlHTML : function(cn) { 30 switch (cn) { 31 case "pastetext": 32 return tinyMCE.getButtonHTML(cn, 'lang_paste_text_desc', '{$pluginurl}/images/pastetext.gif', 'mcePasteText', true); 33 34 case "pasteword": 35 return tinyMCE.getButtonHTML(cn, 'lang_paste_word_desc', '{$pluginurl}/images/pasteword.gif', 'mcePasteWord', true); 36 37 case "selectall": 38 return tinyMCE.getButtonHTML(cn, 'lang_selectall_desc', '{$pluginurl}/images/selectall.gif', 'mceSelectAll', true); 39 } 40 41 return ''; 42 }, 43 44 execCommand : function(editor_id, element, command, user_interface, value) { 45 switch (command) { 46 case "mcePasteText": 47 if (user_interface) { 48 if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) 49 TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"), true); 50 else { 51 var template = new Array(); 52 template['file'] = '../../plugins/paste/pastetext.htm'; // Relative to theme 53 template['width'] = 450; 54 template['height'] = 400; 55 var plain_text = ""; 56 tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); 57 } 58 } else 59 TinyMCE_PastePlugin._insertText(value['html'], value['linebreaks']); 60 61 return true; 62 63 case "mcePasteWord": 64 if (user_interface) { 65 if ((tinyMCE.isMSIE && !tinyMCE.isOpera) && !tinyMCE.getParam('paste_use_dialog', false)) { 66 var html = TinyMCE_PastePlugin._clipboardHTML(); 67 68 if (html && html.length > 0) 69 TinyMCE_PastePlugin._insertWordContent(html); 70 } else { 71 var template = new Array(); 72 template['file'] = '../../plugins/paste/pasteword.htm'; // Relative to theme 73 template['width'] = 450; 74 template['height'] = 400; 75 var plain_text = ""; 76 tinyMCE.openWindow(template, {editor_id : editor_id, plain_text: plain_text, resizable : "yes", scrollbars : "no", inline : "yes", mceDo : 'insert'}); 77 } 78 } else 79 TinyMCE_PastePlugin._insertWordContent(value); 80 81 return true; 82 83 case "mceSelectAll": 84 tinyMCE.execInstanceCommand(editor_id, 'selectall'); 85 return true; 86 87 } 88 89 // Pass to next handler in chain 90 return false; 91 }, 92 93 // Private plugin internal methods 94 95 _handlePasteEvent : function(e) { 96 switch (e.type) { 97 case "paste": 98 var html = TinyMCE_PastePlugin._clipboardHTML(); 99 var r, inst = tinyMCE.selectedInstance; 100 101 // Removes italic, strong etc, the if was needed due to bug #1437114 102 if (inst && (r = inst.getRng()) && r.text.length > 0) 103 tinyMCE.execCommand('delete'); 104 105 if (html && html.length > 0) 106 tinyMCE.execCommand('mcePasteWord', false, html); 107 108 tinyMCE.cancelEvent(e); 109 return false; 110 } 111 112 return true; 113 }, 114 115 _insertText : function(content, bLinebreaks) { 116 if (content && content.length > 0) { 117 if (bLinebreaks) { 118 // Special paragraph treatment 119 if (tinyMCE.getParam("paste_create_paragraphs", true)) { 120 var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); 121 for (var i=0; i<rl.length; i+=2) 122 content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]); 123 124 content = tinyMCE.regexpReplace(content, "\r\n\r\n", "</p><p>", "gi"); 125 content = tinyMCE.regexpReplace(content, "\r\r", "</p><p>", "gi"); 126 content = tinyMCE.regexpReplace(content, "\n\n", "</p><p>", "gi"); 127 128 // Has paragraphs 129 if ((pos = content.indexOf('</p><p>')) != -1) { 130 tinyMCE.execCommand("Delete"); 131 132 var node = tinyMCE.selectedInstance.getFocusElement(); 133 134 // Get list of elements to break 135 var breakElms = new Array(); 136 137 do { 138 if (node.nodeType == 1) { 139 // Don't break tables and break at body 140 if (node.nodeName == "TD" || node.nodeName == "BODY") 141 break; 142 143 breakElms[breakElms.length] = node; 144 } 145 } while(node = node.parentNode); 146 147 var before = "", after = "</p>"; 148 before += content.substring(0, pos); 149 150 for (var i=0; i<breakElms.length; i++) { 151 before += "</" + breakElms[i].nodeName + ">"; 152 after += "<" + breakElms[(breakElms.length-1)-i].nodeName + ">"; 153 } 154 155 before += "<p>"; 156 content = before + content.substring(pos+7) + after; 157 } 158 } 159 160 if (tinyMCE.getParam("paste_create_linebreaks", true)) { 161 content = tinyMCE.regexpReplace(content, "\r\n", "<br />", "gi"); 162 content = tinyMCE.regexpReplace(content, "\r", "<br />", "gi"); 163 content = tinyMCE.regexpReplace(content, "\n", "<br />", "gi"); 164 } 165 } 166 167 tinyMCE.execCommand("mceInsertRawHTML", false, content); 168 } 169 }, 170 171 _insertWordContent : function(content) { 172 if (content && content.length > 0) { 173 // Cleanup Word content 174 var bull = String.fromCharCode(8226); 175 var middot = String.fromCharCode(183); 176 var cb; 177 178 if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") 179 content = eval(cb + "('before', content)"); 180 181 var rl = tinyMCE.getParam("paste_replace_list", '\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(','); 182 for (var i=0; i<rl.length; i+=2) 183 content = content.replace(new RegExp(rl[i], 'gi'), rl[i+1]); 184 185 if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) { 186 content = content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>', 'gi'), '<p><b>$1</b></p>'); 187 } 188 189 content = content.replace(new RegExp('tab-stops: list [0-9]+.0pt">', 'gi'), '">' + "--list--"); 190 content = content.replace(new RegExp(bull + "(.*?)<BR>", "gi"), "<p>" + middot + "$1</p>"); 191 content = content.replace(new RegExp('<SPAN style="mso-list: Ignore">', 'gi'), "<span>" + bull); // Covert to bull list 192 content = content.replace(/<o:p><\/o:p>/gi, ""); 193 content = content.replace(new RegExp('<br style="page-break-before: always;.*>', 'gi'), '-- page break --'); // Replace pagebreaks 194 content = content.replace(new RegExp('<(!--)([^>]*)(--)>', 'g'), ""); // Word comments 195 196 if (tinyMCE.getParam("paste_remove_spans", true)) 197 content = content.replace(/<\/?span[^>]*>/gi, ""); 198 199 if (tinyMCE.getParam("paste_remove_styles", true)) 200 content = content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)', 'gi'), "<$1$3"); 201 202 content = content.replace(/<\/?font[^>]*>/gi, ""); 203 204 // Strips class attributes. 205 switch (tinyMCE.getParam("paste_strip_class_attributes", "all")) { 206 case "all": 207 content = content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi, "<$1$3"); 208 break; 209 210 case "mso": 211 content = content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)', 'gi'), "<$1$3"); 212 break; 213 } 214 215 content = content.replace(new RegExp('href="?' + TinyMCE_PastePlugin._reEscape("" + document.location) + '', 'gi'), 'href="' + tinyMCE.settings['document_base_url']); 216 content = content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi, "<$1$3"); 217 content = content.replace(/<\\?\?xml[^>]*>/gi, ""); 218 content = content.replace(/<\/?\w+:[^>]*>/gi, ""); 219 content = content.replace(/-- page break --\s*<p> <\/p>/gi, ""); // Remove pagebreaks 220 content = content.replace(/-- page break --/gi, ""); // Remove pagebreaks 221 222 // content = content.replace(/\/? */gi, ""); 223 // content = content.replace(/<p> <\/p>/gi, ''); 224 225 if (!tinyMCE.settings['force_p_newlines']) { 226 content = content.replace('', '' ,'gi'); 227 content = content.replace('</p>', '<br /><br />' ,'gi'); 228 } 229 230 if (!tinyMCE.isMSIE && !tinyMCE.settings['force_p_newlines']) { 231 content = content.replace(/<\/?p[^>]*>/gi, ""); 232 } 233 234 content = content.replace(/<\/?div[^>]*>/gi, ""); 235 236 // Convert all middlot lists to UL lists 237 if (tinyMCE.getParam("paste_convert_middot_lists", true)) { 238 var div = document.createElement("div"); 239 div.innerHTML = content; 240 241 // Convert all middot paragraphs to li elements 242 var className = tinyMCE.getParam("paste_unindented_list_class", "unIndentedList"); 243 244 while (TinyMCE_PastePlugin._convertMiddots(div, "--list--")) ; // bull 245 while (TinyMCE_PastePlugin._convertMiddots(div, middot, className)) ; // Middot 246 while (TinyMCE_PastePlugin._convertMiddots(div, bull)) ; // bull 247 248 content = div.innerHTML; 249 } 250 251 // Replace all headers with strong and fix some other issues 252 if (tinyMCE.getParam("paste_convert_headers_to_strong", false)) { 253 content = content.replace(/<h[1-6]> <\/h[1-6]>/gi, '<p> </p>'); 254 content = content.replace(/<h[1-6]>/gi, '<p><b>'); 255 content = content.replace(/<\/h[1-6]>/gi, '</b></p>'); 256 content = content.replace(/<b> <\/b>/gi, '<b> </b>'); 257 content = content.replace(/^( )*/gi, ''); 258 } 259 260 content = content.replace(/--list--/gi, ""); // Remove --list-- 261 262 if ((cb = tinyMCE.getParam("paste_insert_word_content_callback", "")) != "") 263 content = eval(cb + "('after', content)"); 264 265 // Insert cleaned content 266 tinyMCE.execCommand("mceInsertContent", false, content); 267 window.setTimeout('tinyMCE.execCommand("mceCleanup");', 1); // Do normal cleanup detached from this thread 268 } 269 }, 270 271 _reEscape : function(s) { 272 var l = "?.\\*[](){}+^$:"; 273 var o = ""; 274 275 for (var i=0; i<s.length; i++) { 276 var c = s.charAt(i); 277 278 if (l.indexOf(c) != -1) 279 o += '\\' + c; 280 else 281 o += c; 282 } 283 284 return o; 285 }, 286 287 _convertMiddots : function(div, search, class_name) { 288 var mdot = String.fromCharCode(183); 289 var bull = String.fromCharCode(8226); 290 291 var nodes = div.getElementsByTagName("p"); 292 var prevul; 293 for (var i=0; i<nodes.length; i++) { 294 var p = nodes[i]; 295 296 // Is middot 297 if (p.innerHTML.indexOf(search) == 0) { 298 var ul = document.createElement("ul"); 299 300 if (class_name) 301 ul.className = class_name; 302 303 // Add the first one 304 var li = document.createElement("li"); 305 li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); 306 ul.appendChild(li); 307 308 // Add the rest 309 var np = p.nextSibling; 310 while (np) { 311 // If the node is whitespace, then 312 // ignore it and continue on. 313 if (np.nodeType == 3 && /^\s$/m.test(np.nodeValue)) { 314 np = np.nextSibling; 315 continue; 316 } 317 318 if (search == mdot) { 319 if (np.nodeType == 1 && /^o(\s+| )/.test(np.innerHTML)) { 320 // Second level of nesting 321 if (!prevul) { 322 prevul = ul; 323 ul = document.createElement("ul"); 324 prevul.appendChild(ul); 325 } 326 np.innerHTML = np.innerHTML.replace(/^o/, ''); 327 } else { 328 // Pop the stack if we're going back up to the first level 329 if (prevul) { 330 ul = prevul; 331 prevul = null; 332 } 333 // Not element or middot paragraph 334 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0) 335 break; 336 } 337 } else { 338 // Not element or middot paragraph 339 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0) 340 break; 341 } 342 343 var cp = np.nextSibling; 344 var li = document.createElement("li"); 345 li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); 346 np.parentNode.removeChild(np); 347 ul.appendChild(li); 348 np = cp; 349 } 350 351 p.parentNode.replaceChild(ul, p); 352 353 return true; 354 } 355 } 356 357 return false; 358 }, 359 360 _clipboardHTML : function() { 361 var div = document.getElementById('_TinyMCE_clipboardHTML'); 362 363 if (!div) { 364 var div = document.createElement('DIV'); 365 div.id = '_TinyMCE_clipboardHTML'; 366 367 with (div.style) { 368 visibility = 'hidden'; 369 overflow = 'hidden'; 370 position = 'absolute'; 371 width = 1; 372 height = 1; 373 } 374 375 document.body.appendChild(div); 376 } 377 378 div.innerHTML = ''; 379 var rng = document.body.createTextRange(); 380 rng.moveToElementText(div); 381 rng.execCommand('Paste'); 382 var html = div.innerHTML; 383 div.innerHTML = ''; 384 return html; 385 } 386 }; 387 388 tinyMCE.addPlugin("paste", TinyMCE_PastePlugin); 1 tinyMCE.importPluginLanguagePack('paste','en,tr,sv,cs,zh_cn,fr_ca,da,he,nb,de,hu,ru,ru_KOI8-R,ru_UTF-8,nn,fi,es,cy,is,pl,nl,fr,pt_br');var TinyMCE_PastePlugin={getInfo:function(){return{longname:'Paste text/word',author:'Moxiecode Systems',authorurl:'http://tinymce.moxiecode.com',infourl:'http://tinymce.moxiecode.com/tinymce/docs/plugin_paste.html',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};},initInstance:function(inst){if(tinyMCE.isMSIE&&tinyMCE.getParam("paste_auto_cleanup_on_paste",false))tinyMCE.addEvent(inst.getBody(),"paste",TinyMCE_PastePlugin._handlePasteEvent);},getControlHTML:function(cn){switch(cn){case"pastetext":return tinyMCE.getButtonHTML(cn,'lang_paste_text_desc','{$pluginurl}/images/pastetext.gif','mcePasteText',true);case"pasteword":return tinyMCE.getButtonHTML(cn,'lang_paste_word_desc','{$pluginurl}/images/pasteword.gif','mcePasteWord',true);case"selectall":return tinyMCE.getButtonHTML(cn,'lang_selectall_desc','{$pluginurl}/images/selectall.gif','mceSelectAll',true);}return'';},execCommand:function(editor_id,element,command,user_interface,value){switch(command){case"mcePasteText":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false))TinyMCE_PastePlugin._insertText(clipboardData.getData("Text"),true);else{var template=new Array();template['file']='../../plugins/paste/pastetext.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertText(value['html'],value['linebreaks']);return true;case"mcePasteWord":if(user_interface){if((tinyMCE.isMSIE&&!tinyMCE.isOpera)&&!tinyMCE.getParam('paste_use_dialog',false)){var html=TinyMCE_PastePlugin._clipboardHTML();if(html&&html.length>0)TinyMCE_PastePlugin._insertWordContent(html);}else{var template=new Array();template['file']='../../plugins/paste/pasteword.htm';template['width']=450;template['height']=400;var plain_text="";tinyMCE.openWindow(template,{editor_id:editor_id,plain_text:plain_text,resizable:"yes",scrollbars:"no",inline:"yes",mceDo:'insert'});}}else TinyMCE_PastePlugin._insertWordContent(value);return true;case"mceSelectAll":tinyMCE.execInstanceCommand(editor_id,'selectall');return true;}return false;},_handlePasteEvent:function(e){switch(e.type){case"paste":var html=TinyMCE_PastePlugin._clipboardHTML();var r,inst=tinyMCE.selectedInstance;if(inst&&(r=inst.getRng())&&r.text.length>0)tinyMCE.execCommand('delete');if(html&&html.length>0)tinyMCE.execCommand('mcePasteWord',false,html);tinyMCE.cancelEvent(e);return false;}return true;},_insertText:function(content,bLinebreaks){if(content&&content.length>0){if(bLinebreaks){if(tinyMCE.getParam("paste_create_paragraphs",true)){var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);content=tinyMCE.regexpReplace(content,"\r\n\r\n","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\r\r","</p><p>","gi");content=tinyMCE.regexpReplace(content,"\n\n","</p><p>","gi");if((pos=content.indexOf('</p><p>'))!=-1){tinyMCE.execCommand("Delete");var node=tinyMCE.selectedInstance.getFocusElement();var breakElms=new Array();do{if(node.nodeType==1){if(node.nodeName=="TD"||node.nodeName=="BODY")break;breakElms[breakElms.length]=node;}}while(node=node.parentNode);var before="",after="</p>";before+=content.substring(0,pos);for(var i=0;i<breakElms.length;i++){before+="</"+breakElms[i].nodeName+">";after+="<"+breakElms[(breakElms.length-1)-i].nodeName+">";}before+="<p>";content=before+content.substring(pos+7)+after;}}if(tinyMCE.getParam("paste_create_linebreaks",true)){content=tinyMCE.regexpReplace(content,"\r\n","<br />","gi");content=tinyMCE.regexpReplace(content,"\r","<br />","gi");content=tinyMCE.regexpReplace(content,"\n","<br />","gi");}}tinyMCE.execCommand("mceInsertRawHTML",false,content);}},_insertWordContent:function(content){if(content&&content.length>0){var bull=String.fromCharCode(8226);var middot=String.fromCharCode(183);var cb;if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('before', content)");var rl=tinyMCE.getParam("paste_replace_list",'\u2122,<sup>TM</sup>,\u2026,...,\u201c|\u201d,",\u2019,\',\u2013|\u2014|\u2015|\u2212,-').split(',');for(var i=0;i<rl.length;i+=2)content=content.replace(new RegExp(rl[i],'gi'),rl[i+1]);if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(new RegExp('<p class=MsoHeading.*?>(.*?)<\/p>','gi'),'<p><b>$1</b></p>');}content=content.replace(new RegExp('tab-stops: list [0-9]+.0pt">','gi'),'">'+"--list--");content=content.replace(new RegExp(bull+"(.*?)<BR>","gi"),"<p>"+middot+"$1</p>");content=content.replace(new RegExp('<SPAN style="mso-list: Ignore">','gi'),"<span>"+bull);content=content.replace(/<o:p><\/o:p>/gi,"");content=content.replace(new RegExp('<br style="page-break-before: always;.*>','gi'),'-- page break --');content=content.replace(new RegExp('<(!--)([^>]*)(--)>','g'),"");if(tinyMCE.getParam("paste_remove_spans",true))content=content.replace(/<\/?span[^>]*>/gi,"");if(tinyMCE.getParam("paste_remove_styles",true))content=content.replace(new RegExp('<(\\w[^>]*) style="([^"]*)"([^>]*)','gi'),"<$1$3");content=content.replace(/<\/?font[^>]*>/gi,"");switch(tinyMCE.getParam("paste_strip_class_attributes","all")){case"all":content=content.replace(/<(\w[^>]*) class=([^ |>]*)([^>]*)/gi,"<$1$3");break;case"mso":content=content.replace(new RegExp('<(\\w[^>]*) class="?mso([^ |>]*)([^>]*)','gi'),"<$1$3");break;}content=content.replace(new RegExp('href="?'+TinyMCE_PastePlugin._reEscape(""+document.location)+'','gi'),'href="'+tinyMCE.settings['document_base_url']);content=content.replace(/<(\w[^>]*) lang=([^ |>]*)([^>]*)/gi,"<$1$3");content=content.replace(/<\\?\?xml[^>]*>/gi,"");content=content.replace(/<\/?\w+:[^>]*>/gi,"");content=content.replace(/-- page break --\s*<p> <\/p>/gi,"");content=content.replace(/-- page break --/gi,"");if(!tinyMCE.settings['force_p_newlines']){content=content.replace('','','gi');content=content.replace('</p>','<br /><br />','gi');}if(!tinyMCE.isMSIE&&!tinyMCE.settings['force_p_newlines']){content=content.replace(/<\/?p[^>]*>/gi,"");}content=content.replace(/<\/?div[^>]*>/gi,"");if(tinyMCE.getParam("paste_convert_middot_lists",true)){var div=document.createElement("div");div.innerHTML=content;var className=tinyMCE.getParam("paste_unindented_list_class","unIndentedList");while(TinyMCE_PastePlugin._convertMiddots(div,"--list--"));while(TinyMCE_PastePlugin._convertMiddots(div,middot,className));while(TinyMCE_PastePlugin._convertMiddots(div,bull));content=div.innerHTML;}if(tinyMCE.getParam("paste_convert_headers_to_strong",false)){content=content.replace(/<h[1-6]> <\/h[1-6]>/gi,'<p> </p>');content=content.replace(/<h[1-6]>/gi,'<p><b>');content=content.replace(/<\/h[1-6]>/gi,'</b></p>');content=content.replace(/<b> <\/b>/gi,'<b> </b>');content=content.replace(/^( )*/gi,'');}content=content.replace(/--list--/gi,"");if((cb=tinyMCE.getParam("paste_insert_word_content_callback",""))!="")content=eval(cb+"('after', content)");tinyMCE.execCommand("mceInsertContent",false,content);window.setTimeout('tinyMCE.execCommand("mceCleanup");',1);}},_reEscape:function(s){var l="?.\\*[](){}+^$:";var o="";for(var i=0;i<s.length;i++){var c=s.charAt(i);if(l.indexOf(c)!=-1)o+='\\'+c;else o+=c;}return o;},_convertMiddots:function(div,search,class_name){var mdot=String.fromCharCode(183);var bull=String.fromCharCode(8226);var nodes=div.getElementsByTagName("p");var prevul;for(var i=0;i<nodes.length;i++){var p=nodes[i];if(p.innerHTML.indexOf(search)==0){var ul=document.createElement("ul");if(class_name)ul.className=class_name;var li=document.createElement("li");li.innerHTML=p.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');ul.appendChild(li);var np=p.nextSibling;while(np){if(np.nodeType==3&&new RegExp('^\\s$','m').test(np.nodeValue)){np=np.nextSibling;continue;}if(search==mdot){if(np.nodeType==1&&new RegExp('^o(\\s+| )').test(np.innerHTML)){if(!prevul){prevul=ul;ul=document.createElement("ul");prevul.appendChild(ul);}np.innerHTML=np.innerHTML.replace(/^o/,'');}else{if(prevul){ul=prevul;prevul=null;}if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}}else{if(np.nodeType!=1||np.innerHTML.indexOf(search)!=0)break;}var cp=np.nextSibling;var li=document.createElement("li");li.innerHTML=np.innerHTML.replace(new RegExp(''+mdot+'|'+bull+'|--list--| ',"gi"),'');np.parentNode.removeChild(np);ul.appendChild(li);np=cp;}p.parentNode.replaceChild(ul,p);return true;}}return false;},_clipboardHTML:function(){var div=document.getElementById('_TinyMCE_clipboardHTML');if(!div){var div=document.createElement('DIV');div.id='_TinyMCE_clipboardHTML';with(div.style){visibility='hidden';overflow='hidden';position='absolute';width=1;height=1;}document.body.appendChild(div);}div.innerHTML='';var rng=document.body.createTextRange();rng.moveToElementText(div);rng.execCommand('Paste');var html=div.innerHTML;div.innerHTML='';return html;}};tinyMCE.addPlugin("paste",TinyMCE_PastePlugin); -
trunk/wp-includes/js/tinymce/plugins/spellchecker/config.php
r3664 r4080 7 7 // Pspell shell specific settings 8 8 $spellCheckerConfig['tinypspellshell.aspell'] = '/usr/bin/aspell'; 9 $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp ';9 $spellCheckerConfig['tinypspellshell.tmp'] = '/tmp/tinyspell/0'; 10 10 11 11 // Default settings -
trunk/wp-includes/js/tinymce/plugins/wordpress/editor_plugin.js
r3664 r4080 150 150 151 151 // Parse all <!--more--> tags and replace them with images 152 while ((startPos = content.indexOf('<!--more-->', startPos)) != -1) { 152 while ((startPos = content.indexOf('<!--more', startPos)) != -1) { 153 var endPos = content.indexOf('-->', startPos) + 3; 153 154 // Insert image 154 var contentAfter = content.substring(startPos + 11); 155 var moreText = content.substring(startPos + 8, endPos - 3); 156 var contentAfter = content.substring(endPos); 155 157 content = content.substring(0, startPos); 156 158 content += '<img src="' + (tinyMCE.getParam("theme_href") + "/images/spacer.gif") + '" '; 157 content += ' width="100%" height="10px" ';159 content += ' width="100%" height="10px" moretext="'+moreText+'" '; 158 160 content += 'alt="'+altMore+'" title="'+altMore+'" class="mce_plugin_wordpress_more" name="mce_plugin_wordpress_more" />'; 159 161 content += contentAfter; … … 201 203 endPos += 2; 202 204 203 var embedHTML = '<!--more-->'; 205 var moreText = attribs['moretext'] ? attribs['moretext'] : ''; 206 var embedHTML = '<!--more'+moreText+'-->'; 204 207 205 208 // Insert embed/object chunk … … 343 346 attributeName = attributeName.substring(pos+1); 344 347 345 attributes[attributeName.toLowerCase()] = attributeValue.substring(1) .toLowerCase();348 attributes[attributeName.toLowerCase()] = attributeValue.substring(1); 346 349 347 350 attributeName = ""; … … 380 383 return re; 381 384 }; 382 383 tinyMCE.orgFixGeckoBaseHREFBug = tinyMCE.fixGeckoBaseHREFBug;384 tinyMCE.fixGeckoBaseHREFBug = function(m, e, h) {385 if ( tinyMCE.isGecko && m == 1 )386 h = h.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=', 'gi'), '<$1 x$4=');387 else388 h = tinyMCE.orgFixGeckoBaseHREFBug(m, e, h);389 390 return h;391 };392 393 tinyMCE.orgStoreAwayURLs = tinyMCE.storeAwayURLs;394 tinyMCE.storeAwayURLs = function(s) {395 // Remove all mce_src, mce_href and replace them with new ones396 s = s.replace(new RegExp('mce_(href|src)\\s*=\\s*\"[^ >\"]*\"', 'gi'), '');397 s = s.replace(new RegExp('<((a|img|select|area|iframe|base|input|script|embed|object|link)\\s([^>]*\\s)?)(src|href)\\s*=\\s*"([^"]*)"', 'gi'), '<$1 $4="$5" mce_$4="$5"');398 399 return s;400 }; -
trunk/wp-includes/js/tinymce/themes/advanced/editor_template.js
r3664 r4080 1 1 /** 2 2 * $RCSfile: editor_template_src.js,v $ 3 * $Revision: 1.9 3$4 * $Date: 2006/0 3/14 17:33:50$3 * $Revision: 1.96 $ 4 * $Date: 2006/04/18 13:32:52 $ 5 5 * 6 6 * @author Moxiecode … … 82 82 ['h4', '{$lang_theme_h4}'], 83 83 ['h5', '{$lang_theme_h5}'], 84 ['h6', '{$lang_theme_h6}'] 84 ['h6', '{$lang_theme_h6}'], 85 ['div', '{$lang_theme_div}'], 86 ['blockquote', '{$lang_theme_blockquote}'], 87 ['code', '{$lang_theme_code}'], 88 ['dt', '{$lang_theme_dt}'], 89 ['dd', '{$lang_theme_dd}'], 90 ['samp', '{$lang_theme_samp}'] 85 91 ]; 86 92 … … 91 97 for (var x=0; x<lookup.length; x++) { 92 98 if (formats[i] == lookup[x][0]) 93 html += '<option value=" <' + lookup[x][0] + '>">' + lookup[x][1] + '</option>';99 html += '<option value="<' + lookup[x][0] + '>">' + lookup[x][1] + '</option>'; 94 100 } 95 101 } … … 118 124 119 125 case "fontsizeselect": 120 return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList"> \121 <option value="0">{$lang_theme_font_size}</option>\122 <option value="1">1 (8 pt)</option>\123 <option value="2">2 (10 pt)</option>\124 <option value="3">3 (12 pt)</option>\125 <option value="4">4 (14 pt)</option>\126 <option value="5">5 (18 pt)</option>\127 <option value="6">6 (24 pt)</option>\128 <option value="7">7 (36 pt)</option>\129 </select>';126 return '<select id="{$editor_id}_fontSizeSelect" name="{$editor_id}_fontSizeSelect" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="tinyMCE.execInstanceCommand(\'{$editor_id}\',\'FontSize\',false,this.options[this.selectedIndex].value);" class="mceSelectList">'+ 127 '<option value="0">{$lang_theme_font_size}</option>'+ 128 '<option value="1">1 (8 pt)</option>'+ 129 '<option value="2">2 (10 pt)</option>'+ 130 '<option value="3">3 (12 pt)</option>'+ 131 '<option value="4">4 (14 pt)</option>'+ 132 '<option value="5">5 (18 pt)</option>'+ 133 '<option value="6">6 (24 pt)</option>'+ 134 '<option value="7">7 (36 pt)</option>'+ 135 '</select>'; 130 136 131 137 case "|": … … 459 465 var resizing = tinyMCE.getParam("theme_advanced_resizing", false); 460 466 var path = tinyMCE.getParam("theme_advanced_path", true); 461 var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '">& nbsp;</div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />';467 var statusbarHTML = '<div id="{$editor_id}_path" class="mceStatusbarPathText" style="display: ' + (path ? "block" : "none") + '"> </div><div id="{$editor_id}_resize" class="mceStatusbarResize" style="display: ' + (resizing ? "block" : "none") + '" onmousedown="tinyMCE.themes.advanced._setResizing(event,\'{$editor_id}\',true);"></div><br style="clear: both" />'; 462 468 var layoutManager = tinyMCE.getParam("theme_advanced_layout_manager", "SimpleLayout"); 463 469 … … 584 590 { 585 591 if (containers[i] == "mceEditor") //Exceptions for mceEditor and ... 586 { 587 template['html'] += '<tr><td align="center" class="mceEditor_border">\ 588 <span id="{$editor_id}"></span>\ 589 </td></tr>'; 590 } 592 template['html'] += '<tr><td align="center" class="mceEditor_border"><span id="{$editor_id}"></span></td></tr>'; 591 593 else if (containers[i] == "mceElementpath" || containers[i] == "mceStatusbar") // ... mceElementpath: 592 594 { … … 815 817 } 816 818 817 pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + '& nbsp;';819 pathElm.innerHTML = '<a href="#" accesskey="x"></a>' + tinyMCE.getLang('lang_theme_path') + ": " + html + ' '; 818 820 } 819 821 -
trunk/wp-includes/js/tinymce/tiny_mce.js
r3664 r4080 4 4 function TinyMCE_Engine() { 5 5 this.majorVersion = "2"; 6 this.minorVersion = "0. 5.1";7 this.releaseDate = "2006-0 3-22";6 this.minorVersion = "0.6.1"; 7 this.releaseDate = "2006-05-04"; 8 8 9 9 this.instances = new Array(); … … 11 11 this.windowArgs = new Array(); 12 12 this.loadedFiles = new Array(); 13 this.pendingFiles = new Array(); 14 this.loadingIndex = 0; 13 15 this.configs = new Array(); 14 16 this.currentConfig = 0; … … 128 130 this._def("convert_newlines_to_brs", false); 129 131 this._def("auto_reset_designmode", true); 130 this._def("entities", " 160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true);132 this._def("entities", "39,#39,160,nbsp,161,iexcl,162,cent,163,pound,164,curren,165,yen,166,brvbar,167,sect,168,uml,169,copy,170,ordf,171,laquo,172,not,173,shy,174,reg,175,macr,176,deg,177,plusmn,178,sup2,179,sup3,180,acute,181,micro,182,para,183,middot,184,cedil,185,sup1,186,ordm,187,raquo,188,frac14,189,frac12,190,frac34,191,iquest,192,Agrave,193,Aacute,194,Acirc,195,Atilde,196,Auml,197,Aring,198,AElig,199,Ccedil,200,Egrave,201,Eacute,202,Ecirc,203,Euml,204,Igrave,205,Iacute,206,Icirc,207,Iuml,208,ETH,209,Ntilde,210,Ograve,211,Oacute,212,Ocirc,213,Otilde,214,Ouml,215,times,216,Oslash,217,Ugrave,218,Uacute,219,Ucirc,220,Uuml,221,Yacute,222,THORN,223,szlig,224,agrave,225,aacute,226,acirc,227,atilde,228,auml,229,aring,230,aelig,231,ccedil,232,egrave,233,eacute,234,ecirc,235,euml,236,igrave,237,iacute,238,icirc,239,iuml,240,eth,241,ntilde,242,ograve,243,oacute,244,ocirc,245,otilde,246,ouml,247,divide,248,oslash,249,ugrave,250,uacute,251,ucirc,252,uuml,253,yacute,254,thorn,255,yuml,402,fnof,913,Alpha,914,Beta,915,Gamma,916,Delta,917,Epsilon,918,Zeta,919,Eta,920,Theta,921,Iota,922,Kappa,923,Lambda,924,Mu,925,Nu,926,Xi,927,Omicron,928,Pi,929,Rho,931,Sigma,932,Tau,933,Upsilon,934,Phi,935,Chi,936,Psi,937,Omega,945,alpha,946,beta,947,gamma,948,delta,949,epsilon,950,zeta,951,eta,952,theta,953,iota,954,kappa,955,lambda,956,mu,957,nu,958,xi,959,omicron,960,pi,961,rho,962,sigmaf,963,sigma,964,tau,965,upsilon,966,phi,967,chi,968,psi,969,omega,977,thetasym,978,upsih,982,piv,8226,bull,8230,hellip,8242,prime,8243,Prime,8254,oline,8260,frasl,8472,weierp,8465,image,8476,real,8482,trade,8501,alefsym,8592,larr,8593,uarr,8594,rarr,8595,darr,8596,harr,8629,crarr,8656,lArr,8657,uArr,8658,rArr,8659,dArr,8660,hArr,8704,forall,8706,part,8707,exist,8709,empty,8711,nabla,8712,isin,8713,notin,8715,ni,8719,prod,8721,sum,8722,minus,8727,lowast,8730,radic,8733,prop,8734,infin,8736,ang,8743,and,8744,or,8745,cap,8746,cup,8747,int,8756,there4,8764,sim,8773,cong,8776,asymp,8800,ne,8801,equiv,8804,le,8805,ge,8834,sub,8835,sup,8836,nsub,8838,sube,8839,supe,8853,oplus,8855,otimes,8869,perp,8901,sdot,8968,lceil,8969,rceil,8970,lfloor,8971,rfloor,9001,lang,9002,rang,9674,loz,9824,spades,9827,clubs,9829,hearts,9830,diams,34,quot,38,amp,60,lt,62,gt,338,OElig,339,oelig,352,Scaron,353,scaron,376,Yuml,710,circ,732,tilde,8194,ensp,8195,emsp,8201,thinsp,8204,zwnj,8205,zwj,8206,lrm,8207,rlm,8211,ndash,8212,mdash,8216,lsquo,8217,rsquo,8218,sbquo,8220,ldquo,8221,rdquo,8222,bdquo,8224,dagger,8225,Dagger,8240,permil,8249,lsaquo,8250,rsaquo,8364,euro", true); 131 133 this._def("entity_encoding", "named"); 132 134 this._def("cleanup_callback", ""); … … 160 162 this._def("fix_list_elements", false); 161 163 this._def("fix_table_elements", false); 164 this._def("strict_loading_mode", document.contentType == 'application/xhtml+xml'); 165 this._def("hidden_tab_class", ''); 166 this._def("display_tab_class", ''); 167 168 // Force strict loading mode to false on non Gecko browsers 169 if (this.isMSIE && !this.isOpera) 170 this.settings.strict_loading_mode = false; 162 171 163 172 // Browser check IE … … 199 208 200 209 theme = this.settings['theme']; 201 this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|d ir|fieldset|form|noscript|noframes|menu|isindex)$", "i");210 this.blockRegExp = new RegExp("^(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|blockquote|center|dl|dt|dd|dir|fieldset|form|noscript|noframes|menu|isindex|samp)$", "i"); 202 211 this.posKeyCodes = new Array(13,45,36,35,33,34,37,38,39,40); 203 this.uniqueURL = ' http://tinymce.moxiecode.cp/mce_temp_url'; // Make unique URL non real URL212 this.uniqueURL = 'javascript:TINYMCE_UNIQUEURL();'; // Make unique URL non real URL 204 213 this.uniqueTag = '<div id="mceTMPElement" style="display: none">TMP</div>'; 205 214 this.callbacks = new Array('onInit', 'getInfo', 'getEditorTemplate', 'setupContent', 'onChange', 'onPageLoad', 'handleNodeChange', 'initInstance', 'execCommand', 'getControlHTML', 'handleEvent', 'cleanup'); … … 288 297 settings['index'] = this.configs.length; 289 298 this.configs[this.configs.length] = settings; 299 300 // Start loading first one in chain 301 this.loadNextScript(); 290 302 }, 291 303 … … 320 332 p.baseURL = op ? op.baseURL : tinyMCE.baseURL + "/plugins/" + n; 321 333 this.plugins[n] = p; 334 335 this.loadNextScript(); 322 336 }, 323 337 … … 344 358 addTheme : function(n, t) { 345 359 this.themes[n] = t; 360 361 this.loadNextScript(); 346 362 }, 347 363 … … 355 371 356 372 loadScript : function(url) { 357 for (var i=0; i<this.loadedFiles.length; i++) { 373 var i; 374 375 for (i=0; i<this.loadedFiles.length; i++) { 358 376 if (this.loadedFiles[i] == url) 359 377 return; 360 378 } 361 379 362 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>'); 380 if (tinyMCE.settings.strict_loading_mode) 381 this.pendingFiles[this.pendingFiles.length] = url; 382 else 383 document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></script>'); 363 384 364 385 this.loadedFiles[this.loadedFiles.length] = url; 386 }, 387 388 loadNextScript : function() { 389 var d = document, se; 390 391 if (!tinyMCE.settings.strict_loading_mode) 392 return; 393 394 if (this.loadingIndex < this.pendingFiles.length) { 395 se = d.createElementNS('http://www.w3.org/1999/xhtml', 'script'); 396 se.setAttribute('language', 'javascript'); 397 se.setAttribute('type', 'text/javascript'); 398 se.setAttribute('src', this.pendingFiles[this.loadingIndex++]); 399 400 d.getElementsByTagName("head")[0].appendChild(se); 401 } else 402 this.loadingIndex = -1; // Done with loading 365 403 }, 366 404 … … 369 407 var lflen = 0, csslen = 0; 370 408 var skip = false; 371 var x = 0, i = 0 ;409 var x = 0, i = 0, nl, le; 372 410 373 411 for (x = 0,csslen = ar.length; x<csslen; x++) { … … 384 422 385 423 if (!skip) { 386 document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />'); 424 if (tinyMCE.settings.strict_loading_mode) { 425 nl = document.getElementsByTagName("head"); 426 427 le = document.createElement('link'); 428 le.setAttribute('href', ar[x]); 429 le.setAttribute('rel', 'stylesheet'); 430 le.setAttribute('type', 'text/css'); 431 432 nl[0].appendChild(le); 433 } else 434 document.write('<link href="' + ar[x] + '" rel="stylesheet" type="text/css" />'); 435 387 436 this.loadedFiles[this.loadedFiles.length] = ar[x]; 388 437 } … … 659 708 660 709 iframe.setAttribute("id", id); 661 iframe.setAttribute("class Name", "mceEditorIframe");710 iframe.setAttribute("class", "mceEditorIframe"); 662 711 iframe.setAttribute("border", "0"); 663 712 iframe.setAttribute("frameBorder", "0"); … … 669 718 iframe.setAttribute("height", ah); 670 719 iframe.setAttribute("allowtransparency", "true"); 720 iframe.className = 'mceEditorIframe'; 671 721 672 722 if (tinyMCE.settings["auto_resize"]) … … 679 729 iframe.style.width = aw; 680 730 iframe.style.height = ah; 731 732 // Ugly hack for Gecko problem in strict mode 733 if (tinyMCE.settings.strict_loading_mode) 734 iframe.style.marginBottom = '-5px'; 681 735 682 736 // MSIE 5.0 issue … … 697 751 var head = doc.getElementsByTagName('head').item(0); 698 752 var content = inst.startContent; 753 754 // HTML values get XML encoded in strict mode 755 if (tinyMCE.settings.strict_loading_mode) { 756 content = content.replace(/</g, '<'); 757 content = content.replace(/>/g, '>'); 758 content = content.replace(/"/g, '"'); 759 content = content.replace(/&/g, '&'); 760 } 699 761 700 762 inst.switchSettings(); … … 852 914 inst.undoRedo.add({ content : inst.startContent }); 853 915 916 // Cleanup any mess left from storyAwayURLs 917 if (tinyMCE.isGecko) { 918 // Remove mce_src from textnodes and comments 919 tinyMCE.selectNodes(inst.getBody(), function(n) { 920 if (n.nodeType == 3 || n.nodeType == 8) { 921 n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), ""); 922 n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), ""); 923 } 924 925 return false; 926 }); 927 } 928 929 // Cleanup any mess left from storyAwayURLs 930 tinyMCE._removeInternal(inst.getBody()); 931 854 932 tinyMCE.selectedInstance = inst; 855 933 tinyMCE.triggerNodeChange(false, true); … … 867 945 868 946 return s; 947 }, 948 949 _removeInternal : function(n) { 950 if (tinyMCE.isGecko) { 951 // Remove mce_src from textnodes and comments 952 tinyMCE.selectNodes(n, function(n) { 953 if (n.nodeType == 3 || n.nodeType == 8) { 954 n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), ""); 955 n.nodeValue = n.nodeValue.replace(new RegExp('\\smce_href=\"[^\"]*\"', 'gi'), ""); 956 } 957 958 return false; 959 }); 960 } 869 961 }, 870 962 … … 923 1015 tinyMCE.selectedInstance.setBaseHREF(null); 924 1016 925 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);", 1); 1017 // Fixes odd MSIE bug where drag/droping elements in a iframe with height 100% breaks 1018 // This logic forces the width/height to be in pixels while the user is drag/dropping 1019 if (tinyMCE.isMSIE && !tinyMCE.isOpera) { 1020 var ife = tinyMCE.selectedInstance.iframeElement; 1021 1022 /*if (ife.style.width.indexOf('%') != -1) { 1023 ife._oldWidth = ife.width.height; 1024 ife.style.width = ife.clientWidth; 1025 }*/ 1026 1027 if (ife.style.height.indexOf('%') != -1) { 1028 ife._oldHeight = ife.style.height; 1029 ife.style.height = ife.clientHeight; 1030 } 1031 } 1032 1033 window.setTimeout("tinyMCE.selectedInstance.setBaseHREF(tinyMCE.settings['base_href']);tinyMCE._resetIframeHeight();", 1); 926 1034 return; 927 1035 … … 1242 1350 1243 1351 onLoad : function() { 1352 // Wait for everything to be loaded first 1353 if (tinyMCE.settings.strict_loading_mode && this.loadingIndex != -1) { 1354 window.setTimeout('tinyMCE.onLoad();', 1); 1355 return; 1356 } 1357 1244 1358 if (tinyMCE.isMSIE && !tinyMCE.isOpera && window.event.type == "readystatechange" && document.readyState != "complete") 1245 1359 return true; … … 1426 1540 } 1427 1541 1542 this.loadNextScript(); 1543 1428 1544 // for (var key in ar) 1429 1545 // tinyMCELang[(key.indexOf('lang_') == -1 ? 'lang_' : '') + (prefix != '' ? (prefix + "_") : '') + key] = "|" + ar[key] + "|"; … … 1672 1788 }, 1673 1789 1674 handleVisualAid : function(el, deep, state, inst ) {1790 handleVisualAid : function(el, deep, state, inst, skip_dispatch) { 1675 1791 if (!el) 1676 1792 return; 1793 1794 if (!skip_dispatch) 1795 tinyMCE.dispatchCallback(inst, 'handle_visual_aid_callback', 'handleVisualAid', el, deep, state, inst); 1677 1796 1678 1797 var tableElement = null; … … 1714 1833 if (deep && el.hasChildNodes()) { 1715 1834 for (var i=0; i<el.childNodes.length; i++) 1716 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst );1835 tinyMCE.handleVisualAid(el.childNodes[i], deep, state, inst, true); 1717 1836 } 1718 1837 }, … … 1752 1871 1753 1872 fixGeckoBaseHREFBug : function(m, e, h) { 1754 var nl, i ;1873 var nl, i, a, n, xsrc, xhref, el; 1755 1874 1756 1875 if (tinyMCE.isGecko) { 1757 1876 if (m == 1) { 1758 h = h.replace(/\ssrc=/gi, " xsrc=");1759 h = h.replace(/\shref=/gi, " xhref=");1877 h = h.replace(/\ssrc=/gi, " mce_tsrc="); 1878 h = h.replace(/\shref=/gi, " mce_thref="); 1760 1879 1761 1880 return h; 1762 1881 } else { 1763 varel = new Array('a','img','select','area','iframe','base','input','script','embed','object','link');1764 1765 for ( vara=0; a<el.length; a++) {1766 varn = e.getElementsByTagName(el[a]);1882 el = new Array('a','img','select','area','iframe','base','input','script','embed','object','link'); 1883 1884 for (a=0; a<el.length; a++) { 1885 n = e.getElementsByTagName(el[a]); 1767 1886 1768 1887 for (i=0; i<n.length; i++) { 1769 var xsrc = tinyMCE.getAttrib(n[i], "xsrc");1770 var xhref = tinyMCE.getAttrib(n[i], "xhref");1888 xsrc = tinyMCE.getAttrib(n[i], "mce_tsrc"); 1889 xhref = tinyMCE.getAttrib(n[i], "mce_thref"); 1771 1890 1772 1891 if (xsrc != "") { 1773 n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc); 1774 n[i].removeAttribute("xsrc"); 1892 try { 1893 n[i].src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xsrc); 1894 } catch (e) { 1895 // Ignore, Firefox cast exception if local file wasn't found 1896 } 1897 1898 n[i].removeAttribute("mce_tsrc"); 1775 1899 } 1776 1900 1777 1901 if (xhref != "") { 1778 n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref); 1779 n[i].removeAttribute("xhref"); 1902 try { 1903 n[i].href = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], xhref); 1904 } catch (e) { 1905 // Ignore, Firefox cast exception if local file wasn't found 1906 } 1907 1908 n[i].removeAttribute("mce_thref"); 1780 1909 } 1781 1910 } 1782 1911 } 1912 1913 el = tinyMCE.selectNodes(e, function(n) { 1914 if (n.nodeType == 3 || n.nodeType == 8) { 1915 n.nodeValue = n.nodeValue.replace(/\smce_tsrc=/gi, " src="); 1916 n.nodeValue = n.nodeValue.replace(/\smce_thref=/gi, " href="); 1917 } 1918 1919 return false; 1920 }); 1783 1921 } 1784 1922 } … … 1921 2059 1922 2060 if (doc) { 1923 var styles = tinyMCE.isMSIE ? doc.styleSheets :doc.styleSheets;2061 var styles = doc.styleSheets; 1924 2062 1925 2063 if (styles && styles.length > 0) { … … 1928 2066 1929 2067 // Just ignore any errors 1930 eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : doc.styleSheets[" + x + "].cssRules;} catch(e) {}");2068 eval("try {var csses = tinyMCE.isMSIE ? doc.styleSheets(" + x + ").rules : styles[" + x + "].cssRules;} catch(e) {}"); 1931 2069 if (!csses) 1932 2070 return new Array(); … … 1939 2077 var rules = selectorText.split(','); 1940 2078 for (var c=0; c<rules.length; c++) { 2079 var rule = rules[c]; 2080 2081 // Strip spaces between selectors 2082 while (rule.indexOf(' ') == 0) 2083 rule = rule.substring(1); 2084 1941 2085 // Invalid rule 1942 if (rule s[c].indexOf(' ') != -1 || rules[c].indexOf(':') != -1 || rules[c].indexOf('mceItem') != -1)2086 if (rule.indexOf(' ') != -1 || rule.indexOf(':') != -1 || rule.indexOf('mceItem') != -1) 1943 2087 continue; 1944 2088 1945 if (rule s[c] == "." + tinyMCE.settings['visual_table_class'] || rules[c].indexOf('mceEditable') != -1 || rules[c].indexOf('mceNonEditable') != -1)2089 if (rule.indexOf(tinyMCE.settings['visual_table_class']) != -1 || rule.indexOf('mceEditable') != -1 || rule.indexOf('mceNonEditable') != -1) 1946 2090 continue; 1947 2091 1948 2092 // Is class rule 1949 if (rules[c].indexOf('.') != -1) { 1950 //alert(rules[c].substring(rules[c].indexOf('.'))); 1951 output[output.length] = rules[c].substring(rules[c].indexOf('.')+1); 2093 if (rule.indexOf('.') != -1) { 2094 var cssClass = rule.substring(rule.indexOf('.') + 1); 2095 var addClass = true; 2096 2097 for (var p=0; p<output.length && addClass; p++) { 2098 if (output[p] == cssClass) 2099 addClass = false; 2100 } 2101 2102 if (addClass) 2103 output[output.length] = cssClass; 1952 2104 } 1953 2105 } … … 2101 2253 tinyMCE.lastSelectedMenuBtn = null; 2102 2254 } 2255 }, 2256 2257 explode : function(d, s) { 2258 var ar = s.split(d), oar = new Array(), i; 2259 2260 for (i = 0; i<ar.length; i++) { 2261 if (ar[i] != "") 2262 oar[oar.length] = ar[i]; 2263 } 2264 2265 return oar; 2103 2266 } 2104 2267 }; … … 2521 2684 case "FormatBlock": 2522 2685 if (value == null || value == "") { 2523 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address ");2686 var elm = tinyMCE.getParentElement(this.getFocusElement(), "p,div,h1,h2,h3,h4,h5,h6,pre,address,blockquote,dt,dl,dd,samp"); 2524 2687 2525 2688 if (elm) 2526 2689 this.execCommand("mceRemoveNode", false, elm); 2527 2690 } else { 2528 if (value == '<div>' && tinyMCE.isGecko) 2529 value = 'div'; 2530 2531 this.getDoc().execCommand("FormatBlock", false, value); 2691 if (tinyMCE.isGecko && new RegExp('<(div|blockquote|code|dt|dd|dl|samp)>', 'gi').test(value)) 2692 value = value.replace(/[^a-z]/gi, ''); 2693 2694 if (tinyMCE.isMSIE && new RegExp('blockquote|code|samp', 'gi').test(value)) { 2695 var b = this.selection.getBookmark(); 2696 this.getDoc().execCommand("FormatBlock", false, '<p>'); 2697 tinyMCE.renameElement(tinyMCE.getParentBlockElement(this.getFocusElement()), value); 2698 this.selection.moveToBookmark(b); 2699 } else 2700 this.getDoc().execCommand("FormatBlock", false, value); 2532 2701 } 2533 2702 … … 2829 2998 tinyMCE.setInnerHTML(doc.body, tinyMCE._cleanupHTML(this, doc, tinyMCE.settings, doc.body)); 2830 2999 tinyMCE.convertAllRelativeURLs(doc.body); 3000 3001 // Cleanup any mess left from storyAwayURLs 3002 tinyMCE._removeInternal(this.getBody()); 2831 3003 2832 3004 // When editing always use fonts internaly … … 3274 3446 hc = '<textarea wrap="off" id="' + form_element_name + '" name="' + form_element_name + '" cols="100" rows="15"></textarea>'; 3275 3447 } else { 3276 hc = '<input type="hidden" type="text"id="' + form_element_name + '" name="' + form_element_name + '" />';3448 hc = '<input type="hidden" id="' + form_element_name + '" name="' + form_element_name + '" />'; 3277 3449 this.oldTargetElement.style.display = "none"; 3278 3450 } … … 3319 3491 3320 3492 if (!tinyMCE.isMSIE) { 3321 if (tElm && tElm.nodeName == "SPAN") { 3493 // Node case is preserved in XML strict mode 3494 if (tElm && (tElm.nodeName == "SPAN" || tElm.nodeName == "span")) { 3322 3495 tElm = tinyMCE._createIFrame(tElm, targetDoc); 3323 3496 dynamicIFrame = true; … … 3414 3587 3415 3588 triggerSave : function(skip_cleanup, skip_callback) { 3589 var e, nl = new Array(), i, s; 3590 3416 3591 this.switchSettings(); 3592 s = tinyMCE.settings; 3593 3594 // Force hidden tabs visible while serializing 3595 if (tinyMCE.isMSIE && !tinyMCE.isOpera) { 3596 e = this.iframeElement; 3597 3598 do { 3599 if (e.style && e.style.display == 'none') { 3600 e.style.display = 'block'; 3601 nl[nl.length] = {elm : e, type : 'style'}; 3602 } 3603 3604 if (e.style && s.hidden_tab_class.length > 0 && e.className.indexOf(s.hidden_tab_class) != -1) { 3605 e.className = s.display_tab_class; 3606 nl[nl.length] = {elm : e, type : 'class'}; 3607 } 3608 } while ((e = e.parentNode) != null) 3609 } 3417 3610 3418 3611 tinyMCE.settings['preformatted'] = false; … … 3457 3650 if (tinyMCE.isSafari && this.formElement) 3458 3651 this.formElement.innerText = htm; 3652 3653 // Hide them again (tabs in MSIE) 3654 for (i=0; i<nl.length; i++) { 3655 if (nl[i].type == 'style') 3656 nl[i].elm.style.display = 'none'; 3657 else 3658 nl[i].elm.className = s.hidden_tab_class; 3659 } 3459 3660 } 3460 3661 }; … … 3463 3664 3464 3665 TinyMCE_Engine.prototype.cleanupHTMLCode = function(s) { 3465 s = s.replace(/<p \/>/gi, '<p> </p>'); 3466 s = s.replace(/<p>\s*<\/p>/gi, '<p> </p>'); 3666 s = s.replace(new RegExp('<p \\/>', 'gi'), '<p> </p>'); 3667 s = s.replace(new RegExp('<p>\\s*<\\/p>', 'gi'), '<p> </p>'); 3668 3669 // Fix close BR elements 3670 s = s.replace(new RegExp('<br>\\s*<\\/br>', 'gi'), '<br />'); 3467 3671 3468 3672 // Open closed tags like <b/> to <b></b> 3469 // tinyMCE.debug("f:" + s); 3470 s = s.replace(/<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\|>]*?)\/>/gi, '<$1$2$3></$1$2>'); 3471 // tinyMCE.debug("e:" + s); 3673 s = s.replace(new RegExp('<(h[1-6]|p|div|address|pre|form|table|li|ol|ul|td|b|font|em|strong|i|strike|u|span|a|ul|ol|li|blockquote)([a-z]*)([^\\\\|>]*)\\/>', 'gi'), '<$1$2$3></$1$2>'); 3472 3674 3473 3675 // Remove trailing space <b > to <b> … … 3475 3677 3476 3678 // Close tags <img></img> to <img/> 3477 s = s.replace( /<(img|br|hr)(.*?)><\/(img|br|hr)>/gi, '<$1$2 />');3679 s = s.replace(new RegExp('<(img|br|hr)([^>]*)><\\/(img|br|hr)>', 'gi'), '<$1$2 />'); 3478 3680 3479 3681 // Weird MSIE bug, <p><hr /></p> breaks runtime? 3480 3682 if (tinyMCE.isMSIE) 3481 s = s.replace( /<p><hr \/><\/p>/gi, "<hr>");3683 s = s.replace(new RegExp('<p><hr \\/><\\/p>', 'gi'), "<hr>"); 3482 3684 3483 3685 // Convert relative anchors to absolute URLs ex: #something to file.htm#something 3484 3686 if (tinyMCE.getParam('convert_urls')) 3485 s = s.replace(new RegExp('(href=\" ?)(\\s*?#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#");3687 s = s.replace(new RegExp('(href=\"{0,1})(\\s*#)', 'gi'), '$1' + tinyMCE.settings['document_base_url'] + "#"); 3486 3688 3487 3689 return s; … … 3545 3747 tinyMCE.compressStyle(ar, "border", "-width", "border-width"); 3546 3748 tinyMCE.compressStyle(ar, "border", "-color", "border-color"); 3749 tinyMCE.compressStyle(ar, "border", "-style", "border-style"); 3750 tinyMCE.compressStyle(ar, "padding", "", "padding"); 3751 tinyMCE.compressStyle(ar, "margin", "", "margin"); 3547 3752 3548 3753 for (var key in ar) { … … 3705 3910 var i, cn, x, an = doc.getElementsByTagName("a"); 3706 3911 3707 for (i=0; i<an.length; i++) { 3912 // Loops backwards due to bug #1467987 3913 for (i=an.length-1; i>=0; i--) { 3708 3914 if (tinyMCE.getAttrib(an[i], "name") != "" && tinyMCE.getAttrib(an[i], "href") == "") { 3709 3915 cn = an[i].childNodes; … … 3837 4043 h = h.replace(/<p>\s*( | )\s*<br \/>\s*<\/p>/g, '<p> </p>'); 3838 4044 h = h.replace(/<p>\s*<br \/>\s* \s*<\/p>/g, '<p> </p>'); 3839 h = h.replace( /<a>(.*?)<\/a>/g, '$1');4045 h = h.replace(new RegExp('<a>(.*?)<\\/a>', 'g'), '$1'); 3840 4046 h = h.replace(/<p([^>]*)>\s*<\/p>/g, '<p$1> </p>'); 3841 4047 … … 3913 4119 this.vElements = tinyMCE.clearArray(new Array()); 3914 4120 this.vElementsRe = ''; 3915 this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON )$/;4121 this.closeElementsRe = /^(IMG|BR|HR|LINK|META|BASE|INPUT|BUTTON|AREA)$/; 3916 4122 this.codeElementsRe = /^(SCRIPT|STYLE)$/; 3917 4123 this.serializationId = 0; … … 4028 4234 t = a[i]; 4029 4235 4030 av = /(=|:|<)(.*?)$/.exec(t);4031 t = t.replace( /(=|:|<).*?$/, '');4236 av = new RegExp('(=|:|<)(.*?)$').exec(t); 4237 t = t.replace(new RegExp('(=|:|<).*?$'), ''); 4032 4238 if (av && av.length > 0) { 4033 4239 if (av[0].charAt(0) == ':') { … … 4335 4541 e = this.entities[c]; 4336 4542 4337 // ' is not working in MSIE4338 // More info: http://www.w3.org/TR/xhtml1/#C_164339 if (c == 39) {4340 o += "'";4341 continue;4342 }4343 4344 4543 if (e && e != '') 4345 4544 o += '&' + e + ';'; … … 4379 4578 4380 4579 _trimComment : function(s) { 4381 // Make xsrc, xhref as src and href again4382 if (tinyMCE.isGecko) {4383 s = s.replace(/\sxsrc=/gi, " src=");4384 s = s.replace(/\sxhref=/gi, " href=");4385 }4386 4387 4580 // Remove mce_src, mce_href 4388 4581 s = s.replace(new RegExp('\\smce_src=\"[^\"]*\"', 'gi'), ""); … … 4406 4599 if (this.isMSIE && n == "http-equiv") 4407 4600 v = e.httpEquiv; 4601 4602 if (this.isMSIE && e.nodeName == "FORM" && n == "enctype" && v == "application/x-www-form-urlencoded") 4603 v = ""; 4604 4605 if (this.isMSIE && e.nodeName == "INPUT" && n == "size" && v == "20") 4606 v = ""; 4607 4608 if (this.isMSIE && e.nodeName == "INPUT" && n == "maxlength" && v == "2147483647") 4609 v = ""; 4408 4610 4409 4611 if (n == "style" && !tinyMCE.isOpera) … … 4558 4760 // Since MSIE auto generated emtpy P tags some times we must tell it to keep the real ones 4559 4761 h = h.replace(/<p([^>]*)>\u00A0?<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 4560 h = h.replace(/<p([^>]*)> <\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 4762 h = h.replace(/<p([^>]*)>\s* \s*<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 4763 h = h.replace(/<p([^>]*)>\s+<\/p>/gi, '<p$1 mce_keep="true"> </p>'); // Keep empty paragraphs 4561 4764 4562 4765 // Remove first comment … … 4671 4874 }; 4672 4875 4876 TinyMCE_Engine.prototype.getParentNode = function(n, f) { 4877 while (n) { 4878 if (f(n)) 4879 return n; 4880 4881 n = n.parentNode; 4882 } 4883 4884 return null; 4885 }; 4886 4673 4887 TinyMCE_Engine.prototype.getAttrib = function(elm, name, default_value) { 4674 4888 if (typeof(default_value) == "undefined") … … 4790 5004 4791 5005 return null; 5006 }; 5007 5008 TinyMCE_Engine.prototype.selectNodes = function(n, f, a) { 5009 var i; 5010 5011 if (!a) 5012 a = new Array(); 5013 5014 if (f(n)) 5015 a[a.length] = n; 5016 5017 if (n.hasChildNodes()) { 5018 for (i=0; i<n.childNodes.length; i++) 5019 tinyMCE.selectNodes(n.childNodes[i], f, a); 5020 } 5021 5022 return a; 5023 }; 5024 5025 TinyMCE_Engine.prototype.addCSSClass = function(e, c, b) { 5026 var o = this.removeCSSClass(e, c); 5027 5028 return e.className = b ? c + (o != '' ? (' ' + o) : '') : (o != '' ? (o + ' ') : '') + c; 5029 }; 5030 5031 TinyMCE_Engine.prototype.removeCSSClass = function(e, c) { 5032 var a = this.explode(' ', e.className), i; 5033 5034 for (i=0; i<a.length; i++) { 5035 if (a[i] == c) 5036 a[i] = ''; 5037 } 5038 5039 return e.className = a.join(' '); 5040 }; 5041 5042 TinyMCE_Engine.prototype.renameElement = function(e, n, d) { 5043 var ne, i, ar; 5044 5045 d = typeof(d) == "undefined" ? tinyMCE.selectedInstance.getDoc() : d; 5046 5047 if (e) { 5048 ne = d.createElement(n); 5049 5050 ar = e.attributes; 5051 for (i=ar.length-1; i>-1; i--) { 5052 if (ar[i].specified && ar[i].nodeValue) 5053 ne.setAttribute(ar[i].nodeName.toLowerCase(), ar[i].nodeValue); 5054 } 5055 5056 ar = e.childNodes; 5057 for (i=0; i<ar.length; i++) 5058 ne.appendChild(ar[i].cloneNode(true)); 5059 5060 e.parentNode.replaceChild(ne, e); 5061 } 4792 5062 }; 4793 5063 … … 4951 5221 targetURL.path = ""; 4952 5222 4953 // If empty and not local anchor force slash5223 // If empty and not local anchor force filename or slash 4954 5224 if (targetURL.path == "" && !targetURL.anchor) 4955 targetURL.path = "/";5225 targetURL.path = fileName != "" ? fileName : "/"; 4956 5226 4957 5227 return this.serializeURL(targetURL); … … 5216 5486 tinyMCE.addEvent(doc, "keydown", TinyMCE_Engine.prototype._eventPatch); 5217 5487 tinyMCE.addEvent(doc, "mouseup", TinyMCE_Engine.prototype._eventPatch); 5488 tinyMCE.addEvent(doc, "mousedown", TinyMCE_Engine.prototype._eventPatch); 5218 5489 tinyMCE.addEvent(doc, "click", TinyMCE_Engine.prototype._eventPatch); 5219 5490 } else { … … 5309 5580 }; 5310 5581 5582 TinyMCE_Engine.prototype._resetIframeHeight = function() { 5583 var ife; 5584 5585 if (tinyMCE.isMSIE && !tinyMCE.isOpera) { 5586 ife = tinyMCE.selectedInstance.iframeElement; 5587 5588 /* if (ife._oldWidth) { 5589 ife.style.width = ife._oldWidth; 5590 ife.width = ife._oldWidth; 5591 }*/ 5592 5593 if (ife._oldHeight) { 5594 ife.style.height = ife._oldHeight; 5595 ife.height = ife._oldHeight; 5596 } 5597 } 5598 }; 5599 5311 5600 /* file:jscripts/tiny_mce/classes/TinyMCE_Selection.class.js */ 5312 5601 … … 5329 5618 if (tinyMCE.isGecko) 5330 5619 e.appendChild(r.cloneContents()); 5331 else 5332 e.innerHTML = r. htmlText;5620 else 5621 e.innerHTML = r.item ? r.item(0).outerHTML : r.htmlText; 5333 5622 5334 5623 h = tinyMCE._cleanupHTML(inst, inst.contentDocument, inst.settings, e, e, false, true, false); … … 5491 5780 nl = doc.getElementsByTagName(bookmark.tag); 5492 5781 5493 if (nl.length > bookmark.index) 5494 rng.addElement(nl[bookmark.index]); 5782 if (nl.length > bookmark.index) { 5783 try { 5784 rng.addElement(nl[bookmark.index]); 5785 } catch (ex) { 5786 // Might be thrown if the node no longer exists 5787 } 5788 } 5495 5789 } else { 5496 5790 rng = inst.getSel().createRange(); … … 5878 6172 var endBlock = tinyMCE.getParentBlockElement(endNode); 5879 6173 6174 // If absolute force paragraph generation within 6175 if (startBlock && new RegExp('absolute|relative|static', 'gi').test(startBlock.style.position)) 6176 startBlock = null; 6177 6178 if (endBlock && new RegExp('absolute|relative|static', 'gi').test(endBlock.style.position)) 6179 endBlock = null; 6180 5880 6181 // Use current block name 5881 6182 if (startBlock != null) { … … 6063 6364 6064 6365 _handleBackSpace : function(inst) { 6065 var r = inst.getRng(); 6066 var sn = r.startContainer; 6067 6068 if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") 6069 sn.nextSibling.parentNode.removeChild(sn.nextSibling); 6070 6071 return false; 6366 var r = inst.getRng(), sn = r.startContainer, nv, s = false; 6367 6368 if (sn && sn.nextSibling && sn.nextSibling.nodeName == "BR") { 6369 nv = sn.nodeValue; 6370 6371 // Handle if a backspace is pressed after a space character #bug 1466054 6372 if (nv != null && nv.length >= r.startOffset && nv.charAt(r.startOffset - 1) == ' ') 6373 s = true; 6374 6375 // Only remove BRs if we are at the end of line #bug 1464152 6376 if (nv != null && r.startOffset == nv.length) 6377 sn.nextSibling.parentNode.removeChild(sn.nextSibling); 6378 } 6379 6380 return s; 6072 6381 } 6073 6382 }; … … 6081 6390 this.element = null; 6082 6391 this.blockMode = typeof(bm) != 'undefined' ? bm : true; 6392 this.doc = document; 6083 6393 }; 6084 6394 … … 6145 6455 var e = this.getElement(); 6146 6456 6147 e.style.width = w + "px"; 6148 e.style.height = h + "px"; 6457 if (w != null) 6458 e.style.width = w + "px"; 6459 6460 if (h != null) 6461 e.style.height = h + "px"; 6149 6462 6150 6463 this.updateBlocker(); … … 6167 6480 getElement : function() { 6168 6481 if (!this.element) 6169 this.element = document.getElementById(this.id);6482 this.element = this.doc.getElementById(this.id); 6170 6483 6171 6484 return this.element; … … 6202 6515 6203 6516 if (!this.blockerElement && this.blockMode) { 6204 d = document;6517 d = this.doc; 6205 6518 b = d.createElement("iframe"); 6206 6519 … … 6230 6543 6231 6544 create : function(n, c, p) { 6232 var d = document, e = d.createElement(n);6545 var d = this.doc, e = d.createElement(n); 6233 6546 6234 6547 e.setAttribute('id', this.id); … … 6244 6557 return this.element = e; 6245 6558 }, 6246 /*6247 addCSSClass : function(e, c) {6248 this.removeCSSClass(e, c);6249 var a = this.explode(' ', e.className);6250 a[a.length] = c;6251 e.className = a.join(' ');6252 },6253 6254 removeCSSClass : function(e, c) {6255 var a = this.explode(' ', e.className), i;6256 6257 for (i=0; i<a.length; i++) {6258 if (a[i] == c)6259 a[i] = '';6260 }6261 6262 e.className = a.join(' ');6263 },6264 6265 explode : function(d, s) {6266 var ar = s.split(d);6267 var oar = new Array();6268 6269 for (var i = 0; i<ar.length; i++) {6270 if (ar[i] != "")6271 oar[oar.length] = ar[i];6272 }6273 6274 return oar;6275 },6276 */6277 6559 6278 6560 parseInt : function(s) { … … 6398 6680 tinyMCE.lastMenu.hide(); 6399 6681 6400 this.parent.show.call(this);6682 TinyMCE_Layer.prototype.show.call(this); 6401 6683 6402 6684 if (!tinyMCE.isOpera) { -
trunk/wp-includes/js/tinymce/tiny_mce_config.php
r3703 r4080 44 44 $mce_css = get_option('siteurl') . '/wp-includes/js/tinymce/plugins/wordpress/wordpress.css'; 45 45 $mce_css = apply_filters('mce_css', $mce_css); 46 if ( $_SERVER['HTTPS'] ) { 47 $mce_css = str_replace('http://', 'https://', $mce_css); 48 $mce_popups_css = str_replace('http://', 'https://', $mce_popups_css); 49 } 46 50 ?> 47 51 … … 70 74 remove_linebreaks : false, 71 75 fix_list_elements : true, 76 entities : "38,amp,60,lt,62,gt", 72 77 content_css : "<?php echo $mce_css; ?>", 73 78 valid_elements : "<?php echo $valid_elements; ?>", -
trunk/wp-includes/js/tinymce/tiny_mce_popup.js
r3664 r4080 264 264 }; 265 265 266 TinyMCE_Popup.prototype.importClass = function(c) { 267 window[c] = function() {}; 268 269 for (var n in window.opener[c].prototype) 270 window[c].prototype[n] = window.opener[c].prototype[n]; 271 272 window[c].constructor = window.opener[c].constructor; 273 }; 274 266 275 // Setup global instance 267 276 var tinyMCEPopup = new TinyMCE_Popup();
Note: See TracChangeset
for help on using the changeset viewer.