[MediaWiki-commits] [Gerrit] Implement the new schema for when the popups are disabled - change (mediawiki...Popups)

2015-04-06 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Implement the new schema for when the popups are disabled
..


Implement the new schema for when the popups are disabled

Bug: T88167
Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47
---
M resources/ext.popups.core.js
M resources/ext.popups.logger.js
2 files changed, 34 insertions(+), 5 deletions(-)

Approvals:
  Werdna: Looks good to me, approved
  Nuria: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index dbb454f..fa4a26e 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -164,12 +164,39 @@
};
 
mw.hook( 'wikipage.content').add( function ( $content ) {
-   if ( mw.popups.enabled ) {
-   mw.popups.$content = $content;
+   mw.popups.$content = $content;
+   var $elements = mw.popups.selectPopupElements();
 
-   var $elements = mw.popups.selectPopupElements();
+   if ( mw.popups.enabled ) {
mw.popups.removeTooltips( $elements );
mw.popups.setupTriggers( $elements );
+   } else {
+   // Events are logged even when Hovercards are disabled
+   // See T88166 for details
+   $elements.on( 'click', function ( event ) {
+   if ( mw.popups.logger === undefined ) {
+   return true;
+   }
+
+   var
+   $this = $( this ),
+   href = $this.attr( 'href' ),
+   action = mw.popups.logger.getAction( 
event ),
+   logEvent = {
+   pageTitleHover: $this.attr( 
'title' ),
+   pageTitleSource: mw.config.get( 
'wgTitle' ),
+   popupEnabled: mw.popups.enabled,
+   action: action
+   },
+   logPromise = mw.popups.logger.log( 
logEvent );
+
+   if ( action  === 'opened in same tab' ) {
+   event.preventDefault();
+   logPromise.then( function () {
+   window.location.href = href;
+   } );
+   }
+   } );
}
} );
 
diff --git a/resources/ext.popups.logger.js b/resources/ext.popups.logger.js
index e2b3ef2..e08297c 100644
--- a/resources/ext.popups.logger.js
+++ b/resources/ext.popups.logger.js
@@ -40,8 +40,10 @@
}
 
// Get duration from  time
-   event.duration = Math.floor( mw.now() - event.time );
-   delete event.time;
+   if ( $.isNumeric( event.time ) ) {
+   event.duration = Math.floor( mw.now() - event.time );
+   delete event.time;
+   }
 
return  mw.eventLog.logEvent( 'Popups', event );
};

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

Gerrit-MessageType: merged
Gerrit-Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna psax...@wikimedia.org
Gerrit-Reviewer: Nuria nu...@wikimedia.org
Gerrit-Reviewer: Werdna agarr...@wikimedia.org
Gerrit-Reviewer: jenkins-bot 

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Implement the new schema for when the popups are disabled - change (mediawiki...Popups)

2015-03-25 Thread Prtksxna (Code Review)
Prtksxna has uploaded a new change for review.

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

Change subject: Implement the new schema for when the popups are disabled
..

Implement the new schema for when the popups are disabled

Bug: T88167
Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47
---
M resources/ext.popups.core.js
M resources/ext.popups.logger.js
2 files changed, 34 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/28/199828/1

diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index dbb454f..fa4a26e 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -164,12 +164,39 @@
};
 
mw.hook( 'wikipage.content').add( function ( $content ) {
-   if ( mw.popups.enabled ) {
-   mw.popups.$content = $content;
+   mw.popups.$content = $content;
+   var $elements = mw.popups.selectPopupElements();
 
-   var $elements = mw.popups.selectPopupElements();
+   if ( mw.popups.enabled ) {
mw.popups.removeTooltips( $elements );
mw.popups.setupTriggers( $elements );
+   } else {
+   // Events are logged even when Hovercards are disabled
+   // See T88166 for details
+   $elements.on( 'click', function ( event ) {
+   if ( mw.popups.logger === undefined ) {
+   return true;
+   }
+
+   var
+   $this = $( this ),
+   href = $this.attr( 'href' ),
+   action = mw.popups.logger.getAction( 
event ),
+   logEvent = {
+   pageTitleHover: $this.attr( 
'title' ),
+   pageTitleSource: mw.config.get( 
'wgTitle' ),
+   popupEnabled: mw.popups.enabled,
+   action: action
+   },
+   logPromise = mw.popups.logger.log( 
logEvent );
+
+   if ( action  === 'opened in same tab' ) {
+   event.preventDefault();
+   logPromise.then( function () {
+   window.location.href = href;
+   } );
+   }
+   } );
}
} );
 
diff --git a/resources/ext.popups.logger.js b/resources/ext.popups.logger.js
index e2b3ef2..c24fce4 100644
--- a/resources/ext.popups.logger.js
+++ b/resources/ext.popups.logger.js
@@ -40,8 +40,10 @@
}
 
// Get duration from  time
-   event.duration = Math.floor( mw.now() - event.time );
-   delete event.time;
+   if ( event.time !== undefined ) {
+   event.duration = Math.floor( mw.now() - event.time );
+   delete event.time;
+   }
 
return  mw.eventLog.logEvent( 'Popups', event );
};

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If8f1c97379bd37958ec6064242bdebf5fde14b47
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna psax...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Implement the new schema for when the popups are disabled - change (mediawiki...Popups)

2015-03-20 Thread Prtksxna (Code Review)
Prtksxna has uploaded a new change for review.

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

Change subject: Implement the new schema for when the popups are disabled
..

Implement the new schema for when the popups are disabled

Bug: T88167
Change-Id: I2185e68d3bc5b81050a32612afe6fe51833dc207
---
M resources/ext.popups.core.js
M resources/ext.popups.logger.js
2 files changed, 43 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/91/198191/1

diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index dbb454f..35319ce 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -164,12 +164,18 @@
};
 
mw.hook( 'wikipage.content').add( function ( $content ) {
-   if ( mw.popups.enabled ) {
-   mw.popups.$content = $content;
+   mw.popups.$content = $content;
+   var $elements = mw.popups.selectPopupElements();
 
-   var $elements = mw.popups.selectPopupElements();
+   if ( mw.popups.enabled ) {
mw.popups.removeTooltips( $elements );
mw.popups.setupTriggers( $elements );
+   } else {
+   // Events are logged even when hovercards are disabled
+   // See T88166 for details
+   $elements.on( 'click', function () {
+   mw.popups.logger.logLinkClick( event, $( this ) 
);
+   } );
}
} );
 
diff --git a/resources/ext.popups.logger.js b/resources/ext.popups.logger.js
index 03b75ba..93d64d1 100644
--- a/resources/ext.popups.logger.js
+++ b/resources/ext.popups.logger.js
@@ -70,6 +70,33 @@
};
 
/**
+* Called only when popups are disabled
+* Called on links that would've shown popups
+*
+* @method logLinkClick
+* @param {jquery.Event) event
+* @param {jQuery.Element} $el The a element that was clicked
+*/
+   logger.logLinkClick = function ( event, $el ) {
+   var promise,
+   href = $el.attr( 'href' ),
+   action = logger.getAction( event );
+   // logger.action gets reset after log() so we need
+   // a local variable to track it
+
+   logger.action = action;
+   logger.pageTitleHover = $el.attr( 'title' );
+   promise = logger.log();
+
+   if ( action === 'opened in same tab' ) {
+   event.preventDefault();
+   promise.then( function () {
+   window.location.href = href;
+   } );
+   }
+   }
+
+   /**
 * Logs the popup event as defined in the following schema-
 * https://meta.wikimedia.org/wiki/Schema:Popups
 *
@@ -92,14 +119,19 @@
 */
logger.getEventObject = function () {
var event = {
-   'duration': Math.round( logger.duration ),
'action': logger.action,
'popupEnabled': mw.popups.enabled,
-   'popupDelay': mw.popups.render.POPUP_DELAY,
'pageTitleSource': mw.config.get( 'wgTitle' ),
'pageTitleHover': logger.pageTitleHover
};
 
+   // Events are logged even when hovercards are disabled
+   // See T88166 for details
+   if ( mw.popups.enabled ) {
+   event.popupDelay = mw.popups.render.POPUP_DELAY;
+   event.duration = Math.round( logger.duration );
+   }
+
logger.reset();
return event;
}

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I2185e68d3bc5b81050a32612afe6fe51833dc207
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna psax...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits


[MediaWiki-commits] [Gerrit] Implement the new schema for when the popups are disabled - change (mediawiki...Popups)

2015-03-12 Thread Prtksxna (Code Review)
Prtksxna has uploaded a new change for review.

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

Change subject: Implement the new schema for when the popups are disabled
..

Implement the new schema for when the popups are disabled

Bug: T88167
Change-Id: I59face6ba3183e86e292e364e90409a18ee4d194
---
M resources/ext.popups.core.js
M resources/ext.popups.eventlogging.js
2 files changed, 32 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Popups 
refs/changes/89/196189/1

diff --git a/resources/ext.popups.core.js b/resources/ext.popups.core.js
index dbb454f..4187938 100644
--- a/resources/ext.popups.core.js
+++ b/resources/ext.popups.core.js
@@ -164,12 +164,16 @@
};
 
mw.hook( 'wikipage.content').add( function ( $content ) {
-   if ( mw.popups.enabled ) {
-   mw.popups.$content = $content;
+   mw.popups.$content = $content;
+   var $elements = mw.popups.selectPopupElements();
 
-   var $elements = mw.popups.selectPopupElements();
+   if ( mw.popups.enabled ) {
mw.popups.removeTooltips( $elements );
mw.popups.setupTriggers( $elements );
+   } else {
+   $elements.on( 'click', function () {
+   mw.popups.eventLogging.logLinkClick( event, $( 
this ) );
+   } );
}
} );
 
diff --git a/resources/ext.popups.eventlogging.js 
b/resources/ext.popups.eventlogging.js
index 8dedf5e..2790196 100644
--- a/resources/ext.popups.eventlogging.js
+++ b/resources/ext.popups.eventlogging.js
@@ -68,6 +68,26 @@
};
 
/**
+* Logs clicks on links when the popups are disabled
+*
+* @method logLinkClick
+* @param {jQuery.event} event
+* @param {jQuery} $el
+*/
+   eventLogging.logLinkClick = function ( event, $el ) {
+   var href;
+   eventLogging.action = eventLogging.getAction ( event );
+   eventLogging.pageTitleHover = $el.attr( 'title' );
+
+   if ( eventLogging.action === 'opened in same tab' ) {
+   href = $el.attr( 'href' );
+   event.preventDefault();
+   }
+
+   eventLogging.logEvent( href );
+   };
+
+   /**
 * Logs the popup event as defined in the following schema-
 * https://meta.wikimedia.org/wiki/Schema:Popups
 * If `href` is passed it redirects to that location after the event is 
logged.
@@ -81,14 +101,17 @@
}
 
var event = {
-   'duration': Math.round( eventLogging.duration ),
'action': eventLogging.action,
'popup_enabled': mw.popups.enabled,
-   'popup_delay': mw.popups.render.POPUP_DELAY,
'page_title_source': mw.config.get( 'wgTitle' ),
'page_title_hover': eventLogging.pageTitleHover,
};
 
+   if ( mw.popups.enabled ) {
+   event[ 'popup_delay' ] =  mw.popups.render.POPUP_DELAY;
+   event[ 'duration' ] = Math.round( eventLogging.duration 
);
+   }
+
mw.eventLog.logEvent( 'Popups', event );
 
if ( href ) {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I59face6ba3183e86e292e364e90409a18ee4d194
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Popups
Gerrit-Branch: master
Gerrit-Owner: Prtksxna psax...@wikimedia.org

___
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits