blob: e10b4c899fa9ead577778ec6ba64f6f4d3d348a3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
|
/**
* SMW Text DataItem JavaScript representation
*
* @see SMW\DIGeoCoord
*
* Implementation of dataitems that are geographic coordinates.
*
* @file
* @ingroup SMW
*
* @licence GNU GPL v2 or later
* @author Peter Grassberger < petertheone@gmail.com >
*/
( function( $, mw, smw ) {
'use strict';
/**
* Inheritance class for the smw.dataItem constructor
*
* @class
* @abstract
*/
smw.dataItem = smw.dataItem || {};
/**
* Number constructor
*
* @param {string}
* @param {string}
* @return {this}
*/
var geo = function ( geo, type ) {
this.geo = geo !== {} ? geo : null;
// If the type is not specified we assume it has to be '_geo'
this.type = type !== '' && type !== undefined ? type : '_geo';
return this;
};
/**
* Class constructor
*
* @class
* @constructor
* @extends smw.dataItem
*/
smw.dataItem.geo = function( geo, type ) {
if ( $.type( geo ) === 'object' ) {
this.constructor( geo, type );
} else {
throw new Error( 'smw.dataItem.geo: invoked text must be a string but is of type ' + $.type( geo ) );
}
};
/* Public methods */
var fn = {
constructor: geo,
/**
* Returns type
*
* @return {string}
*/
getDIType: function() {
return this.type;
},
/**
* Returns a plain geo representation
*
* @return {string}
*/
getGeo: function() {
return this.geo;
}
};
// Alias
fn.getValue = fn.getGeo;
fn.getString = fn.getGeo;
// Assign methods
smw.dataItem.geo.prototype = fn;
} )( jQuery, mediaWiki, semanticMediaWiki );
|