Changeset 3869:97af47e1ee7d
- Timestamp:
- 09/11/18 15:45:42 (7 years ago)
- Branch:
- default
- Location:
- admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
admin/js/common.js
r3858 r3869 171 171 }; 172 172 var singleExpander = function singleExpander(line, callback) { 173 $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function 173 $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function(e) { 174 174 toggleArrow(this); 175 175 callback(line); … … 178 178 }; 179 179 var multipleExpander = function multipleExpander(line, lines, callback) { 180 $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function 180 $('<button type="button" class="details-cmd" aria-label="' + dotclear.img_plus_alt + '">' + dotclear.img_plus_txt + '</button>').click(function(e) { 181 181 var action = toggleArrow(this); 182 182 lines.each(function() { … … 446 446 window.open($(this).attr('href')); 447 447 }); 448 } 448 }, 449 450 badge: function($elt, options = null) { 451 // Cope with selector given as string or DOM element rather than a jQuery object 452 if (typeof $elt === 'string' || $elt instanceof Element) { 453 $elt = $($elt); 454 } 455 456 // Return if elt does not exist 457 if (!$elt.length) return; 458 459 // Cope with options 460 var opt = $.extend({ 461 /* sibling: define if the given element is a sibling of the badge or it's parent 462 * true: use $elt.after() to add badge 463 * false: use $elt.parent().append() to add badge (default) 464 */ 465 sibling: false, 466 /* id: badge unique class 467 * this class will be used to delete all corresponding badge (used for removing and updating) 468 */ 469 id: 'default', 470 /* remove: will remove the badge if set to true */ 471 remove: false, 472 /* value: badge value */ 473 value: null, 474 /* inline: if set to true, the badge is an inline element (useful for menu item) rather than a block */ 475 inline: false, 476 /* icon: if set to true, the badge is attached to a dashboard icon (needed for correct positionning) */ 477 icon: false, 478 /* type: Override default background (which may vary) 479 * by default badge background are soft grey for dashboard icons (see opt.icon) and bright red for all other elements 480 * possible values: 481 * 'std': bright red 482 * 'info': blue 483 * 'soft': soft grey 484 */ 485 type: '', 486 /* classes: additionnal badge classes */ 487 classes: '' 488 }, options); 489 490 // Set some constants 491 const classid = 'span.badge.badge-' + opt.id; // Pseudo unique class 492 493 // Set badgeable class to elt parent's (if sibling) or elt itself, if it is necessary 494 var $parent = (opt.sibling ? $elt.parent() : $elt); 495 if (!opt.inline && !opt.remove && !$parent.hasClass('badgeable')) { 496 $parent.addClass('badgeable'); 497 } 498 499 // Remove existing badge if exists 500 var $badge = (opt.sibling ? $parent.children(classid) : $elt.children(classid)); 501 if ($badge.length) { 502 $badge.remove(); 503 } 504 505 if (!opt.remove && opt.value !== null) { 506 // Add the new badge 507 const cls = 'badge badge-' + opt.id + ' ' + 508 (opt.inline ? 'badge-inline' : 'badge-block') + 509 (opt.icon ? ' badge-icon' : '') + 510 (opt.type !== '' ? ' badge-' + opt.type : '') + 511 (opt.classes !== '' ? ' ' + opt.classes : ''); 512 const xml = '<span class="' + cls + '" aria-hidden="true">' + opt.value + '</span>'; 513 if (opt.sibling) { 514 // Add badge after it's sibling 515 $elt.after(xml); 516 } else { 517 // Append badge to the elt 518 $elt.append(xml); 519 } 520 } 521 } 522 449 523 }; 450 524 /* On document ready -
admin/style/default-dark.css
r3868 r3869 3211 3211 border: 1px solid #c9cbcf; } 3212 3212 3213 /* Badges */ 3214 /* 3215 Set .badgeable to badge parent's (not mandatory for menu items), then use: 3216 .badge (standard badge) 3217 which must be combined with : 3218 .badge-icon (dashboard icon) → top right, or 3219 .badge-block (dashboard module) → top left, or 3220 .badge-inline (menu item) → right centered 3221 and may be combined with : 3222 .badge-info → blue background 3223 and may be combined with (only in dashboard, not in menu) : 3224 .badge-block-icon (dashboard icon or module) → soft badge on top right 3225 */ 3213 /* Badges (common.js) */ 3226 3214 .badgeable { 3227 3215 /* class to set to badge parent's, not mandatory for menu items */ … … 3236 3224 padding: 0 .6em; } 3237 3225 3226 .badge-icon { 3227 background-color: #708090; } 3228 3229 /* Badge background override */ 3230 .badge-std { 3231 background-color: #d54e21; } 3232 3238 3233 .badge-info { 3239 3234 background-color: #3f51b5; } 3240 3235 3241 .badge-icon { 3242 border-radius: 5px; } 3243 3244 .badge-block-icon { 3245 background-color: #708090; } 3236 .badge-soft { 3237 background-color: #708090; 3238 } 3246 3239 3247 3240 /* Badge position */ 3248 .badge-icon {3249 /* Dashboard icon → badge on top rigt */3250 position: absolute;3251 top: 0;3252 right: 20px; }3253 3254 3241 .badge-block { 3255 /* Dashboard module → badge on top left */3242 /* Dashboard module → badge on top right */ 3256 3243 position: absolute; 3257 3244 top: -10px; 3258 3245 right: -10px; } 3259 3246 3260 .badge- block-icon {3261 /* Dashboard icon /module → badge on top rigt */3247 .badge-icon { 3248 /* Dashboard icon → badge on top right */ 3262 3249 right: 20px; } 3263 3250 -
admin/style/default.css
r3868 r3869 3211 3211 border: 1px solid #c9c9c9; } 3212 3212 3213 /* Badges */ 3214 /* 3215 Set .badgeable to badge parent's (not mandatory for menu items), then use: 3216 .badge (standard badge) 3217 which must be combined with : 3218 .badge-icon (dashboard icon) → top right, or 3219 .badge-block (dashboard module) → top left, or 3220 .badge-inline (menu item) → right centered 3221 and may be combined with : 3222 .badge-info → blue background 3223 and may be combined with (only in dashboard, not in menu) : 3224 .badge-block-icon (dashboard icon or module) → soft badge on top right 3225 */ 3213 /* Badges (common.js) */ 3226 3214 .badgeable { 3227 3215 /* class to set to badge parent's, not mandatory for menu items */ … … 3236 3224 padding: 0 .6em; } 3237 3225 3226 .badge-icon { 3227 background-color: #708090; } 3228 3229 /* Badge background override */ 3230 .badge-std { 3231 background-color: #d54e21; } 3232 3238 3233 .badge-info { 3239 3234 background-color: #3f51b5; } 3240 3235 3241 .badge-icon { 3242 border-radius: 5px; } 3243 3244 .badge-block-icon { 3236 .badge-soft { 3245 3237 background-color: #708090; } 3246 3238 3247 3239 /* Badge position */ 3248 .badge-icon {3249 /* Dashboard icon → badge on top rigt */3250 position: absolute;3251 top: 0;3252 right: 20px; }3253 3254 3240 .badge-block { 3255 /* Dashboard module → badge on top left */3241 /* Dashboard module → badge on top right */ 3256 3242 position: absolute; 3257 3243 top: -10px; 3258 3244 right: -10px; } 3259 3245 3260 .badge- block-icon {3261 /* Dashboard icon /module → badge on top rigt */3246 .badge-icon { 3247 /* Dashboard icon → badge on top right */ 3262 3248 right: 20px; } 3263 3249 -
admin/style/scss/partials/_utils.scss
r3868 r3869 22 22 } 23 23 24 /* Badges */ 25 /* 26 Set .badgeable to badge parent's (not mandatory for menu items), then use: 27 .badge (standard badge) 28 which must be combined with : 29 .badge-icon (dashboard icon) → top right, or 30 .badge-block (dashboard module) → top left, or 31 .badge-inline (menu item) → right centered 32 and may be combined with : 33 .badge-info → blue background 34 and may be combined with (only in dashboard, not in menu) : 35 .badge-block-icon (dashboard icon or module) → soft badge on top right 36 */ 24 /* Badges (common.js) */ 37 25 38 26 .badgeable { … … 49 37 padding: 0 .6em; 50 38 } 39 .badge-icon { 40 background-color: $badge-soft-background; 41 } 42 43 /* Badge background override */ 44 .badge-std { 45 background-color: $badge-std-background; 46 } 51 47 .badge-info { 52 background-color: $badge-info-background 48 background-color: $badge-info-background; 53 49 } 54 .badge-icon { 55 border-radius: 5px; 56 } 57 .badge-block-icon { 58 background-color: $badge-soft-background 50 .badge-soft { 51 background-color: $badge-soft-background; 59 52 } 60 53 61 54 /* Badge position */ 62 .badge-icon {63 /* Dashboard icon → badge on top rigt */64 position: absolute;65 top: 0;66 right: 20px;67 }68 55 .badge-block { 69 /* Dashboard module → badge on top left */56 /* Dashboard module → badge on top right */ 70 57 position: absolute; 71 58 top: -10px; 72 59 right: -10px; 73 60 } 74 .badge- block-icon {75 /* Dashboard icon /module → badge on top rigt */61 .badge-icon { 62 /* Dashboard icon → badge on top right */ 76 63 right: 20px; 77 64 }
Note: See TracChangeset
for help on using the changeset viewer.