I'm using event calendar plug-in on rails 2.3.8 and I need to know whether I can change the calendar size dynamically. For example in one page I need to show calendar in full page in another page I need to put that same calendar in small div. Is it possible with the event calendar plug-in ?
Without the real example, I can only give a sketch how it could possibly work:
Include the view in something like:
<div id="smallcal">
<%= event_calendar %>
</div>
Add then a stylesheet that copies the rules of event_calendar.css, but modifies them like in the following example:
#smallcal > .ec-calendar { ... modified rules here ... }
So your modified rules will match better only for your variant where you want to make the calendar smaller. Perhaps it is possible to ensure that the calendar is smaller by including:
div#smallcal {
width: 200px;
...
}
Related
I use thymeleaf 3.
I display a localdate with
<div th:text="${sampling.buildDate}" th:remove="tag"></div>
is it possible to add a number of day to this date?
You'll want to manipulate the date on the server and display it on the front-end. This allows you to unit test and re-use the code, as well as keep the front-end logic easier for a UI designer to understand.
In your #GetMapping method:
model.addAttribute("modifiedBuildDate", modifiedBuildDate);
in the HTML:
<div th:text=""${#temporals.format(modifiedBuildDate, 'dd-MM-yyyy HH:mm')}"" th:remove="tag">Some modified date</div>
If you must manipulate it on the front-end (and I wouldn't recommend it),
you can try the utility ${#temporals.create(year,month,day)} and modify the date as needed.
I made a file called template.css.scss in my Rails app that holds all the color styling that I want dynamically changed based on a user's preferences.
Here's a little sample of it:
/* pink */
$lighter-shade: #F75F9E;
$darker-shade: #B54573;
.navbar-inverse {
background-color: $lighter-shade;
}
#command-header {
color: $darker-shade;
}
I thought I could do a migration to add a column to track the user's styling preference. Of course, there would be a default setting. Then I could update the Sass variables based on the preference.
Unfortunately, from my research it seems like the way to go is to create separate templates and then set those dynamically based on the user's preference. I really hope that's not the case because the way I have things structured right now is concise and efficient, and I'd hate to lose that.
How would you go about this?
one way to handle: get the user's preference and put it into a
data-user-preference="<%= current_user.pref %>">
then use jquery to add the appropriate class based on that pref
$('.class-name').data('user-preference').addClass('whatever')
I want to be able to find the parent "td" of a day on a datepicker calendar, but can't find a way to do this.
Example of the outpout of a datepicker :
<td class=" " data-year="2013" data-month="6" data-event="click" data-handler="selectDay">
<a class="ui-state-default" href="#">22</a>
</td>
There is a "data-year", "data-month" but no "data-day".. why ? I don't want to have to fetch each element to find the good one for every day object i want to get.. i should be able to access a day element directly...
The purpose is to add a class to the days i want (like an highlight class for example). I can't use "beforeShowDay"...everyone is talking about this, but it don't work for me since i need to add the class after the page load (example: booking a specific date by ajax and updating the calendar by highlighting the selected days without reloading the whole calendar or page)
I don't want to use "onselect" too, i need to be able to highlight my dates (by adding a class) without this AND be able to do it after the calendar is loaded.
To be more simple, i would like to access a day element like i access a div with
$('#divname").css(...)
for example. Or a similar way to change directly a day element.
Thanks for the help
Im building an eCommerce Rails 3.1 site and need the ability to add promotions throughout the site in various places. For example, the entire content side of the homepage might display a holiday promotion during the holidays, which is essentially an HTML block. Then the product pages would have a banner at the top.
I want to be able to do something like:
= render_content(:homepage_main)
In the views and then use a web-based admin to create and manage the content that is displayed. My requirements are:
Ability to define default content per block
Ability to schedule content for display
Ability to rotate content
Ability to track all views and eventual conversions
Internationalization
Does anyone know of a gem that does all or parts of the above?
What you're describing is essentially a partial that is rendered based on some condition (i.e. is today's date between 'x' and 'y').
I'm not aware of a gem for this, but it shouldn't be too hard to build. Just create a class called Promotion with the following fields:
datetime start_date
datetime end_date
text html_code
string block_id
boolean active
string landing_page
The block_id is essentially an HTML id that is used to insert the content of this Promotion to a <div> with a matching id. Then, in your store's layout, you put place marker <div> tags in places that would hold promotional call outs. The active field could be used to turn a promotion on/off (ignoring the start_date and end_date values).
I think that's pretty much all you would need.
To answer you list of needs:
Set the default value on the html_code field to whatever you want
Scheduling is done via the start_date and end_date fields
Do you mean rotate as in how a jCarousel rotates content visually? You can easily add jCarousel support yourself.
In your view code you can automatically add Google Analytics code to do this, and/or your own code to track how many times a promotion is shown in the rotation, and how many clicks it receives. If you did it a custom way, you would just add a views field for the number of times a given promotion was displayed, and a clicked field for when it was clicked. You can count clicks through a Promotions controller that handles redirects to the appropriate landing page, based on the landing_page field.
See the i18n gem
I have been working on a Rails template recently called BaseApp2. You can see it on GitHub here: http://github.com/dannyweb/BaseApp2
There is an administrators section setup which allows the management of Users and I am working on the ability to add announcements to the public site via the admin section.
What I would really like to do, is come up with two or three alternative colour schemes for the interface and allow the administrator to choose which they prefer and select it. The chosen colour scheme would then show for all users from then on.
I have literally no idea how to go about doing this - ideally I am looking for a tutorial of some sort or something equally beginner-esque.
Thanks in advance!
Thanks,
Danny
It should be fairly easy and there are many ways to do it. You will need to save that preference somewhere. Maybe add an attribute to your user/person model that will specify that preference. And in your admin layout template, based on that preference, add an additional stylesheet. Or, add a class to the body tag and in your style sheet subclass the styles:
body {
background-color: white;
}
body.sunshine {
background-color: yellow;
}
The layout template:
<%= stylesheet_link_tag(current_user.theme) if current_user.theme %>
or
<body class="<%= current_user.theme || '' %>">