[ Index ]

PHP Cross Reference of MyBB 1.8.38

title

Body

[close]

/jscripts/ -> inline_edit.js (source)

   1  var inlineEditor = {
   2      timeouts: [],
   3  
   4      init: function()
   5      {
   6          $(function()
   7          {
   8              inlineEditor.bindSubjects();
   9          });
  10      },
  11  
  12      bindSubjects: function()
  13      {
  14          $('.subject_editable').each(function()
  15          {
  16              // Take tid out of the id attribute
  17              id = $(this).attr('id');
  18              tid = id.replace( /[^\d.]/g, '');
  19  
  20              $(this).editable("xmlhttp.php?action=edit_subject&my_post_key=" + my_post_key + "&tid=" + tid,
  21              {
  22                  indicator: spinner,
  23                  type: "text",
  24                  submit: '',
  25                  cancel: '',
  26                  tooltip: lang.inline_edit_description,
  27                  onblur: "submit",
  28                  event: "hold"+tid,
  29                  callback: function(values, settings)
  30                  {
  31                      id = $(this).attr('id');
  32                      tid = id.replace( /[^\d.]/g, '');
  33  
  34                      values = JSON.parse(values);
  35                      if(typeof values == 'object')
  36                      {
  37                          if(values.hasOwnProperty("errors"))
  38                          {
  39                              $.each(values.errors, function(i, message)
  40                              {
  41                                  $.jGrowl(lang.post_fetch_error + ' ' + message, {theme:'jgrowl_error'});
  42                              });
  43                              $(this).html($('#tid_' + tid + '_temp').html());
  44                          }
  45                          else
  46                          {
  47                              // Change subject
  48                              $(this).html(values.subject);
  49                          }
  50                      }
  51                      
  52                      $('#tid_' + tid + '_temp').remove();
  53                  },
  54                  data: function(value, settings)
  55                  {
  56                      return $(value).text();
  57                  }
  58              });
  59  
  60              // Hold event
  61              $(this).on("mousedown", function(e)
  62              {
  63                  // Take tid out of the id attribute
  64                  id = $(this).attr('id');
  65                  tid = id.replace( /[^\d.]/g, '');
  66                  
  67                  // We may click again in the textbox and we'd be adding a new (invalid) clone - we don't want that!
  68                  if(!$('#tid_' + tid + '_temp').length)
  69                      $(this).clone().attr('id','tid_' + tid + '_temp').hide().appendTo("body");
  70  
  71                  inlineEditor.timeouts[tid] = setTimeout(inlineEditor.jeditableTimeout, 700, tid);
  72              });
  73  
  74              $(this).on('mouseup mouseleave', function()
  75              {
  76                  window.clearTimeout(inlineEditor.timeouts[tid]);
  77              });
  78          });
  79  
  80          return false;
  81      },
  82      
  83      jeditableTimeout : function(tid)
  84      {
  85          $('#tid_' + tid).trigger("hold" + tid);
  86          $('#tid_' + tid + ' input').width('98%');
  87      }
  88  };
  89  
  90  inlineEditor.init();


2005 - 2021 © MyBB.de | Alle Rechte vorbehalten! | Sponsor: netcup Cross-referenced by PHPXref