How to change Css class using JQuery? - asp.net

I have an multi user application with basic layouts where i want to change the layout and style of the page for individual user .
I have one way in mind that to change the css at run time but if i am changing the css then it will take effect for every user and if i will refresh the page then it shows basic page again.
Help me for this problem that if i will change the css then it will take effect only for the same user.
and it will not change after refresh.
Or any buddy has any other idea then please suggest me.

$("div#somediv").addClass("specialuserclass");
JQuery reference or have a stylesheet per user;

You might be interested in doing this using themes and the theme manager plugin I built. The plugin is built to work with jQuery UI themes, but could easily be adapted to your own custom CSS-based themes. This plugin works with individual user preferences for a particular theme stored in a database, though I suppose you could also use a cookie. the latter would take more customization. You can find more info on my blog, http://farm-fresh-code.blogspot.com.

You have to persist the style chosen by each user.
Your can design your function/screen to something like:
1. On create of a new user, give the user the default basic layout and persist this in the server side (you can probably save the user preference in your DB).
2. When he changes style, update the user's user preference record/file
3. On load of the page, retrieve the user preference and change the css style on the server side

If you want to implement this yourself, store your user-specific styles in a dedicated store such as a database, indexed by user. At page construction time (server side) consult your database, looking up the customizations for that user, and apply the CSS you want to that page.
Alternatively there are a variety of theming applications available. These will depend on your server-side tools. For example, ASP.NET offers the Web Parts Framework.

Related

cq:include default components in CQ form with server validation

I would like to customize start/end of OOTB CQ5 user form component to start with certain custom components pre-populated when the 'form' component is drag/dropped on to the page.
I currently have an over-laid /apps/foundation/components/form elements with start/end/actions customized. But I am to figure out way to add a component belonging to the FORM group, to the form start.......end to the page whenever a form is added to the page.
I have tried using a <cq:include path= "customComp" resourceType="/pathto/customComponent" /> to the jsp of the form-end component, this adds / shows the custom-component on display but does not perform the server-validations as it is not a separate node between the start and end nodes on the page, but a dynamically added one.
This is basically to enforce/mandate the use of my custom captcha component whenever a form is placed on a page.
thanks in Advance !
If you want to leave the form creation entirely to the author (as intended with OOTB components) there is no easy way to "sneak in" a mandatory captcha component. Even if you managed to put in the captcha component, the author can just delete it or move it out of your paragraph system.
Mingling the captcha with form-end might be possible, but not without reinventing the form-end component pretty much from scratch. I wouldn't want to do that.
I see three options that might be helpful to you:
Implement a jcr EventListener that will fire whenever a form is created or changed. Check the form data structure in jcr and when the mandatory captcha component is missing, add it and commit. This type of behaviour is of course a little shady and may suprise authors - but it's gonna work.
Build a wrapper form component that contains a paragraph system with a fully pre-configured form, including form-start, captcha and form-end. This approach my even save authors a bit of work and nobody will "forget" about the chaptcha easily. Nothing will stop an evil author from explicitly deleting the catpcha component however.
Build an entirely custom form component that does not utilizy any of the OOTB components. In this scenario you have full control over what the author can and cannot do. Most likely you will give up on a lot of flexibility in order to save development time and end up with a mostly static form where the author can edit a few cruicial parts.

Implement adding content only by some pople. Rails

I am working on dictionary-like web page and I want to implement adding/changing phrases only by few people (my client - which is some small organisation wants to be able to do this by himself). The page does not have any login/registration mechanism etc. (for regular users at least) so I do not want It to have any login button. I wondered if making admin model ( few admins made in seeds for example) and adding login button that is invisible - I thought of using CSS opacity for this one. Is this a good solution ? Is there any other good practice in these sitations? Please dont be afraid to post suggestions. Additionally this is a serious page (my first job as freelancer), so I wonder if my solution is... acceptable? Thanks in advance for any answers!
This quite a standard thing in the web. Most of the websites consists of two parts, customer facing part (sometimes called frontend) and admin panel (called backend). In your case you don't need any login to access frontend part, but you need one for backend part.
Creating hidden button is not needed at all. There simply should be no button at all. If you want to log in as an admin, you simply navigate to http://my-website-url.com/admin.
I wouldn't bother with roles et unless your client specified clearly that he needs them.
Even though this is simple I would still suggest adding a role to a user model. After all he may want to have some user functionality later on. The simplest way to do this would be to use devise and add a role enum column.
Check out the article below and look under the "Enum" section.
http://railsapps.github.io/rails-authorization.html

Custom Interface for different user in DNN.. How to?

I am new to DotNetNuke; I have following situation please suggest what are the options for me to target this situation.
I have a website which is in .Net (No CMS and pure logic only) and client want it to be migrated in DNN. Please let me know how to do this? what are the steps i need to perform and how should i approach ahead?
More to this; In DNN I want to do customization per users (or members of my website); so for that which module I should choose? My customization will be like if User A logged in my website then Skin A should be shown and if User B logged in then skin B should shown.
I want to extent this scenario.
I also wanted to know how can I make my website mobile enable?
1) Make a DotNetNuke module for each bit of unique functionality (example: each report) on your old ASP.NET site.
2) Make a content page for everything else (static pages)
3) For each module that you created, create a single content page and add each module to their own content page.
4) Make sure to categorize your users with the appropriate DNN user roles
5) To change the skin dynamically based upon the user's role, see this snippet, from DotnetNuke Corp:
There are a few different ways to dynamically or programmatically change the skin for a specific page load. DotNetNuke will look first for an override value in the URL. If specific value is found, then DNN will load that skin and/or container on that page load. Second, DNN will look in a local cookie to see if there is a skin being defined. Finally, if the first two methods did not specify a skin to load, DNN will load the default skins defined by the page or site. In the event that the skin doesn’t exist, the default skin that ships with DNN will be loaded.
This is why it’s important to not delete the original skin package after installing.
Probably the best way to approach dynamically loading a skin based on security role would be to create a simple cookie using either a DotNetNuke module, or HttpModule. Either way, you will be able to retrieve the user information, and based on the IsInSecurityRole() property, generate a cookie that will in effect load the desired skin.
6) Look at MobiNuke for adapting your site to be mobile-friendly

Creating a custom contact page -- page-contact.tpl.php

I'm new to Drupal. I want to create a contact page, so I copied page.tpl.php and renamed it to page-contact.tpl.php. I created some new elements in the page, so I can see that if I click on the "contact" link, I'll know that I went to the correct page.
Right now I don't see any change. Was there something I missed? Do I need to do something in the admin settings so Drupal knows which file I need to open?
I also tried clearing my cache.
In theory, this is a valid approach. Problem is, you'll be able to create a new layout for your contact page this way, but not necessarily change the contact form. If you wish to alter the form as well, I'd recommend using the webform module. It's pretty flexible when it comes to creating contact forms, plus, it creates a node, so you can style it with ease (either in you standard node.tpl.php or - even better - in node-webform.tpl.php). This is what I usually do.
There might be other solutions too, but it would help if you made it clear what kind of alterations you wish to introduce in your contact page.
When you say cleared my cache do you mean the browser cache or drupal's cache? Ensure drupal's theme registry has been cleared by going to /admin/build/themes, or logging out and back in.
I also recommend trying the webform module as mingos suggests.
Drupal core's built in contact module does not use any templates, so you'll have to use something like Webform if you want a per-contact template.

Need a jQuery plugin that modifies a CSS

I'm trying to create a page that allows a user to change the "look and feel" of the site. I would like to use something similar to jQuery's ThemeRoller or FireFox's Developer Tool.
I can't force the user to use Firefox and I don't need all the options that the ThemeRoller has. I'm really only looking for header, background, font size and font type.
Any suggestions?
Thanks
Try a Stylesheet Switcher, it can be as advanced as you want and this will give you a lot more control the simple Div targeting.
http://www.dynamicdrive.com/dynamicindex9/stylesheetswitcher.htm
If your concern is transferring fewer/smaller files and you really want to avoid jQuery UI, it would be quite easy to develop a small jQuery plugin to modify background, font-size/type, and some header stuff.
Since you ask about jQuery specifically, I assume you have some experience working with it. Check out the plugin authoring documentation at http://docs.jquery.com/Plugins/Authoring
If you aren't worried about transferring fewer/smaller files, just use jQuery UI themeroller and ignore the features you don't want.
I couldn't find a plugin that already did this. I used Brosho to give me a base starting point. Brosho basically set's "Brosho: css info" to the element using the attr method. Then scans the entire document for Brosho to create the CCS to export.
Store the user's style attributes in a datastore (cookie or server based). Then on each page of the site have something like the following if user's preferences are stored server-side:
$(document).ready(function() {
$("h1").css('color','<% =UsersHeaderFontColor');
$("body").css('color','<% =UsersBodyFontColor');
$("body").css('font-size','<% =UsersFontSize');
$("body").css('font-family','<% =UsersFontFamily');
});
If you want to get from a cookie, then there's a nice jquery cookie plugin that would allow you to set/get cookie name/value pairs.

Resources