Dotclear

Changeset 3701:16d6d099e144


Ignore:
Timestamp:
02/15/18 13:03:37 (7 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Admin popups: dealing with Enter key fired, and focus on first input when opening.

Location:
admin
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • admin/js/_media_item.js

    r3446 r3701  
    7878     }); 
    7979 
     80  // Set focus if in popup mode 
     81  $('#media-insert-form :input:visible:enabled:checked:first, #media-insert-form :input:visible:enabled:first').focus(); 
     82 
     83  // Deal with enter key on media insert popup form : every form element will be filtered but Cancel button 
     84  dotclear.enterKeyInForm('#media-insert-form', '#media-insert-ok', '#media-insert-cancel'); 
    8085}); 
  • admin/js/common.js

    r3700 r3701  
    297297var dotclear = { 
    298298  msg: {}, 
     299  enterKeyInForm: function(frm_id, ok_id, cancel_id) { 
     300    $(frm_id + ':not(' + cancel_id + ')').keyup(function(e) { 
     301      if (e.key == 'Enter') { 
     302        e.preventDefault(); 
     303        e.stopPropagation(); 
     304        $(ok_id).trigger('click'); 
     305      } 
     306    }); 
     307  }, 
    299308  condSubmit: function(chkboxes, target) { 
    300309    var checkboxes = $(chkboxes), 
  • admin/popup_link.php

    r3639 r3701  
    1111# -- END LICENSE BLOCK ----------------------------------------- 
    1212 
    13 require dirname(__FILE__).'/../inc/admin/prepend.php'; 
     13require dirname(__FILE__) . '/../inc/admin/prepend.php'; 
    1414 
    1515dcPage::check('usage,contentadmin'); 
    1616 
    17 $href = !empty($_GET['href']) ? $_GET['href'] : ''; 
    18 $hreflang = !empty($_GET['hreflang']) ? $_GET['hreflang'] : ''; 
    19 $title = !empty($_GET['title']) ? $_GET['title'] : ''; 
     17$href      = !empty($_GET['href']) ? $_GET['href'] : ''; 
     18$hreflang  = !empty($_GET['hreflang']) ? $_GET['hreflang'] : ''; 
     19$title     = !empty($_GET['title']) ? $_GET['title'] : ''; 
    2020$plugin_id = !empty($_GET['plugin_id']) ? html::sanitizeURL($_GET['plugin_id']) : ''; 
    2121 
    22 dcPage::openPopup(__('Add a link'),$core->callBehavior('adminPopupLink', $plugin_id)); 
     22dcPage::openPopup(__('Add a link'), dcPage::jsLoad('js/_popup_link.js') . $core->callBehavior('adminPopupLink', $plugin_id)); 
    2323 
    24 echo '<h2 class="page-title">'.__('Add a link').'</h2>'; 
     24echo '<h2 class="page-title">' . __('Add a link') . '</h2>'; 
    2525 
    2626# Languages combo 
    27 $rs = $core->blog->getLangs(array('order'=>'asc')); 
    28 $lang_combo = dcAdminCombos::getLangsCombo($rs,true); 
     27$rs         = $core->blog->getLangs(array('order' => 'asc')); 
     28$lang_combo = dcAdminCombos::getLangsCombo($rs, true); 
    2929 
    3030echo 
    31 '<form id="link-insert-form" action="#" method="get">'. 
    32 '<p><label class="required" for="href"><abbr title="'.__('Required field').'">*</abbr> '.__('Link URL:').'</label> '. 
    33 form::field('href',35,512,html::escapeHTML($href),'','',false,'required placeholder="'.__('URL').'"').'</p>'. 
    34 '<p><label for="title">'.__('Link title:').'</label> '. 
    35 form::field('title',35,512,html::escapeHTML($title)).'</p>'. 
    36 '<p><label for="hreflang">'.__('Link language:').'</label> '. 
    37 form::combo('hreflang',$lang_combo,$hreflang). 
    38 '</p>'. 
     31'<form id="link-insert-form" action="#" method="get">' . 
     32'<p><label class="required" for="href"><abbr title="' . __('Required field') . '">*</abbr> ' . __('Link URL:') . '</label> ' . 
     33form::field('href', 35, 512, html::escapeHTML($href), '', '', false, 'required placeholder="' . __('URL') . '"') . '</p>' . 
     34'<p><label for="title">' . __('Link title:') . '</label> ' . 
     35form::field('title', 35, 512, html::escapeHTML($title)) . '</p>' . 
     36'<p><label for="hreflang">' . __('Link language:') . '</label> ' . 
     37form::combo('hreflang', $lang_combo, $hreflang) . 
     38'</p>' . 
    3939 
    40 '</form>'. 
     40'</form>' . 
    4141 
    42 '<p><button type="button" class="reset" id="link-insert-cancel">'.__('Cancel').'</button> - '. 
    43 '<button type="button" id="link-insert-ok"><strong>'.__('Insert').'</strong></button></p>'."\n". 
    44  
    45 '<script type="text/javascript">'."\n". 
    46 '$(\'input[name="href"]\').get(0).focus();'."\n". 
    47 '</script>'."\n"; 
     42'<p><button type="button" class="reset" id="link-insert-cancel">' . __('Cancel') . '</button> - ' . 
     43'<button type="button" id="link-insert-ok"><strong>' . __('Insert') . '</strong></button></p>' . "\n"; 
    4844 
    4945dcPage::closePopup(); 
  • admin/popup_posts.php

    r3445 r3701  
    4646dcPage::openPopup(__('Add a link to an entry'), 
    4747     dcPage::jsLoad('js/_posts_list.js'). 
     48    dcPage::jsLoad('js/_popup_posts.js'). 
    4849     $core->callBehavior('adminPopupPosts', $plugin_id)); 
    4950 
Note: See TracChangeset for help on using the changeset viewer.

Sites map