[3408] | 1 | /* Set some CSS variables here |
---|
| 2 | -------------------------------------------------------- */ |
---|
| 3 | // set base font-size of body (62.5% default, usually : 50% to 75%) |
---|
| 4 | if (typeof dotclear_htmlFontSize !== 'undefined') { |
---|
| 5 | document.documentElement.style.setProperty('--html-font-size',dotclear_htmlFontSize); |
---|
| 6 | } |
---|
| 7 | |
---|
[0] | 8 | /* ChainHandler, py Peter van der Beken |
---|
| 9 | -------------------------------------------------------- */ |
---|
| 10 | function chainHandler(obj, handlerName, handler) { |
---|
| 11 | obj[handlerName] = (function(existingFunction) { |
---|
| 12 | return function() { |
---|
| 13 | handler.apply(this, arguments); |
---|
| 14 | if (existingFunction) |
---|
[131] | 15 | existingFunction.apply(this, arguments); |
---|
[0] | 16 | }; |
---|
| 17 | })(handlerName in obj ? obj[handlerName] : null); |
---|
| 18 | }; |
---|
| 19 | |
---|
| 20 | /* jQuery extensions |
---|
| 21 | -------------------------------------------------------- */ |
---|
| 22 | jQuery.fn.check = function() { |
---|
| 23 | return this.each(function() { |
---|
| 24 | if (this.checked != undefined) { this.checked = true; } |
---|
| 25 | }); |
---|
| 26 | }; |
---|
| 27 | jQuery.fn.unCheck = function() { |
---|
| 28 | return this.each(function() { |
---|
| 29 | if (this.checked != undefined) { this.checked = false; } |
---|
| 30 | }); |
---|
| 31 | }; |
---|
| 32 | jQuery.fn.setChecked = function(status) { |
---|
| 33 | return this.each(function() { |
---|
| 34 | if (this.checked != undefined) { this.checked = status; } |
---|
| 35 | }); |
---|
| 36 | }; |
---|
| 37 | jQuery.fn.toggleCheck = function() { |
---|
| 38 | return this.each(function() { |
---|
| 39 | if (this.checked != undefined) { this.checked = !this.checked; } |
---|
| 40 | }); |
---|
| 41 | }; |
---|
| 42 | |
---|
| 43 | jQuery.fn.enableShiftClick = function() { |
---|
| 44 | this.click( |
---|
| 45 | function (event) { |
---|
| 46 | if (event.shiftKey) { |
---|
| 47 | if (dotclear.lastclicked != '') { |
---|
| 48 | var range; |
---|
| 49 | var trparent = $(this).parents('tr'); |
---|
| 50 | if (trparent.nextAll('#'+dotclear.lastclicked).length != 0) |
---|
| 51 | range = trparent.nextUntil('#'+dotclear.lastclicked); |
---|
| 52 | else |
---|
| 53 | range = trparent.prevUntil('#'+dotclear.lastclicked); |
---|
[131] | 54 | |
---|
[0] | 55 | range.find('input[type=checkbox]').setChecked(dotclear.lastclickedstatus); |
---|
| 56 | this.checked = dotclear.lastclickedstatus; |
---|
| 57 | } |
---|
| 58 | } else { |
---|
| 59 | dotclear.lastclicked = $(this).parents('tr')[0].id; |
---|
| 60 | dotclear.lastclickedstatus = this.checked; |
---|
| 61 | } |
---|
| 62 | return true; |
---|
| 63 | }); |
---|
| 64 | } |
---|
| 65 | |
---|
[297] | 66 | jQuery.fn.toggleWithLegend = function(target,s) { |
---|
[0] | 67 | var defaults = { |
---|
| 68 | img_on_src: dotclear.img_plus_src, |
---|
| 69 | img_on_alt: dotclear.img_plus_alt, |
---|
| 70 | img_off_src: dotclear.img_minus_src, |
---|
| 71 | img_off_alt: dotclear.img_minus_alt, |
---|
[1699] | 72 | unfolded_sections: dotclear.unfolded_sections, |
---|
[0] | 73 | hide: true, |
---|
| 74 | speed: 0, |
---|
| 75 | legend_click: false, |
---|
| 76 | fn: false, // A function called on first display, |
---|
[1699] | 77 | user_pref: false, |
---|
[1923] | 78 | reverse_user_pref: false // Reverse cookie behavior |
---|
[0] | 79 | }; |
---|
| 80 | var p = jQuery.extend(defaults,s); |
---|
[131] | 81 | |
---|
[0] | 82 | if (!target) { return this; } |
---|
[131] | 83 | |
---|
[0] | 84 | var set_cookie = p.hide ^ p.reverse_cookie; |
---|
| 85 | if (p.cookie && jQuery.cookie(p.cookie)) { |
---|
| 86 | p.hide = p.reverse_cookie; |
---|
| 87 | } |
---|
[2566] | 88 | |
---|
[1699] | 89 | var set_user_pref = p.hide ^ p.reverse_user_pref; |
---|
[1781] | 90 | if (p.user_pref && p.unfolded_sections !== undefined && (p.user_pref in p.unfolded_sections)) { |
---|
[1699] | 91 | p.hide = p.reverse_user_pref; |
---|
| 92 | } |
---|
[297] | 93 | var toggle = function(i,speed) { |
---|
[0] | 94 | speed = speed || 0; |
---|
| 95 | if (p.hide) { |
---|
| 96 | $(i).get(0).src = p.img_on_src; |
---|
| 97 | $(i).get(0).alt = p.img_on_alt; |
---|
[2187] | 98 | target.addClass('hide'); |
---|
[0] | 99 | } else { |
---|
| 100 | $(i).get(0).src = p.img_off_src; |
---|
| 101 | $(i).get(0).alt = p.img_off_alt; |
---|
[2187] | 102 | target.removeClass('hide'); |
---|
[0] | 103 | if (p.fn) { |
---|
| 104 | p.fn.apply(target); |
---|
| 105 | p.fn = false; |
---|
| 106 | } |
---|
| 107 | } |
---|
[131] | 108 | |
---|
[0] | 109 | if (p.cookie && set_cookie) { |
---|
| 110 | if (p.hide ^ p.reverse_cookie) { |
---|
| 111 | jQuery.cookie(p.cookie,'',{expires: -1}); |
---|
| 112 | } else { |
---|
| 113 | jQuery.cookie(p.cookie,1,{expires: 30}); |
---|
| 114 | } |
---|
| 115 | } |
---|
| 116 | p.hide = !p.hide; |
---|
| 117 | }; |
---|
[131] | 118 | |
---|
[0] | 119 | return this.each(function() { |
---|
| 120 | var i = document.createElement('img'); |
---|
| 121 | i.src = p.img_off_src; |
---|
| 122 | i.alt = p.img_off_alt; |
---|
| 123 | var a = document.createElement('a'); |
---|
| 124 | a.href= '#'; |
---|
| 125 | $(a).append(i); |
---|
| 126 | $(a).css({ |
---|
| 127 | border: 'none', |
---|
| 128 | outline: 'none' |
---|
| 129 | }); |
---|
[131] | 130 | |
---|
[0] | 131 | var ctarget = p.legend_click ? this : a; |
---|
[131] | 132 | |
---|
[0] | 133 | $(ctarget).css('cursor','pointer'); |
---|
[1525] | 134 | if (p.legend_click) { |
---|
| 135 | $(ctarget).find('label').css('cursor','pointer'); |
---|
| 136 | } |
---|
[0] | 137 | $(ctarget).click(function() { |
---|
[1699] | 138 | if (p.user_pref && set_user_pref) { |
---|
| 139 | if (p.hide ^ p.reverse_user_pref) { |
---|
[2566] | 140 | jQuery.post('services.php', |
---|
[1699] | 141 | {'f':'setSectionFold','section':p.user_pref,'value':1,xd_check: dotclear.nonce}, |
---|
| 142 | function(data) {}); |
---|
| 143 | } else { |
---|
[2566] | 144 | jQuery.post('services.php', |
---|
[1699] | 145 | {'f':'setSectionFold','section':p.user_pref,'value':0,xd_check: dotclear.nonce}, |
---|
| 146 | function(data) {}); |
---|
| 147 | } |
---|
| 148 | jQuery.cookie(p.user_pref,'',{expires: -1}); |
---|
| 149 | } |
---|
[1140] | 150 | toggle(i,p.speed); |
---|
[0] | 151 | return false; |
---|
| 152 | }); |
---|
[131] | 153 | |
---|
| 154 | |
---|
[0] | 155 | toggle($(i).get(0)); |
---|
| 156 | $(this).prepend(' ').prepend(a); |
---|
| 157 | }); |
---|
| 158 | }; |
---|
| 159 | |
---|
[2531] | 160 | (function($) { |
---|
| 161 | 'use strict'; |
---|
| 162 | |
---|
| 163 | $.expandContent = function(opts) { |
---|
| 164 | var defaults = {}; |
---|
| 165 | $.expandContent.options = $.extend({},defaults,opts); |
---|
| 166 | |
---|
| 167 | if (opts==undefined || opts.callback==undefined || !$.isFunction(opts.callback)) { |
---|
| 168 | return; |
---|
| 169 | } |
---|
| 170 | if (opts.line!=undefined) { |
---|
| 171 | multipleExpander(opts.line,opts.lines); |
---|
| 172 | } |
---|
| 173 | opts.lines.each(function() { |
---|
| 174 | singleExpander(this); |
---|
| 175 | }); |
---|
| 176 | } |
---|
[2566] | 177 | |
---|
[2531] | 178 | var singleExpander = function singleExpander(line) { |
---|
| 179 | $('<input type="image" src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/>') |
---|
| 180 | .click(function(e) { |
---|
| 181 | toggleArrow(this); |
---|
| 182 | $.expandContent.options.callback.call(this,line); |
---|
| 183 | e.preventDefault(); |
---|
| 184 | }) |
---|
| 185 | .prependTo($(line).children().get(0)); // first td |
---|
| 186 | }; |
---|
[2566] | 187 | |
---|
[2531] | 188 | var multipleExpander = function multipleExpander(line,lines) { |
---|
| 189 | $('<input type="image" src="'+dotclear.img_plus_src+'" alt="'+dotclear.img_plus_alt+'"/>') |
---|
| 190 | .click(function(e) { |
---|
| 191 | var that = this; |
---|
| 192 | var action = toggleArrow(this); |
---|
| 193 | lines.each(function() { |
---|
| 194 | toggleArrow(this.firstChild.firstChild,action); |
---|
| 195 | $.expandContent.options.callback.call(that,this,action); |
---|
| 196 | |
---|
| 197 | }); |
---|
| 198 | e.preventDefault(); |
---|
| 199 | }) |
---|
| 200 | .prependTo($(line).children().get(0)); // first td |
---|
| 201 | }; |
---|
| 202 | |
---|
| 203 | var toggleArrow = function toggleArrow(button,action) { |
---|
| 204 | action = action || ''; |
---|
| 205 | if (action=='') { |
---|
| 206 | if (button.alt==dotclear.img_plus_alt) { |
---|
| 207 | action = 'open'; |
---|
| 208 | } else { |
---|
| 209 | action = 'close'; |
---|
| 210 | } |
---|
| 211 | } |
---|
[2566] | 212 | |
---|
[2531] | 213 | if (action=='open') { |
---|
| 214 | button.src = dotclear.img_minus_src; |
---|
| 215 | button.alt = dotclear.img_minus_alt; |
---|
| 216 | } else { |
---|
| 217 | button.src = dotclear.img_plus_src; |
---|
| 218 | button.alt = dotclear.img_plus_alt; |
---|
| 219 | } |
---|
[2566] | 220 | |
---|
[2531] | 221 | return action; |
---|
| 222 | } |
---|
| 223 | })(jQuery); |
---|
| 224 | |
---|
[0] | 225 | jQuery.fn.helpViewer = function() { |
---|
| 226 | if (this.length < 1) { |
---|
| 227 | return this; |
---|
| 228 | } |
---|
[131] | 229 | |
---|
[0] | 230 | var p = { |
---|
| 231 | img_on_src: dotclear.img_plus_src, |
---|
| 232 | img_on_alt: dotclear.img_plus_alt, |
---|
| 233 | img_off_src: dotclear.img_minus_src, |
---|
| 234 | img_off_alt: dotclear.img_minus_alt |
---|
| 235 | }; |
---|
| 236 | var This = this; |
---|
| 237 | var toggle = function() { |
---|
| 238 | $('#content').toggleClass('with-help'); |
---|
| 239 | if (document.all) { |
---|
| 240 | if ($('#content').hasClass('with-help')) { |
---|
| 241 | select = $('#content select:visible').hide(); |
---|
| 242 | } else { |
---|
| 243 | select.show(); |
---|
| 244 | } |
---|
| 245 | } |
---|
[2262] | 246 | $('p#help-button span a').text($('#content').hasClass('with-help') ? dotclear.msg.help_hide : dotclear.msg.help); |
---|
[0] | 247 | sizeBox(); |
---|
| 248 | return false; |
---|
| 249 | }; |
---|
[131] | 250 | |
---|
[0] | 251 | var sizeBox = function() { |
---|
| 252 | This.css('height','auto'); |
---|
[1994] | 253 | if ($('#wrapper').height() > This.height()) { |
---|
| 254 | This.css('height',$('#wrapper').height() + 'px'); |
---|
[0] | 255 | } |
---|
| 256 | }; |
---|
[131] | 257 | |
---|
[0] | 258 | var textToggler = function(o) { |
---|
| 259 | var i = $('<img src="'+p.img_on_src+'" alt="'+p.img_on_alt+'" />'); |
---|
| 260 | o.css('cursor','pointer'); |
---|
| 261 | var hide = true; |
---|
[131] | 262 | |
---|
[0] | 263 | o.prepend(' ').prepend(i); |
---|
| 264 | o.click(function() { |
---|
| 265 | $(this).nextAll().each(function() { |
---|
[1573] | 266 | if ($(this).is('h4')) { |
---|
[0] | 267 | return false; |
---|
| 268 | } |
---|
| 269 | $(this).toggle(); |
---|
| 270 | sizeBox(); |
---|
| 271 | return true; |
---|
| 272 | }); |
---|
| 273 | hide = !hide; |
---|
| 274 | var img = $(this).find('img'); |
---|
| 275 | if (!hide) { |
---|
| 276 | img.attr('src',p.img_off_src); |
---|
| 277 | } else { |
---|
| 278 | img.attr('src',p.img_on_src); |
---|
| 279 | } |
---|
| 280 | }); |
---|
| 281 | }; |
---|
[131] | 282 | |
---|
[0] | 283 | this.addClass('help-box'); |
---|
| 284 | this.find('>hr').remove(); |
---|
[131] | 285 | |
---|
[1573] | 286 | this.find('h4').each(function() { textToggler($(this)); }); |
---|
| 287 | this.find('h4:first').nextAll('*:not(h4)').hide(); |
---|
[0] | 288 | sizeBox(); |
---|
[131] | 289 | |
---|
[2262] | 290 | var img = $('<p id="help-button"><span><a href="">'+dotclear.msg.help+'</a></span></p>'); |
---|
[0] | 291 | var select = $(); |
---|
| 292 | img.click(function() { return toggle(); }); |
---|
[131] | 293 | |
---|
[0] | 294 | $('#content').append(img); |
---|
[2566] | 295 | |
---|
[1990] | 296 | // listen for scroll |
---|
| 297 | var peInPage = $('#help-button').offset().top; |
---|
| 298 | $('#help-button').addClass("floatable"); |
---|
[2689] | 299 | var peInFloat = $('#help-button').offset().top - $(window).scrollTop(); |
---|
[1990] | 300 | $('#help-button').removeClass("floatable"); |
---|
| 301 | $(window).scroll( |
---|
| 302 | function() { |
---|
| 303 | if ($(window).scrollTop() >= peInPage - peInFloat ) { |
---|
| 304 | $('#help-button').addClass("floatable"); |
---|
| 305 | } else { |
---|
| 306 | $('#help-button').removeClass("floatable"); |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | ); |
---|
[131] | 310 | |
---|
[0] | 311 | return this; |
---|
| 312 | }; |
---|
| 313 | |
---|
[2225] | 314 | |
---|
[0] | 315 | /* Dotclear common object |
---|
| 316 | -------------------------------------------------------- */ |
---|
| 317 | var dotclear = { |
---|
| 318 | msg: {}, |
---|
[131] | 319 | |
---|
[3182] | 320 | condSubmit: function(chkboxes,target) { |
---|
| 321 | var checkboxes = $(chkboxes), |
---|
| 322 | submitButt = $(target); |
---|
| 323 | |
---|
| 324 | if (checkboxes === undefined || submitButt === undefined) { |
---|
| 325 | return; |
---|
| 326 | } |
---|
| 327 | |
---|
| 328 | // Set initial state |
---|
| 329 | submitButt.attr("disabled", !checkboxes.is(":checked")); |
---|
| 330 | if (!checkboxes.is(":checked")) { |
---|
| 331 | submitButt.addClass('disabled'); |
---|
| 332 | } else { |
---|
| 333 | submitButt.removeClass('disabled'); |
---|
| 334 | } |
---|
| 335 | |
---|
| 336 | checkboxes.click(function() { |
---|
| 337 | // Update target state |
---|
| 338 | submitButt.attr("disabled", !checkboxes.is(":checked")); |
---|
| 339 | if (!checkboxes.is(":checked")) { |
---|
| 340 | submitButt.addClass('disabled'); |
---|
| 341 | } else { |
---|
| 342 | submitButt.removeClass('disabled'); |
---|
| 343 | } |
---|
| 344 | }); |
---|
| 345 | }, |
---|
| 346 | |
---|
[0] | 347 | hideLockable: function() { |
---|
| 348 | $('div.lockable').each(function() { |
---|
| 349 | var current_lockable_div = this; |
---|
| 350 | $(this).find('p.form-note').hide(); |
---|
| 351 | $(this).find('input').each(function() { |
---|
| 352 | this.disabled = true; |
---|
| 353 | $(this).width(($(this).width()-14) + 'px'); |
---|
[131] | 354 | |
---|
[0] | 355 | var imgE = document.createElement('img'); |
---|
| 356 | imgE.src = 'images/locker.png'; |
---|
| 357 | imgE.style.position = 'absolute'; |
---|
| 358 | imgE.style.top = '1.7em'; |
---|
[1761] | 359 | imgE.style.left = ($(this).width()+12)+'px'; |
---|
[1395] | 360 | imgE.alt=dotclear.msg.click_to_unlock; |
---|
[0] | 361 | $(imgE).css('cursor','pointer'); |
---|
[131] | 362 | |
---|
[0] | 363 | $(imgE).click(function() { |
---|
| 364 | $(this).hide(); |
---|
| 365 | $(this).prev('input').each(function() { |
---|
| 366 | this.disabled = false; |
---|
| 367 | $(this).width(($(this).width()+14) + 'px'); |
---|
| 368 | }); |
---|
| 369 | $(current_lockable_div).find('p.form-note').show(); |
---|
| 370 | }); |
---|
[131] | 371 | |
---|
[0] | 372 | $(this).parent().css('position','relative'); |
---|
| 373 | $(this).after(imgE); |
---|
| 374 | }); |
---|
| 375 | }); |
---|
| 376 | }, |
---|
[131] | 377 | |
---|
[3182] | 378 | checkboxesHelpers: function(e, target, c, s) { |
---|
[1556] | 379 | $(e).append(document.createTextNode(dotclear.msg.to_select)); |
---|
| 380 | $(e).append(document.createTextNode(' ')); |
---|
| 381 | |
---|
[2200] | 382 | $('<a href="#">'+dotclear.msg.select_all+'</a>').click(function() { |
---|
[2201] | 383 | if (target !== undefined) { |
---|
| 384 | target.check(); |
---|
| 385 | } else { |
---|
| 386 | $(e).parents('form').find('input[type="checkbox"]').check(); |
---|
[2200] | 387 | } |
---|
[3182] | 388 | if (c !== undefined && s !== undefined) { |
---|
| 389 | dotclear.condSubmit(c,s); |
---|
| 390 | } |
---|
[0] | 391 | return false; |
---|
[2200] | 392 | }).appendTo($(e)); |
---|
[1556] | 393 | $(e).append(document.createTextNode(' | ')); |
---|
[131] | 394 | |
---|
[2200] | 395 | $('<a href="#">'+dotclear.msg.no_selection+'</a>').click(function() { |
---|
[2201] | 396 | if (target !== undefined) { |
---|
| 397 | target.unCheck(); |
---|
| 398 | } else { |
---|
| 399 | $(e).parents('form').find('input[type="checkbox"]').unCheck(); |
---|
[2200] | 400 | } |
---|
[3182] | 401 | if (c !== undefined && s !== undefined) { |
---|
| 402 | dotclear.condSubmit(c,s); |
---|
| 403 | } |
---|
[0] | 404 | return false; |
---|
[2200] | 405 | }).appendTo($(e)); |
---|
[0] | 406 | $(e).append(document.createTextNode(' - ')); |
---|
[131] | 407 | |
---|
[2200] | 408 | $('<a href="#">'+dotclear.msg.invert_sel+'</a>').click(function() { |
---|
[2201] | 409 | if (target !== undefined) { |
---|
| 410 | target.toggleCheck(); |
---|
| 411 | } else { |
---|
| 412 | $(e).parents('form').find('input[type="checkbox"]').toggleCheck(); |
---|
[2200] | 413 | } |
---|
[3182] | 414 | if (c !== undefined && s !== undefined) { |
---|
| 415 | dotclear.condSubmit(c,s); |
---|
| 416 | } |
---|
[0] | 417 | return false; |
---|
[2200] | 418 | }).appendTo($(e)); |
---|
[0] | 419 | }, |
---|
[131] | 420 | |
---|
[0] | 421 | postsActionsHelper: function() { |
---|
| 422 | $('#form-entries').submit(function() { |
---|
| 423 | var action = $(this).find('select[name="action"]').val(); |
---|
[2810] | 424 | if (action===undefined) { |
---|
| 425 | return; |
---|
| 426 | } |
---|
[0] | 427 | var checked = false; |
---|
[131] | 428 | |
---|
[0] | 429 | $(this).find('input[name="entries[]"]').each(function() { |
---|
| 430 | if (this.checked) { |
---|
| 431 | checked = true; |
---|
| 432 | } |
---|
| 433 | }); |
---|
[131] | 434 | |
---|
[0] | 435 | if (!checked) { return false; } |
---|
[131] | 436 | |
---|
[0] | 437 | if (action == 'delete') { |
---|
| 438 | return window.confirm(dotclear.msg.confirm_delete_posts.replace('%s',$('input[name="entries[]"]:checked').size())); |
---|
| 439 | } |
---|
[131] | 440 | |
---|
[0] | 441 | return true; |
---|
| 442 | }); |
---|
| 443 | }, |
---|
[131] | 444 | |
---|
[0] | 445 | commentsActionsHelper: function() { |
---|
| 446 | $('#form-comments').submit(function() { |
---|
| 447 | var action = $(this).find('select[name="action"]').val(); |
---|
| 448 | var checked = false; |
---|
[131] | 449 | |
---|
[0] | 450 | $(this).find('input[name="comments[]"]').each(function() { |
---|
| 451 | if (this.checked) { |
---|
| 452 | checked = true; |
---|
| 453 | } |
---|
| 454 | }); |
---|
[131] | 455 | |
---|
[0] | 456 | if (!checked) { return false; } |
---|
[131] | 457 | |
---|
[0] | 458 | if (action == 'delete') { |
---|
| 459 | return window.confirm(dotclear.msg.confirm_delete_comments.replace('%s',$('input[name="comments[]"]:checked').size())); |
---|
| 460 | } |
---|
[131] | 461 | |
---|
[0] | 462 | return true; |
---|
| 463 | }); |
---|
[2101] | 464 | }, |
---|
| 465 | getCSSColor : function ( clazz) { |
---|
| 466 | $('<div class="'+clazz+'" id="dotclear-obj-test-color" style="display:none"></div>').appendTo(document.body); |
---|
| 467 | var tag2 = $('#dotclear-obj-test-color'); |
---|
| 468 | var color = $.trim(tag2.css("color").toLowerCase()); |
---|
| 469 | tag2.remove(); |
---|
| 470 | if ( color.charAt(0) === '#') { |
---|
| 471 | return color; |
---|
| 472 | } |
---|
[2566] | 473 | var result = /^rgb\((\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\)$/.exec(color); |
---|
[2101] | 474 | if ( result === null) { |
---|
| 475 | return ''; |
---|
| 476 | } |
---|
| 477 | var ret = '#'; |
---|
| 478 | for ( var i = 1; i < 4; i++) { |
---|
| 479 | var val = parseInt(result[i],10); |
---|
| 480 | ret += (val < 16 ? '0'+val.toString(16) : val.toString(16)); |
---|
| 481 | } |
---|
| 482 | return ret; |
---|
| 483 | }, |
---|
| 484 | initFadeColor : function() { |
---|
| 485 | dotclear.fadeColor = { |
---|
| 486 | beginPassword : dotclear.getCSSColor('colorBeginPassword'), |
---|
| 487 | endPassword : dotclear.getCSSColor('colorEndPassword'), |
---|
| 488 | beginMessage : dotclear.getCSSColor('colorBeginMessage'), |
---|
| 489 | endMessage : dotclear.getCSSColor('colorEndMessage'), |
---|
| 490 | beginError : dotclear.getCSSColor('colorBeginError'), |
---|
| 491 | endError : dotclear.getCSSColor('colorEndError'), |
---|
| 492 | beginSuccess : dotclear.getCSSColor('colorBeginSuccess'), |
---|
| 493 | endSuccess : dotclear.getCSSColor('colorEndSuccess'), |
---|
| 494 | beginValidatorMsg : dotclear.getCSSColor('colorBeginValidatorMsg'), |
---|
| 495 | endValidatorMsg : dotclear.getCSSColor('colorEndValidatorMsg'), |
---|
| 496 | beginValidatorErr : dotclear.getCSSColor('colorBeginValidatorErr'), |
---|
| 497 | endValidatorErr : dotclear.getCSSColor('colorEndValidatorErr'), |
---|
| 498 | beginUserMail : dotclear.getCSSColor('colorBeginUserMail'), |
---|
| 499 | endUserMail : dotclear.getCSSColor('colorEndUserMail') |
---|
| 500 | }; |
---|
| 501 | }}; |
---|
[0] | 502 | |
---|
| 503 | /* On document ready |
---|
| 504 | -------------------------------------------------------- */ |
---|
| 505 | $(function() { |
---|
[2101] | 506 | dotclear.initFadeColor(); |
---|
[1603] | 507 | // remove class no-js from html tag; cf style/default.css for examples |
---|
[1798] | 508 | $('body').removeClass('no-js').addClass('with-js'); |
---|
[2566] | 509 | |
---|
[2297] | 510 | $('body').contents().each(function() { |
---|
[1603] | 511 | if (this.nodeType==8) { |
---|
[2297] | 512 | var data = this.data; |
---|
| 513 | data = data.replace(/ /g,' ').replace(/\n/g,'<br/>'); |
---|
| 514 | $('<span class="tooltip">'+$('#footer a').prop('title')+data+'</span>').appendTo('#footer a'); |
---|
[1603] | 515 | } |
---|
| 516 | }); |
---|
| 517 | |
---|
[2225] | 518 | // manage outgoing links |
---|
[2248] | 519 | $('a').filter(function() { |
---|
[2486] | 520 | return ((this.hostname && this.hostname!=location.hostname && !$(this).hasClass('modal')) |
---|
[2248] | 521 | || $(this).hasClass('outgoing')); |
---|
| 522 | }).each(function() { |
---|
| 523 | $(this).prop('title',$(this).prop('title')+' ('+dotclear.msg.new_window+')'); |
---|
| 524 | if (!$(this).hasClass('outgoing')) { |
---|
[2298] | 525 | $(this).append(' <img src="images/outgoing-blue.png" alt=""/>'); |
---|
[2248] | 526 | } |
---|
[2225] | 527 | }).click(function(e) { |
---|
| 528 | e.preventDefault(); |
---|
| 529 | window.open($(this).attr('href')); |
---|
| 530 | }); |
---|
| 531 | |
---|
[0] | 532 | // Blog switcher |
---|
| 533 | $('#switchblog').change(function() { |
---|
| 534 | this.form.submit(); |
---|
| 535 | }); |
---|
[131] | 536 | |
---|
[0] | 537 | var menu_settings = { |
---|
| 538 | img_on_src: dotclear.img_menu_off, |
---|
| 539 | img_off_src: dotclear.img_menu_on, |
---|
| 540 | legend_click: true, |
---|
| 541 | speed: 100 |
---|
| 542 | } |
---|
| 543 | $('#blog-menu h3:first').toggleWithLegend($('#blog-menu ul:first'), |
---|
[1699] | 544 | $.extend({user_pref:'dc_blog_menu'},menu_settings) |
---|
[0] | 545 | ); |
---|
| 546 | $('#system-menu h3:first').toggleWithLegend($('#system-menu ul:first'), |
---|
[1699] | 547 | $.extend({user_pref:'dc_system_menu'},menu_settings) |
---|
[0] | 548 | ); |
---|
| 549 | $('#plugins-menu h3:first').toggleWithLegend($('#plugins-menu ul:first'), |
---|
[1699] | 550 | $.extend({user_pref:'dc_plugins_menu'},menu_settings) |
---|
[0] | 551 | ); |
---|
[3] | 552 | $('#favorites-menu h3:first').toggleWithLegend($('#favorites-menu ul:first'), |
---|
[1699] | 553 | $.extend({user_pref:'dc_favorites_menu',hide:false,reverse_user_pref:true},menu_settings) |
---|
[3] | 554 | ); |
---|
[131] | 555 | |
---|
[0] | 556 | $('#help').helpViewer(); |
---|
[131] | 557 | |
---|
[2101] | 558 | $('.message').backgroundFade({sColor: dotclear.fadeColor.beginMessage, eColor: dotclear.fadeColor.endMessage, steps:20}); |
---|
| 559 | $('.error').backgroundFade({sColor: dotclear.fadeColor.beginError, eColor: dotclear.fadeColor.endError, steps:20}); |
---|
| 560 | $('.success').backgroundFade({sColor: dotclear.fadeColor.beginSuccess, eColor: dotclear.fadeColor.endSuccess, steps:20}); |
---|
[131] | 561 | |
---|
[0] | 562 | $('form:has(input[type=password][name=your_pwd])').submit(function() { |
---|
| 563 | var e = this.elements['your_pwd']; |
---|
| 564 | if (e.value == '') { |
---|
| 565 | e.focus(); |
---|
[2101] | 566 | $(e).backgroundFade({sColor: dotclear.fadeColor.beginPassword,eColor: dotclear.fadeColor.endPassword,steps:50},function() { |
---|
| 567 | $(this).backgroundFade({sColor: dotclear.fadeColor.endPassword,eColor: dotclear.fadeColor.beginPassword}); |
---|
[0] | 568 | }); |
---|
| 569 | return false; |
---|
| 570 | } |
---|
| 571 | return true; |
---|
| 572 | }); |
---|
| 573 | |
---|
[3398] | 574 | if (dotclear.hideMoreInfo) { |
---|
| 575 | $('.more-info,.form-note:not(.warn,.warning,.info)').addClass('no-more-info'); |
---|
| 576 | } |
---|
| 577 | |
---|
[1861] | 578 | // Main menu collapser |
---|
| 579 | var objMain = $('#wrapper'); |
---|
| 580 | function showSidebar(){ |
---|
| 581 | // Show sidebar |
---|
| 582 | objMain.removeClass('hide-mm'); |
---|
| 583 | $.cookie('sidebar-pref',null,{expires:30}); |
---|
| 584 | } |
---|
| 585 | function hideSidebar(){ |
---|
| 586 | // Hide sidebar |
---|
| 587 | objMain.addClass('hide-mm'); |
---|
| 588 | $.cookie('sidebar-pref','hide-mm',{expires:30}); |
---|
| 589 | } |
---|
| 590 | // Sidebar separator |
---|
| 591 | var objSeparator = $('#collapser'); |
---|
| 592 | objSeparator.click(function(e){ |
---|
| 593 | e.preventDefault(); |
---|
| 594 | if ( objMain.hasClass('hide-mm') ){ |
---|
| 595 | showSidebar(); |
---|
[2284] | 596 | $('#main-menu input#qx').focus(); |
---|
[1861] | 597 | } |
---|
| 598 | else { |
---|
| 599 | hideSidebar(); |
---|
[2284] | 600 | $('#content a.go_home').focus(); |
---|
[1861] | 601 | } |
---|
[1946] | 602 | }); |
---|
[1861] | 603 | if ( $.cookie('sidebar-pref') == 'hide-mm' ){ |
---|
| 604 | objMain.addClass('hide-mm'); |
---|
| 605 | } else { |
---|
| 606 | objMain.removeClass('hide-mm'); |
---|
| 607 | } |
---|
[3294] | 608 | // totop scroll |
---|
| 609 | $(window).scroll(function() { |
---|
| 610 | if($(this).scrollTop() != 0) { |
---|
| 611 | $('#gototop').fadeIn(); |
---|
| 612 | } else { |
---|
| 613 | $('#gototop').fadeOut(); |
---|
| 614 | } |
---|
| 615 | }); |
---|
| 616 | |
---|
[3332] | 617 | $('#gototop').click(function(e) { |
---|
[3294] | 618 | $('body,html').animate({scrollTop:0},800); |
---|
[3332] | 619 | e.preventDefault(); |
---|
[3294] | 620 | }); |
---|
[1871] | 621 | }); |
---|