1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-20 11:25:37 +01:00

remove jquery usage from bar

This commit is contained in:
Kyle Spearrin 2017-11-09 22:38:09 -05:00
parent 0f7a7c56dc
commit 133e3d5b55

View File

@ -1,65 +1,71 @@
require('./bar.less');
require('./bar.less');
$(function () {
var content = document.getElementById('content'),
closeButton = $('#close-button');
document.addEventListener('DOMContentLoaded', function () {
// delay 50ms so that we get proper body dimensions
setTimeout(load, 50);
// i18n
$('body').addClass('lang-' + chrome.i18n.getUILanguage());
function load() {
var content = document.getElementById('content'),
closeButton = document.getElementById('close-button'),
body = document.querySelector('body'),
bodyRect = body.getBoundingClientRect();
$('#logo-link').attr('title', chrome.i18n.getMessage('appName'));
closeButton.attr('title', chrome.i18n.getMessage('close'));
// i18n
body.classList.add('lang-' + chrome.i18n.getUILanguage());
if (window.innerWidth < 768) {
$('#template-add .add-save').text(chrome.i18n.getMessage('yes'));
$('#template-add .never-save').text(chrome.i18n.getMessage('never'));
}
else {
$('#template-add .add-save').text(chrome.i18n.getMessage('notificationAddSave'));
$('#template-add .never-save').text(chrome.i18n.getMessage('notificationNeverSave'));
}
document.getElementById('logo-link').title = chrome.i18n.getMessage('appName');
closeButton.title = chrome.i18n.getMessage('close');
$('#template-add .add-text').text(chrome.i18n.getMessage('notificationAddDesc'));
if (getQueryVariable('add')) {
setContent(document.getElementById('template-add'));
var add = $('#template-add-clone'),
addButton = $('#template-add-clone .add-save'),
neverButton = $('#template-add-clone .never-save');
$(addButton).click(function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgAddSave'
});
});
$(neverButton).click(function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgNeverSave'
});
});
}
else if (getQueryVariable('info')) {
setContent(document.getElementById('template-alert'));
$('#template-alert-clone').text(getQueryVariable('info'));
}
closeButton.click(function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgCloseNotificationBar'
});
});
chrome.runtime.sendMessage({
command: 'bgAdjustNotificationBar',
data: {
height: document.body.scrollHeight
if (bodyRect.width < 768) {
document.querySelector('#template-add .add-save').textContent = chrome.i18n.getMessage('yes');
document.querySelector('#template-add .never-save').textContent = chrome.i18n.getMessage('never');
}
});
else {
document.querySelector('#template-add .add-save').textContent = chrome.i18n.getMessage('notificationAddSave');
document.querySelector('#template-add .never-save').textContent = chrome.i18n.getMessage('notificationNeverSave');
}
document.querySelector('#template-add .add-text').textContent = chrome.i18n.getMessage('notificationAddDesc');
if (getQueryVariable('add')) {
setContent(document.getElementById('template-add'));
var addButton = document.querySelector('#template-add-clone .add-save'),
neverButton = document.querySelector('#template-add-clone .never-save');
addButton.addEventListener('click', function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgAddSave'
});
});
neverButton.addEventListener('click', function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgNeverSave'
});
});
}
else if (getQueryVariable('info')) {
setContent(document.getElementById('template-alert'));
document.getElementById('template-alert-clone').textContent = getQueryVariable('info');
}
closeButton.addEventListener('click', function (e) {
e.preventDefault();
chrome.runtime.sendMessage({
command: 'bgCloseNotificationBar'
});
});
chrome.runtime.sendMessage({
command: 'bgAdjustNotificationBar',
data: {
height: body.scrollHeight
}
});
}
function getQueryVariable(variable) {
var query = window.location.search.substring(1);