Yes, it is necessary and and want to reorganize , put all commands to editor _template , It is  better.

On 1/10/07, Vincent Massol < vincent@massol.net> wrote:
Hi Nam,

Is it normal that we need all this just to get the focus? Isn't there a simpler way?

Thanks
-Vincent

> -----Original Message-----
> From: Phung Hai Nam [mailto:namphunghai@users.forge.objectweb.org]
> Sent: mercredi 10 janvier 2007 07:43
> To: xwiki-commits@objectweb.org
> Subject: [xwiki-commits] r1928 - in
> xwiki/trunk/web/standard/src/main/webapp: tiny_mce/themes/wikieditor
> wiki_editor/plugins
>
> Author: namphunghai
> Date: 2007-01-10 07:43:16 +0100 (Wed, 10 Jan 2007) New Revision: 1928
>
> Modified:
>
> xwiki/trunk/web/standard/src/main/webapp/tiny_mce/themes/wikieditor/edi
> tor_template.js
>
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/attachment
> s.js
>
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/macros.js
> Log:
> Fixed XWIKI-706 : When clicking on buttons (insert/edit image, insert
> an attachment link, etc) in WYSIWYG editor the new window doesn't have
> the focus and is opened in the background.
>
> Modified:
> xwiki/trunk/web/standard/src/main/webapp/tiny_mce/themes/wikieditor/edi
> tor_template.js
> ===================================================================
> ---
> xwiki/trunk/web/standard/src/main/webapp/tiny_mce/themes/wikieditor/edi
> tor_template.js       2007-01-10 06:06:45 UTC (rev 1927)
> +++
> xwiki/trunk/web/standard/src/main/webapp/tiny_mce/themes/wikieditor/edi
> tor_template.js       2007-01-10 06:43:16 UTC (rev 1928)
> @@ -102,6 +102,118 @@
>
>                               return true;
>
> +            case "mceImage":
> +                var src = "", alt = "", border = "", hspace = "",
> vspace = "", width = "", height = "", align = "", halign = "";
> +                var title = "", onmouseover = "", onmouseout = "",
> action = "insert";
> +                var img = tinyMCE.imgElement;
> +                var inst = tinyMCE.getInstanceById(editor_id);
> +
> +                if (tinyMCE.selectedElement != null &&
> tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
> +                    img = tinyMCE.selectedElement;
> +                    tinyMCE.imgElement = img;
> +                    var parent = tinyMCE.selectedElement.parentNode;
> +                    var parentClassName = parent.className;
> +                    if (parent.nodeName.toLowerCase() == "div") {
> +                        halign = parentClassName.substring(3,
> parentClassName.length);
> +                    }
> +                }
> +
> +                if (img) {
> +                    // Is it a internal MCE visual aid image, then
> skip this one.
> +                    if (tinyMCE.getAttrib(img, 'name').indexOf('mce_')
> == 0)
> +                        return true;
> +
> +                    src = tinyMCE.getAttrib(img, 'src');
> +                    alt = tinyMCE.getAttrib(img, 'alt');
> +
> +                    // Try polling out the title
> +                    if (alt == "")
> +                        alt = tinyMCE.getAttrib(img, 'title');
> +
> +                    // Fix width/height attributes if the styles is
> specified
> +                    if (tinyMCE.isGecko ) {
> +                        var w = img.style.width;
> +                        if (w != null && w != "")
> +                            img.setAttribute("width", w);
> +
> +                        var h = img.style.height;
> +                        if (h != null && h != "")
> +                            img.setAttribute("height", h);
> +                    }
> +
> +                    border = tinyMCE.getAttrib(img, 'border');
> +                    hspace = tinyMCE.getAttrib(img, 'hspace');
> +                    vspace = tinyMCE.getAttrib (img, 'vspace');
> +                    width = tinyMCE.getAttrib(img, 'width');
> +                    height = tinyMCE.getAttrib(img, 'height');
> +                    align = tinyMCE.getAttrib (img, 'align');
> +
> +                    onmouseover = tinyMCE.getAttrib(img,
> 'onmouseover');
> +                    onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
> +                    title = tinyMCE.getAttrib(img, 'title');
> +
> +                    // Is realy specified?
> +                    if (tinyMCE.isMSIE) {
> +                        width = img.attributes['width'].specified ?
> width : "";
> +                        height = img.attributes['height'].specified ?
> height : "";
> +                    }
> +
> +                    src =
> + eval(tinyMCE.settings['urlconverter_callback'] + "(src, img,
> true);");
> +
> +                    src = src.substring(src.lastIndexOf ("/") + 1,
> + src.length);
> +
> +                    // Use mce_src if defined
> +                    mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
> +                    if (mceRealSrc != "") {
> +                        src = mceRealSrc;
> +
> +                        if (tinyMCE.getParam('convert_urls'))
> +                            src =
> eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
> +                            src = src.substring(src.lastIndexOf("/") +
> 1, src.length);
> +                    }
> +
> +                    action = "update";
> +                }
> +
> +                var template = new Array();
> +
> +                template['file'] = 'image.htm';
> +                template['width'] = 550;
> +                template['height'] = 400 + ( tinyMCE.isMSIE ? 25 : 0);
> +
> +                if (inst.settings['insertimage_callback']) {
> +                    var returnVal =
> eval(inst.settings['insertimage_callback'] + "(src, alt, border,
> hspace, vspace, width, height, align, title, onmouseover, onmouseout,
> action);");
> +                    if (returnVal && returnVal['src'])
> +
> TinyMCE_WikieditorTheme.insertImage(returnVal['src'],
> returnVal['width'], returnVal['height'], returnVal['align']);
> +                } else {
> +                    tinyMCE.openWindow(template, {editor_id :
> editor_id, scrollbars : 'yes', resizable : 'no', mce_windowresize:
> false, src : src, alt : alt, border : border, hspace : hspace, vspace :
> vspace, width : width, height : height, align : align, halign : halign,
> title : title, onmouseover : onmouseover, onmouseout : onmouseout,
> action : action, inline : "yes"});
> +                }
> +
> +                 return true;
> +
> +            case "wikiAttachment":
> +                var href = "", action = "insert";
> +                var template = new Array();
> +
> +                template['file'] = 'attachment.htm';
> +                template['width'] = 550;
> +                template['height'] = 400 + ( tinyMCE.isMSIE ? 25 : 0);
> +
> +                tinyMCE.openWindow(template, {editor_id : editor_id,
> + href : href, action : action, inline : "yes", scrollbars : 'yes',
> + resizable : 'no', mce_windowresize: false});
> +
> +                return true;
> +
> +            case "wikiMacro":
> +                var template = new Array();
> +
> +                template['file'] = ' macro.htm';
> +                template['width'] = 520;
> +                template['height'] = 300;
> +
> +                tinyMCE.openWindow(template, {editor_id : editor_id,
> + inline : "yes", command : "insert", scrollbars : 'yes',  resizable :
> + 'no', mce_windowresize: false});
> +
> +                return true;
> +
>              case "mceForeColor":
>                  var template = new Array();
>                  var elm = tinyMCE.selectedInstance.getFocusElement();
>
> Modified:
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/attachment
> s.js
> ===================================================================
> ---
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/attachment
> s.js  2007-01-10 06:06:45 UTC (rev 1927)
> +++
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/attachment
> s.js  2007-01-10 06:43:16 UTC (rev 1928)
> @@ -19,9 +19,6 @@
>      this.addInternalProcessorBefore('convertLinkInternal',
> (/<a\s*href=\"wikiattachment:-:(.*?)\"\s*([^>]*)>(.*?)<\/a>/i),
> 'convertAttachmentInternal');
>
>       this.addToolbarHandler('handleAttachmentsButtons');
> -
> -     this.addCommand('wikiAttachment', 'attachmentCommand');
> -    this.addCommand('mceImage', 'imageCommand');
>  }
>
>  wikiEditor.initAttachmentsPlugin ();
> @@ -33,109 +30,6 @@
>      this.core.execInstanceCommand(editor_id, "mceInsertRawHTML",
> false, '<a href="wikiattachment:-:' + name + '" class="' +
> this.ATTACHMENT_CLASS_NAME + '">' + text + '<\/a>');  }
>
> -WikiEditor.prototype.attachmentCommand = function(editor_id, element,
> command, user_interface, value) {
> -     var href = "", action = "insert";
> -    var template = new Array();
> -
> -    template['file'] = 'attachment.htm';
> -     template['width'] = 550;
> -     template['height'] = 400 + (tinyMCE.isMSIE ? 25 : 0);
> -
> -    tinyMCE.openWindow(template, {editor_id : editor_id, href : href,
> action : action, scrollbars : 'yes',  resizable : 'no',
> mce_windowresize: false});
> -
> -    return this.dummyCommand();
> -}
> -
> -WikiEditor.prototype.imageCommand = function(editor_id, element,
> command, user_interface, value) {
> -    var src = "", alt = "", border = "", hspace = "", vspace = "",
> width = "", height = "", align = "", halign = "";
> -    var title = "", onmouseover = "", onmouseout = "", action =
> "insert";
> -    var img = tinyMCE.imgElement;
> -    var inst = tinyMCE.getInstanceById(editor_id);
> -
> -    if (tinyMCE.selectedElement != null &&
> tinyMCE.selectedElement.nodeName.toLowerCase () == "img") {
> -        img = tinyMCE.selectedElement;
> -        tinyMCE.imgElement = img;
> -        var parent = tinyMCE.selectedElement.parentNode;
> -        var parentClassName = parent.className;
> -        if (parent.nodeName.toLowerCase() == "div") {
> -            halign = parentClassName.substring(3,
> parentClassName.length);
> -        }
> -    }
> -
> -    if (img) {
> -        // Is it a internal MCE visual aid image, then skip this one.
> -        if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
> -            return true;
> -
> -        src = tinyMCE.getAttrib(img, 'src');
> -        alt = tinyMCE.getAttrib(img, 'alt');
> -
> -        // Try polling out the title
> -        if (alt == "")
> -            alt = tinyMCE.getAttrib(img, 'title');
> -
> -        // Fix width/height attributes if the styles is specified
> -        if (tinyMCE.isGecko) {
> -            var w = img.style.width;
> -            if (w != null && w != "")
> -                img.setAttribute("width", w);
> -
> -            var h = img.style.height;
> -            if (h != null && h != "")
> -                img.setAttribute("height", h);
> -        }
> -
> -        border = tinyMCE.getAttrib(img, 'border');
> -        hspace = tinyMCE.getAttrib(img, 'hspace');
> -        vspace = tinyMCE.getAttrib(img, 'vspace');
> -        width = tinyMCE.getAttrib(img, 'width');
> -        height = tinyMCE.getAttrib(img, 'height');
> -        align = tinyMCE.getAttrib(img, 'align');
> -
> -        onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
> -        onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
> -        title = tinyMCE.getAttrib(img, 'title');
> -
> -        // Is realy specified?
> -        if (tinyMCE.isMSIE) {
> -            width = img.attributes['width'].specified ? width : "";
> -            height = img.attributes['height'].specified ? height : "";
> -        }
> -
> -        src = eval(tinyMCE.settings['urlconverter_callback'] + "(src,
> img, true);");
> -
> -        src = src.substring(src.lastIndexOf("/") + 1, src.length);
> -
> -        // Use mce_src if defined
> -        mceRealSrc = tinyMCE.getAttrib (img, 'mce_src');
> -        if (mceRealSrc != "") {
> -            src = mceRealSrc;
> -
> -            if (tinyMCE.getParam('convert_urls'))
> -                src = eval( tinyMCE.settings['urlconverter_callback'] +
> "(src, img, true);");
> -                src = src.substring(src.lastIndexOf("/") + 1,
> src.length);
> -        }
> -
> -        action = "update";
> -    }
> -
> -    var template = new Array();
> -
> -    template['file'] = 'image.htm';
> -    template['width'] = 550;
> -     template['height'] = 400 + (tinyMCE.isMSIE ? 25 : 0);
> -
> -    if (inst.settings['insertimage_callback']) {
> -        var returnVal = eval(inst.settings['insertimage_callback'] +
> "(src, alt, border, hspace, vspace, width, height, align, title,
> onmouseover, onmouseout, action);");
> -        if (returnVal && returnVal['src'])
> -            TinyMCE_WikieditorTheme.insertImage(returnVal['src'],
> returnVal['width'], returnVal['height'], returnVal['align']);
> -    } else {
> -        tinyMCE.openWindow(template, {editor_id : editor_id,
> scrollbars : 'yes', resizable : 'no', mce_windowresize: false, src :
> src, alt : alt, border : border, hspace : hspace, vspace : vspace,
> width : width, height : height, align : align, halign : halign, title :
> title, onmouseover : onmouseover, onmouseout : onmouseout, action :
> action, inline : "yes"});
> -    }
> -
> -    return this.dummyCommand();
> -}
> -
>  WikiEditor.prototype.convertImageInternal = function(regexp, result,
> content) {
>      var str="";
>      var href;
>
> Modified:
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/macros.js
> ===================================================================
> ---
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/macros.js
>       2007-01-10 06:06:45 UTC (rev 1927)
> +++
> xwiki/trunk/web/standard/src/main/webapp/wiki_editor/plugins/macros.js
>       2007-01-10 06:43:16 UTC (rev 1928)
> @@ -10,10 +10,8 @@
>               alert("Macros Plugin: You must load the core syntax plugin
> before!");
>               return;
>       }
> -
> +
>      this.addToolbarHandler('handleMacrosButtons');
> -
> -     this.addCommand('wikiMacro', 'macroCommand');
>  }
>
>  wikiEditor.initMacrosPlugin ();
> @@ -22,19 +20,6 @@
>       this.core.execInstanceCommand(editor_id, "mceInsertRawHTML",
> false, name);  }
>
> -
> -WikiEditor.prototype.macroCommand = function(editor_id, element,
> command, user_interface, value) {
> -     var template = new Array();
> -
> -    template['file'] = 'macro.htm';
> -     template['width'] = 520;
> -     template['height'] = 300;
> -
> -    tinyMCE.openWindow(template, {editor_id : editor_id, scrollbars :
> 'yes',  resizable : 'no', mce_windowresize: false});
> -
> -    return this.dummyCommand();
> -}
> -
>  WikiEditor.prototype.handleMacrosButtons = function(editor_id, node,
> undo_index, undo_levels, visual_aid, any_selection) {
>     tinyMCE.switchClass(editor_id + '_macro', 'mceButtonNormal');
>       do
>







___________________________________________________________________________
D�couvrez une nouvelle fa�on d'obtenir des r�ponses � toutes vos questions !
Profitez des connaissances, des opinions et des exp�riences des internautes sur Yahoo! Questions/R�ponses
http://fr.answers.yahoo.com




--
You receive this message as a subscriber of the xwiki-dev@objectweb.org mailing list.
To unsubscribe: mailto:xwiki-dev-unsubscribe@objectweb.org
For general help: mailto:sympa@objectweb.org?subject=help
ObjectWeb mailing lists service home page: http://www.objectweb.org/wws