r83652 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r83651‎ | r83652 | r83653 >
Date:16:06, 10 March 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on googlemaps3 form input
Modified paths:
  • /branches/SemanticMaps0.8/SemanticMaps.i18n.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php (modified) (history)
  • /branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js (modified) (history)

Diff [purge]

Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php
@@ -24,7 +24,7 @@
2525 }
2626
2727 $wgResourceModules['ext.sm.fi.googlemaps3'] = array(
28 - 'dependencies' => array( 'ext.maps.googlemaps3', 'jquery.ui.resizable', 'jquery.ui.button', 'jquery.ui.dialog' ),
 28+ 'dependencies' => array( 'ext.maps.googlemaps3', 'jquery.ui.button', 'jquery.ui.dialog' ),
2929 'localBasePath' => dirname( __FILE__ ),
3030 'remoteBasePath' => $smgScriptPath . '/includes/services/GoogleMaps3',
3131 'group' => 'ext.semanticmaps',
@@ -35,6 +35,7 @@
3636 'messages' => array(
3737 'semanticmaps-forminput-remove',
3838 'semanticmaps-forminput-add',
 39+ 'semanticmaps-forminput-locations'
3940 )
4041 );
4142
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js
@@ -10,6 +10,8 @@
1111 */
1212
1313 (function( $ ){ $.fn.googlemapsinput = function( mapDivId, options ) {
 14+ this.attr( { 'class': "ui-widget" } ).css( { 'width': 'auto' } );
 15+
1416 this.html(
1517 $( '<div />' ).css( {
1618 'display': 'none'
@@ -18,50 +20,90 @@
1921
2022 updateInputValue( buildInputValue( options.locations ) );
2123
22 - var table = $( '<table />' ).attr( { 'class' : 'mapinput' } );
 24+ var table = $( '<table />' ).attr( { 'class' : 'mapinput ui-widget ui-widget-content' } );
2325
 26+ table.append(
 27+ '<thread><tr class="ui-widget-header "><th colspan="2">' + mediaWiki.msg( 'semanticmaps-forminput-locations' ) + '</th></tr></thead><tbody>'
 28+ );
 29+
 30+ this.append( table );
 31+
2432 for ( i in options.locations ) {
25 - table.append(
26 - '<tr><td>' +
27 - locationToDMS( options.locations[i].lat, options.locations[i].lon ) +
28 - '</td><td>' +
29 - '<button>' + mediaWiki.msg( 'semanticmaps-forminput-remove' ) + '</button>' +
30 - '</td></tr>'
31 - );
 33+ appendTableRow( i, options.locations[i].lat, options.locations[i].lon );
3234 }
3335
 36+ var rowNr = options.locations.length;
 37+
3438 table.append(
35 - '<tr><td width="300px">' +
36 - '<input type="text" class="text ui-widget-content ui-corner-all" />' +
 39+ '<tr id="' + mapDivId + '_addrow"><td width="300px">' +
 40+ '<input type="text" class="text ui-widget-content ui-corner-all" width="95%" />' +
3741 '</td><td>' +
38 - '<button>' + mediaWiki.msg( 'semanticmaps-forminput-add' ) + '</button>' +
39 - '</td></tr>'
40 -
 42+ '<button id="' + mapDivId + '_addbutton">' + mediaWiki.msg( 'semanticmaps-forminput-add' ) + '</button>' +
 43+ '</td></tr></tbody>'
4144 );
4245
4346 this.append(
44 - table
45 - );
46 -
47 - /*
48 - this.append(
4947 $( '<div />' )
5048 .attr( {
5149 'id': mapDivId,
 50+ 'class': 'ui-widget ui-widget-content'
 51+ } )
 52+ .css( {
5253 'width': options.width,
5354 'height': options.height
54 - } )
 55+ } )
 56+ .googlemaps( options )
5557 );
56 - */
5758
58 - $( "button", ".mapinput" ).button();
 59+ $( "#" + mapDivId + '_addbutton' ).button().click( onAddButtonClick );
5960
60 - //$('#' + mapDivId).googlemaps( options ).resizable();
 61+ function onAddButtonClick() {
 62+ var addRow = $( '#' + mapDivId + '_addrow' );
 63+
 64+ addRow.remove();
 65+ appendTableRow( rowNr, 0, 0 ); // TODO
 66+ table.append( addRow );
 67+ $( "#" + mapDivId + '_addbutton' ).button().click( onAddButtonClick );
 68+ rowNr++;
 69+
 70+ updateInput();
 71+ return false;
 72+ }
6173
 74+ function onRemoveButtonClick() {
 75+ $( '#' + mapDivId + '_row_' + $( this ).attr( 'rowid' ) ).remove();
 76+ updateInput();
 77+ return false;
 78+ }
 79+
 80+ //$('#' + mapDivId);
 81+
 82+ function appendTableRow( i, lat, lon ) {
 83+ table.append(
 84+ '<tr id="' + mapDivId + '_row_' + i + '"><td>' +
 85+ locationToDMS( lat, lon ) +
 86+ '</td><td>' +
 87+ '<button class="forminput-remove" rowid="' + i + '" id="' + mapDivId + '_addbutton_' + i + '">' +
 88+ mediaWiki.msg( 'semanticmaps-forminput-remove' ) +
 89+ '</button>' +
 90+ '</td></tr>'
 91+ );
 92+
 93+ $( "#" + mapDivId + '_addbutton_' + i ).button().click( onRemoveButtonClick );
 94+ }
 95+
6296 function locationToDMS ( lat, lon ) { // TODO: i18n
6397 return Math.abs( lat ) + '° ' + ( lat < 0 ? 'S' : 'N' ) + ', ' + Math.abs( lon ) + '° ' + ( lon < 0 ? 'W' : 'E' );
6498 }
6599
 100+ function updateInput() {
 101+ var locations = [];
 102+
 103+ //$( '' ).each();
 104+
 105+ updateInputValue( buildInputValue( locations ) );
 106+ }
 107+
66108 function updateInputValue( value ) {
67109 $( '#' + mapDivId + '_values' ).text( value );
68110 }
Index: branches/SemanticMaps0.8/SemanticMaps.i18n.php
@@ -32,6 +32,7 @@
3333 'semanticmaps_notfound' => 'not found',
3434 'semanticmaps-forminput-remove' => 'Remove',
3535 'semanticmaps-forminput-add' => 'Add',
 36+ 'semanticmaps-forminput-locations' => 'Locations',
3637
3738 // Parameter descriptions
3839 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map',

Status & tagging log