1 /** Init for Farbtastic library and page setup
4 * @author Sarven Capadisli <csarven@controlyourself.ca>
5 * @copyright 2009 Control Yourself, Inc.
6 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
7 * @link http://laconi.ca/
9 $(document).ready(function() {
10 function UpdateColors(S) {
12 switch (parseInt(S.id.slice(-1))) {
14 $('html, body').css({'background-color':C});
17 $('#content, #site_nav_local_views .current a').css({'background-color':C});
20 $('#aside_primary').css({'background-color':C});
23 $('html body').css({'color':C});
26 $('a').css({'color':C});
31 function UpdateFarbtastic(e) {
36 function UpdateSwatch(e) {
37 $(e).css({"background-color": e.value,
38 "color": f.hsl[2] > 0.5 ? "#000": "#fff"});
41 function SynchColors(e) {
45 if (S && S.value && S.value != C) {
52 function InitFarbtastic() {
53 $('#settings_design_color').append('<div id="color-picker"></div>');
54 $('#color-picker').hide();
56 f = $.farbtastic('#color-picker', SynchColors);
57 swatches = $('#settings_design_color .swatch');
63 $(this).val(tv.toUpperCase());
64 (tv.length == 4) ? ((tv[0] == '#') ? $(this).val('#'+tv[1]+tv[1]+tv[2]+tv[2]+tv[3]+tv[3]) : '') : '';
67 $('#color-picker').show();
68 UpdateFarbtastic(this);
71 UpdateFarbtastic(this);
79 $('#form_settings_design').bind('reset', function(){
80 setTimeout(function(){
81 swatches.each(function(){UpdateColors(this);});
82 $('#color-picker').remove();
88 $('#design_background-image_off').focus(function() {
89 $('body').css({'background-image':'none'});
91 $('#design_background-image_on').focus(function() {
92 var bis = $('#design_background-image_onoff img')[0].src;
93 $('body').css({'background-image':'url('+bis+')'});
96 $('#design_background-image_repeat').click(function() {
97 ($(this)[0].checked) ? $('body').css({'background-repeat':'repeat'}) : $('body').css({'background-repeat':'no-repeat'});