Merge pull request +10765 from c9/feature/scm

[WIP] Refactor of SCM Panel
pull/282/head
Harutyun Amirjanyan 2016-03-30 11:55:09 +04:00
commit f59a6b4fbc
32 zmienionych plików z 382 dodań i 74 usunięć

Wyświetl plik

@ -806,13 +806,28 @@ module.exports = function(options) {
"plugins/c9.ide.test.mocha/mocha",
// git integration v2
// {
// packagePath: "plugins/c9.ide.scm/scm.commit",
// staticPrefix: staticPrefix + "/plugins/c9.ide.scm"
// },
// "plugins/c9.ide.scm/scm",
// "plugins/c9.ide.scm/scm.branches",
// "plugins/c9.ide.scm/dialog.localchanges",
// "plugins/c9.ide.scm/scm.log",
// "plugins/c9.ide.scm/git",
// "plugins/c9.ide.scm/diff.split",
// "plugins/c9.ide.scm/diff.unified",
// // git integration v1
"plugins/c9.ide.scm/v1/scm",
"plugins/c9.ide.scm/v1/scmpanel",
"plugins/c9.ide.scm/v1/detail",
"plugins/c9.ide.scm/v1/log",
"plugins/c9.ide.scm/v1/git",
"plugins/c9.ide.scm/v1/editor",
// git integration
"plugins/c9.ide.scm/scm",
"plugins/c9.ide.scm/scmpanel",
"plugins/c9.ide.scm/detail",
"plugins/c9.ide.scm/log",
"plugins/c9.ide.scm/git",
"plugins/c9.ide.scm/editor",
"plugins/c9.ide.scm/mergetool"
];

Wyświetl plik

@ -772,7 +772,7 @@ function Folding() {
this.removeFold(fold);
else
this.expandFold(fold);
return;
return fold;
}
var range = this.getFoldWidgetRange(row, true);
@ -781,7 +781,7 @@ function Folding() {
fold = this.getFoldAt(range.start.row, range.start.column, 1);
if (fold && range.isEqual(fold.range)) {
this.removeFold(fold);
return;
return fold;
}
}

Wyświetl plik

@ -214,7 +214,7 @@ function LineWidgets(session) {
if (!w.coverGutter) {
w.el.style.zIndex = 3;
}
if (!w.pixelHeight) {
if (w.pixelHeight == null) {
w.pixelHeight = w.el.offsetHeight;
}
if (w.rowCount == null) {

2
node_modules/ace/lib/ace/mode/diff.js wygenerowano vendored
Wyświetl plik

@ -38,7 +38,7 @@ var FoldMode = require("./folding/diff").FoldMode;
var Mode = function() {
this.HighlightRules = HighlightRules;
this.foldingRules = new FoldMode(["diff", "index", "\\+{3}", "@@|\\*{5}"], "i");
this.foldingRules = new FoldMode(["diff", "@@|\\*{5}"], "i");
};
oop.inherits(Mode, TextMode);

Wyświetl plik

@ -61,7 +61,7 @@ oop.inherits(FoldMode, BaseFoldMode);
}
if (row == start.row + 1)
return;
return Range.fromPoints(start, {row: row - 1, column: line.length});
return new Range(start.row, start.column, row - 1, line.length);
};
}).call(FoldMode.prototype);

Wyświetl plik

@ -417,7 +417,7 @@ DataProvider.variableHeightRowMixin = function() {
var items = this.visibleItems;
var top = 0, index = 0, l = items.length;
while (index < l) {
var height = this.getItemHeight(items[index].height, index);
var height = this.getItemHeight(items[index], index);
top += height;
index++;
if (top >= offset) {
@ -445,7 +445,7 @@ DataProvider.variableHeightRowMixin = function() {
var items = this.visibleItems;
var startH = 0, index = 0, l = items.length;
while (index < l) {
var height = this.getItemHeight(items[index].height, index);
var height = this.getItemHeight(items[index], index);
startH += height;
index++;
if (startH >= top) {

Wyświetl plik

@ -51,7 +51,7 @@ var Cells = function(parentEl) {
this.$renderRow(html, datarow, vsize, hsize, row);
}
if (firstRow === 0 && lastRow === 0) {
if (firstRow <= 0 && lastRow <= 0) {
this.renderPlaceHolder(provider, html, config);
}
@ -130,7 +130,7 @@ var Cells = function(parentEl) {
provider.renderRow(row, html, config);
}
if (firstRow === 0 && lastRow === 0) {
if (firstRow <= 0 && lastRow <= 0) {
this.renderPlaceHolder(provider, html, config);
}
@ -187,7 +187,7 @@ var Cells = function(parentEl) {
} else if (provider.getEmptyMessage) {
html.push(
"<div class='message empty'>",
provider.getEmptyMessage(),
escapeHTML(provider.getEmptyMessage()),
"</div>"
);
}

Wyświetl plik

@ -68,6 +68,7 @@ function ColumnHeader(parentEl, renderer) {
}
col.pixelWidth = 0;
}, this);
columns.fixedWidth = fixedWidth;
columns.$fixedWidth = fixedWidth + "px";
columns.width = null;
provider.columns = columns;

Wyświetl plik

@ -427,7 +427,7 @@ var host = location.protocol + "//" + location.hostname + (location.port ? ":" +
var loadScript = function(path, id, callback) {
if (!config.useCache)
return loadScriptWithTag(path, id, callback);
if (!/https?:/.test(path))
if (!/^https?:/.test(path))
path = host + path;
var cb = function(e, val, deps) {
if (e) return processLoadQueue({ id: id, path: path });
@ -498,10 +498,12 @@ function checkCache() {
}).then(function(keys) {
baseUrl = host + config.baseUrl;
var val = keys.map(function(r) {
var url = r.url;
if (url.startsWith(baseUrl))
url = url.slice(baseUrl.length);
return r.headers.get("etag") + " " + url;
var url = r.url;
if (url.startsWith(baseUrl))
url = url.slice(baseUrl.length);
else if (/^\w+:/.test(url))
return "";
return r.headers.get("etag") + " " + url;
}).join("\n") + "\n";
if (val.length == 1) {
ideCachePromiss = null;
@ -510,7 +512,7 @@ function checkCache() {
return new Promise(function(resolve) {
var checked = 0;
var buffer = "";
var toDelete = []
var toDelete = [];
post("/static/__check__", val, function(t) {
var e = t.slice(checked);
checked = t.length;
@ -539,6 +541,22 @@ function checkCache() {
return ideCachePromiss;
}
require.clearCache = function(callback) {
ideCachePromiss = config.useCache && window.caches.open("ide").then(function(ideCache_) {
ideCache = ideCache_;
return ideCache.keys();
}).then(function(keys) {
var toDelete = keys.map(function(i) {
ideCache.delete(i);
});
Promise.all(toDelete).then(function() {
callback && callback();
}, function(e) {
callback && callback(e);
});
});
}
function post(path, val, progress, cb) {
var xhr = new window.XMLHttpRequest();
xhr.open("POST", path, true);

4
node_modules/vfs-local/localfs.js wygenerowano vendored
Wyświetl plik

@ -200,7 +200,9 @@ module.exports = function setup(fsOptions) {
// Extending the API
extend: extend,
unextend: unextend,
use: use
use: use,
workspaceDir: fsOptions.projectDir
});
function wrapDomain(api) {

Wyświetl plik

@ -55,7 +55,7 @@
"c9"
],
"c9plugins": {
"c9.ide.language": "#fff9c75928",
"c9.ide.language": "#6d5a10ac4f",
"c9.ide.language.css": "#be07d72209",
"c9.ide.language.generic": "#92210f5a48",
"c9.ide.language.html": "#22fdc74869",
@ -67,12 +67,12 @@
"c9.ide.language.javascript.infer": "#18acb93a3a",
"c9.ide.language.jsonalyzer": "#4b329741b1",
"c9.ide.language.codeintel": "#871d8e5e5d",
"c9.ide.collab": "#7d3d49fa8e",
"c9.ide.collab": "#968713f5c8",
"c9.ide.local": "#10eb45842a",
"c9.ide.find": "#e33fbaed2f",
"c9.ide.find.infiles": "#c0a13737ef",
"c9.ide.find.replace": "#8cbce45290",
"c9.ide.run.debug": "#7d6da73fc7",
"c9.ide.run.debug": "#32cf8977c6",
"c9.automate": "#47e2c429c9",
"c9.ide.ace.emmet": "#6dc4585e02",
"c9.ide.ace.gotoline": "#a8ff07c8f4",
@ -94,10 +94,10 @@
"c9.ide.language.python": "#330b80e3b2",
"c9.ide.language.go": "#6ce1c7a7ef",
"c9.ide.mount": "#4c39359b87",
"c9.ide.navigate": "#1fbb7cd53b",
"c9.ide.navigate": "#0b7ec7936c",
"c9.ide.newresource": "#981a408a7b",
"c9.ide.openfiles": "#2ae85a9e33",
"c9.ide.preview": "#70bd68740c",
"c9.ide.preview": "#5f5fff0185",
"c9.ide.preview.browser": "#897177be7f",
"c9.ide.preview.markdown": "#c3174d86e0",
"c9.ide.pubsub": "#a85fb27eca",
@ -109,9 +109,9 @@
"c9.ide.run.build": "#0598fff697",
"c9.ide.run.debug.xdebug": "#9956689819",
"c9.ide.save": "#4cda35bfdb",
"c9.ide.scm": "#dc87315012",
"c9.ide.scm": "#219b66019a",
"c9.ide.terminal.monitor": "#1a4092ede2",
"c9.ide.test": "#a282ec1619",
"c9.ide.test": "#102942ae4e",
"c9.ide.test.mocha": "#fc053b23d2",
"c9.ide.theme.flat": "#81dadeee55",
"c9.ide.threewaymerge": "#229382aa0b",

Wyświetl plik

@ -8,7 +8,7 @@ define(function(require, exports, module) {
var c9 = imports.c9;
var ext = imports.ext;
var JSONStream = require("./json-stream");
var JSONStream = require("json-stream");
/***** Initialization *****/

Wyświetl plik

@ -291,9 +291,9 @@ define(function(require, module, exports) {
load();
});
plugin.on("beforeUnload", function(){
plugin.on("beforeUnload", function(e){
if (!plugin.meta.$closing) {
if (close())
if (close(e && e.animate === false))
return false;
}
});

Wyświetl plik

@ -1283,7 +1283,7 @@ define(function(require, module, exports) {
// Or keep tab until the new one is loaded
else {
previewTab.unload();
previewTab.unload({ animate: false });
}
}

Wyświetl plik

@ -96,9 +96,18 @@ define(function(require, exports, module) {
}
function getHotkey(command) {
if (!commands[command] || !commands[command].bindKey)
return "";
return commands[command].bindKey[platform];
}
function getPrettyHotkey(command) {
var key = getHotkey(command);
if (platform == "mac")
key = apf.hotkeys.toMacNotation(key);
return key;
}
var markDirty = lang.delayedCall(function(){
emit("update");
}, 500);
@ -557,6 +566,14 @@ define(function(require, exports, module) {
*/
getHotkey: getHotkey,
/**
* returns result of getHotkey formatted for displaying in menus
*
* @param {String} name the name of the command.
* @return {String}
*/
getPrettyHotkey: getPrettyHotkey,
/**
* Executes the action tied to a command. This method will call
* the `isAvailable` method for a command and will not execute if

Wyświetl plik

@ -79,6 +79,9 @@ define(function(require, exports, module) {
// @TODO this is probably not sufficient
layout.on("resize", function(){ tree.resize() }, plugin);
var key = commands.getPrettyHotkey("commands");
txtFilter.setAttribute("initial-message", key);
tree.textInput = txtFilter.ace.textInput;
txtFilter.ace.commands.addCommands([

Wyświetl plik

@ -0,0 +1,51 @@
.btn-switcher {
.user-select(none);
cursor: default;
line-height: 19px;
font-size: @preview-chooser-font-size;
font-weight: @preview-chooser-font-weight;
color: ;
font-family: @preview-chooser-font-family;
-webkit-font-smoothing: auto;
-moz-osx-font-smoothing: auto;
background: @preview-chooser-background;
border-radius: 0 2px 2px 0;
box-shadow: @preview-chooser-box-shadow;
cursor: pointer;
border: 1px solid @textbox-border-color;
border-left : 0;
border-radius: 0 3px 3px 0;
position : relative;
padding: 4px 17px 4px 8px;
box-sizing: border-box;
}
.btn-switcherOver{
background: @preview-chooser-over-background;
}
.btn-switcherDown{
background: @preview-chooser-active-background;
}
.btn-switcher svg{
vertical-align: middle;
margin: -2px 4px 0 0;
}
.btn-switcher span{
display : block;
position : absolute;
right : 6px;
top : 11px;
width : 5px;
height : 5px;
background: url("@{image-path}/@{preview-chooser-arrow}") no-repeat;
opacity: 0.6;
}
.btn-switcherIcon {
background-repeat: no-repeat;
padding-left: 25px;
padding-top: 5px;
background-position: 5px 6px;
}

Wyświetl plik

@ -18,6 +18,9 @@
color : @textbox-disabled-color;
background: @textbox-disabled-background;
}
.has_apf .searchTxt.tb_console.ace_searchboxDisabled .sbtb_middle .input {
color : @textbox-disabled-color;
}
.ace_one-line .ace_scroller.ace_scroll-left {
box-shadow: none;
}
@ -63,17 +66,19 @@
padding : 0;
}
.tb_console.tb_textboxInitial .sbtb_middle {
padding-right : 0 !important;
}
.tb_console.tb_textboxInitial .input {
font-size : 10px;
}
.tb_console.tb_textboxInitial .ace_scroller {
text-indent: 5px;
}
.tb_console.tb_textboxInitial .ace_cursor{
display : none;
}
.tb_console.tb_textboxInitial .ace_focus .ace_cursor{
display : block;
}
.tb_consoleDisabled .sbtb_middle {
background : #e2e2e2;

Wyświetl plik

@ -47,6 +47,7 @@ BODY.noInput *{
@import "less/button.less";
@import "less/btn_console.less";
@import "less/btn_console_open.less";
@import "less/btn-switcher.less";
@import "less/c9-divider-double.less";
@import "less/c9-divider-hor.less";
@import "less/c9-divider.less";

Wyświetl plik

@ -859,4 +859,16 @@
</a:main>
</a:presentation>
</a:button>
<a:button name="btn-switcher">
<a:presentation>
<a:main
caption = "text()"
background = "."
icon = ".">
<div class="btn-switcher">
-<span> </span>
</div>
</a:main>
</a:presentation>
</a:button>
</a:skin>

Wyświetl plik

@ -1711,7 +1711,7 @@
@form-bar-border-bottom: 1px solid black;
@form-bar-box-shadow: 0 1px @border-highlight;
@panel-settings-changes-top: 46px;
@panel-settings-changes-top: 53px;
/*******/

Wyświetl plik

@ -1066,8 +1066,8 @@
@textbox-border-color: darken(#dedede, @darken-chrome);
@textbox-initial-color: darken(#A5A5A5, @darken-chrome);
@textbox-initial-text-shadow: 0 1px 0 darken(#FFFFFF, @darken-chrome);
@textbox-disabled-color: gray;
@textbox-disabled-background: darken(rgb(216, 216, 216), @darken-chrome);
@textbox-disabled-color: #C5C5C5;
@textbox-disabled-background: #F1F1F1;
// Textbox - Simple
@tbsimple-border: 1px solid #DEDEDE;
@ -1706,9 +1706,9 @@
@diff-toolbar-buttons-background: #F9F9F9;
@diff-toolbar-buttons-border: 1px solid @border-highlight-dark;
@form-bar-padding: 10px 50px 10px 10px;
@form-bar-padding: 10px 10px 0 10px;
@form-bar-background: @menu-button-active-background;
@form-bar-border-bottom: 1px solid black;
@form-bar-border-bottom: 1px solid #DEDEDE;
@form-bar-box-shadow: 0 1px @border-highlight;
@panel-settings-changes-top: 46px;
@panel-settings-changes-top: 53px;

Wyświetl plik

@ -470,6 +470,9 @@ body .runner-form-header{
.cbblack.cbcontainerDisabled.cbcontainerChecked .checkbox{
background-position: 0 -142px;
}
.cbblack.cbcontainerDisabled.cbcontainerDisabled .checkbox{
background-position: 0 0;
}
.session_btn .tab_middle:before {
background-position : 0 -126px;
-webkit-mask-position : 0 -95px;

Wyświetl plik

@ -147,6 +147,14 @@ define(function(require, module, exports) {
mnuItem.setAttribute("hotkey",
"{commands.commandManager." + options.name + "}");
if (button && button.setAttribute) {
var key = commands.getPrettyHotkey(options.name);
button.setAttribute("tooltip", options.name
+ (key ? " (" + key + ")" : ""));
}
return command;
}
@ -382,6 +390,11 @@ define(function(require, module, exports) {
*/
get button(){ return button; },
/**
*
*/
get active(){ return panels.isActive(plugin.name); },
_events: [
/**
* Fires when the panel is drawn.

Wyświetl plik

@ -87,28 +87,25 @@ apf.codebox = function(struct, tagName) {
this.$editor = this.ace = ace;
ace.renderer.setPadding(2);
this.ace.codebox = this;
ace.on("focus", function() {
dom.removeCssClass(ace.codebox.$ext, "tb_textboxInitial");
if (ace.renderer.initialMessageNode) {
var checkInitial = function() {
var value = ace.getValue();
if (value && ace.renderer.initialMessageNode) {
dom.removeCssClass(ace.codebox.$ext, "tb_textboxInitial");
ace.renderer.scroller.removeChild(ace.renderer.initialMessageNode);
ace.renderer.initialMessageNode = null;
}
});
else if (!value && !ace.renderer.initialMessageNode) {
dom.addCssClass(ace.codebox.$ext, "tb_textboxInitial");
ace.renderer.initialMessageNode = document.createTextNode(ace.codebox["initial-message"] || "");
ace.renderer.scroller.appendChild(ace.renderer.initialMessageNode);
}
};
ace.on("input", checkInitial);
function onBlur() {
if (ace.$isFocused || ace.session.getValue())
return;
dom.addCssClass(ace.codebox.$ext, "tb_textboxInitial");
if (ace.renderer.initialMessageNode)
return;
ace.renderer.initialMessageNode = document.createTextNode(ace.codebox["initial-message"] || "");
ace.renderer.scroller.appendChild(ace.renderer.initialMessageNode);
}
ace.on("blur", onBlur);
setTimeout(onBlur, 100);
setTimeout(checkInitial, 100);
// todo should we do this here?
// ace.on("resize", function(){apf.layout.forceResize();});
@ -181,6 +178,7 @@ apf.codebox = function(struct, tagName) {
new MultiSelect(editor);
editor.session.setUndoManager(new UndoManager());
editor.setOption("indentedSoftWrap", false);
editor.setHighlightActiveLine(false);
editor.setShowPrintMargin(false);
editor.renderer.setShowGutter(false);

Wyświetl plik

@ -967,7 +967,7 @@ define(function(require, exports, module) {
checkItems.call(this, e);
},
"onitemclick" : function(e) {
emit("itemclick", { value : e.value });
emit("itemclick", { value : e.value, item: e.relatedNode });
}
});
aml.cloud9menu = plugin;

Wyświetl plik

@ -124,7 +124,7 @@ define(function(require, module, exports) {
"list", "tab", "textbox", "textarea", "radiobutton", "checkbox", "page",
"splitter", "hsplitbox", "vsplitbox", "group", "img", "label", "spinner",
"dropdown", "BindingColumnRule", "datagrid", "hbox", "vbox", "colorbox",
"frame", "password", "modalwindow", "filler", "splitbutton"].forEach(function(tag) {
"frame", "password", "modalwindow", "filler", "splitbutton", "codebox"].forEach(function(tag) {
plugin[tag] = function(struct) {
return new apf[tag](struct);
};

Wyświetl plik

@ -34,7 +34,7 @@ define(function(require, exports, module) {
var acetree;
var model;
var redirectEvents;
var filterRoot;
var fRoot;
var meta = {};
var dataType = options.model ? "object" : options.dataType;
var excludedEvents = {
@ -251,6 +251,16 @@ define(function(require, exports, module) {
*/
get enableDragdrop(){ return acetree.getOption("enableDragDrop"); },
set enableDragdrop(value){ acetree.setOption("enableDragDrop", value); },
/**
*
*/
get enableVariableHeight(){ return model.getItemHeight; },
set enableVariableHeight(value){
if (!value) throw new Error("Unable to remove variable height");
var variableHeightRowMixin = model.constructor.variableHeightRowMixin;
variableHeightRowMixin.apply(model);
},
/**
*
*/
@ -296,18 +306,20 @@ define(function(require, exports, module) {
set filterKeyword(value){
model.keyword = value;
if (!model.keyword) {
filterRoot = null;
fRoot = null;
model.reKeyword = null;
model.setRoot(model.cachedRoot);
}
else {
model.reKeyword = new RegExp("("
+ util.escapeRegExp(model.keyword) + ")", 'i');
filterRoot = search.treeSearch(
model.cachedRoot.items || model.cachedRoot,
fRoot = search.treeSearch(
model.filterRoot
? model.filterRoot.items || model.filterRoot
: model.cachedRoot.items || model.cachedRoot,
model.keyword, model.filterCaseInsensitive,
null, null, model.indexProperty);
model.setRoot(filterRoot);
null, null, model.filterProperty);
model.setRoot(fRoot);
}
},
/**
@ -320,6 +332,11 @@ define(function(require, exports, module) {
*/
get filterProperty(){ return model.filterProperty; },
set filterProperty(value){ model.filterProperty = value; },
/**
*
*/
get filterRoot(){ return model.filterRoot; },
set filterRoot(value){ model.filterRoot = value; },
/**
*
*/
@ -394,11 +411,21 @@ define(function(require, exports, module) {
*/
get getClassName(){ return model.getClassName; },
set getClassName(fn){ model.getClassName = fn; },
/**
*
*/
get getTooltipText(){ return model.getTooltipText; },
set getTooltipText(fn){ model.getTooltipText = fn; },
/**
*
*/
get getIndex(){ return model.getIndex; },
set getIndex(fn){ model.getIndex = fn; },
/**
*
*/
get getItemHeight(){ return model.getItemHeight; },
set getItemHeight(fn){ model.getItemHeight = fn; },
// Events
_events: [
@ -494,7 +521,10 @@ define(function(require, exports, module) {
*/
setRoot: function(root){
model.cachedRoot = root;
return model.setRoot(root);
if (model.keyword)
plugin.filterKeyword = model.keyword;
else
return model.setRoot(root);
},
/**
*
@ -538,8 +568,8 @@ define(function(require, exports, module) {
/**
*
*/
scrollIntoView: function(anchor, lead, offset){
return acetree.renderer.scrollCaretIntoView(anchor, lead, offset);
scrollIntoView: function(anchor, offset){
return acetree.renderer.scrollCaretIntoView(anchor, offset);
},
/**
*
@ -585,7 +615,10 @@ define(function(require, exports, module) {
*
*/
refresh: function(){
model.setRoot(filterRoot || plugin.root);
if (model.keyword)
plugin.filterKeyword = model.keyword;
else
model.setRoot(plugin.root);
},
/**
*

Wyświetl plik

@ -0,0 +1,132 @@
define(function(require, exports, module) {
function timeago(timestamp) {
if (timestamp instanceof Date) {
return inWords(timestamp);
} else if (typeof timestamp === "string") {
return inWords(parse(timestamp));
} else if (typeof timestamp === "number") {
return inWords(new Date(timestamp));
} else {
return timeagoElement(timestamp);
}
}
var settings = {
refreshMillis: 60000,
allowFuture: false,
strings: {
prefixAgo: null,
prefixFromNow: null,
suffixAgo: "ago",
suffixFromNow: "from now",
seconds: "less than a minute",
minute: "about a minute",
minutes: "%d minutes",
hour: "about an hour",
hours: "about %d hours",
day: "a day",
days: "%d days",
month: "about a month",
months: "%d months",
year: "about a year",
years: "%d years",
wordSeparator: " ",
numbers: []
}
};
function distanceInWords(distanceMillis) {
var $l = settings.strings;
var prefix = $l.prefixAgo;
var suffix = $l.suffixAgo;
if (settings.allowFuture) {
if (distanceMillis < 0) {
prefix = $l.prefixFromNow;
suffix = $l.suffixFromNow;
}
}
var seconds = Math.abs(distanceMillis) / 1000;
var minutes = seconds / 60;
var hours = minutes / 60;
var days = hours / 24;
var years = days / 365;
function substitute(stringOrFunction, number) {
var string = typeof stringOrFunction === "function" ? stringOrFunction(number, distanceMillis) : stringOrFunction;
var value = ($l.numbers && $l.numbers[number]) || number;
return string.replace(/%d/i, value);
}
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
seconds < 90 && substitute($l.minute, 1) ||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
minutes < 90 && substitute($l.hour, 1) ||
hours < 24 && substitute($l.hours, Math.round(hours)) ||
hours < 42 && substitute($l.day, 1) ||
days < 30 && substitute($l.days, Math.round(days)) ||
days < 45 && substitute($l.month, 1) ||
days < 365 && substitute($l.months, Math.round(days / 30)) ||
years < 1.5 && substitute($l.year, 1) ||
substitute($l.years, Math.round(years));
var separator = $l.wordSeparator || "";
if ($l.wordSeparator === undefined) { separator = " "; }
return [prefix, words, suffix].filter(function(s) { return s; })
.map(function(s){ return s.trim(); })
.join(separator);
}
function parse(iso8601) {
var s = iso8601.trim();
s = s.replace(/\.\d+/,""); // remove milliseconds
s = s.replace(/-/,"/").replace(/-/,"/");
s = s.replace(/T/," ").replace(/Z/," UTC");
s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400
return new Date(s);
}
function datetime(elem) {
var iso8601 = isTime(elem) ? elem.getAttribute("datetime") : elem.getAttribute("title");
return parse(iso8601);
}
function isTime(elem) {
return elem.tagName.toLowerCase() === "time";
}
function timeagoElement(elem) {
refresh(elem);
if (settings.refreshMillis > 0)
setInterval(refresh.bind(null, elem), settings.refreshMillis);
}
function refresh(elem) {
var datetime = prepareDateTime(elem);
if (!isNaN(datetime))
elem.textContent = inWords(datetime);
}
function prepareDateTime(elem) {
var timeagoAttr = elem.getAttribute("timeago");
if (timeagoAttr)
return new Date(timeagoAttr);
var data = datetime(elem);
elem.setAttribute("timeago", data);
var text = elem.textContent.trim();
if (text.length > 0 && !(isTime(elem) && elem.title))
elem.title = text;
return data;
}
function inWords(date) {
return distanceInWords(distance(date));
}
function distance(date) {
return (new Date().getTime() - date.getTime());
}
// fix for IE6 suckage
document.createElement("abbr");
document.createElement("time");
module.exports = timeago;
});

Wyświetl plik

@ -76,6 +76,8 @@ function main(options, imports, register) {
var parts = e.split(" ");
var id = parts[1];
var etag = parts[0];
if (!id || /^https?:\/\//.test(id))
return q.oneDone();
var path = resolveModulePath(id, req.pathConfig.pathMap);
if (path == id && !/^(\/|\w:)/.test(path)) {

Wyświetl plik

@ -199,6 +199,8 @@ require([
c.exec = function(name) {
commands[name].exec();
};
c.getPrettyHotkey = function(name) { return "" };
c.getHotkey = function(name) { return "" };
c.getExceptionList = function(){ return []; };
return c;