[MediaWiki-commits] [Gerrit] [coordinate.js] Implemented coordinateinput widget - change (mediawiki...DataValues)

2013-05-30 Thread Henning Snater (Code Review)
Henning Snater has uploaded a new change for review.

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


Change subject: [coordinate.js] Implemented coordinateinput widget
..

[coordinate.js] Implemented coordinateinput widget

The coordinateinput jQuery widget extends an input element with the ability 
to handle
coordinate values.

Change-Id: I3cecd8e16719215d633537f57801c79082278328
---
M ValueView/ValueView.resources.mw.php
M ValueView/ValueView.tests.qunit.php
A ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
A 
ValueView/tests/qunit/jquery.coordinate/jquery.coordinate.coordinateinput.tests.js
4 files changed, 216 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/68/66068/1

diff --git a/ValueView/ValueView.resources.mw.php 
b/ValueView/ValueView.resources.mw.php
index 34f707f..11a4406 100644
--- a/ValueView/ValueView.resources.mw.php
+++ b/ValueView/ValueView.resources.mw.php
@@ -89,6 +89,17 @@
)
),
 
+   'jquery.coordinate.coordinateinput' = $moduleTemplate + array(
+   'scripts' = array(
+   
'jquery.coordinate/jquery.coordinate.coordinateinput.js',
+   ),
+   'dependencies' = array(
+   'jquery.ui.widget',
+   'jquery.eachchange',
+   'coordinate.js',
+   ),
+   ),
+
'jquery.time.timeinput' = $moduleTemplate + array(
'scripts' = array(
'jquery.time/jquery.time.timeinput.js',
diff --git a/ValueView/ValueView.tests.qunit.php 
b/ValueView/ValueView.tests.qunit.php
index 5760f42..0da1fec 100644
--- a/ValueView/ValueView.tests.qunit.php
+++ b/ValueView/ValueView.tests.qunit.php
@@ -63,6 +63,15 @@
),
),
 
+   'jquery.coordinate.coordinateinput.tests' = array(
+   'scripts' = array(
+   
$bp/jquery.coordinate/jquery.coordinate.coordinateinput.tests.js,
+   ),
+   'dependencies' = array(
+   'jquery.coordinate.coordinateinput',
+   ),
+   ),
+
'jquery.time.timeinput.tests' = array(
'scripts' = array(

$bp/jquery.time/jquery.time.timeinput.tests.js,
diff --git 
a/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js 
b/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
new file mode 100644
index 000..82ba4ef
--- /dev/null
+++ b/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
@@ -0,0 +1,110 @@
+/**
+ * Input element that interprets coordinate values.
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater  mediaw...@snater.com 
+ *
+ * @event update: Triggered whenever the widget's value is updated.
+ *(1) {jQuery.Event}
+ *(2) {coordinate.Coordinate|null} New value (null for no or an 
invalid value) the widget's
+ *value has been changed to.
+ *
+ * @dependency jQuery.Widget
+ * @dependency jQuery.eachchange
+ * @dependency coordinate.Coordinate
+ */
+( function( $, Coordinate ) {
+   'use strict';
+
+   $.widget( 'coordinate.coordinateinput', {
+   /**
+* Caches the widget's current value.
+* @type {coordinate.Coordinate|null}
+*/
+   _value: null,
+
+   /**
+* @see jQuery.Widget._create
+*/
+   _create: function() {
+   var self = this;
+
+   this.element.addClass( this.widgetName );
+
+   this.element.eachchange( function( event, oldValue ) {
+   var value = self._parse();
+   if( value !== self._value ) {
+   self._value = value;
+   self._trigger( 'update', null, 
[self._value] );
+   }
+   } );
+   },
+
+   /**
+* @see jQuery.Widget.destroy
+*/
+   destroy: function() {
+   this.element.removeClass( this.widgetName );
+   $.Widget.prototype.destroy.call( this );
+   },
+
+   /**
+* Parses the current input value.
+*
+* @return {coordinate.Coordinate|null} Coordinate object when 
parsing was successful.
+*/
+   _parse: function() {
+   var coordinateValue;
+
+   

[MediaWiki-commits] [Gerrit] [coordinate.js] Implemented coordinateinput widget - change (mediawiki...DataValues)

2013-05-30 Thread Daniel Werner (Code Review)
Daniel Werner has submitted this change and it was merged.

Change subject: [coordinate.js] Implemented coordinateinput widget
..


[coordinate.js] Implemented coordinateinput widget

The coordinateinput jQuery widget extends an input element with the ability 
to handle
coordinate values.

Change-Id: I3cecd8e16719215d633537f57801c79082278328
---
M ValueView/ValueView.resources.mw.php
M ValueView/ValueView.tests.qunit.php
A ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
A 
ValueView/tests/qunit/jquery.coordinate/jquery.coordinate.coordinateinput.tests.js
4 files changed, 216 insertions(+), 0 deletions(-)

Approvals:
  Daniel Werner: Checked; Looks good to me, approved
  jenkins-bot: Verified



diff --git a/ValueView/ValueView.resources.mw.php 
b/ValueView/ValueView.resources.mw.php
index 34f707f..11a4406 100644
--- a/ValueView/ValueView.resources.mw.php
+++ b/ValueView/ValueView.resources.mw.php
@@ -89,6 +89,17 @@
)
),
 
+   'jquery.coordinate.coordinateinput' = $moduleTemplate + array(
+   'scripts' = array(
+   
'jquery.coordinate/jquery.coordinate.coordinateinput.js',
+   ),
+   'dependencies' = array(
+   'jquery.ui.widget',
+   'jquery.eachchange',
+   'coordinate.js',
+   ),
+   ),
+
'jquery.time.timeinput' = $moduleTemplate + array(
'scripts' = array(
'jquery.time/jquery.time.timeinput.js',
diff --git a/ValueView/ValueView.tests.qunit.php 
b/ValueView/ValueView.tests.qunit.php
index 5760f42..0da1fec 100644
--- a/ValueView/ValueView.tests.qunit.php
+++ b/ValueView/ValueView.tests.qunit.php
@@ -63,6 +63,15 @@
),
),
 
+   'jquery.coordinate.coordinateinput.tests' = array(
+   'scripts' = array(
+   
$bp/jquery.coordinate/jquery.coordinate.coordinateinput.tests.js,
+   ),
+   'dependencies' = array(
+   'jquery.coordinate.coordinateinput',
+   ),
+   ),
+
'jquery.time.timeinput.tests' = array(
'scripts' = array(

$bp/jquery.time/jquery.time.timeinput.tests.js,
diff --git 
a/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js 
b/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
new file mode 100644
index 000..82ba4ef
--- /dev/null
+++ b/ValueView/resources/jquery.coordinate/jquery.coordinate.coordinateinput.js
@@ -0,0 +1,110 @@
+/**
+ * Input element that interprets coordinate values.
+ *
+ * @licence GNU GPL v2+
+ * @author H. Snater  mediaw...@snater.com 
+ *
+ * @event update: Triggered whenever the widget's value is updated.
+ *(1) {jQuery.Event}
+ *(2) {coordinate.Coordinate|null} New value (null for no or an 
invalid value) the widget's
+ *value has been changed to.
+ *
+ * @dependency jQuery.Widget
+ * @dependency jQuery.eachchange
+ * @dependency coordinate.Coordinate
+ */
+( function( $, Coordinate ) {
+   'use strict';
+
+   $.widget( 'coordinate.coordinateinput', {
+   /**
+* Caches the widget's current value.
+* @type {coordinate.Coordinate|null}
+*/
+   _value: null,
+
+   /**
+* @see jQuery.Widget._create
+*/
+   _create: function() {
+   var self = this;
+
+   this.element.addClass( this.widgetName );
+
+   this.element.eachchange( function( event, oldValue ) {
+   var value = self._parse();
+   if( value !== self._value ) {
+   self._value = value;
+   self._trigger( 'update', null, 
[self._value] );
+   }
+   } );
+   },
+
+   /**
+* @see jQuery.Widget.destroy
+*/
+   destroy: function() {
+   this.element.removeClass( this.widgetName );
+   $.Widget.prototype.destroy.call( this );
+   },
+
+   /**
+* Parses the current input value.
+*
+* @return {coordinate.Coordinate|null} Coordinate object when 
parsing was successful.
+*/
+   _parse: function() {
+   var coordinateValue;
+
+   try {
+