How can I completely disable jquery mobile styling for certain container?
I am using data-enhance="false" for container along with javascript code:
$(document).bind("mobileinit", function() {
$.mobile.ignoreContentEnabled = true;
});
Yet some jquery mobile styling remains, for example link color:
.ui-page-theme-a a{
color: #38C;
font-weight: 700;}
I had to overwrite these css rules manually, it is pretty cumbersome.
if you have less CSS to overwrite, then overwriting same classes in our css with !important is best way.
If you are overwriting many classes then don't include jQuery mobile theme CSS just use jQuery mobile structure CSS as its requires for some functionalities such as transition and all.
One more option modify Jquery theme CSS as requires means remove unwanted class as jquery mobile is open source you are good on this.
Related
When I changed the css style in the internal css component using angular2 material design, all components changed to the same style.
Ex:
When I used this line in internal css component, all components implemented the same style.
::ng-deep .ng-star-inserted > td:nth-child(1) { color:#3f51b5 }
How I can fix this problem ?
Thanks
what do you mean with 'internal css component'? You mean the css file of a particular component or the styles.css file that applies to all components? If you want the css rule to apply to only one component then you should put it in the css file that comes with that component, not in styles.css. To prevent your problem from happening please do the following:
In the css file of the particular component add !important after the color css style rule and remove ::ng-deep.
.ng-star-inserted > td:nth-child(1) { color:#3f51b5 !important}
I am building an application using jquery mobile and phone gap. As I am about to start the application, have a doubt on how to change the theme of an application on the fly or with minimum changes involved so that I can use the same app with different themes for different client.
Please let me know is there a configuration or common place available to update/change the theme of an entire application at any moment during the development.
EDIT: sorry to confuse a bit, the question is with how to switch between the themes provided by default by jquery mobile like a, b, c, d and e without doing any or much code change.
Thanks.
jQuery Mobile has 3 different CSS files, you can get them when you download whole package.
jQuery Mobile CSS file
jQuery Mobile Structure CSS file
jQuery Mobile Theme CSS file
If you want to use different themes all you need to do is use second and third mentioned file. Structure CSS holds jQuery Mobile structure CSS and it is a backbone of whole structure. What you need to change is jQuery Mobile theme CSS file. This is a file you get when you create a new theme.
On the other hand jQuery Mobile will have several more CSS files but logic is the same. If you download jQuery Mobile from this link: http://jquerymobile.com/
You will find these files:
jquery.mobile.external-png-1.4.2.min.css
jquery.mobile.icons-1.4.2.min.css
jquery.mobile.inline-png-1.4.2.min.css
jquery.mobile.inline-svg-1.4.2.min.css
jquery.mobile.structure-1.4.2.min.css
jquery.mobile.theme-1.4.2.min.css
jquery.mobile-1.4.2.min.css
If you want to use customized themes you will need to remove jquery.mobile-1.4.2.min.css and jquery.mobile.theme-1.4.2.min.css. Theme builder will give you new jquery.mobile.theme-1.4.2.min.css file, or even if you download it from somewhere you will get alternative jquery.mobile.theme-1.4.2.min.css file.
Update
Working example: http://jsfiddle.net/Gajotres/LfLFm/
JavaScript:
$(document).on('pagebeforecreate', '#index',function (e, ui) {
$(this).removeClass('ui-page-theme-a').addClass('ui-page-theme-b');
});
or even better: http://jsfiddle.net/Gajotres/ML2F6/
$(document).on('pagebeforecreate', '#index',function (e, ui) {
$(this).page({theme:'b'});
});
You can simply do it through .page({ theme : "a, b, c" }) widget. It will change the whole page's theme.
$(document).on("pagecreate", function () {
$(".selector").on("click", function () {
$.mobile.pageContainer.pagecontainer("getActivePage").page({
theme: "b"
});
});
});
Demo
I am developing an embeddable widget that needs to have all its CSS properties declared as important to prevent CSS bleed of the embedding page. This means that if I want to use some pre-existing CSS framework (like Bootstrap), or some jQuery plugin that uses a CSS stylesheet, I have to manually copy-paste the CSS in my assets folder and add !important declarations to each property. This seems a rather unmaintainable and error prone process.
As per title, is there a way to extend the SASS preprocessor to add !important to any declared property for an imported file or partial?
No,
Sass doesn't have that functionality, because it is the most uncommon thing you would want to do in Sass, or CSS, or anywhere for that matter.
However, from what I understand, you want to add in the !important to all the CSS properties in a particular file. In that case, you can just simply do a Search & Replace:
Search for ; and replace with !important;
The most obvious solution is to create a new mixin, potentially with the word important appended like so:
%margin-none-important {
margin: 0 !important;
}
And then in your code:
.no-margin {
#extend %margin-none-important;
}
So I have an rails admin system that will allow a user to choose a theme, basically a set of SASS color variables that will recompile application.css.scss with the new colors. How would be the best way of going about changing this when the user selects from a drop down and submits? I read some up on some problems with caching and recompiling but I'm not totally clear how to set it up.
Currently I have..
application.css.scss
#import "themes/whatever_theme";
#import "common";
#import "reset";
#import "base";
themes/_whatever_theme
$theme_sprite_path: '/images/sprite_theme_name.png';
$main_color:#009DDD;
$secondary_color:#b3d929;
$light_background:#f2f2f2;
$border_line:#e6e6e6;
$off_white:#f9f9f9;
$white:#ffffff;
$font_body:#565b59;
$font_headers:#363a36;
Say I have 5 different themes the user will switch between, it would be nice to set variable names for each theme in Rails then pass these down to SASS and change them on the fly and recompile. Is this the best way to go about this?
3 easy steps:
Compile all themes into different files upon deploy. This will take care of timestamping, zipping, etc.
Render page with default theme.
Use javascript to load alternate theme CSS.
No need to mess with dynamic compilation and all that.
To load a CSS dynamically you can use something like this:
function loadCSS(url) {
var cssfile = document.createElement("link");
cssfile.setAttribute("rel", "stylesheet");
cssfile.setAttribute("type", "text/css");
cssfile.setAttribute("href", url);
}
Sergio's answer is valid, but omits the sassy details and I'd used a slightly different approach.
You're using SASS in Rails- don't fight the current, be Railsy and let the asset pipeline precompile all your CSS. Unless you're trying to do something extreme like CSSZenGarden with hundreds of themes, or each theme is thousands of lines I'd recommend setting each theme as it's own CSS class rather than it's own file.
1kb of extra CSS in the rendered application.css file won't bog down your users
It's straightforward to switch theme classes with JQuery: $(".ThemedElement").removeClass([all your themes]).addClass("MyLittlePonyTheme");
As implied, you will have to tag the elements you want the update with the ThemedElement class
You could alternatively just change the class on your top level element and make liberal use of inheritance and the !important declaration, although I find the other approach more maintainable.
If you think you can manage your themes with classes rather than files, here's how we generate them with SASS. SASS doesn't support json style objects, so we have to reach way back and set up a bunch of parallel arrays with the theme properties. Then we iterate over each theme, substitute the dynamic properties into the auto generated theme class, and you're off to the races:
themes.css.scss
#import "global.css.scss";
/* iterate over each theme and create a CSS class with the theme's properties */
#for $i from 1 through 4{
/* here are the names and dynamic properties for each theme class */
$name: nth(("DefaultTheme",
"MyLittlePonyTheme",
"BaconTheme",
"MySpaceTheme"
), $i);
$image: nth(("/assets/themes/bg_1.png",
"/assets/themes/bg_2.png",
"/assets/themes/bg_3.png",
"/assets/themes/bg_4.png"
), $i);
$primary: nth((#7ca8cb,
#3c6911,
#d25d3a,
#c20d2c
), $i);
$font: nth((Rosario,
Helvetica,
Comic Sans,
WingDings
), $i);
/* Now we write our Theme CSS and substitute our properties when desired */
.#{$name}{
&.Picker{
background-image:url($image);
}
color: $primary;
.BigInput, h1{
color: $primary;
font-family: $font, sans-serif !important;
}
.Frame{
background-image:url($image);
}
.Blank:hover{
background-color:mix('#FFF', $primary, 90%) !important;
}
.BigButton{
background-color:$primary;
#include box-shadow(0,0,10px, $primary);
}
/* and so on... */
}
It's a bit of a hack, but it's served us really well. If your themes are uber complicated or you have too many of them it gets more painful to maintain.
One option is to simply load a set of custom css rules (your theme) after your application.css and let your theme override the default colors from application.css. You could just add a database column "theme" and load the css with this name dynamically like.
SASS is not designed for compiling dynamic data on the fly. If you want dynamic css processing, you could add a controller method called "custom_css" and make this respond to the css format and load this dynamically with inline variables, but I don't think SASS is meant to be used for it at all.
I believe that you could use erb to inline variables in sass. I'm not positive, but I think it would look something like this:
themes/_whatever_theme.sass.erb
$theme_sprite_path: '<%= Theme.sprite_path %>';
$main_color: <%= Theme.main_color %>;
$secondary_color: <%= Theme.secondary_color %>;
These should be created dynamically for each page load. I'm not sure how the caching would work here.
How does Vaadin use CSS that was written purely for HTML elements (e.g. styling and layout of body, h1, etc elements) and use that exact CSS style in Vaadin?
Does one need to make changes on the CSS to map to corresponding Vaadin elements, or can one use that CSS as is?
You can use the CSS as is, but you'll (naturally) have to tell Vaadin which CSS classes to use by calling
myComponent.setStyleName("myStyleClass");
or
myComponent.addStyleName("myStyleClass");
The difference between the two is that setStyleName replaces all existing styles with the provided one and addStyleName doesn't replace anything but adds the provided style for the component.
You can also modify your CSS to override default Vaadin styles, for example
.v-panel .v-panel-content {
background: yellow;
}
would change every Panel's background color to yellow.
I recommend that you create a new theme which is based on an existing Vaadin theme. Here's how to:
Create a directory in the VAADIN/themes/ directory (eg. VAADIN/themes/myTheme).
Create styles.css in your theme directory.
Add #import "../runo/styles.css"; to the beginning of your styles.css (you can replace runo by any other existing theme).
Call setTheme(myTheme); in your Vaadin application class.
If you want to apply application-wide styles, override the Vaadin component CSS definitions in your styles.css. If you don't know the names of the CSS classes, you can use firebug and check the HTML elements' classes.
If you want to create a component-specific style, define it in styles.css and call setStyleName or addStyleName methods.
See the CSS entry in the Book of Vaadin here.
As far as I can tell from looking at the demos, Vaadin just generates HTML, so yes.
Does one need to make changes on the CSS to map to corresponding Vaadin elements, or can one use that CSS as is?
You can use your own CSS styles (just as it is) and it can use for either individual components (as said by "miq*" earlier) or entire page. `
Here is a link for more info:
https://vaadin.com/book/-/page/themes.css.html