Project

General

Profile

Feature #18071 » 20080312_opendocs_fixes_part3.patch

Administrator Admin, 2008-03-12 21:47

View differences:

typo3/sysext/opendocs/class.tx_opendocs.php (working copy)
$numDocs = count($this->openDocs);
// return the toolbar item and an empty UL
$output = '<a href="#" class="toolbar-item">';
$output .= '<span id="tx-opendocs-num">'.($numDocs > 0 ? $numDocs : '').'</span>';
$output .= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], t3lib_extMgm::extRelPath($this->EXTKEY).'opendocs.png', 'width="23" height="14"').' title="'.$GLOBALS['LANG']->getLL('toolbaritem',1).'" alt="" />';
$output = '<a href="#" id="tx-opendocs-toolbar-item" class="toolbar-item">';
$output .= '<div title="'.$GLOBALS['LANG']->getLL('toolbaritem',1).'" id="tx-opendocs-num">'.($numDocs > 0 ? $numDocs : '').'</div>';
//$output .= '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], t3lib_extMgm::extRelPath($this->EXTKEY).'opendocs.png', 'width="23" height="14"').' alt="" />';
$output .= '</a>';
$output .= '<div class="toolbar-item-menu" style="display: none;"></div>';
......
$uid = $itm[3]['uid'];
$rec = t3lib_BEfunc::getRecordWSOL($table, $uid);
$label = htmlspecialchars(strip_tags(t3lib_div::htmlspecialchars_decode($itm[0])));
$icon = '<img src="'.t3lib_iconWorks::getIcon($table, $rec).'" alt="'.$label.'" />';
$icon = t3lib_iconWorks::getIconImage($table, $rec, $GLOBALS['BACK_PATH']);
$link = $GLOBALS['BACK_PATH'].'alt_doc.php?'.$itm[2];
if ($isRecentDoc) {
$entry = '
<tr id="opendocs-'.$table.'-'.$uid.'" class="recentdoc">
<td class="opendocs-icon">'.$icon.'</td>
<td class="opendocs-label" colspan="2" id="opendocs-label-'.$table.'-'.$uid.'"><a href="'.$link.'" target="content" onclick="TYPO3BackendOpenDocs.hideMenu();">'.$label.'</a></td>
<td class="opendocs-label" colspan="2" id="opendocs-label-'.$table.'-'.$uid.'" title="'.$label.'"><a href="'.$link.'" target="content" onclick="TYPO3BackendOpenDocs.hideMenu();">'.$label.'</a></td>
</tr>';
} else {
$closeIcon = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/closedok.gif', 'width="16" height="16"').' title="Close Document" alt="" />';
$closeIcon = '<img'.t3lib_iconWorks::skinImg($GLOBALS['BACK_PATH'], 'gfx/closedok.gif', 'width="16" height="16"').' title="'.$GLOBALS['LANG']->getLL('rm.closeDoc',1).'" alt="" />';
$entry = '
<tr id="opendocs-'.$table.'-'.$uid.'" class="opendoc">
<td class="opendocs-icon">'.$icon.'</td>
<td class="opendocs-label" id="opendocs-label-'.$table.'-'.$uid.'"><a href="'.$link.'" target="content" onclick="TYPO3BackendOpenDocs.hideMenu();">'.$label.'</a></td>
<td class="opendocs-label" id="opendocs-label-'.$table.'-'.$uid.'" title="'.$label.'"><a href="'.$link.'" target="content" onclick="TYPO3BackendOpenDocs.hideMenu();">'.$label.'</a></td>
<td class="opendocs-close" onclick="return TYPO3BackendOpenDocs.closeDocument(\''.$md5sum.'\');">'.$closeIcon.'</td>
</tr>';
}
......
public function updateNumberOfOpenDocsHook(&$params, &$ref) {
$params['JScode'] = '
if (top && top.TYPO3BackendOpenDocs) {
top.TYPO3BackendOpenDocs.updateNumberOfDocs('.count($this->openDocs).', false);
top.TYPO3BackendOpenDocs.updateNumberOfDocs('.count($this->openDocs).', true);
}
';
}
......
$entries = array();
if (count($itms)) {
$entries[] = '<tr class="menu-item-div"><td colspan="3">'.$GLOBALS['LANG']->getLL('open_docs',1).'</td></tr>';
$entries[] = '<tr class="menu-item-firstdiv"><th colspan="3">'.$GLOBALS['LANG']->getLL('open_docs',1).'</th></tr>';
foreach ($itms as $md5sum => $itm) {
$entries[] = $this->renderMenuEntry($itm, $md5sum);
}
......
// if there are "recent documents" in the list, add them
if (count($itmsRecent)) {
$entries[] = '<tr class="menu-item-div"><td colspan="3">'.$GLOBALS['LANG']->getLL('recent_docs',1).'</td></tr>';
$entries[] = '<tr class="menu-item-div"><th colspan="3">'.$GLOBALS['LANG']->getLL('recent_docs',1).'</th></tr>';
foreach ($itmsRecent as $md5sum => $itm) {
$entries[] = $this->renderMenuEntry($itm, $md5sum, true);
}
typo3/sysext/opendocs/opendocs.css (working copy)
#open-documents-menu {
width: 40px;
a#tx-opendocs-toolbar-item {
padding-left: 2px;
padding-right: 4px;
width: 42px;
height: 20px;
}
span#tx-opendocs-num {
padding: 0 2px;
line-height: 14px;
#tx-opendocs-num {
border: 0 !important;
width: 38px;
height: 20px;
line-height: 18px;
text-align: right;
background: transparent url('opendocs.png') no-repeat 1px 1px !important;
}
#open-documents-menu div {
position: absolute;
list-style: none;
margin: 0;
padding: 2px 0 0;
padding: 0;
background-color: #f9f9f9;
border: 1px solid #abb2bc;
border-top: none;
......
#open-documents-menu table,
#open-documents-menu tr {
width: 100%;
width: 200px;
border-collapse: collapse;
padding: 0;
border: 0;
......
line-height: 14px;
font-size: 11px;
margin: 0;
padding: 1px 1px 1px 0;
padding: 1px 1px 2px 2px;
}
#open-documents-menu td.opendocs-close {
text-align: right;
}
#open-documents-menu tr.menu-item-div td {
border-top: 1px solid #abb2bc;
#open-documents-menu tr.menu-item-div th,
#open-documents-menu tr.menu-item-firstdiv th {
font-weight: bold;
padding: 2px 3px;
padding: 3px 3px 5px 2px;
text-align: left;
background: #dbdbdb repeat-x url('../../gfx/shortcutgroups-bg.png') left 15px;
}
#open-documents-menu tr.menu-item-div th {
border-top: #a5a5a5 1px solid;
}
#open-documents-menu td a {
text-decoration: none;
typo3/sysext/opendocs/opendocs.js (working copy)
* positions the menu below the toolbar icon
*/
positionMenu: function() {
var calculatedOffset = 0;
var ownWidth = $(this.menu).getWidth();
var parentWidth = $(this.menuItem).getWidth();
var parentSiblings = $(this.menuItem).previousSiblings();
parentSiblings.each(function(toolbarItem) {
calculatedOffset += toolbarItem.getWidth()-1;
var parentWidth = $(this.menuItem).getWidth();
var parentOffset = $(this.menuItem).viewportOffset();
this.menu.setStyle({
right: document.viewport.getWidth() - parentOffset[0] - parentWidth + 'px'
});
calculatedOffset = calculatedOffset - ownWidth + parentWidth;
this.menu.setStyle({ left: calculatedOffset-2 + 'px' });
},
......
parameters: { ajaxID: this.ajaxIDloadMenu },
onSuccess: function(xhr) {
if (!this.menu.visible()) {
this.positionMenu();
Effect.Appear(this.menu, {
duration: 0.2,
afterFinish: function() { this.positionMenu(); }.bind(this)
});
}
}.bind(this)
......
/**
* updates the number of open documents in the toolbar
* updates the number of open documents in the toolbar according to the
* first parameter. If "num" is smaller than "0", the number of opendocs
* is counted from the open menu
*/
updateNumberOfDocs: function(num, doNotUpdateMenu) {
updateNumberOfDocs: function(num, explicitlyUpdateMenu) {
// re-render the menu e.g. if a document was closed inside the menu
if (this.menu.visible() && explicitlyUpdateMenu) {
this.showMenu();
}
if (num < 0) {
num = $$('tr.opendoc').length;
}
......
num = '';
}
$('tx-opendocs-num').innerHTML = num;
if (this.menu.visible() && !doNotUpdateMenu) {
this.showMenu();
}
},
/**
* this function calls the backend to close an open documentshould let the
* this function calls the backend to close an open document
*/
closeDocument: function(md5sum) {
new Ajax.Updater(this.menu, this.ajaxScript, {
parameters: { ajaxID: this.ajaxIDcloseDoc, md5sum: md5sum },
onSuccess: function() { this.updateNumberOfDocs(-1, true); }.bind(this)
onComplete: function() { this.updateNumberOfDocs(-1, false); }.bind(this)
});
return false;
}
(3-3/3)