Installation
Plugin's js code Minified version of the js file Plugin's stylesheet (best suited for dark backgrounds, like this blog) Alternative stylesheet (for bright backgrounds, like this blog's mob version) A CSS reset stylesheet |
There are 2 css choices that are quite different. The default is best suited for dark backgrounds and the alternative for bright ones. You can choose one as a base and tweak it to perfectly fit your site’s style. Actually, the resulting html is nothing more than a series of anchors and that is what we are basically styling. The cleanslate.css is a CSS reset stylesheet, for aggressively resetting the styling of an element and its children. It is written by Premasagar Rose and you can find more about it in its own site on github/premasager/cleanslate.
After you download the files above, you need to include them to your pages, along with the jQuery lib.
<link rel="Stylesheet" href="styles/cleanslate.css" />
<link rel="Stylesheet" href="styles/jquery.weekLine.css" />
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script src="scripts/jquery.weekLine.min.js"></script>
Example use
// Adds a weekLine date picker | Click to select/deselect, or click and hold for fast multiday selection. |
// Return selected days as indexes
$("#weekCal1").weekLine({
onChange: function () {
$("#selectedDays").html(
$(this).weekLine('getSelected', 'indexes')
);
}
});
// Return selected days as labels
$("#weekCal2").weekLine({
mousedownSel: false,
onChange: function () {
$("#selectedDays").html(
$(this).weekLine('getSelected')
);
}
});
// Return selected days with descriptive text
var weekCal3 = $("#weekCal3").weekLine({
onChange: function () {
$("#selectedDays").html(
$(this).weekLine('getSelected', 'descriptive')
);
}
});
var nextMonday = nextDay(0);
// Return selected days as dates,
// starting from coming Monday
var weekCal4 = $("#weekCal4").weekLine({
startDate: nextMonday(),
dayLabels: ["M", "T", "W", "T", "F", "S", "S"],
onChange: function () {
$("#selectedDays").html(
$(this).weekLine('getSelected', 'dates')
);
}
});
// Select some days
weekCal3.weekLine("setSelected", "Sat,Sun");
weekCal4.weekLine("setSelected", "0,1,2,3,4");
Above code creates 4 weekLine day pickers and assigns their values to a span with the id “selectedDays”, using the getSelected method and the onChange callback.
| |
MIT Licence
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.