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