Changeset 1119
- Timestamp:
- 11/12/08 23:00:49 (5 years ago)
- Location:
- trunk
- Files:
-
- 2 modified
-
XinhaCore.js (modified) (135 diffs)
-
modules/Dialogs/XinhaDialog.js (modified) (37 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/XinhaCore.js
r1117 r1119 32 32 -- $LastChangedBy$ 33 33 --------------------------------------------------------------------------*/ 34 /*jslint regexp: false, rhino: false, browser: true, bitwise: false, forin: true, adsafe: false, evil: true, nomen: false, 35 glovar: false, debug: false, eqeqeq: false, passfail: false, sidebar: false, laxbreak: false, on: false, cap: true, 36 white: false, widget: false, undef: true, plusplus: false*/ 37 /*global Dialog , _editor_css , _editor_icons, _editor_lang , _editor_skin , _editor_url, dumpValues, ActiveXObject, HTMLArea, _editor_lcbackend*/ 34 38 35 39 Xinha.version = … … 37 41 'Release' : 'Trunk', 38 42 'Head' : '$HeadURL$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), 39 'Date' : '$LastChangedDate$'.replace(/^[^:]*:\s*([0-9 -]*) ([0-9:]*) ([+0-9]*) \((.*)\)\s*\$/, '$4 $2 $3'),43 'Date' : '$LastChangedDate$'.replace(/^[^:]*:\s*([0-9\-]*) ([0-9:]*) ([+0-9]*) \((.*)\)\s*\$/, '$4 $2 $3'), 40 44 'Revision' : '$LastChangedRevision$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1'), 41 45 'RevisionBy': '$LastChangedBy$'.replace(/^[^:]*:\s*(.*)\s*\$$/, '$1') … … 52 56 { 53 57 var b = base.split("/"); 54 if(b[b.length - 1] == "")58 if(b[b.length - 1] === "") 55 59 { 56 60 b.pop(); … … 68 72 return b.join("/") + "/" + p.join("/"); 69 73 } 70 } 74 }; 71 75 72 76 if ( typeof _editor_url == "string" ) … … 80 84 Xinha.tmpPath.pop(); 81 85 _editor_url = Xinha._resolveRelativeUrl(Xinha.tmpPath.join("/"), _editor_url); 82 delete (Xinha.tmpPath);86 delete Xinha.tmpPath; 83 87 } 84 88 } … … 156 160 */ 157 161 Xinha.is_webkit = (Xinha.agt.indexOf("applewebkit") != -1); 158 Xinha.webkit_version = parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,'$1') );162 Xinha.webkit_version = parseInt(navigator.appVersion.replace(/.*?AppleWebKit\/([\d]).*?/,'$1'), 10); 159 163 160 164 /** Browser is Safari … … 180 184 Xinha.is_gecko = (navigator.product == "Gecko") || Xinha.is_opera; 181 185 Xinha.is_real_gecko = (navigator.product == "Gecko" && !Xinha.is_webkit); 182 Xinha.is_ff3 = Xinha.is_real_gecko && parseInt(navigator.productSub ) >= 2007121016;183 Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub ) < 2007121016;186 Xinha.is_ff3 = Xinha.is_real_gecko && parseInt(navigator.productSub, 10) >= 2007121016; 187 Xinha.is_ff2 = Xinha.is_real_gecko && parseInt(navigator.productSub, 10) < 2007121016; 184 188 185 189 /** File is opened locally opened ("file://" protocol) … … 221 225 function Xinha(textarea, config) 222 226 { 223 if ( !Xinha.isSupportedBrowser ) return; 227 if ( !Xinha.isSupportedBrowser ) 228 { 229 return; 230 } 224 231 225 232 if ( !textarea ) … … 427 434 428 435 //hook in config.Events as as a "plugin" 429 this.plugins ['Events']=436 this.plugins.Events = 430 437 { 431 438 name: 'Events', … … 433 440 instance: config.Events 434 441 }; 435 } 436 442 }; 443 // ray: What is this for? Do we need it? 437 444 Xinha.onload = function() { }; 438 445 Xinha.init = function() { Xinha.onload(); }; … … 459 466 * @type RegExp 460 467 */ 461 Xinha.RE_Specials = /([\/\^$*+?.()|{} [\]])/g;468 Xinha.RE_Specials = /([\/\^$*+?.()|{}\[\]])/g; 462 469 /** When dynamically creating a RegExp from an arbtrary string, some charactes that have special meanings in regular expressions have to be escaped. 463 470 * Run any string through this function to escape reserved characters. … … 468 475 { 469 476 return string.replace(Xinha.RE_Specials, '\\$1'); 470 } 477 }; 471 478 /** Identifies email addresses 472 479 * @type RegExp … … 476 483 * @type RegExp 477 484 */ 478 Xinha.RE_url = /(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_ -]{2,}(\.[a-z0-9_-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i;485 Xinha.RE_url = /(https?:\/\/)?(([a-z0-9_]+:[a-z0-9_]+@)?[a-z0-9_\-]{2,}(\.[a-z0-9_\-]{2,}){2,}(:[0-9]+)?(\/\S+)*)/i; 479 486 480 487 … … 728 735 * @return {String} The processed HTML 729 736 */ 730 this.inwardHtml = function (html) { return html }737 this.inwardHtml = function (html) { return html; }; 731 738 732 739 /** A filter function for the generated HTML<br /> … … 736 743 * @return {String} The processed HTML 737 744 */ 738 this.outwardHtml = function (html) { return html }745 this.outwardHtml = function (html) { return html; }; 739 746 740 747 /** Set to true if you want Word code to be cleaned upon Paste. This only works if … … 1116 1123 dialogCaption : _editor_url + 'images/xinha-small-icon.gif', 1117 1124 wysiwygmode : [_editor_url + 'images/ed_buttons_main.png',7,1] 1118 } 1125 }; 1119 1126 // initialize tooltips from the I18N module and generate correct image path 1120 1127 for ( var i in this.btnList ) … … 1136 1143 btn[0] = Xinha._lc(btn[0]); //initialize tooltip 1137 1144 } 1138 1139 1145 }; 1140 1146 /** A plugin may require more than one icon for one button, this has to be registered in order to work with the iconsets (see FullScreen) … … 1146 1152 { 1147 1153 this.iconList[id] = icon; 1148 } 1154 }; 1149 1155 /** ADDING CUSTOM BUTTONS 1150 1156 * --------------------- … … 1187 1193 Xinha.Config.prototype.registerButton = function(id, tooltip, image, textMode, action, context) 1188 1194 { 1189 var the_id;1190 1195 if ( typeof id == "string" ) 1191 1196 { … … 1447 1452 var tas = document.getElementsByTagName("textarea"); 1448 1453 // @todo: weird syntax, doesnt help to read the code, doesnt obfuscate it and doesnt make it quicker, better rewrite this part 1449 for ( var i = tas.length; i > 0; (new Xinha(tas[--i], config)).generate() )1454 for ( var i = tas.length; i > 0; new Xinha(tas[--i], config).generate() ) 1450 1455 { 1451 1456 // NOP … … 1460 1465 { 1461 1466 var ta = Xinha.getElementById("textarea", id); 1462 return ta ? (new Xinha(ta, config)).generate() : null;1467 return ta ? new Xinha(ta, config).generate() : null; 1463 1468 }; 1464 1469 … … 1685 1690 { 1686 1691 // prevent iterating over wrong type 1687 if ( typeof (options[i])!= 'string' )1692 if ( typeof options[i] != 'string' ) 1688 1693 { 1689 1694 continue; … … 1970 1975 { 1971 1976 img = doc.createElement("span"); 1972 with (img.style)1977 /*with (img.style) 1973 1978 { 1974 1979 display = 'block'; … … 1976 1981 height = '18px'; 1977 1982 filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef+'")'; 1978 } 1983 }*/ 1984 1985 img.style.display = 'block'; 1986 img.style.width = '18px'; 1987 img.style.height = '18px'; 1988 img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef+'")'; 1989 1979 1990 } 1980 1991 else … … 1996 2007 { 1997 2008 img = doc.createElement("span"); 1998 with (img.style) 1999 { 2000 display='block'; 2001 width = '18px'; 2002 height = '18px'; 2003 filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef[0]+'")'; 2004 } 2009 img.style.display = 'block'; 2010 img.style.width = '18px'; 2011 img.style.height = '18px'; 2012 img.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'+imgDef+'")'; 2005 2013 } 2006 2014 else … … 2063 2071 Xinha.prototype.generate = function () 2064 2072 { 2065 if ( !Xinha.isSupportedBrowser ) return; 2073 if ( !Xinha.isSupportedBrowser ) 2074 { 2075 return; 2076 } 2066 2077 2067 2078 var i; … … 2099 2110 if ( !found ) 2100 2111 { 2101 Xinha.loadStyle('skins/' + _editor_skin + '/skin.css',null,"XinhaSkin") 2102 } 2103 } 2104 2112 Xinha.loadStyle('skins/' + _editor_skin + '/skin.css',null,"XinhaSkin"); 2113 } 2114 } 2115 var callback = function() { editor.generate(); }; 2105 2116 // Now load a specific browser plugin which will implement the above for us. 2106 2117 if (Xinha.is_ie) 2107 2118 { 2108 2119 url = _editor_url + 'modules/InternetExplorer/InternetExplorer.js'; 2109 if ( !Xinha.loadPlugins([{plugin:"InternetExplorer",url:url}], function() { editor.generate(); }) )2120 if ( !Xinha.loadPlugins([{plugin:"InternetExplorer",url:url}], callback ) ) 2110 2121 { 2111 2122 return false; 2112 2123 } 2113 if (!this.plugins['InternetExplorer']) editor._browserSpecificPlugin = editor.registerPlugin('InternetExplorer'); 2124 if (!this.plugins.InternetExplorer) 2125 { 2126 editor._browserSpecificPlugin = editor.registerPlugin('InternetExplorer'); 2127 } 2114 2128 } 2115 2129 else if (Xinha.is_webkit) 2116 2130 { 2117 2131 url = _editor_url + 'modules/WebKit/WebKit.js'; 2118 if ( !Xinha.loadPlugins([{plugin:"WebKit",url:url}], function() { editor.generate(); } ) ) 2119 { 2120 2132 if ( !Xinha.loadPlugins([{plugin:"WebKit",url:url}], callback ) ) 2133 { 2121 2134 return false; 2122 2135 } 2123 if (!this.plugins['Webkit']) editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); 2136 if (!this.plugins.Webkit) 2137 { 2138 editor._browserSpecificPlugin = editor.registerPlugin('WebKit'); 2139 } 2124 2140 } 2125 2141 else if (Xinha.is_opera) 2126 2142 { 2127 2143 url = _editor_url + 'modules/Opera/Opera.js'; 2128 if ( !Xinha.loadPlugins([{plugin:"Opera",url:url}], function() { editor.generate(); }) )2144 if ( !Xinha.loadPlugins([{plugin:"Opera",url:url}], callback ) ) 2129 2145 { 2130 2146 return false; 2131 2147 } 2132 if (!this.plugins['Opera']) editor._browserSpecificPlugin = editor.registerPlugin('Opera'); 2148 if (!this.plugins.Opera) 2149 { 2150 editor._browserSpecificPlugin = editor.registerPlugin('Opera'); 2151 } 2133 2152 } 2134 2153 else if (Xinha.is_gecko) 2135 2154 { 2136 2155 url = _editor_url + 'modules/Gecko/Gecko.js'; 2137 if ( !Xinha.loadPlugins([{plugin:"Gecko",url:url}], function() { editor.generate(); }) )2156 if ( !Xinha.loadPlugins([{plugin:"Gecko",url:url}], callback ) ) 2138 2157 { 2139 2158 return false; 2140 2159 } 2141 if (!this.plugins['Gecko']) editor._browserSpecificPlugin = editor.registerPlugin('Gecko'); 2142 } 2143 2144 if ( typeof Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/dialog.js', this.generate, this ) ) 2160 if (!this.plugins.Gecko) 2161 { 2162 editor._browserSpecificPlugin = editor.registerPlugin('Gecko'); 2163 } 2164 } 2165 2166 if ( typeof Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/dialog.js', callback, this ) ) 2145 2167 { 2146 2168 return false; 2147 2169 } 2148 2170 2149 if ( typeof Xinha.Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/XinhaDialog.js' , this.generate, this ) )2171 if ( typeof Xinha.Dialog == 'undefined' && !Xinha._loadback( _editor_url + 'modules/Dialogs/XinhaDialog.js' , callback, this ) ) 2150 2172 { 2151 2173 return false; … … 2153 2175 2154 2176 url = _editor_url + 'modules/FullScreen/full-screen.js'; 2155 if ( !Xinha.loadPlugins([{plugin:"FullScreen",url:url}], function() { editor.generate(); }))2177 if ( !Xinha.loadPlugins([{plugin:"FullScreen",url:url}], callback )) 2156 2178 { 2157 2179 return false; … … 2159 2181 2160 2182 url = _editor_url + 'modules/ColorPicker/ColorPicker.js'; 2161 if ( !Xinha.loadPlugins([{plugin:"ColorPicker",url:url}], function() { editor.generate(); }) )2183 if ( !Xinha.loadPlugins([{plugin:"ColorPicker",url:url}], callback ) ) 2162 2184 { 2163 2185 return false; 2164 2186 } 2165 else if ( typeof Xinha.getPluginConstructor('ColorPicker') != 'undefined' && !this.plugins['colorPicker']) editor.registerPlugin('ColorPicker'); 2187 else if ( typeof Xinha.getPluginConstructor('ColorPicker') != 'undefined' && !this.plugins.colorPicker) 2188 { 2189 editor.registerPlugin('ColorPicker'); 2190 } 2166 2191 2167 2192 var toolbar = editor.config.toolbar; … … 2173 2198 { 2174 2199 case "popupeditor": 2175 if (!this.plugins['FullScreen']) editor.registerPlugin('FullScreen'); 2200 if (!this.plugins.FullScreen) 2201 { 2202 editor.registerPlugin('FullScreen'); 2203 } 2176 2204 break; 2177 2205 case "insertimage": 2178 2206 url = _editor_url + 'modules/InsertImage/insert_image.js'; 2179 if ( typeof Xinha.prototype._insertImage == 'undefined' && !Xinha.loadPlugins([{plugin:"InsertImage",url:url}], function() { editor.generate(); }) )2207 if ( typeof Xinha.prototype._insertImage == 'undefined' && !Xinha.loadPlugins([{plugin:"InsertImage",url:url}], callback ) ) 2180 2208 { 2181 2209 return false; 2182 2210 } 2183 else if ( typeof Xinha.getPluginConstructor('InsertImage') != 'undefined' && !this.plugins['InsertImage']) editor.registerPlugin('InsertImage'); 2211 else if ( typeof Xinha.getPluginConstructor('InsertImage') != 'undefined' && !this.plugins.InsertImage) 2212 { 2213 editor.registerPlugin('InsertImage'); 2214 } 2184 2215 break; 2185 2216 case "createlink": 2186 2217 url = _editor_url + 'modules/CreateLink/link.js'; 2187 if ( typeof Xinha.getPluginConstructor('Linker') == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], function() { editor.generate(); }))2218 if ( typeof Xinha.getPluginConstructor('Linker') == 'undefined' && !Xinha.loadPlugins([{plugin:"CreateLink",url:url}], callback )) 2188 2219 { 2189 2220 return false; 2190 2221 } 2191 else if ( typeof Xinha.getPluginConstructor('CreateLink') != 'undefined' && !this.plugins['CreateLink']) editor.registerPlugin('CreateLink'); 2222 else if ( typeof Xinha.getPluginConstructor('CreateLink') != 'undefined' && !this.plugins.CreateLink) 2223 { 2224 editor.registerPlugin('CreateLink'); 2225 } 2192 2226 break; 2193 2227 case "inserttable": 2194 2228 url = _editor_url + 'modules/InsertTable/insert_table.js'; 2195 if ( !Xinha.loadPlugins([{plugin:"InsertTable",url:url}], function() { editor.generate(); }) )2229 if ( !Xinha.loadPlugins([{plugin:"InsertTable",url:url}], callback ) ) 2196 2230 { 2197 2231 return false; 2198 2232 } 2199 else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins['InsertTable']) editor.registerPlugin('InsertTable'); 2233 else if ( typeof Xinha.getPluginConstructor('InsertTable') != 'undefined' && !this.plugins.InsertTable) 2234 { 2235 editor.registerPlugin('InsertTable'); 2236 } 2200 2237 break; 2201 2238 case "about": 2202 2239 url = _editor_url + 'modules/AboutBox/AboutBox.js'; 2203 if ( !Xinha.loadPlugins([{plugin:"AboutBox",url:url}], function() { editor.generate(); }) )2240 if ( !Xinha.loadPlugins([{plugin:"AboutBox",url:url}], callback ) ) 2204 2241 { 2205 2242 return false; 2206 2243 } 2207 else if ( typeof Xinha.getPluginConstructor('AboutBox') != 'undefined' && !this.plugins['AboutBox']) editor.registerPlugin('AboutBox'); 2244 else if ( typeof Xinha.getPluginConstructor('AboutBox') != 'undefined' && !this.plugins.AboutBox) 2245 { 2246 editor.registerPlugin('AboutBox'); 2247 } 2208 2248 break; 2209 2249 } … … 2214 2254 if ( Xinha.is_gecko && editor.config.mozParaHandler != 'built-in' ) 2215 2255 { 2216 if ( !Xinha.loadPlugins([{plugin:"EnterParagraphs",url: _editor_url + 'modules/Gecko/paraHandlerBest.js'}], function() { editor.generate(); }) )2256 if ( !Xinha.loadPlugins([{plugin:"EnterParagraphs",url: _editor_url + 'modules/Gecko/paraHandlerBest.js'}], callback ) ) 2217 2257 { 2218 2258 return false; 2219 2259 } 2220 if (!this.plugins ['EnterParagraphs']) editor.registerPlugin('EnterParagraphs');2221 }2222 2223 switch (this.config.getHtmlMethod)2224 {2225 case 'TransformInnerHTML':2226 var getHtmlMethodPlugin = _editor_url + 'modules/GetHtml/TransformInnerHTML.js'; 2227 break;2228 default:2229 var getHtmlMethodPlugin = _editor_url + 'modules/GetHtml/DOMwalk.js';2230 break;2231 }2232 2233 if ( !Xinha.loadPlugins([{plugin:"GetHtmlImplementation",url:getHtmlMethodPlugin}], function() { editor.generate(); }))2234 {2235 return false;2236 }2237 else if (!this.plugins['GetHtmlImplementation']) editor.registerPlugin('GetHtmlImplementation');2238 2260 if (!this.plugins.EnterParagraphs) 2261 { 2262 editor.registerPlugin('EnterParagraphs'); 2263 } 2264 } 2265 var getHtmlMethodPlugin = this.config.getHtmlMethod == 'TransformInnerHTML' ? _editor_url + 'modules/GetHtml/TransformInnerHTML.js' : _editor_url + 'modules/GetHtml/DOMwalk.js'; 2266 2267 if ( !Xinha.loadPlugins([{plugin:"GetHtmlImplementation",url:getHtmlMethodPlugin}], callback)) 2268 { 2269 return false; 2270 } 2271 else if (!this.plugins.GetHtmlImplementation) 2272 { 2273 editor.registerPlugin('GetHtmlImplementation'); 2274 } 2275 function getTextContent(node) 2276 { 2277 return node.textContent || node.text; 2278 } 2239 2279 if (_editor_skin) 2240 2280 { … … 2244 2284 { 2245 2285 var meta = skinXML.getElementsByTagName('meta'); 2246 for ( vari=0;i<meta.length;i++)2286 for (i=0;i<meta.length;i++) 2247 2287 { 2248 2288 this.skinInfo[meta[i].getAttribute('name')] = meta[i].getAttribute('value'); 2249 2289 } 2250 2290 var recommendedIcons = skinXML.getElementsByTagName('recommendedIcons'); 2251 if (!_editor_icons && recommendedIcons.length && recommendedIcons[0].textContent)2252 { 2253 _editor_icons = recommendedIcons[0].textContent;2291 if (!_editor_icons && recommendedIcons.length && getTextContent(recommendedIcons[0])) 2292 { 2293 _editor_icons = getTextContent(recommendedIcons[0]); 2254 2294 } 2255 2295 } … … 2258 2298 { 2259 2299 var iconsXML = Xinha._geturlcontent(_editor_url + 'iconsets/' + _editor_icons + '/iconset.xml', true); 2300 2260 2301 if (iconsXML) 2261 2302 { 2262 2303 var icons = iconsXML.getElementsByTagName('icon'); 2263 2304 var icon, id, path, type, x, y; 2264 function getTextContent(node) 2265 { 2266 return node.textContent || node.text; 2267 } 2268 for (var i=0;i<icons.length;i++) 2305 2306 for (i=0;i<icons.length;i++) 2269 2307 { 2270 2308 icon = icons[i]; … … 2286 2324 x = parseInt(getTextContent(icon.getElementsByTagName('x')[0]), 10); 2287 2325 y = parseInt(getTextContent(icon.getElementsByTagName('y')[0]), 10); 2288 if (this.config.btnList[id]) this.config.btnList[id][1] = [path, x, y]; 2289 if (this.config.iconList[id]) this.config.iconList[id] = [path, x, y]; 2326 if (this.config.btnList[id]) 2327 { 2328 this.config.btnList[id][1] = [path, x, y]; 2329 } 2330 if (this.config.iconList[id]) 2331 { 2332 this.config.iconList[id] = [path, x, y]; 2333 } 2290 2334 2291 2335 } 2292 2336 else 2293 2337 { 2294 if (this.config.btnList[id]) this.config.btnList[id][1] = path; 2295 if (this.config.iconList[id]) this.config.iconList[id] = path; 2338 if (this.config.btnList[id]) 2339 { 2340 this.config.btnList[id][1] = path; 2341 } 2342 if (this.config.iconList[id]) 2343 { 2344 this.config.iconList[id] = path; 2345 } 2296 2346 } 2297 2347 } … … 2454 2504 this.onsubmit(); 2455 2505 this.xinha_submit(); 2456 } 2506 }; 2457 2507 } catch(ex) {} 2458 2508 } … … 2485 2535 // Add an event to initialize the iframe once loaded. 2486 2536 editor._iframeLoadDone = false; 2487 if (Xinha.is_opera) 2488 { 2489 editor.initIframe(); 2490 } 2491 else 2537 if (Xinha.is_opera) 2538 { 2539 editor.initIframe(); 2540 } 2541 else 2542 { 2492 2543 Xinha._addEvent( 2493 2544 this._iframe, … … 2503 2554 } 2504 2555 ); 2556 } 2505 2557 }; 2506 2558 … … 2547 2599 break; 2548 2600 } 2549 2550 switch ( this.config.height )2551 {2552 case 'auto':2553 height = this._initial_ta_size.h;2554 break;2555 2556 default :2557 2601 // @todo: check if this is better : 2558 2602 // height = (parseInt(this.config.height, 10) == this.config.height)? this.config.height + 'px' : this.config.height; 2559 height = /[^0-9]/.test(this.config.height) ? this.config.height : this.config.height + 'px'; 2560 break; 2561 } 2562 2603 height = this.config.height == 'auto' ? this._initial_ta_size.h : /[^0-9]/.test(this.config.height) ? this.config.height : this.config.height + 'px'; 2604 2563 2605 this.sizeEditor(width, height, this.config.sizeIncludesBars, this.config.sizeIncludesPanels); 2564 2606 … … 2577 2619 Xinha.prototype.sizeEditor = function(width, height, includingBars, includingPanels) 2578 2620 { 2579 if (this._risizing) return; 2621 if (this._risizing) 2622 { 2623 return; 2624 } 2580 2625 this._risizing = true; 2581 2626 … … 2767 2812 edcellwidth -= parseInt(this.config.panel_dimensions.right, 10); 2768 2813 } 2769 var iframeWidth = (this.config.iframeWidth)? parseInt(this.config.iframeWidth,10): null;2770 this._iframe.style.width = (iframeWidth && iframeWidth < edcellwidth) ? iframeWidth + "px": edcellwidth + "px";2814 var iframeWidth = this.config.iframeWidth ? parseInt(this.config.iframeWidth,10) : null; 2815 this._iframe.style.width = (iframeWidth && iframeWidth < edcellwidth) ? iframeWidth + "px": edcellwidth + "px"; 2771 2816 2772 2817 this._textArea.style.height = this._iframe.style.height; … … 2806 2851 { 2807 2852 div.style.width = this.config.panel_dimensions[side]; 2808 if(this._iframe) div.style.height = this._iframe.style.height; 2853 if (this._iframe) 2854 { 2855 div.style.height = this._iframe.style.height; 2856 } 2809 2857 } 2810 2858 Xinha.addClasses(div, 'panel'); … … 2845 2893 this.notifyOf('panel_change', {'action':'hide','panel':panel}); 2846 2894 this.firePluginEvent('onPanelChange','hide',panel); 2847 try { this._iframe.contentWindow.scrollTo(pos.x,pos.y) } catch(e) { }2895 try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } 2848 2896 } 2849 2897 }; … … 2859 2907 this.notifyOf('panel_change', {'action':'show','panel':panel}); 2860 2908 this.firePluginEvent('onPanelChange','show',panel); 2861 try { this._iframe.contentWindow.scrollTo(pos.x,pos.y) } catch(e) { }2909 try { this._iframe.contentWindow.scrollTo(pos.x,pos.y); } catch(e) { } 2862 2910 } 2863 2911 }; … … 2959 3007 Xinha.prototype.activateEditor = function() 2960 3008 { 2961 if (this.currentModal) return; 2962 3009 if (this.currentModal) 3010 { 3011 return; 3012 } 2963 3013 // We only want ONE editor at a time to be active 2964 3014 if ( Xinha._currentlyActiveEditor ) … … 3071 3121 3072 3122 doc.open("text/html","replace"); 3073 var html = '' ;3123 var html = '', doctype; 3074 3124 if ( editor.config.browserQuirksMode === false ) 3075 3125 { 3076 vardoctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';3126 doctype = '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'; 3077 3127 } 3078 3128 else if ( editor.config.browserQuirksMode === true ) 3079 3129 { 3080 vardoctype = '';3130 doctype = ''; 3081 3131 } 3082 3132 else 3083 3133 { 3084 var doctype = Xinha.getDoctype(document); 3085 } 3134 doctype = Xinha.getDoctype(document); 3135 } 3136 3086 3137 if ( !editor.config.fullPage ) 3087 3138 { … … 3132 3183 var match = html.match(/<link\s+[\s\S]*?["']\s*\/?>/gi); 3133 3184 html = html.replace(/<link\s+[\s\S]*?["']\s*\/?>\s*/gi, ''); 3134 match ? html = html.replace(/<\/head>/i, match.join('\n') + "\n</head>") : null; 3185 if (match) 3186 { 3187 html = html.replace(/<\/head>/i, match.join('\n') + "\n</head>"); 3188 } 3135 3189 } 3136 3190 doc.write(html); … … 3313 3367 { 3314 3368 var r = editor._doc.body.createTextRange(); 3315 r.collapse(); 3316 r.select() 3369 r.collapse(); 3370 r.select(); 3317 3371 //setTimeout (function () { r.collapse(); r.select();},100); // won't do without timeout, dunno why 3318 3372 } … … 3367 3421 { 3368 3422 return Xinha.plugins[pluginName] || window[pluginName]; 3369 } 3423 }; 3370 3424 3371 3425 /** Create the specified plugin and register it with this Xinha … … 3375 3429 Xinha.prototype.registerPlugin = function() 3376 3430 { 3377 if ( !Xinha.isSupportedBrowser ) return; 3378 3431 if (!Xinha.isSupportedBrowser) 3432 { 3433 return; 3434 } 3379 3435 var plugin = arguments[0]; 3380 3436 … … 3409 3465 return false; 3410 3466 } 3411 if (!plugin._pluginInfo) plugin._pluginInfo = {name:pluginName}; 3467 if (!plugin._pluginInfo) 3468 { 3469 plugin._pluginInfo = 3470 { 3471 name: pluginName 3472 }; 3473 } 3412 3474 var obj = new plugin(this, args); 3413 3475 if ( obj ) … … 3452 3514 } 3453 3515 return _editor_url + "plugins/" + plugin ; 3454 } 3516 }; 3455 3517 /** Static function that loads the given plugin 3456 3518 * @param {String} pluginName … … 3461 3523 Xinha.loadPlugin = function(pluginName, callback, url) 3462 3524 { 3463 if ( !Xinha.isSupportedBrowser ) return; 3464 3525 if (!Xinha.isSupportedBrowser) 3526 { 3527 return; 3528 } 3465 3529 Xinha.setLoadingMessage (Xinha._lc("Loading plugin $plugin="+pluginName+"$")); 3466 3530 … … 3476 3540 Xinha._pluginLoadStatus[pluginName] = 'loading'; 3477 3541 3478 if(!url)3479 {3480 if (Xinha.externalPlugins[pluginName])3481 {3482 Xinha._loadback(Xinha.externalPlugins[pluginName][0]+Xinha.externalPlugins[pluginName][1], callback, this, pluginName);3483 }3484 else3485 {3486 var editor = this;3487 multiStageLoader('start',pluginName);3488 }3489 }3490 3491 return false;3492 3493 3542 // This function will try to load a plugin in multiple passes. It tries to 3494 3543 // load the plugin from either the plugin or unsupported directory, using … … 3501 3550 function multiStageLoader(stage,pluginName) 3502 3551 { 3552 var nextstage, dir, file, success_message; 3503 3553 switch (stage) 3504 3554 { 3505 3555 case 'start': 3506 varnextstage = 'old_naming';3507 var dir = editor.getPluginDir(pluginName);3508 varfile = pluginName + ".js";3556 nextstage = 'old_naming'; 3557 dir = Xinha.getPluginDir(pluginName); 3558 file = pluginName + ".js"; 3509 3559 break; 3510 3560 case 'old_naming': 3511 varnextstage = 'unsupported';3512 var dir = editor.getPluginDir(pluginName);3513 varfile = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js";3514 varsuccess_message = 'You are using an obsolete naming scheme for the Xinha plugin '+pluginName+'. Please rename '+file+' to '+pluginName+'.js';3561 nextstage = 'unsupported'; 3562 dir = Xinha.getPluginDir(pluginName); 3563 file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; 3564 success_message = 'You are using an obsolete naming scheme for the Xinha plugin '+pluginName+'. Please rename '+file+' to '+pluginName+'.js'; 3515 3565 break; 3516 3566 case 'unsupported': 3517 varnextstage = 'unsupported_old_name';3518 var dir = editor.getPluginDir(pluginName, true);3519 varfile = pluginName + ".js";3520 varsuccess_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297';3567 nextstage = 'unsupported_old_name'; 3568 dir = Xinha.getPluginDir(pluginName, true); 3569 file = pluginName + ".js"; 3570 success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297'; 3521 3571 break; 3522 3572 case 'unsupported_old_name': 3523 varnextstage = '';3524 var dir = editor.getPluginDir(pluginName, true);3525 varfile = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js";3526 varsuccess_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297';3573 nextstage = ''; 3574 dir = Xinha.getPluginDir(pluginName, true); 3575 file = pluginName.replace(/([a-z])([A-Z])([a-z])/g, function (str, l1, l2, l3) { return l1 + "-" + l2.toLowerCase() + l3; }).toLowerCase() + ".js"; 3576 success_message = 'You are using the unsupported Xinha plugin '+pluginName+'. If you wish continued support, please see http://trac.xinha.org/ticket/1297'; 3527 3577 break; 3528 3578 default: 3529 3579 Xinha._pluginLoadStatus[pluginName] = 'failed'; 3530 Xinha.debugMsg('Xinha was not able to find the plugin '+pluginName+'. Please make sure the plugin exists.', 'warn') 3580 Xinha.debugMsg('Xinha was not able to find the plugin '+pluginName+'. Please make sure the plugin exists.', 'warn'); 3531 3581 return; 3532 3582 } … … 3537 3587 function statusCallback(pluginName) 3538 3588 { 3539 Xinha.getPluginConstructor(pluginName).supported = stage.indexOf('unsupported') != 0;3589 Xinha.getPluginConstructor(pluginName).supported = stage.indexOf('unsupported') !== 0; 3540 3590 callback(pluginName); 3541 3591 } … … 3549 3599 function() 3550 3600 { 3551 if (success_message) Xinha.debugMsg(success_message); 3601 if (success_message) 3602 { 3603 Xinha.debugMsg(success_message); 3604 } 3552 3605 }, 3553 3606 // On failure, we'll clean up the failed load and try the next stage … … 3558 3611 }); 3559 3612 } 3613 3614 if(!url) 3615 { 3616 if (Xinha.externalPlugins[pluginName]) 3617 { 3618 Xinha._loadback(Xinha.externalPlugins[pluginName][0]+Xinha.externalPlugins[pluginName][1], callback, this, pluginName); 3619 } 3620 else 3621 { 3622 var editor = this; 3623 multiStageLoader('start',pluginName); 3624 } 3625 } 3626 3627 return false; 3560 3628 }; 3561 3629 /** Stores a status for each loading plugin that may be one of "loading","ready", or "failed" … … 3583 3651 Xinha.loadPlugins = function(plugins, callbackIfNotReady,url) 3584 3652 { 3585 if ( !Xinha.isSupportedBrowser ) return; 3653 if (!Xinha.isSupportedBrowser) 3654 { 3655 return; 3656 } 3586 3657 //Xinha.setLoadingMessage (Xinha._lc("Loading plugins")); 3587 var m ;3588 for ( vari=0;i<plugins.length;i++)3658 var m,i; 3659 for (i=0;i<plugins.length;i++) 3589 3660 { 3590 3661 if (typeof plugins[i] == 'object') … … 3599 3670 var retVal = true; 3600 3671 var nuPlugins = Xinha.cloneObject(plugins); 3601 for ( vari=0;i<nuPlugins.length;i++ )3672 for (i=0;i<nuPlugins.length;i++ ) 3602 3673 { 3603 3674 var p = nuPlugins[i]; 3604 3675 3605 if (p == 'FullScreen' && !Xinha.externalPlugins['FullScreen'] ) continue; //prevent trying to load FullScreen plugin from the plugins folder 3676 if (p == 'FullScreen' && !Xinha.externalPlugins.FullScreen) 3677 { 3678 continue; //prevent trying to load FullScreen plugin from the plugins folder 3679 } 3606 3680 3607 3681 if ( typeof Xinha._pluginLoadStatus[p] == 'undefined') … … 3621 3695 Xinha._pluginLoadStatus[plugin] = 'failed'; 3622 3696 } 3623 }, url 3624 ); 3697 }, url); 3625 3698 retVal = false; 3626 3699 } … … 3709 3782 } 3710 3783 3711 for ( vari in this.plugins )3784 for ( i in this.plugins ) 3712 3785 { 3713 3786 var plugin = this.plugins[i].instance; 3714 3787 3715 3788 // Skip the browser specific plugin 3716 if ( plugin == this._browserSpecificPlugin) continue; 3717 3789 if (plugin == this._browserSpecificPlugin) 3790 { 3791 continue; 3792 } 3718 3793 if ( plugin && typeof plugin[methodName] == "function" ) 3719 3794 { … … 3727 3802 3728 3803 // Now the browser speific 3729 varplugin = this._browserSpecificPlugin;3804 plugin = this._browserSpecificPlugin; 3730 3805 if ( plugin && typeof plugin[methodName] == "function" ) 3731 3806 { … … 3736 3811 } 3737 3812 return false; 3738 } 3813 }; 3739 3814 /** Adds a stylesheet to the document 3740 3815 * @param {String} style name of the stylesheet file … … 3765 3840 link.href = url; 3766 3841 link.type = "text/css"; 3767 if (id) link.id = id; 3842 if (id) 3843 { 3844 link.id = id; 3845 } 3768 3846 if (prepend && head.getElementsByTagName('link')[0]) 3769 3847 { … … 3848 3926 mso_xmlel : 0, 3849 3927 orig_len : this._doc.body.innerHTML.length, 3850 T : (new Date()).getTime()3928 T : new Date().getTime() 3851 3929 }; 3852 3930 var stats_txt = … … 3872 3950 txt += "\nInitial document length: " + stats.orig_len + "\n"; 3873 3951 txt += "Final document length: " + editor._doc.body.innerHTML.length + "\n"; 3874 txt += "Clean-up took " + (( (new Date()).getTime() - stats.T) / 1000) + " seconds";3952 txt += "Clean-up took " + ((new Date().getTime() - stats.T) / 1000) + " seconds"; 3875 3953 alert(txt); 3876 3954 } … … 3882 3960 { 3883 3961 node.className = newc; 3884 if ( ! ( /\S/.test(node.className) ))3962 if ( !/\S/.test(node.className)) 3885 3963 { 3886 3964 node.removeAttribute("className"); … … 3895 3973 for ( var i = declarations.length; --i >= 0; ) 3896 3974 { 3897 if ( ( /^mso|^tab-stops/i.test(declarations[i]) ) || ( /^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i])) )3975 if ( /^mso|^tab-stops/i.test(declarations[i]) || /^margin\s*:\s*0..\s+0..\s+0../i.test(declarations[i]) ) 3898 3976 { 3899 3977 ++stats.mso_style; … … 3906 3984 function removeElements(el) 3907 3985 { 3908 if (( ('link' == el.tagName.toLowerCase()) &&3909 (el.attributes && /File-List|Edit-Time-Data|themeData|colorSchemeMapping/.test(el.attributes ['rel'].nodeValue))) ||3910 (/^(style|meta)$/i.test(el.tagName)))3986 if (('link' == el.tagName.toLowerCase() && 3987 (el.attributes && /File-List|Edit-Time-Data|themeData|colorSchemeMapping/.test(el.attributes.rel.nodeValue))) || 3988 /^(style|meta)$/i.test(el.tagName)) 3911 3989 { 3912 3990 Xinha.removeFromParent(el); … … 3934 4012 clearClass(root); 3935 4013 clearStyle(root); 3936 4014 var next; 3937 4015 for (var i = root.firstChild; i; i = next ) 3938 4016 { 3939 varnext = i.nextSibling;4017 next = i.nextSibling; 3940 4018 if ( i.nodeType == 1 && parseTree(i) ) 3941 4019 { … … 4018 4096 { 4019 4097 D = D.replace(/color="[^"]*"/gi, ''); 4020 D = D.replace(/([^ -])color:[^;}"']+;?/gi, '$1');4098 D = D.replace(/([^\-])color:[^;}"']+;?/gi, '$1'); 4021 4099 } 4022 4100 … … 4163 4241 } 4164 4242 // prevent iterating over wrong type 4165 if ( typeof (btn.state)!= 'function' )4243 if ( typeof btn.state != 'function' ) 4166 4244 { 4167 4245 continue; … … 4186 4264 Xinha.prototype.updateToolbar = function(noStatus) 4187 4265 { 4188 if (this.suspendUpdateToolbar) return; 4189 4266 if (this.suspendUpdateToolbar) 4267 { 4268 return; 4269 } 4190 4270 var doc = this._doc; 4191 4271 var text = (this._editMode == "textmode"); … … 4203 4283 item.onclick = null; 4204 4284 item.oncontextmenu = null; 4205 item._xinha_dom0Events ['click']= null;4206 item._xinha_dom0Events ['contextmenu']= null;4285 item._xinha_dom0Events.click = null; 4286 item._xinha_dom0Events.contextmenu = null; 4207 4287 item = null; 4208 4288 } … … 4221 4301 } 4222 4302 var a = document.createElement("a"); 4223 a.href = "javascript:void(0) ";4303 a.href = "javascript:void(0);"; 4224 4304 a.el = el; 4225 4305 a.editor = this; … … 4249 4329 ); 4250 4330 var txt = el.tagName.toLowerCase(); 4251 if (typeof el.style != 'undefined') a.title = el.style.cssText; 4331 if (typeof el.style != 'undefined') 4332 { 4333 a.title = el.style.cssText; 4334 } 4252 4335 if ( el.id ) 4253 4336 { … … 4274 4357 var inContext = true; 4275 4358 // prevent iterating over wrong type 4276 if ( typeof (btn.state)!= 'function' )4359 if ( typeof btn.state != 'function' ) 4277 4360 { 4278 4361 continue; … … 4498 4581 return this.plugins[plugin].instance; 4499 4582 } 4500 else return null; 4583 else 4584 { 4585 return null; 4586 } 4501 4587 }; 4502 4588 /** Returns an array with all the ancestor nodes of the selection or current cursor position. … … 4889 4975 case 'justifyleft' : 4890 4976 case 'justifyright' : 4891 {4892 4977 cmdID.match(/^justify(.*)$/); 4893 4978 var ae = this.activeElement(this.getSelection()); … … 4900 4985 this._doc.execCommand(cmdID, UI, param); 4901 4986 } 4902 }4903 4987 break; 4904 4988 … … 5052 5136 { 5053 5137 e = this.getParentElement(); 5054 if(!e) return; 5138 if(!e) 5139 { 5140 return; 5141 } 5055 5142 } 5056 5143 … … 5068 5155 { 5069 5156 return this.outwardHtml(this.getHTML()); 5070 } 5157 }; 5071 5158 5072 5159 /** Completely change the HTML inside the editor … … 5078 5165 { 5079 5166 this.setHTML(this.inwardHtml(html)); 5080 } 5167 }; 5081 5168 5082 5169 /** Get the raw edited HTML, should not be used without Xinha.prototype.outwardHtml() … … 5293 5380 { 5294 5381 if ( typeof this.config.expandRelativeUrl != 'undefined' && this.config.expandRelativeUrl ) 5295 var src = html.match(/(src|href)="([^"]*)"/gi); 5296 var b = document.location.href; 5297 if ( src ) 5298 { 5299 var url,url_m,relPath,base_m,absPath 5300 for ( var i=0;i<src.length;++i ) 5301 { 5302 url = src[i].match(/(src|href)="([^"]*)"/i); 5303 url_m = url[2].match( /\.\.\//g ); 5304 if ( url_m ) 5305 { 5306 relPath = new RegExp( "(.*?)(([^\/]*\/){"+ url_m.length+"})[^\/]*$" ); 5307 base_m = b.match( relPath ); 5308 absPath = url[2].replace(/(\.\.\/)*/,base_m[1]); 5309 html = html.replace( new RegExp(Xinha.escapeStringForRegExp(url[2])),absPath ); 5382 { 5383 var src = html.match(/(src|href)="([^"]*)"/gi); 5384 var b = document.location.href; 5385 if ( src ) 5386 { 5387 var url,url_m,relPath,base_m,absPath; 5388 for ( var i=0;i<src.length;++i ) 5389 { 5390 url = src[i].match(/(src|href)="([^"]*)"/i); 5391 url_m = url[2].match( /\.\.\//g ); 5392 if ( url_m ) 5393 { 5394 relPath = new RegExp( "(.*?)(([^\/]*\/){"+ url_m.length+"})[^\/]*$" ); 5395 base_m = b.match( relPath ); 5396 absPath = url[2].replace(/(\.\.\/)*/,base_m[1]); 5397 html = html.replace( new RegExp(Xinha.escapeStringForRegExp(url[2])),absPath ); 5398 } 5310 5399 } 5311 5400 } … … 5314 5403 if ( typeof this.config.stripSelfNamedAnchors != 'undefined' && this.config.stripSelfNamedAnchors ) 5315 5404 { 5316 var stripRe = new RegExp("((href|src|background)=\")("+Xinha.escapeStringForRegExp( unescape(document.location.href.replace(/&/g,'&'))) + ')([#?][^\'" ]*)', 'g');5405 var stripRe = new RegExp("((href|src|background)=\")("+Xinha.escapeStringForRegExp(window.unescape(document.location.href.replace(/&/g,'&'))) + ')([#?][^\'" ]*)', 'g'); 5317 5406 html = html.replace(stripRe, '$1$4'); 5318 5407 } … … 5427 5516 return null; 5428 5517 } 5429 var newObj = (obj.isArray )? [] : {};5518 var newObj = obj.isArray ? [] : {}; 5430 5519 5431 5520 // check for function and RegExp objects (as usual, IE is fucked up) … … 5650 5739 { 5651 5740 // quit if this function has already been called 5652 if (arguments.callee.done) return; 5741 if (arguments.callee.done) 5742 { 5743 return; 5744 } 5653 5745 // flag this function so we don't do the same thing twice 5654 5746 arguments.callee.done = true; 5655 5747 // kill the timer 5656 if (Xinha.onloadTimer) clearInterval(Xinha.onloadTimer); 5748 if (Xinha.onloadTimer) 5749 { 5750 clearInterval(Xinha.onloadTimer); 5751 } 5657 5752 5658 5753 func(); 5659 } 5754 }; 5660 5755 if (Xinha.is_ie) 5661 5756 { … … 5739 5834 { 5740 5835 return ev || window.event; 5741 } 5836 }; 5742 5837 /** 5743 5838 * Prepares an element to receive more than one DOM-0 event handler … … 5875 5970 Xinha.htmlEncode = function(str) 5876 5971 { 5877 if (!str) return ''; 5878 if ( typeof str.replace == 'undefined' ) 5972 if (!str) 5973 { 5974 return ''; 5975 } if ( typeof str.replace == 'undefined' ) 5879 5976 { 5880 5977 str = str.toString(); … … 6031 6128 var plugin = RegExp.$1; 6032 6129 var popup = RegExp.$2; 6033 if ( ! ( /\.(html?|php)$/.test(popup)) )6130 if ( !/\.(html?|php)$/.test(popup) ) 6034 6131 { 6035 6132 popup += ".html"; … … 6113 6210 Xinha.addCoreCSS = function(html) 6114 6211 { 6115 var coreCSS = 6116 "<style title=\"XinhaInternalCSS\" type=\"text/css\">" 6117 + ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\n" 6118 + "html, body { border: 0px; } \n" 6119 + "body { background-color: #ffffff; } \n" 6120 + "img, hr { cursor: default } \n" 6121 +"</style>\n"; 6212 var coreCSS = "<style title=\"XinhaInternalCSS\" type=\"text/css\">" + 6213 ".htmtableborders, .htmtableborders td, .htmtableborders th {border : 1px dashed lightgrey ! important;}\n" + 6214 "html, body { border: 0px; } \n" + 6215 "body { background-color: #ffffff; } \n" + 6216 "img, hr { cursor: default } \n" + 6217 "</style>\n"; 6122 6218 6123 6219 if( html && /<head>/i.test(html)) … … 6133 6229 return coreCSS; 6134 6230 } 6135 } 6231 }; 6136 6232 /** Allows plugins to add a stylesheet for internal use to the edited document that won't appear in the HTML output 6137 6233 * … … 6145 6241 style.type = 'text/css'; 6146 6242 style.title = 'XinhaInternalCSS'; 6147 style.href = stylesheet;6243 style.href = stylesheet; 6148 6244 this._doc.getElementsByTagName("HEAD")[0].appendChild(style); 6149 } 6245 }; 6150 6246 /** Remove internal styles 6151 6247 * … … 6158 6254 { 6159 6255 return html.replace(/<style[^>]+title="XinhaInternalCSS"(.|\n)*?<\/style>/ig, '').replace(/<link[^>]+title="XinhaInternalCSS"(.|\n)*?>/ig, ''); 6160 } 6256 }; 6161 6257 /** Removes one CSS class (that is one of possible more parts 6162 6258 * separated by spaces) from a given element … … 6339 6435 if ( req.readyState == 4 ) 6340 6436 { 6341 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status == 0 )6437 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) 6342 6438 { 6343 6439 if ( typeof success == 'function' ) … … 6388 6484 if ( req.readyState == 4 ) 6389 6485 { 6390 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status == 0 )6486 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) 6391 6487 { 6392 6488 success(req.responseText, req); … … 6417 6513 if ( req.readyState == 4 ) 6418 6514 { 6419 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status == 0 ) 6420 { 6421 if (successHandler) successHandler(req); 6515 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) 6516 { 6517 if (successHandler) 6518 { 6519 successHandler(req); 6520 } 6422 6521 } 6423 6522 else 6424 6523 { 6425 if (failHandler) failHandler(req) 6524 if (failHandler) 6525 { 6526 failHandler(req); 6527 } 6426 6528 } 6427 6529 } … … 6448 6550 req.open('GET', url, false); 6449 6551 req.send(null); 6450 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status == 0 )6552 if ( ((req.status / 100) == 2) || Xinha.isRunLocally && req.status === 0 ) 6451 6553 { 6452 6554 return (returnXML) ? req.responseXML : req.responseText; … … 6462 6564 if (typeof dumpValues == 'undefined') 6463 6565 { 6464 function dumpValues(o)6566 dumpValues = function(o) 6465 6567 { 6466 6568 var s = ''; … … 6470 6572 { 6471 6573 if (typeof console.firebug != 'undefined') 6574 { 6472 6575 console.log(o); 6576 } 6473 6577 else 6578 { 6474 6579 console.log(prop + ' = ' + o[prop] + '\n'); 6580 } 6475 6581 } 6476 6582 else … … 6492 6598 6493 6599 } 6494 } 6600 }; 6495 6601 } 6496 6602 if ( !Array.prototype.contains ) … … 6559 6665 var len = this.length; 6560 6666 if (typeof fn != "function") 6667 { 6561 6668 throw new TypeError(); 6669 } 6562 6670 6563 6671 var thisObject = arguments[1]; … … 6565 6673 { 6566 6674 if (i in this) 6675 { 6567 6676 fn.call(thisObject, this[i], i, this); 6677 } 6568 6678 } 6569 6679 }; … … 6583 6693 { 6584 6694 classNames = els[i].className.split(' '); 6585 if (classNames.contains(className)) result.push(els[i]); 6695 if (classNames.contains(className)) 6696 { 6697 result.push(els[i]); 6698 } 6586 6699 } 6587 6700 return result; 6588 6701 } 6589 } 6702 }; 6590 6703 6591 6704 /** Returns true if all elements of <em>a2</em> are also contained in <em>a1</em> (at least I think this is what it does) … … 6741 6854 6742 6855 var m = null; 6743 if (typeof string == 'string') m = string.match(/\$(.*?)=(.*?)\$/g); 6856 if (typeof string == 'string') 6857 { 6858 m = string.match(/\$(.*?)=(.*?)\$/g); 6859 } 6744 6860 if (m) 6745 6861 { 6746 if (!replace) replace = {}; 6862 if (!replace) 6863 { 6864 replace = {}; 6865 } 6747 6866 for (var i = 0;i<m.length;i++) 6748 6867 { … … 6826 6945 if ( typeof replace != "undefined" ) 6827 6946 { 6828 for ( vari in replace )6947 for ( i in replace ) 6829 6948 { 6830 6949 ret = ret.replace('$'+i, replace[i]); … … 6880 6999 s[t] = function() 6881 7000 { 6882 if ( Xinha.is_ie && ( ! ( /loaded|complete/.test(window.event.srcElement.readyState) ) ))7001 if (Xinha.is_ie && (!/loaded|complete/.test(window.event.srcElement.readyState))) 6883 7002 { 6884 7003 return; … … 6901 7020 Xinha.makeEditors = function(editor_names, default_config, plugin_names) 6902 7021 { 6903 if ( !Xinha.isSupportedBrowser ) return; 7022 if (!Xinha.isSupportedBrowser) 7023 { 7024 return; 7025 } 6904 7026 6905 7027 if ( typeof default_config == 'function' ) … … 6941 7063 Xinha.startEditors = function(editors) 6942 7064 { 6943 if ( !Xinha.isSupportedBrowser ) return; 7065 if (!Xinha.isSupportedBrowser) 7066 { 7067 return; 7068 } 6944 7069 6945 7070 for ( var i in editors ) … … 6957 7082 Xinha.prototype.registerPlugins = function(plugin_names) 6958 7083 { 6959 if ( !Xinha.isSupportedBrowser ) return; 7084 if (!Xinha.isSupportedBrowser) 7085 { 7086 return; 7087 } 6960 7088 6961 7089 if ( plugin_names ) … … 7168 7296 if (element.offsetParent) 7169 7297 { 7170 curleft = element.offsetLeft 7171 curtop = element.offsetTop 7298 curleft = element.offsetLeft; 7299 curtop = element.offsetTop; 7172 7300 while (element = element.offsetParent) 7173 7301 { 7174 curleft += element.offsetLeft 7175 curtop += element.offsetTop 7302 curleft += element.offsetLeft; 7303 curtop += element.offsetTop; 7176 7304 } 7177 7305 } 7178 7306 return { top:curtop, left:curleft }; 7179 } 7307 }; 7180 7308 /** Find left pixel position of an element in the DOM. 7181 7309 * @param {DomNode} element HTML Element … … 7187 7315 if ( obj.offsetParent ) 7188 7316 { 7189 return Xinha.getElementTopLeft(obj).left; 7317 return Xinha.getElementTopLeft(obj).left; 7190 7318 } 7191 7319 else if ( obj.x ) … … 7223 7351 for (var i=0;i<xinha_editors.length;i++) 7224 7352 { 7225 if (!document.getElementById(xinha_editors[i])) continue; 7226 Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById('textarea', xinha_editors[i]))); 7353 if (!document.getElementById(xinha_editors[i])) 7354 { 7355 continue; 7356 } 7357 Xinha.loadingMessages.push(Xinha.createLoadingMessage(Xinha.getElementById('textarea', xinha_editors[i]))); 7227 7358 } 7228 7359 }; … … 7276 7407 Xinha.setLoadingMessage = function(string) 7277 7408 { 7278 if (!Xinha.loadingMessages) return; 7409 if (!Xinha.loadingMessages) 7410 { 7411 return; 7412 } 7279 7413 for ( var i = 0; i < Xinha.loadingMessages.length; i++ ) 7280 7414 { … … 7295 7429 for (var i=0;i< xinha_editors.length;i++) 7296 7430 { 7297 if (!document.getElementById(xinha_editors[i])) continue; 7431 if (!document.getElementById(xinha_editors[i])) 7432 { 7433 continue; 7434 } 7298 7435 var main = document.getElementById("loading_" + document.getElementById(xinha_editors[i]).id); 7299 7436 main.parentNode.removeChild(main); … … 7374 7511 */ 7375 7512 7376 Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { Xinha.notImplemented("insertNodeAtSelection"); } 7513 Xinha.prototype.insertNodeAtSelection = function(toBeInserted) { Xinha.notImplemented("insertNodeAtSelection"); }; 7377 7514 7378 7515 /** Get the parent element of the supplied or current selection. … … 7381 7518 */ 7382 7519 7383 Xinha.prototype.getParentElement = function(sel) { Xinha.notImplemented("getParentElement"); } 7520 Xinha.prototype.getParentElement = function(sel) { Xinha.notImplemented("getParentElement"); }; 7384 7521 7385 7522 /** … … 7391 7528 */ 7392 7529 7393 Xinha.prototype.activeElement = function(sel) { Xinha.notImplemented("activeElement"); } 7530 Xinha.prototype.activeElement = function(sel) { Xinha.notImplemented("activeElement"); }; 7394 7531 7395 7532 /** … … 7399 7536 */ 7400 7537 7401 Xinha.prototype.selectionEmpty = function(sel) { Xinha.notImplemented("selectionEmpty"); } 7538 Xinha.prototype.selectionEmpty = function(sel) { Xinha.notImplemented("selectionEmpty"); }; 7402 7539 /** 7403 7540 * Returns a range object to be stored … … 7406 7543 */ 7407 7544 7408 Xinha.prototype.saveSelection = function() { Xinha.notImplemented("saveSelection"); } 7545 Xinha.prototype.saveSelection = function() { Xinha.notImplemented("saveSelection"); }; 7409 7546 7410 7547 /** Restores a selection previously stored 7411 7548 * @param {Range} savedSelection Range object as returned by Xinha.prototype.restoreSelection() 7412 7549 */ 7413 Xinha.prototype.restoreSelection = function(savedSelection) { Xinha.notImplemented("restoreSelection"); } 7550 Xinha.prototype.restoreSelection = function(savedSelection) { Xinha.notImplemented("restoreSelection"); }; 7414 7551 7415 7552 /** … … 7420 7557 * @param {Integer} pos Set to a numeric position inside the node to collapse the cursor here if possible. 7421 7558 */ 7422 Xinha.prototype.selectNodeContents = function(node,pos) { Xinha.notImplemented("selectNodeContents"); } 7559 Xinha.prototype.selectNodeContents = function(node,pos) { Xinha.notImplemented("selectNodeContents"); }; 7423 7560 7424 7561 /** Insert HTML at the current position, deleting the selection if any. … … 7427 7564 */ 7428 7565 7429 Xinha.prototype.insertHTML = function(html) { Xinha.notImplemented("insertHTML"); } 7566 Xinha.prototype.insertHTML = function(html) { Xinha.notImplemented("insertHTML"); }; 7430 7567 7431 7568 /** Get the HTML of the current selection. HTML returned has not been passed through outwardHTML. … … 7433 7570 * @returns {String} 7434 7571 */ 7435 Xinha.prototype.getSelectedHTML = function() { Xinha.notImplemented("getSelectedHTML"); } 7572 Xinha.prototype.getSelectedHTML = function() { Xinha.notImplemented("getSelectedHTML"); }; 7436 7573 7437 7574 /** Get a Selection object of the current selection. Note that selection objects are browser specific. … … 7440 7577 */ 7441 7578 7442 Xinha.prototype.getSelection = function() { Xinha.notImplemented("getSelection"); } 7579 Xinha.prototype.getSelection = function() { Xinha.notImplemented("getSelection"); }; 7443 7580 7444 7581 /** Create a Range object from the given selection. Note that range objects are browser specific. … … 7447 7584 * @returns {Range} 7448 7585 */ 7449 Xinha.prototype.createRange = function(sel) { Xinha.notImplemented("createRange"); } 7586 Xinha.prototype.createRange = function(sel) { Xinha.notImplemented("createRange"); }; 7450 7587 7451 7588 /** Determine if the given event object is a keydown/press event. … … 7455 7592 */ 7456 7593 7457 Xinha.prototype.isKeyEvent = function(event) { Xinha.notImplemented("isKeyEvent"); } 7594 Xinha.prototype.isKeyEvent = function(event) { Xinha.notImplemented("isKeyEvent"); }; 7458 7595 7459 7596 /** Determines if the given key event object represents a combination of CTRL-<key>, … … 7472 7609 7473 7610 return false; 7474 } 7611 }; 7475 7612 7476 7613 /** Return the character (as a string) of a keyEvent - ie, press the 'a' key and … … 7481 7618 */ 7482 7619 7483 Xinha.prototype.getKey = function(keyEvent) { Xinha.notImplemented("getKey"); } 7620 Xinha.prototype.getKey = function(keyEvent) { Xinha.notImplemented("getKey"); }; 7484 7621 7485 7622 /** Return the HTML string of the given Element, including the Element. … … 7489 7626 */ 7490 7627 7491 Xinha.getOuterHTML = function(element) { Xinha.notImplemented("getOuterHTML"); } 7628 Xinha.getOuterHTML = function(element) { Xinha.notImplemented("getOuterHTML"); }; 7492 7629 7493 7630 /** Get a new XMLHTTPRequest Object ready to be used. … … 7513 7650 Xinha.notImplemented('getXMLHTTPRequestObject'); 7514 7651 } 7515 } 7652 }; 7516 7653 7517 7654 // Compatability - all these names are deprecated and will be removed in a future version … … 7521 7658 * @returns {DomNode|null} 7522 7659 */ 7523 Xinha.prototype._activeElement = function(sel) { return this.activeElement(sel); } 7660 Xinha.prototype._activeElement = function(sel) { return this.activeElement(sel); }; 7524 7661 /** Alias of selectionEmpty() 7525 7662 * @see Xinha#selectionEmpty … … 7528 7665 * @returns {Boolean} 7529 7666 */ 7530 Xinha.prototype._selectionEmpty = function(sel) { return this.selectionEmpty(sel); } 7667 Xinha.prototype._selectionEmpty = function(sel) { return this.selectionEmpty(sel); }; 7531 7668 /** Alias of getSelection() 7532 7669 * @see Xinha#getSelection … … 7534 7671 * @returns {Selection} 7535 7672 */ 7536 Xinha.prototype._getSelection = function() { return this.getSelection(); } 7673 Xinha.prototype._getSelection = function() { return this.getSelection(); }; 7537 7674 /** Alias of createRange() 7538 7675 * @see Xinha#createRange … … 7541 7678 * @returns {Range} 7542 7679 */ 7543 Xinha.prototype._createRange = function(sel) { return this.createRange(sel); } 7680 Xinha.prototype._createRange = function(sel) { return this.createRange(sel); }; 7544 7681 HTMLArea = Xinha; 7545 7682 7683 //what is this for? Do we need it? 7546 7684 Xinha.init(); 7547 7685 … … 7557 7695 Xinha.debugMsg = function(text, level) 7558 7696 { 7559 if (typeof console != 'undefined' && typeof console.log == 'function') 7560 { 7561 if (level && level == 'warn' && typeof console.warn == 'function') 7562 { 7563 console.warn(text) 7564 } 7565 else if (level && level == 'info' && typeof console.info == 'function') 7566 { 7567 console.info(text) 7568 } 7569 else console.log(text); 7570 } 7571 else if (typeof opera != 'undefined' && typeof opera.postError == 'function') opera.postError(text); 7572 7573 } 7697 if (typeof console != 'undefined' && typeof console.log == 'function') 7698 { 7699 if (level && level == 'warn' && typeof console.warn == 'function') 7700 { 7701 console.warn(text); 7702 } 7703 else 7704 if (level && level == 'info' && typeof console.info == 'function') 7705 { 7706 console.info(text); 7707 } 7708 else 7709 { 7710 console.log(text); 7711 } 7712 } 7713 else if (typeof opera != 'undefined' && typeof opera.postError == 'function') 7714 { 7715 opera.postError(text); 7716 } 7717 }; 7574 7718 Xinha.notImplemented = function(methodName) 7575 7719 { 7576 7720 throw new Error("Method Not Implemented", "Part of Xinha has tried to call the " + methodName + " method which has not been implemented."); 7577 } 7721 }; -
trunk/modules/Dialogs/XinhaDialog.js
r1117 r1119 20 20 -- $LastChangedBy$ 21 21 --------------------------------------------------------------------------*/ 22 /*jslint regexp: false, rhino: false, browser: true, bitwise: false, forin: false, adsafe: false, evil: true, nomen: false, 23 glovar: false, debug: false, eqeqeq: false, passfail: false, sidebar: false, laxbreak: false, on: false, cap: true, 24 white: false, widget: false, undef: true, plusplus: false*/ 25 /*global Xinha */ 22 26 23 27 /** Xinha Dialog … … 50 54 undefined, the options passed in above will be used. 51 55 */ 52 var globalOptions = editor.config.dialogOptions 53 if (globalOptions) { 54 if (typeof(globalOptions.centered) != 'undefined') { 56 var globalOptions = editor.config.dialogOptions; 57 if (globalOptions) 58 { 59 if (typeof globalOptions.centered != 'undefined') 60 { 55 61 this.centered = globalOptions.centered; 56 62 } 57 if (typeof(globalOptions.resizable) != 'undefined') { 63 if (typeof globalOptions.resizable != 'undefined') 64 { 58 65 this.resizable = globalOptions.resizable; 59 66 } 60 if (typeof(globalOptions.closable) != 'undefined') { 67 if (typeof globalOptions.closable != 'undefined') 68 { 61 69 this.closable = globalOptions.closable; 62 70 } 63 if (typeof(globalOptions.greyout) != 'undefined') { 71 if (typeof globalOptions.greyout != 'undefined') 72 { 64 73 this.greyout = globalOptions.greyout; 65 74 } 66 if (typeof(globalOptions.closeOnEscape) != 'undefined') { 75 if (typeof globalOptions.closeOnEscape != 'undefined') 76 { 67 77 this.closeOnEscape = globalOptions.closeOnEscape; 68 78 } 69 79 } 70 80 var backG; 71 81 if (Xinha.is_ie) 72 82 { // IE6 needs the iframe to hide select boxes 73 varbackG = document.createElement("iframe");83 backG = document.createElement("iframe"); 74 84 backG.src = "about:blank"; 75 85 backG.onreadystatechange = function () … … 84 94 for (var i=0;i<stylesheets.length;i++) 85 95 { 86 if (stylesheets[i].id.indexOf('Xinha') != -1 && stylesheets[i].cssText) 96 if (stylesheets[i].id.indexOf('Xinha') != -1 && stylesheets[i].cssText) 97 { 87 98 styles += stylesheets[i].cssText; 99 } 88 100 } 89 101 div.innerHTML = '<br><style type="text/css">\n'+styles+'\n</style>'; // strange way, but didn't work otherwise 90 102 doc.getElementsByTagName('body')[0].appendChild(div); 91 103 doc.body.className = 'xinha_dialog_background'; 92 if (dialog.modal) doc.body.className += ' modal'; 93 if (dialog.greyout) doc.body.className += ' greyout'; 104 if (dialog.modal) 105 { 106 doc.body.className += ' modal'; 107 } 108 if (dialog.greyout) 109 { 110 doc.body.className += ' greyout'; 111 } 94 112 } 95 } 113 }; 96 114 } 97 115 else 98 116 { // Mozilla (<FF3) can't have the iframe, because it hides the caret in text fields 99 117 // see https://bugzilla.mozilla.org/show_bug.cgi?id=226933 100 varbackG = document.createElement("div");118 backG = document.createElement("div"); 101 119 } 102 120 backG.className = "xinha_dialog_background"; 103 if (this.modal) backG.className += ' modal'; 104 if (this.greyout) backG.className += ' greyout'; 121 if (this.modal) 122 { 123 backG.className += ' modal'; 124 } 125 if (this.greyout) 126 { 127 backG.className += ' greyout'; 128 } 105 129 var z = 1000; 106 130 if (!Xinha.Dialog.initialZ) … … 109 133 while (p) 110 134 { 111 if (p.style && parseInt(p.style.zIndex, 10) > z) z = parseInt(p.style.zIndex, 10); 135 if (p.style && parseInt(p.style.zIndex, 10) > z) 136 { 137 z = parseInt(p.style.zIndex, 10); 138 } 112 139 p = p.parentNode; 113 140 } … … 115 142 } 116 143 z = Xinha.Dialog.initialZ; 117 with (backG.style) 118 { 119 position = "absolute"; 120 top = 0; 121 left = 0; 122 border = 'none'; 123 overflow = "hidden"; 124 display = "none"; 125 zIndex = (this.modal ? z + 25 : z +1 ) + this.layer; 126 } 144 var s = backG.style; 145 s.position = "absolute"; 146 s.top = 0; 147 s.left = 0; 148 s.border = 'none'; 149 s.overflow = "hidden"; 150 s.display = "none"; 151 s.zIndex = (this.modal ? z + 25 : z +1 ) + this.layer; 152 127 153 document.body.appendChild(backG); 128 154 this.background = backG; … … 166 192 } 167 193 168 html = this.translateHtml(html,localizer) 194 html = this.translateHtml(html,localizer); 169 195 170 196 var main = document.createElement('div'); … … 183 209 184 210 this.buttons = document.createElement('div'); 185 with (this.buttons.style) 186 { 187 position = "absolute"; 188 top = "0"; 189 right = "2px"; 190 } 211 s = this.buttons.style; 212 s.position = "absolute"; 213 s.top = "0"; 214 s.right = "2px"; 215 191 216 rootElem.appendChild(this.buttons); 192 217 … … 233 258 234 259 this.icon = document.createElement('img'); 235 with (this.icon) 236 { 237 className = 'icon'; 238 src = editor.config.iconList.dialogCaption; 239 style.position = 'absolute'; 240 style.top = '3px'; 241 style.left = '2px'; 242 ondrag = function () {return false;}; 243 } 260 var icon = this.icon; 261 icon.className = 'icon'; 262 icon.src = editor.config.iconList.dialogCaption; 263 icon.style.position = 'absolute'; 264 icon.style.top = '3px'; 265 icon.style.left = '2px'; 266 icon.ondrag = function () {return false;}; 267 244 268 captionBar.style.paddingLeft = '22px'; 245 269 rootElem.appendChild(this.icon); … … 266 290 this.resizer = document.createElement('div'); 267 291 this.resizer.className = "resizeHandle"; 268 with (this.resizer.style) 269 { 270 position = "absolute"; 271 bottom = "0px"; 272 right= "0px"; 273 MozUserSelect = 'none'; 274 } 292 s = this.resizer.style; 293 s.position = "absolute"; 294 s.bottom = "0px"; 295 s.right= "0px"; 296 s.MozUserSelect = 'none'; 297 275 298 Xinha._addEvent(this.resizer, 'mousedown', function(ev) { dialog.resizeStart(ev); }); 276 299 rootElem.appendChild(this.resizer); … … 309 332 var rootElemStyle = rootElem.style; 310 333 var modal = this.modal; 311 var scrollPos = this.scrollPos = this.editor.scrollPos(); 334 var scrollPos = this.editor.scrollPos(); 335 this.scrollPos = scrollPos; 312 336 var dialog = this; 313 337 //dialog.main.style.height = ''; … … 347 371 if ( !this.attached ) 348 372 { 349 if ( modal ) 350 { 351 this.showBackground() 352 this.posBackground({top:0, left:0}); 373 if (modal) 374 { 375 this.showBackground(); 376 this.posBackground({ 377 top: 0, 378 left: 0 379 }); 353 380 this.resizeBackground(Xinha.Dialog.calcFullBgSize()); 354 381 } 355 else this.background.style.display = ''; 382 else 383 { 384 this.background.style.display = ''; 385 } 356 386 357 387 //this.onResizeWin = function () {dialog.sizeBackground()}; … … 581 611 dialog.mouseMove = function(ev) { dialog.dragIt(ev); }; 582 612 Xinha._addEvent(document,"mousemove", dialog.mouseMove ); 583 if (Xinha.is_ie) Xinha._addEvent(this.background.contentWindow.document,"mousemove", dialog.mouseMove ); 613 if (Xinha.is_ie) 614 { 615 Xinha._addEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); 616 } 584 617 585 618 dialog.mouseUp = function (ev) { dialog.dragEnd(ev); }; 586 619 Xinha._addEvent(document,"mouseup", dialog.mouseUp); 587 if (Xinha.is_ie) Xinha._addEvent(this.background.contentWindow.document,"mouseup", dialog.mouseUp); 620 if (Xinha.is_ie) 621 { 622 Xinha._addEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 623 } 588 624 }; 589 625 … … 596 632 return false; 597 633 } 598 634 var posY, posX, newPos; 599 635 if (dialog.rootElem.style.position == 'absolute') 600 636 { 601 varposY = (ev.clientY + this.scrollPos.y) - dialog.yOffs + "px";602 varposX = (ev.clientX + this.scrollPos.x) - dialog.xOffs + "px";603 604 varnewPos = {top: posY,left: posX};637 posY = (ev.clientY + this.scrollPos.y) - dialog.yOffs + "px"; 638 posX = (ev.clientX + this.scrollPos.x) - dialog.xOffs + "px"; 639 640 newPos = {top: posY,left: posX}; 605 641 } 606 642 else if (dialog.rootElem.style.position == 'fixed') 607 643 { 608 varposY = ev.clientY - dialog.yOffs + "px";609 varposX = ev.clientX - dialog.xOffs + "px";610 611 varnewPos = {top: posY,left: posX};644 posY = ev.clientY - dialog.yOffs + "px"; 645 posX = ev.clientX - dialog.xOffs + "px"; 646 647 newPos = {top: posY,left: posX}; 612 648 } 613 649 … … 631 667 632 668 Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 633 if (Xinha.is_ie) Xinha._removeEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove ); 669 if (Xinha.is_ie) 670 { 671 Xinha._removeEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); 672 } 634 673 Xinha._removeEvent(document, "mouseup", dialog.mouseUp); 635 if (Xinha.is_ie) Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 674 if (Xinha.is_ie) 675 { 676 Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 677 } 636 678 637 679 var rootElemStyle = dialog.rootElem.style; … … 670 712 dialog.mouseMove = function(ev) { dialog.resizeIt(ev); }; 671 713 Xinha._addEvent(document,"mousemove", dialog.mouseMove ); 672 if (Xinha.is_ie) Xinha._addEvent(this.background.contentWindow.document,"mousemove", dialog.mouseMove ); 714 if (Xinha.is_ie) 715 { 716 Xinha._addEvent(this.background.contentWindow.document, "mousemove", dialog.mouseMove); 717 } 673 718 dialog.mouseUp = function (ev) { dialog.resizeEnd(ev); }; 674 719 Xinha._addEvent(document,"mouseup", dialog.mouseUp); 675 if (Xinha.is_ie) Xinha._addEvent(this.background.contentWindow.document,"mouseup", dialog.mouseUp ); 720 if (Xinha.is_ie) 721 { 722 Xinha._addEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 723 } 676 724 }; 677 725 … … 683 731 return false; 684 732 } 685 733 var posY, posX; 686 734 if (dialog.rootElem.style.position == 'absolute') 687 735 { 688 varposY = ev.clientY + dialog.scrollPos.y;689 varposX = ev.clientX + dialog.scrollPos.x;736 posY = ev.clientY + dialog.scrollPos.y; 737 posX = ev.clientX + dialog.scrollPos.x; 690 738 } 691 739 else 692 740 { 693 varposY = ev.clientY;694 varposX = ev.clientX;741 posY = ev.clientY; 742 posX = ev.clientX; 695 743 } 696 744 … … 722 770 723 771 Xinha._removeEvent(document, "mousemove", dialog.mouseMove ); 724 if (Xinha.is_ie) Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 772 if (Xinha.is_ie) 773 { 774 Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 775 } 725 776 Xinha._removeEvent(document, "mouseup", dialog.mouseUp); 726 if (Xinha.is_ie) Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 777 if (Xinha.is_ie) 778 { 779 Xinha._removeEvent(this.background.contentWindow.document, "mouseup", dialog.mouseUp); 780 } 727 781 728 782 dialog.size.width = dialog.rootElem.offsetWidth; … … 752 806 this.captionBar.style.paddingLeft = "3px"; 753 807 this.resizer.style.display = 'none'; 754 if ( this.closable ) this.closer.style.display = 'none'; 808 if (this.closable) 809 { 810 this.closer.style.display = 'none'; 811 } 755 812 this.icon.style.display = 'none'; 756 813 … … 789 846 dialog.captionBar.style.paddingLeft = "22px"; 790 847 dialog.resizer.style.display = ''; 791 if ( dialog.closable ) dialog.closer.style.display = ''; 848 if (dialog.closable) 849 { 850 dialog.closer.style.display = ''; 851 } 792 852 dialog.icon.style.display = ''; 793 853 794 if ( dialog.size.width ) rootElem.style.width = dialog.size.width + 'px'; 854 if (dialog.size.width) 855 { 856 rootElem.style.width = dialog.size.width + 'px'; 857 } 795 858 796 859 Xinha.removeClasses(rootElem, 'panel'); … … 807 870 var viewport = Xinha.viewportSize(); 808 871 return {width:(page.x > viewport.x ? page.x : viewport.x ) + "px",height:(page.x > viewport.y ? page.y : viewport.y ) + "px"}; 809 } 872 }; 810 873 811 874 Xinha.Dialog.prototype.sizeBgToDialog = function() … … 817 880 bgStyle.width = rootElemStyle.width; 818 881 bgStyle.height = rootElemStyle.height; 819 } 882 }; 820 883 Xinha.Dialog.prototype.hideBackground = function() 821 884 { 822 885 //this.background.style.display = 'none'; 823 886 Xinha.Dialog.fadeOut(this.background); 824 } 887 }; 825 888 Xinha.Dialog.prototype.showBackground = function() 826 889 { 827 890 //this.background.style.display = ''; 828 891 Xinha.Dialog.fadeIn(this.background,70); 829 } 892 }; 830 893 Xinha.Dialog.prototype.posBackground = function(pos) 831 894 { … … 835 898 this.background.style.left = pos.left; 836 899 } 837 } 900 }; 838 901 Xinha.Dialog.prototype.resizeBackground = function(size) 839 902 { … … 843 906 this.background.style.height = size.height; 844 907 } 845 } 908 }; 846 909 Xinha.Dialog.prototype.posDialog = function(pos) 847 910 { … … 849 912 st.left = pos.left; 850 913 st.top = pos.top; 851 } 914 }; 852 915 Xinha.Dialog.prototype.sizeDialog = function(size) 853 916 { … … 859 922 this.main.style.height = (height > 20) ? height : 20 + "px"; 860 923 this.main.style.width = (width > 10) ? width : 10 + 'px'; 861 } 924 }; 862 925 Xinha.Dialog.prototype.setValues = function(values) 863 926 { 864 927 for(var i in values) 865 928 { 866 var elems = this.getElementsByName(i); 867 if(!elems) continue; 868 for(var x = 0; x < elems.length; x++) 869 { 870 var e = elems[x]; 871 switch(e.tagName.toLowerCase()) 929 if (typeof i == 'string') 930 { 931 var elems = this.getElementsByName(i); 932 if (!elems) 872 933 { 873 case 'select' : 934 continue; 935 } 936 for(var x = 0; x < elems.length; x++) 937 { 938 var e = elems[x]; 939 switch(e.tagName.toLowerCase()) 874 940 { 875 for(var j = 0; j < e.options.length; j++) 876 { 877 if(typeof values[i] == 'object') 878 { 879 for(var k = 0; k < values[i].length; k++) 880 { 881 if(values[i][k] == e.options[j].value) 882 { 883 e.options[j].selected = true; 884 } 885 } 886 } 887 else if(values[i] == e.options[j].value) 888 { 889 e.options[j].selected = true; 890 } 891 } 892 break; 893 } 894 895 case 'textarea': 896 case 'input' : 897 { 898 switch(e.getAttribute('type')) 899 { 900 case 'radio' : 901 { 902 if(e.value == values[i]) 903 { 904 e.checked = true; 905 } 906 break; 907 } 908 909 case 'checkbox': 941 case 'select' : 942 for(var j = 0; j < e.options.length; j++) 910 943 { 911 944 if(typeof values[i] == 'object') 912 945 { 913 for(var j in values[i])946 for(var k = 0; k < values[i].length; k++) 914 947 { 915 if(values[i][j] == e.value) 948 if(values[i][k] == e.options[j].value) 949 { 950 e.options[j].selected = true; 951 } 952 } 953 } 954 else if(values[i] == e.options[j].value) 955 { 956 e.options[j].selected = true; 957 } 958 } 959 break; 960 case 'textarea': 961 case 'input' : 962 switch(e.getAttribute('type')) 963 { 964 case 'radio' : 965 if(e.value == values[i]) 966 { 967 e.checked = true; 968 } 969 break; 970 case 'checkbox': 971 if(typeof values[i] == 'object') 972 { 973 for(j in values[i]) 974 { 975 if(values[i][j] == e.value) 976 { 977 e.checked = true; 978 } 979 } 980 } 981 else 982 { 983 if(values[i] == e.value) 916 984 { 917 985 e.checked = true; 918 986 } 919 987 } 920 } 921 else 922 { 923 if(values[i] == e.value) 924 { 925 e.checked = true; 926 } 927 } 988 break; 989 default: 990 e.value = values[i]; 928 991 break; 929 992 } 930 931 default :932 {933 e.value = values[i];934 }935 }936 break;937 993 } 938 939 default :940 break;941 994 } 942 995 } … … 954 1007 { 955 1008 var i = inputs[x]; 956 if(!(i.name && this.r_id[i.name])) continue; 1009 if (!(i.name && this.r_id[i.name])) 1010 { 1011 continue; 1012 } 957 1013 958 1014 if(typeof values[this.r_id[i.name]] == 'undefined') … … 965 1021 { 966 1022 case 'select': 967 {968 1023 if(i.multiple) 969 1024 { 970 1025 if(!v.push) 971 1026 { 972 if(v != null)1027 if(v !== null) 973 1028 { 974 1029 v = [v]; … … 976 1031 else 977 1032 { 978 v = new Array();1033 v = []; 979 1034 } 980 1035 } … … 995 1050 } 996 1051 break; 997 } 998 1052 /* 999 1053 case 'textarea': 1000 1054 case 'input' : 1001 default : 1002 {1055 */ 1056 default: 1003 1057 switch(i.type.toLowerCase()) 1004 1058 { 1005 1059 case 'radio': 1006 {1007 1060 if(i.checked) 1008 1061 { 1009 1062 v = i.value; 1010 break;1011 1063 } 1012 } 1013 1064 break; 1014 1065 case 'checkbox': 1015 { 1016 if(v == null) 1066 if(v === null) 1017 1067 { 1018 1068 if(this.getElementsByName(this.r_id[i.name]).length > 1) 1019 1069 { 1020 v = new Array();1070 v = []; 1021 1071 } 1022 1072 } 1023 1024 1073 if(i.checked) 1025 1074 { 1026 if(v != null && typeof v == 'object' && v.push)1075 if(v !== null && typeof v == 'object' && v.push) 1027 1076 { 1028 1077 v.push(i.value); … … 1033 1082 } 1034 1083 } 1035 break; 1036 } 1037 1038 default : 1039 { 1084 break; 1085 default: 1040 1086 v = i.value; 1041 break; 1042 } 1087 break; 1043 1088 } 1044 } 1045 1046 } 1047 1089 } 1048 1090 values[this.r_id[i.name]] = v; 1049 1091 } … … 1084 1126 return dialog._lc(translate) ; 1085 1127 } 1086 ).replace(/ ="_\((.*?)\)"/g,1128 ).replace(/\="_\((.*?)\)"/g, 1087 1129 function(fullString, translate) 1088 1130 { … … 1091 1133 ); 1092 1134 return html; 1093 } 1135 }; 1094 1136 1095 1137 /** Use this function when adding an element with a new ID/name to a … … 1130 1172 if (Xinha.Dialog.activeModeless ) 1131 1173 { 1132 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex ) -10;1174 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex, 10) -10; 1133 1175 } 1134 1176 Xinha.Dialog.activeModeless = dialog; 1135 1177 1136 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex ) + 10;1137 } 1178 Xinha.Dialog.activeModeless.rootElem.style.zIndex = parseInt(Xinha.Dialog.activeModeless.rootElem.style.zIndex, 10) + 10; 1179 }; 1138 1180 /** Set opacity cross browser 1139 1181 * … … 1151 1193 el.style.opacity = value/100; 1152 1194 } 1153 } 1195 }; 1154 1196 /** Fade in an element 1155 1197 * … … 1182 1224 el.op = endOpacity; 1183 1225 el.timeOut = null; 1184 if (typeof callback == 'function') callback.call(); 1185 } 1186 } 1226 if (typeof callback == 'function') 1227 { 1228 callback.call(); 1229 } 1230 } 1231 }; 1187 1232 /** Fade out an element 1188 1233 * … … 1195 1240 delay = delay || 1; 1196 1241 step = step || 30; 1197 if (typeof el.op == 'undefined') el.op = 100; 1242 if (typeof el.op == 'undefined') 1243 { 1244 el.op = 100; 1245 } 1198 1246 var op = el.op; 1199 1247 … … 1211 1259 el.timeOut = null; 1212 1260 } 1213 } 1261 };
