This commit is contained in:
Eric Bidelman 2016-07-19 15:19:06 -07:00 коммит произвёл GitHub
Родитель 93acd5cf9d
Коммит 2759f224b7
5 изменённых файлов: 153 добавлений и 89 удалений

19
.editorconfig Normal file
Просмотреть файл

@ -0,0 +1,19 @@
# editorconfig.org
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
; Python
[*.py]
indent_style = space
indent_size = 2
; YAML
[*.{yaml,yml}]
indent_size = 2

9
.eslintignore Normal file
Просмотреть файл

@ -0,0 +1,9 @@
**/node_modules/**
**/bower_components/
http2push/
**/urlize.js
**/*.vulcanize.js
Gruntfile.js
gulpfile*.js

18
.eslintrc Normal file
Просмотреть файл

@ -0,0 +1,18 @@
{
"extends": "google",
"env": {
"browser": true
},
"rules": {
"no-warning-comments": "off",
"no-unused-vars": ["error", {
"vars": "all",
"args": "after-used",
"argsIgnorePattern": "^var_args$"
}]
},
"globals": {
"Polymer": true,
"ga": true
}
}

Просмотреть файл

@ -9,6 +9,7 @@
"scripts": {
"postinstall": "npm run deps; npm run build",
"deps": "rm -rf static/bower_components; bower install",
"lint": "eslint .",
"build": "grunt",
"deploy": "./scripts/deploy_site.sh"
},
@ -20,6 +21,8 @@
"url": "https://github.com/GoogleChrome/chromium-dashboard/issues"
},
"devDependencies": {
"eslint": "^3.1.1",
"eslint-config-google": "^0.6.0",
"grunt": "^0.4.5",
"grunt-appengine": "^0.1.5",
"grunt-contrib-clean": "^0.6.0",

Просмотреть файл

@ -1,100 +1,115 @@
(function() {
'use strict';
var fields = document.querySelectorAll('input, textarea');
for (var i = 0, input; input = fields[i]; ++i) {
fields[i].addEventListener('blur', function(e) {
e.target.classList.add('interacted');
});
}
// TODO(ericbidelman): These values are brittle if changed in the db later on.
var MIN_MILESTONE_TO_BE_ACTIVE = 3;
var MIN_STD_TO_BE_ACTIVE = 5;
var NO_PUBLIC_SIGNALS = 5;
var NO_LONGER_PURSUING = 1000;
var form = document.querySelector('[name="feature_form"]');
form.addEventListener('change', function(e) {
switch (e.target.tagName.toLowerCase()) {
case 'select':
if (e.target.id == 'id_impl_status_chrome') {
toggleMilestones(e.target);
} else if (e.target.id == 'id_standardization') {
toggleSpecLink(e.target)
}
break;
case 'input':
if (e.target.name == 'shipped_milestone') {
fillOperaFields(e.target);
}
break;
default:
break;
var fields = document.querySelectorAll('input, textarea');
for (var i = 0; i < fields.length; ++i) {
fields[i].addEventListener('blur', function(e) {
e.target.classList.add('interacted');
});
}
});
var operaDesktop = document.querySelector('#id_shipped_opera_milestone');
var operaAndroid = document.querySelector('#id_shipped_opera_android_milestone');
function fillOperaFields(chromeField) {
var chromeVersion = chromeField.valueAsNumber;
if (chromeVersion < 28) {
return;
}
var operaVersion = chromeVersion - 13; // e.g. Chrome 32 ~ Opera 19
if (!operaDesktop.classList.contains('interacted')) {
operaDesktop.value = operaVersion;
}
if (!operaAndroid.classList.contains('interacted')) {
operaAndroid.value = operaVersion;
}
}
// TODO(ericbidelman): These values are brittle if changed in the db later on.
var MIN_MILESTONE_TO_BE_ACTIVE = 3;
var MIN_STD_TO_BE_ACTIVE = 5;
var NO_LONGER_PURSUING = 1000;
var specLink = document.querySelector('#id_spec_link');
function toggleSpecLink(stdStage) {
specLink.disabled = parseInt(stdStage.value) >= MIN_STD_TO_BE_ACTIVE;
specLink.parentElement.parentElement.hidden = specLink.disabled;
}
function toggleMilestones(status) {
var val = parseInt(status.value);
var disabled = val <= MIN_MILESTONE_TO_BE_ACTIVE || val == NO_LONGER_PURSUING;
var shippedInputs = document.querySelectorAll('[name^="shipped_"]');
[].forEach.call(shippedInputs, function(input) {
input.disabled = disabled;
input.parentElement.parentElement.hidden = input.disabled;
var form = document.querySelector('[name="feature_form"]');
form.addEventListener('change', function(e) {
switch (e.target.tagName.toLowerCase()) {
case 'select':
if (e.target.id === 'id_impl_status_chrome') {
toggleMilestones(e.target);
} else if (e.target.id === 'id_standardization') {
toggleSpecLink(e.target);
}
break;
case 'input':
if (e.target.name === 'shipped_milestone') {
fillOperaFields(e.target);
}
break;
default:
break;
}
});
// var milestone = document.querySelector('#id_shipped_milestone');
// milestone.disabled = parseInt(status.value) <= MIN_MILESTONE_TO_BE_ACTIVE;
// milestone.parentElement.parentElement.hidden = milestone.disabled;
}
var operaDesktop = document.querySelector('#id_shipped_opera_milestone');
var operaAndroid = document.querySelector(
'#id_shipped_opera_android_milestone');
document.addEventListener('DOMContentLoaded', function() {
// Get around Django rendering input type="text" fields for URLs.
var inputs = document.querySelectorAll('[name$="_url"], [name$="_link"]');
[].forEach.call(inputs, function(input) {
input.type = 'url';
input.placeholder = 'http://';
});
var shippedInputs = document.querySelectorAll('[name^="shipped_"]');
[].forEach.call(shippedInputs, function(input) {
input.type = 'number';
input.placeholder = 'Milestone #';
});
var owner = document.querySelector('[name="owner"]');
owner.type = 'email';
owner.multiple = true;
toggleMilestones(document.querySelector('#id_impl_status_chrome'));
});
document.body.addEventListener('ajaxdeleted', function(e) {
if (e.detail.xhr.status == 200) {
location.href = '/features';
/**
* Populates Opera version inputs with Chrome 32 -> Opera 19 version mapping.
* @param {HTMLInputElement} chromeField Chrome version input.
*/
function fillOperaFields(chromeField) {
var chromeVersion = chromeField.valueAsNumber;
if (chromeVersion < 28) {
return;
}
var operaVersion = chromeVersion - 13; // e.g. Chrome 32 ~ Opera 19
if (!operaDesktop.classList.contains('interacted')) {
operaDesktop.value = operaVersion;
}
if (!operaAndroid.classList.contains('interacted')) {
operaAndroid.value = operaVersion;
}
}
});
var specLink = document.querySelector('#id_spec_link');
/**
* Toggles the spec link input.
* @param {HTMLInputElement} stdStage Input element.
*/
function toggleSpecLink(stdStage) {
specLink.disabled = parseInt(stdStage.value, 10) >= MIN_STD_TO_BE_ACTIVE;
specLink.parentElement.parentElement.hidden = specLink.disabled;
}
/**
* Toggles the chrome milestone inputs.
* @param {HTMLInputElement} status Input element.
*/
function toggleMilestones(status) {
var val = parseInt(status.value, 10);
var disabled = (val <= MIN_MILESTONE_TO_BE_ACTIVE ||
val === NO_LONGER_PURSUING);
var shippedInputs = document.querySelectorAll('[name^="shipped_"]');
[].forEach.call(shippedInputs, function(input) {
input.disabled = disabled;
input.parentElement.parentElement.hidden = input.disabled;
});
// var milestone = document.querySelector('#id_shipped_milestone');
// milestone.disabled = parseInt(status.value) <= MIN_MILESTONE_TO_BE_ACTIVE;
// milestone.parentElement.parentElement.hidden = milestone.disabled;
}
document.addEventListener('DOMContentLoaded', function() {
// Get around Django rendering input type="text" fields for URLs.
var inputs = document.querySelectorAll('[name$="_url"], [name$="_link"]');
[].forEach.call(inputs, function(input) {
input.type = 'url';
input.placeholder = 'http://';
});
var shippedInputs = document.querySelectorAll('[name^="shipped_"]');
[].forEach.call(shippedInputs, function(input) {
input.type = 'number';
input.placeholder = 'Milestone #';
});
var owner = document.querySelector('[name="owner"]');
owner.type = 'email';
owner.multiple = true;
toggleMilestones(document.querySelector('#id_impl_status_chrome'));
});
document.body.addEventListener('ajaxdeleted', function(e) {
if (e.detail.xhr.status === 200) {
location.href = '/features';
}
});
})();