internal.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. (function () {
  2. var parent = window.parent;
  3. //dialog对象
  4. dialog = parent.$EDITORUI[window.frameElement.id.replace( /_iframe$/, '' )];
  5. //当前打开dialog的编辑器实例
  6. editor = dialog.editor;
  7. UE = parent.UE;
  8. domUtils = UE.dom.domUtils;
  9. utils = UE.utils;
  10. browser = UE.browser;
  11. ajax = UE.ajax;
  12. $G = function ( id ) {
  13. return document.getElementById( id )
  14. };
  15. //focus元素
  16. $focus = function ( node ) {
  17. setTimeout( function () {
  18. if ( browser.ie ) {
  19. var r = node.createTextRange();
  20. r.collapse( false );
  21. r.select();
  22. } else {
  23. node.focus()
  24. }
  25. }, 0 )
  26. };
  27. lang = UE.I18N[editor.options.lang][dialog.className.split( "-" )[2]];
  28. utils.domReady( function () {
  29. var langImgPath = editor.options.langPath + editor.options.lang + "/images/";
  30. //针对静态资源
  31. for ( var i in lang.static ) {
  32. var dom = $G( i );
  33. if(!dom) continue;
  34. var tagName = dom.tagName,
  35. content = lang.static[i];
  36. if(content.src){
  37. //clone
  38. content = utils.extend({},content,false);
  39. content.src = langImgPath + content.src;
  40. }
  41. if(content.style){
  42. content = utils.extend({},content,false);
  43. content.style = content.style.replace(/url\s*\(/g,"url(" + langImgPath)
  44. }
  45. switch ( tagName.toLowerCase() ) {
  46. case "var":
  47. dom.parentNode.replaceChild( document.createTextNode( content ), dom );
  48. break;
  49. case "select":
  50. var ops = dom.options;
  51. for ( var j = 0, oj; oj = ops[j]; ) {
  52. oj.innerHTML = content.options[j++];
  53. }
  54. for ( var p in content ) {
  55. p != "options" && dom.setAttribute( p, content[p] );
  56. }
  57. break;
  58. default :
  59. domUtils.setAttributes( dom, content);
  60. }
  61. }
  62. } );
  63. })();