Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/SM_GoogleMaps3.php |
— | — | @@ -24,7 +24,7 @@ |
25 | 25 | } |
26 | 26 | |
27 | 27 | $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' ), |
29 | 29 | 'localBasePath' => dirname( __FILE__ ), |
30 | 30 | 'remoteBasePath' => $smgScriptPath . '/includes/services/GoogleMaps3', |
31 | 31 | 'group' => 'ext.semanticmaps', |
— | — | @@ -35,6 +35,7 @@ |
36 | 36 | 'messages' => array( |
37 | 37 | 'semanticmaps-forminput-remove', |
38 | 38 | 'semanticmaps-forminput-add', |
| 39 | + 'semanticmaps-forminput-locations' |
39 | 40 | ) |
40 | 41 | ); |
41 | 42 | |
Index: branches/SemanticMaps0.8/includes/services/GoogleMaps3/jquery.googlemapsinput.js |
— | — | @@ -10,6 +10,8 @@ |
11 | 11 | */ |
12 | 12 | |
13 | 13 | (function( $ ){ $.fn.googlemapsinput = function( mapDivId, options ) { |
| 14 | + this.attr( { 'class': "ui-widget" } ).css( { 'width': 'auto' } ); |
| 15 | + |
14 | 16 | this.html( |
15 | 17 | $( '<div />' ).css( { |
16 | 18 | 'display': 'none' |
— | — | @@ -18,50 +20,90 @@ |
19 | 21 | |
20 | 22 | updateInputValue( buildInputValue( options.locations ) ); |
21 | 23 | |
22 | | - var table = $( '<table />' ).attr( { 'class' : 'mapinput' } ); |
| 24 | + var table = $( '<table />' ).attr( { 'class' : 'mapinput ui-widget ui-widget-content' } ); |
23 | 25 | |
| 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 | + |
24 | 32 | 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 ); |
32 | 34 | } |
33 | 35 | |
| 36 | + var rowNr = options.locations.length; |
| 37 | + |
34 | 38 | 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%" />' + |
37 | 41 | '</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>' |
41 | 44 | ); |
42 | 45 | |
43 | 46 | this.append( |
44 | | - table |
45 | | - ); |
46 | | - |
47 | | - /* |
48 | | - this.append( |
49 | 47 | $( '<div />' ) |
50 | 48 | .attr( { |
51 | 49 | 'id': mapDivId, |
| 50 | + 'class': 'ui-widget ui-widget-content' |
| 51 | + } ) |
| 52 | + .css( { |
52 | 53 | 'width': options.width, |
53 | 54 | 'height': options.height |
54 | | - } ) |
| 55 | + } ) |
| 56 | + .googlemaps( options ) |
55 | 57 | ); |
56 | | - */ |
57 | 58 | |
58 | | - $( "button", ".mapinput" ).button(); |
| 59 | + $( "#" + mapDivId + '_addbutton' ).button().click( onAddButtonClick ); |
59 | 60 | |
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 | + } |
61 | 73 | |
| 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 | + |
62 | 96 | function locationToDMS ( lat, lon ) { // TODO: i18n |
63 | 97 | return Math.abs( lat ) + '° ' + ( lat < 0 ? 'S' : 'N' ) + ', ' + Math.abs( lon ) + '° ' + ( lon < 0 ? 'W' : 'E' ); |
64 | 98 | } |
65 | 99 | |
| 100 | + function updateInput() { |
| 101 | + var locations = []; |
| 102 | + |
| 103 | + //$( '' ).each(); |
| 104 | + |
| 105 | + updateInputValue( buildInputValue( locations ) ); |
| 106 | + } |
| 107 | + |
66 | 108 | function updateInputValue( value ) { |
67 | 109 | $( '#' + mapDivId + '_values' ).text( value ); |
68 | 110 | } |
Index: branches/SemanticMaps0.8/SemanticMaps.i18n.php |
— | — | @@ -32,6 +32,7 @@ |
33 | 33 | 'semanticmaps_notfound' => 'not found', |
34 | 34 | 'semanticmaps-forminput-remove' => 'Remove', |
35 | 35 | 'semanticmaps-forminput-add' => 'Add', |
| 36 | + 'semanticmaps-forminput-locations' => 'Locations', |
36 | 37 | |
37 | 38 | // Parameter descriptions |
38 | 39 | 'semanticmaps_paramdesc_format' => 'The mapping service used to generate the map', |