internal.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. utils.loadFile(document,{
  28. href: "../../themes/default/dialogbase.css?cache="+Math.random(),
  29. tag:"link",
  30. type:"text/css",
  31. rel:"stylesheet"
  32. });
  33. lang = editor.getLang(dialog.className.split( "-" )[2]);
  34. if(lang){
  35. domUtils.on(window,'load',function () {
  36. var langImgPath = editor.options.langPath + editor.options.lang + "/images/";
  37. //针对静态资源
  38. for ( var i in lang["static"] ) {
  39. var dom = $G( i );
  40. if(!dom) continue;
  41. var tagName = dom.tagName,
  42. content = lang["static"][i];
  43. if(content.src){
  44. //clone
  45. content = utils.extend({},content,false);
  46. content.src = langImgPath + content.src;
  47. }
  48. if(content.style){
  49. content = utils.extend({},content,false);
  50. content.style = content.style.replace(/url\s*\(/g,"url(" + langImgPath)
  51. }
  52. switch ( tagName.toLowerCase() ) {
  53. case "var":
  54. dom.parentNode.replaceChild( document.createTextNode( content ), dom );
  55. break;
  56. case "select":
  57. var ops = dom.options;
  58. for ( var j = 0, oj; oj = ops[j]; ) {
  59. oj.innerHTML = content.options[j++];
  60. }
  61. for ( var p in content ) {
  62. p != "options" && dom.setAttribute( p, content[p] );
  63. }
  64. break;
  65. default :
  66. domUtils.setAttributes( dom, content);
  67. }
  68. }
  69. } );
  70. }
  71. })();