Esempio n. 1
0
function addFckPopupJS($src)
{
    $res = "";
    $res .= "<script type=\"text/javascript\"><!--\n";
    // ---------------------------------------------------------------------------
    $res .= "function insItem() {\n";
    $type = getPopupSelType();
    switch ($type) {
        case "image":
            $res .= "dialogArguments = window.opener.FCKLastDialogInfo ;\n";
            $res .= "var oEditor\t\t= dialogArguments.Editor ;\n";
            $res .= "var FCK\t\t\t= oEditor.FCK ;\n";
            $res .= "var FCKLang\t\t= oEditor.FCKLang ;\n";
            $res .= "var FCKConfig\t= oEditor.FCKConfig ;\n";
            $res .= "var titleTxt = GetE('title_text').value;\n";
            $res .= "var altTxt = GetE('alt_text').value;\n";
            $res .= "// Get the selected item (if available).\n";
            $res .= "var oItem = FCK.Selection.GetSelectedElement() ;\n";
            $res .= "var bHasItem = ( oItem != null ) ;\n";
            $res .= "if ( bHasItem ) {\n";
            $res .= "FCK.Selection.Delete() ;\n";
            $res .= "}\n";
            $res .= "oItem = FCK.CreateElement( 'IMG' ) ;\n";
            $res .= "oItem.src=\"" . $src . "\" ;\n";
            $res .= "oItem.title=titleTxt ;\n";
            $res .= "oItem.alt=altTxt ;\n";
            break;
        case "flash":
            $res .= "dialogArguments = window.opener.FCKLastDialogInfo ;\n";
            $res .= "var oEditor\t\t= dialogArguments.Editor ;\n";
            $res .= "var FCK\t\t\t= oEditor.FCK ;\n";
            $res .= "var FCKLang\t\t= oEditor.FCKLang ;\n";
            $res .= "var FCKConfig\t= oEditor.FCKConfig ;\n";
            $res .= "var itemWidth = GetE('width').value;\n";
            $res .= "var itemHeight = GetE('height').value;\n";
            $res .= "var itemBgCol = GetE('bgcolor').value;\n";
            $res .= "// Get the selected item (if available).\n";
            $res .= "var oItem = FCK.Selection.GetSelectedElement() ;\n";
            $res .= "var bHasItem = ( oItem != null ) ;\n";
            $res .= "if ( bHasItem ) {\n";
            $res .= "FCK.Selection.Delete() ;\n";
            $res .= "}\n";
            $res .= "oItem = FCK.CreateElement( 'embed' ) ;\n";
            $res .= "oItem.src=\"" . $src . "\" ;\n";
            $res .= "oItem.bgcolor=itemBgCol ;\n";
            $res .= "oItem.width=itemWidth ;\n";
            $res .= "oItem.height=itemHeight ;\n";
            $res .= "oItem.type=\"application/x-shockwave-flash\" ;\n";
            $res .= "FCK.OnAfterSetHTML() ;\n";
            break;
        case "audio":
        case "video":
        case "streaming":
            addAjaxJs();
            // req. by our friend json..
            $res .= "dialogArguments = window.opener.FCKLastDialogInfo ;\n";
            $res .= "var oEditor\t\t= dialogArguments.Editor ;\n";
            $res .= "var FCK\t\t\t= oEditor.FCK ;\n";
            $res .= "var FCKLang\t\t= oEditor.FCKLang ;\n";
            $res .= "var FCKConfig\t= oEditor.FCKConfig ;\n";
            $res .= "var html_code = GetE('embed_code').value;\n";
            $res .= 'var parsed = unescape(html_code);' . "\n";
            $res .= 'parsed = parsed.evalJSON(true);' . "\n";
            $res .= "FCK.InsertHtml(parsed.code);\n";
            $res .= "FCK.OnAfterSetHTML() ;\n";
            break;
    }
    $res .= "window.close();\n";
    $res .= "}\n\n";
    // ---------------------------------------------------------------------------
    $res .= getPopupCommonCode();
    $res .= "--></script>\n";
    return $res;
}
Esempio n. 2
0
function addWidgLinkPopupAfterJS()
{
    $res = "";
    $type = getPopupSelType();
    $res .= "var theToolbar \t\t= window.opener.widg.theToolbar;\n";
    $res .= "var theWidgEditor \t= window.opener.widg.theWidgEditor;\n";
    $res .= "var theIframe \t\t= window.opener.widg.theIframe;\n";
    $res .= 'var code_field = GetE("code");' . "\n";
    $res .= 'var url_field = GetE("url");' . "\n";
    $res .= 'var title_field = GetE("title");' . "\n";
    switch ($type) {
        case "link":
            $res .= <<<JS_END
\t\t\t\tbrowser = get_browser_obj();
\t\t\t\tif (browser.IE) {
\t\t\t\t\ttext = theIframe.contentWindow.document.selection;
\t\t\t\t}
\t\t\t\telse {
\t\t\t\t\tvar text = theIframe.contentWindow.getSelection();
\t\t\t\t}

\t\t\t\tcode_field.value = text;
\t\t\t\turl_field.value = text.anchorNode.parentNode.getAttribute('href');
\t\t\t\ttitle_field.value = text.anchorNode.parentNode.getAttribute('title');
JS_END;
            $res .= "\n";
            break;
    }
    return $res;
}