Пример #1
0
    window.OnPreferencePageLoading = (prefset) =>
    {
        var pref = prefset.getPref('notify_disabled_categories');
        var categories = notify.categories.get();
        var wrapper = $("#enabled-notifications-vbox");

        log.debug("Disabled categories: " + pref.length);

        var i = 0, wrap;
        for (let key in categories)
        {
            if (++i % 2) wrap = $('<hbox>');

            let category = categories[key];
            let elem = $('<checkbox>');
            elem.attr(
            {
                label: category.label,
                value: key,
                checked: pref.findString(key) == -1
            });

            wrap.append(elem);
            if ( ! (i % 2))
            {
                wrapper.append(wrap);
            }
        }
    }
Пример #2
0
    this.register = (commandName, command, opts = {}) =>
    {
        if (commandName.indexOf("cmd") !== 0)
            commandName = "cmd_" + commandName;

        if ( ! commandName.match(/^[a-zA-Z0-9_\-]+$/))
            throw new this.exceptionInvalidCommandName;

        if (document.getElementById(commandName))
            throw new this.exceptionAlreadyUsed;

        var commandNode = $("<command/>", _window);
        commandNode.attr({
            id: commandName,
            key: "key_" + commandName,
            onCommand: "ko.commands.doCommandAsync('"+commandName+"', event)",
            desc: opts.label || commandName
        });
        $("#allcommands", _window).append(commandNode);

        log.debug(("defaultBind" in opts));
        if (("defaultBind" in opts) && opts.defaultBind)
        {
            var keybinds = require("ko/keybindings");
            keybinds.register(commandName, opts.defaultBind, opts.forceBind);
        }

        local.registered[commandName] = {
            command: command,
            opts: opts
        };
    }
Пример #3
0
	this.addPanel = function(){
		ko.views.manager.currentView.setFocus();
		var view 	= $(require("ko/views").current().get()),
		LESSpanel	= $("<statusbarpanel id='statusbar-less' />");
		
		if (view === undefined) {
			return;
 		}
		
		if ($('#statusbar-less').length > 0) {
			$('#statusbar-less').remove();
		}
		
		view.findAnonymous("anonid", "statusbar-encoding").before(LESSpanel);
 	}
Пример #4
0
 this.loadSample = () =>
 {
     var sample = $('#sample');
     
     if ( ! ("initialized" in this.loadSample))
     {
         scintillaOverlayOnLoad();
         
         var view = sample.element();
         sample.element().initWithBuffer("", "Text");
         
         var scimoz = sample.element().scimoz;
         for (var i=0; i <= scimoz.SC_MAX_MARGIN; i++) 
             scimoz.setMarginWidthN(i, 0);
         
         scimoz.wrapMode = 1;
         scimoz.readOnly = 1;
             
         this.loadSample.initialized = true;
         
         var languageRegistry = Cc["@activestate.com/koLanguageRegistryService;1"].getService(Ci.koILanguageRegistryService);
         var sampleText = languageRegistry.getLanguage("Python").sample;
         view.setBufferText(sampleText);
         view.language = "Python";
     }
     
     var schemeService = Cc['@activestate.com/koScintillaSchemeService;1'].getService();
     var scintilla = sample.element().scimoz;
     var encoding = 'unused';
     var alternateType = false;
     var scheme = schemeService.getScheme(fields.colorScheme.value());
     scheme.applyScheme(scintilla, "Python", encoding, alternateType);
 };
Пример #5
0
 this.init = () =>
 {
     this.createFields();
     
     var wizard = $("<wizard>").attr("flex", "1");
     wizard.append(this.getPageUI().$element);
     wizard.append(this.getPageEditor().$element);
     
     wizard.on("wizardcancel", this.onCancel);
     wizard.on("wizardfinish", this.onFinish);
     wizard.on("wizardnext", this.onNext);
     
     $("window").append(wizard);
     
     this.loadSample();
 };
Пример #6
0
	insertLessVar = function() {
		var scimoz = ko.views.manager.currentView.scimoz,
			currentLine =	scimoz.lineFromPosition(scimoz.currentPos),
			input = $('#less_auto');

		if (input.length > 0) {
			var val = input.value();

			if (val.length > 0) {
				scimoz.insertText(scimoz.currentPos, val);
				scimoz.gotoPos(scimoz.currentPos + val.length);
			}
			input.parent().remove();
			ko.views.manager.currentView.setFocus();
			
			setTimeout(function(){
				if (scimoz.lineFromPosition(scimoz.currentPos) > currentLine) {
					scimoz.homeExtend();
					scimoz.charLeftExtend();
					scimoz.replaceSel('');
				}
				
			}, 50);
		}
	}
Пример #7
0
    this.setSubscope = function(subscope, record = true)
    {
        if (subscope && ! (subscope.scope in local.scopes))
            return log.error("Subscope does not exist: " + subscope.scope);

        if (subscope)
        {
            log.debug("Setting Subscope");

            if (local.subscope && record)
            {
                local.history.push({
                    subscope: local.subscope,
                    query: local.prevSearchValue
                });
            }

            var el = $(template('subscope', {scope: subscope, scopes: local.history}));
            elem('subscopeWrap').html(el).show();
            elem('panel').addClass("subscoped");
        }
        else
        {
            log.debug("Removing Subscope");

            elem('subscopeWrap').empty().hide();
            elem('panel').removeClass("subscoped");
        }

        local.subscope = subscope;

        this.clear();

        return true;
    }
Пример #8
0
        this.initWithLabel = function(label, options = {})
        {
            if (label && typeof label == "object")
            {
                options = label;
                label = null;
            }

            this.parseOptions(options);
            options = this.options;
            
            if (options.label)
            {
                label = options.label;
            }
            
            if (typeof label == "string")
            {
                this.attributes.label = label;
            }

            this.$element = $($.create(this.name, this.attributes).toString());
            this.$element.addClass("ui-" + this.name);
            this.element = this.$element.element();
            this.element._sdk = this;
        };
Пример #9
0
	abortLessVarCompletion = function() {
		var comp = $('#less_wrapper');

		if (comp.length > 0) {
			comp.remove();
			ko.views.manager.currentView.setFocus();
		}
	}
Пример #10
0
 this.init = function(value, options = {})
 {
     this.parseOptions(options);
     this.$element = $($.create(this.name, this.attributes).toString());
     this.$element.text(value);
     this.$element.addClass("ui-span");
     this.element = this.$element.element();
 };
Пример #11
0
	this._updateView = function() {
		var wrapper = $('#less_wrapper');
		if (wrapper.length > 0) {
			wrapper.remove();
		}

		self._updateStatusBar();
	}
Пример #12
0
        this.init = function(label, options = {})
        {
            if (Array.isArray(options))
            {
                options = { options: options };
            }

            if (typeof label == "object")
            {
                options = label;
                label = null;
            }
            else if (label)
            {
                options.label = label;
            }

            this.parseOptions(options);
            options = this.options;

            this.$element = $($.createElement(this.name));
            this.$element.addClass("ui-radiogroup-wrapper");
            this.element = this.$element.element();
            this.element._sdk = this;

            this.$formElement = $($.createElement("radiogroup", this.attributes));
            this.$formElement.addClass("ui-radiogroup");
            this.formElement = this.$formElement.element();
            this.$element.append(this.formElement);

            if (options.label)
            {
                this.$element.prepend(require("./label").create(options.label).element);
            }
            var radioBtns = options.options;
            if (radioBtns && Array.isArray(radioBtns))
            {
                this.addRadioItems(radioBtns);
            }
            else if (radioBtns && ! Array.isArray(radioBtns))
            {
                log.warn("Radio items must be in an array.  Failed to add menu "+
                         "items to menu.");
            }
        };
Пример #13
0
        this.init = function(options = {})
        {
            this.parseOptions(options);

            this.$element = $($.create(this.name, this.attributes).toString());
            this.$element.addClass("ui-" + this.name);
            this.element = this.$element.element();
            this.element._sdk = this;
        };
Пример #14
0
        var hideOnClick = function(e)
        {
            if (running) return; // Unless the command is still running
            $("#komodo_main").off(hideOnClick);
            if ( ! showing) return;

            var target = e.originalTarget || e.target;
            while((target=target.parentNode) && target !== hud.element() && target.nodeName != "dialog");
            if ( ! target) hud.element().hidePopup();
        };
Пример #15
0
     contexts.each(function()
     {
         let context = $(this);
         
         let id = "sdk_menuitem_" + context.uniqueId() + opts.id;
         context.find(id).remove();
 
         let menuitem = document.createElementNS(XUL_NS, !opts.separator ? 'menuitem' : 'menuseparator');
         menuitem.setAttribute("id", id);
         if (!opts.separator) {
             menuitem.setAttribute("label", opts.label);
             menuitem.setAttribute("image", opts.image);
             menuitem.setAttribute("class", opts.classList);
             menuitem.setAttribute("disabled", opts.disabled || false);
             menuitem.addEventListener("command", opts.command);
         }
         
         // Optionally set custom attributes
         try
         {
             if (opts.attributes)
             {
                 for (let k in opts.attributes)
                 {
                     if ( ! opts.attributes.hasOwnProperty(k)) continue;
                     menuitem.setAttribute(k, opts.attributes[k]);
                 }
             }
         } catch (e)
         {
             log.exception(e, "Setting attributes failed");
         }
         
         menuitem.classList.add("sdk-menuitem");
 
         menuitem.sdkOpts = opts;
 
         let sibling, appended;
         if (contextOpts.before || contextOpts.after)
         {
             sibling = context.find(contextOpts.before || contextOpts.after);
             if (sibling.length)
             {
                 sibling[contextOpts.before ? 'before' : 'after'](menuitem);
                 appended = true;
             }
         }
 
         if ( ! appended)
         {
             context.append(menuitem);
         }
 
         placeMenuEventListener(context);
     });
Пример #16
0
    this.unregisterScope = function(id)
    {
        if ( ! (id in local.scopes)) return;

        log.debug("Unregistering Scope: " + id);

        $("#scope-" + id).delete();
        delete local.scopes[id];

        commands.unregister(id);
    }
Пример #17
0
        this.init = function(value, options = {})
        {
            var attributes = Object.assign(options.attributes || {}, this.attributes);

            this.options = options;
            this.attributes = attributes;
            this.$element = $($.create(this.name, attributes).toString());
            this.$element.text(value);
            this.$element.addClass("ui-span");
            this.element = this.$element.element();
        };
Пример #18
0
    var init = function()
    {
        $(window).on("folder_touched", require("contrib/underscore").debounce(function(e)
        {
            scope.deleteCachePath(e.detail.path);

            if (commando.getScope().handler == "scope-files/files")
            {
                commando.reSearch();
                if (commando.isOpen()) commando.focus();
            }
        }, 100));
    };
Пример #19
0
    this.init = function breadcrumbs_init()
    {
        log.debug("Init");
        
        if ( ! view || view.getAttribute("type") != "editor") return;
        
        crumbView = view;
        
        var $ = require("ko/dom");
        xv = $(view);

        self = this;

        var breadcrumbBarWrap = $('#breadcrumbBarWrap').clone();
        breadcrumbBarWrap.removeAttr("id");
        
        breadcrumbBar           = breadcrumbBarWrap.find('[anonid="breadcrumbBar"]').element();
        template.crumbFile      = breadcrumbBarWrap.find('[anonid="breadcrumbTemplateFile"]').element();
        template.crumbFolder    = breadcrumbBarWrap.find('[anonid="breadcrumbTemplateFolder"]').element();
        template.crumbMenuFile  = breadcrumbBarWrap.find('[anonid="breadcrumbMenuFileTemplate"]').element();
        template.crumbMenuFolder= breadcrumbBarWrap.find('[anonid="breadcrumbMenuFolderTemplate"]').element();
        template.crumbMenupopup = breadcrumbBarWrap.find('[anonid="breadcrumbMenupopupTemplate"]').element();
        template.overflowItem   = breadcrumbBarWrap.find('[anonid="overflowMenuTemplate"]').element();
        overflowBtn             = breadcrumbBarWrap.find('[anonid="breadcrumbOverflowBtn"]').element();
        
        sectionList             = xv.findAnonymous('anonid', "statusbar-sectionlist").element();
        
        var parent = xv.findAnonymous("anonid", "statusbar-message-deck-default");
        parent.append(breadcrumbBarWrap);

        // Bind event listeners
        this.bindListeners();

        // Register Controller 
        //window.controllers.appendController(this.controller);

        this.load();
    };
Пример #20
0
 function addButton()
 {
     $("#trackChangesShareButton").remove();
     
     // Update button in track changes
     var $trackchanges = $("#changeTracker_hbox");
     
     // Create the button if it doens't exist
     var shareButton = require("ko/ui/button").create('Share',
         {
             attributes:
             {
                 type: "menu",
                 id: "trackChangesShareButton",
                 tooltiptext:"Share Changeset .."
             }
         });
     
     //Create the new modules menuitem for this menu
     for (let id in koShare.modules)
     {
         let module = koShare.modules[id];
         let menuitem = require("ko/ui/menuitem").create({
             attributes: {
                 label:  module.label
             }
         });
         
         menuitem.on("command", share.bind(this, module.name));
         
         // Add it to the menu
         shareButton.addMenuItem(menuitem);
     }
     
     // Append the share button to the track changes panel
     $trackchanges.append(shareButton.element);
 }
Пример #21
0
        this.initWithAttribute = function(attribute, value, options = {})
        {
            if (typeof attribute == "object")
                options = attribute;
            else if (typeof value == "object")
                options = value;
                
            this.parseOptions(options);

            if (typeof attribute != "object" && typeof value != "object")
                this.attributes[attribute] = value;
            
            this.$element = $($.create(this.name, this.attributes).toString());
            this.$element.addClass("ui-" + this.name);
            this.element = this.$element.element();
        };
Пример #22
0
    this.unregister = (id, opts) =>
    {
        id = id.replace(/\W+/g, "");

        var context = _parseContext(opts.context);
        for (let i=0;i<context.length;i++)
        {
            let contextOpts = context[i];
            let _context = $(contextOpts.select);
            if ( ! _context || ! _context.length || _context.element().nodeName != "menupopup")
                throw new exceptionInvalidContext(contextOpts.select || "null");

            // TODO: this does not work.
            // $("#sdk_menuitem_" + _context.uniqueId() + id).element().remove() works.
            _context.find("sdk_menuitem_" + _context.uniqueId() + id).element().remove();
        }
    }
Пример #23
0
 this.init = function($element = {}, options = {})
 {
     // The only arg passed in might only be options
     if (!$element.koDom)
     {
         options = $element;
     }
     var newElem = $.create(this.type, options.attributes || {})
     var $newElem = $(newElem.toString());
     // if content has been provided append it to the element
     if($element && $element.koDom)
     {
         $newElem.append($element);
     }
     this.$elem = $newElem; // koDom object
     this.element = this.$elem.element.bind(this.$elem); // Actual DOM object
 };
Пример #24
0
    this.unregister = (commandName) =>
    {
        if (commandName.indexOf("cmd") !== 0)
            commandName = "cmd_" + commandName;

        if ( ! (commandName in local.registered))
        {
            log.warn("Trying to unregister nonexistant command: " + commandName);
            return;
        }

        var opts = local.registered[commandName].opts;
        var label = local.registered[commandName].opts.label || commandName;
        keybinds.unregister(commandName,label);

        $("#"+commandName).remove();
        delete local.registered[commandName];
    }
Пример #25
0
        this.init = function(listitems = [], options = {})
        {
            if ( ! Array.isArray(listitems) && typeof listitems == "object")
            {
                options = listitems;
                listitems = null;
            }

            this.parseOptions(options);
            options = this.options;

            if ("listitems" in options)
            {
                listitems = options.listitems;
            }

            this.$element = $($.createElement(this.name, this.attributes));
            this.$element.addClass("ui-" + this.name);
            this.element = this.$element.element();

            if (listitems && Array.isArray(listitems))
            {
                this.addListItems(listitems);
            }
            else if (listitems && ! Array.isArray(listitems))
            {
                log.warn("List items must be in an array.  Failed to add list "+
                         "items to listbox.");
            }

            if ("listheaders" in options)
            {
                this.addListHeaders(options.listheaders);
            }

            if ("listcols" in options)
            {
                this.addListCols(options.listcols);
            }
        };
Пример #26
0
    window.OnPreferencePageOK = (prefset) =>
    {
        var pref = prefset.getPref('notify_disabled_categories');

        $("checkbox").each(function()
        {
            var id = this.getAttribute("value");
            var disabled = pref.findString(id) != -1;

            if ( ! this.checked && ! disabled)
            {
                log.debug("Add: " + id);
                pref.appendString(id);
            }
            else if (this.checked && disabled)
            {
                log.debug("Remove: " + id);
                pref.findAndDeleteString(id);
            }
        });
        return true;
    }
Пример #27
0
 this.getPageUI = () =>
 {
     var page = require("ko/ui/wizardpage").create();
     
     var appearanceGroupbox = page.addGroupbox({caption: "Appearance"});
     var integrationGroupbox = page.addGroupbox({caption: "Integration"});
     
     // Color scheme
     appearanceGroupbox.addRow([
         require("ko/ui/label").create("Color Scheme: "),
         fields.colorScheme
     ]);
     fields.colorScheme.onChange(this.loadSample);
     
     appearanceGroupbox.addRow($("#sample-stack"));
     
     // I don't like changes
     appearanceGroupbox.addRow(fields.classicMode);
     
     // Native window borders
     appearanceGroupbox.addRow(fields.nativeBorders);
     
     // Minimap
     appearanceGroupbox.addRow(fields.minimap);
     
     // Key bindings
     integrationGroupbox.addRow([
         require("ko/ui/label").create("Key Bindings: "),
         fields.keybinding
     ]);
     
     // Browser
     integrationGroupbox.addRow([
         require("ko/ui/label").create("Default Browser: "),
         fields.browser
     ]);
     
     return page;
 };
Пример #28
0
 this.initWithElement = function(appendElement = null, options = {})
 {
     if ( ! Array.isArray(appendElement) && appendElement)
     {
         if ("isSdkElement" in appendElement || "koDom" in appendElement ||
             "nodeName" in appendElement || ("type" in appendElement && ! ("attributes" in appendElement)))
         {
             appendElement = [appendElement];
         } 
         else
         {
             options = appendElement;
             appendElement = null;
         }
     }
     
     this.parseOptions(options);
     this.$element = $($.create(this.name, this.attributes).toString());
     this.$element.addClass("ui-" + this.name);
     this.element = this.$element.element();
     
     this.addElement(appendElement);
 };
Пример #29
0
        process.on('close', function (code, signal)
        {
            if (code !== 0)
            {
                log.debug("child process ended with code " + code + ", stdout: " + stdout + ", stderr: " + stderr);
            }

            if (lastLine)
            {
                callbacks.stdout.forEach(function(callback)
                {
                    callback(lastLine);
                });
            }

            callbacks.complete.forEach(function(callback)
            {
                callback(stdout, stderr, code, signal);
            });

            if (w)
                $(w.document).trigger("process_close");
        });
Пример #30
0
    this.chooseTemplate = (path, callback) =>
    {
        var $ = require("ko/dom");
        var commando = require("commando");

        commando.showSubscope("scope-tools", "tool-category-template");

        var handleViewOpened = (e) =>
        {
            window.removeEventListener("editor_view_opened_from_template", handleViewOpened);

            var view = e.detail.view;
            if ( ! view.koDoc.isUntitled)
                return;

            if (path)
            {
                if ( ! path.match(/\w\.\w+$/))
                {
                    var filename = require("ko/dialogs").prompt("Saving to " + path, { label: "Filename:" });
                    path = require("ko/file").join(path, filename);
                }
                view.saveAsURI(ko.uriparse.localPathToURI(path));
            }

            callback(e.detail);
        };

        window.addEventListener("editor_view_opened_from_template", handleViewOpened);
        $("#commando-panel").once("popuphidden", () =>
        {
            setTimeout(() =>
            {
                window.removeEventListener("editor_view_opened_from_template", handleViewOpened);
            }, 1000);
        });
    };