APEX extension: Switch Application

Switch to another application page from current page designer

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name           APEX extension: Switch Application
// @namespace      iminglei.blogspot.com
// @description    Switch to another application page from current page designer
// @author         Ming (Tim) Lei

// @compatible     chrome Works with Chrome and Tampermonkey

// @include        http*://*/f?p=4000:4500:*

// @version        0.0.1
// ==/UserScript==

(function() {
    'use strict';

    // add "app switch" button to APEX Page Designer utilities menu bar
    var btn = '<button id="app_switch" title="Switch Application  [Ctrl+Alt+A]" class="a-Button a-Button--noLabel a-Button--iconTextButton js-menuButton a-Button--gapRight a-Button--simple" type="button">' +
        '<span class="a-Icon icon-irr-icons" aria-hidden="true"></span>' +
        '<span class="a-Icon icon-menu-drop-down" aria-hidden="true"></span>' +
        '</button>';
    $('#utilitiesMenu').after(btn);

    // set "app_switch" button click event
    $('#app_switch').on('click.switch', function() {

        // set iframe url
        var se = $v('pInstance'),
            appID = $v('P4500_CURRENT_APP'),
            la = apex.jQuery("#PDrenderingTree_0 span.a-TreeView-label").first().text(),
            pageID = la.substring(5, la.indexOf(":")),
            ifrSRC = 'f?p=APEXT:APP_SWITCH:::NO::G0_INSTANCE,G0_APPID,G0_PAGEID:' + se + ',' + appID + ',' + pageID;

        $('body').append(
            '<div id="div_switch"><iframe scrolling="no" style="position:absolute;height:130px" ' +
            'src="' + ifrSRC + '"></iframe></div>');

        // define dialog
        $("#div_switch").dialog({
            close: function() {
                $(this).dialog("destroy");
                $(this).remove();
                // show scroll bar
                $("body").css("overflow", "");
            },
            create: function() {
                // hide scroll bar
                $("body").css("overflow", "hidden");
            },
            height: 181,
            width: 650,
            position: {
                my: "center top",
                at: "center top",
                of: "#a_PageDesigner",
                //of: "#app_switch"
            },
            title: "Switch Application",
            draggable: true,
            modal: true,
            resizable: false,
            closeText: "Close  [Esc]",
            overlay: {
                background: "#000",
                opacity: 0.15
            }
        });
    });

    // set shortcut keys for "app_switch" button click event
    $(document).keydown(function(e) {
        if ((e.which === 65 || e.which === 97) && e.ctrlKey && e.altKey && !$("#div_switch").length) {
            $('#app_switch').trigger('click.switch');
        }
    });
})();