Dotclear

Changeset 3706:170617361020 for admin/js


Ignore:
Timestamp:
02/16/18 16:01:59 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

use strict and no more linter warnings/errors as far as possible

Location:
admin/js
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_blog_pref.js

    r3524 r3706  
     1/*global $, dotclear, jsToolBar */ 
     2'use strict'; 
    13function checkQueryString() { 
    24     var blogUrl = $('#blog_url')[0].value; 
    35     var urlScan = $('#url_scan')[0].value; 
    4      errorMsg = ''; 
     6     var errorMsg = ''; 
    57     if (/.*[^\/]$/.exec(blogUrl) && urlScan=='path_info') { 
    68          errorMsg = dotclear.msg.warning_path_info; 
     
    810          errorMsg = dotclear.msg.warning_query_string; 
    911     } 
    10      $("p#urlwarning").remove(); 
     12     $('p#urlwarning').remove(); 
    1113     if (errorMsg != '') { 
    12           $("#blog_url").parents('p').after('<p id="urlwarning" class="warning">'+errorMsg+'</p>'); 
     14          $('#blog_url').parents('p').after('<p id="urlwarning" class="warning">'+errorMsg+'</p>'); 
    1315     } 
    1416} 
  • admin/js/_blog_theme.js

    r2566 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      // expend theme info 
    3      $('.module-sshot').not('.current-theme .module-sshot').each(function(){ 
    4           var bar = $('<div>').addClass('bloc-toggler'); 
    5           $(this).after( 
    6           $(bar).toggleWithLegend($(this).parent().children('.toggle-bloc'),{ 
    7                img_on_src: dotclear.img_plus_theme_src, 
    8                img_on_alt: dotclear.img_plus_theme_alt, 
    9                img_off_src: dotclear.img_minus_theme_src, 
    10                img_off_alt: dotclear.img_minus_theme_alt, 
    11                legend_click: true 
    12           })); 
    13           $(this).children('img').click(function(){ 
    14                $(this).parent().parent().children('.bloc-toggler').click(); 
    15           }); 
    16      }); 
     5  // expend theme info 
     6  $('.module-sshot').not('.current-theme .module-sshot').each(function() { 
     7    var bar = $('<div>').addClass('bloc-toggler'); 
     8    $(this).after( 
     9      $(bar).toggleWithLegend($(this).parent().children('.toggle-bloc'), { 
     10        img_on_src: dotclear.img_plus_theme_src, 
     11        img_on_alt: dotclear.img_plus_theme_alt, 
     12        img_off_src: dotclear.img_minus_theme_src, 
     13        img_off_alt: dotclear.img_minus_theme_alt, 
     14        legend_click: true 
     15      })); 
     16    $(this).children('img').click(function() { 
     17      $(this).parent().parent().children('.bloc-toggler').click(); 
     18    }); 
     19  }); 
    1720 
    18      // dirty short search blocker 
    19      $('div.modules-search form input[type=submit]').click(function(){ 
    20           var mlen = $('input[name=m_search]',$(this).parent()).val(); 
    21           if (mlen.length > 2){return true;}else{return false;} 
    22      }); 
     21  // dirty short search blocker 
     22  $('div.modules-search form input[type=submit]').click(function() { 
     23    var mlen = $('input[name=m_search]', $(this).parent()).val(); 
     24    if (mlen.length > 2) { 
     25      return true; 
     26    } else { 
     27      return false; 
     28    } 
     29  }); 
    2330 
    24      // checkboxes selection 
    25      $('.checkboxes-helpers').each(function() { 
    26           dotclear.checkboxesHelpers(this); 
    27      }); 
     31  // checkboxes selection 
     32  $('.checkboxes-helpers').each(function() { 
     33    dotclear.checkboxesHelpers(this); 
     34  }); 
    2835 
    29      // actions tests 
    30      $('.modules-form-actions').each(function(){ 
    31           var rxActionType = /^[^\[]+/; 
    32           var rxActionValue = /([^\[]+)\]$/; 
    33           var checkboxes = $(this).find('input[type=checkbox]'); 
     36  // actions tests 
     37  $('.modules-form-actions').each(function() { 
     38    var rxActionType = /^[^\[]+/; 
     39    var rxActionValue = /([^\[]+)\]$/; 
     40    var checkboxes = $(this).find('input[type=checkbox]'); 
    3441 
    35           // check if submit is a global action or one line action 
    36           $("input[type=submit]",this).click(function() { 
    37                var keyword = $(this).attr('name'); 
    38                var maction = keyword.match(rxActionType); 
    39                var action = maction[0]; 
    40                var mvalues = keyword.match(rxActionValue); 
     42    // check if submit is a global action or one line action 
     43    $('input[type=submit]', this).click(function() { 
     44      var keyword = $(this).attr('name'); 
     45      var maction = keyword.match(rxActionType); 
     46      var action = maction[0]; 
     47      var mvalues = keyword.match(rxActionValue); 
    4148 
    42                // action on multiple modules 
    43                if (!mvalues) { 
    44                     var checked = false; 
     49      // action on multiple modules 
     50      if (!mvalues) { 
     51        var checked = false; 
    4552 
    46                     // check if there is checkboxes in form 
    47                     if(checkboxes.length > 0) { 
    48                          // check if there is at least one checkbox checked 
    49                          $(checkboxes).each(function() { 
    50                               if (this.checked) { 
    51                                    checked = true; 
    52                               } 
    53                          }); 
    54                          if (!checked) { 
    55                               //alert(dotclear.msg.no_selection); 
    56                               return false; 
    57                          } 
    58                     } 
     53        // check if there is checkboxes in form 
     54        if (checkboxes.length > 0) { 
     55          // check if there is at least one checkbox checked 
     56          $(checkboxes).each(function() { 
     57            if (this.checked) { 
     58              checked = true; 
     59            } 
     60          }); 
     61          if (!checked) { 
     62            //alert(dotclear.msg.no_selection); 
     63            return false; 
     64          } 
     65        } 
    5966 
    60                     // confirm delete 
    61                     if (action == 'delete') { 
    62                          return window.confirm(dotclear.msg.confirm_delete_themes); 
    63                     } 
     67        // confirm delete 
     68        if (action == 'delete') { 
     69          return window.confirm(dotclear.msg.confirm_delete_themes); 
     70        } 
    6471 
    65                // action on one module 
    66                }else { 
    67                     var module = mvalues[1]; 
     72        // action on one module 
     73      } else { 
     74        var module = mvalues[1]; 
    6875 
    69                     // confirm delete 
    70                     if (action == 'delete') { 
    71                          return window.confirm(dotclear.msg.confirm_delete_theme.replace('%s',module)); 
    72                     } 
    73                } 
     76        // confirm delete 
     77        if (action == 'delete') { 
     78          return window.confirm(dotclear.msg.confirm_delete_theme.replace('%s', module)); 
     79        } 
     80      } 
    7481 
    75                return true; 
    76           }); 
    77      }); 
     82      return true; 
     83    }); 
     84  }); 
    7885}); 
  • admin/js/_blogs.js

    r3403 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('.checkboxes-helpers').each(function() { 
    3           dotclear.checkboxesHelpers(this,undefined,'#form-blogs td input[type=checkbox]','#form-blogs #do-action'); 
    4      }); 
    5      $('#form-blogs td input[type=checkbox]').enableShiftClick(); 
    6      dotclear.condSubmit('#form-blogs td input[type=checkbox]','#form-blogs #do-action'); 
    7      $('#form-blogs').submit(function() { 
    8           var action = $(this).find('select[name="action"]').val(); 
    9           if (action == 'delete') { 
    10                return window.confirm(dotclear.msg.confirm_delete_blog.replace('%s',$('input[name="blogs[]"]:checked').size())); 
    11           } 
    12      }); 
     5  $('.checkboxes-helpers').each(function() { 
     6    dotclear.checkboxesHelpers(this, undefined, '#form-blogs td input[type=checkbox]', '#form-blogs #do-action'); 
     7  }); 
     8  $('#form-blogs td input[type=checkbox]').enableShiftClick(); 
     9  dotclear.condSubmit('#form-blogs td input[type=checkbox]', '#form-blogs #do-action'); 
     10  $('#form-blogs').submit(function() { 
     11    var action = $(this).find('select[name="action"]').val(); 
     12    if (action == 'delete') { 
     13      return window.confirm(dotclear.msg.confirm_delete_blog.replace('%s', $('input[name="blogs[]"]:checked').size())); 
     14    } 
     15  }); 
    1316}); 
  • admin/js/_blogs_actions.js

    r3403 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      dotclear.condSubmit('table.blogs-list td input[type=checkbox]','input[type=submit]'); 
     5  dotclear.condSubmit('table.blogs-list td input[type=checkbox]', 'input[type=submit]'); 
    36}); 
  • admin/js/_categories.js

    r2190 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      if ($.fn['nestedSortable']!==undefined) { 
    3           $('#categories ul li').css('cursor','move'); 
    4           $('#save-set-order').prop('disabled',true).addClass('disabled'); 
    5           $('#categories ul').nestedSortable({ 
    6                listType: 'ul', 
    7                items: 'li', 
    8                placeholder: 'placeholder', 
    9                update: function() { 
    10                     $('#categories_order').attr('value',JSON.stringify($('#categories ul').nestedSortable('toArray'))); 
    11                     $('#save-set-order').prop('disabled',false).removeClass('disabled'); 
    12                } 
    13           }); 
    14      } 
     5  if ($.fn.nestedSortable !== undefined) { 
     6    $('#categories ul li').css('cursor', 'move'); 
     7    $('#save-set-order').prop('disabled', true).addClass('disabled'); 
     8    $('#categories ul').nestedSortable({ 
     9      listType: 'ul', 
     10      items: 'li', 
     11      placeholder: 'placeholder', 
     12      update: function() { 
     13        $('#categories_order').attr('value', JSON.stringify($('#categories ul').nestedSortable('toArray'))); 
     14        $('#save-set-order').prop('disabled', false).removeClass('disabled'); 
     15      } 
     16    }); 
     17  } 
    1518 
    16      $('input[name^="delete"]').click(function() { 
    17           return window.confirm(dotclear.msg.confirm_delete_category.replace('%s',$(this).parents('li').first().find('.cat-title label a').text())); 
    18      }); 
     19  $('input[name^="delete"]').click(function() { 
     20    return window.confirm(dotclear.msg.confirm_delete_category.replace('%s', $(this).parents('li').first().find('.cat-title label a').text())); 
     21  }); 
    1922 
    20      $('input[name="reset"]').click(function() { 
    21           return window.confirm(dotclear.msg.confirm_reorder_categories); 
    22      }); 
     23  $('input[name="reset"]').click(function() { 
     24    return window.confirm(dotclear.msg.confirm_reorder_categories); 
     25  }); 
    2326}); 
  • admin/js/_category.js

    r2891 r3706  
     1/*global $, dotclear, jsToolBar */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      dotclear.hideLockable(); 
     5  dotclear.hideLockable(); 
    36 
    4      if ($.isFunction(jsToolBar)) { 
    5           var tbCategory = new jsToolBar(document.getElementById('cat_desc')); 
    6           tbCategory.draw('xhtml'); 
    7      } 
     7  if ($.isFunction(jsToolBar)) { 
     8    var tbCategory = new jsToolBar(document.getElementById('cat_desc')); 
     9    tbCategory.draw('xhtml'); 
     10  } 
    811}); 
  • admin/js/_comment.js

    r2860 r3706  
     1/*global $, dotclear, jsToolBar */ 
     2'use strict'; 
     3 
    14$(function() { 
    25     if ($.isFunction(jsToolBar)) { 
  • admin/js/_comments.js

    r3182 r3706  
    1 dotclear.viewCommentContent = function(line,action) { 
    2      var action = action || 'toggle'; 
    3      var commentId = $(line).attr('id').substr(1); 
    4      var tr = document.getElementById('ce'+commentId); 
     1/*global $, dotclear */ 
     2'use strict'; 
    53 
    6      if ( !tr && ( action == 'toggle' || action == 'open' ) ) { 
    7           tr = document.createElement('tr'); 
    8           tr.id = 'ce'+commentId; 
    9           var td = document.createElement('td'); 
    10           td.colSpan = 6; 
    11           td.className = 'expand'; 
    12           tr.appendChild(td); 
     4dotclear.viewCommentContent = function(line, action) { 
     5  action = action || 'toggle'; 
     6  var commentId = $(line).attr('id').substr(1); 
     7  var tr = document.getElementById('ce' + commentId); 
    138 
    14           // Get comment content 
    15           $.get('services.php',{f:'getCommentById',id: commentId},function(data) { 
    16                var rsp = $(data).children('rsp')[0]; 
     9  if (!tr && (action == 'toggle' || action == 'open')) { 
     10    tr = document.createElement('tr'); 
     11    tr.id = 'ce' + commentId; 
     12    var td = document.createElement('td'); 
     13    td.colSpan = 6; 
     14    td.className = 'expand'; 
     15    tr.appendChild(td); 
    1716 
    18                if (rsp.attributes[0].value == 'ok') { 
    19                     var comment = $(rsp).find('comment_display_content').text(); 
     17    // Get comment content 
     18    $.get('services.php', { 
     19      f: 'getCommentById', 
     20      id: commentId 
     21    }, function(data) { 
     22      var rsp = $(data).children('rsp')[0]; 
    2023 
    21                     if (comment) { 
    22                          $(td).append(comment); 
    23                          var comment_email = $(rsp).find('comment_email').text(); 
    24                          var comment_site = $(rsp).find('comment_site').text(); 
    25                          var comment_ip = $(rsp).find('comment_ip').text(); 
    26                          var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
     24      if (rsp.attributes[0].value == 'ok') { 
     25        var comment = $(rsp).find('comment_display_content').text(); 
    2726 
    28                          $(td).append('<p><strong>' + dotclear.msg.website + 
    29                          '</strong> ' + comment_site + '<br />' + 
    30                          '<strong>' + dotclear.msg.email + '</strong> ' + comment_email + '<br />' + 
    31                          '<strong>' + dotclear.msg.ip_address + 
    32                          '</strong> <a href="comments.php?ip=' + comment_ip + '">' + comment_ip + '</a>' + 
    33                          '<br />' + comment_spam_disp + '</p>'); 
    34                     } 
    35                } else { 
    36                     alert($(rsp).find('message').text()); 
    37                } 
    38           }); 
     27        if (comment) { 
     28          $(td).append(comment); 
     29          var comment_email = $(rsp).find('comment_email').text(); 
     30          var comment_site = $(rsp).find('comment_site').text(); 
     31          var comment_ip = $(rsp).find('comment_ip').text(); 
     32          var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    3933 
    40           $(line).toggleClass('expand'); 
    41           line.parentNode.insertBefore(tr,line.nextSibling); 
    42      } 
    43      else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) 
    44      { 
    45           $(tr).css('display', 'table-row'); 
    46           $(line).addClass('expand'); 
    47      } 
    48      else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) 
    49      { 
    50           $(tr).css('display', 'none'); 
    51           $(line).removeClass('expand'); 
    52      } 
     34          $(td).append('<p><strong>' + dotclear.msg.website + 
     35            '</strong> ' + comment_site + '<br />' + 
     36            '<strong>' + dotclear.msg.email + '</strong> ' + comment_email + '<br />' + 
     37            '<strong>' + dotclear.msg.ip_address + 
     38            '</strong> <a href="comments.php?ip=' + comment_ip + '">' + comment_ip + '</a>' + 
     39            '<br />' + comment_spam_disp + '</p>'); 
     40        } 
     41      } else { 
     42        window.alert($(rsp).find('message').text()); 
     43      } 
     44    }); 
     45 
     46    $(line).toggleClass('expand'); 
     47    line.parentNode.insertBefore(tr, line.nextSibling); 
     48  } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { 
     49    $(tr).css('display', 'table-row'); 
     50    $(line).addClass('expand'); 
     51  } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { 
     52    $(tr).css('display', 'none'); 
     53    $(line).removeClass('expand'); 
     54  } 
    5355}; 
    5456 
    5557$(function() { 
    56      $.expandContent({ 
    57           line:$('#form-comments tr:not(.line)'), 
    58           lines:$('#form-comments tr.line'), 
    59           callback:dotclear.viewCommentContent 
    60      }); 
    61      $('.checkboxes-helpers').each(function() { 
    62           dotclear.checkboxesHelpers(this,undefined,'#form-comments td input[type=checkbox]','#form-comments #do-action'); 
    63      }); 
    64      $('#form-comments td input[type=checkbox]').enableShiftClick(); 
    65      dotclear.commentsActionsHelper(); 
    66      dotclear.condSubmit('#form-comments td input[type=checkbox]','#form-comments #do-action'); 
    67      $('form input[type=submit][name=delete_all_spam]').click(function(){ 
    68           return window.confirm(dotclear.msg.confirm_spam_delete); 
    69      }); 
     58  $.expandContent({ 
     59    line: $('#form-comments tr:not(.line)'), 
     60    lines: $('#form-comments tr.line'), 
     61    callback: dotclear.viewCommentContent 
     62  }); 
     63  $('.checkboxes-helpers').each(function() { 
     64    dotclear.checkboxesHelpers(this, undefined, '#form-comments td input[type=checkbox]', '#form-comments #do-action'); 
     65  }); 
     66  $('#form-comments td input[type=checkbox]').enableShiftClick(); 
     67  dotclear.commentsActionsHelper(); 
     68  dotclear.condSubmit('#form-comments td input[type=checkbox]', '#form-comments #do-action'); 
     69  $('form input[type=submit][name=delete_all_spam]').click(function() { 
     70    return window.confirm(dotclear.msg.confirm_spam_delete); 
     71  }); 
    7072}); 
  • admin/js/_comments_actions.js

    r3184 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    25     dotclear.condSubmit('table.posts-list td input[type=checkbox]','input[type=submit]'); 
  • admin/js/_index.js

    r3614 r3706  
     1/*global $, dotclear, jsToolBar */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      var f = $('#quick-entry'); 
    3      if (f.length > 0) { 
    4           if ($.isFunction(jsToolBar)) { 
    5                var contentTb = new jsToolBar($('#post_content',f)[0]); 
    6                contentTb.switchMode($('#post_format',f).val()); 
    7           } 
     5  function quickPost(f, status) { 
     6    if ($.isFunction('jsToolBar') && (contentTb.getMode() == 'wysiwyg')) { 
     7      contentTb.syncContents('iframe'); 
     8    } 
    89 
    9           $('input[name=save]',f).click(function() { 
    10                quickPost(f,-2); 
    11                return false; 
    12           }); 
     10    var params = { 
     11      f: 'quickPost', 
     12      xd_check: dotclear.nonce, 
     13      post_title: $('#post_title', f).val(), 
     14      post_content: $('#post_content', f).val(), 
     15      cat_id: $('#cat_id', f).val(), 
     16      post_status: status, 
     17      post_format: $('#post_format', f).val(), 
     18      post_lang: $('#post_lang', f).val(), 
     19      new_cat_title: $('#new_cat_title', f).val(), 
     20      new_cat_parent: $('#new_cat_parent', f).val() 
     21    }; 
    1322 
    14           if ($('input[name=save-publish]',f).length > 0) { 
    15                var btn = $('<input type="submit" value="' + $('input[name=save-publish]',f).val() + '" />'); 
    16                $('input[name=save-publish]',f).remove(); 
    17                $('input[name=save]',f).after(btn).after(' '); 
    18                btn.click(function() { 
    19                     quickPost(f,1); 
    20                     return false; 
    21                }); 
    22           } 
     23    $('p.qinfo', f).remove(); 
    2324 
    24           function quickPost(f,status) { 
    25                if ($.isFunction('jsToolBar') && (contentTb.getMode() == 'wysiwyg')) { 
    26                     contentTb.syncContents('iframe'); 
    27                } 
     25    $.post('services.php', params, function(data) { 
     26      var msg; 
     27      if ($('rsp[status=failed]', data).length > 0) { 
     28        msg = '<p class="qinfo"><strong>' + dotclear.msg.error + 
     29          '</strong> ' + $('rsp', data).text() + '</p>'; 
     30      } else { 
     31        msg = '<p class="qinfo">' + dotclear.msg.entry_created + 
     32          ' - <a href="post.php?id=' + $('rsp>post', data).attr('id') + '">' + 
     33          dotclear.msg.edit_entry + '</a>'; 
     34        if ($('rsp>post', data).attr('post_status') == 1) { 
     35          msg += ' - <a href="' + $('rsp>post', data).attr('post_url') + '">' + 
     36            dotclear.msg.view_entry + '</a>'; 
     37        } 
     38        msg += '</p>'; 
     39        $('#post_title', f).val(''); 
     40        $('#post_content', f).val(''); 
     41        $('#post_content', f).change(); 
     42        if ($.isFunction('jsToolBar') && (contentTb.getMode() == 'wysiwyg')) { 
     43          contentTb.syncContents('textarea'); 
     44        } 
     45        $('#cat_id', f).val('0'); 
     46        $('#new_cat_title', f).val(''); 
     47        $('#new_cat_parent', f).val('0'); 
     48      } 
    2849 
    29                var params = { 
    30                     f: 'quickPost', 
    31                     xd_check: dotclear.nonce, 
    32                     post_title: $('#post_title',f).val(), 
    33                     post_content: $('#post_content',f).val(), 
    34                     cat_id: $('#cat_id',f).val(), 
    35                     post_status: status, 
    36                     post_format: $('#post_format',f).val(), 
    37                     post_lang: $('#post_lang',f).val(), 
    38                     new_cat_title: $('#new_cat_title',f).val(), 
    39                     new_cat_parent: $('#new_cat_parent',f).val() 
    40                } 
     50      $('fieldset', f).prepend(msg); 
     51    }); 
     52  } 
    4153 
    42                $('p.qinfo',f).remove(); 
     54  var f = $('#quick-entry'); 
     55  if (f.length > 0) { 
     56    if ($.isFunction(jsToolBar)) { 
     57      var contentTb = new jsToolBar($('#post_content', f)[0]); 
     58      contentTb.switchMode($('#post_format', f).val()); 
     59    } 
    4360 
    44                $.post('services.php',params,function(data) { 
    45                     if ($('rsp[status=failed]',data).length > 0) { 
    46                          var msg = '<p class="qinfo"><strong>' + dotclear.msg.error + 
    47                          '</strong> ' + $('rsp',data).text() + '</p>'; 
    48                     } else { 
    49                          var msg = '<p class="qinfo">' + dotclear.msg.entry_created + 
    50                          ' - <a href="post.php?id=' + $('rsp>post',data).attr('id') + '">' + 
    51                          dotclear.msg.edit_entry + '</a>'; 
    52                          if ($('rsp>post',data).attr('post_status') == 1) { 
    53                               msg += ' - <a href="' + $('rsp>post',data).attr('post_url') + '">' + 
    54                               dotclear.msg.view_entry + '</a>'; 
    55                          } 
    56                          msg += '</p>'; 
    57                          $('#post_title',f).val(''); 
    58                          $('#post_content',f).val(''); 
    59                          $('#post_content',f).change(); 
    60                          if ($.isFunction('jsToolBar') &&  (contentTb.getMode() == 'wysiwyg')) { 
    61                               contentTb.syncContents('textarea'); 
    62                          } 
    63                          $('#cat_id',f).val('0'); 
    64                          $('#new_cat_title',f).val(''); 
    65                          $('#new_cat_parent',f).val('0'); 
    66                     } 
     61    $('input[name=save]', f).click(function() { 
     62      quickPost(f, -2); 
     63      return false; 
     64    }); 
    6765 
    68                     $('fieldset',f).prepend(msg); 
    69                }); 
    70           } 
    71           $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), { 
    72                // no cookie on new category as we don't use this every day 
    73                legend_click: true 
    74           }); 
    75      } 
     66    if ($('input[name=save-publish]', f).length > 0) { 
     67      var btn = $('<input type="submit" value="' + $('input[name=save-publish]', f).val() + '" />'); 
     68      $('input[name=save-publish]', f).remove(); 
     69      $('input[name=save]', f).after(btn).after(' '); 
     70      btn.click(function() { 
     71        quickPost(f, 1); 
     72        return false; 
     73      }); 
     74    } 
    7675 
    77      // allow to hide quick entry div, and remember choice 
    78      $('#quick h3').toggleWithLegend($('#quick').children().not('h3'),{ 
    79           legend_click: true, 
    80           user_pref: 'dcx_quick_entry' 
    81      }); 
     76    $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), { 
     77      // no cookie on new category as we don't use this every day 
     78      legend_click: true 
     79    }); 
     80  } 
    8281 
    83      // check if core update available 
    84      var params = { 
    85           f: 'checkCoreUpdate', 
    86           xd_check: dotclear.nonce 
    87      }; 
    88      $.post('services.php',params,function(data) { 
    89           if ($('rsp[status=failed]',data).length > 0) { 
    90                // Silently fail as a forced checked my be done with admin update page 
    91           } else { 
    92                if ($('rsp>update',data).attr('check') == 1) { 
    93                     // Something has to be displayed 
    94                     xml = $('rsp>update',data).attr('ret'); 
    95                     $('#content h2').after(xml); 
    96                } 
    97           } 
    98      }); 
     82  // allow to hide quick entry div, and remember choice 
     83  $('#quick h3').toggleWithLegend($('#quick').children().not('h3'), { 
     84    legend_click: true, 
     85    user_pref: 'dcx_quick_entry' 
     86  }); 
    9987 
    100      // check if some news are available 
    101      var params = { 
    102           f: 'checkNewsUpdate', 
    103           xd_check: dotclear.nonce 
    104      }; 
    105      $.post('services.php',params,function(data) { 
    106           if ($('rsp[status=failed]',data).length > 0) { 
    107                // Silently fail 
    108           } else { 
    109                if ($('rsp>news',data).attr('check') == 1) { 
    110                     // Something has to be displayed 
    111                     xml = $('rsp>news',data).attr('ret'); 
    112                     if ($('#dashboard-boxes').length == 0) { 
    113                          // Create the #dashboard-boxes container 
    114                          $('#dashboard-main').append('<div id="dashboard-boxes"></div>'); 
    115                     } 
    116                     if ($('#dashboard-boxes div.db-items').length == 0) { 
    117                          // Create the #dashboard-boxes div.db-items container 
    118                          $('#dashboard-boxes').prepend('<div class="db-items"></div>'); 
    119                     } 
    120                     $('#dashboard-boxes div.db-items').prepend(xml); 
    121                } 
    122           } 
    123      }); 
     88  // check if core update available 
     89  var params = { 
     90    f: 'checkCoreUpdate', 
     91    xd_check: dotclear.nonce 
     92  }; 
     93  $.post('services.php', params, function(data) { 
     94    if ($('rsp[status=failed]', data).length > 0) { 
     95      // Silently fail as a forced checked my be done with admin update page 
     96    } else { 
     97      if ($('rsp>update', data).attr('check') == 1) { 
     98        // Something has to be displayed 
     99        var xml = $('rsp>update', data).attr('ret'); 
     100        $('#content h2').after(xml); 
     101      } 
     102    } 
     103  }); 
     104 
     105  // check if some news are available 
     106  params = { 
     107    f: 'checkNewsUpdate', 
     108    xd_check: dotclear.nonce 
     109  }; 
     110  $.post('services.php', params, function(data) { 
     111    if ($('rsp[status=failed]', data).length > 0) { 
     112      // Silently fail 
     113    } else { 
     114      if ($('rsp>news', data).attr('check') == 1) { 
     115        // Something has to be displayed 
     116        var xml = $('rsp>news', data).attr('ret'); 
     117        if ($('#dashboard-boxes').length == 0) { 
     118          // Create the #dashboard-boxes container 
     119          $('#dashboard-main').append('<div id="dashboard-boxes"></div>'); 
     120        } 
     121        if ($('#dashboard-boxes div.db-items').length == 0) { 
     122          // Create the #dashboard-boxes div.db-items container 
     123          $('#dashboard-boxes').prepend('<div class="db-items"></div>'); 
     124        } 
     125        $('#dashboard-boxes div.db-items').prepend(xml); 
     126      } 
     127    } 
     128  }); 
    124129}); 
  • admin/js/_langs.js

    r2566 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    25     $('table.plugins form input[type=submit][name=delete]').click(function() { 
  • admin/js/_media.js

    r3445 r3706  
     1/*global $, jQuery, dotclear, template_upload, template_download */ 
     2'use strict'; 
     3 
    14(function($) { 
    2      $.fn.enhancedUploader = function() { 
    3           return this.each(function() { 
    4                var me = $(this); 
    5                var $container = $(me).parent(); 
    6  
    7                function enableButton(button) { 
    8                     button.prop('disabled',false).removeClass('disabled'); 
    9                } 
    10  
    11                function disableButton(button) { 
    12                     button.prop('disabled',true).addClass('disabled'); 
    13                } 
    14  
    15                function displayMessageInQueue(n) { 
    16                     var msg = ''; 
    17                     if (n==1) { 
    18                          msg = dotclear.jsUpload.msg.file_in_queue; 
    19                     } else if (n>1) { 
    20                          msg = dotclear.jsUpload.msg.files_in_queue; 
    21                          msg = msg.replace(/%d/,n); 
    22                     } else { 
    23                          msg = dotclear.jsUpload.msg.no_file_in_queue; 
    24                     } 
    25                     $('.queue-message',me).html(msg); 
    26                } 
    27  
    28                $('.button.choose_files').click(function(e) { 
    29                     if ($container.hasClass('enhanced_uploader')) { 
    30                          // Use the native click() of the file input. 
    31                          $('#upfile').click(); 
    32                          e.preventDefault(); 
    33                     } 
    34                }); 
    35  
    36                $('.button.cancel', '#fileupload .fileupload-buttonbar').click(function(e) { 
    37                     $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
    38                     disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    39                     displayMessageInQueue(0); 
    40                }); 
    41  
    42                $(me).on('click','.cancel',function(e) { 
    43                     if ($('.fileupload-ctrl .files .template-upload', me).length==0) { 
    44                          $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
    45                          disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    46                     } 
    47                     displayMessageInQueue($('.files .template-upload',me).length); 
    48                }); 
    49  
    50                $('.button.clean', me).click(function(e) { 
    51                     $('.fileupload-ctrl .files .template-download', me).slideUp(500, function() { 
    52                          $(this).remove(); 
    53                     }); 
    54                     $(this).hide(); 
    55                     e.preventDefault(); 
    56                }); 
    57  
    58                $(me).fileupload({ 
    59                     url: $(me).attr('action'), 
    60                     autoUpload: false, 
    61                     sequentialUploads: true, 
    62                     uploadTemplateId: null, 
    63                     downloadTemplateId: null, 
    64                     uploadTemplate: template_upload, 
    65                     downloadTemplate: template_download 
    66                }).bind('fileuploadadd', function(e, data) { 
    67                     $('.button.cancel').css('display','inline-block'); 
    68                     $('#fileupload .fileupload-buttonbar').show(); 
    69                     enableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    70                }).bind('fileuploadadded', function(e, data) { 
    71                     displayMessageInQueue($('.files .template-upload',me).length); 
    72                }).bind('fileuploaddone', function(e, data) { 
    73                     if (data.result.files[0].html !==undefined) { 
    74                          $('.media-list .files-group').append(data.result.files[0].html); 
    75                          $('#form-medias .hide').removeClass('hide'); 
    76                     } 
    77                     $('.button.clean').css('display','inline-block'); 
    78                     $(me).show(); 
    79                }).bind('fileuploadalways', function(e, data) { 
    80                     displayMessageInQueue($('.files .template-upload',me).length); 
    81                     if ($('.fileupload-ctrl .files .template-upload',me).length==0) { 
    82                          $('.button.cancel','#fileupload .fileupload-buttonbar').hide(); 
    83                          disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    84                     } 
    85                }); 
    86  
    87                var $msg,label; 
    88  
    89                if ($container.hasClass('enhanced_uploader')) { 
    90                     $msg = dotclear.msg.enhanced_uploader_disable; 
    91                     label = dotclear.jsUpload.msg.choose_files; 
    92                     $(me).fileupload({disabled:false}); 
    93                     displayMessageInQueue(0); 
    94                     disableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    95                } else { 
    96                     $msg = dotclear.msg.enhanced_uploader_activate; 
    97                     label = dotclear.jsUpload.msg.choose_file; 
    98                } 
    99  
    100                $('<p class="clear"><button type="button" class="enhanced-toggle">' + $msg + '</button></p>').click(function(e) { 
    101                     if ($container.hasClass('enhanced_uploader')) { 
    102                          $msg = dotclear.msg.enhanced_uploader_activate; 
    103                          label = dotclear.jsUpload.msg.choose_file; 
    104                          $('#upfile').attr('multiple', false); 
    105                          enableButton($('.button.start','#fileupload .fileupload-buttonbar')); 
    106  
    107                          // when a user has clicked enhanced_uploader, and has added files 
    108                          // We must remove files in table 
    109                          $('.files .upload-file', me).remove(); 
    110                          $('.button.cancel,.button.clean','#fileupload .fileupload-buttonbar').hide(); 
    111                          $(me).fileupload({disabled:true}); 
    112                          $('.queue-message',me).html('').hide(); 
    113                     } else { 
    114                          $msg = dotclear.msg.enhanced_uploader_disable; 
    115                          label = dotclear.jsUpload.msg.choose_files; 
    116                          $('#upfile').attr('multiple', true); 
    117                          var startButton = $('.button.start'); 
    118                          var buttonBar = $('#fileupload .fileupload-buttonbar'); 
    119                          disableButton(startButton); 
    120                          disableButton(buttonBar); 
    121                          startButton.css('display','inline-block'); 
    122                          buttonBar.show(); 
    123                          $(me).fileupload({disabled:false}); 
    124                          $('.queue-message',me).show(); 
    125                          displayMessageInQueue(0); 
    126                     } 
    127                     $(this).find('button').text($msg); 
    128                     $('.add-label', me).text(label); 
    129  
    130                     $container.toggleClass('enhanced_uploader'); 
    131                     e.preventDefault(); 
    132                }).appendTo(me); 
    133           }); 
    134      }; 
     5  $.fn.enhancedUploader = function() { 
     6    return this.each(function() { 
     7      var me = $(this); 
     8      var $container = $(me).parent(); 
     9 
     10      function enableButton(button) { 
     11        button.prop('disabled', false).removeClass('disabled'); 
     12      } 
     13 
     14      function disableButton(button) { 
     15        button.prop('disabled', true).addClass('disabled'); 
     16      } 
     17 
     18      function displayMessageInQueue(n) { 
     19        var msg = ''; 
     20        if (n == 1) { 
     21          msg = dotclear.jsUpload.msg.file_in_queue; 
     22        } else if (n > 1) { 
     23          msg = dotclear.jsUpload.msg.files_in_queue; 
     24          msg = msg.replace(/%d/, n); 
     25        } else { 
     26          msg = dotclear.jsUpload.msg.no_file_in_queue; 
     27        } 
     28        $('.queue-message', me).html(msg); 
     29      } 
     30 
     31      $('.button.choose_files').click(function(e) { 
     32        if ($container.hasClass('enhanced_uploader')) { 
     33          // Use the native click() of the file input. 
     34          $('#upfile').click(); 
     35          e.preventDefault(); 
     36        } 
     37      }); 
     38 
     39      $('.button.cancel', '#fileupload .fileupload-buttonbar').click(function() { 
     40        $('.button.cancel', '#fileupload .fileupload-buttonbar').hide(); 
     41        disableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     42        displayMessageInQueue(0); 
     43      }); 
     44 
     45      $(me).on('click', '.cancel', function() { 
     46        if ($('.fileupload-ctrl .files .template-upload', me).length == 0) { 
     47          $('.button.cancel', '#fileupload .fileupload-buttonbar').hide(); 
     48          disableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     49        } 
     50        displayMessageInQueue($('.files .template-upload', me).length); 
     51      }); 
     52 
     53      $('.button.clean', me).click(function(e) { 
     54        $('.fileupload-ctrl .files .template-download', me).slideUp(500, function() { 
     55          $(this).remove(); 
     56        }); 
     57        $(this).hide(); 
     58        e.preventDefault(); 
     59      }); 
     60 
     61      $(me).fileupload({ 
     62        url: $(me).attr('action'), 
     63        autoUpload: false, 
     64        sequentialUploads: true, 
     65        uploadTemplateId: null, 
     66        downloadTemplateId: null, 
     67        uploadTemplate: template_upload, 
     68        downloadTemplate: template_download 
     69      }).bind('fileuploadadd', function() { 
     70        $('.button.cancel').css('display', 'inline-block'); 
     71        $('#fileupload .fileupload-buttonbar').show(); 
     72        enableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     73      }).bind('fileuploadadded', function() { 
     74        displayMessageInQueue($('.files .template-upload', me).length); 
     75      }).bind('fileuploaddone', function(e, data) { 
     76        if (data.result.files[0].html !== undefined) { 
     77          $('.media-list .files-group').append(data.result.files[0].html); 
     78          $('#form-medias .hide').removeClass('hide'); 
     79        } 
     80        $('.button.clean').css('display', 'inline-block'); 
     81        $(me).show(); 
     82      }).bind('fileuploadalways', function() { 
     83        displayMessageInQueue($('.files .template-upload', me).length); 
     84        if ($('.fileupload-ctrl .files .template-upload', me).length == 0) { 
     85          $('.button.cancel', '#fileupload .fileupload-buttonbar').hide(); 
     86          disableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     87        } 
     88      }); 
     89 
     90      var $msg, label; 
     91 
     92      if ($container.hasClass('enhanced_uploader')) { 
     93        $msg = dotclear.msg.enhanced_uploader_disable; 
     94        label = dotclear.jsUpload.msg.choose_files; 
     95        $(me).fileupload({ 
     96          disabled: false 
     97        }); 
     98        displayMessageInQueue(0); 
     99        disableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     100      } else { 
     101        $msg = dotclear.msg.enhanced_uploader_activate; 
     102        label = dotclear.jsUpload.msg.choose_file; 
     103      } 
     104 
     105      $('<p class="clear"><button type="button" class="enhanced-toggle">' + $msg + '</button></p>').click(function(e) { 
     106        if ($container.hasClass('enhanced_uploader')) { 
     107          $msg = dotclear.msg.enhanced_uploader_activate; 
     108          label = dotclear.jsUpload.msg.choose_file; 
     109          $('#upfile').attr('multiple', false); 
     110          enableButton($('.button.start', '#fileupload .fileupload-buttonbar')); 
     111 
     112          // when a user has clicked enhanced_uploader, and has added files 
     113          // We must remove files in table 
     114          $('.files .upload-file', me).remove(); 
     115          $('.button.cancel,.button.clean', '#fileupload .fileupload-buttonbar').hide(); 
     116          $(me).fileupload({ 
     117            disabled: true 
     118          }); 
     119          $('.queue-message', me).html('').hide(); 
     120        } else { 
     121          $msg = dotclear.msg.enhanced_uploader_disable; 
     122          label = dotclear.jsUpload.msg.choose_files; 
     123          $('#upfile').attr('multiple', true); 
     124          var startButton = $('.button.start'); 
     125          var buttonBar = $('#fileupload .fileupload-buttonbar'); 
     126          disableButton(startButton); 
     127          disableButton(buttonBar); 
     128          startButton.css('display', 'inline-block'); 
     129          buttonBar.show(); 
     130          $(me).fileupload({ 
     131            disabled: false 
     132          }); 
     133          $('.queue-message', me).show(); 
     134          displayMessageInQueue(0); 
     135        } 
     136        $(this).find('button').text($msg); 
     137        $('.add-label', me).text(label); 
     138 
     139        $container.toggleClass('enhanced_uploader'); 
     140        e.preventDefault(); 
     141      }).appendTo(me); 
     142    }); 
     143  }; 
    135144})(jQuery); 
    136145 
    137  
    138146$(function() { 
    139      $('#fileupload').enhancedUploader(); 
    140  
    141      $('.checkboxes-helpers').each(function() { 
    142           dotclear.checkboxesHelpers(this,undefined,'#form-medias input[type="checkbox"]','#form-medias #delete_medias'); 
    143      }); 
    144      dotclear.condSubmit('#form-medias input[type="checkbox"]','#form-medias #delete_medias'); 
    145  
    146      $('#form-medias #delete_medias').click(function(e) { 
    147           var count_checked = $('input[name="medias[]"]:checked', $('#form-medias')).length; 
    148           if (count_checked == 0) { 
    149                e.preventDefault(); 
    150                return false; 
    151           } 
    152           return window.confirm(dotclear.msg.confirm_delete_medias.replace('%d',count_checked)); 
    153      }); 
    154  
    155      // Preview media 
    156      $('.modal-image').magnificPopup({ type:'image' }); 
    157  
    158      // attach media 
    159      $('#form-medias').on('click', '.media-item .attach-media', function(e) { 
    160           var parts = $(this).prop('href').split('?'); 
    161           var str_params = parts[1].split('&'); 
    162           var postData = {}; 
    163  
    164           for (var n=0;n<str_params.length;n++) { 
    165                kv = str_params[n].split('='); 
    166                postData[kv[0]] = kv[1]; 
    167           } 
    168           postData.xd_check = dotclear.nonce; 
    169  
    170           $.post(parts[0], postData, function(data) { 
    171                if (data.url !== undefined) { 
    172                     document.location = data.url; 
    173                } 
    174           }); 
    175  
    176           e.preventDefault(); 
    177      }); 
    178  
    179      // Replace remove links by a POST on hidden form 
    180      fileRemoveAct(); 
    181  
    182      function fileRemoveAct() { 
    183           $('body').on('click','a.media-remove',function() { 
    184                var m_name = $(this).parents('.media-item').find('a.media-link').text(); 
    185                var m_text=''; 
    186                if ($(this).parents('div.media-folder').length == 0) { 
    187                     m_text = dotclear.msg.confirm_delete_media.replace('%s',m_name); 
    188                } else { 
    189                     m_text = dotclear.msg.confirm_delete_directory.replace('%s',m_name); 
    190                } 
    191                if (window.confirm(m_text)) { 
    192                     var f = $('#media-remove-hide').get(0); 
    193                     f.elements['remove'].value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/,'$2'); 
    194                     this.href = ''; 
    195                     f.submit(); 
    196                } 
    197                return false; 
    198           }); 
    199      } 
     147  $('#fileupload').enhancedUploader(); 
     148 
     149  $('.checkboxes-helpers').each(function() { 
     150    dotclear.checkboxesHelpers(this, undefined, '#form-medias input[type="checkbox"]', '#form-medias #delete_medias'); 
     151  }); 
     152  dotclear.condSubmit('#form-medias input[type="checkbox"]', '#form-medias #delete_medias'); 
     153 
     154  $('#form-medias #delete_medias').click(function(e) { 
     155    var count_checked = $('input[name="medias[]"]:checked', $('#form-medias')).length; 
     156    if (count_checked == 0) { 
     157      e.preventDefault(); 
     158      return false; 
     159    } 
     160    return window.confirm(dotclear.msg.confirm_delete_medias.replace('%d', count_checked)); 
     161  }); 
     162 
     163  // Preview media 
     164  $('.modal-image').magnificPopup({ 
     165    type: 'image' 
     166  }); 
     167 
     168  // attach media 
     169  $('#form-medias').on('click', '.media-item .attach-media', function(e) { 
     170    var parts = $(this).prop('href').split('?'); 
     171    var str_params = parts[1].split('&'); 
     172    var postData = {}; 
     173 
     174    for (var n = 0; n < str_params.length; n++) { 
     175      var kv = str_params[n].split('='); 
     176      postData[kv[0]] = kv[1]; 
     177    } 
     178    postData.xd_check = dotclear.nonce; 
     179 
     180    $.post(parts[0], postData, function(data) { 
     181      if (data.url !== undefined) { 
     182        document.location = data.url; 
     183      } 
     184    }); 
     185 
     186    e.preventDefault(); 
     187  }); 
     188 
     189  // Replace remove links by a POST on hidden form 
     190  fileRemoveAct(); 
     191 
     192  function fileRemoveAct() { 
     193    $('body').on('click', 'a.media-remove', function() { 
     194      var m_name = $(this).parents('.media-item').find('a.media-link').text(); 
     195      var m_text = ''; 
     196      if ($(this).parents('div.media-folder').length == 0) { 
     197        m_text = dotclear.msg.confirm_delete_media.replace('%s', m_name); 
     198      } else { 
     199        m_text = dotclear.msg.confirm_delete_directory.replace('%s', m_name); 
     200      } 
     201      if (window.confirm(m_text)) { 
     202        var f = $('#media-remove-hide').get(0); 
     203        f.elements.remove.value = this.href.replace(/^(.*)&remove=(.*?)(&|$)/, '$2'); 
     204        this.href = ''; 
     205        f.submit(); 
     206      } 
     207      return false; 
     208    }); 
     209  } 
    200210}); 
  • admin/js/_media_item.js

    r3702 r3706  
     1/*global $, dotclear, datePicker */ 
     2'use strict'; 
     3 
    14$(function() { 
    25  // Add datePicker if possible 
     
    5760          }); 
    5861        } else { 
    59           alert($(rsp).find('message').text()); 
     62          window.alert($(rsp).find('message').text()); 
    6063        } 
    6164      }); 
  • admin/js/_plugins.js

    r2566 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      // expand a module line 
    3      $('table.modules.expandable tr.line').each(function(){ 
    4           $('td.module-name',this).toggleWithLegend($(this).next('.module-more'),{ 
    5                img_on_src: dotclear.img_plus_src, 
    6                img_on_alt: dotclear.img_plus_alt, 
    7                img_off_src: dotclear.img_minus_src, 
    8                img_off_alt: dotclear.img_minus_alt, 
    9                legend_click: true 
    10           }); 
    11      }); 
     5  // expand a module line 
     6  $('table.modules.expandable tr.line').each(function() { 
     7    $('td.module-name', this).toggleWithLegend($(this).next('.module-more'), { 
     8      img_on_src: dotclear.img_plus_src, 
     9      img_on_alt: dotclear.img_plus_alt, 
     10      img_off_src: dotclear.img_minus_src, 
     11      img_off_alt: dotclear.img_minus_alt, 
     12      legend_click: true 
     13    }); 
     14  }); 
    1215 
    13      // checkboxes selection 
    14      $('.checkboxes-helpers').each(function() { 
    15           dotclear.checkboxesHelpers(this); 
    16      }); 
     16  // checkboxes selection 
     17  $('.checkboxes-helpers').each(function() { 
     18    dotclear.checkboxesHelpers(this); 
     19  }); 
    1720 
    18      // actions tests 
    19      $('.modules-form-actions').each(function(){ 
    20           var rxActionType = /^[^\[]+/; 
    21           var rxActionValue = /([^\[]+)\]$/; 
    22           var checkboxes = $(this).find('input[type=checkbox]'); 
     21  // actions tests 
     22  $('.modules-form-actions').each(function() { 
     23    var rxActionType = /^[^\[]+/; 
     24    var rxActionValue = /([^\[]+)\]$/; 
     25    var checkboxes = $(this).find('input[type=checkbox]'); 
    2326 
    24           // check if submit is a global action or one line action 
    25           $("input[type=submit]",this).click(function() { 
    26                var keyword = $(this).attr('name'); 
    27                var maction = keyword.match(rxActionType); 
    28                var action = maction[0]; 
    29                var mvalues = keyword.match(rxActionValue); 
     27    // check if submit is a global action or one line action 
     28    $('input[type=submit]', this).click(function() { 
     29      var keyword = $(this).attr('name'); 
     30      var maction = keyword.match(rxActionType); 
     31      var action = maction[0]; 
     32      var mvalues = keyword.match(rxActionValue); 
    3033 
    31                // action on multiple modules 
    32                if (!mvalues) { 
    33                     var checked = false; 
     34      // action on multiple modules 
     35      if (!mvalues) { 
     36        var checked = false; 
    3437 
    35                     // check if there is checkboxes in form 
    36                     if(checkboxes.length > 0) { 
    37                          // check if there is at least one checkbox checked 
    38                          $(checkboxes).each(function() { 
    39                               if (this.checked) { 
    40                                    checked = true; 
    41                               } 
    42                          }); 
    43                          if (!checked) { 
    44                               //alert(dotclear.msg.no_selection); 
    45                               return false; 
    46                          } 
    47                     } 
     38        // check if there is checkboxes in form 
     39        if (checkboxes.length > 0) { 
     40          // check if there is at least one checkbox checked 
     41          $(checkboxes).each(function() { 
     42            if (this.checked) { 
     43              checked = true; 
     44            } 
     45          }); 
     46          if (!checked) { 
     47            //alert(dotclear.msg.no_selection); 
     48            return false; 
     49          } 
     50        } 
    4851 
    49                     // confirm delete 
    50                     if (action == 'delete') { 
    51                          return window.confirm(dotclear.msg.confirm_delete_plugins); 
    52                     } 
     52        // confirm delete 
     53        if (action == 'delete') { 
     54          return window.confirm(dotclear.msg.confirm_delete_plugins); 
     55        } 
    5356 
    54                // action on one module 
    55                }else { 
    56                     var module = mvalues[1]; 
     57        // action on one module 
     58      } else { 
     59        var module = mvalues[1]; 
    5760 
    58                     // confirm delete 
    59                     if (action == 'delete') { 
    60                          return window.confirm(dotclear.msg.confirm_delete_plugin.replace('%s',module)); 
    61                     } 
    62                } 
     61        // confirm delete 
     62        if (action == 'delete') { 
     63          return window.confirm(dotclear.msg.confirm_delete_plugin.replace('%s', module)); 
     64        } 
     65      } 
    6366 
    64                return true; 
    65           }); 
    66      }); 
     67      return true; 
     68    }); 
     69  }); 
    6770}); 
  • admin/js/_popup_link.js

    r3701 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    25  // Set focus on #href input 
  • admin/js/_popup_posts.js

    r3701 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    25  // Set focus on #type input 
  • admin/js/_post.js

    r3483 r3706  
    1 dotclear.viewCommentContent = function(line,action) { 
    2      var commentId = $(line).attr('id').substr(1); 
    3      var tr = document.getElementById('ce'+commentId); 
     1/*global $, dotclear, datePicker, commentTb */ 
     2'use strict'; 
    43 
    5      if (!tr) { 
    6           tr = document.createElement('tr'); 
    7           tr.id = 'ce'+commentId; 
    8           var td = document.createElement('td'); 
    9           td.colSpan = 6; 
    10           td.className = 'expand'; 
    11           tr.appendChild(td); 
     4dotclear.viewCommentContent = function(line) { 
     5  var commentId = $(line).attr('id').substr(1); 
     6  var tr = document.getElementById('ce' + commentId); 
    127 
    13           // Get comment content 
    14           $.get('services.php',{f:'getCommentById',id: commentId},function(data) { 
    15                var rsp = $(data).children('rsp')[0]; 
     8  if (!tr) { 
     9    tr = document.createElement('tr'); 
     10    tr.id = 'ce' + commentId; 
     11    var td = document.createElement('td'); 
     12    td.colSpan = 6; 
     13    td.className = 'expand'; 
     14    tr.appendChild(td); 
    1615 
    17                if (rsp.attributes[0].value == 'ok') { 
    18                     var comment = $(rsp).find('comment_display_content').text(); 
     16    // Get comment content 
     17    $.get('services.php', { 
     18      f: 'getCommentById', 
     19      id: commentId 
     20    }, function(data) { 
     21      var rsp = $(data).children('rsp')[0]; 
    1922 
    20                     if (comment) { 
    21                          $(td).append(comment); 
    22                          var comment_email = $(rsp).find('comment_email').text(); 
    23                          var comment_site = $(rsp).find('comment_site').text(); 
    24                          var comment_ip = $(rsp).find('comment_ip').text(); 
    25                          var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
     23      if (rsp.attributes[0].value == 'ok') { 
     24        var comment = $(rsp).find('comment_display_content').text(); 
    2625 
    27                          $(td).append('<p><strong>' + dotclear.msg.website + 
    28                          '</strong> ' + comment_site + '<br />' + 
    29                          '<strong>' + dotclear.msg.email + '</strong> ' + 
    30                          comment_email + '<br />' + comment_spam_disp + '</p>'); 
    31                     } 
    32                } else { 
    33                     alert($(rsp).find('message').text()); 
    34                } 
    35           }); 
     26        if (comment) { 
     27          $(td).append(comment); 
     28          var comment_email = $(rsp).find('comment_email').text(); 
     29          var comment_site = $(rsp).find('comment_site').text(); 
     30          //          var comment_ip = $(rsp).find('comment_ip').text(); 
     31          var comment_spam_disp = $(rsp).find('comment_spam_disp').text(); 
    3632 
    37           $(line).toggleClass('expand'); 
    38           line.parentNode.insertBefore(tr,line.nextSibling); 
    39      } 
    40      else if (tr.style.display == 'none') 
    41      { 
    42           $(tr).toggle(); 
    43           $(line).toggleClass('expand'); 
    44      } 
    45      else 
    46      { 
    47           $(tr).toggle(); 
    48           $(line).toggleClass('expand'); 
    49      } 
     33          $(td).append('<p><strong>' + dotclear.msg.website + 
     34            '</strong> ' + comment_site + '<br />' + 
     35            '<strong>' + dotclear.msg.email + '</strong> ' + 
     36            comment_email + '<br />' + comment_spam_disp + '</p>'); 
     37        } 
     38      } else { 
     39        window.alert($(rsp).find('message').text()); 
     40      } 
     41    }); 
     42 
     43    $(line).toggleClass('expand'); 
     44    line.parentNode.insertBefore(tr, line.nextSibling); 
     45  } else if (tr.style.display == 'none') { 
     46    $(tr).toggle(); 
     47    $(line).toggleClass('expand'); 
     48  } else { 
     49    $(tr).toggle(); 
     50    $(line).toggleClass('expand'); 
     51  } 
    5052}; 
    5153 
    5254$(function() { 
    53      // Post preview 
    54      $preview_url = $('#post-preview').attr('href'); 
    55      if ($preview_url) { 
     55  // Post preview 
     56  var $preview_url = $('#post-preview').attr('href'); 
     57  if ($preview_url) { 
    5658 
    57           // Make $preview_url absolute 
    58           $a = document.createElement('a'); 
    59           $a.href = $('#post-preview').attr('href'); 
    60           $preview_url = $a.href; 
     59    // Make $preview_url absolute 
     60    var $a = document.createElement('a'); 
     61    $a.href = $('#post-preview').attr('href'); 
     62    $preview_url = $a.href; 
    6163 
    62           // Check if admin and blog have same protocol (ie not mixed-content) 
    63           if (window.location.protocol == $preview_url.substring(0,window.location.protocol.length)) { 
    64                // Open preview in a modal iframe 
    65                $('#post-preview').magnificPopup({ 
    66                     type:'iframe', 
    67                     iframe: { 
    68                          patterns: { 
    69                               dotclear_preview: { 
    70                                    index: $preview_url, 
    71                                    src: $preview_url 
    72                               } 
    73                          } 
    74                     } 
    75                }); 
    76           } else { 
    77                // Open preview on antother window 
    78                $('#post-preview').click(function(e) { 
    79                     e.preventDefault(); 
    80                     window.open($(this).attr('href')); 
    81                }); 
    82           } 
    83      } 
     64    // Check if admin and blog have same protocol (ie not mixed-content) 
     65    if (window.location.protocol == $preview_url.substring(0, window.location.protocol.length)) { 
     66      // Open preview in a modal iframe 
     67      $('#post-preview').magnificPopup({ 
     68        type: 'iframe', 
     69        iframe: { 
     70          patterns: { 
     71            dotclear_preview: { 
     72              index: $preview_url, 
     73              src: $preview_url 
     74            } 
     75          } 
     76        } 
     77      }); 
     78    } else { 
     79      // Open preview on antother window 
     80      $('#post-preview').click(function(e) { 
     81        e.preventDefault(); 
     82        window.open($(this).attr('href')); 
     83      }); 
     84    } 
     85  } 
    8486 
    85      // Tabs events 
    86      $('#edit-entry').onetabload(function() { 
    87           dotclear.hideLockable(); 
     87  // Tabs events 
     88  $('#edit-entry').onetabload(function() { 
     89    dotclear.hideLockable(); 
    8890 
    89           // Add date picker 
    90           var post_dtPick = new datePicker($('#post_dt').get(0)); 
    91           post_dtPick.img_top = '1.5em'; 
    92           post_dtPick.draw(); 
     91    // Add date picker 
     92    var post_dtPick = new datePicker($('#post_dt').get(0)); 
     93    post_dtPick.img_top = '1.5em'; 
     94    post_dtPick.draw(); 
    9395 
    94           // Confirm post deletion 
    95           $('input[name="delete"]').click(function() { 
    96                return window.confirm(dotclear.msg.confirm_delete_post); 
    97           }); 
     96    // Confirm post deletion 
     97    $('input[name="delete"]').click(function() { 
     98      return window.confirm(dotclear.msg.confirm_delete_post); 
     99    }); 
    98100 
    99           // Hide some fields 
    100           $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'),{ 
    101                user_pref: 'dcx_post_notes', 
    102                legend_click:true, 
    103                hide: $('#post_notes').val() == '' 
    104           }); 
    105           $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'),{ 
    106                user_pref: 'dcx_post_lang', 
    107                legend_click: true 
    108           }); 
    109           $('#post_password').parent().children('label').toggleWithLegend($('#post_password'),{ 
    110                user_pref: 'dcx_post_password', 
    111                legend_click: true, 
    112                hide: $('#post_password').val() == '' 
    113           }); 
    114           $('#post_status').parent().children('label').toggleWithLegend($('#post_status'),{ 
    115                user_pref: 'dcx_post_status', 
    116                legend_click: true 
    117           }); 
    118           $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'),{ 
    119                user_pref: 'dcx_post_dt', 
    120                legend_click: true 
    121           }); 
    122           $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'),{ 
    123                user_pref: 'dcx_post_format', 
    124                legend_click: true 
    125           }); 
    126           $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'),{ 
    127                user_pref: 'dcx_cat_id', 
    128                legend_click: true 
    129           }); 
    130           $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'),{ 
    131                // no cookie on new category as we don't use this every day 
    132                legend_click: true 
    133           }); 
    134           $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'),{ 
    135                user_pref: 'dcx_comment_tb', 
    136                legend_click: true 
    137           }); 
    138           $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'),{ 
    139                user_pref: 'post_url', 
    140                legend_click: true 
    141           }); 
    142           // We load toolbar on excerpt only when it's ready 
    143           $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'),{ 
    144                user_pref: 'dcx_post_excerpt', 
    145                legend_click: true, 
    146                hide: $('#post_excerpt').val() == '' 
    147           }); 
     101    // Hide some fields 
     102    $('#notes-area label').toggleWithLegend($('#notes-area').children().not('label'), { 
     103      user_pref: 'dcx_post_notes', 
     104      legend_click: true, 
     105      hide: $('#post_notes').val() == '' 
     106    }); 
     107    $('#post_lang').parent().children('label').toggleWithLegend($('#post_lang'), { 
     108      user_pref: 'dcx_post_lang', 
     109      legend_click: true 
     110    }); 
     111    $('#post_password').parent().children('label').toggleWithLegend($('#post_password'), { 
     112      user_pref: 'dcx_post_password', 
     113      legend_click: true, 
     114      hide: $('#post_password').val() == '' 
     115    }); 
     116    $('#post_status').parent().children('label').toggleWithLegend($('#post_status'), { 
     117      user_pref: 'dcx_post_status', 
     118      legend_click: true 
     119    }); 
     120    $('#post_dt').parent().children('label').toggleWithLegend($('#post_dt').parent().children().not('label'), { 
     121      user_pref: 'dcx_post_dt', 
     122      legend_click: true 
     123    }); 
     124    $('#label_format').toggleWithLegend($('#label_format').parent().children().not('#label_format'), { 
     125      user_pref: 'dcx_post_format', 
     126      legend_click: true 
     127    }); 
     128    $('#label_cat_id').toggleWithLegend($('#label_cat_id').parent().children().not('#label_cat_id'), { 
     129      user_pref: 'dcx_cat_id', 
     130      legend_click: true 
     131    }); 
     132    $('#create_cat').toggleWithLegend($('#create_cat').parent().children().not('#create_cat'), { 
     133      // no cookie on new category as we don't use this every day 
     134      legend_click: true 
     135    }); 
     136    $('#label_comment_tb').toggleWithLegend($('#label_comment_tb').parent().children().not('#label_comment_tb'), { 
     137      user_pref: 'dcx_comment_tb', 
     138      legend_click: true 
     139    }); 
     140    $('#post_url').parent().children('label').toggleWithLegend($('#post_url').parent().children().not('label'), { 
     141      user_pref: 'post_url', 
     142      legend_click: true 
     143    }); 
     144    // We load toolbar on excerpt only when it's ready 
     145    $('#excerpt-area label').toggleWithLegend($('#excerpt-area').children().not('label'), { 
     146      user_pref: 'dcx_post_excerpt', 
     147      legend_click: true, 
     148      hide: $('#post_excerpt').val() == '' 
     149    }); 
    148150 
    149           // Replace attachment remove links by a POST form submit 
    150           $('a.attachment-remove').click(function() { 
    151                this.href = ''; 
    152                var m_name = $(this).parents('ul').find('li:first>a').attr('title'); 
    153                if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s',m_name))) { 
    154                     var f = $('#attachment-remove-hide').get(0); 
    155                     f.elements['media_id'].value = this.id.substring(11); 
    156                     f.submit(); 
    157                } 
    158                return false; 
    159           }); 
    160      }); 
     151    // Replace attachment remove links by a POST form submit 
     152    $('a.attachment-remove').click(function() { 
     153      this.href = ''; 
     154      var m_name = $(this).parents('ul').find('li:first>a').attr('title'); 
     155      if (window.confirm(dotclear.msg.confirm_remove_attachment.replace('%s', m_name))) { 
     156        var f = $('#attachment-remove-hide').get(0); 
     157        f.elements.media_id.value = this.id.substring(11); 
     158        f.submit(); 
     159      } 
     160      return false; 
     161    }); 
     162  }); 
    161163 
    162      $('#comments').onetabload(function() { 
    163           $.expandContent({ 
    164                lines:$('#form-comments .comments-list tr.line'), 
    165                callback:dotclear.viewCommentContent 
    166           }); 
    167           $('#form-comments .checkboxes-helpers').each(function() { 
    168                dotclear.checkboxesHelpers(this); 
    169           }); 
     164  $('#comments').onetabload(function() { 
     165    $.expandContent({ 
     166      lines: $('#form-comments .comments-list tr.line'), 
     167      callback: dotclear.viewCommentContent 
     168    }); 
     169    $('#form-comments .checkboxes-helpers').each(function() { 
     170      dotclear.checkboxesHelpers(this); 
     171    }); 
    170172 
    171           dotclear.commentsActionsHelper(); 
    172      }); 
     173    dotclear.commentsActionsHelper(); 
     174  }); 
    173175 
    174      $('#trackbacks').onetabload(function() { 
    175           $.expandContent({ 
    176                lines:$('#form-trackbacks .comments-list tr.line'), 
    177                callback:dotclear.viewCommentContent 
    178           }); 
    179           $('#form-trackbacks .checkboxes-helpers').each(function() { 
    180                dotclear.checkboxesHelpers(this); 
    181           }); 
     176  $('#trackbacks').onetabload(function() { 
     177    $.expandContent({ 
     178      lines: $('#form-trackbacks .comments-list tr.line'), 
     179      callback: dotclear.viewCommentContent 
     180    }); 
     181    $('#form-trackbacks .checkboxes-helpers').each(function() { 
     182      dotclear.checkboxesHelpers(this); 
     183    }); 
    182184 
    183           dotclear.commentsActionsHelper(); 
    184      }); 
     185    dotclear.commentsActionsHelper(); 
     186  }); 
    185187 
    186      $('#add-comment').onetabload(function() { 
    187           commentTb.draw('xhtml'); 
    188      }); 
     188  $('#add-comment').onetabload(function() { 
     189    commentTb.draw('xhtml'); 
     190  }); 
    189191}); 
  • admin/js/_posts_actions.js

    r3182 r3706  
     1/*global $, dotclear, usersList */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      new_auth_id = $('#new_auth_id'); 
    3      if (new_auth_id.length) { 
    4           new_auth_id.autocomplete(usersList, 
    5           { 
    6                delay: 1000, 
    7                matchSubset: true, 
    8                matchContains: true 
    9           }); 
    10      } 
    11      $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), { 
    12           // no cookie on new category as we don't use this every day 
    13           legend_click: true 
    14      }); 
    15      dotclear.condSubmit('table.posts-list td input[type=checkbox]','input[type=submit]'); 
     5  var new_auth_id = $('#new_auth_id'); 
     6  if (new_auth_id.length) { 
     7    new_auth_id.autocomplete(usersList, { 
     8      delay: 1000, 
     9      matchSubset: true, 
     10      matchContains: true 
     11    }); 
     12  } 
     13  $('#new_cat').toggleWithLegend($('#new_cat').parent().children().not('#new_cat'), { 
     14    // no cookie on new category as we don't use this every day 
     15    legend_click: true 
     16  }); 
     17  dotclear.condSubmit('table.posts-list td input[type=checkbox]', 'input[type=submit]'); 
    1618}); 
  • admin/js/_posts_list.js

    r3182 r3706  
    1 dotclear.viewPostContent = function(line,action) { 
    2      var action = action || 'toggle'; 
    3      var postId = $(line).attr('id').substr(1); 
    4      var tr = document.getElementById('pe'+postId); 
     1/*global $, dotclear */ 
     2'use strict'; 
    53 
    6      if ( !tr && ( action == 'toggle' || action == 'open' ) ) { 
    7           tr = document.createElement('tr'); 
    8           tr.id = 'pe'+postId; 
    9           var td = document.createElement('td'); 
    10           td.colSpan = 8; 
    11           td.className = 'expand'; 
    12           tr.appendChild(td); 
     4dotclear.viewPostContent = function(line, action) { 
     5  action = action || 'toggle'; 
     6  var postId = $(line).attr('id').substr(1); 
     7  var tr = document.getElementById('pe' + postId); 
    138 
    14           // Get post content 
    15           $.get('services.php',{f:'getPostById', id: postId, post_type: ''},function(data) { 
    16                var rsp = $(data).children('rsp')[0]; 
     9  if (!tr && (action == 'toggle' || action == 'open')) { 
     10    tr = document.createElement('tr'); 
     11    tr.id = 'pe' + postId; 
     12    var td = document.createElement('td'); 
     13    td.colSpan = 8; 
     14    td.className = 'expand'; 
     15    tr.appendChild(td); 
    1716 
    18                if (rsp.attributes[0].value == 'ok') { 
    19                     var post = $(rsp).find('post_display_content').text(); 
    20                     var post_excerpt = $(rsp).find('post_display_excerpt').text(); 
    21                     var res = ''; 
     17    // Get post content 
     18    $.get('services.php', { 
     19      f: 'getPostById', 
     20      id: postId, 
     21      post_type: '' 
     22    }, function(data) { 
     23      var rsp = $(data).children('rsp')[0]; 
    2224 
    23                     if (post) { 
    24                          if (post_excerpt) { 
    25                               res += post_excerpt + '<hr />'; 
    26                          } 
    27                          res += post; 
    28                          $(td).append(res); 
    29                     } 
    30                } else { 
    31                     alert($(rsp).find('message').text()); 
    32                } 
    33           }); 
     25      if (rsp.attributes[0].value == 'ok') { 
     26        var post = $(rsp).find('post_display_content').text(); 
     27        var post_excerpt = $(rsp).find('post_display_excerpt').text(); 
     28        var res = ''; 
    3429 
    35           $(line).addClass('expand'); 
    36           line.parentNode.insertBefore(tr,line.nextSibling); 
    37      } 
    38      else if (tr && tr.style.display == 'none' && ( action == 'toggle' || action == 'open' ) ) 
    39      { 
    40           $(tr).css('display', 'table-row'); 
    41           $(line).addClass('expand'); 
    42      } 
    43      else if (tr && tr.style.display != 'none' && ( action == 'toggle' || action == 'close' ) ) 
    44      { 
    45           $(tr).css('display', 'none'); 
    46           $(line).removeClass('expand'); 
    47      } 
     30        if (post) { 
     31          if (post_excerpt) { 
     32            res += post_excerpt + '<hr />'; 
     33          } 
     34          res += post; 
     35          $(td).append(res); 
     36        } 
     37      } else { 
     38        window.alert($(rsp).find('message').text()); 
     39      } 
     40    }); 
     41 
     42    $(line).addClass('expand'); 
     43    line.parentNode.insertBefore(tr, line.nextSibling); 
     44  } else if (tr && tr.style.display == 'none' && (action == 'toggle' || action == 'open')) { 
     45    $(tr).css('display', 'table-row'); 
     46    $(line).addClass('expand'); 
     47  } else if (tr && tr.style.display != 'none' && (action == 'toggle' || action == 'close')) { 
     48    $(tr).css('display', 'none'); 
     49    $(line).removeClass('expand'); 
     50  } 
    4851}; 
    4952 
    5053$(function() { 
    51      // Entry type switcher 
    52      $('#type').change(function() { 
    53           this.form.submit(); 
    54      }); 
     54  // Entry type switcher 
     55  $('#type').change(function() { 
     56    this.form.submit(); 
     57  }); 
    5558 
    56      $.expandContent({ 
    57           line:$('#form-entries tr:not(.line)'), 
    58           lines:$('#form-entries tr.line'), 
    59           callback:dotclear.viewPostContent 
    60      }); 
    61      $('.checkboxes-helpers').each(function() { 
    62           dotclear.checkboxesHelpers(this,undefined,'#form-entries td input[type=checkbox]','#form-entries #do-action'); 
    63      }); 
    64      $('#form-entries td input[type=checkbox]').enableShiftClick(); 
    65      dotclear.condSubmit('#form-entries td input[type=checkbox]','#form-entries #do-action'); 
    66      dotclear.postsActionsHelper(); 
     59  $.expandContent({ 
     60    line: $('#form-entries tr:not(.line)'), 
     61    lines: $('#form-entries tr.line'), 
     62    callback: dotclear.viewPostContent 
     63  }); 
     64  $('.checkboxes-helpers').each(function() { 
     65    dotclear.checkboxesHelpers(this, undefined, '#form-entries td input[type=checkbox]', '#form-entries #do-action'); 
     66  }); 
     67  $('#form-entries td input[type=checkbox]').enableShiftClick(); 
     68  dotclear.condSubmit('#form-entries td input[type=checkbox]', '#form-entries #do-action'); 
     69  dotclear.postsActionsHelper(); 
    6770}); 
  • admin/js/_preferences-dragdrop.js

    r2566 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $("#my-favs ul").sortable({'cursor':'move'}); 
    3      $("#my-favs ul, #my-favs ul *").css({'cursor':'move'}); 
    4      $("#my-favs ul input").css({'cursor':'auto'}); 
    5      $('#favs-form').submit(function() { 
    6           var order=[]; 
    7           $("#my-favs ul li input.position").each(function() { 
    8                order.push(this.name.replace(/^order\[([^\]]+)\]$/,'$1')); 
    9           }); 
    10           $("input[name=favs_order]")[0].value = order.join(','); 
    11           return true; 
    12      }); 
    13      $("#my-favs ul li input.position").hide(); 
     5  $('#my-favs ul').sortable({ 
     6    'cursor': 'move' 
     7  }); 
     8  $('#my-favs ul, #my-favs ul *').css({ 
     9    'cursor': 'move' 
     10  }); 
     11  $('#my-favs ul input').css({ 
     12    'cursor': 'auto' 
     13  }); 
     14  $('#favs-form').submit(function() { 
     15    var order = []; 
     16    $('#my-favs ul li input.position').each(function() { 
     17      order.push(this.name.replace(/^order\[([^\]]+)\]$/, '$1')); 
     18    }); 
     19    $('input[name=favs_order]')[0].value = order.join(','); 
     20    return true; 
     21  }); 
     22  $('#my-favs ul li input.position').hide(); 
    1423}); 
  • admin/js/_preferences.js

    r3685 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    25  if ($('#new_pwd').length == 0) { 
     
    58  var user_email = $('#user_email').val(); 
    69  $('#user-form').submit(function() { 
    7     var e = this.elements['cur_pwd']; 
     10    var e = this.elements.cur_pwd; 
    811    if (e.value != '') { 
    912      return true; 
     
    1114    if ($('#user_email').val() != user_email || $('#new_pwd').val() != '') { 
    1215      $(e).addClass('missing').focusout(function() { 
    13         $(this).removeClass('missing') 
     16        $(this).removeClass('missing'); 
    1417      }); 
    1518      e.focus(); 
  • admin/js/_trackbacks.js

    r2566 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('#tb_excerpt').keypress(function() { 
    3           if (this.value.length > 255) { 
    4                this.value = this.value.substring(0,255); 
    5           } 
    6      }); 
     5  $('#tb_excerpt').keypress(function() { 
     6    if (this.value.length > 255) { 
     7      this.value = this.value.substring(0, 255); 
     8    } 
     9  }); 
    710}); 
  • admin/js/_update.js

    r2503 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('form input[type=submit][name=b_del]').click(function(){ 
    3           return window.confirm(dotclear.msg.confirm_delete_backup); 
    4      }); 
    5      $('form input[type=submit][name=b_revert]').click(function(){ 
    6           return window.confirm(dotclear.msg.confirm_revert_backup); 
    7      }); 
     5  $('form input[type=submit][name=b_del]').click(function() { 
     6    return window.confirm(dotclear.msg.confirm_delete_backup); 
     7  }); 
     8  $('form input[type=submit][name=b_revert]').click(function() { 
     9    return window.confirm(dotclear.msg.confirm_revert_backup); 
     10  }); 
    811}); 
  • admin/js/_users.js

    r3182 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('.checkboxes-helpers').each(function() { 
    3           dotclear.checkboxesHelpers(this,undefined,'#form-users input[type="checkbox"]','#form-users #do-action'); 
    4      }); 
    5      dotclear.condSubmit('#form-users input[type="checkbox"]','#form-users #do-action'); 
    6      $('#form-users').submit(function() { 
    7           var action = $(this).find('select[name="action"]').val(); 
    8           var user_ids = new Array(); 
    9           var nb_posts = new Array(); 
    10           var i; 
    11           var msg_cannot_delete = false; 
     5  $('.checkboxes-helpers').each(function() { 
     6    dotclear.checkboxesHelpers(this, undefined, '#form-users input[type="checkbox"]', '#form-users #do-action'); 
     7  }); 
     8  dotclear.condSubmit('#form-users input[type="checkbox"]', '#form-users #do-action'); 
     9  $('#form-users').submit(function() { 
     10    var action = $(this).find('select[name="action"]').val(); 
     11    var user_ids = []; 
     12    var nb_posts = []; 
     13    var i; 
     14    var msg_cannot_delete = false; 
    1215 
    13           $(this).find('input[name="users[]"]').each(function() { 
    14                user_ids.push(this); 
    15           }); 
    16           $(this).find('input[name="nb_post[]"]').each(function() { 
    17                nb_posts.push(this.value); 
    18           }); 
     16    $(this).find('input[name="users[]"]').each(function() { 
     17      user_ids.push(this); 
     18    }); 
     19    $(this).find('input[name="nb_post[]"]').each(function() { 
     20      nb_posts.push(this.value); 
     21    }); 
    1922 
    20           if (action == 'deleteuser') { 
    21                for (i=0; i<user_ids.length; i++) { 
    22                     if (nb_posts[i] > 0) { 
    23                          if (user_ids[i].checked == true) { 
    24                               msg_cannot_delete = true; 
    25                               user_ids[i].checked = false; 
    26                          } 
    27                     } 
    28                } 
    29                if (msg_cannot_delete == true) { 
    30                     alert(dotclear.msg.cannot_delete_users); 
    31                } 
    32           } 
     23    if (action == 'deleteuser') { 
     24      for (i = 0; i < user_ids.length; i++) { 
     25        if (nb_posts[i] > 0) { 
     26          if (user_ids[i].checked == true) { 
     27            msg_cannot_delete = true; 
     28            user_ids[i].checked = false; 
     29          } 
     30        } 
     31      } 
     32      if (msg_cannot_delete == true) { 
     33        window.alert(dotclear.msg.cannot_delete_users); 
     34      } 
     35    } 
    3336 
    34           var selectfields = 0; 
    35           for (i=0; i<user_ids.length; i++) { 
    36                selectfields += user_ids[i].checked; 
    37           } 
     37    var selectfields = 0; 
     38    for (i = 0; i < user_ids.length; i++) { 
     39      selectfields += user_ids[i].checked; 
     40    } 
    3841 
    39           if (selectfields == 0) { 
    40                return false; 
    41           } 
     42    if (selectfields == 0) { 
     43      return false; 
     44    } 
    4245 
    43           if (action == 'deleteuser') { 
    44                return window.confirm(dotclear.msg.confirm_delete_user.replace('%s',$('input[name="users[]"]:checked').size())); 
    45           } 
     46    if (action == 'deleteuser') { 
     47      return window.confirm(dotclear.msg.confirm_delete_user.replace('%s', $('input[name="users[]"]:checked').size())); 
     48    } 
    4649 
    47           return true; 
    48      }); 
     50    return true; 
     51  }); 
    4952}); 
  • admin/js/_users_actions.js

    r3182 r3706  
     1/*global $, jQuery, dotclear */ 
     2'use strict'; 
     3 
    14jQuery.fn.updatePermissionsForm = function() { 
    2      return this.each(function() { 
     5  return this.each(function() { 
    36 
    4           var perms = {}; 
    5           var re = /^perm\[(.+?)\]\[(.+?)\]$/; 
    6           var e,prop; 
     7    var perms = {}; 
     8    var re = /^perm\[(.+?)\]\[(.+?)\]$/; 
     9    var e, prop; 
    710 
    8           // Building a nice object of form elements 
    9           for (var i=0; i<this.elements.length; i++) { 
    10                e = this.elements[i]; 
     11    var admin = function(E, perms, re) { 
     12      var P = E.name.match(re); 
    1113 
    12                if (e.name == undefined) { 
    13                     continue; 
    14                } 
    15                var prop; 
    16                prop = e.name.match(re); 
    17                if (!prop) { 
    18                     continue; 
    19                } 
    20                if (perms[prop[1]] == undefined) { 
    21                     perms[prop[1]] = {}; 
    22                } 
    23                perms[prop[1]][prop[2]] = e; 
     14      perms[P[1]].usage.checked = E.checked; 
     15      perms[P[1]].publish.checked = E.checked; 
     16      perms[P[1]].delete.checked = E.checked; 
     17      perms[P[1]].contentadmin.checked = E.checked; 
     18      perms[P[1]].categories.checked = E.checked; 
     19      perms[P[1]].media.checked = E.checked; 
     20      perms[P[1]].media_admin.checked = E.checked; 
    2421 
    25                // select related permissions for admin 
    26                if (prop[2] == 'admin') { 
    27                     if (e.checked) { 
    28                          admin(e,perms,re); 
    29                     } 
    30                     $(e).click(function(){ 
    31                          admin(this,perms,re); 
    32                     }); 
    33                // select related permissions for content admin 
    34                } else if (prop[2] == 'contentadmin') { 
    35                     if (e.checked) { 
    36                          contentadmin(e,perms,re); 
    37                     } 
    38                     $(e).click(function(){ 
    39                          contentadmin(this,perms,re); 
    40                     }); 
    41                // select related permissions for media admin 
    42                } else if (prop[2] == 'media_admin') { 
    43                     if (e.checked) { 
    44                          mediaadmin(e,perms,re); 
    45                     } 
    46                     $(e).click(function(){ 
    47                          mediaadmin(this,perms,re); 
    48                     }); 
    49                } 
    50           } 
     22      perms[P[1]].usage.disabled = E.checked; 
     23      perms[P[1]].publish.disabled = E.checked; 
     24      perms[P[1]].delete.disabled = E.checked; 
     25      perms[P[1]].contentadmin.disabled = E.checked; 
     26      perms[P[1]].categories.disabled = E.checked; 
     27      perms[P[1]].media.disabled = E.checked; 
     28      perms[P[1]].media_admin.disabled = E.checked; 
     29    }; 
    5130 
    52           function admin(E,perms,re) { 
    53                          P = E.name.match(re); 
     31    var contentadmin = function(E, perms, re) { 
     32      var P = E.name.match(re); 
    5433 
    55                          perms[P[1]]['usage'].checked = E.checked; 
    56                          perms[P[1]]['publish'].checked = E.checked; 
    57                          perms[P[1]]['delete'].checked = E.checked; 
    58                          perms[P[1]]['contentadmin'].checked = E.checked; 
    59                          perms[P[1]]['categories'].checked = E.checked; 
    60                          perms[P[1]]['media'].checked = E.checked; 
    61                          perms[P[1]]['media_admin'].checked = E.checked; 
    62                          perms[P[1]]['usage'].disabled = E.checked; 
    63                          perms[P[1]]['publish'].disabled = E.checked; 
    64                          perms[P[1]]['delete'].disabled = E.checked; 
    65                          perms[P[1]]['contentadmin'].disabled = E.checked; 
    66                          perms[P[1]]['categories'].disabled = E.checked; 
    67                          perms[P[1]]['media'].disabled = E.checked; 
    68                          perms[P[1]]['media_admin'].disabled = E.checked; 
    69           } 
     34      perms[P[1]].usage.checked = E.checked; 
     35      perms[P[1]].publish.checked = E.checked; 
     36      perms[P[1]].delete.checked = E.checked; 
    7037 
    71           function contentadmin(E,perms,re) { 
    72                          P = E.name.match(re); 
     38      perms[P[1]].usage.disabled = E.checked; 
     39      perms[P[1]].publish.disabled = E.checked; 
     40      perms[P[1]].delete.disabled = E.checked; 
     41    }; 
    7342 
    74                          perms[P[1]]['usage'].checked = E.checked; 
    75                          perms[P[1]]['publish'].checked = E.checked; 
    76                          perms[P[1]]['delete'].checked = E.checked; 
    77                          perms[P[1]]['usage'].disabled = E.checked; 
    78                          perms[P[1]]['publish'].disabled = E.checked; 
    79                          perms[P[1]]['delete'].disabled = E.checked; 
    80           } 
     43    var mediaadmin = function(E, perms, re) { 
     44      var P = E.name.match(re); 
    8145 
    82           function mediaadmin(E,perms,re) { 
    83                          P = E.name.match(re); 
     46      perms[P[1]].media.checked = E.checked; 
    8447 
    85                          perms[P[1]]['media'].checked = E.checked; 
    86                          perms[P[1]]['media'].disabled = E.checked; 
    87           } 
     48      perms[P[1]].media.disabled = E.checked; 
     49    }; 
    8850 
    89  
    90      }); 
     51    // Building a nice object of form elements 
     52    for (var i = 0; i < this.elements.length; i++) { 
     53      e = this.elements[i]; 
     54      if (e.name == undefined) { 
     55        continue; 
     56      } 
     57      prop = e.name.match(re); 
     58      if (!prop) { 
     59        continue; 
     60      } 
     61      if (perms[prop[1]] == undefined) { 
     62        perms[prop[1]] = {}; 
     63      } 
     64      perms[prop[1]][prop[2]] = e; 
     65    } 
     66    // Populate states 
     67    for (var blog in perms) { 
     68      // Loop on blog 
     69      for (var element in perms[blog]) { 
     70        // Loop on permission 
     71        e = perms[blog][element]; 
     72        prop = e.name.match(re); 
     73        if (prop[2] == 'admin') { 
     74          // select related permissions for admin 
     75          if (e.checked) { 
     76            admin(e, perms, re); 
     77          } 
     78          $(e).click(function() { 
     79            admin(this, perms, re); 
     80          }); 
     81        } else if (prop[2] == 'contentadmin') { 
     82          // select related permissions for content admin 
     83          if (e.checked) { 
     84            contentadmin(e, perms, re); 
     85          } 
     86          $(e).click(function() { 
     87            contentadmin(this, perms, re); 
     88          }); 
     89        } else if (prop[2] == 'media_admin') { 
     90          // select related permissions for media admin 
     91          if (e.checked) { 
     92            mediaadmin(e, perms, re); 
     93          } 
     94          $(e).click(function() { 
     95            mediaadmin(this, perms, re); 
     96          }); 
     97        } 
     98      } 
     99    } 
     100  }); 
    91101}; 
    92102 
    93103$(function() { 
    94      $('.checkboxes-helpers').each(function() { 
    95           dotclear.checkboxesHelpers(this,undefined,'#form-blogs input[type="checkbox"]','#form-blogs #do-action'); 
    96      }); 
    97      dotclear.condSubmit('#form-blogs input[type="checkbox"]','#form-blogs #do-action'); 
    98      $('#permissions-form').updatePermissionsForm(); 
     104  $('.checkboxes-helpers').each(function() { 
     105    dotclear.checkboxesHelpers(this, undefined, '#form-blogs input[type="checkbox"]', '#form-blogs #do-action'); 
     106  }); 
     107  dotclear.condSubmit('#form-blogs input[type="checkbox"]', '#form-blogs #do-action'); 
     108  $('#permissions-form').updatePermissionsForm(); 
    99109}); 
  • admin/js/color-picker.js

    r2566 r3706  
     1/*global $, jQuery */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      $('.colorpicker').colorPicker(); 
     5  $('.colorpicker').colorPicker(); 
    36}); 
    47 
    58jQuery.fn.colorPicker = function() { 
    6      $(this).each(function() { 
    7           var colbox, f; 
    8           var colbox = $('#jquery-colorpicker')[0]; 
     9  $(this).each(function() { 
     10    var colbox, f; 
     11    colbox = $('#jquery-colorpicker')[0]; 
    912 
    10           if (colbox == undefined) { 
    11                colbox = document.createElement('div'); 
    12                colbox.id = 'jquery-colorpicker'; 
    13                colbox.linkedto = null; 
     13    if (colbox == undefined) { 
     14      colbox = document.createElement('div'); 
     15      colbox.id = 'jquery-colorpicker'; 
     16      colbox.linkedto = null; 
    1417 
    15                $(colbox).addClass('color-color-picker'); 
    16                $(colbox).css({display: 'none', position: 'absolute'}); 
    17                $('body').append(colbox); 
    18           } 
    19           f = $.farbtastic(colbox); 
    20           f.linkTo(this); 
     18      $(colbox).addClass('color-color-picker'); 
     19      $(colbox).css({ 
     20        display: 'none', 
     21        position: 'absolute' 
     22      }); 
     23      $('body').append(colbox); 
     24    } 
     25    f = $.farbtastic(colbox); 
     26    f.linkTo(this); 
    2127 
    22           var handler = $(document.createElement('img')); 
    23           handler.attr('src','images/picker.png'); 
    24           handler.attr('alt',''); 
     28    var handler = $(document.createElement('img')); 
     29    handler.attr('src', 'images/picker.png'); 
     30    handler.attr('alt', ''); 
    2531 
    26           var span = $(document.createElement('span')); 
     32    var span = $(document.createElement('span')); 
    2733 
    28           if ($(this).css('position') == 'absolute') { 
    29                span.css('position','absolute'); 
    30                span.css('top',$(this).css('top')); 
    31                span.css('left',$(this).css('left')); 
    32                $(this).css('position','static'); 
    33           } else { 
    34                span.css('position','relative'); 
    35           } 
    36           span.css('display','inline-block'); 
     34    if ($(this).css('position') == 'absolute') { 
     35      span.css('position', 'absolute'); 
     36      span.css('top', $(this).css('top')); 
     37      span.css('left', $(this).css('left')); 
     38      $(this).css('position', 'static'); 
     39    } else { 
     40      span.css('position', 'relative'); 
     41    } 
     42    span.css('display', 'inline-block'); 
     43    span.css('padding', '0 5px 0 0'); 
     44    $(this).wrap(span); 
     45    $(this).after(handler); 
    3746 
    38           /*ligne supprimée car elle ne fait pas le calcul 
    39           du width de l'input et ça fout la merde */ 
    40           //span.css('width',($(this).width()+12)+'px'); 
    41           span.css('padding','0 5px 0 0'); 
    42           $(this).wrap(span); 
    43           $(this).after(handler); 
     47    handler.css({ 
     48      position: 'absolute', 
     49      top: 3, 
     50    }); 
    4451 
    45           var offset = $(this).offset(); 
    46           handler.css({ 
    47                position: 'absolute', 
    48                top: 3, 
    49                /* la largeur du span n'étant pas calculée 
    50                right: 0 crée un affichage pourri. On vire. */ 
    51                //right: 0 
    52           }); 
     52    handler.css({ 
     53      cursor: 'default' 
     54    }); 
    5355 
    54           handler.css({cursor: 'default'}); 
     56    var This = this; 
     57    handler.click(function() { 
     58      if ($(colbox).css('display') == 'none' || this != colbox.linkedto) { 
     59        f.linkTo(This); 
     60        This.focus(); 
     61        var offset = $(This).offset(); 
     62        $(colbox).css({ 
     63          zIndex: 1000, 
     64          top: offset.top + $(this).height() + 5, 
     65          left: offset.left 
     66        }); 
     67        if (document.all) { 
     68          $('select').hide(); 
     69        } 
     70        $(colbox).show(); 
     71        colbox.linkedto = this; 
    5572 
    56           var This = this; 
    57           handler.click(function() { 
    58                if ($(colbox).css('display') == 'none' || this != colbox.linkedto) { 
    59                     f.linkTo(This); 
    60                     This.focus(); 
    61                     var offset = $(This).offset(); 
    62                     $(colbox).css({ 
    63                          zIndex: 1000, 
    64                          top: offset.top + $(this).height() + 5, 
    65                          left: offset.left 
    66                     }); 
    67                     if (document.all) { $('select').hide(); } 
    68                     $(colbox).show(); 
    69                     colbox.linkedto = this; 
    70  
    71                } else { 
    72                     $(colbox).hide(); 
    73                     if (document.all) { $('select').show(); } 
    74                     colbox.linkedto = null; 
    75                } 
    76           }); 
    77           $(this).blur(function() { 
    78                $(colbox).hide(); 
    79                if (document.all) { $('select').show(); } 
    80           }); 
    81      }); 
    82      return this; 
     73      } else { 
     74        $(colbox).hide(); 
     75        if (document.all) { 
     76          $('select').show(); 
     77        } 
     78        colbox.linkedto = null; 
     79      } 
     80    }); 
     81    $(this).blur(function() { 
     82      $(colbox).hide(); 
     83      if (document.all) { 
     84        $('select').show(); 
     85      } 
     86    }); 
     87  }); 
     88  return this; 
    8389}; 
  • admin/js/common.js

    r3701 r3706  
     1/*global $, jQuery, dotclear_htmlFontSize */ 
     2/*exported chainHandler */ 
     3'use strict'; 
     4 
    15/* Set some CSS variables here 
    26-------------------------------------------------------- */ 
     
    1418    }; 
    1519  })(handlerName in obj ? obj[handlerName] : null); 
    16 }; 
     20} 
    1721/* jQuery extensions 
    1822-------------------------------------------------------- */ 
     
    6266    return true; 
    6367  }); 
    64 } 
     68}; 
    6569jQuery.fn.toggleWithLegend = function(target, s) { 
    6670  var defaults = { 
     
    141145            'value': 1, 
    142146            xd_check: dotclear.nonce 
    143           }, function(data) {}); 
     147          }, function() {}); 
    144148        } else { 
    145149          jQuery.post('services.php', { 
     
    148152            'value': 0, 
    149153            xd_check: dotclear.nonce 
    150           }, function(data) {}); 
     154          }, function() {}); 
    151155        } 
    152156        jQuery.cookie(p.user_pref, '', { 
     
    162166}; 
    163167(function($) { 
    164   'use strict'; 
    165168  $.expandContent = function(opts) { 
    166169    var defaults = {}; 
     
    175178      singleExpander(this); 
    176179    }); 
    177   } 
     180  }; 
    178181  var singleExpander = function singleExpander(line) { 
    179182    $('<input type="image" src="' + dotclear.img_plus_src + '" alt="' + dotclear.img_plus_alt + '"/>').click(function(e) { 
     
    211214    } 
    212215    return action; 
    213   } 
     216  }; 
    214217})(jQuery); 
    215218jQuery.fn.helpViewer = function() { 
     
    281284  // listen for scroll 
    282285  var peInPage = $('#help-button').offset().top; 
    283   $('#help-button').addClass("floatable"); 
     286  $('#help-button').addClass('floatable'); 
    284287  var peInFloat = $('#help-button').offset().top - $(window).scrollTop(); 
    285   $('#help-button').removeClass("floatable"); 
     288  $('#help-button').removeClass('floatable'); 
    286289  $(window).scroll(function() { 
    287290    if ($(window).scrollTop() >= peInPage - peInFloat) { 
    288       $('#help-button').addClass("floatable"); 
    289     } else { 
    290       $('#help-button').removeClass("floatable"); 
     291      $('#help-button').addClass('floatable'); 
     292    } else { 
     293      $('#help-button').removeClass('floatable'); 
    291294    } 
    292295  }); 
     
    313316    } 
    314317    // Set initial state 
    315     submitButt.attr("disabled", !checkboxes.is(":checked")); 
    316     if (!checkboxes.is(":checked")) { 
     318    submitButt.attr('disabled', !checkboxes.is(':checked')); 
     319    if (!checkboxes.is(':checked')) { 
    317320      submitButt.addClass('disabled'); 
    318321    } else { 
     
    321324    checkboxes.click(function() { 
    322325      // Update target state 
    323       submitButt.attr("disabled", !checkboxes.is(":checked")); 
    324       if (!checkboxes.is(":checked")) { 
     326      submitButt.attr('disabled', !checkboxes.is(':checked')); 
     327      if (!checkboxes.is(':checked')) { 
    325328        submitButt.addClass('disabled'); 
    326329      } else { 
     
    476479    legend_click: true, 
    477480    speed: 100 
    478   } 
     481  }; 
    479482  $('#blog-menu h3:first').toggleWithLegend($('#blog-menu ul:first'), $.extend({ 
    480483    user_pref: 'dc_blog_menu' 
     
    503506  // Password 
    504507  $('form:has(input[type=password][name=your_pwd])').submit(function() { 
    505     var e = this.elements['your_pwd']; 
     508    var e = this.elements.your_pwd; 
    506509    if (e.value == '') { 
    507510      $(e).addClass('missing').focusout(function() { 
    508         $(this).removeClass('missing') 
     511        $(this).removeClass('missing'); 
    509512      }); 
    510513      e.focus(); 
     
    526529      this.title = this.innerText; 
    527530    } 
    528   }) 
     531  }); 
    529532  // Advanced users 
    530533  if (dotclear.hideMoreInfo) { 
  • admin/js/confirm-close.js

    r3449 r3706  
     1/*global chainHandler */ 
     2'use strict'; 
     3 
    14function confirmClose() { 
    2  
    3      if (arguments.length > 0) { 
    4           for (var i = 0; i < arguments.length; i++) { 
    5                this.forms_id.push(arguments[i]); 
    6           } 
    7      } 
    8 }; 
     5  if (arguments.length > 0) { 
     6    for (var i = 0; i < arguments.length; i++) { 
     7      this.forms_id.push(arguments[i]); 
     8    } 
     9  } 
     10} 
    911 
    1012confirmClose.prototype = { 
    11      prompt: 'You have unsaved changes.', 
    12      forms_id: new Array(), 
    13      forms: new Array(), 
    14      formSubmit: false, 
     13  prompt: 'You have unsaved changes.', 
     14  forms_id: [], 
     15  forms: [], 
     16  formSubmit: false, 
    1517 
    16      getCurrentForms: function() { 
    17           // Store current form's element's values 
     18  getCurrentForms: function() { 
     19    // Store current form's element's values 
    1820 
    19           var formsInPage = this.getForms(); 
    20           var f, e; 
    21           var This = this; 
    22           this.forms = new Array(); 
    23           for (var i = 0; i < formsInPage.length; i++) { 
    24                f = formsInPage[i]; 
    25                var tmpForm = new Array(); 
    26                for (var j = 0; j < f.elements.length; j++) { 
    27                     e = this.getFormElementValue(f[j]); 
    28                     if (e != undefined) { 
    29                          tmpForm.push(e); 
    30                     } 
    31                } 
    32                this.forms.push(tmpForm); 
     21    var formsInPage = this.getForms(); 
     22    var f, e; 
     23    var This = this; 
     24    this.forms = []; 
     25    for (var i = 0; i < formsInPage.length; i++) { 
     26      f = formsInPage[i]; 
     27      var tmpForm = []; 
     28      for (var j = 0; j < f.elements.length; j++) { 
     29        e = this.getFormElementValue(f[j]); 
     30        if (e != undefined) { 
     31          tmpForm.push(e); 
     32        } 
     33      } 
     34      this.forms.push(tmpForm); 
    3335 
    34                chainHandler(f, 'onsubmit', function() { 
    35                     This.formSubmit = true; 
    36                }); 
    37           } 
    38      }, 
     36      chainHandler(f, 'onsubmit', function() { 
     37        This.formSubmit = true; 
     38      }); 
     39    } 
     40  }, 
    3941 
    40      compareForms: function() { 
    41           // Compare current form's element's values to their original values 
    42           // Return false if any difference, else true 
     42  compareForms: function() { 
     43    // Compare current form's element's values to their original values 
     44    // Return false if any difference, else true 
    4345 
    44           if (this.forms.length == 0) { 
    45                return true; 
    46           } 
     46    if (this.forms.length == 0) { 
     47      return true; 
     48    } 
    4749 
    48           var formsInPage = this.getForms(); 
    49           var f, e; 
    50           for (var i = 0; i < formsInPage.length; i++) { 
    51                f = formsInPage[i]; 
    52                var tmpForm = new Array(); 
    53                for (var j = 0; j < f.elements.length; j++) { 
    54                     e = this.getFormElementValue(f[j]); 
    55                     if (e != undefined) { 
    56                          tmpForm.push(e); 
    57                     } 
    58                } 
    59                for (var j = 0; j < this.forms[i].length; j++) { 
    60                     if (this.forms[i][j] != tmpForm[j]) { 
    61                          return false; 
    62                     } 
    63                } 
    64           } 
     50    var formsInPage = this.getForms(); 
     51    var f, e, i, j; 
     52    for (i = 0; i < formsInPage.length; i++) { 
     53      f = formsInPage[i]; 
     54      var tmpForm = []; 
     55      for (j = 0; j < f.elements.length; j++) { 
     56        e = this.getFormElementValue(f[j]); 
     57        if (e != undefined) { 
     58          tmpForm.push(e); 
     59        } 
     60      } 
     61      for (j = 0; j < this.forms[i].length; j++) { 
     62        if (this.forms[i][j] != tmpForm[j]) { 
     63          return false; 
     64        } 
     65      } 
     66    } 
    6567 
    66           return true; 
    67      }, 
     68    return true; 
     69  }, 
    6870 
    69      getForms: function() { 
    70           // Get current list of forms as HTMLCollection(s) 
     71  getForms: function() { 
     72    // Get current list of forms as HTMLCollection(s) 
    7173 
    72           if (!document.getElementsByTagName || !document.getElementById) { 
    73                return new Array(); 
    74           } 
     74    if (!document.getElementsByTagName || !document.getElementById) { 
     75      return []; 
     76    } 
    7577 
    76           if (this.forms_id.length > 0) { 
    77                var res = new Array(); 
    78                var f; 
    79                for (var i = 0; i < this.forms_id.length; i++) { 
    80                     f = document.getElementById(this.forms_id[i]); 
    81                     if (f != undefined) { 
    82                          res.push(f); 
    83                     } 
    84                } 
    85                return res; 
    86           } else { 
    87                return document.getElementsByTagName('form'); 
    88           } 
     78    if (this.forms_id.length > 0) { 
     79      var res = []; 
     80      var f; 
     81      for (var i = 0; i < this.forms_id.length; i++) { 
     82        f = document.getElementById(this.forms_id[i]); 
     83        if (f != undefined) { 
     84          res.push(f); 
     85        } 
     86      } 
     87      return res; 
     88    } else { 
     89      return document.getElementsByTagName('form'); 
     90    } 
    8991 
    90           return new Array(); 
    91      }, 
     92    return []; 
     93  }, 
    9294 
    93      getFormElementValue: function(e) { 
    94           // Return current value of an form element 
     95  getFormElementValue: function(e) { 
     96    // Return current value of an form element 
    9597 
    96           if (e == undefined) { 
    97                // Unknown object 
    98                return undefined; 
    99           } 
    100           if (e.type != undefined && e.type == 'button') { 
    101                // Ignore button element 
    102                return undefined; 
    103           } 
    104           if (e.classList.contains('meta-helper') || e.classList.contains('checkbox-helper')) { 
    105                // Ignore some application helper element 
    106                return undefined; 
    107           } 
    108           if (e.type != undefined && e.type == 'radio') { 
    109                // Return actual radio button value if selected, else null 
    110                return this.getFormRadioValue(e); 
    111           } else if (e.type != undefined && e.type == 'checkbox') { 
    112                // Return actual checkbox button value if checked, else null 
    113                return this.getFormCheckValue(e); 
    114           } else if (e.type != undefined && e.type == 'password') { 
    115                // Ignore password element 
    116                return null; 
    117           } else if (e.value != undefined) { 
    118                // Return element value if not undefined 
    119                return e.value; 
    120           } else { 
    121                // Every other case, return null 
    122                return null; 
    123           } 
    124      }, 
     98    if (e == undefined) { 
     99      // Unknown object 
     100      return undefined; 
     101    } 
     102    if (e.type != undefined && e.type == 'button') { 
     103      // Ignore button element 
     104      return undefined; 
     105    } 
     106    if (e.classList.contains('meta-helper') || e.classList.contains('checkbox-helper')) { 
     107      // Ignore some application helper element 
     108      return undefined; 
     109    } 
     110    if (e.type != undefined && e.type == 'radio') { 
     111      // Return actual radio button value if selected, else null 
     112      return this.getFormRadioValue(e); 
     113    } else if (e.type != undefined && e.type == 'checkbox') { 
     114      // Return actual checkbox button value if checked, else null 
     115      return this.getFormCheckValue(e); 
     116    } else if (e.type != undefined && e.type == 'password') { 
     117      // Ignore password element 
     118      return null; 
     119    } else if (e.value != undefined) { 
     120      // Return element value if not undefined 
     121      return e.value; 
     122    } else { 
     123      // Every other case, return null 
     124      return null; 
     125    } 
     126  }, 
    125127 
    126      getFormCheckValue: function(e) { 
    127           if (e.checked) { 
    128                return e.value; 
    129           } 
    130           return null; 
    131      }, 
     128  getFormCheckValue: function(e) { 
     129    if (e.checked) { 
     130      return e.value; 
     131    } 
     132    return null; 
     133  }, 
    132134 
    133      getFormRadioValue: function(e) { 
    134           for (var i = 0; i < e.length; i++) { 
    135                if (e[i].checked) { 
    136                     return e[i].value; 
    137                } else { 
    138                     return null; 
    139                } 
    140           } 
    141           return null; 
    142      } 
     135  getFormRadioValue: function(e) { 
     136    for (var i = 0; i < e.length; i++) { 
     137      if (e[i].checked) { 
     138        return e[i].value; 
     139      } else { 
     140        return null; 
     141      } 
     142    } 
     143    return null; 
     144  } 
    143145}; 
    144146 
     
    146148 
    147149chainHandler(window, 'onload', function() { 
    148      confirmClosePage.getCurrentForms(); 
     150  confirmClosePage.getCurrentForms(); 
    149151}); 
    150152 
    151153chainHandler(window, 'onbeforeunload', function(event_) { 
    152      if (event_ == undefined && window.event) { 
    153           event_ = window.event; 
    154      } 
     154  if (event_ == undefined && window.event) { 
     155    event_ = window.event; 
     156  } 
    155157 
    156      if (!confirmClosePage.formSubmit && !confirmClosePage.compareForms()) { 
    157           event_.returnValue = confirmClosePage.prompt; 
    158           return confirmClosePage.prompt; 
    159      } 
    160      return false; 
     158  if (!confirmClosePage.formSubmit && !confirmClosePage.compareForms()) { 
     159    event_.returnValue = confirmClosePage.prompt; 
     160    return confirmClosePage.prompt; 
     161  } 
     162  return false; 
    161163}); 
  • admin/js/date-picker.js

    r3525 r3706  
    1 function datePicker(target) 
    2 { 
    3      if (!document.getElementById) { return; } 
    4  
    5      if (!target || target.nodeName.toLowerCase() != 'input') { 
    6           return; 
    7      } 
    8  
    9      this.target = target; 
    10      this.oTable = document.createElement('table'); 
    11      this.oBody = document.createElement('tbody'); 
    12      this.oDates = new Array(); 
    13      this.oMonth = document.createElement('span'); 
    14      this.oYear = document.createElement('span'); 
    15      this.oHour = document.createElement('input'); 
    16      this.oMinute = document.createElement('input'); 
    17      this.oTable.id = 'dc_datepicker_'+target.id; 
    18      this.oTable.className = 'date-picker'; 
    19  
    20      var cur = 1; 
    21      var oRow, oHeading, oSpan; 
    22  
    23      // Set title 
    24      oRow = document.createElement('tr'); 
    25  
    26      // Month block 
    27      oHeading = document.createElement('th'); 
    28      oHeading.colSpan = 4; 
    29      oHeading.className = 'date-picker-month'; 
    30  
    31      var nav = document.createElement('span'); 
    32      nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
    33      nav.fn = this.changeMonth; 
    34      nav.obj = this; 
    35      nav.onclick = function() { this.fn.call(this.obj,-1); }; 
    36      nav.className = 'date-picker-control'; 
    37      oHeading.appendChild(nav); 
    38  
    39      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    40  
    41      nav = document.createElement('span'); 
    42      nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
    43      nav.fn = this.changeMonth; 
    44      nav.obj = this; 
    45      nav.onclick = function() { this.fn.call(this.obj,+1); }; 
    46      nav.className = 'date-picker-control'; 
    47      oHeading.appendChild(nav); 
    48  
    49      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    50  
    51      oHeading.appendChild(this.oMonth); 
    52  
    53      oRow.appendChild(oHeading); 
    54  
    55      // Year block 
    56      oHeading = document.createElement('th'); 
    57      oHeading.colSpan = 3; 
    58      oHeading.className = 'date-picker-year'; 
    59  
    60      oHeading.appendChild(this.oYear); 
    61  
    62      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    63  
    64      nav = document.createElement('span'); 
    65      nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
    66      nav.fn = this.changeYear; 
    67      nav.obj = this; 
    68      nav.onclick = function() { this.fn.call(this.obj,-1); }; 
    69      nav.className = 'date-picker-control'; 
    70      oHeading.appendChild(nav); 
    71  
    72      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    73  
    74      nav = document.createElement('span'); 
    75      nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
    76      nav.fn = this.changeYear; 
    77      nav.obj = this; 
    78      nav.onclick = function() { this.fn.call(this.obj,+1); }; 
    79      nav.className = 'date-picker-control'; 
    80      oHeading.appendChild(nav); 
    81  
    82      oRow.appendChild(oHeading); 
    83  
    84      this.oBody.appendChild(oRow); 
    85  
    86      // Create legend 
    87      oRow = document.createElement('tr'); 
    88      var cday; 
    89      for (i=0; i<this.days.length; i++) { 
    90           cday = this.days[i].substring(0,1).toUpperCase(); 
    91           oHeading = document.createElement('th'); 
    92           oHeading.appendChild(document.createTextNode(cday)); 
    93           oHeading.setAttribute('title',this.days[i]); 
    94           oRow.appendChild(oHeading); 
    95      } 
    96      this.oBody.appendChild(oRow); 
    97  
    98      // Create 6 rows of 7 cols for days 
    99      for (var i=0; i<6; i++) { 
    100           oRow = document.createElement('tr'); 
    101  
    102           for (var j=0; j<7; j++) { 
    103                this.oDates[cur] = document.createElement('td'); 
    104                this.oDates[cur].appendChild(document.createTextNode( 
    105                     String.fromCharCode(160))); 
    106                oRow.appendChild(this.oDates[cur]); 
    107                cur++; 
    108           } 
    109  
    110           this.oBody.appendChild(oRow); 
    111      } 
    112  
    113      // Time controls 
    114      oRow = document.createElement('tr'); 
    115  
    116      oHeading = document.createElement('th'); 
    117      oHeading.className = 'date-picker-control'; 
    118      oHeading.appendChild(document.createTextNode('!')); 
    119      oHeading.setAttribute('title',this.now_msg); 
    120      oHeading.fn = this.sendNow; 
    121      oHeading.obj = this; 
    122      oHeading.onclick = function() { this.fn.call(this.obj); }; 
    123  
    124      oRow.appendChild(oHeading); 
    125  
    126      oHeading = document.createElement('th'); 
    127      oHeading.colSpan = 5; 
    128  
    129      oSpan = document.createElement('span'); 
    130      oSpan.className = 'date-picker-control'; 
    131      oSpan.appendChild(document.createTextNode('-')); 
    132      oSpan.fn = this.changeHour; 
    133      oSpan.obj = this; 
    134      oSpan.onclick = function() { this.fn.call(this.obj,-1); }; 
    135      oHeading.appendChild(oSpan); 
    136      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    137      oSpan = document.createElement('span'); 
    138      oSpan.className = 'date-picker-control'; 
    139      oSpan.appendChild(document.createTextNode('+')); 
    140      oSpan.fn = this.changeHour; 
    141      oSpan.obj = this; 
    142      oSpan.onclick = function() { this.fn.call(this.obj,+1); }; 
    143      oHeading.appendChild(oSpan); 
    144      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    145  
    146      this.oHour.size = 2; 
    147      oHeading.appendChild(this.oHour); 
    148  
    149      oHeading.appendChild(document.createTextNode(' : ')); 
    150  
    151      this.oMinute.size = 2; 
    152      oHeading.appendChild(this.oMinute); 
    153  
    154      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    155      oSpan = document.createElement('span'); 
    156      oSpan.className = 'date-picker-control'; 
    157      oSpan.appendChild(document.createTextNode('-')); 
    158      oSpan.fn = this.changeMinute; 
    159      oSpan.obj = this; 
    160      oSpan.onclick = function() { this.fn.call(this.obj,-1); }; 
    161      oHeading.appendChild(oSpan); 
    162      oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
    163      oSpan = document.createElement('span'); 
    164      oSpan.className = 'date-picker-control'; 
    165      oSpan.appendChild(document.createTextNode('+')); 
    166      oSpan.fn = this.changeMinute; 
    167      oSpan.obj = this; 
    168      oSpan.onclick = function() { this.fn.call(this.obj,+1); }; 
    169  
    170      oHeading.appendChild(oSpan); 
    171  
    172      oRow.appendChild(oHeading); 
    173  
    174      // Close control 
    175      oHeading = document.createElement('th'); 
    176      oHeading.className = 'date-picker-control'; 
    177      oHeading.appendChild(document.createTextNode('x')); 
    178      oHeading.setAttribute('title',this.close_msg); 
    179      oHeading.fn = this.close; 
    180      oHeading.obj = this; 
    181      oHeading.onclick = function() { this.fn.call(this.obj); }; 
    182  
    183      oRow.appendChild(oHeading); 
    184  
    185      this.oBody.appendChild(oRow); 
     1'use strict'; 
     2 
     3function datePicker(target) { 
     4  if (!document.getElementById) { 
     5    return; 
     6  } 
     7 
     8  if (!target || target.nodeName.toLowerCase() != 'input') { 
     9    return; 
     10  } 
     11 
     12  this.target = target; 
     13  this.oTable = document.createElement('table'); 
     14  this.oBody = document.createElement('tbody'); 
     15  this.oDates = []; 
     16  this.oMonth = document.createElement('span'); 
     17  this.oYear = document.createElement('span'); 
     18  this.oHour = document.createElement('input'); 
     19  this.oMinute = document.createElement('input'); 
     20  this.oTable.id = 'dc_datepicker_' + target.id; 
     21  this.oTable.className = 'date-picker'; 
     22 
     23  var cur = 1; 
     24  var oRow, oHeading, oSpan; 
     25 
     26  // Set title 
     27  oRow = document.createElement('tr'); 
     28 
     29  // Month block 
     30  oHeading = document.createElement('th'); 
     31  oHeading.colSpan = 4; 
     32  oHeading.className = 'date-picker-month'; 
     33 
     34  var nav = document.createElement('span'); 
     35  nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
     36  nav.fn = this.changeMonth; 
     37  nav.obj = this; 
     38  nav.onclick = function() { 
     39    this.fn.call(this.obj, -1); 
     40  }; 
     41  nav.className = 'date-picker-control'; 
     42  oHeading.appendChild(nav); 
     43 
     44  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     45 
     46  nav = document.createElement('span'); 
     47  nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
     48  nav.fn = this.changeMonth; 
     49  nav.obj = this; 
     50  nav.onclick = function() { 
     51    this.fn.call(this.obj, +1); 
     52  }; 
     53  nav.className = 'date-picker-control'; 
     54  oHeading.appendChild(nav); 
     55 
     56  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     57 
     58  oHeading.appendChild(this.oMonth); 
     59 
     60  oRow.appendChild(oHeading); 
     61 
     62  // Year block 
     63  oHeading = document.createElement('th'); 
     64  oHeading.colSpan = 3; 
     65  oHeading.className = 'date-picker-year'; 
     66 
     67  oHeading.appendChild(this.oYear); 
     68 
     69  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     70 
     71  nav = document.createElement('span'); 
     72  nav.appendChild(document.createTextNode(String.fromCharCode(171))); 
     73  nav.fn = this.changeYear; 
     74  nav.obj = this; 
     75  nav.onclick = function() { 
     76    this.fn.call(this.obj, -1); 
     77  }; 
     78  nav.className = 'date-picker-control'; 
     79  oHeading.appendChild(nav); 
     80 
     81  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     82 
     83  nav = document.createElement('span'); 
     84  nav.appendChild(document.createTextNode(String.fromCharCode(187))); 
     85  nav.fn = this.changeYear; 
     86  nav.obj = this; 
     87  nav.onclick = function() { 
     88    this.fn.call(this.obj, +1); 
     89  }; 
     90  nav.className = 'date-picker-control'; 
     91  oHeading.appendChild(nav); 
     92 
     93  oRow.appendChild(oHeading); 
     94 
     95  this.oBody.appendChild(oRow); 
     96 
     97  // Create legend 
     98  oRow = document.createElement('tr'); 
     99  var cday; 
     100  for (i = 0; i < this.days.length; i++) { 
     101    cday = this.days[i].substring(0, 1).toUpperCase(); 
     102    oHeading = document.createElement('th'); 
     103    oHeading.appendChild(document.createTextNode(cday)); 
     104    oHeading.setAttribute('title', this.days[i]); 
     105    oRow.appendChild(oHeading); 
     106  } 
     107  this.oBody.appendChild(oRow); 
     108 
     109  // Create 6 rows of 7 cols for days 
     110  for (var i = 0; i < 6; i++) { 
     111    oRow = document.createElement('tr'); 
     112 
     113    for (var j = 0; j < 7; j++) { 
     114      this.oDates[cur] = document.createElement('td'); 
     115      this.oDates[cur].appendChild(document.createTextNode( 
     116        String.fromCharCode(160))); 
     117      oRow.appendChild(this.oDates[cur]); 
     118      cur++; 
     119    } 
     120 
     121    this.oBody.appendChild(oRow); 
     122  } 
     123 
     124  // Time controls 
     125  oRow = document.createElement('tr'); 
     126 
     127  oHeading = document.createElement('th'); 
     128  oHeading.className = 'date-picker-control'; 
     129  oHeading.appendChild(document.createTextNode('!')); 
     130  oHeading.setAttribute('title', this.now_msg); 
     131  oHeading.fn = this.sendNow; 
     132  oHeading.obj = this; 
     133  oHeading.onclick = function() { 
     134    this.fn.call(this.obj); 
     135  }; 
     136 
     137  oRow.appendChild(oHeading); 
     138 
     139  oHeading = document.createElement('th'); 
     140  oHeading.colSpan = 5; 
     141 
     142  oSpan = document.createElement('span'); 
     143  oSpan.className = 'date-picker-control'; 
     144  oSpan.appendChild(document.createTextNode('-')); 
     145  oSpan.fn = this.changeHour; 
     146  oSpan.obj = this; 
     147  oSpan.onclick = function() { 
     148    this.fn.call(this.obj, -1); 
     149  }; 
     150  oHeading.appendChild(oSpan); 
     151  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     152  oSpan = document.createElement('span'); 
     153  oSpan.className = 'date-picker-control'; 
     154  oSpan.appendChild(document.createTextNode('+')); 
     155  oSpan.fn = this.changeHour; 
     156  oSpan.obj = this; 
     157  oSpan.onclick = function() { 
     158    this.fn.call(this.obj, +1); 
     159  }; 
     160  oHeading.appendChild(oSpan); 
     161  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     162 
     163  this.oHour.size = 2; 
     164  oHeading.appendChild(this.oHour); 
     165 
     166  oHeading.appendChild(document.createTextNode(' : ')); 
     167 
     168  this.oMinute.size = 2; 
     169  oHeading.appendChild(this.oMinute); 
     170 
     171  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     172  oSpan = document.createElement('span'); 
     173  oSpan.className = 'date-picker-control'; 
     174  oSpan.appendChild(document.createTextNode('-')); 
     175  oSpan.fn = this.changeMinute; 
     176  oSpan.obj = this; 
     177  oSpan.onclick = function() { 
     178    this.fn.call(this.obj, -1); 
     179  }; 
     180  oHeading.appendChild(oSpan); 
     181  oHeading.appendChild(document.createTextNode(String.fromCharCode(160))); 
     182  oSpan = document.createElement('span'); 
     183  oSpan.className = 'date-picker-control'; 
     184  oSpan.appendChild(document.createTextNode('+')); 
     185  oSpan.fn = this.changeMinute; 
     186  oSpan.obj = this; 
     187  oSpan.onclick = function() { 
     188    this.fn.call(this.obj, +1); 
     189  }; 
     190 
     191  oHeading.appendChild(oSpan); 
     192 
     193  oRow.appendChild(oHeading); 
     194 
     195  // Close control 
     196  oHeading = document.createElement('th'); 
     197  oHeading.className = 'date-picker-control'; 
     198  oHeading.appendChild(document.createTextNode('x')); 
     199  oHeading.setAttribute('title', this.close_msg); 
     200  oHeading.fn = this.close; 
     201  oHeading.obj = this; 
     202  oHeading.onclick = function() { 
     203    this.fn.call(this.obj); 
     204  }; 
     205 
     206  oRow.appendChild(oHeading); 
     207 
     208  this.oBody.appendChild(oRow); 
     209} 
     210 
     211datePicker.prototype = { 
     212  year: 0, 
     213  month: 0, 
     214  day: 0, 
     215  hour: 0, 
     216  minute: 0, 
     217 
     218  img_src: '', 
     219  img_top: '0.2em', 
     220  now_msg: 'now', 
     221  close_msg: 'close', 
     222 
     223  days: new Array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 
     224    'Saturday', 'Sunday'), 
     225 
     226  months: new Array('January', 'February', 'March', 'April', 'May', 'June', 
     227    'July', 'August', 'September', 'October', 'November', 'December'), 
     228 
     229  setDate: function() { 
     230    if (this.numberOfDays() < this.day) { 
     231      this.day = this.numberOfDays(); 
     232    } 
     233 
     234    while (this.oYear.hasChildNodes()) { 
     235      this.oYear.removeChild(this.oYear.firstChild); 
     236    } 
     237    this.oYear.appendChild(document.createTextNode(this.year)); 
     238 
     239    while (this.oMonth.hasChildNodes()) { 
     240      this.oMonth.removeChild(this.oMonth.firstChild); 
     241    } 
     242    this.oMonth.appendChild(document.createTextNode( 
     243      this.months[this.month - 1])); 
     244 
     245    var firstDay = this.firstDay(); 
     246    var nbDays = this.numberOfDays(); 
     247 
     248    // Empty days 
     249    for (var i = 1; i <= 42; i++) { 
     250      while (this.oDates[i].hasChildNodes()) { 
     251        this.oDates[i].removeChild(this.oDates[i].firstChild); 
     252      } 
     253      this.oDates[i].appendChild(document.createTextNode('-')); 
     254      this.oDates[i].className = ''; 
     255      this.oDates[i].onclick = function() { 
     256        return; 
     257      }; 
     258    } 
     259 
     260    // Insert days from the first day to the last 
     261    for (i = 1; i <= nbDays; i++) { 
     262      var j = firstDay + i - 1; 
     263 
     264      while (this.oDates[j].hasChildNodes()) { 
     265        this.oDates[j].removeChild(this.oDates[j].firstChild); 
     266      } 
     267 
     268      this.oDates[j].appendChild(document.createTextNode(i)); 
     269      this.oDates[j].index = i; 
     270      this.oDates[j].fn = this.sendDate; 
     271      this.oDates[j].obj = this; 
     272      this.oDates[j].onclick = function() { 
     273        this.fn.call(this.obj, this.index); 
     274      }; 
     275      if (i == this.day) { 
     276        this.oDates[j].className = 'date-picker-today'; 
     277      } else { 
     278        this.oDates[j].className = 'date-picker-day'; 
     279      } 
     280    } 
     281 
     282    // Set time 
     283    this.setHour(this.hour); 
     284    this.setMinute(this.minute); 
     285  }, 
     286 
     287  setHour: function(h) { 
     288    if (h < 0) { 
     289      h = 23; 
     290    } 
     291    if (h > 23) { 
     292      h = 0; 
     293    } 
     294    if (h < 10) { 
     295      h = '0' + h; 
     296    } 
     297 
     298    this.hour = h * 1; 
     299    this.oHour.value = h; 
     300  }, 
     301 
     302  setMinute: function(m) { 
     303    if (m < 0) { 
     304      m = 59; 
     305    } 
     306    if (m > 59) { 
     307      m = 0; 
     308    } 
     309    if (m < 10) { 
     310      m = '0' + m; 
     311    } 
     312 
     313    this.minute = m * 1; 
     314    this.oMinute.value = m; 
     315  }, 
     316 
     317  changeMonth: function(dir) { 
     318    var m = this.month; 
     319    m = m + dir; 
     320 
     321    if (m > 12) { 
     322      this.month = 1; 
     323      this.year++; 
     324    } else if (m < 1) { 
     325      this.month = 12; 
     326      this.year--; 
     327    } else { 
     328      this.month = m; 
     329    } 
     330 
     331    this.setDate(); 
     332  }, 
     333 
     334  changeYear: function(dir) { 
     335    this.year = this.year + dir; 
     336    this.setDate(); 
     337  }, 
     338 
     339  changeHour: function(dir) { 
     340    this.setHour(this.hour * 1 + dir); 
     341  }, 
     342 
     343  changeMinute: function(dir) { 
     344    this.setMinute(this.minute * 1 + dir); 
     345  }, 
     346 
     347  sendDate: function(d) { 
     348    var m = this.month; 
     349    var hour = this.oHour.value * 1; 
     350    var minute = this.oMinute.value * 1; 
     351 
     352    if (hour < 0 || hour > 23 || isNaN(hour)) { 
     353      hour = 0; 
     354    } 
     355    if (minute < 0 || minute > 59 || isNaN(minute)) { 
     356      minute = 0; 
     357    } 
     358 
     359    if (m < 10) { 
     360      m = '0' + m; 
     361    } 
     362    if (d < 10) { 
     363      d = '0' + d; 
     364    } 
     365    if (hour < 10) { 
     366      hour = '0' + hour; 
     367    } 
     368    if (minute < 10) { 
     369      minute = '0' + minute; 
     370    } 
     371 
     372    this.target.value = this.year + '-' + m + '-' + d + ' ' + hour + ':' + minute; 
     373    this.close(); 
     374  }, 
     375 
     376  sendNow: function() { 
     377    var dt = new Date(); 
     378    var y = dt.getFullYear(); 
     379    var m = dt.getMonth() + 1; 
     380    var d = dt.getDate(); 
     381    var h = dt.getHours(); 
     382    var i = dt.getMinutes(); 
     383 
     384    if (m < 10) { 
     385      m = '0' + m; 
     386    } 
     387    if (d < 10) { 
     388      d = '0' + d; 
     389    } 
     390    if (h < 10) { 
     391      h = '0' + h; 
     392    } 
     393    if (i < 10) { 
     394      i = '0' + i; 
     395    } 
     396 
     397    this.target.value = y + '-' + m + '-' + d + ' ' + h + ':' + i; 
     398    this.close(); 
     399  }, 
     400 
     401  close: function() { 
     402    document.body.removeChild(this.oTable); 
     403  }, 
     404 
     405  numberOfDays: function() { 
     406    var res = 31; 
     407    if (this.month == 4 || this.month == 6 || this.month == 9 || 
     408      this.month == 11) { 
     409      res = 30; 
     410    } else if (this.month == 2) { 
     411      res = 28; 
     412      if (this.year % 4 == 0 && (this.year % 100 != 0 || 
     413          this.year % 400 == 0)) { 
     414        res = 29; 
     415      } 
     416    } 
     417 
     418    return res; 
     419  }, 
     420 
     421  firstDay: function() { 
     422    var dt = new Date(this.year, this.month - 1, 1); 
     423    var res = dt.getDay(); 
     424 
     425    if (res == 0) { 
     426      res = 7; 
     427    } 
     428 
     429    return res; 
     430  }, 
     431 
     432  show: function() { 
     433    // Parsing target value 
     434    var re = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})/; 
     435    var match = re.exec(this.target.value); 
     436    if (match) { 
     437      this.year = match[1] * 1; 
     438      this.month = match[2] * 1; 
     439      this.day = match[3] * 1; 
     440      this.hour = match[4] * 1; 
     441      this.minute = match[5] * 1; 
     442    } else { 
     443      var dt = new Date(); 
     444      this.year = dt.getFullYear(); 
     445      this.month = dt.getMonth() + 1; 
     446      this.day = dt.getDate(); 
     447      this.hour = dt.getHours(); 
     448      this.minute = dt.getMinutes(); 
     449    } 
     450 
     451    this.oTable.appendChild(this.oBody); 
     452    this.setDate(); 
     453    this.setPosition(); 
     454    document.body.appendChild(this.oTable); 
     455    this.oHour.focus(); 
     456  }, 
     457 
     458  setPosition: function() { 
     459    var t_x = this.findPosX(this.target); 
     460    var t_y = this.findPosY(this.target); 
     461 
     462    this.oTable.style.position = 'absolute'; 
     463    this.oTable.style.zIndex = '100'; 
     464    this.oTable.style.top = t_y + 'px'; 
     465    this.oTable.style.left = t_x + 'px'; 
     466  }, 
     467 
     468  findPosX: function(obj) { 
     469    var curleft = 0; 
     470    if (obj.offsetParent) { 
     471      while (1) { 
     472        curleft += obj.offsetLeft; 
     473        if (!obj.offsetParent) { 
     474          break; 
     475        } 
     476        obj = obj.offsetParent; 
     477      } 
     478    } else if (obj.x) { 
     479      curleft += obj.x; 
     480    } 
     481    return curleft; 
     482  }, 
     483 
     484  findPosY: function(obj) { 
     485    var curtop = 0; 
     486    if (obj.offsetParent) { 
     487      while (1) { 
     488        curtop += obj.offsetTop; 
     489        if (!obj.offsetParent) { 
     490          break; 
     491        } 
     492        obj = obj.offsetParent; 
     493      } 
     494    } else if (obj.y) { 
     495      curtop += obj.y; 
     496    } 
     497    return curtop; 
     498  }, 
     499 
     500  draw: function() { 
     501    var imgE = document.createElement('img'); 
     502    imgE.src = this.img_src; 
     503    imgE.alt = this.img_alt; 
     504    imgE.style.position = 'absolute'; 
     505    imgE.style.top = this.img_top; 
     506    imgE.style.left = (this.target.clientWidth + 4) + 'px'; 
     507    imgE.obj = this; 
     508    imgE.fn = this.show; 
     509    imgE.onclick = function() { 
     510      this.fn.apply(this.obj); 
     511    }; 
     512 
     513    this.target.parentNode.style.position = 'relative'; 
     514    this.target.parentNode.insertBefore(imgE, this.target.nextSibling); 
     515  } 
    186516}; 
    187  
    188 datePicker.prototype = { 
    189      year: 0, 
    190      month: 0, 
    191      day: 0, 
    192      hour: 0, 
    193      minute: 0, 
    194  
    195      img_src: '', 
    196      img_top: '0.2em', 
    197      now_msg: 'now', 
    198      close_msg: 'close', 
    199  
    200      days: new Array('Monday','Tuesday','Wednesday','Thursday','Friday', 
    201      'Saturday','Sunday'), 
    202  
    203      months: new Array('January','February','March','April','May','June', 
    204      'July','August','September','October','November','December'), 
    205  
    206  
    207      setDate: function() { 
    208           if (this.numberOfDays() < this.day) { 
    209                this.day = this.numberOfDays(); 
    210           } 
    211  
    212           while (this.oYear.hasChildNodes()) { 
    213                this.oYear.removeChild(this.oYear.firstChild) 
    214           } 
    215           this.oYear.appendChild(document.createTextNode(this.year)); 
    216  
    217           while (this.oMonth.hasChildNodes()) { 
    218                this.oMonth.removeChild(this.oMonth.firstChild) 
    219           } 
    220           this.oMonth.appendChild(document.createTextNode( 
    221                this.months[this.month-1])); 
    222  
    223           var firstDay = this.firstDay(); 
    224           var nbDays = this.numberOfDays(); 
    225  
    226           // Empty days 
    227           for (var i=1; i<=42; i++) { 
    228                while (this.oDates[i].hasChildNodes()) { 
    229                     this.oDates[i].removeChild(this.oDates[i].firstChild) 
    230                } 
    231                this.oDates[i].appendChild(document.createTextNode('-')); 
    232                this.oDates[i].className = ''; 
    233                this.oDates[i].onclick = function() { return; }; 
    234           } 
    235  
    236           // Insert days from the first day to the last 
    237           for (i=1; i<=nbDays; i++) { 
    238                var j=firstDay+i-1; 
    239  
    240                while (this.oDates[j].hasChildNodes()) { 
    241                     this.oDates[j].removeChild(this.oDates[j].firstChild) 
    242                } 
    243  
    244                this.oDates[j].appendChild(document.createTextNode(i)); 
    245                this.oDates[j].index = i; 
    246                this.oDates[j].fn = this.sendDate; 
    247                this.oDates[j].obj = this; 
    248                this.oDates[j].onclick = function() { this.fn.call(this.obj,this.index); }; 
    249                if (i == this.day) { 
    250                     this.oDates[j].className = 'date-picker-today'; 
    251                } else { 
    252                     this.oDates[j].className = 'date-picker-day'; 
    253                } 
    254           } 
    255  
    256           // Set time 
    257           this.setHour(this.hour); 
    258           this.setMinute(this.minute); 
    259      }, 
    260  
    261      setHour: function(h) { 
    262           if (h < 0) { h = 23; } 
    263           if (h > 23) { h = 0; } 
    264           if (h < 10) { h = '0'+h; } 
    265  
    266           this.hour = h*1; 
    267           this.oHour.value = h; 
    268      }, 
    269  
    270      setMinute: function(m) { 
    271           if (m < 0) { m = 59; } 
    272           if (m > 59) { m = 0; } 
    273           if (m < 10) { m = '0'+m; } 
    274  
    275           this.minute = m*1; 
    276           this.oMinute.value = m; 
    277      }, 
    278  
    279      changeMonth: function(dir) { 
    280           var y = this.year; 
    281           var m = this.month; 
    282           m = m+dir; 
    283  
    284           if (m > 12) { this.month = 1; this.year++; } 
    285           else if ( m < 1) { this.month = 12; this.year--; } 
    286           else { this.month = m; } 
    287  
    288           this.setDate(); 
    289      }, 
    290  
    291      changeYear: function(dir) { 
    292           this.year = this.year + dir; 
    293           this.setDate(); 
    294      }, 
    295  
    296      changeHour: function(dir) { 
    297           this.setHour(this.hour*1+dir); 
    298      }, 
    299  
    300      changeMinute: function(dir) { 
    301           this.setMinute(this.minute*1+dir); 
    302      }, 
    303  
    304      sendDate: function(d) { 
    305           var m = this.month; 
    306           var hour = this.oHour.value*1; 
    307           var minute = this.oMinute.value*1; 
    308  
    309           if (hour < 0 || hour > 23 || isNaN(hour)) { hour = 0; } 
    310           if (minute < 0 || minute > 59 || isNaN(minute)) { minute = 0; } 
    311  
    312           if (m < 10) { m = '0'+m; } 
    313           if (d < 10) { d = '0'+d; } 
    314           if (hour < 10) { hour = '0'+hour; } 
    315           if (minute < 10) { minute = '0'+minute; } 
    316  
    317           this.target.value = this.year+'-'+m+'-'+d+' '+hour+':'+minute; 
    318           this.close(); 
    319      }, 
    320  
    321      sendNow: function() { 
    322           var dt = new Date(); 
    323           var y = dt.getFullYear(); 
    324           var m = dt.getMonth() + 1; 
    325           var d = dt.getDate(); 
    326           var h = dt.getHours(); 
    327           var i = dt.getMinutes(); 
    328  
    329           if (m < 10) { m = '0'+m; } 
    330           if (d < 10) { d = '0'+d; } 
    331           if (h < 10) { h = '0'+h; } 
    332           if (i < 10) { i = '0'+i; } 
    333  
    334           this.target.value = y+'-'+m+'-'+d+' '+h+':'+i; 
    335           this.close(); 
    336      }, 
    337  
    338      close: function() { 
    339           document.body.removeChild(this.oTable); 
    340      }, 
    341  
    342      numberOfDays: function() { 
    343           var res = 31; 
    344           if (this.month == 4 || this.month == 6 || this.month == 9 || 
    345           this.month == 11) { 
    346                res = 30; 
    347           } else if (this.month == 2) { 
    348                res = 28; 
    349                if (this.year%4 == 0 && (this.year%100 != 0 || 
    350                this.year%400 == 0)) { 
    351                     res = 29; 
    352                } 
    353           } 
    354  
    355           return res; 
    356      }, 
    357  
    358      firstDay: function() { 
    359           var dt = new Date(this.year,this.month-1,1); 
    360           var res = dt.getDay(); 
    361  
    362           if (res == 0) { 
    363                res = 7; 
    364           } 
    365  
    366           return res; 
    367      }, 
    368  
    369      show: function() { 
    370           // Parsing target value 
    371           var re = /(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})/; 
    372           var match = re.exec(this.target.value); 
    373           if (match) { 
    374                this.year = match[1]*1; 
    375                this.month = match[2]*1; 
    376                this.day = match[3]*1; 
    377                this.hour = match[4]*1; 
    378                this.minute = match[5]*1; 
    379           } else { 
    380                var dt = new Date(); 
    381                this.year = dt.getFullYear(); 
    382                this.month = dt.getMonth() + 1; 
    383                this.day = dt.getDate(); 
    384                this.hour = dt.getHours(); 
    385                this.minute = dt.getMinutes(); 
    386           } 
    387  
    388           this.oTable.appendChild(this.oBody); 
    389           this.setDate(); 
    390           this.setPosition(); 
    391           document.body.appendChild(this.oTable); 
    392           this.oHour.focus(); 
    393      }, 
    394  
    395      setPosition: function() { 
    396           var t_x = this.findPosX(this.target); 
    397           var t_y = this.findPosY(this.target); 
    398           var o_h = this.oTable.offsetHeight; 
    399           var o_w = this.oTable.offsetWidth; 
    400  
    401           this.oTable.style.position = 'absolute'; 
    402           this.oTable.style.zIndex = '100'; 
    403           this.oTable.style.top = t_y+'px'; 
    404           this.oTable.style.left = t_x+'px'; 
    405      }, 
    406  
    407      findPosX: function(obj) { 
    408           var curleft = 0; 
    409           if(obj.offsetParent) { 
    410                while(1) { 
    411                     curleft += obj.offsetLeft; 
    412                     if(!obj.offsetParent) { 
    413                          break; 
    414                     } 
    415                     obj = obj.offsetParent; 
    416                } 
    417           } else if(obj.x) { 
    418                curleft += obj.x; 
    419           } 
    420           return curleft; 
    421      }, 
    422  
    423      findPosY: function(obj) { 
    424           var curtop = 0; 
    425           if(obj.offsetParent) { 
    426                while(1) { 
    427                     curtop += obj.offsetTop; 
    428                     if(!obj.offsetParent) { 
    429                          break; 
    430                     } 
    431                     obj = obj.offsetParent; 
    432                } 
    433           } else if(obj.y) { 
    434                curtop += obj.y; 
    435           } 
    436           return curtop; 
    437      }, 
    438  
    439      draw: function() { 
    440           var imgE = document.createElement('img'); 
    441           imgE.src = this.img_src; 
    442           imgE.alt = this.img_alt; 
    443           imgE.style.position = 'absolute'; 
    444           imgE.style.top = this.img_top; 
    445           imgE.style.left = (this.target.clientWidth+4)+'px'; 
    446           imgE.obj = this; 
    447           imgE.fn = this.show; 
    448           imgE.onclick = function() { this.fn.apply(this.obj); }; 
    449  
    450           this.target.parentNode.style.position = 'relative'; 
    451           this.target.parentNode.insertBefore(imgE,this.target.nextSibling); 
    452      } 
    453 }; 
  • admin/js/filter-controls.js

    r3026 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      var reset_url = '?'; 
    3      if (dotclear.filter_reset_url != undefined) { 
    4           reset_url = dotclear.filter_reset_url; 
    5      } 
     5  var reset_url = '?'; 
     6  if (dotclear.filter_reset_url != undefined) { 
     7    reset_url = dotclear.filter_reset_url; 
     8  } 
    69 
    7      $filtersform = $('#filters-form'); 
    8      $filtersform.before('<p><a id="filter-control" class="form-control" href="'+reset_url+'" style="display:inline">'+dotclear.msg.filter_posts_list+'</a></p>') 
     10  var $filtersform = $('#filters-form'); 
     11  $filtersform.before('<p><a id="filter-control" class="form-control" href="' + reset_url + '" style="display:inline">' + dotclear.msg.filter_posts_list + '</a></p>'); 
    912 
    10      if( dotclear.msg.show_filters == 'false' ) { 
    11           $filtersform.hide(); 
    12      } else { 
    13           $('#filter-control') 
    14                .addClass('open') 
    15                .text(dotclear.msg.cancel_the_filter); 
    16      } 
     13  if (dotclear.msg.show_filters == 'false') { 
     14    $filtersform.hide(); 
     15  } else { 
     16    $('#filter-control') 
     17      .addClass('open') 
     18      .text(dotclear.msg.cancel_the_filter); 
     19  } 
    1720 
    18      $('#filter-control').click(function() { 
    19           if( $(this).hasClass('open') ) { 
    20                if( dotclear.msg.show_filters == 'true' ) { 
    21                     return true; 
    22                } else { 
    23                     $filtersform.hide(); 
    24                     $(this).removeClass('open') 
    25                             .text(dotclear.msg.filter_posts_list); 
    26                } 
    27           } else { 
    28                $filtersform.show(); 
    29                $(this).addClass('open') 
    30                        .text(dotclear.msg.cancel_the_filter); 
    31           } 
    32           return false; 
    33      }); 
     21  $('#filter-control').click(function() { 
     22    if ($(this).hasClass('open')) { 
     23      if (dotclear.msg.show_filters == 'true') { 
     24        return true; 
     25      } else { 
     26        $filtersform.hide(); 
     27        $(this).removeClass('open') 
     28          .text(dotclear.msg.filter_posts_list); 
     29      } 
     30    } else { 
     31      $filtersform.show(); 
     32      $(this).addClass('open') 
     33        .text(dotclear.msg.cancel_the_filter); 
     34    } 
     35    return false; 
     36  }); 
    3437}); 
  • admin/js/jsUpload/template-download.js

    r1461 r3706  
    1 var template_download = tmpl('{% for (var i=0, file; file=o.files[i]; i++) { %}<li class="template-download fade"><div class="upload-file"><div class="upload-fileinfo"><span class="upload-filename">{%=file.name%}</span><span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span><span class="upload-filemsg{% if (file.error) { %} upload-error{% } %}">{% if (file.error) { %}'+dotclear.jsUpload.msg.error+' {%=file.error%}{% } else { %}'+dotclear.jsUpload.msg.file_successfully_uploaded+'{% } %}</span></div><div class="upload-progress">{% if (!file.error) { %}<div class="bar" style="width:100%;">100%</div>{% } %}</div></li>{% } %}'); 
     1/*global tmpl, dotclear */ 
     2/*exported template_download */ 
     3'use strict'; 
     4 
     5var template_download = tmpl('{% for (var i=0, file; file=o.files[i]; i++) { %}<li class="template-download fade"><div class="upload-file"><div class="upload-fileinfo"><span class="upload-filename">{%=file.name%}</span><span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span><span class="upload-filemsg{% if (file.error) { %} upload-error{% } %}">{% if (file.error) { %}' + dotclear.jsUpload.msg.error + ' {%=file.error%}{% } else { %}' + dotclear.jsUpload.msg.file_successfully_uploaded + '{% } %}</span></div><div class="upload-progress">{% if (!file.error) { %}<div class="bar" style="width:100%;">100%</div>{% } %}</div></li>{% } %}'); 
  • admin/js/jsUpload/template-upload.js

    r1461 r3706  
    1 var template_upload = tmpl('{% for (var i=0, file; file=o.files[i]; i++) { %}<li class="template-upload fade"><div class="upload-file"><div class="upload-fileinfo"><span class="upload-filename">{%=file.name%}</span><span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span><span class="upload-filecancel cancel">'+dotclear.jsUpload.msg.cancel+'</span>{% if (!o.files.error && !i && !o.options.autoUpload) { %}<input type="submit" class="button start"  value="'+dotclear.jsUpload.msg.send+'"/>{% } %}<span class="upload-filemsg"></span></div>{% if (!o.files.error) { %}<div class="upload-progress progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>{% } %}</li>{% } %}'); 
     1/*global tmpl, dotclear */ 
     2/*exported template_upload */ 
     3'use strict'; 
     4 
     5var template_upload = tmpl('{% for (var i=0, file; file=o.files[i]; i++) { %}<li class="template-upload fade"><div class="upload-file"><div class="upload-fileinfo"><span class="upload-filename">{%=file.name%}</span><span class="upload-filesize">({%=o.formatFileSize(file.size)%})</span><span class="upload-filecancel cancel">' + dotclear.jsUpload.msg.cancel + '</span>{% if (!o.files.error && !i && !o.options.autoUpload) { %}<input type="submit" class="button start"  value="' + dotclear.jsUpload.msg.send + '"/>{% } %}<span class="upload-filemsg"></span></div>{% if (!o.files.error) { %}<div class="upload-progress progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>{% } %}</li>{% } %}'); 
  • admin/js/meta-editor.js

    r3449 r3706  
     1/*global $, dotclear */ 
     2'use strict'; 
     3 
    14//~ metaEditor & metaEditor.prototype should go to the core. 
    2 function metaEditor(target,meta_field,meta_type,meta_options) { 
    3      this.target = target; 
    4      this.meta_field = meta_field; 
    5      this.meta_type = meta_type; 
    6  
    7      // options 
    8      meta_options = meta_options || {}; 
    9      this.meta_url = meta_options.meta_url || this.meta_url; 
    10      this.list_type = meta_options.list_type || this.list_type; 
    11      this.text_confirm_remove = meta_options.text_confirm_remove || this.text_confirm_remove; 
    12      this.text_add_meta = meta_options.text_add_meta || this.text_add_meta; 
    13      this.text_choose = meta_options.text_choose || this.text_choose; 
    14      this.text_all = meta_options.text_all || this.text_all; 
    15      this.text_separation = meta_options.text_separation || this.text_separation; 
     5function metaEditor(target, meta_field, meta_type, meta_options) { 
     6  this.target = target; 
     7  this.meta_field = meta_field; 
     8  this.meta_type = meta_type; 
     9 
     10  // options 
     11  meta_options = meta_options || {}; 
     12  this.meta_url = meta_options.meta_url || this.meta_url; 
     13  this.list_type = meta_options.list_type || this.list_type; 
     14  this.text_confirm_remove = meta_options.text_confirm_remove || this.text_confirm_remove; 
     15  this.text_add_meta = meta_options.text_add_meta || this.text_add_meta; 
     16  this.text_choose = meta_options.text_choose || this.text_choose; 
     17  this.text_all = meta_options.text_all || this.text_all; 
     18  this.text_separation = meta_options.text_separation || this.text_separation; 
     19} 
     20 
     21metaEditor.prototype = { 
     22  meta_url: '', 
     23  text_confirm_remove: 'Are you sure you want to remove this %s?', 
     24  text_add_meta: 'Add a %s to this entry', 
     25  text_choose: 'Choose from list', 
     26  text_all: 'all', 
     27  text_separation: 'Separate each %s by comas', 
     28  list_type: 'more', 
     29 
     30  target: null, 
     31  meta_type: null, 
     32  meta_dialog: null, 
     33  meta_field: null, 
     34  submit_button: null, 
     35  post_id: false, 
     36 
     37  service_uri: 'services.php', 
     38 
     39  displayMeta: function(type, post_id) { 
     40    this.meta_type = type; 
     41    this.post_id = post_id; 
     42    this.target.empty(); 
     43 
     44    this.meta_dialog = $('<input type="text" class="ib" />'); 
     45    this.meta_dialog.attr('title', this.text_add_meta.replace(/%s/, this.meta_type)); 
     46    this.meta_dialog.attr('id', 'post_meta_input'); 
     47    // Meta dialog input 
     48    this.meta_dialog.keypress(function(evt) { // We don't want to submit form! 
     49      if (evt.keyCode == 13) { 
     50        This.addMeta(this.value); 
     51        return false; 
     52      } 
     53      return true; 
     54    }); 
     55 
     56    var This = this; 
     57 
     58    this.submit_button = $('<input type="button" value="ok" class="ib meta-helper" />'); 
     59    this.submit_button.click(function() { 
     60      var v = This.meta_dialog.val(); 
     61      This.addMeta(v); 
     62      return false; 
     63    }); 
     64 
     65    this.addMetaDialog(); 
     66 
     67    if (this.post_id == false) { 
     68      this.target.append(this.meta_field); 
     69    } 
     70    this.displayMetaList(); 
     71  }, 
     72 
     73  displayMetaList: function() { 
     74    var li; 
     75    if (this.meta_list == undefined) { 
     76      this.meta_list = $('<ul class="metaList"></ul>'); 
     77      this.target.prepend(this.meta_list); 
     78    } 
     79 
     80    if (this.post_id == false) { 
     81      var meta = this.splitMetaValues(this.meta_field.val()); 
     82 
     83      this.meta_list.empty(); 
     84      for (var i = 0; i < meta.length; i++) { 
     85        li = $('<li>' + meta[i] + '</li>'); 
     86        var a_remove = $('<button type="button" class="metaRemove meta-helper"><img src="images/trash.png" alt="remove" /></button>'); 
     87        a_remove.get(0).caller = this; 
     88        a_remove.get(0).meta_id = meta[i]; 
     89        a_remove.click(function() { 
     90          this.caller.removeMeta(this.meta_id); 
     91          return false; 
     92        }); 
     93        li.prepend('&nbsp;').prepend(a_remove); 
     94        this.meta_list.append(li); 
     95      } 
     96    } else { 
     97      var This = this; 
     98      var params = { 
     99        f: 'getMeta', 
     100        metaType: this.meta_type, 
     101        sortby: 'metaId,asc', 
     102        postId: this.post_id 
     103      }; 
     104 
     105      $.get(this.service_uri, params, function(data) { 
     106        data = $(data); 
     107 
     108        if (data.find('rsp').attr('status') != 'ok') { 
     109          return; 
     110        } 
     111 
     112        This.meta_list.empty(); 
     113        data.find('meta').each(function() { 
     114          var meta_id = $(this).text(); 
     115          li = $('<li><a href="' + This.meta_url + $(this).attr('uri') + '">' + meta_id + '</a></li>'); 
     116          a_remove = $('<button type="button" class="metaRemove meta-helper"><img src="images/trash.png" alt="remove" /></button>'); 
     117          a_remove.get(0).caller = This; 
     118          a_remove.get(0).meta_id = meta_id; 
     119          a_remove.click(function() { 
     120            this.caller.removeMeta(this.meta_id); 
     121            return false; 
     122          }); 
     123          li.prepend('&nbsp;').prepend(a_remove); 
     124          This.meta_list.append(li); 
     125        }); 
     126      }); 
     127    } 
     128  }, 
     129 
     130  addMetaDialog: function() { 
     131 
     132    if (this.submit_button == null) { 
     133      this.target.append($('<p></p>').append(this.meta_dialog)); 
     134    } else { 
     135      this.target.append($('<p></p>').append(this.meta_dialog).append(' ').append(this.submit_button)); 
     136    } 
     137 
     138    if (this.text_separation != '') { 
     139      this.target.append($('<p></p>').addClass('form-note').append(this.text_separation.replace(/%s/, this.meta_type))); 
     140    } 
     141 
     142    this.showMetaList(this.list_type, this.target); 
     143 
     144  }, 
     145 
     146  showMetaList: function(list_type, target) { 
     147    var params = { 
     148      f: 'getMeta', 
     149      metaType: this.meta_type, 
     150      sortby: 'metaId,asc' 
     151    }; 
     152 
     153    if (list_type == 'more') { 
     154      params.limit = '30'; 
     155    } 
     156 
     157    var This = this; 
     158 
     159    $.get(this.service_uri, params, function(data) { 
     160 
     161      var pl = $('<p class="addMeta"></p>'); 
     162 
     163      $(target).find('.addMeta').remove(); 
     164 
     165      if ($(data).find('meta').length > 0) { 
     166        pl.empty(); 
     167        var meta_link; 
     168 
     169        $(data).find('meta').each(function(i) { 
     170          meta_link = $('<button type="button" class="metaItem meta-helper">' + $(this).text() + '</button>'); 
     171          meta_link.get(0).meta_id = $(this).text(); 
     172          meta_link.click(function() { 
     173            var v = This.splitMetaValues(This.meta_dialog.val() + ',' + this.meta_id); 
     174            This.meta_dialog.val(v.join(',')); 
     175            return false; 
     176          }); 
     177 
     178          if (i > 0) { 
     179            pl.append(', '); 
     180          } 
     181          pl.append(meta_link); 
     182        }); 
     183 
     184        if (list_type == 'more') { 
     185          var a_more = $('<button type="button" class="button metaGetMore meta-helper"></button>'); 
     186          a_more.append(This.text_all + String.fromCharCode(160) + String.fromCharCode(187)); 
     187          a_more.click(function() { 
     188            This.showMetaList('more-all', target); 
     189            return false; 
     190          }); 
     191          pl.append(', ').append(a_more); 
     192        } 
     193 
     194        if (list_type != 'more-all') { 
     195          pl.addClass('hide'); 
     196 
     197          var pa = $('<p></p>'); 
     198          target.append(pa); 
     199 
     200          var a = $('<button type="button" class="button metaGetList meta-helper">' + This.text_choose + '</button>'); 
     201          a.click(function() { 
     202            $(this).parent().next().removeClass('hide'); 
     203            $(this).remove(); 
     204            return false; 
     205          }); 
     206 
     207          pa.append(a); 
     208        } 
     209 
     210        target.append(pl); 
     211 
     212      } else { 
     213        pl.empty(); 
     214      } 
     215    }); 
     216  }, 
     217 
     218  addMeta: function(str) { 
     219    str = this.splitMetaValues(str).join(','); 
     220    if (this.post_id == false) { 
     221      str = this.splitMetaValues(this.meta_field.val() + ',' + str); 
     222      this.meta_field.val(str); 
     223 
     224      this.meta_dialog.val(''); 
     225      this.displayMetaList(); 
     226    } else { 
     227      var params = { 
     228        xd_check: dotclear.nonce, 
     229        f: 'setPostMeta', 
     230        postId: this.post_id, 
     231        metaType: this.meta_type, 
     232        meta: str 
     233      }; 
     234 
     235      var This = this; 
     236      $.post(this.service_uri, params, function(data) { 
     237        if ($(data).find('rsp').attr('status') == 'ok') { 
     238          This.meta_dialog.val(''); 
     239          This.displayMetaList(); 
     240        } else { 
     241          window.alert($(data).find('message').text()); 
     242        } 
     243      }); 
     244    } 
     245  }, 
     246 
     247  removeMeta: function(meta_id) { 
     248    if (this.post_id == false) { 
     249      var meta = this.splitMetaValues(this.meta_field.val()); 
     250      for (var i = 0; i < meta.length; i++) { 
     251        if (meta[i] == meta_id) { 
     252          meta.splice(i, 1); 
     253          break; 
     254        } 
     255      } 
     256      this.meta_field.val(meta.join(',')); 
     257      this.displayMetaList(); 
     258    } else { 
     259      var text_confirm_msg = this.text_confirm_remove.replace(/%s/, this.meta_type); 
     260 
     261      if (window.confirm(text_confirm_msg)) { 
     262        var This = this; 
     263        var params = { 
     264          xd_check: dotclear.nonce, 
     265          f: 'delMeta', 
     266          postId: this.post_id, 
     267          metaId: meta_id, 
     268          metaType: this.meta_type 
     269        }; 
     270 
     271        $.post(this.service_uri, params, function(data) { 
     272          if ($(data).find('rsp').attr('status') == 'ok') { 
     273            This.displayMetaList(); 
     274          } else { 
     275            window.alert($(data).find('message').text()); 
     276          } 
     277        }); 
     278      } 
     279    } 
     280  }, 
     281 
     282  splitMetaValues: function(str) { 
     283    function inArray(needle, stack) { 
     284      for (var i = 0; i < stack.length; i++) { 
     285        if (stack[i] == needle) { 
     286          return true; 
     287        } 
     288      } 
     289      return false; 
     290    } 
     291 
     292    var res = []; 
     293    var v = str.split(','); 
     294    v.sort(); 
     295    for (var i = 0; i < v.length; i++) { 
     296      v[i] = v[i].replace(/^\s*/, '').replace(/\s*$/, ''); 
     297      if (v[i] != '' && !inArray(v[i], res)) { 
     298        res.push(v[i]); 
     299      } 
     300    } 
     301    res.sort(); 
     302    return res; 
     303  } 
    16304}; 
    17  
    18 metaEditor.prototype = { 
    19      meta_url: '', 
    20      text_confirm_remove: 'Are you sure you want to remove this %s?', 
    21      text_add_meta: 'Add a %s to this entry', 
    22      text_choose: 'Choose from list', 
    23      text_all: 'all', 
    24      text_separation: 'Separate each %s by comas', 
    25      list_type: 'more', 
    26  
    27      target: null, 
    28      meta_type: null, 
    29      meta_dialog: null, 
    30      meta_field: null, 
    31      submit_button: null, 
    32      post_id: false, 
    33  
    34      service_uri: 'services.php', 
    35  
    36      displayMeta: function(type,post_id) { 
    37           this.meta_type = type; 
    38           this.post_id = post_id; 
    39           this.target.empty(); 
    40  
    41           this.meta_dialog = $('<input type="text" class="ib" />'); 
    42           this.meta_dialog.attr('title',this.text_add_meta.replace(/%s/,this.meta_type)); 
    43           this.meta_dialog.attr('id','post_meta_input'); 
    44           // Meta dialog input 
    45           this.meta_dialog.keypress(function(evt) { // We don't want to submit form! 
    46                if (evt.keyCode == 13) { 
    47                     This.addMeta(this.value); 
    48                     return false; 
    49                } 
    50                return true; 
    51           }); 
    52  
    53           var This = this; 
    54  
    55           this.submit_button = $('<input type="button" value="ok" class="ib meta-helper" />'); 
    56           this.submit_button.click(function() { 
    57                var v = This.meta_dialog.val(); 
    58                This.addMeta(v); 
    59                return false; 
    60           }); 
    61  
    62           this.addMetaDialog(); 
    63  
    64           if (this.post_id == false) { 
    65                this.target.append(this.meta_field); 
    66           } 
    67           this.displayMetaList(); 
    68      }, 
    69  
    70      displayMetaList: function() { 
    71           var li; 
    72           if (this.meta_list == undefined) { 
    73                this.meta_list = $('<ul class="metaList"></ul>'); 
    74                this.target.prepend(this.meta_list); 
    75           } 
    76  
    77           if (this.post_id == false) { 
    78                var meta = this.splitMetaValues(this.meta_field.val()); 
    79  
    80                this.meta_list.empty(); 
    81                for (var i=0; i < meta.length; i++) { 
    82                     li = $('<li>'+meta[i]+'</li>'); 
    83                     a_remove = $('<button type="button" class="metaRemove meta-helper"><img src="images/trash.png" alt="remove" /></button>'); 
    84                     a_remove.get(0).caller = this; 
    85                     a_remove.get(0).meta_id = meta[i]; 
    86                     a_remove.click(function() { 
    87                          this.caller.removeMeta(this.meta_id); 
    88                          return false; 
    89                     }); 
    90                     li.prepend('&nbsp;').prepend(a_remove); 
    91                     this.meta_list.append(li); 
    92                } 
    93           } else { 
    94                var This = this; 
    95                var params = { 
    96                     f: 'getMeta', 
    97                     metaType: this.meta_type, 
    98                     sortby: 'metaId,asc', 
    99                     postId: this.post_id 
    100                }; 
    101  
    102                $.get(this.service_uri,params,function(data) { 
    103                     data = $(data); 
    104  
    105                     if (data.find('rsp').attr('status') != 'ok') { return; } 
    106  
    107                     This.meta_list.empty(); 
    108                     data.find('meta').each(function() { 
    109                          var meta_id = $(this).text(); 
    110                          li = $('<li><a href="' + This.meta_url + $(this).attr('uri') + '">'+meta_id+'</a></li>'); 
    111                          a_remove = $('<button type="button" class="metaRemove meta-helper"><img src="images/trash.png" alt="remove" /></button>'); 
    112                          a_remove.get(0).caller = This; 
    113                          a_remove.get(0).meta_id = meta_id; 
    114                          a_remove.click(function() { 
    115                               this.caller.removeMeta(this.meta_id); 
    116                               return false; 
    117                          }); 
    118                          li.prepend('&nbsp;').prepend(a_remove); 
    119                          This.meta_list.append(li); 
    120                     }); 
    121                }); 
    122           } 
    123      }, 
    124  
    125      addMetaDialog: function() { 
    126  
    127           if (this.submit_button == null) { 
    128                this.target.append($('<p></p>').append(this.meta_dialog)); 
    129           } else { 
    130                this.target.append($('<p></p>').append(this.meta_dialog).append(' ').append(this.submit_button)); 
    131           } 
    132  
    133           if (this.text_separation != '') { 
    134                this.target.append($('<p></p>').addClass('form-note').append(this.text_separation.replace(/%s/,this.meta_type))); 
    135           } 
    136  
    137           this.showMetaList(this.list_type,this.target); 
    138  
    139      }, 
    140  
    141      showMetaList: function(list_type,target) { 
    142           var params = { 
    143                f: 'getMeta', 
    144                metaType: this.meta_type, 
    145                sortby: 'metaId,asc' 
    146           }; 
    147  
    148           if (list_type == 'more') { 
    149                params.limit = '30'; 
    150           } 
    151  
    152           var This = this; 
    153  
    154           $.get(this.service_uri,params,function(data) { 
    155  
    156                var pl = $('<p class="addMeta"></p>'); 
    157  
    158                $(target).find('.addMeta').remove(); 
    159  
    160                if ($(data).find('meta').length > 0) { 
    161                     pl.empty(); 
    162                     var meta_link; 
    163  
    164                     $(data).find('meta').each(function(i) { 
    165                          meta_link = $('<button type="button" class="metaItem meta-helper">' + $(this).text() + '</button>'); 
    166                          meta_link.get(0).meta_id = $(this).text(); 
    167                          meta_link.click(function() { 
    168                               var v = This.splitMetaValues(This.meta_dialog.val() + ',' + this.meta_id); 
    169                               This.meta_dialog.val(v.join(',')); 
    170                               return false; 
    171                          }); 
    172  
    173                          if (i>0) { 
    174                               pl.append(', '); 
    175                          } 
    176                          pl.append(meta_link); 
    177                     }); 
    178  
    179                     if (list_type == 'more') { 
    180                          var a_more = $('<button type="button" class="button metaGetMore meta-helper"></button>'); 
    181                          a_more.append(This.text_all + String.fromCharCode(160)+String.fromCharCode(187)); 
    182                          a_more.click(function() { 
    183                               This.showMetaList('more-all',target); 
    184                               return false; 
    185                          }); 
    186                          pl.append(', ').append(a_more); 
    187                     } 
    188  
    189                     if (list_type != 'more-all') { 
    190                          pl.addClass('hide'); 
    191  
    192                          var pa = $('<p></p>'); 
    193                          target.append(pa); 
    194  
    195                          var a = $('<button type="button" class="button metaGetList meta-helper">' + This.text_choose + '</button>'); 
    196                          a.click(function() { 
    197                               $(this).parent().next().removeClass('hide'); 
    198                               $(this).remove(); 
    199                               return false; 
    200                          }); 
    201  
    202                          pa.append(a); 
    203                     } 
    204  
    205                     target.append(pl); 
    206  
    207                } else { 
    208                     pl.empty(); 
    209                } 
    210           }); 
    211      }, 
    212  
    213      addMeta: function(str) { 
    214           str = this.splitMetaValues(str).join(','); 
    215           if (this.post_id == false) { 
    216                str = this.splitMetaValues(this.meta_field.val() + ',' + str); 
    217                this.meta_field.val(str); 
    218  
    219                this.meta_dialog.val(''); 
    220                this.displayMetaList(); 
    221           } else { 
    222                var params = { 
    223                     xd_check: dotclear.nonce, 
    224                     f: 'setPostMeta', 
    225                     postId: this.post_id, 
    226                     metaType: this.meta_type, 
    227                     meta: str 
    228                }; 
    229  
    230                var This = this; 
    231                $.post(this.service_uri,params,function(data) { 
    232                     if ($(data).find('rsp').attr('status') == 'ok') { 
    233                          This.meta_dialog.val(''); 
    234                          This.displayMetaList(); 
    235                     } else { 
    236                          alert($(data).find('message').text()); 
    237                     } 
    238                }); 
    239           } 
    240      }, 
    241  
    242      removeMeta: function(meta_id) { 
    243           if (this.post_id == false) { 
    244                var meta = this.splitMetaValues(this.meta_field.val()); 
    245                for (var i=0; i<meta.length; i++) { 
    246                     if (meta[i] == meta_id) { 
    247                          meta.splice(i,1); 
    248                          break; 
    249                     } 
    250                } 
    251                this.meta_field.val(meta.join(',')); 
    252                this.displayMetaList(); 
    253           } else { 
    254                var text_confirm_msg = this.text_confirm_remove.replace(/%s/,this.meta_type); 
    255  
    256                if (window.confirm(text_confirm_msg)) { 
    257                     var This = this; 
    258                     var params = { 
    259                          xd_check: dotclear.nonce, 
    260                          f: 'delMeta', 
    261                          postId: this.post_id, 
    262                          metaId: meta_id, 
    263                          metaType: this.meta_type 
    264                     }; 
    265  
    266                     $.post(this.service_uri,params,function(data) { 
    267                          if ($(data).find('rsp').attr('status') == 'ok') { 
    268                               This.displayMetaList(); 
    269                          } else { 
    270                               alert($(data).find('message').text()); 
    271                          } 
    272                     }); 
    273                } 
    274           } 
    275      }, 
    276  
    277      splitMetaValues: function(str) { 
    278           function inArray(needle,stack) { 
    279                for (var i=0; i<stack.length; i++) { 
    280                     if (stack[i] == needle) { 
    281                          return true; 
    282                     } 
    283                } 
    284                return false; 
    285           } 
    286  
    287           var res = new Array(); 
    288           var v = str.split(','); 
    289           v.sort(); 
    290           for (var i=0; i<v.length; i++) { 
    291                v[i] = v[i].replace(/^\s*/,'').replace(/\s*$/,''); 
    292                if (v[i] != '' && !inArray(v[i],res)) { 
    293                     res.push(v[i]); 
    294                } 
    295           } 
    296           res.sort(); 
    297           return res; 
    298      } 
    299 }; 
  • admin/js/prelude.js

    r2566 r3706  
     1/*global $ */ 
     2'use strict'; 
     3 
    14$(function() { 
    2      if ($('#prelude').length > 0) { 
    3           $('#prelude a') 
    4                .addClass('hidden') 
    5                .focus(function() { 
    6                     $('#prelude a').removeClass('hidden'); 
    7                     $('#wrapper, #help-button, #collapser').addClass('with-prelude'); 
    8                }); 
     5  if ($('#prelude').length > 0) { 
     6    $('#prelude a') 
     7      .addClass('hidden') 
     8      .focus(function() { 
     9        $('#prelude a').removeClass('hidden'); 
     10        $('#wrapper, #help-button, #collapser').addClass('with-prelude'); 
     11      }); 
    912 
    10           $('body').on('click', '#prelude a[href="#help"]', function(e) { 
    11                e.preventDefault(); 
    12                $('#help-button a').focus(); 
    13           }); 
    14      } 
     13    $('body').on('click', '#prelude a[href="#help"]', function(e) { 
     14      e.preventDefault(); 
     15      $('#help-button a').focus(); 
     16    }); 
     17  } 
    1518}); 
Note: See TracChangeset for help on using the changeset viewer.

Sites map