[MediaWiki-commits] [Gerrit] Do not start any JavaScript in diffs/old revisions - change (mediawiki...Wikibase)

2014-10-17 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Do not start any JavaScript in diffs/old revisions
..


Do not start any JavaScript in diffs/old revisions

Change-Id: I429f44af2db749263cd4cd26365ac39fddcb498d
---
M repo/includes/EntityParserOutputGenerator.php
M repo/includes/EntityView.php
M repo/resources/wikibase.ui.entityViewInit.js
3 files changed, 15 insertions(+), 15 deletions(-)

Approvals:
  Hoo man: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/repo/includes/EntityParserOutputGenerator.php 
b/repo/includes/EntityParserOutputGenerator.php
index dfd03d6..2cecb92 100644
--- a/repo/includes/EntityParserOutputGenerator.php
+++ b/repo/includes/EntityParserOutputGenerator.php
@@ -94,7 +94,7 @@
//@todo: record sitelinks as iwlinks
//@todo: record CommonsMedia values as imagelinks
 
-   $this->addModules( $pout );
+   $this->addModules( $pout, $editable );
 
//FIXME: some places, like Special:NewItem, don't want to 
override the page title.
//   But we still want to use OutputPage::addParserOutput 
to apply the modules etc from the ParserOutput.
@@ -151,7 +151,7 @@
$pout->setExtensionData( 'wikibase-view-chunks', 
$this->entityView->getPlaceholders() );
}
 
-   private function addModules( ParserOutput $pout ) {
+   private function addModules( ParserOutput $pout, $editable ) {
// make css available for JavaScript-less browsers
$pout->addModuleStyles( array(
'wikibase.common',
@@ -161,8 +161,10 @@
'jquery.wikibase.toolbar',
) );
 
-   // make sure required client sided resources will be loaded:
-   $pout->addModules( 'wikibase.ui.entityViewInit' );
+   if ( $editable ) {
+   // make sure required client sided resources will be 
loaded:
+   $pout->addModules( 'wikibase.ui.entityViewInit' );
+   }
}
 
 }
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 80cd94f..1a6738e 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -11,7 +11,6 @@
 use Wikibase\Repo\View\ClaimsView;
 use Wikibase\Repo\View\FingerprintView;
 use Wikibase\Repo\View\TextInjector;
-use Wikibase\Repo\View\EntityViewPlaceholderExpander;
 
 /**
  * Base class for creating views for all different kinds of Wikibase\Entity.
@@ -118,13 +117,21 @@
$this->getInnerHtml( $entityRevision, $editable )
);
 
+   if ( $editable ) {
+   $html .= $this->getLoadingSpinnerInlineScript();
+   }
+
+   return $html;
+   }
+
+   private function getLoadingSpinnerInlineScript() {
// Show loading spinner as long as JavaScript is initialising.
// The fastest way to show it is placing the script right after 
the corresponding HTML.
// Remove it after a while in any case (e.g. some resources 
might not have been loaded
// silently, so JavaScript is not initialising).
// Additionally attaching to window.error would only make sense 
before any other
// JavaScript is parsed.
-   $html .= Html::inlineScript( '
+   return Html::inlineScript( '
 if ( $ ) {
$( ".wikibase-entityview" ).addClass( "loading" ).after( function() {
var $div = $( "" ).addClass( "wb-entity-spinner 
mw-small-spinner" );
@@ -141,7 +148,6 @@
}, 7000 );
 }
 ' );
-   return $html;
}
 
/**
diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
index 6ef2b4c..8f03ffc 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -296,14 +296,6 @@
} else if( !mw.config.get( 'wbUserCanEdit' ) ) {
restrict( 'restrictionedit' );
}
-
-   if( !mw.config.get( 'wbIsEditView' ) ) {
-   // no need to implement a 'disableEntityPageActions' 
since hiding all the toolbars
-   // directly like this is not really worse than hacking 
the Toolbar prototype to achieve
-   // this:
-   $( ':wikibase-toolbar' ).hide();
-   $( 'body' ).addClass( 'wb-editing-disabled' );
-   }
}
 
/**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I429f44af2db749263cd4cd26365ac39fddcb498d
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit

[MediaWiki-commits] [Gerrit] Do not start any JavaScript in diffs/old revisions - change (mediawiki...Wikibase)

2014-10-17 Thread WMDE
Thiemo Mättig (WMDE) has uploaded a new change for review.

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

Change subject: Do not start any JavaScript in diffs/old revisions
..

Do not start any JavaScript in diffs/old revisions

Change-Id: I429f44af2db749263cd4cd26365ac39fddcb498d
---
M repo/includes/EntityParserOutputGenerator.php
M repo/includes/EntityView.php
M repo/resources/wikibase.ui.entityViewInit.js
3 files changed, 15 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Wikibase 
refs/changes/82/167182/1

diff --git a/repo/includes/EntityParserOutputGenerator.php 
b/repo/includes/EntityParserOutputGenerator.php
index dfd03d6..2cecb92 100644
--- a/repo/includes/EntityParserOutputGenerator.php
+++ b/repo/includes/EntityParserOutputGenerator.php
@@ -94,7 +94,7 @@
//@todo: record sitelinks as iwlinks
//@todo: record CommonsMedia values as imagelinks
 
-   $this->addModules( $pout );
+   $this->addModules( $pout, $editable );
 
//FIXME: some places, like Special:NewItem, don't want to 
override the page title.
//   But we still want to use OutputPage::addParserOutput 
to apply the modules etc from the ParserOutput.
@@ -151,7 +151,7 @@
$pout->setExtensionData( 'wikibase-view-chunks', 
$this->entityView->getPlaceholders() );
}
 
-   private function addModules( ParserOutput $pout ) {
+   private function addModules( ParserOutput $pout, $editable ) {
// make css available for JavaScript-less browsers
$pout->addModuleStyles( array(
'wikibase.common',
@@ -161,8 +161,10 @@
'jquery.wikibase.toolbar',
) );
 
-   // make sure required client sided resources will be loaded:
-   $pout->addModules( 'wikibase.ui.entityViewInit' );
+   if ( $editable ) {
+   // make sure required client sided resources will be 
loaded:
+   $pout->addModules( 'wikibase.ui.entityViewInit' );
+   }
}
 
 }
diff --git a/repo/includes/EntityView.php b/repo/includes/EntityView.php
index 80cd94f..1a6738e 100644
--- a/repo/includes/EntityView.php
+++ b/repo/includes/EntityView.php
@@ -11,7 +11,6 @@
 use Wikibase\Repo\View\ClaimsView;
 use Wikibase\Repo\View\FingerprintView;
 use Wikibase\Repo\View\TextInjector;
-use Wikibase\Repo\View\EntityViewPlaceholderExpander;
 
 /**
  * Base class for creating views for all different kinds of Wikibase\Entity.
@@ -118,13 +117,21 @@
$this->getInnerHtml( $entityRevision, $editable )
);
 
+   if ( $editable ) {
+   $html .= $this->getLoadingSpinnerInlineScript();
+   }
+
+   return $html;
+   }
+
+   private function getLoadingSpinnerInlineScript() {
// Show loading spinner as long as JavaScript is initialising.
// The fastest way to show it is placing the script right after 
the corresponding HTML.
// Remove it after a while in any case (e.g. some resources 
might not have been loaded
// silently, so JavaScript is not initialising).
// Additionally attaching to window.error would only make sense 
before any other
// JavaScript is parsed.
-   $html .= Html::inlineScript( '
+   return Html::inlineScript( '
 if ( $ ) {
$( ".wikibase-entityview" ).addClass( "loading" ).after( function() {
var $div = $( "" ).addClass( "wb-entity-spinner 
mw-small-spinner" );
@@ -141,7 +148,6 @@
}, 7000 );
 }
 ' );
-   return $html;
}
 
/**
diff --git a/repo/resources/wikibase.ui.entityViewInit.js 
b/repo/resources/wikibase.ui.entityViewInit.js
index 6ef2b4c..8f03ffc 100644
--- a/repo/resources/wikibase.ui.entityViewInit.js
+++ b/repo/resources/wikibase.ui.entityViewInit.js
@@ -296,14 +296,6 @@
} else if( !mw.config.get( 'wbUserCanEdit' ) ) {
restrict( 'restrictionedit' );
}
-
-   if( !mw.config.get( 'wbIsEditView' ) ) {
-   // no need to implement a 'disableEntityPageActions' 
since hiding all the toolbars
-   // directly like this is not really worse than hacking 
the Toolbar prototype to achieve
-   // this:
-   $( ':wikibase-toolbar' ).hide();
-   $( 'body' ).addClass( 'wb-editing-disabled' );
-   }
}
 
/**

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I429f44af2db749263cd4cd26365ac39fddcb498d
Gerrit-PatchSet: 1
Ger