r87650 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87649‎ | r87650 | r87651 >
Date:18:59, 7 May 2011
Author:nord
Status:deferred
Tags:
Comment:
Commit ElmEasyRef extension
Modified paths:
  • /trunk/extensions/ElmEasyRef (added) (history)
  • /trunk/extensions/ElmEasyRef/ElmEasyRef.i18n.php (added) (history)
  • /trunk/extensions/ElmEasyRef/ElmEasyRef.php (added) (history)
  • /trunk/extensions/ElmEasyRef/README (added) (history)
  • /trunk/extensions/ElmEasyRef/css (added) (history)
  • /trunk/extensions/ElmEasyRef/css/referencefield.css (added) (history)
  • /trunk/extensions/ElmEasyRef/css/refield-blue.css (added) (history)
  • /trunk/extensions/ElmEasyRef/css/refield-green.css (added) (history)
  • /trunk/extensions/ElmEasyRef/css/refield-red.css (added) (history)
  • /trunk/extensions/ElmEasyRef/css/refield-white.css (added) (history)
  • /trunk/extensions/ElmEasyRef/img (added) (history)
  • /trunk/extensions/ElmEasyRef/img/close-blue.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/close-green.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/close-red.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/close-white.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/close.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-l-blue.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-l-green.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-l-red.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-l-white.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-l.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-r-blue.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-r-green.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-r-red.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-r-white.png (added) (history)
  • /trunk/extensions/ElmEasyRef/img/corner-r.png (added) (history)
  • /trunk/extensions/ElmEasyRef/js (added) (history)
  • /trunk/extensions/ElmEasyRef/js/elmEasyRef-min.js (added) (history)
  • /trunk/extensions/ElmEasyRef/js/elmEasyRef.js (added) (history)

Diff [purge]

Index: trunk/extensions/ElmEasyRef/ElmEasyRef.i18n.php
@@ -0,0 +1,27 @@
 2+<?php
 3+
 4+/**
 5+ * Internationalisation file for extension ElmEasyRef.
 6+ *
 7+ * @file
 8+ * @ingroup Extensions
 9+ */
 10+
 11+$messages = array();
 12+
 13+/** English
 14+ * @author Elancev Michael
 15+ */
 16+$messages['en'] = array(
 17+ 'elm-easyref-ref' => 'Reference $1',
 18+ 'elm-easyref-close' => 'Close',
 19+);
 20+
 21+
 22+/** Russian (Русский)
 23+ * @author Elancev Michael
 24+ */
 25+$messages['ru'] = array(
 26+ 'elm-easyref-ref' => 'Ссылка $1',
 27+ 'elm-easyref-close' => 'Закрыть',
 28+);
Property changes on: trunk/extensions/ElmEasyRef/ElmEasyRef.i18n.php
___________________________________________________________________
Added: svn:eol-style
129 + native
Index: trunk/extensions/ElmEasyRef/ElmEasyRef.php
@@ -0,0 +1,167 @@
 2+<?php
 3+
 4+# ElmEasyRef 0.8.2b
 5+# Add popup field to display reference's content
 6+# When user click on reference he would be not jumped down to "References" section.
 7+# Text will be shown in popup field
 8+#
 9+# Extension do not provide <ref> tags, you should use extension like Cite
 10+
 11+
 12+# @addtogroup
 13+# @author Elancev Michael
 14+# @copyright © 2011 by Elancev Michael
 15+# @licence
 16+
 17+
 18+if( !defined( 'MEDIAWIKI' ) ) {
 19+ echo( "This file is an extension to the MediaWiki software and cannot be used standalone.\n" );
 20+ die();
 21+}
 22+
 23+# Lang
 24+$wgExtensionMessagesFiles['ElmEasyRef'] = dirname( __FILE__ ) . '/ElmEasyRef.i18n.php';
 25+
 26+# Options
 27+
 28+// If debug mode is on (true), debug messages will be enabled and uncompressed version of js-script will be attached
 29+$wgElmEasyRefDebugMode = false;
 30+
 31+// Full path to additional css file, which can change styles of referencefield.css
 32+$wgElmEasyRefAddCSS = '';
 33+
 34+// Field metrics
 35+$wgElmEasyRefMetrics = array(
 36+ // Min size of popup field
 37+ 'min_width' => 140,
 38+ 'min_height' => 40,
 39+
 40+ // Size of collapsed popup field
 41+ 'col_width' => 400,
 42+ 'col_height' => 140,
 43+
 44+ // Size of expanded popup field (Max size)
 45+ // Note: popup apear in collapsed mode first.
 46+ // Expanded mode is for large references and opened with "More button"
 47+ 'exp_width' => 400,
 48+ 'exp_height' => 380
 49+);
 50+
 51+// Animation properties
 52+$wgElmEasyRefAnimation = array(
 53+ // If true, enable apear animation
 54+ 'enable' => true,
 55+ // Interval delay
 56+ 'delay' => 50,
 57+ // How long width and height will grow up
 58+ 'stepw' => 2,
 59+ 'steph' => 3
 60+);
 61+
 62+// bodyContent: ID of element which contain articles body
 63+$wgElmEasyRefBodyContentId = 'bodyContent';
 64+
 65+
 66+// Regular expression to retrieve number of reference (for links look like: [123])
 67+// (with no / /)
 68+$wgElmEasyRefNum_rp = '(<.*?>)'; // strip that first
 69+$wgElmEasyRefNum_mt = '([0-9]+)'; // search
 70+
 71+# Hooks
 72+
 73+$wgHooks['BeforePageDisplay'][] = 'elmEasyRefOutput';
 74+
 75+
 76+# Credits
 77+
 78+$wgExtensionCredits['other'][] = array(
 79+ 'path' => __FILE__,
 80+ 'name' => "ElmEasyRef",
 81+ 'description' => "Add popup field to display reference's content",
 82+ 'version' => '0.8.2b',
 83+ 'author' => "Elancev Michael",
 84+ 'url' => "http://www.mediawiki.org/wiki/Extension:ElmEasyRef",
 85+);
 86+
 87+
 88+# Output hook
 89+
 90+function elmEasyRefOutput( OutputPage $outputPage, $skin ) {
 91+
 92+ global $wgScriptPath;
 93+
 94+ // Options
 95+ global $wgElmEasyRefAddCSS,
 96+ $wgElmEasyRefDebugMode,
 97+ $wgElmEasyRefBodyContentId,
 98+ $wgElmEasyRefAnimation,
 99+ $wgElmEasyRefMetrics,
 100+ $wgElmEasyRefNum_rp,
 101+ $wgElmEasyRefNum_mt;
 102+
 103+ // Register css for popup field
 104+ $outputPage->addLink(
 105+ array(
 106+ 'rel' => 'stylesheet',
 107+ 'type' => 'text/css',
 108+ 'href' => $wgScriptPath . '/extensions/ElmEasyRef/css/referencefield.css'
 109+ )
 110+ );
 111+
 112+ // Additonal css if setted
 113+ if ( $wgElmEasyRefAddCSS ) {
 114+ $outputPage->addLink(
 115+ array(
 116+ 'rel' => 'stylesheet',
 117+ 'type' => 'text/css',
 118+ 'href' => $wgElmEasyRefAddCSS
 119+ )
 120+ );
 121+ }
 122+
 123+ // Register js-script file
 124+ $src = '/extensions/ElmEasyRef/js/elmEasyRef';
 125+ if ( !$wgElmEasyRefDebugMode ){
 126+ $src .= '-min';
 127+ }
 128+ $outputPage->addScript( Html::linkedScript( $wgScriptPath . $src . '.js' ) );
 129+
 130+ // Settings
 131+ $settings = '';
 132+ if ( $wgElmEasyRefDebugMode ){
 133+ $settings .= 'elmEasyRef.debug = true;';
 134+ }
 135+ if ( $wgElmEasyRefBodyContentId ){
 136+ $settings .= 'elmEasyRef.bodyContentId = ' . Xml::encodeJsVar($wgElmEasyRefBodyContentId) . ';';
 137+ }
 138+ if ( $wgElmEasyRefNum_rp ){
 139+ $settings .= 'elmEasyRef.regRefNum_rp = /' . $wgElmEasyRefNum_rp . '/;';
 140+ }
 141+ if ( $wgElmEasyRefNum_mt ){
 142+ $settings .= 'elmEasyRef.regRefNum_mt = /' . $wgElmEasyRefNum_mt . '/;';
 143+ }
 144+ if ( $wgElmEasyRefAnimation ){
 145+ foreach ( $wgElmEasyRefAnimation as $prop => $val ) {
 146+ $settings .= 'elmEasyRef.animation.' . $prop . ' = ' . Xml::encodeJsVar($val) . ';';
 147+ }
 148+ }
 149+ if ( $wgElmEasyRefMetrics ){
 150+ foreach ( $wgElmEasyRefMetrics as $prop => $val ) {
 151+ $settings .= 'elmEasyRef.fieldm.' . $prop . ' = ' . Xml::encodeJsVar($val) . ';';
 152+ }
 153+ }
 154+ $msg = wfMsgExt( 'elm-easyref-ref', 'parseinline' );
 155+ $settings .= 'elmEasyRef.messages.elm_easyref_ref = ' . Xml::encodeJsVar($msg) . ';';
 156+ $msg = wfMsgExt( 'elm-easyref-close', 'parseinline' );
 157+ $settings .= 'elmEasyRef.messages.elm_easyref_close = ' . Xml::encodeJsVar($msg) . ';';
 158+
 159+ $outputPage->addInlineScript(
 160+ 'addOnloadHook( function() {' .
 161+ $settings . 'elmEasyRef.prepare();'.
 162+ '} );'
 163+ );
 164+
 165+ return true;
 166+}
 167+
 168+
Property changes on: trunk/extensions/ElmEasyRef/ElmEasyRef.php
___________________________________________________________________
Added: svn:eol-style
1169 + native
Index: trunk/extensions/ElmEasyRef/css/refield-green.css
@@ -0,0 +1,36 @@
 2+/*
 3+ Green
 4+ Overwrite styles of referencefield.css
 5+*/
 6+
 7+
 8+.elm-easyref-corner-l {
 9+ background:url(../img/corner-l-green.png) no-repeat !important;
 10+}
 11+
 12+.elm-easyref-corner-r {
 13+ background:url(../img/corner-r-green.png) no-repeat !important;
 14+}
 15+
 16+.elm-easyref-frame {
 17+ background-color:#F6F6F6 !important;
 18+}
 19+
 20+.elm-easyref-frame {
 21+ border: 1px solid #269926 !important;
 22+}
 23+
 24+.elm-easyref-link:link,
 25+.elm-easyref-link:visited,
 26+.elm-easyref-link:hover {
 27+ color: #67D867 !important;;
 28+}
 29+
 30+.elm-easyref-close {
 31+ background: url(../img/close-green.png) no-repeat !important;
 32+}
 33+
 34+.elm-easyref-more {
 35+ background-color:#D8F5D8 !important;
 36+}
 37+
Property changes on: trunk/extensions/ElmEasyRef/css/refield-green.css
___________________________________________________________________
Added: svn:eol-style
138 + native
Index: trunk/extensions/ElmEasyRef/css/refield-white.css
@@ -0,0 +1,37 @@
 2+/*
 3+ White
 4+ Overwrite styles of referencefield.css
 5+*/
 6+
 7+
 8+.elm-easyref-corner-l {
 9+ background:url(../img/corner-l-white.png) no-repeat !important;
 10+}
 11+
 12+.elm-easyref-corner-r {
 13+ background:url(../img/corner-r-white.png) no-repeat !important;
 14+}
 15+
 16+.elm-easyref-frame {
 17+ background-color:#FFFFFF !important;
 18+}
 19+
 20+.elm-easyref-frame {
 21+ border: 1px solid #666666 !important;
 22+}
 23+
 24+
 25+.elm-easyref-link:link,
 26+.elm-easyref-link:visited,
 27+.elm-easyref-link:hover {
 28+ color: #666666 !important;;
 29+}
 30+
 31+.elm-easyref-close {
 32+ background: url(../img/close-white.png) no-repeat !important;
 33+}
 34+
 35+.elm-easyref-more {
 36+ background-color:#CCCCCC !important;
 37+}
 38+
Property changes on: trunk/extensions/ElmEasyRef/css/refield-white.css
___________________________________________________________________
Added: svn:eol-style
139 + native
Index: trunk/extensions/ElmEasyRef/css/refield-blue.css
@@ -0,0 +1,37 @@
 2+/*
 3+ Blue
 4+ Overwrite styles of referencefield.css
 5+*/
 6+
 7+
 8+.elm-easyref-corner-l {
 9+ background:url(../img/corner-l-blue.png) no-repeat !important;
 10+}
 11+
 12+.elm-easyref-corner-r {
 13+ background:url(../img/corner-r-blue.png) no-repeat !important;
 14+}
 15+
 16+.elm-easyref-frame {
 17+ background-color:#F6F6F6 !important;
 18+}
 19+
 20+.elm-easyref-frame {
 21+ border: 1px solid #3333CC !important;
 22+}
 23+
 24+
 25+.elm-easyref-link:link,
 26+.elm-easyref-link:visited,
 27+.elm-easyref-link:hover {
 28+ color: #B6B6ED !important;;
 29+}
 30+
 31+.elm-easyref-close {
 32+ background: url(../img/close-blue.png) no-repeat !important;
 33+}
 34+
 35+.elm-easyref-more {
 36+ background-color:#D8D8F5 !important;
 37+}
 38+
Property changes on: trunk/extensions/ElmEasyRef/css/refield-blue.css
___________________________________________________________________
Added: svn:eol-style
139 + native
Index: trunk/extensions/ElmEasyRef/css/referencefield.css
@@ -0,0 +1,157 @@
 2+/*
 3+ Style of pupup reference field
 4+ DOM structure:
 5+
 6+ .elm-easyref-container
 7+ |- .elm-easyref-frame
 8+ | |- .elm-easyref-header
 9+ | | |- .elm-easyref-link - link to "Reference" Section
 10+ | | |- .elm-easyref-close - close popup button
 11+ | |
 12+ | |- .elm-easyref-field
 13+ | |- .elm-easyref-content - keep text of reference
 14+ | |- .elm-easyref-more - expand button
 15+ |
 16+ |- .elm-easyref-corner
 17+*/
 18+
 19+
 20+/*
 21+ Offset from ref link: [123]
 22+*/
 23+.elm-easyref-container {
 24+ margin-left: -5px;
 25+}
 26+
 27+/*
 28+ Corner style and position
 29+*/
 30+.elm-easyref-corner-l,
 31+.elm-easyref-corner-r {
 32+ width: 84px;
 33+ height: 20px;
 34+ position: absolute;
 35+ top: 1px;
 36+}
 37+
 38+.elm-easyref-corner-l {
 39+ background:url(../img/corner-l-blue.png) no-repeat;
 40+ margin-left: 7px;
 41+}
 42+
 43+.elm-easyref-corner-r {
 44+ background:url(../img/corner-r-blue.png) no-repeat;
 45+ margin-left: -77px;
 46+}
 47+
 48+.elm-easyref-frame {
 49+ margin-top: 20px; /* = corner.height */
 50+}
 51+
 52+/*
 53+ Background color
 54+*/
 55+.elm-easyref-frame {
 56+ background-color:#F6F6F6;
 57+}
 58+
 59+/*
 60+ Border style
 61+*/
 62+
 63+.elm-easyref-frame {
 64+ border: 1px solid #3333CC;
 65+}
 66+
 67+/*
 68+ Header style
 69+*/
 70+.elm-easyref-header {
 71+ font-size: 10px;
 72+ text-align:right;
 73+ height:12px;
 74+ padding: 4px 6px 4px 0px;
 75+}
 76+
 77+
 78+/*
 79+ Header: Link button
 80+*/
 81+.elm-easyref-link {
 82+ display:block;
 83+ position:absolute;
 84+ right: 22px;
 85+ font-weight:bold;
 86+ top: 0px;
 87+}
 88+
 89+.elm-easyref-link:link,
 90+.elm-easyref-link:visited,
 91+.elm-easyref-link:hover {
 92+ color: #B6B6ED;
 93+ font-weight:bold;
 94+ text-decoration:none;
 95+}
 96+
 97+/*
 98+ Header: Close button
 99+*/
 100+.elm-easyref-close {
 101+ display:block;
 102+ height:12px;
 103+ width: 12px;
 104+ background: url(../img/close-blue.png) no-repeat;
 105+ position:absolute;
 106+ right: 4px;
 107+ top: 3px;
 108+}
 109+
 110+/*
 111+ Padding for reference text
 112+ Do not add paddings to .elm-easyref-field
 113+*/
 114+.elm-easyref-content {
 115+ padding: 4px 16px 16px 16px;
 116+}
 117+
 118+
 119+/*
 120+ Style and position of mere(...) button
 121+*/
 122+.elm-easyref-more {
 123+ position:absolute;
 124+ bottom:0px;
 125+ height:20px;
 126+ text-align:center;
 127+ background-color:#D8D8F5;
 128+ margin: 0px 1px;
 129+}
 130+
 131+.elm-easyref-more a{
 132+ color: #000000;
 133+ font-weight:bold;
 134+ text-decoration:none;
 135+ display: block;
 136+ width: 100%;
 137+}
 138+
 139+.elm-easyref-more a:hover{
 140+ text-decoration:none;
 141+}
 142+
 143+/*
 144+ DO NOT CHANGE FOLLOWING STYLES:
 145+*/
 146+.elm-easyref-field,
 147+.elm-easyref-frame{
 148+ overflow:hidden;
 149+}
 150+
 151+.elm-easyref-header,
 152+.elm-easyref-field {
 153+ position:relative;
 154+}
 155+
 156+.elm-easyref-content {
 157+ display: inline-block;
 158+}
Property changes on: trunk/extensions/ElmEasyRef/css/referencefield.css
___________________________________________________________________
Added: svn:eol-style
1159 + native
Index: trunk/extensions/ElmEasyRef/css/refield-red.css
@@ -0,0 +1,36 @@
 2+/*
 3+ Red
 4+ Overwrite styles of referencefield.css
 5+*/
 6+
 7+
 8+.elm-easyref-corner-l {
 9+ background:url(../img/corner-l-red.png) no-repeat !important;
 10+}
 11+
 12+.elm-easyref-corner-r {
 13+ background:url(../img/corner-r-red.png) no-repeat !important;
 14+}
 15+
 16+.elm-easyref-frame {
 17+ background-color:#F6F6F6 !important;
 18+}
 19+
 20+.elm-easyref-frame {
 21+ border: 1px solid #E10000 !important;
 22+}
 23+
 24+.elm-easyref-link:link,
 25+.elm-easyref-link:visited,
 26+.elm-easyref-link:hover {
 27+ color: #E05F5F !important;;
 28+}
 29+
 30+.elm-easyref-close {
 31+ background: url(../img/close-red.png) no-repeat !important;
 32+}
 33+
 34+.elm-easyref-more {
 35+ background-color:#F5D8D8 !important;
 36+}
 37+
Property changes on: trunk/extensions/ElmEasyRef/css/refield-red.css
___________________________________________________________________
Added: svn:eol-style
138 + native
Index: trunk/extensions/ElmEasyRef/img/corner-r-blue.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-r-blue.png
___________________________________________________________________
Added: svn:mime-type
239 + image/png
Index: trunk/extensions/ElmEasyRef/img/close-red.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/close-red.png
___________________________________________________________________
Added: svn:mime-type
340 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-l-green.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-l-green.png
___________________________________________________________________
Added: svn:mime-type
441 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-l-white.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-l-white.png
___________________________________________________________________
Added: svn:mime-type
542 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-r-red.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-r-red.png
___________________________________________________________________
Added: svn:mime-type
643 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-l.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-l.png
___________________________________________________________________
Added: svn:mime-type
744 + image/png
Index: trunk/extensions/ElmEasyRef/img/close-green.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/close-green.png
___________________________________________________________________
Added: svn:mime-type
845 + image/png
Index: trunk/extensions/ElmEasyRef/img/close-white.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/close-white.png
___________________________________________________________________
Added: svn:mime-type
946 + image/png
Index: trunk/extensions/ElmEasyRef/img/close.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/close.png
___________________________________________________________________
Added: svn:mime-type
1047 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-r-green.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-r-green.png
___________________________________________________________________
Added: svn:mime-type
1148 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-r-white.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-r-white.png
___________________________________________________________________
Added: svn:mime-type
1249 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-l-blue.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-l-blue.png
___________________________________________________________________
Added: svn:mime-type
1350 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-r.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-r.png
___________________________________________________________________
Added: svn:mime-type
1451 + image/png
Index: trunk/extensions/ElmEasyRef/img/corner-l-red.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/corner-l-red.png
___________________________________________________________________
Added: svn:mime-type
1552 + image/png
Index: trunk/extensions/ElmEasyRef/img/close-blue.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/ElmEasyRef/img/close-blue.png
___________________________________________________________________
Added: svn:mime-type
1653 + image/png
Index: trunk/extensions/ElmEasyRef/js/elmEasyRef.js
@@ -0,0 +1,763 @@
 2+/*
 3+ * ElmEasyRef v 0.8.2b:
 4+ * Add popup field to display reference's content
 5+ * When user click on reference he would be not jumped down to "References" section.
 6+ * Text will be shown in popup field
 7+ *
 8+ * author: Elancev Michael
 9+ */
 10+
 11+// addEventListener || attachEvent to elem
 12+//
 13+function elm_addEvent( elem, event, func ){
 14+ if ( elem.addEventListener ) {
 15+ elem.addEventListener( event, func, false );
 16+ } else {
 17+ // For IE <9
 18+ var self = elem;
 19+ elem.attachEvent(
 20+ // Event type
 21+ 'on' + event,
 22+
 23+ // Callback
 24+ function() {
 25+ var event = {
 26+ target: window.event.srcElement,
 27+ currentTarget: self,
 28+ ctrlKey: window.event.ctrlKey,
 29+ keyCode: window.event.keyCode,
 30+ eventObj: window.event,
 31+
 32+ preventDefault: function (){ this.eventObj.returnValue = false; },
 33+ stopPropagation: function (){ this.eventObj.cancelBubble = true; }
 34+ };
 35+ return func.apply( self, [event] );
 36+ }
 37+ );
 38+
 39+ }
 40+}
 41+
 42+
 43+// Check if classname is in elem.className
 44+//
 45+function elm_hasClass( elem, classname ){
 46+ var classes = elem.className;
 47+ if ( classes == classname ) return true;
 48+ var whitespace = /\s+/;
 49+ if ( !whitespace.test( classes ) ) return false;
 50+ var cs = classes.split( whitespace );
 51+ for ( var i = 0; i < cs.length; i++ ){
 52+ if ( cs[i] == classname ) return true;
 53+ }
 54+ return false;
 55+}
 56+
 57+// Find elements with class classname in all children of elem
 58+// Return array of founded elems
 59+//
 60+function elm_getElementsByClassName( elem, classname ){
 61+ if ( elem.getElementsByClassName ){
 62+ return elem.getElementsByClassName( classname );
 63+
 64+ } else {
 65+ var elements = elem.getElementsByTagName( "*" );
 66+
 67+ if ( !classname ) return elements;
 68+
 69+ var returnlist = [];
 70+ for ( var i = 0; i < elements.length; i++ ){
 71+ if ( elm_hasClass(elements[i], classname)) returnlist.push(elements[i]);
 72+ }
 73+
 74+ return returnlist;
 75+ }
 76+}
 77+
 78+// Determine current window size
 79+// Return {x: <val>, y: <val>} - width and height of window
 80+//
 81+function elm_getWindowSize(){
 82+ if( typeof( window.innerWidth ) == 'number' ) {
 83+ //Non-IE
 84+ return {x: window.innerWidth, y: window.innerHeight};
 85+ } else if( document.documentElement && typeof(document.documentElement.clientWidth) == 'number') {
 86+ //IE 6+ in 'standards compliant mode'
 87+ return {x: document.documentElement.clientWidth, y: document.documentElement.clientHeight};
 88+
 89+ // Not compatible
 90+ } else return false;
 91+}
 92+
 93+// Determine window scroll position
 94+// Return {x: <val>, y: <val>} - left and top scroll position
 95+//
 96+function elm_getWindowScroll(){
 97+ if( typeof( window.pageYOffset ) == 'number' ) {
 98+ //
 99+ return {x: window.pageXOffset, y: window.pageYOffset};
 100+ } else if( document.body && (document.body.scrollLeft || document.body.scrollTop)) {
 101+ //
 102+ return {x: document.body.scrollLeft, y: document.body.scrollTop};
 103+ } else if ( document.documentElement && typeof(document.documentElement.scrollLeft) == 'number') {
 104+ //
 105+ return {x: document.documentElement.scrollLeft, y: document.documentElement.scrollTop};
 106+
 107+ // Not compatible
 108+ } else return false;
 109+}
 110+
 111+// Main object
 112+// - keep properties of extension
 113+// - init extension
 114+// - control global event listeners
 115+//
 116+var elmEasyRef = {
 117+ // Show debug alerts
 118+ debug: false,
 119+
 120+ // Nodes
 121+ references: null, // block with text of references
 122+ refField: null, // block where reference text will be displayed
 123+ refText: null, // node which contain text of reference
 124+
 125+ // Id of node that contain article
 126+ bodyContentId: "bodyContent",
 127+
 128+ // Retrieve data regular expression
 129+ // retrieve number of reference (for links look like: [123])
 130+ regRefNum_rp: /(<.*?>)/, // strip that first
 131+ regRefNum_mt: /([0-9]+)/, // search
 132+
 133+ // Displayed messages
 134+ messages: {
 135+ elm_easyref_ref: 'Reference $1',
 136+ elm_easyref_close: 'Close'
 137+ },
 138+
 139+ // Animation properties
 140+ animation: {
 141+ enable: true,
 142+ delay: 50,
 143+ stepw: 2,
 144+ steph: 3
 145+ },
 146+
 147+ // Field metrics
 148+ fieldm: {
 149+ // Min size of popup field
 150+ min_width: 140,
 151+ min_height: 40,
 152+
 153+ // Size of collapsed popup field
 154+ col_width: 400,
 155+ col_height: 140,
 156+
 157+ // Size of expanded popup field (Max size)
 158+ exp_width: 400,
 159+ exp_height: 380
 160+ },
 161+
 162+ // Keep pointer to last clicked reference node
 163+ lastRef: null,
 164+
 165+ // Add event listeners to references
 166+ prepare: function(){
 167+ // where search references
 168+ var bodyContent = document.getElementById( this.bodyContentId );
 169+ if ( !bodyContent ) {
 170+ if ( this.debug ) alert( "bodyContent node not found" );
 171+ return;
 172+ }
 173+
 174+
 175+ // add event listeneres to all refs
 176+ var elems = elm_getElementsByClassName( bodyContent, "reference" );
 177+ for ( var i = 0; i < elems.length; i++ ){
 178+ if ( elems[i].firstChild && elems[i].firstChild.tagName == "A" ){
 179+ elm_addEvent( elems[i].firstChild, "click", this.refClickListener );
 180+ }
 181+ }
 182+
 183+ // if references are in page
 184+ if ( elems.length ){
 185+ // block with text of references
 186+ this.references = elm_getElementsByClassName( bodyContent, "references" )[0];
 187+ if ( !this.references ) {
 188+ if ( this.debug ) alert( "References block not found" );
 189+ return;
 190+ }
 191+
 192+ // element which temporary keep reference's text
 193+ this.refText = document.createElement( "div" );
 194+ }
 195+
 196+
 197+ // Close shown popup field, when user click out of field
 198+ elm_addEvent( document.body,
 199+ "mousedown",
 200+ function( event ){
 201+ if ( elmEasyRef.refField && elmEasyRef.refField.is_shown &&
 202+ elmEasyRef.lastRef != event.target &&
 203+ !elmEasyRef.refField.isInsideField(event.target) ){
 204+
 205+ elmEasyRef.refField.hide();
 206+ }
 207+ }
 208+ );
 209+
 210+
 211+ // Update popup position, wnen user resize window
 212+ elm_addEvent( window,
 213+ "resize",
 214+ function( event ){
 215+ if ( elmEasyRef.refField && elmEasyRef.refField.is_shown ){
 216+ elmEasyRef.refField.updatePos();
 217+ }
 218+ }
 219+ );
 220+ },
 221+
 222+ // Mouse click event listener for reference
 223+ refClickListener: function( event ){
 224+ var n = event.currentTarget,
 225+ rf = elmEasyRef.refField;
 226+
 227+ if ( elmEasyRef.lastRef == n && rf && rf.is_shown ) {
 228+ // Click when already shown -> hide popup
 229+ rf.hide();
 230+ } else {
 231+ // Show popup
 232+ if ( !elmEasyRef.showRefField(n) ) return;
 233+ }
 234+ event.preventDefault();
 235+ elmEasyRef.lastRef = n;
 236+ },
 237+
 238+ // Show popup reference field for reference node
 239+ // Return true if all ok, and false if error
 240+ showRefField: function( node ){
 241+ var refContent = document.getElementById( node.hash.substr(1) );
 242+ if ( !refContent) {
 243+ if ( this.debug) alert( "Reference content not found" );
 244+ return false;
 245+ }
 246+
 247+ this.refText.innerHTML = refContent.innerHTML;
 248+ this.cutUselessNodes(this.refText);
 249+
 250+ if ( !this.refField ) {
 251+ // ElmEasyRefField is not initialized yet
 252+ this.refField = new ElmEasyRefField();
 253+ }
 254+
 255+ this.refField.setRefLink( this.getRefNum(node), node.href );
 256+ this.refField.setInnerNode( this.refText.innerHTML );
 257+ this.refField.attachToAnchor( node );
 258+ this.refField.show();
 259+
 260+ // Free
 261+ this.refText.innerHTML = "";
 262+
 263+ return true;
 264+ },
 265+
 266+ // Return number of reference
 267+ getRefNum: function ( node ){
 268+ // Cut tags
 269+ var t = String( node.innerHTML ).replace( this.regRefNum_rp, '' );
 270+ // Match number
 271+ t = this.regRefNum_mt.exec( t );
 272+
 273+ return (t ? t[0] : 0);
 274+ },
 275+
 276+ // Remove needless elems from reference content
 277+ cutUselessNodes: function ( root ){
 278+
 279+ // Remove prepend
 280+ var nodes = root.childNodes;
 281+ var i;
 282+ for ( i = nodes.length - 1; i >= 0; i-- ){
 283+ var node = null;
 284+ if ( nodes[i].tagName == "A" ) node = nodes[i];
 285+ else if ( nodes[i].firstChild && nodes[i].firstChild.tagName == "A" ) node = nodes[i].firstChild;
 286+
 287+
 288+ if ( node && node.hash){
 289+ var wl = window.location.pathname,
 290+ nl = node.pathname;
 291+
 292+ // Make them same
 293+ if (wl.charAt(0) == '/') wl = wl.substr(1);
 294+ if (nl.charAt(0) == '/') nl = nl.substr(1);
 295+
 296+ if (wl == nl || nl == 'blank') {
 297+ // Founded back link to reference
 298+ // Remove prepend before founded
 299+ for ( var j = 0; j <= i; j++ ) root.removeChild( nodes[0] );
 300+ break;
 301+ }
 302+ }
 303+ }
 304+
 305+
 306+ // Remove <SCRIPT> tag
 307+ nodes = root.getElementsByTagName( "SCRIPT" );
 308+
 309+ for ( i = 0; i < nodes.length; i++ ){
 310+ nodes[i].parentNode.removeChild( nodes[i] );
 311+ }
 312+
 313+ nodes = null;
 314+ }
 315+
 316+};
 317+
 318+// Displayable popup reference field
 319+// - keep settings and state of one popup field
 320+// - create elems
 321+// - control event listeners of current field
 322+// - deal with animation
 323+//
 324+function ElmEasyRefField(){
 325+
 326+ // References to important parts of popup field
 327+ this.elems = {
 328+ container: null,
 329+ frame: null,
 330+ header: null,
 331+ link: null,
 332+ close: null,
 333+ field: null,
 334+ content: null,
 335+ more: null,
 336+ corner: null
 337+ };
 338+
 339+ // Metrics data
 340+ this.metrics = {
 341+ width: 0,
 342+ height: 0
 343+ };
 344+
 345+ // Animation data
 346+ if ( elmEasyRef.animation.enable) {
 347+ this.animation = {
 348+ // Curent values
 349+ curw: 0,
 350+ curh: 0,
 351+ // Interval object
 352+ interval: null
 353+ };
 354+ }
 355+
 356+ // Pointer to attached anchor
 357+ this.anchor = null;
 358+
 359+ // Check if shown
 360+ this.is_shown = false;
 361+
 362+ //
 363+ // GENERATE DOM
 364+ //
 365+ // DOM structure:
 366+ //
 367+ // .elems.container
 368+ // |- .elemst.frame
 369+ // | |- .elems.header
 370+ // | | |- .elems.link - link to "Reference" Section
 371+ // | | |- .elems.close - close popup button
 372+ // | |
 373+ // | |- .elems.field
 374+ // | |- .elems.content - keep text of reference
 375+ // | |- .elems.more - expand button
 376+ // |
 377+ // |- .elm-easyref-corner
 378+
 379+ var el = this.elems.container = document.createElement( "div" );
 380+ el.className = "elm-easyref-container";
 381+ el.style.display = "none";
 382+ el.style.visibility = "hidden";
 383+ el.style.position = "absolute";
 384+
 385+ // Create frame
 386+ el = this.elems.frame = document.createElement( "div" );
 387+ el.className = "elm-easyref-frame";
 388+ this.elems.container.appendChild( el );
 389+
 390+ // Create corner
 391+ el = this.elems.corner = document.createElement( "div" );
 392+ el.className = "elm-easyref-corner-l";
 393+ this.elems.container.appendChild( el );
 394+
 395+ // Create header
 396+ el = this.elems.header = document.createElement( "div" );
 397+ el.className = "elm-easyref-header";
 398+ this.elems.frame.appendChild( el );
 399+
 400+ // Create "link" button
 401+ el = this.elems.link = document.createElement( "a" );
 402+ el.href = "#";
 403+ el.className = "elm-easyref-link";
 404+ this.elems.header.appendChild( el );
 405+
 406+ // Create "close" button
 407+ el = this.elems.close = document.createElement( "a" );
 408+ el.href = "#";
 409+ el.className = "elm-easyref-close";
 410+ el.title = elmEasyRef.messages.elm_easyref_close;
 411+ this.elems.header.appendChild( el );
 412+
 413+ // Create field
 414+ el = this.elems.field = document.createElement( "div" );
 415+ el.className = "elm-easyref-field";
 416+ this.elems.frame.appendChild( el );
 417+
 418+ // Create content - will keep content of reference
 419+ el = this.elems.content = document.createElement( "div" );
 420+ el.className = "elm-easyref-content";
 421+ this.elems.field.appendChild( el );
 422+
 423+ // Create "more" button
 424+ el = this.elems.more = document.createElement( "div" );
 425+ el.className = "elm-easyref-more";
 426+ el.innerHTML = '<a href="#">...</a>';
 427+ this.elems.field.appendChild( el );
 428+
 429+ // Set size of "More" button
 430+ el.style.width = ( elmEasyRef.fieldm.col_width - 2 ) + "px";
 431+
 432+ // Append container to document
 433+ document.getElementById( elmEasyRef.bodyContentId ).appendChild( this.elems.container );
 434+
 435+ //
 436+ // ADD EVENT LISTENERS
 437+ //
 438+
 439+ // hide popup
 440+ elm_addEvent( this.elems.close, 'click', this.closeButtonListener );
 441+ elm_addEvent( this.elems.link, 'click', this.linkButtonListener );
 442+
 443+ // expand popup
 444+ elm_addEvent( this.elems.more, 'click', this.moreButtonListener );
 445+
 446+}
 447+
 448+// Set label of link to "References" Section
 449+//
 450+ElmEasyRefField.prototype.setRefLink = function( num, href ){
 451+ this.elems.link.href = href;
 452+ this.elems.link.innerHTML = elmEasyRef.messages.elm_easyref_ref.replace( "$1", num );
 453+};
 454+
 455+// Set text of reference
 456+ElmEasyRefField.prototype.setInnerNode = function( html ){
 457+ this.elems.content.innerHTML = html;
 458+};
 459+
 460+
 461+
 462+// Show this field (collapse mode) and calc width
 463+//
 464+ElmEasyRefField.prototype.show = function(){
 465+ var cont = this.elems.container;
 466+
 467+ // Prepare
 468+ cont.style.display = "block";
 469+ cont.style.visibility = "hidden";
 470+
 471+ // Calc metrics
 472+
 473+ // Change width to default
 474+ this.elems.field.style.width = elmEasyRef.fieldm.col_width + "px";
 475+ // Get text width
 476+ this.metrics.width = this.elems.content.clientWidth;
 477+ if ( this.metrics.width < elmEasyRef.fieldm.min_width ) {
 478+ this.metrics.width = elmEasyRef.fieldm.min_width;
 479+ }
 480+ // Apply new width
 481+ this.elems.field.style.width = this.metrics.width + "px";
 482+ this.elems.frame.style.width = this.metrics.width + "px";
 483+
 484+
 485+ // Get text height
 486+ this.metrics.height = this.elems.content.clientHeight;
 487+ if ( this.metrics.height > elmEasyRef.fieldm.col_height ) {
 488+ // More button
 489+ this.metrics.height = elmEasyRef.fieldm.col_height;
 490+ this.elems.more.style.display = "block";
 491+ this.elems.more.style.visibility = "visible";
 492+ } else {
 493+ if ( this.metrics.height < elmEasyRef.fieldm.min_height ) {
 494+ this.metrics.height = elmEasyRef.fieldm.min_height;
 495+ }
 496+ this.elems.more.style.display = "none";
 497+ this.elems.more.style.visibility = "hidden";
 498+ }
 499+ // Apply new height
 500+ this.elems.field.style.height = this.metrics.height + "px";
 501+
 502+ // Position
 503+ this.updatePos();
 504+
 505+ // Scroll to it
 506+ this.scrollDownToMe();
 507+
 508+ // Animation
 509+ if ( this.animation) {
 510+ this.animation.curw = elmEasyRef.fieldm.min_width;
 511+ this.animation.curh = elmEasyRef.fieldm.min_height;
 512+ this.startAnimation();
 513+ }
 514+
 515+
 516+
 517+ // Make visible now
 518+ cont.style.visibility = "visible";
 519+ this.is_shown = true;
 520+
 521+
 522+};
 523+
 524+
 525+// Attach this popup to node
 526+// If node will change position, popup should change it too
 527+//
 528+ElmEasyRefField.prototype.attachToAnchor = function( node ){
 529+ this.anchor = node;
 530+};
 531+
 532+// Calculate anchor positon relatively of contentBody element
 533+//
 534+ElmEasyRefField.prototype.calcAnchorPos = function(){
 535+ var ret = { x: this.anchor.offsetLeft, y: this.anchor.offsetTop },
 536+ parent = this.anchor.offsetParent;
 537+
 538+ while ( parent && parent.id != elmEasyRef.bodyContentId ){
 539+ ret.x += parent.offsetLeft;
 540+ ret.y += parent.offsetTop;
 541+ parent = parent.offsetParent;
 542+ }
 543+ return ret;
 544+};
 545+
 546+// Update position of popup field and corner position
 547+//
 548+ElmEasyRefField.prototype.updatePos = function(){
 549+ var cont = this.elems.container;
 550+
 551+ var anchpos = this.calcAnchorPos(),
 552+ x = anchpos.x + Math.round( this.anchor.offsetWidth / 2 ),
 553+ y = anchpos.y + this.anchor.offsetHeight,
 554+ d = cont.offsetParent.offsetWidth - x - cont.clientWidth;
 555+
 556+ if ( d < 0) {
 557+ // Need to shift corner
 558+ x += d;
 559+ this.elems.corner.style.left = (-d) + "px";
 560+ if ( cont.clientWidth + d < this.elems.corner.clientWidth ||
 561+ d / cont.clientWidth < -0.5 ){
 562+
 563+ // Show right corner
 564+ this.elems.corner.className = "elm-easyref-corner-r";
 565+ } else {
 566+
 567+ // Show left corner
 568+ this.elems.corner.className = "elm-easyref-corner-l";
 569+ }
 570+ } else {
 571+ // Show left corner without offset
 572+ this.elems.corner.style.left = '';
 573+ this.elems.corner.className = "elm-easyref-corner-l";
 574+ }
 575+
 576+ cont.style.left = (x) + "px";
 577+ cont.style.top = (y) + "px";
 578+
 579+};
 580+
 581+// Scroll down to this popup
 582+//
 583+ElmEasyRefField.prototype.scrollDownToMe = function(){
 584+ var cont = this.elems.container;
 585+ if ( cont.getBoundingClientRect && window.scrollTo ){
 586+ var bound = cont.getBoundingClientRect(),
 587+ wsize = elm_getWindowSize(),
 588+ wscroll = elm_getWindowScroll();
 589+ if ( wsize && wscroll && bound.bottom > wsize.y ){
 590+ // If supported
 591+ window.scrollTo( wscroll.x, wscroll.y + bound.bottom - wsize.y + 10 );
 592+ }
 593+ }
 594+};
 595+
 596+// Change to expand mode
 597+//
 598+ElmEasyRefField.prototype.expand = function( node ){
 599+ var cont = this.elems.container;
 600+
 601+ // Hide more button
 602+ this.elems.more.style.visibility = "hidden";
 603+ this.elems.more.style.display = "none";
 604+
 605+ // Calc metrics
 606+
 607+ // Get text width
 608+ this.metrics.width = elmEasyRef.fieldm.exp_width;
 609+ // Apply new width
 610+ this.elems.field.style.width = this.metrics.width + "px";
 611+ this.elems.frame.style.width = this.metrics.width + "px";
 612+
 613+
 614+ // Get text height
 615+ this.metrics.height = this.elems.content.clientHeight;
 616+ if ( this.metrics.height > elmEasyRef.fieldm.exp_height ) {
 617+ // Add scroll
 618+ this.metrics.height = elmEasyRef.fieldm.exp_height;
 619+ this.elems.field.style.overflow = "auto";
 620+ }
 621+
 622+ // Apply new height
 623+ this.elems.field.style.height = this.metrics.height + "px";
 624+
 625+ // Position
 626+ this.updatePos();
 627+
 628+ // Scroll to it
 629+ this.scrollDownToMe();
 630+
 631+ // Animation
 632+ if ( this.animation) {
 633+ this.animation.curw = elmEasyRef.fieldm.col_width;
 634+ this.animation.curh = elmEasyRef.fieldm.col_height;
 635+ this.startAnimation();
 636+ }
 637+
 638+
 639+
 640+};
 641+
 642+// Clear expand mode
 643+ElmEasyRefField.prototype.removeExpandStyles = function(){
 644+ this.elems.field.style.overflow = "";
 645+ this.elems.field.scrollTop = 0;
 646+}
 647+
 648+// Hide this popup
 649+//
 650+ElmEasyRefField.prototype.hide = function(){
 651+ this.finishAnimation();
 652+
 653+ var cont = this.elems.container;
 654+ cont.style.left = "-1000px";
 655+ cont.style.top = "-1000px";
 656+ cont.style.visibility = "hidden";
 657+ // cont.style.display = "none";
 658+ this.removeExpandStyles();
 659+
 660+ this.is_shown = false;
 661+
 662+};
 663+
 664+// Close button listener - close this popup
 665+//
 666+ElmEasyRefField.prototype.closeButtonListener = function( event ){
 667+ if ( elmEasyRef.refField ) elmEasyRef.refField.hide();
 668+ event.preventDefault();
 669+};
 670+
 671+// Link button listener - goto reference section and close this popup
 672+//
 673+ElmEasyRefField.prototype.linkButtonListener = function( event ){
 674+ if ( elmEasyRef.refField ) elmEasyRef.refField.hide();
 675+};
 676+
 677+// More button listener - expand this popup
 678+//
 679+ElmEasyRefField.prototype.moreButtonListener = function( event ){
 680+ if ( elmEasyRef.refField ) elmEasyRef.refField.expand();
 681+ event.preventDefault();
 682+};
 683+
 684+// Check if node belong to popup field frame
 685+// (If user click on such elems, popou should not to close)
 686+// Return true, if node belongs to field frame
 687+//
 688+ElmEasyRefField.prototype.isInsideField = function( node ) {
 689+ var rf = elmEasyRef.refField;
 690+ if ( !rf ) return false;
 691+
 692+ while ( node ){
 693+ if ( node == rf.elems.frame ) return true;
 694+ node = node.parentNode;
 695+ }
 696+
 697+ return false;
 698+};
 699+
 700+// Start animation and do first step
 701+// this.animation curw and curh should be already set
 702+//
 703+ElmEasyRefField.prototype.startAnimation = function(){
 704+ if ( this.animation ){
 705+ if ( !this.animation.interval ) {
 706+ this.animation.interval = setInterval( this.stepAnimation, elmEasyRef.animation.delay );
 707+ }
 708+ this.stepAnimation();
 709+ }
 710+};
 711+
 712+// Next step of animation
 713+// Stop animation when
 714+// rf.metrics.width == rf.animation.curw and
 715+// rf.metrics.height == rf.animation.curh
 716+//
 717+ElmEasyRefField.prototype.stepAnimation = function(){
 718+ var rf = elmEasyRef.refField;
 719+ if ( rf ){
 720+ var chg = false;
 721+
 722+ // Force browser redisplay div
 723+ rf.elems.container.style.visibility = "hidden";
 724+
 725+ // Change width
 726+ // Will be changed FRAME width
 727+ var d = ( rf.metrics.width - rf.animation.curw ) / elmEasyRef.animation.stepw;
 728+ if ( d > 0.5){
 729+ rf.animation.curw += d;
 730+ rf.elems.frame.style.width = Math.round( rf.animation.curw ) + "px";
 731+ chg = true;
 732+ }
 733+
 734+ // Change height
 735+ // Will be changed FIELD height
 736+ d = ( rf.metrics.height - rf.animation.curh ) / elmEasyRef.animation.steph;
 737+ if ( d > 0.5 ){
 738+ rf.animation.curh += d;
 739+ rf.elems.field.style.height = Math.round( rf.animation.curh ) + "px";
 740+ chg = true;
 741+ }
 742+
 743+ if ( !chg ) rf.finishAnimation();
 744+
 745+ // Update pos
 746+ rf.updatePos();
 747+
 748+ // Force browser redisplay div
 749+ rf.elems.container.style.visibility = "visible";
 750+ }
 751+};
 752+
 753+// Stop animation
 754+//
 755+ElmEasyRefField.prototype.finishAnimation = function(){
 756+ if ( this.animation ){
 757+ this.elems.content.style.wordWrap = "";
 758+ this.elems.content.style.wordBreak = "";
 759+ this.elems.frame.style.width = this.metrics.width + "px";
 760+ this.elems.field.style.height = this.metrics.height + "px";
 761+ if ( this.animation.interval ) clearInterval( this.animation.interval );
 762+ this.animation.interval = null;
 763+ }
 764+};
Property changes on: trunk/extensions/ElmEasyRef/js/elmEasyRef.js
___________________________________________________________________
Added: svn:eol-style
1765 + native
Index: trunk/extensions/ElmEasyRef/js/elmEasyRef-min.js
@@ -0,0 +1,11 @@
 2+/*
 3+ * ElmEasyRef v 0.8.2b:
 4+ * Add popup field to display reference's content
 5+ * When user click on reference he would be not jumped down to "References" section.
 6+ * Text will be shown in popup field
 7+ *
 8+ * This is compressed version of elmEasyRef.js
 9+ *
 10+ * author: Elancev Michael
 11+ */
 12+function elm_addEvent(d,c,b){if(d.addEventListener){d.addEventListener(c,b,false)}else{var a=d;d.attachEvent("on"+c,function(){var e={target:window.event.srcElement,currentTarget:a,ctrlKey:window.event.ctrlKey,keyCode:window.event.keyCode,eventObj:window.event,preventDefault:function(){this.eventObj.returnValue=false},stopPropagation:function(){this.eventObj.cancelBubble=true}};return b.apply(a,[e])})}}function elm_hasClass(e,f){var c=e.className;if(c==f){return true}var a=/\s+/;if(!a.test(c)){return false}var d=c.split(a);for(var b=0;b<d.length;b++){if(d[b]==f){return true}}return false}function elm_getElementsByClassName(b,e){if(b.getElementsByClassName){return b.getElementsByClassName(e)}else{var c=b.getElementsByTagName("*");if(!e){return c}var d=[];for(var a=0;a<c.length;a++){if(elm_hasClass(c[a],e)){d.push(c[a])}}return d}}function elm_getWindowSize(){if(typeof(window.innerWidth)=="number"){return{x:window.innerWidth,y:window.innerHeight}}else{if(document.documentElement&&typeof(document.documentElement.clientWidth)=="number"){return{x:document.documentElement.clientWidth,y:document.documentElement.clientHeight}}else{return false}}}function elm_getWindowScroll(){if(typeof(window.pageYOffset)=="number"){return{x:window.pageXOffset,y:window.pageYOffset}}else{if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){return{x:document.body.scrollLeft,y:document.body.scrollTop}}else{if(document.documentElement&&typeof(document.documentElement.scrollLeft)=="number"){return{x:document.documentElement.scrollLeft,y:document.documentElement.scrollTop}}else{return false}}}}var elmEasyRef={debug:false,references:null,refField:null,refText:null,bodyContentId:"bodyContent",regRefNum_rp:/(<.*?>)/,regRefNum_mt:/([0-9]+)/,messages:{elm_easyref_ref:"Reference $1",elm_easyref_close:"Close"},animation:{enable:true,delay:50,stepw:2,steph:3},fieldm:{min_width:140,min_height:40,col_width:400,col_height:140,exp_width:400,exp_height:380},lastRef:null,prepare:function(){var c=document.getElementById(this.bodyContentId);if(!c){if(this.debug){alert("bodyContent node not found")}return}var a=elm_getElementsByClassName(c,"reference");for(var b=0;b<a.length;b++){if(a[b].firstChild&&a[b].firstChild.tagName=="A"){elm_addEvent(a[b].firstChild,"click",this.refClickListener)}}if(a.length){this.references=elm_getElementsByClassName(c,"references")[0];if(!this.references){if(this.debug){alert("References block not found")}return}this.refText=document.createElement("div")}elm_addEvent(document.body,"mousedown",function(d){if(elmEasyRef.refField&&elmEasyRef.refField.is_shown&&elmEasyRef.lastRef!=d.target&&!elmEasyRef.refField.isInsideField(d.target)){elmEasyRef.refField.hide()}});elm_addEvent(window,"resize",function(d){if(elmEasyRef.refField&&elmEasyRef.refField.is_shown){elmEasyRef.refField.updatePos()}})},refClickListener:function(b){var c=b.currentTarget,a=elmEasyRef.refField;if(elmEasyRef.lastRef==c&&a&&a.is_shown){a.hide()}else{if(!elmEasyRef.showRefField(c)){return}}b.preventDefault();elmEasyRef.lastRef=c},showRefField:function(b){var a=document.getElementById(b.hash.substr(1));if(!a){if(this.debug){alert("Reference content not found")}return false}this.refText.innerHTML=a.innerHTML;this.cutUselessNodes(this.refText);if(!this.refField){this.refField=new ElmEasyRefField()}this.refField.setRefLink(this.getRefNum(b),b.href);this.refField.setInnerNode(this.refText.innerHTML);this.refField.attachToAnchor(b);this.refField.show();this.refText.innerHTML="";return true},getRefNum:function(b){var a=String(b.innerHTML).replace(this.regRefNum_rp,"");a=this.regRefNum_mt.exec(a);return(a?a[0]:0)},cutUselessNodes:function(b){var c=b.childNodes;var e;for(e=c.length-1;e>=0;e--){var f=null;if(c[e].tagName=="A"){f=c[e]}else{if(c[e].firstChild&&c[e].firstChild.tagName=="A"){f=c[e].firstChild}}if(f&&f.hash){var g=window.location.pathname,a=f.pathname;if(g.charAt(0)=="/"){g=g.substr(1)}if(a.charAt(0)=="/"){a=a.substr(1)}if(g==a||a=="blank"){for(var d=0;d<=e;d++){b.removeChild(c[0])}break}}}c=b.getElementsByTagName("SCRIPT");for(e=0;e<c.length;e++){c[e].parentNode.removeChild(c[e])}c=null}};function ElmEasyRefField(){this.elems={container:null,frame:null,header:null,link:null,close:null,field:null,content:null,more:null,corner:null};this.metrics={width:0,height:0};if(elmEasyRef.animation.enable){this.animation={curw:0,curh:0,interval:null}}this.anchor=null;this.is_shown=false;var a=this.elems.container=document.createElement("div");a.className="elm-easyref-container";a.style.display="none";a.style.visibility="hidden";a.style.position="absolute";a=this.elems.frame=document.createElement("div");a.className="elm-easyref-frame";this.elems.container.appendChild(a);a=this.elems.corner=document.createElement("div");a.className="elm-easyref-corner-l";this.elems.container.appendChild(a);a=this.elems.header=document.createElement("div");a.className="elm-easyref-header";this.elems.frame.appendChild(a);a=this.elems.link=document.createElement("a");a.href="#";a.className="elm-easyref-link";this.elems.header.appendChild(a);a=this.elems.close=document.createElement("a");a.href="#";a.className="elm-easyref-close";a.title=elmEasyRef.messages.elm_easyref_close;this.elems.header.appendChild(a);a=this.elems.field=document.createElement("div");a.className="elm-easyref-field";this.elems.frame.appendChild(a);a=this.elems.content=document.createElement("div");a.className="elm-easyref-content";this.elems.field.appendChild(a);a=this.elems.more=document.createElement("div");a.className="elm-easyref-more";a.innerHTML='<a href="#">...</a>';this.elems.field.appendChild(a);a.style.width=(elmEasyRef.fieldm.col_width-2)+"px";document.getElementById(elmEasyRef.bodyContentId).appendChild(this.elems.container);elm_addEvent(this.elems.close,"click",this.closeButtonListener);elm_addEvent(this.elems.link,"click",this.linkButtonListener);elm_addEvent(this.elems.more,"click",this.moreButtonListener)}ElmEasyRefField.prototype.setRefLink=function(b,a){this.elems.link.href=a;this.elems.link.innerHTML=elmEasyRef.messages.elm_easyref_ref.replace("$1",b)};ElmEasyRefField.prototype.setInnerNode=function(a){this.elems.content.innerHTML=a};ElmEasyRefField.prototype.show=function(){var a=this.elems.container;a.style.display="block";a.style.visibility="hidden";this.elems.field.style.width=elmEasyRef.fieldm.col_width+"px";this.metrics.width=this.elems.content.clientWidth;if(this.metrics.width<elmEasyRef.fieldm.min_width){this.metrics.width=elmEasyRef.fieldm.min_width}this.elems.field.style.width=this.metrics.width+"px";this.elems.frame.style.width=this.metrics.width+"px";this.metrics.height=this.elems.content.clientHeight;if(this.metrics.height>elmEasyRef.fieldm.col_height){this.metrics.height=elmEasyRef.fieldm.col_height;this.elems.more.style.display="block";this.elems.more.style.visibility="visible"}else{if(this.metrics.height<elmEasyRef.fieldm.min_height){this.metrics.height=elmEasyRef.fieldm.min_height}this.elems.more.style.display="none";this.elems.more.style.visibility="hidden"}this.elems.field.style.height=this.metrics.height+"px";this.updatePos();this.scrollDownToMe();if(this.animation){this.animation.curw=elmEasyRef.fieldm.min_width;this.animation.curh=elmEasyRef.fieldm.min_height;this.startAnimation()}a.style.visibility="visible";this.is_shown=true};ElmEasyRefField.prototype.attachToAnchor=function(a){this.anchor=a};ElmEasyRefField.prototype.calcAnchorPos=function(){var a={x:this.anchor.offsetLeft,y:this.anchor.offsetTop},b=this.anchor.offsetParent;while(b&&b.id!=elmEasyRef.bodyContentId){a.x+=b.offsetLeft;a.y+=b.offsetTop;b=b.offsetParent}return a};ElmEasyRefField.prototype.updatePos=function(){var b=this.elems.container;var c=this.calcAnchorPos(),a=c.x+Math.round(this.anchor.offsetWidth/2),f=c.y+this.anchor.offsetHeight,e=b.offsetParent.offsetWidth-a-b.clientWidth;if(e<0){a+=e;this.elems.corner.style.left=(-e)+"px";if(b.clientWidth+e<this.elems.corner.clientWidth||e/b.clientWidth<-0.5){this.elems.corner.className="elm-easyref-corner-r"}else{this.elems.corner.className="elm-easyref-corner-l"}}else{this.elems.corner.style.left="";this.elems.corner.className="elm-easyref-corner-l"}b.style.left=(a)+"px";b.style.top=(f)+"px"};ElmEasyRefField.prototype.scrollDownToMe=function(){var a=this.elems.container;if(a.getBoundingClientRect&&window.scrollTo){var c=a.getBoundingClientRect(),b=elm_getWindowSize(),d=elm_getWindowScroll();if(b&&d&&c.bottom>b.y){window.scrollTo(d.x,d.y+c.bottom-b.y+10)}}};ElmEasyRefField.prototype.expand=function(b){var a=this.elems.container;this.elems.more.style.visibility="hidden";this.elems.more.style.display="none";this.metrics.width=elmEasyRef.fieldm.exp_width;this.elems.field.style.width=this.metrics.width+"px";this.elems.frame.style.width=this.metrics.width+"px";this.metrics.height=this.elems.content.clientHeight;if(this.metrics.height>elmEasyRef.fieldm.exp_height){this.metrics.height=elmEasyRef.fieldm.exp_height;this.elems.field.style.overflow="auto"}this.elems.field.style.height=this.metrics.height+"px";this.updatePos();this.scrollDownToMe();if(this.animation){this.animation.curw=elmEasyRef.fieldm.col_width;this.animation.curh=elmEasyRef.fieldm.col_height;this.startAnimation()}};ElmEasyRefField.prototype.removeExpandStyles=function(){this.elems.field.style.overflow="";this.elems.field.scrollTop=0};ElmEasyRefField.prototype.hide=function(){this.finishAnimation();var a=this.elems.container;a.style.left="-1000px";a.style.top="-1000px";a.style.visibility="hidden";this.removeExpandStyles();this.is_shown=false};ElmEasyRefField.prototype.closeButtonListener=function(a){if(elmEasyRef.refField){elmEasyRef.refField.hide()}a.preventDefault()};ElmEasyRefField.prototype.linkButtonListener=function(a){if(elmEasyRef.refField){elmEasyRef.refField.hide()}};ElmEasyRefField.prototype.moreButtonListener=function(a){if(elmEasyRef.refField){elmEasyRef.refField.expand()}a.preventDefault()};ElmEasyRefField.prototype.isInsideField=function(b){var a=elmEasyRef.refField;if(!a){return false}while(b){if(b==a.elems.frame){return true}b=b.parentNode}return false};ElmEasyRefField.prototype.startAnimation=function(){if(this.animation){if(!this.animation.interval){this.animation.interval=setInterval(this.stepAnimation,elmEasyRef.animation.delay)}this.stepAnimation()}};ElmEasyRefField.prototype.stepAnimation=function(){var a=elmEasyRef.refField;if(a){var b=false;a.elems.container.style.visibility="hidden";var c=(a.metrics.width-a.animation.curw)/elmEasyRef.animation.stepw;if(c>0.5){a.animation.curw+=c;a.elems.frame.style.width=Math.round(a.animation.curw)+"px";b=true}c=(a.metrics.height-a.animation.curh)/elmEasyRef.animation.steph;if(c>0.5){a.animation.curh+=c;a.elems.field.style.height=Math.round(a.animation.curh)+"px";b=true}if(!b){a.finishAnimation()}a.updatePos();a.elems.container.style.visibility="visible"}};ElmEasyRefField.prototype.finishAnimation=function(){if(this.animation){this.elems.content.style.wordWrap="";this.elems.content.style.wordBreak="";this.elems.frame.style.width=this.metrics.width+"px";this.elems.field.style.height=this.metrics.height+"px";if(this.animation.interval){clearInterval(this.animation.interval)}this.animation.interval=null}};
\ No newline at end of file
Property changes on: trunk/extensions/ElmEasyRef/js/elmEasyRef-min.js
___________________________________________________________________
Added: svn:eol-style
113 + native
Index: trunk/extensions/ElmEasyRef/README
@@ -0,0 +1,15 @@
 2+--------------------------------------------------------------------------
 3+README for the ElmEasyRef extension
 4+Copyright © 2011 by Elancev Michael
 5+--------------------------------------------------------------------------
 6+
 7+The ElmEasyRef extension adds popup field to display reference's content.
 8+It doesn't provide <ref> tags, so you should intall Cite extension first.
 9+
 10+To install this extension, add the following lines at the end of LocalSettings.php file:
 11+
 12+ # ElmEasyRef Extension
 13+ require_once("$IP/extensions/ElmEasyRef/ElmEasyRef.php");
 14+
 15+Full instructions, screenshots and link to demo can be founded here:
 16+<http://www.mediawiki.org/wiki/Extension:ElmEasyRef>

Follow-up revisions

RevisionCommit summaryAuthorDate
r87655Followup r87650: Add description message...raymond20:16, 7 May 2011
r87656Followup r87650/r87655 fix extension creditsraymond20:35, 7 May 2011

Status & tagging log