コード例 #1
0
ファイル: colorscheme.js プロジェクト: jimiy/KomodoEdit
 var init = () =>
 {
     var observer = {observe: () =>
     {
         currentScheme = {
             'editor-scheme': null,
             'interface-scheme': null,
             'widget-scheme': null
         };
         colorCache = {};
     }};
     
     prefs.prefObserverService.addObserverForTopics(
         observer, [3], ['editor-scheme', 'interface-scheme', 'widget-scheme'], false
     );
 };
コード例 #2
0
ファイル: dynamic-button.js プロジェクト: Defman21/KomodoEdit
        this.init = function()
        {
            button = $("<toolbarbutton>");
            button.attr({
                id: "dynamicBtn-" + opts.id,
                tooltiptext: opts.tooltip,
                type: "button",
                disabled: "true",
                class: "dynamic-button " + opts.classList
            });
            button.element()._dynamicButton = this;
            
            if (typeof opts.command == "string")
            {
                button.attr("oncommand", "ko.commands.doCommandAsync('"+opts.command+"', event)");
                button.attr("observes", opts.command);
            }
            else if (opts.command)
                button.on("command", opts.command);
                
            if (opts.icon)
            {
                button.addClass("icon-" + opts.icon);
            }
            else if (opts.image)
                button.attr("image", opts.image);
            
            if (opts.label)
                button.attr("label", opts.label);
                
            if (opts.ordinal)
                button.attr("ordinal", opts.ordinal);
                
            if (opts.menuitems)
            {
                button.attr("type", opts.command ? "menu-button" : "menu");

                menupopup = $("<menupopup>");
                menupopup.on("popupshowing", (e) =>
                {
                    if (e.originalTarget != menupopup.element())
                        return;

                    this.updateMenu();
                });
                button.append(menupopup);
            }
            
            var groupItem = tb.find("#dynamicBtnGrp-" + opts.group);
            if ( ! groupItem.length)
            {
                groupItem = $("<toolbaritem>");
                groupItem.attr("id", "dynamicBtnGrp-" + opts.group);
                if (opts.groupOrdinal)
                    groupItem.attr("ordinal", opts.groupOrdinal);
                tb.append(groupItem);
            }
            
            if ( ! opts.isEnabled)
            {
                if (typeof opts.command == "string")
                {
                    var controller = window.controllers.getControllerForCommand(opts.command);
                    if (controller)
                    {
                        opts.isEnabled = () =>
                        {
                            return controller.isCommandEnabled(opts.command);
                        }
                    }
                }
                
                if ( ! opts.isEnabled)
                    opts.isEnabled = () => false;
            }
            
            if (ss.storage.buttons[opts.id].hide)
                this.hide();
            
            groupItem.append(button);
            
            for (let event of opts.events)
            {
                if (event.indexOf("observe:") === 0)
                {
                    obsvc.addObserver(observer, event.substr(8), false);
                }
                else if (event.indexOf("pref:") === 0)
                {
                    prefs.prefObserverService.addObserver(observer, event.substr(5), false);
                }
                else
                {
                    w.addEventListener(event, this.update.bind(this, false));
                }
            }
            
            w.addEventListener("update_dynamic_buttons", this.update.bind(this, false));
            
            this.update();
        }