diff options
author | Jan Holesovsky <kendy@collabora.com> | 2015-11-04 23:49:23 +0300 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2015-11-04 23:49:23 +0300 |
commit | e6593def87b00f2ddbe15bad257a415493f187e1 (patch) | |
tree | d91dc73ed07967bd2f58fc378ee8fab23854ace9 | |
parent | 37f61b405681767b6dcc2c115c71b653e3ee2527 (diff) |
cloudsuite: Add buttons to create new spreadsheet and new presentation.
-rw-r--r-- | controller/documentcontroller.php | 21 | ||||
-rw-r--r-- | css/style.css | 23 | ||||
-rw-r--r-- | js/documents.js | 22 | ||||
-rw-r--r-- | lib/helper.php | 2 | ||||
-rw-r--r-- | templates/documents.php | 10 |
5 files changed, 60 insertions, 18 deletions
diff --git a/controller/documentcontroller.php b/controller/documentcontroller.php index a3ee6d4a..81c57721 100644 --- a/controller/documentcontroller.php +++ b/controller/documentcontroller.php @@ -77,17 +77,34 @@ class DocumentController extends Controller{ * @NoAdminRequired */ public function create(){ + $mimetype = $this->request->post['mimetype']; + $view = new View('/' . $this->uid . '/files'); $dir = $this->settings->getUserValue($this->uid, $this->appName, 'save_path', '/'); if (!$view->is_dir($dir)){ $dir = '/'; } - $path = Helper::getNewFileName($view, $dir . '/New Document.odt'); + + $basename = $this->l10n->t('New Document.odt'); + switch ($mimetype) { + case 'application/vnd.oasis.opendocument.spreadsheet': + $basename = $this->l10n->t('New Spreadsheet.ods'); + break; + case 'application/vnd.oasis.opendocument.presentation': + $basename = $this->l10n->t('New Presentation.odp'); + break; + default: + // to be safe + $mimetype = 'application/vnd.oasis.opendocument.text'; + break; + } + + $path = Helper::getNewFileName($view, $dir . '/' . $basename); $content = ''; if (class_exists('\OC\Files\Type\TemplateManager')){ $manager = \OC_Helper::getFileTemplateManager(); - $content = $manager->getTemplate('application/vnd.oasis.opendocument.text'); + $content = $manager->getTemplate($mimetype); } if (!$content){ diff --git a/css/style.css b/css/style.css index b38a1caf..ccdcad83 100644 --- a/css/style.css +++ b/css/style.css @@ -34,26 +34,29 @@ box-sizing: border-box; display: inline-block; position: relative; - height: 100px; + height: 46px; width: 200px; background-repeat: no-repeat; background-size: 32px; - background-position: 50%; + background-position: 3%; } -.add-document a.add { - border-bottom: 1px solid #fff; -} -.add-document .add, +.add-document .add-odt, +.add-document .add-ods, +.add-document .add-odp, .add-document .upload { opacity: .7; border: 1px solid #e8e8e8; } .add-document .upload { - margin-top: 4px; -} -.add-document .add:hover, -.add-document .add:focus, + margin-top: 12px; +} +.add-document .add-odt:hover, +.add-document .add-ods:hover, +.add-document .add-odp:hover, +.add-document .add-odt:focus, +.add-document .add-ods:focus, +.add-document .add-odp:focus, .add-document #upload:hover .upload, .add-document .upload:focus { opacity: 1; diff --git a/js/documents.js b/js/documents.js index 8b9f6b2f..1df005cd 100644 --- a/js/documents.js +++ b/js/documents.js @@ -374,8 +374,22 @@ var documentsMain = { }); }, - onCreate: function(event){ + onCreateODT: function(event){ event.preventDefault(); + documentsMain.create('application/vnd.oasis.opendocument.text'); + }, + + onCreateODS: function(event){ + event.preventDefault(); + documentsMain.create('application/vnd.oasis.opendocument.spreadsheet'); + }, + + onCreateODP: function(event){ + event.preventDefault(); + documentsMain.create('application/vnd.oasis.opendocument.presentation'); + }, + + create: function(mimetype){ var docElem = $('.documentslist .template').clone(); docElem.removeClass('template'); docElem.addClass('document'); @@ -383,7 +397,7 @@ var documentsMain = { docElem.show(); $.post( OC.generateUrl('apps/documents/ajax/documents/create'), - {}, + { mimetype : mimetype }, function(response){ if (response && response.fileid){ documentsMain.prepareSession(); @@ -692,7 +706,9 @@ $(document).ready(function() { } }); - $('.add-document').on('click', '.add', documentsMain.onCreate); + $('.add-document').on('click', '.add-odt', documentsMain.onCreateODT); + $('.add-document').on('click', '.add-ods', documentsMain.onCreateODS); + $('.add-document').on('click', '.add-odp', documentsMain.onCreateODP); var file_upload_start = $('#file_upload_start'); if (typeof supportAjaxUploadWithProgress !== 'undefined' && supportAjaxUploadWithProgress()) { diff --git a/lib/helper.php b/lib/helper.php index 2f02be51..e67d32ad 100644 --- a/lib/helper.php +++ b/lib/helper.php @@ -21,7 +21,7 @@ class Helper { while ($view->file_exists($path)){ $fileNum += 1; - $path = preg_replace('/(\.odt|' . $prepend . '\(\d+\)\.odt)$/', $prepend . '(' . $fileNum . ').odt', $path); + $path = preg_replace('/(\.|' . $prepend . '\(\d+\)\.)([^.]*)$/', $prepend . '(' . $fileNum . ').$2', $path); }; return $path; diff --git a/templates/documents.php b/templates/documents.php index 1475c8f4..ccce1174 100644 --- a/templates/documents.php +++ b/templates/documents.php @@ -11,9 +11,15 @@ script('files', 'jquery.fileupload'); <div id="documents-content"> <ul class="documentslist"> <li class="add-document"> - <a class="icon-add add svg" target="_blank" href=""> - <label><?php p($l->t('New document')) ?></label> + <a class="icon-add add-odt svg" target="_blank" href=""> + <label><?php p($l->t('New Document')) ?></label> </a> + <a class="icon-add add-ods svg" target="_blank" href=""> + <label><?php p($l->t('New Spreadsheet')) ?></label> + </a> + <a class="icon-add add-odp svg" target="_blank" href=""> + <label><?php p($l->t('New Presentation')) ?></label> + </a> <div id="upload" title="<?php p($l->t('Upload (max. %s)', array($_['uploadMaxHumanFilesize']))) ?>"> <form data-upload-id="1" id="data-upload-form" |