How to use the ko/windows.getMain function in ko

To help you get started, we’ve selected a few ko examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Komodo / KomodoEdit / src / chrome / komodo / content / project / customMenuProperties.js View on Github external
* decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */


//Arguments to window.arguments[0] are:
//    Required:
//        item: the item being edited
//        task: 'new' or 'edit'
//        type: the type of the part ('URL', 'template', etc...)
//        src:  the chrome of the image to be used in the dialog

var ko = require("ko/windows").getMain().ko;
var gPriority, gPriorityLabel, gOKButton, gPart, gItem;
var gAccessKey = null;
var tabs, gApplyButton;
var gPartType;
var gObserverSvc;
var partname;

function onLoad() {
    try {
        var dialog = document.getElementById("dialog-custommenuproperties");
        gOKButton = dialog.getButton("accept");
        gApplyButton = dialog.getButton("extra1");
        gApplyButton.setAttribute('label', 'Apply');
        gApplyButton.setAttribute('accesskey', 'a');
        gItem = window.arguments[0].item;
        gPartType = window.arguments[0].type;
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / editor.js View on Github external
this.setBookmark = function(lineNum, type = ko.markers.MARKNUM_BOOKMARK)
    {
        if ( ! lineNum )
        {
            lineNum = scimoz().lineFromPosition(scimoz().currentPos);
        }
        else
        {
            --lineNum;
        }

        var markerId=0;
        let mainWindow = require("ko/windows").getMain();
        let bookMarknum = type
        let data = {
                      'line': lineNum,
                   }
        // Clean the line of old markers and re-set it
        this.unsetBookmarkByLine();
        markerId = scimoz().markerAdd(lineNum, bookMarknum);
        return markerId;
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / about / about.js View on Github external
* either the GNU General Public License Version 2 or later (the "GPL"), or
 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 * in which case the provisions of the GPL or the LGPL are applicable instead
 * of those above. If you wish to allow use of your version of this file only
 * under the terms of either the GPL or the LGPL, and not to allow others to
 * use your version of this file under the terms of the MPL, indicate your
 * decision by deleting the provisions above and replace them with the notice
 * and other provisions required by the GPL or the LGPL. If you do not delete
 * the provisions above, a recipient may use your version of this file under
 * the terms of any one of the MPL, the GPL or the LGPL.
 * 
 * ***** END LICENSE BLOCK ***** */

/* Komodo's About dialog */

const w = require("ko/windows").getMain();
var ko = w.ko;
var log = ko.logging.getLogger("about");
var _bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
        .getService(Components.interfaces.nsIStringBundleService)
        .createBundle("chrome://komodo/locale/about.properties");
var infoSvc = Components.classes["@activestate.com/koInfoService;1"].
              getService(Components.interfaces.koIInfoService);


//---- interface routines for XUL

function onLoad()
{
    var iframe = window.frames[0];

    // Fill in Komodo build information.
github Komodo / KomodoEdit / src / modules / breadcrumbs / content / sdk / breadcrumbs.js View on Github external
var breadcrumbs = function(view) {

    /* Dependant interfaces */
    const {Cc, Ci} = require("chrome");
    const { NetUtil } =   window.Cu.import("resource://gre/modules/NetUtil.jsm", {});
    const w = require("ko/windows").getMain();
    const document = w.document;
    const legacy = w.ko;

    var RCService   = Cc["@activestate.com/koRemoteConnectionService;1"]
                        .getService(Ci.koIRemoteConnectionService);
    var koViews     = require("ko/views");
    var os          = Cc["@activestate.com/koOs;1"].getService(Ci.koIOs);
    var osPath      = Cc["@activestate.com/koOsPath;1"].getService(Ci.koIOsPath);
    var xtk         = window.xtk;
    var Iterator    = window.Iterator;

    /* Logging */
    var log = legacy.logging.getLogger('koBreadcrumbs');
    //log.setLevel(legacy.logging.LOG_DEBUG);

    /* Element References */
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / modal.js View on Github external
else
        {
            opts = {
                title: title,
                fields: fields,
                onComplete: onComplete,
                onReady: function() {},
                okLabel: okLabel,
                cancelLabel: cancelLabel,
            };
        }

        opts.okLabel = opts.okLabel || "Ok";
        opts.cancelLabel = opts.cancelLabel || opts.callback ? "Cancel" : "Close";

        var w = require("ko/windows").getMain();

        var dialog = w.openDialog("chrome://komodo/content/empty.xul?name=" + opts.title.replace(/\s+/g, ''), opts.title, "modal=true");
        dialog.title = opts.title;
        dialog.addEventListener("load", () => doOpen(opts, dialog));

        return dialog;
    };
github Komodo / KomodoEdit / src / chrome / komodo / content / templates / new.p.js View on Github external
*      templateOnly
 *          Is an optional boolean to limit the UI to just the selection of a
 *          template path. (Used by "Add Template..." in the Toolbox).
 *          Default is false.
 *
 * Output arguments (in window.arguments[0]):
 *      template
 *          Full path to the selected template. If the dialog was cancelled
 *          this is null.
 *      filename
 *          Full path to the selected target file, or null if the user didn't
 *          specify one.
 */


var ko = require("ko/windows").getMain().ko;
var log = ko.logging.getLogger("templates");
//log.setLevel(ko.logging.LOG_DEBUG);

var gPrefs = null;
var gTemplateSvc = null;
var gCategoriesView = null;
var gTemplatesView = null;

var options = null;
var openButton;

var _bundle = Components.classes["@mozilla.org/intl/stringbundle;1"]
    .getService(Components.interfaces.nsIStringBundleService)
    .createBundle("chrome://komodo/locale/templates/new.properties");

//---- interface routines for XUL
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / prefs.js View on Github external
/**
 * @copyright (c) 2015 ActiveState Software Inc.
 * @license Mozilla Public License v. 2.0
 * @author ActiveState
 * @overview -
 */

const {Cc, Ci} = require("chrome");
const w = require("ko/windows").getMain();

/**
 * Wrap the Komodo global preferences (XPCOM) object.
 */

/**
 * The prefs SDK allows you to access Komodo's preferences
 *
 * @module ko/prefs
 */
var exports = module.exports;
var prefs = Cc["@activestate.com/koPrefService;1"].
                getService(Ci.koIPrefService).prefs;
for (var name of Object.keys(prefs.__proto__)) {
    if (name == "QueryInterface") {
        continue;
github Komodo / KomodoEdit / src / modules / scope_packages / content / commands.js View on Github external
command: function()
            {
                commando.hide();
                require("ko/windows").getMain().openDialog(pkg.data.optionsURL, "chrome,titlebar,toolbar,centerscreen,modal");
            }
        }, uuid);
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / share / sources / logs.js View on Github external
(function()
{
    const koShare = require("ko/share");
    const w = require("ko/windows").getMain();
    const $ = require("ko/dom");
    const {Cc, Ci}  = require("chrome");
    
    var listening = false;
    
    this.load = function()
    {
        if (listening)
            return;
        
        listening = true;
        
        w.addEventListener("window_opened", function(e) {
            var windowPath = "chrome://komodo/content/tail/tail.xul";
            if( windowPath === e.detail.location.href)
            {
github Komodo / KomodoEdit / src / chrome / komodo / content / sdk / dialogs.js View on Github external
this.filepicker = (message, callback, opts) =>
    {
        var ss = require("ko/simple-storage").get("dialogs");
        var  legacy = require("ko/windows").getMain().ko;
        var _opts;

        if (typeof callback == "object")
        {
            _opts = callback;
            callback = opts;
            opts = _opts;
        }

        _opts = {};
        var props = ["type", "path", "callback"];
        _.each(props, (prop) => { _opts[prop] = opts[prop] || null; });

        message = message || "Choose path";
        opts.type = opts.type || "file";
        opts.path = opts.path || ss.storage.filepicker_path || legacy.uriparse.URIToLocalPath(legacy.places.getDirectory());