diff --git a/appinfo/info.xml b/appinfo/info.xml index ece3d23..d4c488c 100644 --- a/appinfo/info.xml +++ b/appinfo/info.xml @@ -6,6 +6,6 @@ Thomas Tanghus 4.93 false - 0.3.2 + 0.3.3 Journal view from calendar diff --git a/css/icons.css b/css/icons.css new file mode 100644 index 0000000..435dca8 --- /dev/null +++ b/css/icons.css @@ -0,0 +1,7 @@ +.delete { background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; } +.edit { background:url('%webroot%/core/img/actions/rename.svg') no-repeat center; } +.share { background:url('%webroot%/core/img/actions/share.svg') no-repeat center; } +.mail { background:url('%webroot%/core/img/actions/mail.svg') no-repeat center; } +.download { background:url('%webroot%/core/img/actions/download.svg') no-repeat center; } +.globe { background:url('%webroot%/core/img/actions/public.svg') no-repeat center; } +.cog { background:url('%webroot%/core/img/actions/settings.svg') no-repeat center; float: right; } diff --git a/css/journal.css b/css/journal.css index d00cb40..ad2a4d2 100644 --- a/css/journal.css +++ b/css/journal.css @@ -50,16 +50,7 @@ input { font-size: 1em; font-weight: bold; } #actions { float: right; padding-right: 1em; } #actions a { display: inline-block; width: 16px; height: 16px; opacity: 0.5; padding: 0 0.3em; } #actions a:hover { opacity: 1; } -.add { background:url('%webroot%/core/img/actions/add.svg') no-repeat center; clear: both; } -.delete { background:url('%webroot%/core/img/actions/delete.svg') no-repeat center; } -.edit { background:url('%webroot%/core/img/actions/rename.svg') no-repeat center; } -.share { background:url('%webroot%/core/img/actions/share.svg') no-repeat center; } -.mail { background:url('%webroot%/core/img/actions/mail.svg') no-repeat center; } -.upload { background:url('%webroot%/core/img/actions/upload.svg') no-repeat center; } -.download { background:url('%webroot%/core/img/actions/download.svg') no-repeat center; } -.cloud { background:url('%webroot%/core/img/places/picture.svg') no-repeat center; } -.globe { background:url('%webroot%/core/img/actions/public.svg') no-repeat center; } -.cog { background:url('%webroot%/core/img/actions/settings.svg') no-repeat center; float: right; } +.cog { float: right; } .drop { margin-right: 0.5em !important; } #settings_status { padding: 0.2em; font-weight: bold; float: left; border-radius: 3px; } #firstrun { diff --git a/index.php b/index.php index 4539301..a027a9f 100644 --- a/index.php +++ b/index.php @@ -36,7 +36,7 @@ } if(count($errors) == 0) { - $categories = OC_Calendar_App::getCategoryOptions(); + $categories = OCA\Journal\App::getCategories(); $calendars = array(); $singlecalendar = (bool)OCP\Config::getUserValue(OCP\User::getUser(), 'journal', 'single_calendar', false); $calendars = OC_Calendar_Calendar::allCalendars(OCP\User::getUser(), true); @@ -48,9 +48,16 @@ // Load a specific entry? $id = isset($_GET['id']) ? $_GET['id'] : null; + // Version check + list($version,) = \OCP\Util::getVersion(); + OCP\Util::addScript('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addScript('contacts','jquery.multi-autocomplete'); - OCP\Util::addScript('','oc-vcategories'); + if($version < 6) { + OCP\Util::addScript('','oc-vcategories'); + } else { + OCP\Util::addScript('','tags'); + } OCP\Util::addScript('journal', 'jquery.rte'); OCP\Util::addScript('journal', 'jquery.textchange'); OCP\Util::addScript('journal', 'journal'); @@ -58,6 +65,9 @@ OCP\Util::addStyle('3rdparty/timepicker', 'jquery.ui.timepicker'); OCP\Util::addStyle('journal', 'rte'); OCP\Util::addStyle('journal', 'journal'); + if($version < 6) { + OCP\Util::addStyle('journal', 'icons'); + } OCP\App::setActiveNavigationEntry('journal_index'); } @@ -71,5 +81,6 @@ $tmpl->assign('calendars', $calendars); $tmpl->assign('singlecalendar', $singlecalendar); $tmpl->assign('id', $id); + $tmpl->assign('version', $version); } $tmpl->printPage(); diff --git a/js/journal.js b/js/journal.js index 20d3fc6..8b87d83 100644 --- a/js/journal.js +++ b/js/journal.js @@ -72,8 +72,20 @@ String.prototype.zeroPad = function(digits) { OC.Journal = { categories:undefined, + version:undefined, init:function() { var self = this; + this.version = $('#journal-content').data('version'); + if(this.version < 6) { + OCCategories.changed = OC.Journal.categoriesChanged; + OCCategories.app = 'journal'; + } else { + $(OC.Tags).on('change', function(event, data) { + if(data.type === 'journal') { + self.categoriesChanged(data.tags); + } + }); + } this.setEnabled(false); // Fetch journal entries. If it's a direct link 'id' will be loaded. var id = parseInt(window.location.hash.substr(1)); @@ -124,7 +136,11 @@ OC.Journal = { } }, categoriesChanged:function(newcategories) { // Categories added/deleted. - this.categories = $.map(newcategories, function(v) {return v;}); + if(this.version < 6) { + this.categories = $.map(newcategories, function(v) {return v;}); + } else { + this.categories = $.map(newcategories, function(v) {return v.name;}); + } $('#categories').multiple_autocomplete('option', 'source', this.categories); }, propertyContainerFor:function(obj) { @@ -567,8 +583,6 @@ OC.Journal = { }; $(document).ready(function(){ - OCCategories.changed = OC.Journal.categoriesChanged; - OCCategories.app = 'journal'; // Initialize controls. $('#categories').multiple_autocomplete({source: OC.Journal.categories}); @@ -666,7 +680,11 @@ $(document).ready(function(){ $('#metadata').on('click', '#editcategories', function(event) { $(this).tipsy('hide'); - OCCategories.edit(); + if(OC.Journal.version < 6) { + OCCategories.edit(); + } else { + OC.Tags.edit('journal'); + } }); $('#metadata').on('click', '#delete', function(event) { diff --git a/js/jquery.rte.js b/js/jquery.rte.js index 9ddc544..67b25df 100644 --- a/js/jquery.rte.js +++ b/js/jquery.rte.js @@ -65,7 +65,7 @@ $.widget( 'ui.rte', { }); }, text: function(str) { - console.log('function text'); + console.log('function text', str); if(str != undefined) { this.mirror.html(str); this.element.val(str); @@ -215,7 +215,11 @@ $.widget( 'ui.rte', { this.mirror.trigger('change'); break; case 'text': + try { this.element.val($(this.mirror.html().replace(/
/g, "\n")).text()); + } catch(e) { + console.warn('Exception:', e); + } this.mirror.hide(); this.element.show(); this.element.trigger('resize'); diff --git a/lib/app.php b/lib/app.php index 47000c0..6b42518 100644 --- a/lib/app.php +++ b/lib/app.php @@ -212,8 +212,21 @@ public static function getDefaultCategories() { * @return (object) $vcategories */ protected static function getVCategories() { + // Version check + list($version,) = \OCP\Util::getVersion(); + if (is_null(self::$categories)) { - self::$categories = new \OC_VCategories('journal', null, self::getDefaultCategories()); + if($version < 6) { + self::$categories = new \OC_VCategories('journal', null, self::getDefaultCategories()); + } else { + $categories = \OC::$server->getTagManager()->load('journal'); + if($categories->isEmpty('journal')) { + self::scanCategories(); + } + self::$categories = \OC::$server->getTagManager() + ->load('journal', self::getDefaultCategories()); + } + } return self::$categories; } @@ -222,8 +235,21 @@ protected static function getVCategories() { * @brief returns the categories of the vcategories object * @return (array) $categories */ - public static function getCategoryOptions(){ - $categories = self::getVCategories()->categories(); + public static function getCategories(){ + // Version check + list($version,) = \OCP\Util::getVersion(); + + if($version < 6) { + $categories = self::getVCategories()->categories(); + } else { + + $getNames = function($tag) { + return $tag['name']; + }; + $categories = self::getVCategories()->getTags(); + $categories = array_map($getNames, $categories); + } + return $categories; } @@ -231,14 +257,14 @@ public static function getCategoryOptions(){ * @brief returns the categories for the user * @return (Array) $categories */ - public static function getCategories() { + /*public static function getCategories() { $categories = self::getVCategories()->categories(); if(count($categories) == 0) { self::scanCategories(); $categories = self::$categories->categories(); } return ($categories ? $categories : self::getDefaultCategories()); - } + }*/ /** * scan journals for categories. diff --git a/templates/index.pt b/templates/index.pt index 3a0f1af..7c3612c 100644 --- a/templates/index.pt +++ b/templates/index.pt @@ -1,4 +1,4 @@ -
+
- +
    @@ -66,10 +66,10 @@
    - - - - + + + +