internal.js 2.6 KB

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