Prevent eclipse from destroying CSS formatting - css

Eclipse seems to be completely oblivious of EL expressions inside CSS. When I format my stylesheets, this happens:
.tooltip:hover span.info {
...
border-color: #{theme.get('borderTooltip')};
border-style: solid;
...
}
turns into
.tooltip:hover span.info {
...
border-color: #{theme.get('borderTooltip' )
}
;
border-style
:
solid
;
...
}
Is there anything I can do to prevent this and still use the formatter?

Go to the Eclipse preferences Window -> Preferences. And enter formatter into the search box on the upper left. I don't know which plugin performs the formatting in your case maybe you find the right one here and can change its configuration.

Related

How to change default styling of browser? [duplicate]

I have 2 basic forms: sign in and sign up, both on the same page. Now, I have no problem with the sign in form auto-filling, but the sign up form auto fills as well, and I don't like it.
Also, the form styles get a yellow background which I can't manage to override and I don't want to use inline CSS to do so. What can I do to make them stop being colored yellow and (possibly) auto filling?
Trick it with a "strong" inside shadow:
input:-webkit-autofill {
-webkit-box-shadow:0 0 0 50px white inset; /* Change the color to your own background color */
-webkit-text-fill-color: #333;
}
input:-webkit-autofill:focus {
-webkit-box-shadow: 0 0 0 50px white inset;/*your box-shadow*/
-webkit-text-fill-color: #333;
}
for the autocompletion, you can use:
<form autocomplete="off">
regarding the coloring-problem:
from your screenshot i can see that webkit generates the following style:
input:-webkit-autofill {
background-color: #FAFFBD !important;
}
1) as #id-styles are even more important than .class styles, the following may work:
#inputId:-webkit-autofill {
background-color: white !important;
}
2) if that won't work, you can try to set the style via javascript programmatically
$("input[type='text']").bind('focus', function() {
$(this).css('background-color', 'white');
});
3) if that won't work, you're doomed :-) consider this:
this wont hide the yellow color, but will make the text readable again.
input:-webkit-autofill {
color: #2a2a2a !important;
}
4) a css/javascript solution:
css:
input:focus {
background-position: 0 0;
}
and the following javascript has to be run onload:
function loadPage()
{
if (document.login)//if the form login exists, focus:
{
document.login.name.focus();//the username input
document.login.pass.focus();//the password input
document.login.login.focus();//the login button (submitbutton)
}
}
eg:
<body onload="loadPage();">
good luck :-)
5) If none of the above work try removing the input elements, cloning them, then placing the cloned elements back on the page (works on Safari 6.0.3):
<script>
function loadPage(){
var e = document.getElementById('id_email');
var ep = e.parentNode;
ep.removeChild(e);
var e2 = e.cloneNode();
ep.appendChild(e2);
var p = document.getElementById('id_password');
var pp = p.parentNode;
pp.removeChild(p);
var p2 = p.cloneNode();
pp.appendChild(p2);
}
document.body.onload = loadPage;
</script>
6) From here:
if (navigator.userAgent.toLowerCase().indexOf("chrome") >= 0) {
$(window).load(function(){
$('input:-webkit-autofill').each(function(){
var text = $(this).val();
var name = $(this).attr('name');
$(this).after(this.outerHTML).remove();
$('input[name=' + name + ']').val(text);
});
});
}
Add this CSS rule, and yellow background color will disapear. :)
input:-webkit-autofill {
-webkit-box-shadow: 0 0 0px 1000px white inset;
}
After 2 hours of searching it seems Google Chrome still overrides the yellow color somehow, but I found the fix. It will work for hover, focus etc. as well. All you have to do is to add !important to it.
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0px 1000px white inset !important;
}
this will completely remove yellow color from input fields
This seems to be working for me:
input {
-webkit-background-clip: text !important;
}
<form autocomplete="off">
Pretty much all modern browsers will respect that.
Sometimes autocomplete on the browser still autocompletes when you just have the code in the <form> element.
I tried putting it in the <input> element as well and it worked better.
<form autocomplete="off"> AND <input autocomplete="off">
Support for this attribute however is ceasing, please read
https://bugzilla.mozilla.org/show_bug.cgi?id=956906#c1
https://bugzilla.mozilla.org/show_bug.cgi?id=956906
Another work around that I've found is taking out placeholders inside of the input fields that suggest that it is an email, username, or phone field (ie. "Your Email", "Email", etc.")
This makes it so that browsers don't know what kind of field it is, thus doesn't try to autocomplete it.
You can also change the name attribute of your form elements to be something generated so that the browser won't keep track of it. HOWEVER firefox 2.x+ and google chrome seems to not have much problems with that if the request url is identical. Try basically adding a salt request param and a salt field name for the sign-up form.
However I think autocomplete="off" is still top solution :)
You can disable auto-completion as of HTML5 (via autocomplete="off"), but you CAN'T override the browser's highlighting. You could try messing with ::selection in CSS (most browsers require a vendor prefix for that to work), but that probably won't help you either.
Unless the browser vendor specifically implemented a vendor-specific way of overriding it, you can't do anything about such styles that are already intended to override the site's stylesheet for the user. These are usually applied after your stylesheets are applied and ignore ! important overrides, too.
This fixes the problem on both Safari and Chrome
if(navigator.userAgent.toLowerCase().indexOf("chrome") >= 0 || navigator.userAgent.toLowerCase().indexOf("safari") >= 0){
window.setInterval(function(){
$('input:-webkit-autofill').each(function(){
var clone = $(this).clone(true, true);
$(this).after(clone).remove();
});
}, 20);
}
I was able to remove the autofill color with this approach:
// Workaround to remove autofill color from inputs
input, select {
color: #fff !important;
-webkit-text-fill-color: #fff !important;
-webkit-background-clip: text !important;
background-clip: text !important;
}
This is working for Safari and Chrome on iOS and Chrome on android, as far as I have tested.
The accepted answer might have been a good answer for specific cases, but I was using angular material with transparent backgrounds and on top of that the <input> field was not the 'entre material field' with the fancy borders etc.
I made this modified solution, that just forces a very long transition on any of the autofill pseudo-elements, so that the change in properties is not even noticeable unless the user manages to stay on the same page for a considerable amount of the 1000000000 or so seconds that I have set it to!
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus {
transition: all 10000000s;
}
The form element has an autocomplete attribute that you can set to off. As of the CSS the !important directive after a property keeps it from being overriden:
background-color: white !important;
Only IE6 doesn't understand it.
If I misunderstood you, there's also the outline property that you could find useful.
If it's in input field you're trying to "un-yellow" ...
Set a background-color with css... let's say #ccc (light gray).
Add value="sometext", which temporary fills the field with "sometext"
(optional) Add a little javascript to make the "sometext" clear when you go to put the real text in.
So, it might look like this:
<input id="login" style="background-color: #ccc;" value="username"
onblur="if(this.value=='') this.value='username';"
onfocus="if(this.value=='username') this.value='';" />
Lets use a little css hack:
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
textarea:-webkit-autofill,
textarea:-webkit-autofill:hover,
textarea:-webkit-autofill:focus,
select:-webkit-autofill,
select:-webkit-autofill:hover,
select:-webkit-autofill:focus,
input:-internal-autofill-selected {
-webkit-text-fill-color: #000;
background: #fff !important;
box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0%), inset 0 0 0 100px #fff;
}
The screenshot you linked to says that WebKit is using the selector input:-webkit-autofill for those elements. Have you tried putting this in your CSS?
input:-webkit-autofill {
background-color: white !important;
}
If that doesn't work, then nothing probably will. Those fields are highlighted to alert the user that they have been autofilled with private information (such as the user's home address) and it could be argued that allowing a page to hide that is allowing a security risk.
I've seen Google toolbar's autocomplete feature disabled with javascript. It might work with some other autofill tools; I don't know if it'll help with browsers built in autocomplete.
<script type="text/javascript"><!--
if(window.attachEvent)
window.attachEvent("onload",setListeners);
function setListeners(){
inputList = document.getElementsByTagName("INPUT");
for(i=0;i<inputList.length;i++){
inputList[i].attachEvent("onpropertychange",restoreStyles);
inputList[i].style.backgroundColor = "";
}
selectList = document.getElementsByTagName("SELECT");
for(i=0;i<selectList.length;i++){
selectList[i].attachEvent("onpropertychange",restoreStyles);
selectList[i].style.backgroundColor = "";
}
}
function restoreStyles(){
if(event.srcElement.style.backgroundColor != "")
event.srcElement.style.backgroundColor = "";
}//-->
</script>
After trying a lot of things, I found working solutions that nuked the autofilled fields and replaced them with duplicated. Not to loose attached events, i came up with another (a bit lengthy) solution.
At each "input" event it swiftly attaches "change" events to all involved inputs. It tests if they have been autofilled. If yes, then dispatch a new text event that will trick the browser to think that the value has been changed by the user, thus allowing to remove the yellow background.
var initialFocusedElement = null
, $inputs = $('input[type="text"]');
var removeAutofillStyle = function() {
if($(this).is(':-webkit-autofill')) {
var val = this.value;
// Remove change event, we won't need it until next "input" event.
$(this).off('change');
// Dispatch a text event on the input field to trick the browser
this.focus();
event = document.createEvent('TextEvent');
event.initTextEvent('textInput', true, true, window, '*');
this.dispatchEvent(event);
// Now the value has an asterisk appended, so restore it to the original
this.value = val;
// Always turn focus back to the element that received
// input that caused autofill
initialFocusedElement.focus();
}
};
var onChange = function() {
// Testing if element has been autofilled doesn't
// work directly on change event.
var self = this;
setTimeout(function() {
removeAutofillStyle.call(self);
}, 1);
};
$inputs.on('input', function() {
if(this === document.activeElement) {
initialFocusedElement = this;
// Autofilling will cause "change" event to be
// fired, so look for it
$inputs.on('change', onChange);
}
});
Simple javascript solution for all browser:
setTimeout(function() {
$(".parent input").each(function(){
parent = $(this).parents(".parent");
$(this).clone().appendTo(parent);
$(this).attr("id","").attr("name","").hide();
});
}, 300 );
Clone input, reset attribute and hide original input.
Timeout is needed for iPad
Since the browser searches for password type fields, another workaround is to include a hidden field at the beginning of your form:
<!-- unused field to stop browsers from overriding form style -->
<input type='password' style = 'display:none' />
I've read so many threads and try so many pieces of code.
After gathering all that stuff, the only way I found to cleanly empty the login and password fields and reset their background to white was the following :
$(window).load(function() {
setTimeout(function() {
$('input:-webkit-autofill')
.val('')
.css('-webkit-box-shadow', '0 0 0px 1000px white inset')
.attr('readonly', true)
.removeAttr('readonly')
;
}, 50);
});
Feel free to comment, I'm opened to all enhancements if you find some.
Autocomplete off is not supported by modern browsers. The easiest way to solve autocomplete I found was a little track with HTML and JS.
The first thing to do is change the type of the input in HTML from 'password' to 'text'.
<input class="input input-xxl input-watery" type="text" name="password"/>
Autocomplete starts after window loaded. That's OK. But when the type of your field is not 'password', browser didn`t know what fields it must complete. So, there will be no autocomplete on form fields.
After that, bind event focusin to password field, for ex. in Backbone:
'focusin input[name=password]': 'onInputPasswordFocusIn',
In onInputPasswordFocusIn, just change the type of your field to password, by simple check:
if (e.currentTarget.value === '') {
$(e.currentTarget).attr('type', 'password');
}
That`s it!
UPD: this thing doesn't work with disabled JavaSciprt
UPD in 2018. Also found some funny trick. Set readonly attribute to the input field, and remove it on the focus event. First prevent browser from autofilling fields, second will allow to input data.
Please try with autocomplete="none" in your input tag
This works for me
I had to also change the text color to something darker (see StackOverflow dark theme colors).
So ended up with a hybrid of #Tamás Pap, #MCBL and #don's solution:
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-box-shadow: 0 0 0px 1000px #2d2d2d inset !important;
-webkit-text-stroke-color: #e7e8eb !important;
-webkit-text-fill-color: #e7e8eb !important;
}
You can style autofilled inputs using :-webkit-autofill
Even in firefox with the webkit-prefix!
To change the background color, there is the box-shadow trick.
And for Firefox you need additionally filter:none.
:-webkit-autofill {
filter:none; /* needed for firefox! */
box-shadow: 0 0 0 100px rgba(38, 163, 48, 0.212) inset;
}
Just sharing this great solution from wahmal for anyone who wants a transparent background for their input. Bypass all the annoying webkit default styling by adding a long delay to the transition from your default input styling to the webkit styling for autofill.
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active {
-webkit-transition-delay: 9999s;
transition-delay: 9999s;
}
Why not just put this in your css:
input --webkit-autocomplete {
color: inherit;
background: inherit;
border: inherit;
}
That should take care of your issue. Although it does raise a usability issue because now the user can't see that the form was autofilled in the way he/she is used to.
[edit] After posting this I saw that a similar answer was already given and that you commented on it that it didn't work. I don't quite see why because it did work when I tested it.
The REAL problem here is that Webkit (Safari, Chrome, ...) has a bug. When there's more than one [form] on the page, each with an [input type="text" name="foo" ...] (i.e. with the same value for the attribute 'name'), then when the user returns to the page the autofill will be done in the input field of the FIRST [form] on the page, not in the [form] that was sent. The second time, the NEXT [form] will be autofilled, and so on. Only [form] with an input text field with the SAME name will be affected.
This should be reported to the Webkit developers.
Opera autofills the right [form].
Firefox and IE doesn't autofill.
So, I say again: this is a bug in Webkit.

qt setStylesheet does not update

I want to change the borders of my textboxes if they are not field. So I do a simple check and the change styles like this:
if(!ui->TextBoxPhone->text().isEmpty() && !ui->TextBoxAddress->text().isEmpty()) {
cout<<"Saved fine \n";
}
else {
if(ui->TextBoxPhone->text().isEmpty()) {
ui->TextBoxPhone->setStyleSheet("border: 2px solid red");
}
if(ui->TextBoxAddress->text().isEmpty()) {
ui->TextBoxAddress->setStyleSheet("border: 2px solid red");
}
}
So the problem I have is that the stylesheet would not update automaticly. It will update however if I click elsewhere.
I already tried using
ui->TextBoxName->style()->unpolish(ui->TextBoxName);
ui->TextBoxName->style()->polish(ui->TextBoxName);
ui->TextBoxName->update();
No luck. Might it be a macbook isue?
here are some screenshots:
as you can see left-border is red
when I click on another textbox both of them update and become red
Solved it... repaint() method did the job;
ui->TextBoxPhone->repaint();
Works for me:
myTextEdit->setStyleSheet("QTextEdit{background: transparent; border: none;}");
Nothing else needed. Make sure to specify correct type for the stylesheet. Or maybe even this will resolve:
myTextEdit->setStyleSheet("{background: transparent; border: none;}");

Selector alignment in CSS source code

I'm looking to see if anyone has ever had any experience with this CSS syntax debate we are currently having on our team. Our dev team has been using the vim plugin Tabular to align text in our code. For example in PHP or Javascript we will align variable declarations using the plugin like this:
$count = 0;
$var_1 = array();
$var_2_long_name = array();
$stdout = fopen( 'php://stdout', 'w' );
$some_data = json_decode( $some_json_data, true );
Helps the code look clean and easy to read.
We have considered using alignment in our CSS (we are using LESS but this question could be applied to SASS or just straight CSS). For example we would change this block:
.btn-section {
position: relative;
top: -65px;
display: block;
z-index: 100;
.content-box;
background-color: #grayButton;
color: #gray;
padding: 10px 0;
.border-radius(5px);
}
To this:
.btn-section {
position : relative;
top : -65px;
display : block;
z-index : 100;
background-color : #grayButton;
color : #gray;
padding : 10px 0;
.content-box;
.border-radius(5px);
}
One of the devs experimenting with this tactic moved the mixins from their original spots to the bottom of the declaration in order to make the code "look right" since mixins don't conform the the normal selector: value; format of regular css. In this case, the .content-box mixin had a background-color declaration that was being overridden by the backgroud-color line beneath it. Moving the mixin to the bottom broke the override and gave the element the wrong background color.
Errors like this coupled with the extra steps it takes to format every single block of CSS make me think this might not be such a good idea. Has anyone ever tried this type of alignment before? Any opinions on whether this is a good or bad idea? Thanks.
I think your alignment tactic is a good idea, I'd just recommend turning it upside down:
.btn-section {
.content-box;
.border-radius(5px);
position : relative;
top : -65px;
display : block;
z-index : 100;
background-color : #grayButton;
color : #gray;
padding : 10px 0;
}
That way the more general mixin styles would be applied first, after which they may be overridden by selection specific adjustments instead of the other way around.
By doing it like this, you eliminate this risk of accidently overriding specific styles with inherited ones and still keep everything neat and easy to read.

How to change font size in brackets

I want to change the font size for editing in brackets from the default size to 16pt.
I go to view--> theme--> edit font size to 16pt or another size, but it doesn't change.
Go to view->themes->fontsize
it works
Try the keyboard shortcut Ctrl++
I. EDITOR FONT
run brackets as admin (sudo brackets or in win right click...)
Debug -> Open preference file -> ctrl+f "size"
Save both files -> go to view--> theme and there is changed font size
II. brackets UI (menu fonts) too Small on Ubuntu 16.04 64 bit
See https://github.com/1beb/ui-too-small - it works for me.
Go to Brackets>view >then select increase or decrease font size from dropdown menu. Continue until you get the size font you want. To see your changes go to Brackets>view>themes
Like previously mentioned, you can achieve this with the ui-too-small plugin.
Personally I don't like the default settings of this plugin either but you can change the setting by editing the main.js file which you can find by navigating to:
Help > Show Extensions Folder > Navigate to user > Navigate to ui too small > open main.js
I personally like the following settings (Material Design):
define(function (require, exports, module) {
"use strict";
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
ExtensionUtils.addEmbeddedStyleSheet("#sidebar *, #main-toolbar *, #titlebar *, #problems-panel *,"+
"#find-in-files-results *, #e4b-main-panel *, #status-bar *,"+
"#main-toolbar *, #context-menu-bar *, #codehint-menu-bar *,"+
"#quick-view-container *, #function-hint-container * { font-size: 16px !important;"+
" line-height: 30px !important; }"+
".sidebar li { min-height: 30px !important;}"+
".sidebar-selection, .filetree-selection { min-height: 30px !important; margin-top: 5px;}"+
""+".jstree-icon{margin-top:10px !important} .filetree-selection-extension{margin-top: 5px; height: 30px !important;} .jstree-rename-input{ margin-top: 2px !important; height: 30px !important; padding-bottom: 0px !important;} "
);
});
View -> Theme -> Font-size: '24px'.
If you don't write px at the end, it will not accept.
Good luck!

styling the optional input fields

I have a web form where some input fields are required and some are optional. I can give style the required fields as I expect but can't the optional ones.
When the optional fields have a valid input it will turn green(for instance). And it works with this code
input:optional:valid{
background: #AAB69B
}
But generally like as first loading they will be in another color. For this, I am trying this code
input:optional{
background: #f19999
}
But this doesn't work. I can't select the optional fields when they have no input. Unfortunately, with no input value they get the background as I set for the valid input. When I start typing , it get my expected invalid background. And when the input gets valid, the field gets valid background (it works).
Please, help !
Demo Link : http://bdlance.byethost9.com/front-end%20form%20validation%20with%20html5/
Taking a look at your form styles, I've seen that your background color is similar for both valid and invalid pseudo classes:
input:required:invalid, textarea:required:invalid{
background: #AAB69B; // same
}
input:required:focus:invalid, textarea:focus:invalid{
background: #AAB69B; // same
}
input:required:valid, textarea:required:valid{
background: #AAB69B; // same
}
input:optional, select {
background: #f19999;
}
input:optional:valid{
background: #AAB69B; // same
}
Try this instead:
input:required:invalid, textarea:required:invalid{
background: #f19999;
}
input:required:focus:invalid, textarea:focus:invalid{
background: #f19999;
}
input:required:valid, textarea:required:valid{
background: #AAB69B;
}
input:optional, select {
background: #f19999;
}
input:optional:valid{
background: #AAB69B;
}
Sorry, but your CSS file is not the best, Please do dedicate more time to learn CSS. Here are some good resources (the order matters):
https://developer.mozilla.org/en-US/docs/Learn/CSS
https://flukeout.github.io/
https://smacss.com/
https://en.bem.info/methodology/css/

Resources