internal.js 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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:editor.options.themePath + editor.options.theme + "/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. domUtils.on(window,'load',function () {
  35. var langImgPath = editor.options.langPath + editor.options.lang + "/images/";
  36. //针对静态资源
  37. for ( var i in lang.static ) {
  38. var dom = $G( i );
  39. if(!dom) continue;
  40. var tagName = dom.tagName,
  41. content = lang.static[i];
  42. if(content.src){
  43. //clone
  44. content = utils.extend({},content,false);
  45. content.src = langImgPath + content.src;
  46. }
  47. if(content.style){
  48. content = utils.extend({},content,false);
  49. content.style = content.style.replace(/url\s*\(/g,"url(" + langImgPath)
  50. }
  51. switch ( tagName.toLowerCase() ) {
  52. case "var":
  53. dom.parentNode.replaceChild( document.createTextNode( content ), dom );
  54. break;
  55. case "select":
  56. var ops = dom.options;
  57. for ( var j = 0, oj; oj = ops[j]; ) {
  58. oj.innerHTML = content.options[j++];
  59. }
  60. for ( var p in content ) {
  61. p != "options" && dom.setAttribute( p, content[p] );
  62. }
  63. break;
  64. default :
  65. domUtils.setAttributes( dom, content);
  66. }
  67. }
  68. } );
  69. })();