Merge pull request #494 from owncloud/fix-486

Use closure for navigation.
This commit is contained in:
VicDeo 2015-06-17 09:20:11 +03:00
commit 28fb6a4412
6 changed files with 80 additions and 64 deletions

View File

@ -21,61 +21,72 @@
* *
*/ */
OCP\App::register(array('order' => 70, 'id' => 'documents', 'name' => 'Documents')); namespace OCA\Documents\AppInfo;
//OCP\App::registerAdmin('documents', 'settings');
\OCP\App::registerAdmin('documents', 'admin');
OCP\App::registerPersonal('documents', 'personal');
OCP\App::addNavigationEntry(array( use OCA\Documents\Filter\Office;
'id' => 'documents_index', use OCA\Documents\Config;
'order' => 2,
'href' => OCP\Util::linkTo('documents/', 'index.php'), $app = new Application();
'icon' => OCP\Util::imagePath('documents', 'documents.svg'), $c = $app->getContainer();
'name' => OCA\Documents\Config::getL10n()->t('Documents'))
); \OCP\App::register(['order' => 70, 'id' => 'documents', 'name' => 'Documents']);
//\OCP\App::registerAdmin('documents', 'settings');
\OCP\App::registerAdmin('documents', 'admin');
\OCP\App::registerPersonal('documents', 'personal');
$navigationEntry = function () use ($c) {
return [
'id' => 'documents_index',
'order' => 2,
'href' => \OCP\Util::linkTo('documents/', 'index.php'),
'icon' => \OCP\Util::imagePath('documents', 'documents.svg'),
'name' => $c->query('L10N')->t('Documents')
];
};
$c->getServer()->getNavigationManager()->add($navigationEntry);
//Script for registering file actions //Script for registering file actions
$url = OC::$server->getRequest()->server['REQUEST_URI']; $url = \OC::$server->getRequest()->server['REQUEST_URI'];
if (preg_match('%index.php/apps/files(/.*)?%', $url)) { if (preg_match('%index.php/apps/files(/.*)?%', $url)) {
OCP\Util::addScript('documents', 'viewer/viewer'); \OCP\Util::addScript('documents', 'viewer/viewer');
} }
if (OCA\Documents\Config::getConverter() !== 'off'){ if (Config::getConverter() !== 'off'){
$docFilter = new OCA\Documents\Filter\Office( $docFilter = new Office(
array( [
'read' => 'read' =>
array ( [
'target' => 'application/vnd.oasis.opendocument.text', 'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8', 'format' => 'odt:writer8',
'extension' => 'odt' 'extension' => 'odt'
), ],
'write' => 'write' =>
array ( [
'target' => 'application/msword', 'target' => 'application/msword',
'format' => 'doc', 'format' => 'doc',
'extension' => 'doc' 'extension' => 'doc'
) ]
) ]
); );
$docxFilter = new OCA\Documents\Filter\Office( $docxFilter = new Office(
array ( [
'read' => 'read' =>
array ( [
'target' => 'application/vnd.oasis.opendocument.text', 'target' => 'application/vnd.oasis.opendocument.text',
'format' => 'odt:writer8', 'format' => 'odt:writer8',
'extension' => 'odt' 'extension' => 'odt'
), ],
'write' => 'write' =>
array ( [
'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'target' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'format' => 'docx', 'format' => 'docx',
'extension' => 'docx' 'extension' => 'docx'
) ]
) ]
); );
} }
//Listen to delete file signal //Listen to delete file signal
OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Documents\Storage", "onDelete"); \OCP\Util::connectHook('OC_Filesystem', 'delete', "OCA\Documents\Storage", "onDelete");

View File

@ -5,7 +5,7 @@ $(document).ready(function(){
var documentsSettings = { var documentsSettings = {
save : function() { save : function() {
$('#docs_apply').attr('disabled', true); $('#docs_apply').attr('disabled', true);
var data = { var data = {
converter : $('[name="docs_converter"]:checked').val() converter : $('[name="docs_converter"]:checked').val()
}; };

View File

@ -14,8 +14,8 @@ $(document).ready(function(){
$('#documents-default-path').blur(documentsSettings.save); $('#documents-default-path').blur(documentsSettings.save);
$('#documents-default-path').keypress(function( event ) { $('#documents-default-path').keypress(function( event ) {
if (event.which == 13) { if (event.which == 13) {
event.preventDefault(); event.preventDefault();
documentsSettings.save(); documentsSettings.save();
} }
}); });
}); });

View File

@ -8,7 +8,7 @@ $(document).ready(function(){
$.post(OC.generateUrl('apps/documents/ajax/config/unstable'), data, documentsSettings.afterSave); $.post(OC.generateUrl('apps/documents/ajax/config/unstable'), data, documentsSettings.afterSave);
}, },
afterSave : function(){ afterSave : function(){
documentsMain.useUnstable = $('#webodf-unstable').attr('checked')==="checked" documentsMain.useUnstable = $('#webodf-unstable').attr('checked')==="checked";
} }
}; };
$('#webodf-unstable').change(documentsSettings.save); $('#webodf-unstable').change(documentsSettings.save);

View File

@ -13,21 +13,25 @@ var odfViewer = {
], ],
register : function(response){ register : function(response){
var i,
mimeRead,
mimeUpdate;
if (response && response.mimes){ if (response && response.mimes){
jQuery.each(response.mimes, function(i, mime){ jQuery.each(response.mimes, function(i, mime){
odfViewer.supportedMimesRead.push(mime); odfViewer.supportedMimesRead.push(mime);
odfViewer.supportedMimesUpdate.push(mime); odfViewer.supportedMimesUpdate.push(mime);
}); });
} }
for (var i = 0; i < odfViewer.supportedMimesRead.length; ++i) { for (i = 0; i < odfViewer.supportedMimesRead.length; ++i) {
var mime = odfViewer.supportedMimesRead[i]; mimeRead = odfViewer.supportedMimesRead[i];
OCA.Files.fileActions.register(mime, 'View', OC.PERMISSION_READ, '', odfViewer.onView); OCA.Files.fileActions.register(mimeRead, 'View', OC.PERMISSION_READ, '', odfViewer.onView);
OCA.Files.fileActions.setDefault(mime, 'View'); OCA.Files.fileActions.setDefault(mimeRead, 'View');
} }
for (var i = 0; i < odfViewer.supportedMimesUpdate.length; ++i) { for (i = 0; i < odfViewer.supportedMimesUpdate.length; ++i) {
var mime = odfViewer.supportedMimesUpdate[i]; mimeUpdate = odfViewer.supportedMimesUpdate[i];
OCA.Files.fileActions.register( OCA.Files.fileActions.register(
mime, mimeUpdate,
'Edit', 'Edit',
OC.PERMISSION_UPDATE, OC.PERMISSION_UPDATE,
OC.imagePath('core', 'actions/rename'), OC.imagePath('core', 'actions/rename'),
@ -39,7 +43,7 @@ var odfViewer = {
dispatch : function(filename){ dispatch : function(filename){
if (odfViewer.supportedMimesUpdate.indexOf(OCA.Files.fileActions.getCurrentMimeType()) !== -1 if (odfViewer.supportedMimesUpdate.indexOf(OCA.Files.fileActions.getCurrentMimeType()) !== -1
&& OCA.Files.fileActions.getCurrentPermissions() & OC.PERMISSION_UPDATE && OCA.Files.fileActions.getCurrentPermissions() & OC.PERMISSION_UPDATE
){ ){
odfViewer.onEdit(filename); odfViewer.onEdit(filename);
} else { } else {
@ -48,7 +52,8 @@ var odfViewer = {
}, },
onEdit : function(fileName, context){ onEdit : function(fileName, context){
var fileId = context.$file.attr('data-id'); var location,
fileId = context.$file.attr('data-id');
window.location = OC.linkTo('documents', 'index.php') + '#' + fileId; window.location = OC.linkTo('documents', 'index.php') + '#' + fileId;
}, },
@ -58,12 +63,13 @@ var odfViewer = {
if (odfViewer.isDocuments){ if (odfViewer.isDocuments){
//Documents view //Documents view
var location = filename; location = filename;
} else { } else {
//Public page, files app, etc //Public page, files app, etc
var dirName = $('#dir').val()!='/' ? $('#dir').val() + '/' : '/'; var dirName = $('#dir').val()!='/' ? $('#dir').val() + '/' : '/';
var location = OC.filePath('documents', 'ajax', 'download.php') + '?path=' + encodeURIComponent(dirName) + encodeURIComponent(filename) location = OC.filePath('documents', 'ajax', 'download.php') + '?path='
+ '&requesttoken=' + encodeURIComponent(oc_requesttoken); + encodeURIComponent(dirName) + encodeURIComponent(filename)
+ '&requesttoken=' + encodeURIComponent(oc_requesttoken);
OC.addStyle('documents', '3rdparty/webodf/wodotexteditor'); OC.addStyle('documents', '3rdparty/webodf/wodotexteditor');
} }

View File

@ -42,8 +42,7 @@ define("owncloud/widgets/ocToolbar",
ocClose.startup(); ocClose.startup();
}); });
return callback(ocToolbar); return callback(ocToolbar);
} };
;
// init // init
makeWidget(function (widget) { makeWidget(function (widget) {
return callback(widget); return callback(widget);