Dotclear


Ignore:
Timestamp:
08/22/18 11:57:07 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Avoid uninstanciable options for the expandContent utility

File:
1 edited

Legend:

Unmodified
Added
Removed
  • admin/js/common.js

    r3805 r3815  
    164164(function($) { 
    165165  $.expandContent = function(opts) { 
    166     var defaults = {}; 
    167     $.expandContent.options = $.extend({}, defaults, opts); 
    168166    if (opts == undefined || opts.callback == undefined || !$.isFunction(opts.callback)) { 
    169167      return; 
    170168    } 
    171169    if (opts.line != undefined) { 
    172       multipleExpander(opts.line, opts.lines); 
     170      multipleExpander(opts.line, opts.lines, opts.callback); 
    173171    } 
    174172    opts.lines.each(function() { 
    175       singleExpander(this); 
    176     }); 
    177   }; 
    178   var singleExpander = function singleExpander(line) { 
     173      singleExpander(this, opts.callback); 
     174    }); 
     175  }; 
     176  var singleExpander = function singleExpander(line, callback) { 
    179177    $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
    180178      toggleArrow(this); 
    181       $.expandContent.options.callback.call(this, line); 
     179      callback(line); 
    182180      e.preventDefault(); 
    183181    }).prependTo($(line).children().get(0)); // first td 
    184182  }; 
    185   var multipleExpander = function multipleExpander(line, lines) { 
     183  var multipleExpander = function multipleExpander(line, lines, callback) { 
    186184    $('<input class="details-cmd" type="submit" value="' + dotclear.img_plus_txt + '" aria-label="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
    187       var that = this; 
    188185      var action = toggleArrow(this); 
    189186      lines.each(function() { 
    190187        toggleArrow(this.firstChild.firstChild, action); 
    191         $.expandContent.options.callback.call(that, this, action); 
     188        callback(this, action); 
    192189      }); 
    193190      e.preventDefault(); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map