示例#1
0
        function prepareDropPaths(fileList) {
            // Convert FileList object to an Array with all image files first, then CSS
            // followed by HTML files at the end, since we need to write any .css, .js, etc.
            // resources first such that Blob URLs can be generated for these resources
            // prior to rewriting an HTML file.
            function rateFileByType(filename) {
                var ext = Path.extname(filename);

                // We want to end up with: [images, ..., js, ..., css, html]
                // since CSS can include images, and HTML can include CSS or JS.
                // We also treat .md like an HTML file, since we render them.
                if(Content.isHTML(ext) || Content.isMarkdown(ext)) {
                    return 10;
                } else if(Content.isCSS(ext)) {
                    return 8;
                } else if(Content.isImage(ext)) {
                    return 1;
                }
                return 3;
            }

            return _.toArray(fileList).sort(function(a,b) {
                a = rateFileByType(a.name);
                b = rateFileByType(b.name);

                if(a < b) {
                    return -1;
                }
                if(a > b) {
                    return 1;
                }
                return 0;
            });
        }
示例#2
0
        _.forEach(_customKeyMapCache, function (commandID, key) {
            var normalizedKey  = normalizeKeyDescriptorString(key),
                defaults       = _.find(_.toArray(_defaultKeyMap), { "commandID": commandID }),
                defaultCommand = _defaultKeyMap[normalizedKey];

            // We didn't modified this before, so skip it.
            if (_isSpecialCommand(commandID) ||
                    _isReservedShortcuts(normalizedKey)) {
                return;
            }

            if (_isKeyAssigned(normalizedKey) &&
                    _customKeyMap[key] !== commandID && _customKeyMap[normalizedKey] !== commandID) {
                // Unassign the key from any command. e.g. "Cmd-W": "file.open" in _customKeyMapCache
                // will require us to remove Cmd-W shortcut from file.open command.
                removeBinding(normalizedKey);
                
                // Reassign the default key binding. e.g. "Cmd-W": "file.open" in _customKeyMapCache
                // will require us to reassign Cmd-O shortcut to file.open command.
                if (defaults) {
                    addBinding(commandID, defaults, brackets.platform);
                }

                // Reassign the default key binding of the previously modified command. 
                // e.g. "Cmd-W": "file.open" in _customKeyMapCache will require us to reassign Cmd-W
                // shortcut to file.close command.
                if (defaultCommand && defaultCommand.key) {
                    addBinding(defaultCommand.commandID, defaultCommand.key, brackets.platform);
                }
            }
        });