Commit 6f03fa976169823d381be2e0f492e150420aade6
1 parent
6a288fbe
- fix a ... very annoying bug in firefox (return false) handling.
- don't duplicate javascript. git-svn-id: https://kt-dms.svn.sourceforge.net/svnroot/kt-dms/trunk@4811 c91229c3-7414-0410-bfa2-8a42b809f60b
Showing
2 changed files
with
24 additions
and
10 deletions
resources/js/kt-utility.js
| @@ -2,15 +2,29 @@ | @@ -2,15 +2,29 @@ | ||
| 2 | * general utility functions for KT | 2 | * general utility functions for KT |
| 3 | */ | 3 | */ |
| 4 | 4 | ||
| 5 | -function addEvent(obj, event, func) { | 5 | +var message; |
| 6 | + | ||
| 7 | +function addEvent(obj, event, func, capture) { | ||
| 6 | if (obj.attachEvent) { obj.attachEvent('on'+event, func); } | 8 | if (obj.attachEvent) { obj.attachEvent('on'+event, func); } |
| 7 | - else { obj.addEventListener(event, func, false); } | 9 | + else { obj.addEventListener(event, func, capture); } |
| 8 | } | 10 | } |
| 9 | 11 | ||
| 10 | -function confirmDelete(message) { return confirm(message); } | 12 | +function confirmDelete(e) { |
| 13 | + var v = confirm(message); | ||
| 14 | + if (v == false) { | ||
| 15 | + if (e.stopPropagation) { | ||
| 16 | + e.stopPropagation(); | ||
| 17 | + e.preventDefault(); | ||
| 18 | + } | ||
| 19 | + else if (window.event) | ||
| 20 | + return false; | ||
| 21 | + } | ||
| 22 | + return v; | ||
| 23 | +} | ||
| 11 | 24 | ||
| 12 | -function initDeleteProtection(message) { | ||
| 13 | - var fn = partial(confirmDelete, message); | 25 | +function initDeleteProtection(m) { |
| 26 | + var fn = confirmDelete; | ||
| 27 | + message = m; | ||
| 14 | var elements = getElementsByTagAndClassName('A','ktDelete'); | 28 | var elements = getElementsByTagAndClassName('A','ktDelete'); |
| 15 | 29 | ||
| 16 | function setClickFunction(fn, node) { | 30 | function setClickFunction(fn, node) { |
| @@ -21,13 +35,14 @@ function initDeleteProtection(message) { | @@ -21,13 +35,14 @@ function initDeleteProtection(message) { | ||
| 21 | else { return null; } | 35 | else { return null; } |
| 22 | } | 36 | } |
| 23 | 37 | ||
| 24 | - addEvent(node, 'click', fn); | 38 | + addEvent(node, 'click', fn, true); |
| 39 | + | ||
| 25 | } | 40 | } |
| 26 | 41 | ||
| 27 | forEach(elements, partial(setClickFunction, fn)); | 42 | forEach(elements, partial(setClickFunction, fn)); |
| 28 | 43 | ||
| 29 | - elements = getElementsByTagAndClassName('SPAN', 'ktDelete'); | 44 | + //elements = getElementsByTagAndClassName('SPAN', 'ktDelete'); |
| 30 | 45 | ||
| 31 | - forEach(elements, partial(setClickFunction, fn)); | 46 | + //forEach(elements, partial(setClickFunction, fn)); |
| 32 | 47 | ||
| 33 | } | 48 | } |
| 34 | \ No newline at end of file | 49 | \ No newline at end of file |
templates/ktcore/principals/useradmin.smarty
| @@ -53,8 +53,7 @@ very slow if you have many users).{/i18n}</p> | @@ -53,8 +53,7 @@ very slow if you have many users).{/i18n}</p> | ||
| 53 | <td>{$oUser->getName()}</td> | 53 | <td>{$oUser->getName()}</td> |
| 54 | <td>{$oUser->getUsername()}</td> | 54 | <td>{$oUser->getUsername()}</td> |
| 55 | <td><a href="{addQS}action=editUser&user_id={$oUser->getId()}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a></td> | 55 | <td><a href="{addQS}action=editUser&user_id={$oUser->getId()}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a></td> |
| 56 | - <td><a onclick="javascript:return confirm('{i18n}Are you sure | ||
| 57 | -you wish to delete this user?{/i18n}');" href="{addQS}action=deleteuser&user_id={$oUser->getId()}{/addQS}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a></td> | 56 | + <td><a href="{addQS}action=deleteuser&user_id={$oUser->getId()}{/addQS}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a></td> |
| 58 | <td><a href="{addQS}action=editgroups&user_id={$oUser->getId()}{/addQS}">{i18n}Groups{/i18n}</a></td> | 57 | <td><a href="{addQS}action=editgroups&user_id={$oUser->getId()}{/addQS}">{i18n}Groups{/i18n}</a></td> |
| 59 | </tr> | 58 | </tr> |
| 60 | {/foreach} | 59 | {/foreach} |