Rjain has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/79839


Change subject: Added a tab to toggle visibility of annotations
......................................................................

Added a tab to toggle visibility of annotations

Bug: 52064
Change-Id: I321581cdf9f56ddf9dbf0696fd51c4578f6c674d
---
M Annotator.i18n.php
M modules/Annotator.js
2 files changed, 70 insertions(+), 45 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Annotator 
refs/changes/39/79839/1

diff --git a/Annotator.i18n.php b/Annotator.i18n.php
index 21b3fb3..de5192f 100644
--- a/Annotator.i18n.php
+++ b/Annotator.i18n.php
@@ -14,6 +14,7 @@
  */
 $messages['en'] = array(
        'annotator-desc' => 'Allows inline comments on pages',
+       'load-annotations' => 'Load Annotations',
 );
 
 /** Message documentation (Message documentation)
@@ -22,6 +23,7 @@
  */
 $messages['qqq'] = array(
        'annotator-desc' => 
'{{desc|name=Annotator|url=http://www.mediawiki.org/wiki/Extension:Annotator}}',
+       'load-annotations' => 'The message shown in the tab which allows the 
user to load annotations on a page',
 );
 
 /** Asturian (asturianu)
diff --git a/modules/Annotator.js b/modules/Annotator.js
index 3a25f07..67dbab3 100755
--- a/modules/Annotator.js
+++ b/modules/Annotator.js
@@ -10,53 +10,76 @@
                //Get the userId
                userId = mw.config.get( 'wgUserId' );
                //Call the annotations
-               if( userId === null ) {
-                       annotations = $( '#mw-content-text' ).annotator({ 
readOnly: true });
-               }
-               else {
-                       annotations = $( '#mw-content-text' ).annotator();
-               }
-               //Add the store plugin and modify the urls according to 
mediawiki api
-               annotations.annotator( 'addPlugin', 'Store', {
-                       prefix: mw.util.wikiScript( 'api' ),
-                       urls: {
-                               create: 
'?action=annotator-create&format=json&revid=' + revid,
-                               update: 
'?action=annotator-update&format=json&id=:id',
-                               read: 
'?action=annotator-read&format=json&id=:id',
-                               destroy: 
'?action=annotator-destroy&format=json&id=:id',
-                               search: '?action=annotator-search&format=json'
-                       },
-                       loadFromSearch: {
-                               revid: revid
-                       }
-               } );
 
-               //add the permissions plugin
-               annotations.annotator('addPlugin', 'Permissions', {
-                       
-                       user: {
-                               id: userId,
-                               username: mw.user.getName()
-                       },
-                       permissions: {
-                               'read': [],
-                               'update': [ userId ],
-                               'delete': [ userId ]
-                       },
-                       userId: function (user) {
-                               if( user && user.id ) {
-                                       return user.id;
+               //Add a tab to view the page with annotations
+               var caViewAnnotations,
+                       pTabsId = $( '#p-views' ).length ?  'p-views' : 
'p-cactions',
+                       $caViewAnnotations = $('#ca-load-annotations'),
+                       caViewAnnotations = mw.util.addPortletLink(
+                               pTabsId,
+                               '',
+                               mw.msg('load-annotations'),
+                               'ca-load-annotations'
+                               );
+
+               //load the annotations when the tab is clicked
+               $('#ca-load-annotations').click(function() {
+
+                       $( '#ca-view' ).removeClass( 'selected' );
+                       $( '[id^="ca-nstab-"]' ).removeClass( 'selected' );
+                       $( '#ca-talk' ).removeClass( 'selected' );
+                       $(this).addClass( 'selected' );
+
+                       if( userId === null ) {
+                               annotations = $( '#mw-content-text' 
).annotator({ readOnly: true });
+                       }
+                       else {
+                               annotations = $( '#mw-content-text' 
).annotator();
+                       }
+                       //Add the store plugin and modify the urls according to 
mediawiki api
+                       annotations.annotator( 'addPlugin', 'Store', {
+                               prefix: mw.util.wikiScript( 'api' ),
+                               urls: {
+                                       create: 
'?action=annotator-create&format=json&revid=' + revid,
+                                       update: 
'?action=annotator-update&format=json&id=:id',
+                                       read: 
'?action=annotator-read&format=json&id=:id',
+                                       destroy: 
'?action=annotator-destroy&format=json&id=:id',
+                                       search: 
'?action=annotator-search&format=json'
+                               },
+                               loadFromSearch: {
+                                       revid: revid
                                }
-                               return user;
-                       },
-                       userString: function (user) {
-                               if( user && user.username ) {
-                                       return user.username;
-                               }
-                               return user;
-                       },
-                       showViewPermissionsCheckbox: false,
-                       showEditPermissionsCheckbox: false
+                       } );
+
+                       //add the permissions plugin
+                       annotations.annotator('addPlugin', 'Permissions', {
+                               
+                               user: {
+                                       id: userId,
+                                       username: mw.user.getName()
+                               },
+                               permissions: {
+                                       'read': [],
+                                       'update': [ userId ],
+                                       'delete': [ userId ]
+                               },
+                               userId: function (user) {
+                                       if( user && user.id ) {
+                                               return user.id;
+                                       }
+                                       return user;
+                               },
+                               userString: function (user) {
+                                       if( user && user.username ) {
+                                               return user.username;
+                                       }
+                                       return user;
+                               },
+                               showViewPermissionsCheckbox: false,
+                               showEditPermissionsCheckbox: false
+                       });
+                       return false;
                });
+
        } )
 }( mediaWiki, jQuery ) );

-- 
To view, visit https://gerrit.wikimedia.org/r/79839
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I321581cdf9f56ddf9dbf0696fd51c4578f6c674d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Annotator
Gerrit-Branch: master
Gerrit-Owner: Rjain <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to