275 |
275 |
276 return o; |
276 return o; |
277 }, |
277 }, |
278 |
278 |
279 _convertMiddots : function(div, search, class_name) { |
279 _convertMiddots : function(div, search, class_name) { |
280 var mdot = String.fromCharCode(183); |
280 var ed = this.editor, mdot = String.fromCharCode(183), bull = String.fromCharCode(8226); |
281 var bull = String.fromCharCode(8226); |
281 var nodes, prevul, i, p, ul, li, np, cp, li; |
282 |
282 |
283 var nodes = div.getElementsByTagName("p"); |
283 nodes = div.getElementsByTagName("p"); |
284 var prevul; |
284 for (i=0; i<nodes.length; i++) { |
285 for (var i=0; i<nodes.length; i++) { |
285 p = nodes[i]; |
286 var p = nodes[i]; |
|
287 |
286 |
288 // Is middot |
287 // Is middot |
289 if (p.innerHTML.indexOf(search) == 0) { |
288 if (p.innerHTML.indexOf(search) == 0) { |
290 var ul = document.createElement("ul"); |
289 ul = ed.dom.create("ul"); |
291 |
290 |
292 if (class_name) |
291 if (class_name) |
293 ul.className = class_name; |
292 ul.className = class_name; |
294 |
293 |
295 // Add the first one |
294 // Add the first one |
296 var li = document.createElement("li"); |
295 li = ed.dom.create("li"); |
297 li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); |
296 li.innerHTML = p.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); |
298 ul.appendChild(li); |
297 ul.appendChild(li); |
299 |
298 |
300 // Add the rest |
299 // Add the rest |
301 var np = p.nextSibling; |
300 np = p.nextSibling; |
302 while (np) { |
301 while (np) { |
303 // If the node is whitespace, then |
302 // If the node is whitespace, then |
304 // ignore it and continue on. |
303 // ignore it and continue on. |
305 if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) { |
304 if (np.nodeType == 3 && new RegExp('^\\s$', 'm').test(np.nodeValue)) { |
306 np = np.nextSibling; |
305 np = np.nextSibling; |
310 if (search == mdot) { |
309 if (search == mdot) { |
311 if (np.nodeType == 1 && new RegExp('^o(\\s+| )').test(np.innerHTML)) { |
310 if (np.nodeType == 1 && new RegExp('^o(\\s+| )').test(np.innerHTML)) { |
312 // Second level of nesting |
311 // Second level of nesting |
313 if (!prevul) { |
312 if (!prevul) { |
314 prevul = ul; |
313 prevul = ul; |
315 ul = document.createElement("ul"); |
314 ul = ed.dom.create("ul"); |
316 prevul.appendChild(ul); |
315 prevul.appendChild(ul); |
317 } |
316 } |
318 np.innerHTML = np.innerHTML.replace(/^o/, ''); |
317 np.innerHTML = np.innerHTML.replace(/^o/, ''); |
319 } else { |
318 } else { |
320 // Pop the stack if we're going back up to the first level |
319 // Pop the stack if we're going back up to the first level |
330 // Not element or middot paragraph |
329 // Not element or middot paragraph |
331 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0) |
330 if (np.nodeType != 1 || np.innerHTML.indexOf(search) != 0) |
332 break; |
331 break; |
333 } |
332 } |
334 |
333 |
335 var cp = np.nextSibling; |
334 cp = np.nextSibling; |
336 var li = document.createElement("li"); |
335 li = ed.dom.create("li"); |
337 li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); |
336 li.innerHTML = np.innerHTML.replace(new RegExp('' + mdot + '|' + bull + '|--list--| ', "gi"), ''); |
338 np.parentNode.removeChild(np); |
337 np.parentNode.removeChild(np); |
339 ul.appendChild(li); |
338 ul.appendChild(li); |
340 np = cp; |
339 np = cp; |
341 } |
340 } |